AddUserView.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <UserControl
  2. x:Class="ShakerManger.View.AddUserView"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:hc="https://handyorg.github.io/handycontrol"
  7. xmlns:local="clr-namespace:ShakerManger.View"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:model="clr-namespace:Shaker.Model;assembly=Shaker"
  10. xmlns:vm="clr-namespace:ShakerManger.ViewModel"
  11. Width="{x:Static SystemParameters.PrimaryScreenWidth}"
  12. Height="{x:Static SystemParameters.PrimaryScreenHeight}"
  13. d:DataContext="{d:DesignInstance {x:Type vm:AddUserViewModel}}"
  14. d:DesignHeight="450"
  15. d:DesignWidth="800"
  16. Background="#afffffff"
  17. DataContext="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.AddUserViewModel}"
  18. FontSize="14"
  19. Foreground="{StaticResource LableBrush}"
  20. mc:Ignorable="d">
  21. <Border
  22. HorizontalAlignment="Center"
  23. VerticalAlignment="Center"
  24. Background="{StaticResource MainBrush}"
  25. BorderBrush="{StaticResource AuxiliaryBrush}"
  26. BorderThickness="1"
  27. CornerRadius="6">
  28. <Grid
  29. Margin="60"
  30. HorizontalAlignment="Center"
  31. VerticalAlignment="Center">
  32. <Grid.RowDefinitions>
  33. <RowDefinition Height="46" />
  34. <RowDefinition Height="46" />
  35. <RowDefinition Height="46" />
  36. <RowDefinition Height="auto" />
  37. <RowDefinition Height="46" />
  38. </Grid.RowDefinitions>
  39. <StackPanel
  40. Grid.Row="0"
  41. Height="46"
  42. HorizontalAlignment="Center"
  43. Orientation="Horizontal">
  44. <TextBlock
  45. Width="80"
  46. HorizontalAlignment="Center"
  47. VerticalAlignment="Center"
  48. Text="用户名:" />
  49. <TextBox
  50. Width="220"
  51. Height="32"
  52. Background="Transparent"
  53. CaretBrush="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  54. FontSize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=FontSize}"
  55. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  56. Text="{Binding UserName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  57. </StackPanel>
  58. <StackPanel
  59. Grid.Row="1"
  60. Height="46"
  61. HorizontalAlignment="Center"
  62. Orientation="Horizontal">
  63. <TextBlock
  64. Width="80"
  65. HorizontalAlignment="Center"
  66. VerticalAlignment="Center"
  67. Text="用户类型:" />
  68. <ComboBox
  69. Width="220"
  70. Height="32"
  71. Background="Transparent"
  72. DisplayMemberPath="Description"
  73. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  74. ItemsSource="{Binding UserType, Converter={StaticResource EnumToCollectionConverter}, Mode=OneTime}"
  75. SelectedValue="{Binding UserType}"
  76. SelectedValuePath="Value"
  77. Style="{StaticResource ComboBoxStyle1}" />
  78. </StackPanel>
  79. <StackPanel
  80. Grid.Row="2"
  81. Height="46"
  82. HorizontalAlignment="Center"
  83. Orientation="Horizontal">
  84. <TextBlock
  85. Width="80"
  86. HorizontalAlignment="Center"
  87. VerticalAlignment="Center"
  88. Text="密码:" />
  89. <TextBox
  90. Width="220"
  91. Height="32"
  92. Background="Transparent"
  93. CaretBrush="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  94. FontSize="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=FontSize}"
  95. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  96. Text="{Binding PassWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  97. </StackPanel>
  98. <StackPanel Grid.Row="3">
  99. <ListView
  100. MinHeight="622"
  101. FontSize="14"
  102. ItemsSource="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.Shakers}">
  103. <ListView.Style>
  104. <Style TargetType="ListView">
  105. <Setter Property="Background" Value="White" />
  106. <Setter Property="BorderBrush" Value="Transparent" />
  107. <Setter Property="Padding" Value="0" />
  108. <Setter Property="Template">
  109. <Setter.Value>
  110. <ControlTemplate TargetType="{x:Type ListView}">
  111. <Grid Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=ActualHeight}">
  112. <Grid.RowDefinitions>
  113. <RowDefinition Height="36" />
  114. <RowDefinition Height="auto" MaxHeight="540" />
  115. </Grid.RowDefinitions>
  116. <Grid Background="{StaticResource EmbellishBrush}">
  117. <Grid.ColumnDefinitions>
  118. <ColumnDefinition Width="400" />
  119. <ColumnDefinition Width="140" />
  120. </Grid.ColumnDefinitions>
  121. <Line
  122. Grid.Column="0"
  123. HorizontalAlignment="Right"
  124. VerticalAlignment="Center"
  125. Stroke="{StaticResource AuxiliaryBrush}"
  126. StrokeThickness="1"
  127. X1="0"
  128. X2="0"
  129. Y1="0"
  130. Y2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualHeight}" />
  131. <TextBlock
  132. HorizontalAlignment="Center"
  133. VerticalAlignment="Center"
  134. Foreground="{StaticResource MainBrush}"
  135. Text="振动台" />
  136. <TextBlock
  137. Grid.Column="1"
  138. HorizontalAlignment="Center"
  139. VerticalAlignment="Center"
  140. Foreground="{StaticResource MainBrush}"
  141. Text="是否允许" />
  142. </Grid>
  143. <hc:ScrollViewer
  144. Grid.Row="1"
  145. MaxHeight="540"
  146. Padding="0"
  147. HorizontalScrollBarVisibility="Hidden"
  148. VerticalScrollBarVisibility="Auto">
  149. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  150. </hc:ScrollViewer>
  151. </Grid>
  152. </ControlTemplate>
  153. </Setter.Value>
  154. </Setter>
  155. <Setter Property="ItemTemplate">
  156. <Setter.Value>
  157. <DataTemplate>
  158. <Grid>
  159. <Grid.ColumnDefinitions>
  160. <ColumnDefinition Width="400" />
  161. <ColumnDefinition Width="140" />
  162. </Grid.ColumnDefinitions>
  163. <Line
  164. Grid.Column="1"
  165. HorizontalAlignment="Left"
  166. VerticalAlignment="Center"
  167. Stroke="{StaticResource AuxiliaryBrush}"
  168. StrokeThickness="1"
  169. X1="0"
  170. X2="0"
  171. Y1="0"
  172. Y2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualHeight}" />
  173. <Line
  174. Grid.Column="0"
  175. Grid.ColumnSpan="2"
  176. VerticalAlignment="Bottom"
  177. Stroke="{StaticResource AuxiliaryBrush}"
  178. X1="0"
  179. X2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualWidth}"
  180. Y1="0"
  181. Y2="0" />
  182. <TextBlock
  183. HorizontalAlignment="Center"
  184. VerticalAlignment="Center"
  185. Background="Transparent"
  186. Text="{Binding Description, Mode=OneWay}" />
  187. <hc:BulletCheckBox
  188. Grid.Column="1"
  189. Width="86"
  190. Height="32"
  191. hc:BorderElement.CornerRadius="0"
  192. BorderThickness="0"
  193. Cursor="Hand">
  194. <hc:BulletCheckBox.Style>
  195. <Style TargetType="hc:BulletCheckBox" BasedOn="{StaticResource {x:Type hc:BulletCheckBox}}">
  196. <Style.Setters>
  197. <Setter Property="IsChecked">
  198. <Setter.Value>
  199. <MultiBinding Converter="{StaticResource UserAllowClientIDConverter}" Mode="OneWay">
  200. <Binding Mode="OneWay" Path="ClientID" />
  201. <Binding
  202. Mode="OneWay"
  203. Path="Data.SystemConfig.UserPage.AddUserViewModel.ClientIDs"
  204. Source="{StaticResource MainViewModel}" />
  205. </MultiBinding>
  206. </Setter.Value>
  207. </Setter>
  208. </Style.Setters>
  209. </Style>
  210. </hc:BulletCheckBox.Style>
  211. <hc:Interaction.Triggers>
  212. <hc:EventTrigger EventName="Click">
  213. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.AddUserViewModel.ClickCommand}" CommandParameter="{Binding ClientID}" />
  214. </hc:EventTrigger>
  215. </hc:Interaction.Triggers>
  216. </hc:BulletCheckBox>
  217. </Grid>
  218. </DataTemplate>
  219. </Setter.Value>
  220. </Setter>
  221. <Setter Property="ItemContainerStyle">
  222. <Setter.Value>
  223. <Style TargetType="ListViewItem">
  224. <Setter Property="MinHeight" Value="46" />
  225. <Setter Property="Background" Value="Transparent" />
  226. <Setter Property="BorderBrush" Value="Transparent" />
  227. <Setter Property="BorderThickness" Value="0" />
  228. <Setter Property="SnapsToDevicePixels" Value="True" />
  229. <Setter Property="OverridesDefaultStyle" Value="True" />
  230. <Setter Property="Cursor" Value="Hand" />
  231. <Setter Property="IsEnabled" Value="True" />
  232. <Setter Property="Template">
  233. <Setter.Value>
  234. <ControlTemplate TargetType="ListViewItem">
  235. <ContentPresenter />
  236. </ControlTemplate>
  237. </Setter.Value>
  238. </Setter>
  239. </Style>
  240. </Setter.Value>
  241. </Setter>
  242. <Style.Triggers>
  243. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.AddUserViewModel.UserType}" Value="{x:Static model:UserType.SystemAdministrator}">
  244. <Setter Property="IsEnabled" Value="False" />
  245. </DataTrigger>
  246. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.AddUserViewModel.UserType}" Value="{x:Static model:UserType.ClientUser}">
  247. <Setter Property="IsEnabled" Value="True" />
  248. </DataTrigger>
  249. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.AddUserViewModel.UserType}" Value="{x:Static model:UserType.SystemUser}">
  250. <Setter Property="IsEnabled" Value="False" />
  251. </DataTrigger>
  252. </Style.Triggers>
  253. </Style>
  254. </ListView.Style>
  255. </ListView>
  256. </StackPanel>
  257. <StackPanel
  258. Grid.Row="4"
  259. Height="46"
  260. HorizontalAlignment="Center"
  261. VerticalAlignment="Center"
  262. Orientation="Horizontal">
  263. <Button
  264. Width="120"
  265. Height="32"
  266. hc:IconElement.Geometry="{StaticResource YesGeometry}"
  267. hc:IconElement.Height="20"
  268. hc:IconElement.Width="20"
  269. Command="{Binding OkCommand}"
  270. Content="确认"
  271. FontSize="16"
  272. IsEnabled="{Binding CanOk}"
  273. Style="{StaticResource HasIconButton}" />
  274. <Button
  275. Width="120"
  276. Height="32"
  277. Margin="20,0,0,0"
  278. hc:IconElement.Geometry="{StaticResource NoGeometry}"
  279. hc:IconElement.Height="20"
  280. hc:IconElement.Width="20"
  281. Command="{Binding CancelCommand}"
  282. Content="取消"
  283. FontSize="16"
  284. Style="{StaticResource HasIconButton}" />
  285. </StackPanel>
  286. </Grid>
  287. </Border>
  288. </UserControl>