@@ -101,6 +101,8 @@ | |||||
<None Remove="Image\文字.png" /> | <None Remove="Image\文字.png" /> | ||||
<None Remove="Image\日历.png" /> | <None Remove="Image\日历.png" /> | ||||
<None Remove="Image\日期1.png" /> | <None Remove="Image\日期1.png" /> | ||||
<None Remove="Image\智慧城市科技风登录页面.png" /> | |||||
<None Remove="Image\智慧城市科技风登录页面边框.png" /> | |||||
<None Remove="Image\有告警.png" /> | <None Remove="Image\有告警.png" /> | ||||
<None Remove="Image\标题背景.png" /> | <None Remove="Image\标题背景.png" /> | ||||
<None Remove="Image\环形切图\内圈\未选中.png" /> | <None Remove="Image\环形切图\内圈\未选中.png" /> | ||||
@@ -219,6 +221,8 @@ | |||||
<Resource Include="Image\告警\轻微告警.png" /> | <Resource Include="Image\告警\轻微告警.png" /> | ||||
<Resource Include="Image\工艺流程.jpg" /> | <Resource Include="Image\工艺流程.jpg" /> | ||||
<Resource Include="Image\工艺流程.png" /> | <Resource Include="Image\工艺流程.png" /> | ||||
<Resource Include="Image\智慧城市科技风登录页面.png" /> | |||||
<Resource Include="Image\智慧城市科技风登录页面边框.png" /> | |||||
<Resource Include="Image\界面2.png"> | <Resource Include="Image\界面2.png"> | ||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||||
</Resource> | </Resource> | ||||
@@ -12,7 +12,7 @@ | |||||
Height="1080" | Height="1080" | ||||
AllowsTransparency="True" | AllowsTransparency="True" | ||||
Background="{x:Null}" | Background="{x:Null}" | ||||
Topmost="True" | |||||
Topmost="False" | |||||
WindowStartupLocation="CenterScreen" | WindowStartupLocation="CenterScreen" | ||||
WindowStyle="None" | WindowStyle="None" | ||||
mc:Ignorable="d"> | mc:Ignorable="d"> | ||||
@@ -154,7 +154,7 @@ | |||||
Margin="10,0" | Margin="10,0" | ||||
HorizontalAlignment="Left" | HorizontalAlignment="Left" | ||||
VerticalAlignment="Center" | VerticalAlignment="Center" | ||||
FontSize="20" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
Foreground="#88009dff" | Foreground="#88009dff" | ||||
Text="请输入账号名称" | Text="请输入账号名称" | ||||
Visibility="Collapsed" /> | Visibility="Collapsed" /> | ||||
@@ -282,9 +282,11 @@ | |||||
Grid.Row="1" | Grid.Row="1" | ||||
Margin="20,20" | Margin="20,20" | ||||
BorderBrush="#009DFF" | BorderBrush="#009DFF" | ||||
Name="Username" | |||||
BorderThickness="3" | BorderThickness="3" | ||||
FontSize="30" | FontSize="30" | ||||
Foreground="#009DFF" | Foreground="#009DFF" | ||||
KeyDown="TextBox_KeyDown" | |||||
Style="{DynamicResource UserTextBoxStyle}" | Style="{DynamicResource UserTextBoxStyle}" | ||||
TabIndex="1" | TabIndex="1" | ||||
Text="{Binding UserName}" /> | Text="{Binding UserName}" /> | ||||
@@ -292,6 +294,7 @@ | |||||
<PasswordBox | <PasswordBox | ||||
Name="pb" | Name="pb" | ||||
Grid.Row="2" | Grid.Row="2" | ||||
KeyDown="pb_KeyDown" | |||||
Margin="20,20" | Margin="20,20" | ||||
common:PasswordHelper.Attach="True" | common:PasswordHelper.Attach="True" | ||||
common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||||
@@ -27,35 +27,25 @@ namespace BPASmartClient.CustomResource.Pages.View | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
grid.Visibility = Visibility.Collapsed; | grid.Visibility = Visibility.Collapsed; | ||||
Username.Focus(); | |||||
Username.SelectionStart = Username.Text.Trim().Length; | |||||
this.Loaded += LoginView_Loaded; | this.Loaded += LoginView_Loaded; | ||||
this.WindowState = WindowState.Maximized; | |||||
ActionManage.GetInstance.CancelRegister("LoginOk"); | |||||
ActionManage.GetInstance.CancelRegister("ExitAction"); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk"); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = false; this.Close(); }), "ExitAction"); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk", true); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = false; this.Close(); }), "ExitAction", true); | |||||
} | } | ||||
private void LoginView_Loaded(object sender, RoutedEventArgs e) | private void LoginView_Loaded(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
string path = @"Videos\Login.mp4"; | |||||
string path = $"{AppDomain.CurrentDomain.BaseDirectory}Videos\\Login.mp4"; | |||||
if (File.Exists(path)) | if (File.Exists(path)) | ||||
{ | { | ||||
// 绑定视频文件 | |||||
player.Source = new Uri(path); | |||||
// 交互式控制 | |||||
player.LoadedBehavior = MediaState.Manual; | |||||
// 添加元素加载完成事件 -- 自动开始播放 | |||||
player.Loaded += new RoutedEventHandler(media_Loaded); | |||||
// 添加媒体播放结束事件 -- 重新播放 | |||||
player.MediaEnded += new RoutedEventHandler(media_MediaEnded); | |||||
// 添加元素卸载完成事件 -- 停止播放 | |||||
player.Unloaded += new RoutedEventHandler(media_Unloaded); | |||||
player.MediaOpened += Player_MediaOpened; | |||||
player.Source = new Uri(path); // 绑定视频文件 | |||||
this.WindowState = WindowState.Maximized; | |||||
player.LoadedBehavior = MediaState.Manual; // 交互式控制 | |||||
player.Loaded += new RoutedEventHandler(media_Loaded); // 添加元素加载完成事件 -- 自动开始播放 | |||||
player.MediaEnded += new RoutedEventHandler(media_MediaEnded); // 添加媒体播放结束事件 -- 重新播放 | |||||
player.Unloaded += new RoutedEventHandler(media_Unloaded);// 添加元素卸载完成事件 -- 停止播放 | |||||
player.MediaOpened += Player_MediaOpened;//已播放事件 | |||||
} | } | ||||
} | } | ||||
@@ -84,14 +74,17 @@ namespace BPASmartClient.CustomResource.Pages.View | |||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | ||||
{ | { | ||||
if (this.pb.Password.Length > 0) | |||||
{ | |||||
this.markText.Visibility = Visibility.Collapsed; | |||||
} | |||||
else | |||||
{ | |||||
this.markText.Visibility = Visibility.Visible; | |||||
} | |||||
this.markText.Visibility = this.pb.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible; | |||||
} | |||||
private void TextBox_KeyDown(object sender, KeyEventArgs e) | |||||
{ | |||||
if (e.Key == Key.Enter) pb.Focus(); | |||||
} | |||||
private void pb_KeyDown(object sender, KeyEventArgs e) | |||||
{ | |||||
if (e.Key == Key.Enter) ActionManage.GetInstance.Send("EnterLogin"); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -0,0 +1,327 @@ | |||||
<Window | |||||
x:Class="BPASmartClient.CustomResource.Pages.View.SubPagLoginView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:common="clr-namespace:BPASmartClient.CustomResource.Pages.Model" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | |||||
Title="SubPagLoginView" | |||||
Width="800" | |||||
Height="450" | |||||
AllowsTransparency="True" | |||||
Background="{x:Null}" | |||||
Topmost="True" | |||||
WindowStartupLocation="CenterScreen" | |||||
WindowStyle="None" | |||||
mc:Ignorable="d"> | |||||
<Window.DataContext> | |||||
<vm:LoginViewModel /> | |||||
</Window.DataContext> | |||||
<Window.Resources> | |||||
<Style x:Key="TxLogin" TargetType="TextBlock"> | |||||
<Setter Property="FontSize" Value="20" /> | |||||
<Setter Property="Foreground" Value="#ddd" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<!--#region 密码输入框样式--> | |||||
<Style x:Key="PasswordBoxStyle" TargetType="{x:Type PasswordBox}"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="FontFamily" Value="Times New Roman" /> | |||||
<Setter Property="PasswordChar" Value="●" /> | |||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" /> | |||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" /> | |||||
<Setter Property="HorizontalContentAlignment" Value="Left" /> | |||||
<Setter Property="Padding" Value="1" /> | |||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" /> | |||||
<Setter Property="AllowDrop" Value="true" /> | |||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" /> | |||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False" /> | |||||
<Setter Property="CaretBrush" Value="#009DFF" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type PasswordBox}"> | |||||
<Border | |||||
x:Name="Bd" | |||||
Background="{TemplateBinding Background}" | |||||
BorderBrush="{TemplateBinding BorderBrush}" | |||||
BorderThickness="{TemplateBinding BorderThickness}" | |||||
CornerRadius="5" | |||||
SnapsToDevicePixels="true"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="40" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
x:Name="UserTextBlock" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../../Fonts/#iconfont" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
Foreground="{TemplateBinding BorderBrush}" | |||||
Text="" /> | |||||
<!--<TextBlock | |||||
Name="markText" | |||||
Grid.Column="1" | |||||
Margin="10,0" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
FontSize="20" | |||||
Foreground="#88009dff" | |||||
Text="请输入账号密码" | |||||
Visibility="Collapsed" />--> | |||||
<ScrollViewer | |||||
x:Name="PART_ContentHost" | |||||
Grid.Column="1" | |||||
MinHeight="{TemplateBinding FontSize}" | |||||
VerticalAlignment="Center" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter TargetName="Bd" Property="Opacity" Value="0.56" /> | |||||
<Setter TargetName="UserTextBlock" Property="Opacity" Value="0.56" /> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="Bd" Property="BorderBrush" Value="#FF7EB4EA" /> | |||||
<Setter TargetName="UserTextBlock" Property="Foreground" Value="#FF7EB4EA" /> | |||||
</Trigger> | |||||
<Trigger Property="IsKeyboardFocused" Value="true"> | |||||
<Setter TargetName="Bd" Property="BorderBrush" Value="#FF569DE5" /> | |||||
<Setter TargetName="UserTextBlock" Property="Foreground" Value="#FF569DE5" /> | |||||
</Trigger> | |||||
<!--<DataTrigger Binding="{Binding Path=Password, RelativeSource={RelativeSource Mode=self}}" Value=""> | |||||
<Setter TargetName="markText" Property="Visibility" Value="Visible" /> | |||||
</DataTrigger>--> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Style.Triggers> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true" /> | |||||
<Condition Property="IsSelectionActive" Value="false" /> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" /> | |||||
</MultiTrigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
<!--#endregion--> | |||||
<!--#region 用户输入框样式--> | |||||
<Style x:Key="UserTextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="CaretBrush" Value="#009DFF" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="TextBox"> | |||||
<Border | |||||
x:Name="border" | |||||
Background="{TemplateBinding Background}" | |||||
BorderBrush="{TemplateBinding BorderBrush}" | |||||
BorderThickness="{TemplateBinding BorderThickness}" | |||||
CornerRadius="5" | |||||
SnapsToDevicePixels="true"> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="40" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
x:Name="PasswordTextBlock" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontFamily="../../Fonts/#iconfont" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
Foreground="{TemplateBinding BorderBrush}" | |||||
Text="" /> | |||||
<TextBlock | |||||
Name="markText" | |||||
Grid.Column="1" | |||||
Margin="10,0" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
FontSize="{TemplateBinding FontSize}" | |||||
Foreground="#88009dff" | |||||
Text="请输入账号名称" | |||||
Visibility="Collapsed" /> | |||||
<ScrollViewer | |||||
x:Name="PART_ContentHost" | |||||
Grid.Column="1" | |||||
MinHeight="20" | |||||
VerticalAlignment="Center" | |||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |||||
</Grid> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter TargetName="border" Property="Opacity" Value="0.56" /> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="border" Property="BorderBrush" Value="#FF7EB4EA" /> | |||||
</Trigger> | |||||
<Trigger Property="IsKeyboardFocused" Value="true"> | |||||
<Setter TargetName="border" Property="BorderBrush" Value="#FF569DE5" /> | |||||
</Trigger> | |||||
<DataTrigger Binding="{Binding Path=Text, RelativeSource={RelativeSource Mode=self}}" Value=""> | |||||
<Setter TargetName="markText" Property="Visibility" Value="Visible" /> | |||||
</DataTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
<!--#region 操作按钮样式--> | |||||
<Style x:Key="ButtonStyle" TargetType="Button"> | |||||
<Setter Property="Margin" Value="5" /> | |||||
<Setter Property="Background" Value="#cc009DFF" /> | |||||
<Setter Property="BorderThickness" Value="0" /> | |||||
<Setter Property="FontSize" Value="16" /> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="Button"> | |||||
<Border | |||||
Name="TitleBarBr" | |||||
Background="{TemplateBinding Background}" | |||||
BorderBrush="{TemplateBinding BorderBrush}" | |||||
BorderThickness="{TemplateBinding BorderThickness}" | |||||
CornerRadius="5"> | |||||
<ContentPresenter | |||||
Margin="{TemplateBinding Margin}" | |||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="TitleBarBr" Property="Background" Value="#009DFF" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</Window.Resources> | |||||
<Grid> | |||||
<Grid.Background> | |||||
<ImageBrush ImageSource="../../Image/智慧城市科技风登录页面边框.png" /> | |||||
</Grid.Background> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="1.05*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="0.9*" /> | |||||
<RowDefinition /> | |||||
<RowDefinition Height="1.2*" /> | |||||
</Grid.RowDefinitions> | |||||
<TextBlock | |||||
Grid.Column="1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#FFEF2020" | |||||
Text="{Binding ErrorInfo}" /> | |||||
<Grid | |||||
x:Name="grid" | |||||
Grid.Row="1" | |||||
Grid.Column="1"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<TextBox | |||||
Name="Username" | |||||
Margin="5,5" | |||||
BorderBrush="#009DFF" | |||||
BorderThickness="3" | |||||
FontSize="16" | |||||
Foreground="#009DFF" | |||||
KeyDown="TextBox_KeyDown" | |||||
Style="{DynamicResource UserTextBoxStyle}" | |||||
TabIndex="1" | |||||
Text="{Binding UserName}" /> | |||||
<PasswordBox | |||||
Name="pb" | |||||
Grid.Row="1" | |||||
Margin="5" | |||||
common:PasswordHelper.Attach="True" | |||||
common:PasswordHelper.Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | |||||
BorderBrush="#009DFF" | |||||
BorderThickness="3" | |||||
FontSize="16" | |||||
Foreground="#009DFF" | |||||
KeyDown="pb_KeyDown" | |||||
PasswordChanged="PasswordBox_PasswordChanged" | |||||
Style="{DynamicResource PasswordBoxStyle}" | |||||
TabIndex="2" /> | |||||
<TextBlock | |||||
Name="markText" | |||||
Grid.Row="1" | |||||
Margin="58,5" | |||||
HorizontalAlignment="Left" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="#88009dff" | |||||
IsHitTestVisible="False" | |||||
Text="请输入账号密码" | |||||
Visibility="Visible" /> | |||||
<Grid Grid.Row="2"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<Button | |||||
Command="{Binding ExitCommand}" | |||||
Content="退 出" | |||||
Style="{StaticResource ButtonStyle}" /> | |||||
<Button | |||||
Grid.Column="1" | |||||
Command="{Binding LoginCommand}" | |||||
Content="登 录" | |||||
Style="{StaticResource ButtonStyle}" | |||||
TabIndex="3" /> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
</Window> |
@@ -0,0 +1,47 @@ | |||||
using BPASmartClient.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmartClient.CustomResource.Pages.View | |||||
{ | |||||
/// <summary> | |||||
/// SubPagLoginView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class SubPagLoginView : Window | |||||
{ | |||||
public SubPagLoginView() | |||||
{ | |||||
InitializeComponent(); | |||||
Username.Focus(); | |||||
Username.SelectionStart = Username.Text.Trim().Length; | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = true; this.Close(); }), "LoginOk", true); | |||||
ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = false; this.Close(); }), "ExitAction", true); | |||||
} | |||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e) | |||||
{ | |||||
this.markText.Visibility = this.pb.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible; | |||||
} | |||||
private void TextBox_KeyDown(object sender, KeyEventArgs e) | |||||
{ | |||||
if (e.Key == Key.Enter) pb.Focus(); | |||||
} | |||||
private void pb_KeyDown(object sender, KeyEventArgs e) | |||||
{ | |||||
if (e.Key == Key.Enter) ActionManage.GetInstance.Send("EnterLogin"); | |||||
} | |||||
} | |||||
} |
@@ -15,45 +15,48 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
{ | { | ||||
public LoginViewModel() | public LoginViewModel() | ||||
{ | { | ||||
LoginCommand = new RelayCommand(() => | |||||
ActionManage.GetInstance.Register(new Action(() => { Login(); }), "EnterLogin", true); | |||||
LoginCommand = new RelayCommand(() => { Login(); }); | |||||
ExitCommand = new RelayCommand(() => | |||||
{ | { | ||||
var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName && p.Password == Password); | |||||
if (res != null) | |||||
ActionManage.GetInstance.Send("ExitAction"); | |||||
}); | |||||
} | |||||
private void Login() | |||||
{ | |||||
var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName && p.Password == Password); | |||||
if (res != null) | |||||
{ | |||||
Global.userInfo.permission = res.permission; | |||||
Global.userInfo.UserName = res.UserName; | |||||
Global.userInfo.Password = res.Password; | |||||
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++) | |||||
{ | { | ||||
Global.userInfo.permission = res.permission; | |||||
Global.userInfo.UserName = res.UserName; | |||||
Global.userInfo.Password = res.Password; | |||||
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++) | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible; | |||||
else | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | |||||
for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++) | |||||
{ | { | ||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible; | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible; | |||||
else | else | ||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | |||||
for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++) | |||||
{ | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible; | |||||
else | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed; | |||||
} | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed; | |||||
} | } | ||||
ActionManage.GetInstance.Send("LoginOk"); | |||||
} | |||||
else | |||||
{ | |||||
ErrorInfo = "用户名或密码错误!"; | |||||
} | } | ||||
}); | |||||
ExitCommand = new RelayCommand(() => | |||||
ActionManage.GetInstance.Send("PermissionChange"); | |||||
ActionManage.GetInstance.Send("LoginOk"); | |||||
} | |||||
else | |||||
{ | { | ||||
ActionManage.GetInstance.Send("ExitAction"); | |||||
}); | |||||
ErrorInfo = "用户名或密码错误!"; | |||||
} | |||||
} | } | ||||
public RelayCommand LoginCommand { get; set; } | public RelayCommand LoginCommand { get; set; } | ||||
@@ -67,7 +70,7 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
public string UserName { get { return _mUserName; } set { _mUserName = value; OnPropertyChanged(); } } | public string UserName { get { return _mUserName; } set { _mUserName = value; OnPropertyChanged(); } } | ||||
private string _mUserName = "admin"; | |||||
private string _mUserName = Global.userInfo.UserName; | |||||
public string Password { get { return _mPassword; } set { _mPassword = value; OnPropertyChanged(); } } | public string Password { get { return _mPassword; } set { _mPassword = value; OnPropertyChanged(); } } | ||||
@@ -7,6 +7,7 @@ using System.Text; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
using BPASmartClient.CustomResource.Pages.Model; | using BPASmartClient.CustomResource.Pages.Model; | ||||
using BPASmartClient.Helper; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | using Microsoft.Toolkit.Mvvm.ComponentModel; | ||||
using Microsoft.Toolkit.Mvvm.Input; | using Microsoft.Toolkit.Mvvm.Input; | ||||
@@ -18,7 +19,27 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
{ | { | ||||
NavChangedCommand = new RelayCommand<object>(DoNavChanged); | NavChangedCommand = new RelayCommand<object>(DoNavChanged); | ||||
menuModels = MenuManage.GetInstance.menuModels; | menuModels = MenuManage.GetInstance.menuModels; | ||||
PermissionChange(); | |||||
ActionManage.GetInstance.Register(new Action(() => | |||||
{ | |||||
PermissionChange(); | |||||
}), "PermissionChange"); | |||||
} | |||||
private void PermissionChange() | |||||
{ | |||||
int MainIndex = Array.FindIndex(menuModels.ToArray(), P => P.MainMenuVisibility == Visibility.Visible); | |||||
if (MainIndex >= 0 && MainIndex < menuModels.Count) | |||||
{ | |||||
int SubIndex; SubIndex = Array.FindIndex(menuModels.ElementAt(MainIndex).subMenumodels.ToArray(), p => p.SubMenuVisibility == Visibility.Visible); | |||||
if (SubIndex >= 0 && SubIndex < menuModels.ElementAt(MainIndex).subMenumodels.Count) | |||||
{ | |||||
DoNavChanged(menuModels.ElementAt(MainIndex).subMenumodels.ElementAt(SubIndex).ToggleWindowPath); | |||||
} | |||||
} | |||||
} | } | ||||
public ObservableCollection<MenuModel> menuModels { get; set; } | public ObservableCollection<MenuModel> menuModels { get; set; } | ||||
private void DoNavChanged(object obj) | private void DoNavChanged(object obj) | ||||
@@ -81,12 +81,20 @@ namespace BPASmartClient.Helper | |||||
return default; | return default; | ||||
} | } | ||||
public void Register<T>(T action, string key) | |||||
/// <summary> | |||||
/// 根据 Key 注册需要执行的委托 | |||||
/// </summary> | |||||
/// <typeparam name="T"></typeparam> | |||||
/// <param name="action">委托方法</param> | |||||
/// <param name="key">委托key</param> | |||||
/// <param name="IsAutoCancelRegister">是否自动取消注册</param> | |||||
public void Register<T>(T action, string key, bool IsAutoCancelRegister = false) | |||||
{ | { | ||||
lock (RegisterLock) | lock (RegisterLock) | ||||
{ | { | ||||
if (action != null) | if (action != null) | ||||
{ | { | ||||
if (IsAutoCancelRegister && actions.ContainsKey(key)) actions.TryRemove(key, out Delegation d); | |||||
if (!actions.ContainsKey(key)) | if (!actions.ContainsKey(key)) | ||||
{ | { | ||||
if (action is Action actionBus) | if (action is Action actionBus) | ||||
@@ -146,7 +146,7 @@ namespace BPASmartClient.DosingSystem | |||||
SubMenuName = "用户登录", | SubMenuName = "用户登录", | ||||
SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, | ||||
AssemblyName = "BPASmartClient.CustomResource", | AssemblyName = "BPASmartClient.CustomResource", | ||||
ToggleWindowPath = "Pages.View.LoginView" | |||||
ToggleWindowPath = "Pages.View.SubPagLoginView" | |||||
}); | }); | ||||
UserManager.Add(new SubMenumodel() | UserManager.Add(new SubMenumodel() | ||||
@@ -1,380 +0,0 @@ | |||||
<UserControl | |||||
x:Class="BPASmartClient.DosingSystem.View.AlarmRecordView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem.View" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
d:DesignHeight="450" | |||||
d:DesignWidth="800" | |||||
mc:Ignorable="d"> | |||||
<UserControl.DataContext> | |||||
<vm:AlarmRecordViewModel /> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary> | |||||
<!--<convert:TextDisplayConvert x:Key="textDisplayConvert" /> | |||||
<convert:IsEnableConvert x:Key="isEnableConvert" /> | |||||
<convert:AnalogAlarmConvert x:Key="analogAlarmConvert" /> | |||||
<convert:DiscreteAlarmConvert x:Key="discreteAlarmConvert" /> | |||||
<convert:AlarmTypeTextConvert x:Key="alarmTypeTextConvert" />--> | |||||
<SolidColorBrush x:Key="BorderSolid" Color="#5523CACA" /> | |||||
<SolidColorBrush x:Key="FontColor" Color="#FF2AB2E7" /> | |||||
<SolidColorBrush x:Key="TitleFontColor" Color="#ddd" /> | |||||
<SolidColorBrush x:Key="CursorColor" Color="Aqua" /> | |||||
<SolidColorBrush x:Key="TitleBorderColor" Color="#FF2AB2E7" /> | |||||
<Style x:Key="TextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="18" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="TextBoxStyle" TargetType="TextBox"> | |||||
<Setter Property="FontFamily" Value="楷体" /> | |||||
<Setter Property="FontSize" Value="22" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="{StaticResource TextBlockForeground}" /> | |||||
<Setter Property="BorderBrush" Value="#FF23CACA" /> | |||||
<Setter Property="CaretBrush" Value="Aqua" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
</Style> | |||||
<Style x:Key="DataTextBlockStyle" TargetType="TextBlock"> | |||||
<Setter Property="HorizontalAlignment" Value="Center" /> | |||||
<Setter Property="VerticalAlignment" Value="Center" /> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
<Setter Property="Foreground" Value="Red" /> | |||||
<Setter Property="FontSize" Value="14" /> | |||||
</Style> | |||||
<ControlTemplate x:Key="ButTemplate" TargetType="Button"> | |||||
<Border | |||||
x:Name="br" | |||||
Background="Transparent" | |||||
BorderBrush="#FF19B7EC" | |||||
BorderThickness="2"> | |||||
<StackPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Horizontal"> | |||||
<ContentControl | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Content="{TemplateBinding Content}" | |||||
Foreground="{TemplateBinding Foreground}" /> | |||||
</StackPanel> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter TargetName="br" Property="Background" Value="#2219B7EC" /> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</UserControl.Resources> | |||||
<Grid Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="50" /> | |||||
<RowDefinition Height="30" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<StackPanel | |||||
Margin="0,8" | |||||
HorizontalAlignment="Right" | |||||
Orientation="Horizontal"> | |||||
<DatePicker | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding StartDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入开始时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<DatePicker | |||||
Margin="20,0,20,0" | |||||
Background="Transparent" | |||||
BorderBrush="#aa3aa7f3" | |||||
BorderThickness="2" | |||||
SelectedDate="{Binding EndDateTime}" | |||||
Style="{StaticResource PickerStyle}" | |||||
Text="请输入结束时间" | |||||
Visibility="{Binding IsVisibility}" /> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding ControlCommand}" | |||||
Content="{Binding ControlButText}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
<Button | |||||
Width="140" | |||||
Height="30" | |||||
Margin="20,0,0,0" | |||||
Background="#FF19B7EC" | |||||
Command="{Binding SwitchCommand}" | |||||
Content="{Binding ButContent}" | |||||
FontFamily="楷体" | |||||
FontSize="18" | |||||
Template="{StaticResource ButTemplate}"> | |||||
<Button.Foreground> | |||||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> | |||||
<GradientStop Color="#FFBB662A" /> | |||||
<GradientStop Offset="1" Color="White" /> | |||||
</LinearGradientBrush> | |||||
</Button.Foreground> | |||||
</Button> | |||||
</StackPanel> | |||||
<!--#region 表格标题栏设置--> | |||||
<Grid Grid.Row="1" Background="#dd2AB2E7"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="ID" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警日期" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警时间" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警信息" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警值" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
FontSize="16" | |||||
Foreground="{StaticResource TitleFontColor}" | |||||
Text="报警等级" /> | |||||
<Border | |||||
BorderBrush="{StaticResource TitleBorderColor}" | |||||
BorderThickness="1,0,1,0" | |||||
Cursor="SizeWE" /> | |||||
</Grid> | |||||
</Grid> | |||||
<!--#endregion--> | |||||
<!--#region 表格数据显示--> | |||||
<ScrollViewer | |||||
Grid.Row="2" | |||||
HorizontalScrollBarVisibility="Hidden" | |||||
VerticalScrollBarVisibility="Hidden"> | |||||
<Grid> | |||||
<!--#region 实时报警信息--> | |||||
<ItemsControl ItemsSource="{Binding AlarmInfos}" Visibility="{Binding CurrentDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding NumId}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
<!--#region 历史报警信息--> | |||||
<ItemsControl ItemsSource="{Binding HistoryAlarm}" Visibility="{Binding HistoryDataVis}"> | |||||
<ItemsControl.ItemTemplate> | |||||
<DataTemplate> | |||||
<Grid x:Name="gr" Height="30"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="0.3*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition /> | |||||
<ColumnDefinition Width="0.7*" /> | |||||
<ColumnDefinition Width="0.5*" /> | |||||
</Grid.ColumnDefinitions> | |||||
<TextBlock | |||||
Grid.Column="0" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Id}" /> | |||||
<Grid Grid.Column="1"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Date}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="2" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Time}" /> | |||||
<Grid Grid.Column="3"> | |||||
<TextBlock | |||||
Margin="10,0,0,0" | |||||
HorizontalAlignment="Left" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Info}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<TextBlock | |||||
Grid.Column="4" | |||||
Style="{StaticResource DataTextBlockStyle}" | |||||
Text="{Binding Value}" /> | |||||
<Grid Grid.Column="5"> | |||||
<TextBlock Style="{StaticResource DataTextBlockStyle}" Text="{Binding Grade}" /> | |||||
<Border BorderBrush="{StaticResource BorderSolid}" BorderThickness="1,0,1,0" /> | |||||
</Grid> | |||||
<Border | |||||
Grid.ColumnSpan="6" | |||||
BorderBrush="{StaticResource BorderSolid}" | |||||
BorderThickness="1" /> | |||||
</Grid> | |||||
<DataTemplate.Triggers> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter TargetName="gr" Property="Background" Value="#112AB2E7" /> | |||||
</Trigger> | |||||
</DataTemplate.Triggers> | |||||
</DataTemplate> | |||||
</ItemsControl.ItemTemplate> | |||||
</ItemsControl> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</UserControl> |
@@ -1,28 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | |||||
/// <summary> | |||||
/// AlarmRecordView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class AlarmRecordView : UserControl | |||||
{ | |||||
public AlarmRecordView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -1,251 +0,0 @@ | |||||
<Window | |||||
x:Class="BPASmartClient.DosingSystem.View.MainWindow" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.DosingSystem" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" | |||||
xmlns:vm="clr-namespace:BPASmartClient.DosingSystem.ViewModel" | |||||
Title="MainWindow" | |||||
Width="1300" | |||||
Height="800" | |||||
AllowsTransparency="True" | |||||
Background="{x:Null}" | |||||
Topmost="False" | |||||
WindowStartupLocation="CenterScreen" | |||||
WindowStyle="None" | |||||
mc:Ignorable="d"> | |||||
<Window.Resources> | |||||
<ResourceDictionary> | |||||
<ResourceDictionary.MergedDictionaries> | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" /> | |||||
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" /> | |||||
<ResourceDictionary> | |||||
<!--#region ListBox样式--> | |||||
<Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}"> | |||||
<Setter Property="OverridesDefaultStyle" Value="True" /> | |||||
<Setter Property="SnapsToDevicePixels" Value="True" /> | |||||
<Setter Property="BorderBrush" Value="{x:Null}" /> | |||||
<Setter Property="Foreground" Value="White" /> | |||||
<Setter Property="FontSize" Value="20" /> | |||||
<Setter Property="HorizontalContentAlignment" Value="Center" /> | |||||
<Setter Property="VerticalContentAlignment" Value="Center" /> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ListBoxItem}"> | |||||
<Border x:Name="border" CornerRadius="8"> | |||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | |||||
</Border> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<!--#endregion--> | |||||
</ResourceDictionary> | |||||
</ResourceDictionary.MergedDictionaries> | |||||
</ResourceDictionary> | |||||
</Window.Resources> | |||||
<Window.DataContext> | |||||
<vm:MainViewModel /> | |||||
</Window.DataContext> | |||||
<Border x:Name="br" Style="{DynamicResource border主窗体背景}"> | |||||
<Grid> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="60" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<!-- 标题 --> | |||||
<Grid Grid.Row="0"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="300" /> | |||||
<ColumnDefinition /> | |||||
</Grid.ColumnDefinitions> | |||||
<Border | |||||
Grid.ColumnSpan="2" | |||||
Height="52" | |||||
VerticalAlignment="Top" | |||||
Style="{DynamicResource bordertop矩形}" /> | |||||
<Border Style="{DynamicResource bordertopL}" /> | |||||
<Image | |||||
Margin="20,0,0,0" | |||||
VerticalAlignment="Center" | |||||
Style="{DynamicResource imagetop_Title}" /> | |||||
<Grid Grid.Column="1"> | |||||
<ListBox | |||||
x:Name="lstEnt" | |||||
Background="{x:Null}" | |||||
BorderBrush="{x:Null}" | |||||
BorderThickness="0" | |||||
ItemContainerStyle="{StaticResource ResourceKey=ListBoxItemStyle1}" | |||||
ItemsSource="{Binding Menus}"> | |||||
<ListBox.ItemsPanel> | |||||
<ItemsPanelTemplate> | |||||
<StackPanel Orientation="Horizontal" /> | |||||
</ItemsPanelTemplate> | |||||
</ListBox.ItemsPanel> | |||||
<ListBox.ItemTemplate> | |||||
<DataTemplate> | |||||
<RadioButton | |||||
Command="{Binding DataContext.TogglePag, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}" | |||||
CommandParameter="{Binding CommandParameter}" | |||||
Content="{Binding MenuName}" | |||||
GroupName="all" | |||||
Style="{StaticResource MenuRadioButtonStyle}" /> | |||||
</DataTemplate> | |||||
</ListBox.ItemTemplate> | |||||
</ListBox> | |||||
</Grid> | |||||
<StackPanel | |||||
Grid.Column="4" | |||||
Height="50" | |||||
HorizontalAlignment="Right" | |||||
VerticalAlignment="Top" | |||||
Orientation="Horizontal"> | |||||
<Border Style="{DynamicResource border竖线}" /> | |||||
<Grid> | |||||
<ToggleButton | |||||
Name="tb" | |||||
Margin="5" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Cursor="Hand" | |||||
IsChecked="{Binding UserManagement}" | |||||
Style="{DynamicResource StatusBtnStyle网络连接状态}" | |||||
ToolTip="用户管理" /> | |||||
<!-- 当 StaysOpen 设置为 True 时 popup失去焦点的时候不会自动关闭 --> | |||||
<Popup | |||||
AllowsTransparency="True" | |||||
Focusable="False" | |||||
IsOpen="{Binding IsChecked, ElementName=tb}" | |||||
Placement="Bottom" | |||||
PlacementTarget="{Binding ElementName=tb}" | |||||
StaysOpen="False"> | |||||
<Border Background="#081424" ClipToBounds="True"> | |||||
<Grid Width="100" Margin="0"> | |||||
<StackPanel Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}"> | |||||
<Button | |||||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||||
Margin="0,5,0,1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Command="{Binding PasswordChange}" | |||||
Content="密码修改" | |||||
Cursor="Hand" /> | |||||
<Button | |||||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||||
Margin="0,5,0,1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Command="{Binding Login}" | |||||
Content="登录账号" | |||||
Cursor="Hand" /> | |||||
<Button | |||||
Width="{Binding RelativeSource={RelativeSource AncestorLevel=1, AncestorType=Grid}, Path=ActualWidth}" | |||||
Margin="0,5,0,1" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Command="{Binding ExitLogin}" | |||||
Content="退出登录" | |||||
Cursor="Hand" /> | |||||
</StackPanel> | |||||
</Grid> | |||||
</Border> | |||||
</Popup> | |||||
</Grid> | |||||
<Border Style="{DynamicResource border竖线}" /> | |||||
<ToggleButton | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Cursor="Hand" | |||||
DataContext="{Binding IsAlarm}" | |||||
Style="{DynamicResource StatusBtnStyle告警}" | |||||
ToolTip="告警消息" /> | |||||
<Border Style="{DynamicResource border竖线}" /> | |||||
<control:DateTimeUI Margin="10,0,10,0" VerticalAlignment="Center" /> | |||||
<Border Style="{DynamicResource border竖线}" /> | |||||
<Button | |||||
x:Name="ButClose" | |||||
Grid.Column="4" | |||||
Margin="10,0,20,0" | |||||
VerticalAlignment="Center" | |||||
Content="退出" | |||||
Cursor="Hand" | |||||
Style="{DynamicResource CommonBtn_返回}" | |||||
ToolTip="退出程序" /> | |||||
</StackPanel> | |||||
</Grid> | |||||
<!-- 底部窗体 --> | |||||
<Grid Grid.Row="1" Margin="10"> | |||||
<Grid.RowDefinitions> | |||||
<RowDefinition Height="45" /> | |||||
<RowDefinition /> | |||||
</Grid.RowDefinitions> | |||||
<!-- 顶部装饰 --> | |||||
<Border | |||||
Grid.Row="0" | |||||
Grid.RowSpan="2" | |||||
Style="{DynamicResource border右下}" /> | |||||
<Border | |||||
Grid.Row="0" | |||||
Grid.RowSpan="2" | |||||
Style="{DynamicResource border左下}" /> | |||||
<Border | |||||
Grid.Row="0" | |||||
Grid.RowSpan="2" | |||||
Style="{DynamicResource border右上}" /> | |||||
<Border | |||||
Grid.Row="0" | |||||
Grid.RowSpan="2" | |||||
Style="{DynamicResource border左上}" /> | |||||
<Grid Margin="10"> | |||||
<Border Width="600" Style="{DynamicResource borderFromTitle}" /> | |||||
<StackPanel Orientation="Horizontal"> | |||||
<CheckBox | |||||
Margin="5,0,5,0" | |||||
Content="开机启动" | |||||
IsChecked="{Binding AutoStart}" /> | |||||
</StackPanel> | |||||
<TextBlock | |||||
x:Name="Title" | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Top" | |||||
FontSize="16" | |||||
Foreground="#feffff" | |||||
Text="{Binding WindowTitleName}" /> | |||||
</Grid> | |||||
<!--#region 底部窗体栏--> | |||||
<ContentControl | |||||
x:Name="contentRegion" | |||||
Grid.Row="1" | |||||
Content="{Binding MyWindow}" /> | |||||
<!--#endregion--> | |||||
</Grid> | |||||
</Grid> | |||||
</Border> | |||||
</Window> |
@@ -1,48 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
using System.Windows.Controls; | |||||
using System.Windows.Data; | |||||
using System.Windows.Documents; | |||||
using System.Windows.Input; | |||||
using System.Windows.Media; | |||||
using System.Windows.Media.Imaging; | |||||
using System.Windows.Navigation; | |||||
using System.Windows.Shapes; | |||||
namespace BPASmartClient.DosingSystem.View | |||||
{ | |||||
/// <summary> | |||||
/// Interaction logic for MainWindow.xaml | |||||
/// </summary> | |||||
public partial class MainWindow : Window | |||||
{ | |||||
public MainWindow() | |||||
{ | |||||
InitializeComponent(); | |||||
this.ButClose.Click += (o, e) => { this.Close(); }; | |||||
this.MaxWidth = SystemParameters.WorkArea.Width; | |||||
this.MaxHeight = SystemParameters.WorkArea.Height; | |||||
this.br.MouseLeftButtonDown += (o, e) => | |||||
{ | |||||
if (e.ClickCount > 1) | |||||
{ | |||||
if (this.WindowState == WindowState.Maximized) | |||||
this.WindowState = WindowState.Normal; | |||||
else if (this.WindowState == WindowState.Normal) | |||||
this.WindowState = WindowState.Maximized; | |||||
} | |||||
if (e.LeftButton == MouseButtonState.Pressed) this.DragMove(); | |||||
}; | |||||
} | |||||
} | |||||
} |
@@ -1,18 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | |||||
using System.Windows; | |||||
using BPASmartClient.Helper; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | |||||
public class AlarmRecordViewModel : ObservableObject | |||||
{ | |||||
} | |||||
} |
@@ -1,161 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System.Collections.Concurrent; | |||||
using System.Collections.ObjectModel; | |||||
using System.Windows; | |||||
using BPASmartClient.Helper; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using BPASmartClient.DosingSystem.Model; | |||||
using Newtonsoft.Json; | |||||
using System.IO; | |||||
using System.Reflection; | |||||
namespace BPASmartClient.DosingSystem.ViewModel | |||||
{ | |||||
public class MainViewModel : ObservableObject | |||||
{ | |||||
//ObservableCollection<ActionMenu> menus = new ObservableCollection<ActionMenu>(); | |||||
//private Permission _permission; | |||||
//public Permission permission | |||||
//{ | |||||
// get { return _permission; } | |||||
// set | |||||
// { | |||||
// var res = menus.Where(p => Array.FindIndex(p.permission, s => s == value) >= 0).ToList(); | |||||
// if (res != null && res.Count > 0) | |||||
// { | |||||
// Menus.Clear(); | |||||
// res.ForEach((item) => { Menus.Add(item); }); | |||||
// } | |||||
// _permission = value; | |||||
// } | |||||
//} | |||||
public MainViewModel() | |||||
{ | |||||
//Json<LocaPar>.Read(); | |||||
TogglePag = new RelayCommand<object>(DoNavChanged); | |||||
Login = new RelayCommand(() => { DoNavChanged("BPASmartClient.DosingSystem.View.AdminstratorsView_用户登录"); UserManagement = false; }); | |||||
PasswordChange = new RelayCommand(() => | |||||
{ | |||||
//DoNavChanged("PasswordChangeView.密码修改"); | |||||
UserManagement = false; | |||||
}); | |||||
ExitLogin = new RelayCommand(() => | |||||
{ | |||||
//SystemUtils.ShowScreenKeyboard(); | |||||
//DoNavChanged("LoginView.退出登录"); | |||||
UserManagement = false; | |||||
}); | |||||
//Config.GetInstance.Init(); | |||||
LoginRegister(); | |||||
MenuInit(); | |||||
//permission = Permission.管理员; | |||||
//if (Menus.Count > 0) DoNavChanged(Menus.ElementAt(0).CommandParameter); | |||||
DeviceInquire.GetInstance.Init(); | |||||
} | |||||
private void LoginRegister() | |||||
{ | |||||
ActionManage.GetInstance.Register(new Func<object, object>((o) => | |||||
{ | |||||
//if (o != null && o is string str) | |||||
//{ | |||||
// var strs = str.Split("-="); | |||||
// if (strs != null && strs.Length == 3) | |||||
// { | |||||
// var us = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == strs[0]); | |||||
// if (us != null && strs[1] == us.Password && strs[2] == us.permission.ToString()) | |||||
// { | |||||
// permission = us.permission; | |||||
// return string.Empty; | |||||
// } | |||||
// } | |||||
//} | |||||
return "用户名或密码错误"; | |||||
}), "LoginBPASmartClient.DosingSystem"); | |||||
} | |||||
private void MenuInit() | |||||
{ | |||||
//menus.Add(new ActionMenu() | |||||
//{ | |||||
// MenuName = "配方设置", | |||||
// CommandParameter = "BPASmartClient.DosingSystem.View.RecipeSettingsView_配方设置", | |||||
// permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||||
//}); | |||||
//menus.Add(new ActionMenu() | |||||
//{ | |||||
// MenuName = "设备列表", | |||||
// CommandParameter = "BPASmartClient.DosingSystem.View.DeviceListView_设备列表", | |||||
// permission = new Permission[] { Permission.管理员, Permission.技术员 }, | |||||
//}); | |||||
//menus.Add(new ActionMenu() | |||||
//{ | |||||
// MenuName = "硬件状态", | |||||
// CommandParameter = "BPASmartClient.DosingSystem.View.HardwareStatusView_硬件状态", | |||||
// permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
//}); | |||||
//menus.Add(new ActionMenu() | |||||
//{ | |||||
// MenuName = "报警记录", | |||||
// CommandParameter = "BPASmartClient.CustomResource.Pages.View.AlarmView_报警记录", | |||||
// permission = new Permission[] { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }, | |||||
//}); | |||||
//menus.Add(new ActionMenu() | |||||
//{ | |||||
// MenuName = "配方下发", | |||||
// CommandParameter = "BPASmartClient.DosingSystem.View.RecipeControlView_配方控制", | |||||
// permission = new Permission[] { Permission.管理员, Permission.操作员 }, | |||||
//}); | |||||
} | |||||
public void DoNavChanged(object obj) | |||||
{ | |||||
if (obj != null && obj is string stobj) | |||||
{ | |||||
var strs = stobj.Split('_'); | |||||
if (strs != null && strs.Length == 2) | |||||
{ | |||||
Type type; | |||||
if (!stobj.Contains("BPASmartClient.DosingSystem")) | |||||
{ | |||||
type = Assembly.Load("BPASmartClient.CustomResource").GetType(strs[0]); | |||||
} | |||||
else type = Type.GetType(strs[0]); | |||||
var res = type?.GetConstructor(System.Type.EmptyTypes)?.Invoke(null); | |||||
if (res != null && res is FrameworkElement fe) MyWindow = fe; | |||||
WindowTitleName = strs[1]; | |||||
} | |||||
} | |||||
} | |||||
public RelayCommand<object> TogglePag { get; set; } | |||||
public RelayCommand Login { get; set; } | |||||
public RelayCommand PasswordChange { get; set; } | |||||
public RelayCommand ExitLogin { get; set; } | |||||
public ObservableCollection<ActionMenu> Menus { get; set; } = new ObservableCollection<ActionMenu>(); | |||||
public FrameworkElement MyWindow { get { return _mMyWindow; } set { _mMyWindow = value; OnPropertyChanged(); } } | |||||
private FrameworkElement _mMyWindow; | |||||
public string WindowTitleName { get { return _mWindowTitleName; } set { _mWindowTitleName = value; OnPropertyChanged(); } } | |||||
private string _mWindowTitleName; | |||||
public bool UserManagement { get { return _mUserManagement; } set { _mUserManagement = value; OnPropertyChanged(); } } | |||||
private bool _mUserManagement; | |||||
public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } } | |||||
} | |||||
} |