@@ -38,10 +38,10 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||||
private void AddData() | private void AddData() | ||||
{ | { | ||||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.管理员, UserName = "admin", Password = "admin" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.操作员, UserName = "czy", Password = "123456" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.观察员, UserName = "gcy", Password = "654321" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { permission = Permission.技术员, UserName = "jsy", Password = "88888888" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.管理员, UserName = "admin", Password = "admin" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.操作员, UserName = "czy", Password = "123456" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.观察员, UserName = "gcy", Password = "654321" }); | |||||
Global.userManager.userInfos.Add(new UserInfo() { Permission = Permission.技术员, UserName = "jsy", Password = "88888888" }); | |||||
SaveUser(); | SaveUser(); | ||||
} | } | ||||
@@ -46,7 +46,7 @@ namespace BPASmartClient.CustomResource.Pages.Model | |||||
{ | { | ||||
Date = DateTime.Now.ToString("yyyy-MM-dd"), | Date = DateTime.Now.ToString("yyyy-MM-dd"), | ||||
Time = DateTime.Now.ToString("HH:mm:ss"), | Time = DateTime.Now.ToString("HH:mm:ss"), | ||||
Permission = Global.userInfo.permission.ToString(), | |||||
Permission = Global.userInfo.Permission.ToString(), | |||||
UserName = Global.userInfo.UserName, | UserName = Global.userInfo.UserName, | ||||
LogInfo = info | LogInfo = info | ||||
}; | }; | ||||
@@ -1,4 +1,5 @@ | |||||
using BPASmartClient.CustomResource.Pages.Enums; | using BPASmartClient.CustomResource.Pages.Enums; | ||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.Linq; | using System.Linq; | ||||
@@ -7,11 +8,14 @@ using System.Threading.Tasks; | |||||
namespace BPASmartClient.CustomResource.Pages.Model | namespace BPASmartClient.CustomResource.Pages.Model | ||||
{ | { | ||||
public class UserInfo | |||||
public class UserInfo:ObservableObject | |||||
{ | { | ||||
public Permission permission { get; set; } | |||||
public string UserName { get; set; } | |||||
public string Password { get; set; } | |||||
public Permission Permission { get { return _permission; } set { if (value is Permission per) { _permission = value; } else { _permission =(Permission) Enum.Parse(typeof(Permission), value.ToString()); } OnPropertyChanged(); } } | |||||
private Permission _permission; | |||||
public string UserName { get { return _userName; } set { _userName = value;OnPropertyChanged(); } } | |||||
private string _userName; | |||||
public string Password { get { return _password; } set { _password = value; OnPropertyChanged(); } } | |||||
private string _password; | |||||
} | } | ||||
} | } |
@@ -0,0 +1,422 @@ | |||||
<UserControl x:Class="BPASmartClient.CustomResource.Pages.View.UserManageView" | |||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |||||
xmlns:local="clr-namespace:BPASmartClient.CustomResource.Pages.View" | |||||
xmlns:vm="clr-namespace:BPASmartClient.CustomResource.Pages.ViewModel" | |||||
xmlns:theme="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero2" | |||||
mc:Ignorable="d" | |||||
d:DesignHeight="450" d:DesignWidth="800"> | |||||
<UserControl.DataContext> | |||||
<vm:UserManageViewModel/> | |||||
</UserControl.DataContext> | |||||
<UserControl.Resources> | |||||
<Style x:Key="dgCell" TargetType="TextBlock"> | |||||
<Setter Property="HorizontalAlignment" Value="Center"/> | |||||
<Setter Property="VerticalAlignment" Value="Center"/> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
</Style> | |||||
<Style x:Key="btnStyle" TargetType="Button"> | |||||
<Setter Property="Width" Value="auto"/> | |||||
<Setter Property="FontSize" Value="16"/> | |||||
<Setter Property="Foreground" Value="SkyBlue"/> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
<Setter Property="BorderBrush" Value="SkyBlue"/> | |||||
</Style> | |||||
<Style x:Key="textboxStyle" TargetType="TextBox"> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
<Setter Property="Foreground" Value="SkyBlue"/> | |||||
<Setter Property="HorizontalContentAlignment" Value="Center"/> | |||||
<Setter Property="VerticalContentAlignment" Value="Center"/> | |||||
<Setter Property="FontSize" Value="16"/> | |||||
<Setter Property="BorderThickness" Value="0"/> | |||||
<Setter Property="CaretBrush" Value="LightBlue"/> | |||||
<Style.Triggers> | |||||
<Trigger Property="IsFocused" Value="True"> | |||||
<Setter Property="Cursor" Value="Arrow"/> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
<Style TargetType="DataGrid" x:Key="dataGrid"> | |||||
<!--网格线颜色--> | |||||
<Setter Property="CanUserResizeColumns" Value="false"/> | |||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"></Setter> | |||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"></Setter> | |||||
<Setter Property="HeadersVisibility" Value="Column"/> | |||||
<Setter Property="HorizontalGridLinesBrush"> | |||||
<Setter.Value> | |||||
<SolidColorBrush Color="#FF2AB2E7"/> | |||||
</Setter.Value> | |||||
</Setter> | |||||
<Setter Property="VerticalGridLinesBrush"> | |||||
<Setter.Value> | |||||
<SolidColorBrush Color="#FF2AB2E7"/> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<Style x:Key="columsHeader" TargetType="DataGridColumnHeader"> | |||||
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter> | |||||
<Setter Property="VerticalAlignment" Value="Center"/> | |||||
<Setter Property="Foreground" Value="White"></Setter> | |||||
<Setter Property="Background" Value="#FF2AB2E7"/> | |||||
<Setter Property="BorderThickness" Value="1"></Setter> | |||||
<Setter Property="BorderBrush" Value="white"></Setter> | |||||
<Setter Property="Height" Value="30"/> | |||||
<Setter Property="FontSize" Value="16"/> | |||||
<Setter Property="FontWeight" Value="Heavy"/> | |||||
<Setter Property="Margin" Value="-1,-1,-1,-1"/> | |||||
</Style> | |||||
<Style x:Key="rowStyle" TargetType="DataGridRow"> | |||||
<Setter Property="Height" Value="35"/> | |||||
<Setter Property="Foreground" Value="SkyBlue"/> | |||||
<Style.Triggers> | |||||
<Trigger Property="AlternationIndex" Value="0"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
</Trigger> | |||||
<Trigger Property="AlternationIndex" Value="1"> | |||||
<Setter Property="Background" Value="Transparent" /> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="True"> | |||||
<Setter Property="Background" Value="#000066" /> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
<Style x:Key="cellStyle" TargetType="DataGridCell"> | |||||
<Style.Triggers> | |||||
<Trigger Property="IsSelected" Value="True"> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
<Setter Property="Foreground" | |||||
Value="SkyBlue"/> | |||||
</Trigger> | |||||
<Trigger Property="IsSelected" Value="false"> | |||||
<Setter Property="Background" Value="Transparent"/> | |||||
<Setter Property="Foreground" | |||||
Value="SkyBlue"/> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
<LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="SkyBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="SkyBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="LightBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#FFABADB3"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/> | |||||
<LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="SteelBlue" Offset="0.0"/> | |||||
<GradientStop Color="SteelBlue" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/> | |||||
<LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="#FFEBF4FC" Offset="0.0"/> | |||||
<GradientStop Color="#FFDCECFC" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/> | |||||
<LinearGradientBrush x:Key="ComboBox.Pressed.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="#FFDAECFC" Offset="0.0"/> | |||||
<GradientStop Color="#FFC4E0FC" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="ComboBox.Pressed.Border" Color="#FF569DE5"/> | |||||
<SolidColorBrush x:Key="ComboBox.Pressed.Glyph" Color="#FF000000"/> | |||||
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Background" Color="#FFFFFFFF"/> | |||||
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Border" Color="#FF569DE5"/> | |||||
<LinearGradientBrush x:Key="ComboBox.Pressed.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="#FFDAEBFC" Offset="0.0"/> | |||||
<GradientStop Color="#FFC4E0FC" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="ComboBox.Pressed.Editable.Button.Border" Color="#FF569DE5"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Background" Color="#FFF0F0F0"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Border" Color="#FFD9D9D9"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Glyph" Color="#FFBFBFBF"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Background" Color="#FFFFFFFF"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Border" Color="#FFBFBFBF"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Background" Color="Transparent"/> | |||||
<SolidColorBrush x:Key="ComboBox.Disabled.Editable.Button.Border" Color="Transparent"/> | |||||
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}"> | |||||
<Setter Property="OverridesDefaultStyle" Value="true"/> | |||||
<Setter Property="IsTabStop" Value="false"/> | |||||
<Setter Property="Focusable" Value="false"/> | |||||
<Setter Property="ClickMode" Value="Press"/> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type ToggleButton}"> | |||||
<Border x:Name="templateRoot" Background="{StaticResource ComboBox.Static.Background}" BorderBrush="{StaticResource ComboBox.Static.Border}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true"> | |||||
<Border x:Name="splitBorder" BorderBrush="Transparent" BorderThickness="1" HorizontalAlignment="Right" Margin="0" SnapsToDevicePixels="true" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"> | |||||
<Path x:Name="arrow" Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z" Fill="{StaticResource ComboBox.Static.Glyph}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center"/> | |||||
</Border> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/> | |||||
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="false"/> | |||||
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="false"/> | |||||
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="true"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Static.Editable.Border}"/> | |||||
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Static.Editable.Button.Border}"/> | |||||
</MultiDataTrigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.MouseOver.Glyph}"/> | |||||
</Trigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<!--<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/>--> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/> | |||||
</MultiDataTrigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Editable.Border}"/> | |||||
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.MouseOver.Editable.Button.Border}"/> | |||||
</MultiDataTrigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Pressed.Glyph}"/> | |||||
</Trigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Border}"/> | |||||
</MultiDataTrigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsPressed, RelativeSource={RelativeSource Self}}" Value="true"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Pressed.Editable.Border}"/> | |||||
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Pressed.Editable.Button.Border}"/> | |||||
</MultiDataTrigger> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Fill" TargetName="arrow" Value="{StaticResource ComboBox.Disabled.Glyph}"/> | |||||
</Trigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Border}"/> | |||||
</MultiDataTrigger> | |||||
<MultiDataTrigger> | |||||
<MultiDataTrigger.Conditions> | |||||
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}" Value="false"/> | |||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="true"/> | |||||
</MultiDataTrigger.Conditions> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.Disabled.Editable.Border}"/> | |||||
<Setter Property="Background" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="splitBorder" Value="{StaticResource ComboBox.Disabled.Editable.Button.Border}"/> | |||||
</MultiDataTrigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"> | |||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="*"/> | |||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> | |||||
</Grid.ColumnDefinitions> | |||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"> | |||||
<theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> | |||||
<Border x:Name="dropDownBorder" Background="White" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1"> | |||||
<ScrollViewer x:Name="DropDownScrollViewer"> | |||||
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"> | |||||
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> | |||||
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/> | |||||
</Canvas> | |||||
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
</Border> | |||||
</theme:SystemDropShadowChrome> | |||||
</Popup> | |||||
<ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/> | |||||
<ContentPresenter x:Name="contentPresenter" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"> | |||||
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/> | |||||
<Setter Property="Color" TargetName="shadow" Value="#71000000"/> | |||||
</Trigger> | |||||
<Trigger Property="HasItems" Value="false"> | |||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/> | |||||
</Trigger> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsGrouping" Value="true"/> | |||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/> | |||||
</MultiTrigger> | |||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false"> | |||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/> | |||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<LinearGradientBrush x:Key="Button.Static.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/> | |||||
<ControlTemplate x:Key="ButtonTemplate1" TargetType="{x:Type ButtonBase}"> | |||||
<Border x:Name="border" Background="{StaticResource Button.Static.Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true"> | |||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="Button.IsDefaulted" Value="true"> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<!--<Setter Property="Background" TargetName="border" Value="#000066"/>--> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/> | |||||
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
</UserControl.Resources> | |||||
<Grid> | |||||
<ScrollViewer VerticalScrollBarVisibility="Hidden"> | |||||
<DataGrid ItemsSource="{Binding usersInfo}" GridLinesVisibility="All" Background="Transparent" | |||||
AutoGenerateColumns="False" | |||||
IsReadOnly="False" Style="{StaticResource dataGrid }" | |||||
ColumnHeaderStyle="{StaticResource columsHeader}" RowStyle="{StaticResource rowStyle}" CellStyle="{StaticResource cellStyle}"> | |||||
<DataGrid.Columns> | |||||
<!--<DataGridTemplateColumn Width="0.2*"> | |||||
<DataGridTemplateColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" FontSize="24" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Account" /> | |||||
</StackPanel> | |||||
</DataGridTemplateColumn.Header> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<TextBox Text="{Binding UserName}" Style="{StaticResource textboxStyle}"></TextBox> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn>--> | |||||
<DataGridTextColumn FontSize="16" IsReadOnly="false" Width="0.2*" Binding="{Binding UserName}" ElementStyle="{StaticResource dgCell}"> | |||||
<DataGridTextColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" FontSize="24" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Account" /> | |||||
</StackPanel> | |||||
</DataGridTextColumn.Header> | |||||
</DataGridTextColumn> | |||||
<!--<DataGridTemplateColumn Width="0.2*"> | |||||
<DataGridTemplateColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" > | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" FontSize="24" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Account" /> | |||||
</StackPanel> | |||||
</DataGridTemplateColumn.Header> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<TextBox Text="{Binding Password}" Style="{StaticResource textboxStyle}"></TextBox> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn>--> | |||||
<DataGridTextColumn FontSize="16" IsReadOnly="False" Width="0.2*" Binding="{Binding Password}" ElementStyle="{StaticResource dgCell}" > | |||||
<DataGridTextColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Password"/> | |||||
</StackPanel> | |||||
</DataGridTextColumn.Header> | |||||
</DataGridTextColumn> | |||||
<DataGridTemplateColumn Width="0.2*"> | |||||
<DataGridTemplateColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Authority"/> | |||||
</StackPanel> | |||||
</DataGridTemplateColumn.Header> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<ComboBox Text="{Binding Permission}" Template="{DynamicResource ComboBoxTemplate}" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}, Mode=FindAncestor}}" IsEditable="False" Foreground="Cyan" VerticalContentAlignment="Center" Width="auto" FontSize="16" HorizontalContentAlignment="Center" > | |||||
<ComboBox.ItemContainerStyle> | |||||
<Style TargetType="{x:Type ComboBoxItem}"> | |||||
<Setter Property="FontSize" Value="16"/> | |||||
<Setter Property="Background" Value="White" /> | |||||
<Setter Property="Foreground" Value="#FF2AB2E7"/> | |||||
</Style> | |||||
</ComboBox.ItemContainerStyle> | |||||
</ComboBox> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn> | |||||
<DataGridTemplateColumn Width="0.4*"> | |||||
<DataGridTemplateColumn.Header> | |||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||||
<TextBlock FontFamily="../Resources/fonts/#iconfont" Foreground="Orange" Text="" VerticalAlignment="Center" Margin="0,0,8,0"/> | |||||
<TextBlock Text="Operate"/> | |||||
</StackPanel> | |||||
</DataGridTemplateColumn.Header> | |||||
<DataGridTemplateColumn.CellTemplate> | |||||
<DataTemplate> | |||||
<Grid> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition/> | |||||
<ColumnDefinition/> | |||||
<!--<ColumnDefinition/>--> | |||||
</Grid.ColumnDefinitions> | |||||
<Button Command="{Binding DataContext.SaveCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" | |||||
CommandParameter="{Binding UserName}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Foreground="Cyan" Content="Save" Margin="5,0"></Button> | |||||
<!--<Button Command="{Binding DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Content="Update" Grid.Column="1" Margin="5,0"></Button>--> | |||||
<Button Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" CommandParameter="{Binding Account}" Template="{DynamicResource ButtonTemplate1}" Style="{StaticResource btnStyle}" Content="Delete" Grid.Column="1" Foreground="Cyan" Margin="5,0"></Button> | |||||
</Grid> | |||||
</DataTemplate> | |||||
</DataGridTemplateColumn.CellTemplate> | |||||
</DataGridTemplateColumn> | |||||
</DataGrid.Columns> | |||||
</DataGrid> | |||||
</ScrollViewer> | |||||
</Grid> | |||||
</UserControl> |
@@ -0,0 +1,28 @@ | |||||
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.CustomResource.Pages.View | |||||
{ | |||||
/// <summary> | |||||
/// UserManageView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class UserManageView : UserControl | |||||
{ | |||||
public UserManageView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
} | |||||
} |
@@ -29,22 +29,22 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName && p.Password == Password); | var res = Global.userManager.userInfos.FirstOrDefault(p => p.UserName == UserName && p.Password == Password); | ||||
if (res != null) | if (res != null) | ||||
{ | { | ||||
Global.userInfo.permission = res.permission; | |||||
Global.userInfo.Permission = res.Permission; | |||||
Global.userInfo.UserName = res.UserName; | Global.userInfo.UserName = res.UserName; | ||||
Global.userInfo.Password = res.Password; | Global.userInfo.Password = res.Password; | ||||
for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++) | for (int i = 0; i < MenuManage.GetInstance.menuModels.Count; i++) | ||||
{ | { | ||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.permission)) | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuPermission.Contains(res.Permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible; | MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Visible; | ||||
else | else | ||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | ||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.permission)) == null) | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.FirstOrDefault(p => p.SubMenuPermission.Contains(res.Permission)) == null) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | MenuManage.GetInstance.menuModels.ElementAt(i).MainMenuVisibility = Visibility.Collapsed; | ||||
for (int m = 0; m < MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.Count; m++) | 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)) | |||||
if (MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuPermission.Contains(res.Permission)) | |||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible; | MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Visible; | ||||
else | else | ||||
MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed; | MenuManage.GetInstance.menuModels.ElementAt(i).subMenumodels.ElementAt(m).SubMenuVisibility = Visibility.Collapsed; | ||||
@@ -0,0 +1,79 @@ | |||||
using BPA.Message; | |||||
using BPASmartClient.CustomResource.Pages.Enums; | |||||
using BPASmartClient.CustomResource.Pages.Model; | |||||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||||
using Microsoft.Toolkit.Mvvm.Input; | |||||
using Newtonsoft.Json; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Collections.ObjectModel; | |||||
using System.IO; | |||||
using System.Linq; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
using System.Windows; | |||||
namespace BPASmartClient.CustomResource.Pages.ViewModel | |||||
{ | |||||
internal class UserManageViewModel:ObservableObject | |||||
{ | |||||
public ObservableCollection<UserInfo> usersInfo { get; set; } = new ObservableCollection<UserInfo>(); | |||||
public List<string> Authorities { get; set; } = new List<string>(); | |||||
public RelayCommand<string> SaveCommand { get; set; } | |||||
public RelayCommand<string> DeleteCommand { get; set; } | |||||
public UserManageViewModel() | |||||
{ | |||||
var userManager = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt()); | |||||
usersInfo = userManager.userInfos; | |||||
AddAuthorities(); | |||||
SaveCommand = new RelayCommand<string>((str) => | |||||
{ | |||||
if (str != string.Empty && str != null) | |||||
{ | |||||
int num = usersInfo.Where(p => p.UserName == str).Count(); | |||||
if (num > 0 && num >= 2) | |||||
{ | |||||
MessageBox.Show("用户名重复", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | |||||
} | |||||
else | |||||
{ | |||||
Global.userManager.userInfos = usersInfo; | |||||
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | |||||
} | |||||
} | |||||
}); | |||||
DeleteCommand = new RelayCommand<string>((str) => | |||||
{ | |||||
if (str != string.Empty && str != null) | |||||
{ | |||||
var userInfo = usersInfo.FirstOrDefault(p => p.UserName == str); | |||||
if (userInfo != null) | |||||
{ | |||||
if (usersInfo.Remove(userInfo)) | |||||
{ | |||||
Global.userManager.userInfos = usersInfo; | |||||
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
MessageBox.Show("未找到对应记录", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | |||||
} | |||||
} | |||||
}); | |||||
} | |||||
private void AddAuthorities() | |||||
{ | |||||
foreach (Permission aut in System.Enum.GetValues(typeof(Permission))) | |||||
{ | |||||
Authorities.Add(aut.ToString()); | |||||
} | |||||
} | |||||
} | |||||
} |
@@ -98,31 +98,65 @@ | |||||
<Setter Property="Foreground" | <Setter Property="Foreground" | ||||
Value="SkyBlue"/> | Value="SkyBlue"/> | ||||
</Trigger> | </Trigger> | ||||
</Style.Triggers> | </Style.Triggers> | ||||
</Style> | </Style> | ||||
<LinearGradientBrush x:Key="Button.Static.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/> | |||||
<ControlTemplate x:Key="ButtonTemplate1" TargetType="{x:Type ButtonBase}"> | |||||
<Border x:Name="border" Background="{StaticResource Button.Static.Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true"> | |||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Border> | |||||
<ControlTemplate.Triggers> | |||||
<Trigger Property="Button.IsDefaulted" Value="true"> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<!--<Setter Property="Background" TargetName="border" Value="#000066"/>--> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/> | |||||
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/> | |||||
</Trigger> | |||||
</ControlTemplate.Triggers> | |||||
</ControlTemplate> | |||||
<LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0"> | <LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0"> | ||||
<GradientStop Color="Transparent" Offset="0.0"/> | <GradientStop Color="Transparent" Offset="0.0"/> | ||||
<GradientStop Color="Transparent" Offset="1.0"/> | <GradientStop Color="Transparent" Offset="1.0"/> | ||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="SkyBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="SkyBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="LightBlue"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF2AB2E7"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Background" Color="Transparent"/> | |||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#FFABADB3"/> | <SolidColorBrush x:Key="ComboBox.Static.Editable.Border" Color="#FFABADB3"/> | ||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/> | <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Background" Color="Transparent"/> | ||||
<SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/> | <SolidColorBrush x:Key="ComboBox.Static.Editable.Button.Border" Color="Transparent"/> | ||||
<LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0"> | <LinearGradientBrush x:Key="ComboBox.MouseOver.Background" EndPoint="0,1" StartPoint="0,0"> | ||||
<GradientStop Color="SteelBlue" Offset="0.0"/> | |||||
<GradientStop Color="SteelBlue" Offset="1.0"/> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/> | <SolidColorBrush x:Key="ComboBox.MouseOver.Border" Color="#FF7EB4EA"/> | ||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/> | <SolidColorBrush x:Key="ComboBox.MouseOver.Glyph" Color="#FF000000"/> | ||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="#FFFFFFFF"/> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Background" Color="Transparent"/> | |||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/> | <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Border" Color="#FF7EB4EA"/> | ||||
<LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> | <LinearGradientBrush x:Key="ComboBox.MouseOver.Editable.Button.Background" EndPoint="0,1" StartPoint="0,0"> | ||||
<GradientStop Color="#FFEBF4FC" Offset="0.0"/> | |||||
<GradientStop Color="#FFDCECFC" Offset="1.0"/> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | </LinearGradientBrush> | ||||
<SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/> | <SolidColorBrush x:Key="ComboBox.MouseOver.Editable.Button.Border" Color="#FF7EB4EA"/> | ||||
<LinearGradientBrush x:Key="ComboBox.Pressed.Background" EndPoint="0,1" StartPoint="0,0"> | <LinearGradientBrush x:Key="ComboBox.Pressed.Background" EndPoint="0,1" StartPoint="0,0"> | ||||
@@ -179,7 +213,7 @@ | |||||
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/> | <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true"/> | ||||
<Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/> | <Condition Binding="{Binding IsEditable, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false"/> | ||||
</MultiDataTrigger.Conditions> | </MultiDataTrigger.Conditions> | ||||
<!--<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/>--> | |||||
<Setter Property="Background" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/> | <Setter Property="BorderBrush" TargetName="templateRoot" Value="{StaticResource ComboBox.MouseOver.Border}"/> | ||||
</MultiDataTrigger> | </MultiDataTrigger> | ||||
<MultiDataTrigger> | <MultiDataTrigger> | ||||
@@ -239,15 +273,41 @@ | |||||
</Setter.Value> | </Setter.Value> | ||||
</Setter> | </Setter> | ||||
</Style> | </Style> | ||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"> | |||||
<Style x:Key="FocusVisual"> | |||||
<Setter Property="Control.Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate> | |||||
<Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF"/> | |||||
<Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}"> | |||||
<Setter Property="OverridesDefaultStyle" Value="true"/> | |||||
<Setter Property="AllowDrop" Value="true"/> | |||||
<Setter Property="MinWidth" Value="0"/> | |||||
<Setter Property="MinHeight" Value="0"/> | |||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> | |||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/> | |||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/> | |||||
<Setter Property="Template"> | |||||
<Setter.Value> | |||||
<ControlTemplate TargetType="{x:Type TextBox}"> | |||||
<ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/> | |||||
</ControlTemplate> | |||||
</Setter.Value> | |||||
</Setter> | |||||
</Style> | |||||
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}"> | |||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true"> | <Grid x:Name="templateRoot" SnapsToDevicePixels="true"> | ||||
<Grid.ColumnDefinitions> | <Grid.ColumnDefinitions> | ||||
<ColumnDefinition Width="*"/> | <ColumnDefinition Width="*"/> | ||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> | <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> | ||||
</Grid.ColumnDefinitions> | </Grid.ColumnDefinitions> | ||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"> | |||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"> | |||||
<theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> | <theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> | ||||
<Border x:Name="dropDownBorder" Background="White" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1"> | |||||
<Border x:Name="dropDownBorder" Background="Transparent" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1"> | |||||
<ScrollViewer x:Name="DropDownScrollViewer"> | <ScrollViewer x:Name="DropDownScrollViewer"> | ||||
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"> | <Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"> | ||||
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> | <Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> | ||||
@@ -260,9 +320,17 @@ | |||||
</theme:SystemDropShadowChrome> | </theme:SystemDropShadowChrome> | ||||
</Popup> | </Popup> | ||||
<ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/> | <ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/> | ||||
<ContentPresenter x:Name="contentPresenter" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
<Border x:Name="border" Background="{StaticResource TextBox.Static.Background}" Margin="{TemplateBinding BorderThickness}"> | |||||
<TextBox x:Name="PART_EditableTextBox" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Margin="{TemplateBinding Padding}" Style="{StaticResource ComboBoxEditableTextBox}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Border> | |||||
</Grid> | </Grid> | ||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/> | |||||
</Trigger> | |||||
<Trigger Property="IsKeyboardFocusWithin" Value="true"> | |||||
<Setter Property="Foreground" Value="Black"/> | |||||
</Trigger> | |||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"> | <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"> | ||||
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/> | <Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/> | ||||
<Setter Property="Color" TargetName="shadow" Value="#71000000"/> | <Setter Property="Color" TargetName="shadow" Value="#71000000"/> | ||||
@@ -283,40 +351,71 @@ | |||||
</Trigger> | </Trigger> | ||||
</ControlTemplate.Triggers> | </ControlTemplate.Triggers> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
<LinearGradientBrush x:Key="Button.Static.Background" EndPoint="0,1" StartPoint="0,0"> | |||||
<GradientStop Color="Transparent" Offset="0.0"/> | |||||
<GradientStop Color="Transparent" Offset="1.0"/> | |||||
</LinearGradientBrush> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/> | |||||
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/> | |||||
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/> | |||||
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/> | |||||
<ControlTemplate x:Key="ButtonTemplate1" TargetType="{x:Type ButtonBase}"> | |||||
<Border x:Name="border" Background="{StaticResource Button.Static.Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true"> | |||||
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Border> | |||||
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}"> | |||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true"> | |||||
<Grid.ColumnDefinitions> | |||||
<ColumnDefinition Width="*"/> | |||||
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/> | |||||
</Grid.ColumnDefinitions> | |||||
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"> | |||||
<theme:SystemDropShadowChrome x:Name="shadow" Color="Transparent" MinWidth="{Binding ActualWidth, ElementName=templateRoot}" MaxHeight="{TemplateBinding MaxDropDownHeight}"> | |||||
<Border x:Name="dropDownBorder" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1"> | |||||
<ScrollViewer x:Name="DropDownScrollViewer"> | |||||
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled"> | |||||
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"> | |||||
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}" Height="{Binding ActualHeight, ElementName=dropDownBorder}" Width="{Binding ActualWidth, ElementName=dropDownBorder}"/> | |||||
</Canvas> | |||||
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/> | |||||
</Grid> | |||||
</ScrollViewer> | |||||
</Border> | |||||
</theme:SystemDropShadowChrome> | |||||
</Popup> | |||||
<ToggleButton x:Name="toggleButton" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/> | |||||
<ContentPresenter x:Name="contentPresenter" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" Content="{TemplateBinding SelectionBoxItem}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> | |||||
</Grid> | |||||
<ControlTemplate.Triggers> | <ControlTemplate.Triggers> | ||||
<Trigger Property="Button.IsDefaulted" Value="true"> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/> | |||||
</Trigger> | |||||
<Trigger Property="IsMouseOver" Value="true"> | |||||
<!--<Setter Property="Background" TargetName="border" Value="#000066"/>--> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/> | |||||
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"> | |||||
<Setter Property="Margin" TargetName="shadow" Value="0,0,5,5"/> | |||||
<Setter Property="Color" TargetName="shadow" Value="#71000000"/> | |||||
</Trigger> | </Trigger> | ||||
<Trigger Property="IsPressed" Value="true"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/> | |||||
<Trigger Property="HasItems" Value="false"> | |||||
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/> | |||||
</Trigger> | </Trigger> | ||||
<Trigger Property="IsEnabled" Value="false"> | |||||
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/> | |||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/> | |||||
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/> | |||||
<MultiTrigger> | |||||
<MultiTrigger.Conditions> | |||||
<Condition Property="IsGrouping" Value="true"/> | |||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/> | |||||
</MultiTrigger.Conditions> | |||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/> | |||||
</MultiTrigger> | |||||
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false"> | |||||
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/> | |||||
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/> | |||||
</Trigger> | </Trigger> | ||||
</ControlTemplate.Triggers> | </ControlTemplate.Triggers> | ||||
</ControlTemplate> | </ControlTemplate> | ||||
<Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}"> | |||||
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/> | |||||
<Setter Property="Background" Value="{StaticResource ComboBox.Static.Background}"/> | |||||
<Setter Property="BorderBrush" Value="{StaticResource ComboBox.Static.Border}"/> | |||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/> | |||||
<Setter Property="BorderThickness" Value="1"/> | |||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> | |||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> | |||||
<Setter Property="Padding" Value="6,3,5,3"/> | |||||
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/> | |||||
<Setter Property="ScrollViewer.PanningMode" Value="Both"/> | |||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/> | |||||
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}"/> | |||||
<Style.Triggers> | |||||
<Trigger Property="IsEditable" Value="true"> | |||||
<Setter Property="IsTabStop" Value="false"/> | |||||
<Setter Property="Padding" Value="2"/> | |||||
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/> | |||||
</Trigger> | |||||
</Style.Triggers> | |||||
</Style> | |||||
</UserControl.Resources> | </UserControl.Resources> | ||||
<Grid> | <Grid> | ||||
<ScrollViewer VerticalScrollBarVisibility="Hidden"> | <ScrollViewer VerticalScrollBarVisibility="Hidden"> | ||||
@@ -379,7 +478,8 @@ | |||||
</DataGridTemplateColumn.Header> | </DataGridTemplateColumn.Header> | ||||
<DataGridTemplateColumn.CellTemplate> | <DataGridTemplateColumn.CellTemplate> | ||||
<DataTemplate> | <DataTemplate> | ||||
<ComboBox Text="{Binding permission}" Template="{DynamicResource ComboBoxTemplate}" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}, Mode=FindAncestor}}" IsEditable="False" Foreground="Cyan" VerticalContentAlignment="Center" Width="auto" FontSize="16" HorizontalContentAlignment="Center" > | |||||
<ComboBox Style="{StaticResource ComboBoxStyle1}" SelectedValue="{Binding Permission}" SelectionChanged="ComboBox_SelectionChanged" ItemsSource="{Binding DataContext.Authorities, RelativeSource={RelativeSource AncestorType=DataGrid, Mode=FindAncestor}}" Foreground="SkyBlue" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="16"> | |||||
<ComboBox.ItemContainerStyle> | <ComboBox.ItemContainerStyle> | ||||
<Style TargetType="{x:Type ComboBoxItem}"> | <Style TargetType="{x:Type ComboBoxItem}"> | ||||
<Setter Property="FontSize" Value="16"/> | <Setter Property="FontSize" Value="16"/> | ||||
@@ -24,5 +24,11 @@ namespace FryPot_DosingSystem.View | |||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
} | } | ||||
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) | |||||
{ | |||||
var a= (sender as ComboBox).SelectedValue; | |||||
var b= (sender as ComboBox).Text; | |||||
} | |||||
} | } | ||||
} | } |
@@ -15,19 +15,21 @@ using System.Windows; | |||||
namespace FryPot_DosingSystem.ViewModel | namespace FryPot_DosingSystem.ViewModel | ||||
{ | { | ||||
internal class UserManageViewModel:ObservableObject | |||||
internal class UserManageViewModel : ObservableObject | |||||
{ | { | ||||
public ObservableCollection<UserInfo> usersInfo { get; set; } = new ObservableCollection<UserInfo>(); | public ObservableCollection<UserInfo> usersInfo { get; set; } = new ObservableCollection<UserInfo>(); | ||||
public List<string> Authorities { get; set; } = new List<string>(); | |||||
public List<Permission> Authorities { get; set; } = new List<Permission>() { Permission.管理员, Permission.操作员, Permission.观察员, Permission.技术员 }; | |||||
//public string selecttext { get; set; } = "123"; | |||||
public RelayCommand<string> SaveCommand { get; set; } | public RelayCommand<string> SaveCommand { get; set; } | ||||
public RelayCommand<string> DeleteCommand { get; set; } | public RelayCommand<string> DeleteCommand { get; set; } | ||||
public UserManageViewModel() | public UserManageViewModel() | ||||
{ | { | ||||
var userManager = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt()); | var userManager = JsonConvert.DeserializeObject<UserManager>(File.ReadAllText("up.hbl").AESDecrypt()); | ||||
usersInfo = userManager.userInfos; | usersInfo = userManager.userInfos; | ||||
AddAuthorities(); | |||||
// AddAuthorities(); | |||||
SaveCommand = new RelayCommand<string>((str) => | SaveCommand = new RelayCommand<string>((str) => | ||||
{ | { | ||||
if (str != string.Empty && str != null) | if (str != string.Empty && str != null) | ||||
@@ -40,7 +42,7 @@ namespace FryPot_DosingSystem.ViewModel | |||||
else | else | ||||
{ | { | ||||
Global.userManager.userInfos = usersInfo; | Global.userManager.userInfos = usersInfo; | ||||
File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | MessageBox.Show("保存成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information); | ||||
} | } | ||||
@@ -56,7 +58,7 @@ namespace FryPot_DosingSystem.ViewModel | |||||
if (usersInfo.Remove(userInfo)) | if (usersInfo.Remove(userInfo)) | ||||
{ | { | ||||
Global.userManager.userInfos = usersInfo; | Global.userManager.userInfos = usersInfo; | ||||
File.WriteAllText("UserInfo.jz", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
File.WriteAllText("up.hbl", JsonConvert.SerializeObject(Global.userManager).AESEncrypt()); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
@@ -67,13 +69,17 @@ namespace FryPot_DosingSystem.ViewModel | |||||
}); | }); | ||||
} | } | ||||
private void AddAuthorities() | |||||
{ | |||||
foreach (Permission aut in System.Enum.GetValues(typeof(Permission))) | |||||
{ | |||||
Authorities.Add(aut.ToString()); | |||||
} | |||||
} | |||||
//private void AddAuthorities() | |||||
//{ | |||||
// foreach (Permission aut in System.Enum.GetValues(typeof(Permission))) | |||||
// { | |||||
// Authorities.Add(aut.ToString()); | |||||
// } | |||||
//} | |||||
} | } | ||||
} | } |