RoleView.xaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Configs.Roles.RoleView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  7. xmlns:micro="clr-namespace:Caliburn.Micro"
  8. xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
  9. xmlns:command="clr-namespace:OpenSEMI.ClientBase.Command"
  10. >
  11. <UserControl.Resources>
  12. <Style x:Key="ViewEnabledBtn" TargetType="{x:Type Button}" BasedOn="{StaticResource ResourceKey={x:Type Button}}">
  13. <Setter Property="Button.IsEnabled" Value="False" />
  14. <Style.Triggers>
  15. <MultiDataTrigger>
  16. <MultiDataTrigger.Conditions>
  17. <Condition Binding="{Binding Permission}" Value="3"></Condition>
  18. <Condition Binding="{Binding ControlMode}" Value="VIEW"></Condition>
  19. </MultiDataTrigger.Conditions>
  20. <Setter Property="Button.IsEnabled" Value="True"/>
  21. </MultiDataTrigger>
  22. </Style.Triggers>
  23. </Style>
  24. <Style x:Key="EditEnabledBtn" TargetType="{x:Type Button}" BasedOn="{StaticResource ResourceKey={x:Type Button}}">
  25. <Setter Property="Button.IsEnabled" Value="False" />
  26. <Style.Triggers>
  27. <MultiDataTrigger>
  28. <MultiDataTrigger.Conditions>
  29. <Condition Binding="{Binding Permission}" Value="3"></Condition>
  30. <Condition Binding="{Binding ControlMode}" Value="EDIT"></Condition>
  31. </MultiDataTrigger.Conditions>
  32. <Setter Property="Button.IsEnabled" Value="True"/>
  33. </MultiDataTrigger>
  34. </Style.Triggers>
  35. </Style>
  36. </UserControl.Resources>
  37. <Grid x:Name="MainTable" MinHeight="450" HorizontalAlignment="Left" MinWidth="1200" Width="1900">
  38. <Grid x:Name="MainField">
  39. <Grid.ColumnDefinitions>
  40. <ColumnDefinition Width="Auto" MinWidth="250"/>
  41. <ColumnDefinition />
  42. </Grid.ColumnDefinitions>
  43. <Grid.RowDefinitions>
  44. <RowDefinition />
  45. <RowDefinition Height="40"/>
  46. </Grid.RowDefinitions>
  47. <GridSplitter Width="5" Grid.Column="1" HorizontalAlignment="Left" BorderThickness="0,8">
  48. <GridSplitter.Background>
  49. <SolidColorBrush/>
  50. </GridSplitter.Background>
  51. </GridSplitter>
  52. <Border BorderBrush="{DynamicResource Tab_BD}" BorderThickness="1" SnapsToDevicePixels="True" Background="{DynamicResource Tab_BG}" Margin="0,20,0,0" Padding="12">
  53. <TreeView HorizontalAlignment="Left" Name="RolesTree" VerticalAlignment="Top">
  54. <TreeView.Style>
  55. <Style TargetType="{x:Type TreeView}" BasedOn="{StaticResource ResourceKey={x:Type TreeView}}">
  56. <Setter Property="TreeView.IsEnabled" Value="False" />
  57. <Style.Triggers>
  58. <DataTrigger Binding="{Binding ControlMode}" Value="VIEW">
  59. <Setter Property="TreeView.IsEnabled" Value="True"/>
  60. </DataTrigger>
  61. </Style.Triggers>
  62. </Style>
  63. </TreeView.Style>
  64. <TreeViewItem Header="Roles" ItemsSource="{Binding RoleList}" IsExpanded="True">
  65. <TreeViewItem.ItemContainerStyle>
  66. <Style x:Name="RoleTreeViewItem" TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}">
  67. <Setter Property="IsSelected" Value="{Binding Path=IsSelected,Mode=TwoWay}"></Setter>
  68. <Style.Triggers>
  69. <Trigger Property="VirtualizingStackPanel.IsVirtualizing" Value="true">
  70. <Setter Property="ItemsPanel">
  71. <Setter.Value>
  72. <ItemsPanelTemplate>
  73. <VirtualizingStackPanel/>
  74. </ItemsPanelTemplate>
  75. </Setter.Value>
  76. </Setter>
  77. </Trigger>
  78. </Style.Triggers>
  79. </Style>
  80. </TreeViewItem.ItemContainerStyle>
  81. <TreeViewItem.ItemTemplate>
  82. <DataTemplate>
  83. <TextBlock Text="{Binding DisplayRoleName}" />
  84. </DataTemplate>
  85. </TreeViewItem.ItemTemplate>
  86. </TreeViewItem>
  87. <command:CommandSource.Trigger>
  88. <command:CommandTriggerGroup>
  89. <command:EventCommandTrigger
  90. RoutedEvent="TreeView.SelectedItemChanged"
  91. CustomParameter="{Binding ElementName=RolesTree,Path=SelectedItem}"
  92. Command="{Binding DataContext.RoleTreeSelectChangedCommand,
  93. RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
  94. </command:CommandTriggerGroup>
  95. </command:CommandSource.Trigger>
  96. </TreeView>
  97. </Border>
  98. <Grid Grid.Column="1" Margin="10,0,0,0">
  99. <Grid.RowDefinitions>
  100. <RowDefinition Height="20"/>
  101. <RowDefinition Height="Auto"/>
  102. <RowDefinition/>
  103. </Grid.RowDefinitions>
  104. <TextBlock TextWrapping="Wrap" Text="Role Property" VerticalAlignment="Top" Foreground="{DynamicResource FG_Black}" FontWeight="Bold" FontSize="14" FontFamily="Arial" Margin="5,0,0,0"/>
  105. <Grid x:Name="Role_Property" Grid.Row="1" Margin="0,0,0,5" IsEnabled="{Binding IsPermission}">
  106. <Grid.RowDefinitions>
  107. <RowDefinition Height="24"/>
  108. <RowDefinition Height="24"/>
  109. <RowDefinition Height="24"/>
  110. <RowDefinition Height="24"/>
  111. </Grid.RowDefinitions>
  112. <Grid x:Name="Role_Name" Grid.Row="0">
  113. <Grid.ColumnDefinitions>
  114. <ColumnDefinition Width="100"/>
  115. <ColumnDefinition/>
  116. </Grid.ColumnDefinitions>
  117. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Title}" Padding="5,1">
  118. <TextBlock Text="Role Name" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
  119. </Border>
  120. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,1,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Column="1" Padding="5,1">
  121. <controls:TextBoxEx Text="{Binding TreeSelectedRole.DisplayRoleName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Stretch" TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedRole.RoleNameTextSaved }" x:Name="textBox1"
  122. HorizontalAlignment="Left" VerticalAlignment="Center" Width="150" IsEnabled="{Binding IsEnabledRoleName}">
  123. <i:Interaction.Triggers>
  124. <i:EventTrigger EventName="TextChanged">
  125. <micro:ActionMessage MethodName="OnRoleChanged">
  126. </micro:ActionMessage>
  127. </i:EventTrigger>
  128. </i:Interaction.Triggers>
  129. </controls:TextBoxEx>
  130. </Border>
  131. </Grid>
  132. <Grid x:Name="Is_Auto_Logout" Grid.Row="1">
  133. <Grid.ColumnDefinitions>
  134. <ColumnDefinition Width="100"/>
  135. <ColumnDefinition/>
  136. </Grid.ColumnDefinitions>
  137. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1,0,1,1" Background="{DynamicResource Table_BG_Title}" Padding="5,1">
  138. <TextBlock Text="Is Auto lock" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
  139. </Border>
  140. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,0,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Column="1" Padding="5,1">
  141. <CheckBox IsChecked="{Binding TreeSelectedRole.DisplayIsAutoLogout}" HorizontalAlignment="Left" VerticalAlignment="Center"
  142. Content=""
  143. Name="checkBox1">
  144. <i:Interaction.Triggers>
  145. <i:EventTrigger EventName="Click">
  146. <micro:ActionMessage MethodName="OnAutoLogoutTimeChecked">
  147. <micro:Parameter Value="$source" />
  148. </micro:ActionMessage>
  149. </i:EventTrigger>
  150. </i:Interaction.Triggers>
  151. </CheckBox>
  152. </Border>
  153. </Grid>
  154. <Grid x:Name="Time" Grid.Row="2">
  155. <Grid.ColumnDefinitions>
  156. <ColumnDefinition Width="100"/>
  157. <ColumnDefinition/>
  158. </Grid.ColumnDefinitions>
  159. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1,0,1,1" Background="{DynamicResource Table_BG_Title}" Padding="5,1">
  160. <TextBlock Text="Time(minutes)" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
  161. </Border>
  162. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,0,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Column="1" Padding="5,1">
  163. <controls:TextBoxEx EditBoxMode="UnSignInteger" Text="{Binding TreeSelectedRole.DisplayAutoLogoutTime,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Stretch" TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedRole.TimeTextSaved }" x:Name="textBox2"
  164. HorizontalAlignment="Left" VerticalAlignment="Center" Width="150" PreviewTextInput="TextBox2_PreviewTextInput">
  165. <i:Interaction.Triggers>
  166. <i:EventTrigger EventName="TextChanged">
  167. <micro:ActionMessage MethodName="OnRoleChanged">
  168. </micro:ActionMessage>
  169. </i:EventTrigger>
  170. </i:Interaction.Triggers>
  171. </controls:TextBoxEx>
  172. </Border>
  173. </Grid>
  174. <Grid x:Name="Description" Grid.Row="3">
  175. <Grid.ColumnDefinitions>
  176. <ColumnDefinition Width="100"/>
  177. <ColumnDefinition/>
  178. </Grid.ColumnDefinitions>
  179. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1,0,1,1" Background="{DynamicResource Table_BG_Title}" Padding="5,1">
  180. <TextBlock Text="Description" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
  181. </Border>
  182. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,1,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Column="1" Padding="5,1">
  183. <controls:TextBoxEx Text="{Binding TreeSelectedRole.DisplayDescription,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Stretch" TextSaved="{Binding Mode=TwoWay, Path=TreeSelectedRole.DescriptionTextSaved }" x:Name="textBox3"
  184. HorizontalAlignment="Left" VerticalAlignment="Center" MinWidth="150">
  185. <i:Interaction.Triggers>
  186. <i:EventTrigger EventName="TextChanged">
  187. <micro:ActionMessage MethodName="OnRoleChanged">
  188. </micro:ActionMessage>
  189. </i:EventTrigger>
  190. </i:Interaction.Triggers>
  191. </controls:TextBoxEx>
  192. </Border>
  193. </Grid>
  194. </Grid>
  195. <TabControl Grid.Row="2">
  196. <TabItem>
  197. <TabItem.Header>
  198. <TextBlock Text="Page Access Permission" FontWeight="Bold"/>
  199. </TabItem.Header>
  200. <ListView AlternationCount="2"
  201. VerticalAlignment="Top"
  202. Name="RolesList"
  203. ScrollViewer.HorizontalScrollBarVisibility="Auto"
  204. ScrollViewer.VerticalScrollBarVisibility="Auto"
  205. ScrollViewer.CanContentScroll="True"
  206. ItemsSource="{Binding Path=TreeSelectedRole.MenuCollection}" IsEnabled="{Binding IsPermission}">
  207. <ListView.View>
  208. <GridView>
  209. <GridViewColumn Width="200" Header="Menu Name" DisplayMemberBinding="{Binding Name}"/>
  210. <GridViewColumn Width="200" Header="Permission Configuration">
  211. <GridViewColumn.CellTemplate>
  212. <DataTemplate >
  213. <ComboBox Width="140" x:Name="combPermission"
  214. DisplayMemberPath="StringPermission"
  215. SelectedIndex="{Binding DisplayIndexPermission}"
  216. ItemsSource="{Binding DataContext.PermissionDictionary,
  217. RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
  218. <i:Interaction.Triggers>
  219. <i:EventTrigger EventName="SelectionChanged">
  220. <micro:ActionMessage MethodName="OnRoleChanged">
  221. </micro:ActionMessage>
  222. </i:EventTrigger>
  223. </i:Interaction.Triggers>
  224. </ComboBox>
  225. </DataTemplate>
  226. </GridViewColumn.CellTemplate>
  227. </GridViewColumn>
  228. </GridView>
  229. </ListView.View>
  230. </ListView>
  231. </TabItem>
  232. </TabControl>
  233. </Grid>
  234. <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
  235. <Button Content="Create" Style="{StaticResource ViewEnabledBtn}" Command="{Binding btnAddRoleCommand}" Height="25" Width="80"/>
  236. <Button Content="Delete" Style="{StaticResource ViewEnabledBtn}" Command="{Binding btnDeleteRoleCommand}" Height="25" Width="80" Margin="10,0,0,0"/>
  237. <Button Content="Clone" Style="{StaticResource ViewEnabledBtn}" Command="{Binding btnCloneRoleCommand}" Height="25" Width="80" Margin="10,0,0,0"/>
  238. <Button Content="Save" Style="{StaticResource EditEnabledBtn}" Command="{Binding btnSaveCommand}" Height="25" Width="80" Margin="10,0,0,0" />
  239. <Button Content="Cancel" Style="{StaticResource EditEnabledBtn}" Command="{Binding BtnCancelRoleCommand}" Height="25" Width="80" Margin="10,0,0,0"/>
  240. </StackPanel>
  241. </Grid>
  242. </Grid>
  243. </UserControl>