UserPageView.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <UserControl
  2. x:Class="ShakerManger.View.UserPageView"
  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. d:DataContext="{d:DesignInstance {x:Type vm:UserPageViewModel}}"
  12. d:DesignHeight="450"
  13. d:DesignWidth="800"
  14. DataContext="{Binding UserPage}"
  15. FontSize="16"
  16. IsEnabled="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=IsAnonymous, Converter={StaticResource Boolean2BooleanReConverter}}"
  17. mc:Ignorable="d">
  18. <UserControl.Style>
  19. <Style TargetType="UserControl">
  20. <Style.Triggers>
  21. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.SystemAdministrator}">
  22. <Setter Property="IsEnabled" Value="True" />
  23. </DataTrigger>
  24. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.ClientUser}">
  25. <Setter Property="IsEnabled" Value="False" />
  26. </DataTrigger>
  27. <DataTrigger Binding="{Binding Source={x:Static vm:LoginViewModel.Default}, Path=UserType}" Value="{x:Static model:UserType.SystemUser}">
  28. <Setter Property="IsEnabled" Value="False" />
  29. </DataTrigger>
  30. </Style.Triggers>
  31. </Style>
  32. </UserControl.Style>
  33. <Grid
  34. Margin="0,20,0,0"
  35. HorizontalAlignment="Center"
  36. VerticalAlignment="Top">
  37. <Grid.RowDefinitions>
  38. <RowDefinition Height="46" />
  39. <RowDefinition Height="46" />
  40. <RowDefinition Height="46" />
  41. <RowDefinition Height="auto" />
  42. <RowDefinition Height="46" />
  43. </Grid.RowDefinitions>
  44. <StackPanel
  45. Grid.Row="0"
  46. Height="46"
  47. HorizontalAlignment="Center"
  48. Orientation="Horizontal">
  49. <TextBlock
  50. Width="80"
  51. HorizontalAlignment="Center"
  52. VerticalAlignment="Center"
  53. Text="当前用户:" />
  54. <ComboBox
  55. Width="220"
  56. Height="32"
  57. Background="Transparent"
  58. DisplayMemberPath="UserName"
  59. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  60. ItemsSource="{Binding Users}"
  61. SelectedValue="{Binding SelectedUser}"
  62. Style="{StaticResource ComboBoxStyle1}" />
  63. </StackPanel>
  64. <StackPanel
  65. Grid.Row="1"
  66. HorizontalAlignment="Center"
  67. Orientation="Horizontal">
  68. <TextBlock
  69. Width="80"
  70. HorizontalAlignment="Center"
  71. VerticalAlignment="Center"
  72. Text="用户名:" />
  73. <TextBox
  74. Width="220"
  75. Height="32"
  76. Background="Transparent"
  77. CaretBrush="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  78. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  79. Text="{Binding SelectedUser.UserName}" />
  80. </StackPanel>
  81. <StackPanel
  82. Grid.Row="2"
  83. Height="46"
  84. HorizontalAlignment="Center"
  85. Orientation="Horizontal">
  86. <TextBlock
  87. Width="80"
  88. HorizontalAlignment="Center"
  89. VerticalAlignment="Center"
  90. Text="用户类型:" />
  91. <ComboBox
  92. Width="220"
  93. Height="32"
  94. Background="Transparent"
  95. DisplayMemberPath="Description"
  96. Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=Foreground}"
  97. ItemsSource="{Binding SelectedUser.UserType, Converter={StaticResource EnumToCollectionConverter}, Mode=OneTime}"
  98. SelectedValue="{Binding SelectedUser.UserType}"
  99. SelectedValuePath="Value"
  100. Style="{StaticResource ComboBoxStyle1}" />
  101. </StackPanel>
  102. <StackPanel Grid.Row="3">
  103. <ListView
  104. MinHeight="622"
  105. FontSize="14"
  106. ItemsSource="{Binding Source={StaticResource MainViewModel}, Path=Data.Shakers.Shakers}">
  107. <ListView.Style>
  108. <Style TargetType="ListView">
  109. <Setter Property="Background" Value="White" />
  110. <Setter Property="BorderBrush" Value="Transparent" />
  111. <Setter Property="Padding" Value="0" />
  112. <Setter Property="Template">
  113. <Setter.Value>
  114. <ControlTemplate TargetType="{x:Type ListView}">
  115. <Grid Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=ActualHeight}">
  116. <Grid.RowDefinitions>
  117. <RowDefinition Height="36" />
  118. <RowDefinition Height="auto" MaxHeight="540" />
  119. </Grid.RowDefinitions>
  120. <Grid Background="{StaticResource EmbellishBrush}">
  121. <Grid.ColumnDefinitions>
  122. <ColumnDefinition Width="400" />
  123. <ColumnDefinition Width="140" />
  124. </Grid.ColumnDefinitions>
  125. <Line
  126. Grid.Column="0"
  127. HorizontalAlignment="Right"
  128. VerticalAlignment="Center"
  129. Stroke="{StaticResource AuxiliaryBrush}"
  130. StrokeThickness="1"
  131. X1="0"
  132. X2="0"
  133. Y1="0"
  134. Y2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualHeight}" />
  135. <TextBlock
  136. HorizontalAlignment="Center"
  137. VerticalAlignment="Center"
  138. Foreground="{StaticResource MainBrush}"
  139. Text="振动台" />
  140. <TextBlock
  141. Grid.Column="1"
  142. HorizontalAlignment="Center"
  143. VerticalAlignment="Center"
  144. Foreground="{StaticResource MainBrush}"
  145. Text="是否允许" />
  146. </Grid>
  147. <hc:ScrollViewer
  148. Grid.Row="1"
  149. MaxHeight="540"
  150. Padding="0"
  151. HorizontalScrollBarVisibility="Hidden"
  152. VerticalScrollBarVisibility="Auto">
  153. <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  154. </hc:ScrollViewer>
  155. </Grid>
  156. </ControlTemplate>
  157. </Setter.Value>
  158. </Setter>
  159. <Setter Property="ItemTemplate">
  160. <Setter.Value>
  161. <DataTemplate>
  162. <Grid>
  163. <Grid.ColumnDefinitions>
  164. <ColumnDefinition Width="400" />
  165. <ColumnDefinition Width="140" />
  166. </Grid.ColumnDefinitions>
  167. <Line
  168. Grid.Column="1"
  169. HorizontalAlignment="Left"
  170. VerticalAlignment="Center"
  171. Stroke="{StaticResource AuxiliaryBrush}"
  172. StrokeThickness="1"
  173. X1="0"
  174. X2="0"
  175. Y1="0"
  176. Y2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualHeight}" />
  177. <Line
  178. Grid.Column="0"
  179. Grid.ColumnSpan="2"
  180. VerticalAlignment="Bottom"
  181. Stroke="{StaticResource AuxiliaryBrush}"
  182. X1="0"
  183. X2="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, Path=ActualWidth}"
  184. Y1="0"
  185. Y2="0" />
  186. <TextBlock
  187. HorizontalAlignment="Center"
  188. VerticalAlignment="Center"
  189. Background="Transparent"
  190. Text="{Binding Description, Mode=OneWay}" />
  191. <hc:BulletCheckBox
  192. Grid.Column="1"
  193. Width="86"
  194. Height="32"
  195. hc:BorderElement.CornerRadius="0"
  196. BorderThickness="0"
  197. Cursor="Hand">
  198. <hc:BulletCheckBox.Style>
  199. <Style TargetType="hc:BulletCheckBox" BasedOn="{StaticResource {x:Type hc:BulletCheckBox}}">
  200. <Style.Setters>
  201. <Setter Property="IsChecked">
  202. <Setter.Value>
  203. <MultiBinding Converter="{StaticResource UserAllowClientIDConverter}" Mode="OneWay">
  204. <Binding Mode="OneWay" Path="ClientID" />
  205. <Binding
  206. Mode="OneWay"
  207. Path="Data.SystemConfig.UserPage.SelectedUser.ClientIDs"
  208. Source="{StaticResource MainViewModel}" />
  209. </MultiBinding>
  210. </Setter.Value>
  211. </Setter>
  212. </Style.Setters>
  213. </Style>
  214. </hc:BulletCheckBox.Style>
  215. <hc:Interaction.Triggers>
  216. <hc:EventTrigger EventName="Click">
  217. <hc:ExInvokeCommandAction Command="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.SelectedUser.ClickCommand}" CommandParameter="{Binding ClientID}" />
  218. </hc:EventTrigger>
  219. </hc:Interaction.Triggers>
  220. </hc:BulletCheckBox>
  221. </Grid>
  222. </DataTemplate>
  223. </Setter.Value>
  224. </Setter>
  225. <Setter Property="ItemContainerStyle">
  226. <Setter.Value>
  227. <Style TargetType="ListViewItem">
  228. <Setter Property="MinHeight" Value="46" />
  229. <Setter Property="Background" Value="Transparent" />
  230. <Setter Property="BorderBrush" Value="Transparent" />
  231. <Setter Property="BorderThickness" Value="0" />
  232. <Setter Property="SnapsToDevicePixels" Value="True" />
  233. <Setter Property="OverridesDefaultStyle" Value="True" />
  234. <Setter Property="Cursor" Value="Hand" />
  235. <Setter Property="IsEnabled" Value="True" />
  236. <Setter Property="Template">
  237. <Setter.Value>
  238. <ControlTemplate TargetType="ListViewItem">
  239. <ContentPresenter />
  240. </ControlTemplate>
  241. </Setter.Value>
  242. </Setter>
  243. </Style>
  244. </Setter.Value>
  245. </Setter>
  246. <Style.Triggers>
  247. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.SelectedUser.UserType}" Value="{x:Static model:UserType.SystemAdministrator}">
  248. <Setter Property="IsEnabled" Value="False" />
  249. </DataTrigger>
  250. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.SelectedUser.UserType}" Value="{x:Static model:UserType.ClientUser}">
  251. <Setter Property="IsEnabled" Value="True" />
  252. </DataTrigger>
  253. <DataTrigger Binding="{Binding Source={StaticResource MainViewModel}, Path=Data.SystemConfig.UserPage.SelectedUser.UserType}" Value="{x:Static model:UserType.SystemUser}">
  254. <Setter Property="IsEnabled" Value="False" />
  255. </DataTrigger>
  256. </Style.Triggers>
  257. </Style>
  258. </ListView.Style>
  259. </ListView>
  260. </StackPanel>
  261. <StackPanel
  262. Grid.Row="4"
  263. Height="46"
  264. HorizontalAlignment="Center"
  265. VerticalAlignment="Center"
  266. Orientation="Horizontal">
  267. <Button
  268. Width="120"
  269. Height="32"
  270. hc:IconElement.Geometry="{StaticResource AddUserGeometry}"
  271. hc:IconElement.Height="20"
  272. hc:IconElement.Width="20"
  273. Command="{Binding AddUserCommand}"
  274. Content="新增用户"
  275. Style="{StaticResource HasIconButton}" />
  276. <Button
  277. Width="120"
  278. Height="32"
  279. Margin="20,0,0,0"
  280. hc:IconElement.Geometry="{StaticResource SaveGeometry}"
  281. hc:IconElement.Height="20"
  282. hc:IconElement.Width="20"
  283. Command="{Binding SaveUserCommand}"
  284. Content="保存"
  285. IsEnabled="{Binding SelectedUser.IsChanged}"
  286. Style="{StaticResource HasIconButton}" />
  287. <Button
  288. Width="120"
  289. Height="32"
  290. Margin="20,0,0,0"
  291. hc:IconElement.Geometry="{StaticResource EditPasswordGeometry}"
  292. hc:IconElement.Height="20"
  293. hc:IconElement.Width="20"
  294. Command="{Binding ResetPasswordCommand}"
  295. Content="修改密码"
  296. IsEnabled="{Binding IsLocalUser}"
  297. Style="{StaticResource HasIconButton}" />
  298. <Button
  299. Width="120"
  300. Height="32"
  301. Margin="20,0,0,0"
  302. hc:IconElement.Geometry="{StaticResource DelUserGeometry}"
  303. hc:IconElement.Height="20"
  304. hc:IconElement.Width="20"
  305. Command="{Binding DeleteUserCommand}"
  306. Content="删除用户"
  307. IsEnabled="{Binding IsLocalUser}"
  308. Style="{StaticResource HasIconButton}" />
  309. </StackPanel>
  310. </Grid>
  311. </UserControl>