Browse Source

添加界面登出功能

lixiang 11 months ago
parent
commit
88fb4d096c

+ 1 - 1
Venus/Framework/UICore/DeviceControl/AITSignalTower.xaml

@@ -27,7 +27,7 @@
                     <Setter Property="Image.Opacity"  Value="0.2"/>
                     <Style.Triggers>
                         <DataTrigger Binding="{Binding ElementName=signalTower,Path=IsRedLightOn}"  Value="True">
-                            <Setter Property="Image.Opacity"  Value="1"/>
+                            <Setter Property="Image.Opacity"  Value="0.7"/>
                         </DataTrigger>
                     </Style.Triggers>
                 </Style>

+ 22 - 6
Venus/Venus_MainPages/ViewModels/TopViewModel.cs

@@ -17,6 +17,7 @@ using System.Windows.Media;
 using System.Windows.Threading;
 using Venus_Core;
 using Venus_MainPages.Unity;
+using Venus_MainPages.Views;
 
 namespace Venus_MainPages.ViewModels
 {
@@ -55,7 +56,7 @@ namespace Venus_MainPages.ViewModels
         private bool m_TMIsInstalled;
         private bool m_EFEMIsInstalled;
 
-        private List<eEvent> stopEntityId = new List<eEvent>() 
+        private List<eEvent> stopEntityId = new List<eEvent>()
         {
             eEvent.ERR_MATCH,
             eEvent.ERR_RF,
@@ -158,8 +159,8 @@ namespace Venus_MainPages.ViewModels
         public string HostCommunicationStatus
         {
             get { return m_HostCommunicationStatus; }
-            set 
-            { 
+            set
+            {
                 SetProperty(ref m_HostCommunicationStatus, value);
             }
         }
@@ -285,7 +286,11 @@ namespace Venus_MainPages.ViewModels
         private DelegateCommand _ExcludeInfoCommand;
         public DelegateCommand ExcludeInfoCommand =>
                  _ExcludeInfoCommand ?? (_ExcludeInfoCommand = new DelegateCommand(OnExcludeInfo));
-        
+
+        private DelegateCommand _LogoutCommand;
+        public DelegateCommand LogoutCommand =>
+                 _LogoutCommand ?? (_LogoutCommand = new DelegateCommand(OnLogout));
+
         #endregion
 
         #region 构造函数
@@ -332,7 +337,7 @@ namespace Venus_MainPages.ViewModels
         {
             TimeTick = DateTime.Now.ToString();
             RtDataValues = QueryDataClient.Instance.Service.PollData(m_RtDataKeys);
-            
+
             SignalTowerData = CommonFunction.GetValue<AITSignalTowerData>(RtDataValues, $"System.SignalTower.DeviceData");
             HostCommunicationStatus = CommonFunction.GetValue<String>(RtDataValues, "System.CommunicationStatus");
             //IsEnableEnable = FACommunicationState == CommunicationState.Disabled;
@@ -428,7 +433,7 @@ namespace Venus_MainPages.ViewModels
                         if (eventItem.Level == EventLevel.Alarm)
                         {
                             alarmQuery.Enqueue(eventItem);
-                            if (m_ConfigType==ConfigType.Kepler2200)
+                            if (m_ConfigType == ConfigType.Kepler2200)
                             {
                                 if (stopEntityId.Contains((eEvent)eventItem.Id) && eventItem.Source.Contains("PM"))
                                 {
@@ -502,6 +507,17 @@ namespace Venus_MainPages.ViewModels
         {
             IsExcludeInfoType = !IsExcludeInfoType;
         }
+
+        private void OnLogout()
+        {
+            var _mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is Window) as Window;
+            LoginView heaterView = new LoginView(false);
+            heaterView.Width = 1555;
+            heaterView.Height = 874;
+            heaterView.WindowStartupLocation = WindowStartupLocation.CenterScreen;
+            heaterView.Owner = _mainWindow;
+            heaterView.Show();
+        }
         #endregion
 
     }

+ 88 - 85
Venus/Venus_MainPages/Views/LoginView.xaml

@@ -11,97 +11,100 @@
              xmlns:customControls="clr-namespace:Venus_Themes.CustomControls;assembly=Venus_Themes"
              WindowStartupLocation="CenterScreen"           
              Width="1920" Height="1080">
-    <Grid>
-        <Image   Source="Pack://application:,,,/Venus_Themes;Component/Resources/Login.png" Stretch="Fill"/>
-        <Border Width="500" Height="650" Background="#FFFFFF" Margin="100 200 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1" BorderBrush="Silver" CornerRadius="15,15,15,15">
-            <Grid Margin="50 0 0 0">
-                <Grid.RowDefinitions>
-                    <RowDefinition/>
-                    <RowDefinition/>
-                    <RowDefinition/>
-                    <RowDefinition Height="30"/>
-                    <RowDefinition/>
-                    <RowDefinition Height="30"/>
-                    <RowDefinition/>
-                    <RowDefinition/>
-                    <RowDefinition/>
-                    <RowDefinition/>
-                </Grid.RowDefinitions>
-                <Image Source="Pack://application:,,,/Venus_Themes;Component/Resources/JetLogo.png" HorizontalAlignment="Left" Width="154" Height="14"></Image>
-                <TextBlock Grid.Row="1" Text="Login"                                       FontSize="42" FontFamily="D-DIN" Foreground="#222222" FontWeight="Bold"/>
-                <TextBlock Grid.Row="2" Text="Welcome back! Please login to your account." FontSize="16" FontFamily="D-DIN" Foreground="#999999"/>
-                <TextBlock Grid.Row="3" Text="UserName"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
-                <TextBox  x:Name="UserTextBox" Grid.Row="4" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="16" VerticalContentAlignment="Center" Padding="20 0 0 0" Foreground="Gray" Text="admin" KeyDown="UserTextBox_KeyDown">
-                    <TextBox.Resources>
-                        <VisualBrush x:Key="WaterText" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Center" AlignmentY="Center">
-                            <VisualBrush.Visual>
-                                <TextBlock  Text="please enter your name"/>
-                            </VisualBrush.Visual>
-                        </VisualBrush>
-                        <Style TargetType="{x:Type Border}">
-                            <Setter Property="CornerRadius" Value="8"/>
-                            <Setter Property="BorderBrush" Value="#c1d0dc"/>
-                        </Style>
+    <Viewbox>
+        <Grid>
+            <Image   Source="Pack://application:,,,/Venus_Themes;Component/Resources/Login.png" Stretch="Fill" Width="1920" Height="1080"/>
+            <Border Width="500" Height="650" Background="#FFFFFF" Margin="100 200 0 0" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="1" BorderBrush="Silver" CornerRadius="15,15,15,15">
+                <Grid Margin="50 0 0 0">
+                    <Grid.RowDefinitions>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition Height="30"/>
+                        <RowDefinition/>
+                        <RowDefinition Height="30"/>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                    </Grid.RowDefinitions>
+                    <Image Source="Pack://application:,,,/Venus_Themes;Component/Resources/JetLogo.png" HorizontalAlignment="Left" Width="154" Height="14"></Image>
+                    <TextBlock Grid.Row="1" Text="Login"                                       FontSize="42" FontFamily="D-DIN" Foreground="#222222" FontWeight="Bold"/>
+                    <TextBlock Grid.Row="2" Text="Welcome back! Please login to your account." FontSize="16" FontFamily="D-DIN" Foreground="#999999"/>
+                    <TextBlock Grid.Row="3" Text="UserName"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
+                    <TextBox  x:Name="UserTextBox" Grid.Row="4" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="16" VerticalContentAlignment="Center" Padding="20 0 0 0" Foreground="Gray" Text="admin" KeyDown="UserTextBox_KeyDown">
+                        <TextBox.Resources>
+                            <VisualBrush x:Key="WaterText" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Center" AlignmentY="Center">
+                                <VisualBrush.Visual>
+                                    <TextBlock  Text="please enter your name"/>
+                                </VisualBrush.Visual>
+                            </VisualBrush>
+                            <Style TargetType="{x:Type Border}">
+                                <Setter Property="CornerRadius" Value="8"/>
+                                <Setter Property="BorderBrush" Value="#c1d0dc"/>
+                            </Style>
 
-                    </TextBox.Resources>
-                    <TextBox.Style>
-                     
-                        <Style TargetType="TextBox">
-                            <Style.Triggers>
-                                <Trigger Property="Text" Value="{x:Null}">
-                                    <Setter Property="Background" Value="{StaticResource WaterText}"/>
-                                </Trigger>
-                                <Trigger Property="Text" Value="">
-                                    <Setter Property="Background" Value="{StaticResource WaterText}"/>
-                                </Trigger>
-                            </Style.Triggers>
-                        </Style>
-                    </TextBox.Style>
-                </TextBox>
-                <TextBlock Grid.Row="5" Text="Password"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
-                <customControls:CustomPasswordBox  x:Name="PassWordTextBox" Grid.Row="6" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="16" VerticalContentAlignment="Center" Padding="20 5 0 0" Foreground="Gray" KeyDown="PassWordTextBox_KeyDown">
-                    <customControls:CustomPasswordBox.Resources>
-                        <VisualBrush x:Key="WaterText" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Center" AlignmentY="Center">
-                            <VisualBrush.Visual>
-                                <TextBlock  Text="please enter your password"/>
-                            </VisualBrush.Visual>
-                        </VisualBrush>
-                        <Style TargetType="{x:Type Border}">
-                            <Setter Property="CornerRadius" Value="8"/>
-                            <Setter Property="BorderBrush" Value="#c1d0dc"/>
-                        </Style>
-                    </customControls:CustomPasswordBox.Resources>
-                    <customControls:CustomPasswordBox.Style>
+                        </TextBox.Resources>
+                        <TextBox.Style>
 
-                        <Style TargetType="TextBox">
-                            <Style.Triggers>
-                                <Trigger Property="Text" Value="{x:Null}">
-                                    <Setter Property="Background" Value="{StaticResource WaterText}"/>
-                                </Trigger>
-                                <Trigger Property="Text" Value="">
-                                    <Setter Property="Background" Value="{StaticResource WaterText}"/>
-                                </Trigger>
-                            </Style.Triggers>
-                        </Style>
-                    </customControls:CustomPasswordBox.Style>
-                </customControls:CustomPasswordBox>
-                <TextBlock Grid.Row="7" Text="Role"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
-                <customControls:CustomComBobox x:Name="MangerComboBox" Grid.Row="8" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Top"  CustomCornerRadius="4" Margin="0 -30 0 0" SelectedIndex="0" FontSize="16" BorderBrush="Silver" BorderThickness="1">
-                    <ComboBoxItem>Manager</ComboBoxItem>
-                    <ComboBoxItem>Engineer</ComboBoxItem>
-                    <ComboBoxItem>Technician</ComboBoxItem>
-                    <ComboBoxItem>Operator</ComboBoxItem>
-                </customControls:CustomComBobox>
-                <customControls:PathButton Grid.Row="9" Width="400" Height="40" Content="Login"          Command="{Binding LoginCommand}"   HorizontalAlignment="Left"    VerticalAlignment="Top"   Click="Login_Click" />
+                            <Style TargetType="TextBox">
+                                <Style.Triggers>
+                                    <Trigger Property="Text" Value="{x:Null}">
+                                        <Setter Property="Background" Value="{StaticResource WaterText}"/>
+                                    </Trigger>
+                                    <Trigger Property="Text" Value="">
+                                        <Setter Property="Background" Value="{StaticResource WaterText}"/>
+                                    </Trigger>
+                                </Style.Triggers>
+                            </Style>
+                        </TextBox.Style>
+                    </TextBox>
+                    <TextBlock Grid.Row="5" Text="Password"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
+                    <customControls:CustomPasswordBox  x:Name="PassWordTextBox" Grid.Row="6" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Center"  FontSize="16" VerticalContentAlignment="Center" Padding="20 5 0 0" Foreground="Gray" KeyDown="PassWordTextBox_KeyDown">
+                        <customControls:CustomPasswordBox.Resources>
+                            <VisualBrush x:Key="WaterText" TileMode="None" Opacity="0.3" Stretch="None" AlignmentX="Center" AlignmentY="Center">
+                                <VisualBrush.Visual>
+                                    <TextBlock  Text="please enter your password"/>
+                                </VisualBrush.Visual>
+                            </VisualBrush>
+                            <Style TargetType="{x:Type Border}">
+                                <Setter Property="CornerRadius" Value="8"/>
+                                <Setter Property="BorderBrush" Value="#c1d0dc"/>
+                            </Style>
+                        </customControls:CustomPasswordBox.Resources>
+                        <customControls:CustomPasswordBox.Style>
 
-            </Grid>
-        </Border>
+                            <Style TargetType="TextBox">
+                                <Style.Triggers>
+                                    <Trigger Property="Text" Value="{x:Null}">
+                                        <Setter Property="Background" Value="{StaticResource WaterText}"/>
+                                    </Trigger>
+                                    <Trigger Property="Text" Value="">
+                                        <Setter Property="Background" Value="{StaticResource WaterText}"/>
+                                    </Trigger>
+                                </Style.Triggers>
+                            </Style>
+                        </customControls:CustomPasswordBox.Style>
+                    </customControls:CustomPasswordBox>
+                    <TextBlock Grid.Row="7" Text="Role"                                    FontSize="16" FontFamily="D-DIN" Foreground="#666666"/>
+                    <customControls:CustomComBobox x:Name="MangerComboBox" Grid.Row="8" Height="40" Width="400" HorizontalAlignment="Left" VerticalAlignment="Top"  CustomCornerRadius="4" Margin="0 -30 0 0" SelectedIndex="0" FontSize="16" BorderBrush="Silver" BorderThickness="1">
+                        <ComboBoxItem>Manager</ComboBoxItem>
+                        <ComboBoxItem>Engineer</ComboBoxItem>
+                        <ComboBoxItem>Technician</ComboBoxItem>
+                        <ComboBoxItem>Operator</ComboBoxItem>
+                    </customControls:CustomComBobox>
+                    <customControls:PathButton Grid.Row="9" Width="400" Height="40" x:Name="logButton"         Command="{Binding LoginCommand}"   HorizontalAlignment="Left"    VerticalAlignment="Top"   Click="Login_Click" />
 
-        <userControl:PathButton Width="15" Height="15" Cursor="Hand"
+                </Grid>
+            </Border>
+
+            <userControl:PathButton Width="15" Height="15" Cursor="Hand"
                                 PathData="{StaticResource Icon_Close}" 
                                 Margin="1880 -1000 0 0" 
-                                DefaultFillBrush="White"
+                                DefaultFillBrush="DimGray"
                                 MouseOverBrush="Yellow"
                                 IsPressedBrush="Blue" Click="Close_Click"/>
-    </Grid>
+        </Grid>
+
+    </Viewbox>
 </Window>

+ 37 - 2
Venus/Venus_MainPages/Views/LoginView.xaml.cs

@@ -15,9 +15,20 @@ namespace Venus_MainPages.Views
 
         public bool IsLoginSuccess { get; set; }
         public User CurrentUser { get; set; }
-        public LoginView()
+        private bool _isLogin;
+        public LoginView(bool isLogin=true)
         {
             InitializeComponent();
+            _isLogin = isLogin;
+            if (isLogin)
+            {
+                logButton.Content = "Login";
+            }
+            else
+            {
+                logButton.Content = "Logout";
+                //MangerComboBox.IsEnabled = false;
+            }
         }
 
         private void Close_Click(object sender, RoutedEventArgs e)
@@ -34,7 +45,15 @@ namespace Venus_MainPages.Views
         {
             if (e.Key == Key.Return)
             {
-                Login();
+                if (_isLogin)
+                {
+                    Login();
+
+                }
+                else
+                {
+                    Logout();
+                }
             }          
         }
         private void UserTextBox_KeyDown(object sender, KeyEventArgs e)
@@ -63,5 +82,21 @@ namespace Venus_MainPages.Views
             this.Close();
 
         }
+        private void Logout()
+        {
+            if (UserTextBox.Text != "admin")
+            {
+                IsLoginSuccess = false;
+                WPFMessageBox.ShowError("用户名错误");
+                return;
+            }
+            if (PassWordTextBox.Password != "admin")
+            {
+                IsLoginSuccess = false;
+                WPFMessageBox.ShowError("密码错误");
+                return;
+            }
+            Environment.Exit(0); // 0 表示正常退出
+        }
     }
 }

+ 1 - 1
Venus/Venus_MainPages/Views/TopView.xaml

@@ -123,7 +123,7 @@
                 <Path Data="{StaticResource Icon_User}" Stretch="Fill" StrokeThickness="1"  Fill="#333333"  Width="20" Height="20" Canvas.Left="20" Canvas.Top="10"></Path>
                 <TextBlock Text="admin" Canvas.Left="48" Canvas.Top="9" />
 
-                <customControls:PathButton  Content="Logout"   BorderThickness="1"  BorderBrush="Red"           Command="{Binding SkipCommand}"  Width="90"    FontSize="15"  Height="28" Canvas.Left="120" Canvas.Top="7" Background="White" Foreground="Red" Padding="-6 -2 0 0"/>
+                <customControls:PathButton  Content="Logout"   BorderThickness="1"  BorderBrush="Red"           Command="{Binding LogoutCommand}"  Width="90"    FontSize="15"  Height="28" Canvas.Left="120" Canvas.Top="7" Background="White" Foreground="Red" Padding="-6 -2 0 0"/>
 
 
                 <RadioButton Content="Host Disable"   Canvas.Left="20"  Canvas.Top="40" Width="100" Height="25" Style="{StaticResource Button_RadioButton}"   IsChecked="{Binding IsEnableEnable}"    GroupName="Host" FontSize="13" Command="{Binding FADisableCommand}"/>