<UserControl x:Class="XHandler.View.User.MenuManagement"
|
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:XHandler.View.User"
|
xmlns:cls ="clr-namespace:XHandler.View.Classes"
|
xmlns:ctrls="clr-namespace:XHandler.Controls"
|
xmlns:str="clr-namespace:XHandler.Properties"
|
mc:Ignorable="d"
|
d:DesignHeight="450" d:DesignWidth="800" Loaded="UserControl_Loaded">
|
<UserControl.Resources>
|
<Style x:Key="treeViewItemStyle" TargetType="{x:Type TreeViewItem}">
|
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
<Setter Property="Padding" Value="1,0,0,0"/>
|
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="{x:Type TreeViewItem}">
|
<Grid>
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition MinWidth="16" Width="Auto"/>
|
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="Auto"/>
|
</Grid.ColumnDefinitions>
|
<Grid.RowDefinitions>
|
<RowDefinition Height="40"/>
|
<RowDefinition/>
|
</Grid.RowDefinitions>
|
<Border x:Name="BdBack" Margin="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" CornerRadius="3" Background="Transparent"></Border>
|
<ToggleButton x:Name="Expander" Grid.Row="0" Grid.Column="0" Style="{StaticResource ExpandCollapseToggleStyle}" ClickMode="Press" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"/>
|
<Border x:Name="Bd" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" CornerRadius="3" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
|
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="PART_Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header"/>
|
</Border>
|
<ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
|
</Grid>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsExpanded" Value="false">
|
<Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
|
</Trigger>
|
<Trigger Property="HasItems" Value="false">
|
<Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
|
</Trigger>
|
<Trigger Property="IsSelected" Value="true">
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource listSelectedBrush}"/>
|
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
|
</Trigger>
|
<Trigger Property="IsEnabled" Value="false">
|
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
</Trigger>
|
<MultiTrigger>
|
<MultiTrigger.Conditions>
|
<Condition Property="IsMouseOver" Value="true" SourceName="Bd"/>
|
<Condition Property="IsSelected" Value="false"/>
|
</MultiTrigger.Conditions>
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource lightBlueBrush}"/>
|
</MultiTrigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
|
<HierarchicalDataTemplate x:Key="MyTreeItemTemplate"
|
DataType="{x:Type cls:MenuTree}"
|
ItemsSource="{Binding Path=Children,Mode=OneWay}">
|
<StackPanel x:Name="My_SP" Orientation="Horizontal" Margin="2" VerticalAlignment="Center">
|
<CheckBox IsChecked="{Binding Path=IsChecked}" FontSize="16" VerticalAlignment="Center"/>
|
<Image Width="32" Height="32" Visibility="{Binding ImgDefault, Converter={StaticResource String2VisibilityConverter}}">
|
<Image.Source>
|
<MultiBinding Converter="{StaticResource cmdIconMultiConvert}">
|
<Binding Path="ImgDefault"/>
|
<Binding Path="IsChecked"/>
|
<Binding Path="Level"/>
|
</MultiBinding>
|
</Image.Source>
|
</Image>
|
<TextBlock Foreground="Black" FontSize="16" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" />
|
</StackPanel>
|
</HierarchicalDataTemplate>
|
|
<Style TargetType="{x:Type CheckBox}">
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
<Setter Property="Background" Value="White"/>
|
<Setter Property="BorderBrush" Value="#FF616467"/>
|
<Setter Property="FontSize" Value="16"/>
|
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="{x:Type CheckBox}">
|
<Grid x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="*"/>
|
</Grid.ColumnDefinitions>
|
<Border x:Name="checkBoxBorder" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="0" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
Width="20" Height="20" BorderBrush="#FF616467" BorderThickness="1" CornerRadius="5">
|
<Grid x:Name="markGrid">
|
<Path x:Name="optionMark" Data="M5,5 L15,18 L38,0" Stroke="White" StrokeThickness="2" Margin="4" Opacity="0" Stretch="Uniform"/>
|
<Rectangle x:Name="indeterminateMark" Fill="#FF0E81EC" Opacity="1" Margin="3"/>
|
</Grid>
|
</Border>
|
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"
|
Grid.Column="1" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False"
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="5,0,0,0"
|
RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
</Grid>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsChecked" Value="True">
|
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="Transparent"/>
|
<Setter Property="Background" TargetName="checkBoxBorder" Value="#FF0E81EC"/>
|
<Setter Property="Opacity" TargetName="optionMark" Value="1"/>
|
<Setter Property="Opacity" TargetName="indeterminateMark" Value="0"/>
|
</Trigger>
|
<Trigger Property="IsChecked" Value="False">
|
<Setter Property="BorderBrush" TargetName="checkBoxBorder" Value="#FFC6CBD0"/>
|
<Setter Property="Opacity" TargetName="optionMark" Value="0"/>
|
<Setter Property="Opacity" TargetName="indeterminateMark" Value="0"/>
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
|
|
<Style x:Key="menuListBoxStyle" TargetType="ListBox">
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
<Setter Property="BorderBrush" Value="{StaticResource blueBrush}"/>
|
<Setter Property="BorderThickness" Value="1"/>
|
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
|
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
|
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
|
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
|
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="{x:Type ListBox}">
|
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="1" SnapsToDevicePixels="true">
|
<ScrollViewer Focusable="false" Padding="{TemplateBinding Padding}">
|
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
</ScrollViewer>
|
</Border>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsEnabled" Value="false">
|
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Background}"/>
|
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ListBox.Disabled.Border}"/>
|
</Trigger>
|
<MultiTrigger>
|
<MultiTrigger.Conditions>
|
<Condition Property="IsGrouping" Value="true"/>
|
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
|
</MultiTrigger.Conditions>
|
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
|
</MultiTrigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
<Setter Property="ItemsPanel">
|
<Setter.Value>
|
<ItemsPanelTemplate>
|
<StackPanel/>
|
</ItemsPanelTemplate>
|
</Setter.Value>
|
</Setter>
|
<Setter Property="ItemContainerStyle">
|
<Setter.Value>
|
<Style TargetType="ListBoxItem">
|
<Setter Property="Template">
|
<Setter.Value>
|
<ControlTemplate TargetType="ListBoxItem">
|
<Border x:Name="Border" Margin="0" Height="50" BorderThickness="0" Padding="1" Background="{TemplateBinding Background}">
|
<Grid>
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition Width="30"/>
|
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="auto"/>
|
<ColumnDefinition Width="auto"/>
|
|
</Grid.ColumnDefinitions>
|
<CheckBox x:Name="checkbox" IsChecked="{Binding State}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
<Image Name="idCheckImage" Grid.Column="1" Source="{Binding Path=CheckImg}" HorizontalAlignment="Center"
|
VerticalAlignment="Center" Width="30" Height="30" />
|
<TextBlock Grid.Column="2" Text="{Binding Path=Name}" FontSize="16" VerticalAlignment="Center" Margin="0"/>
|
<ctrls:ImageButton Grid.Column="3" x:Name="btnUp" NormalImage="/Assets/btn_moveup.png" Width="40" Height="40" ImageWidth="24" ImageHeight="24" VerticalAlignment="Center" HorizontalAlignment="Right"
|
Margin="0" Visibility="Collapsed" Click="btnUp_Click"/>
|
<ctrls:ImageButton Grid.Column="4" x:Name="btnDown" NormalImage="/Assets/btn_movedown.png" Width="40" Height="40" ImageWidth="24" ImageHeight="24" VerticalAlignment="Center" HorizontalAlignment="Right"
|
Margin="0" Visibility="Collapsed" Click="btnDown_Click"/>
|
</Grid>
|
</Border>
|
<ControlTemplate.Triggers>
|
<Trigger Property="IsSelected" Value="True">
|
<Setter Property="Background" TargetName="Border" Value="{DynamicResource listSelectedBrush}"/>
|
<Setter Property="Visibility" TargetName="btnUp" Value="Visible"/>
|
<Setter Property="Visibility" TargetName="btnDown" Value="Visible"/>
|
|
</Trigger>
|
<Trigger Property="IsMouseOver" Value="True" >
|
<Setter TargetName="Border" Property="Background" Value="{DynamicResource lightBlueBrush}"></Setter>
|
</Trigger>
|
</ControlTemplate.Triggers>
|
</ControlTemplate>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</Setter.Value>
|
</Setter>
|
</Style>
|
</UserControl.Resources>
|
<Grid>
|
<Grid.RowDefinitions>
|
<RowDefinition Height="50"/>
|
<RowDefinition Height="*"/>
|
</Grid.RowDefinitions>
|
<Grid.ColumnDefinitions>
|
<ColumnDefinition Width="50"/>
|
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="50"/>
|
</Grid.ColumnDefinitions>
|
<TextBlock Grid.Row="0" Grid.Column="1" Text="{x:Static str:UserManagementResource.strMenuSet}" FontSize="16" VerticalAlignment="Center"/>
|
<Button Name="btnMenuSave" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" Style="{DynamicResource BlueButtonStyle}" Content="{x:Static str:UserManagementResource.strSave}"
|
Foreground="White" Background="{DynamicResource blueBrush}" Click="btnMenuSave_Click" Width="80" Height="35" Margin="0 0 300 0" FontSize="16"/>
|
<ListBox x:Name="listboxMenu" Grid.Row="1" Grid.Column="1" Style="{DynamicResource menuListBoxStyle}"
|
Margin="0 0 300 0" HorizontalAlignment="Stretch"/>
|
<TextBlock Grid.Row="0" Grid.Column="2" Text="{x:Static str:UserManagementResource.strCommandSet}" FontSize="16" VerticalAlignment="Center"/>
|
<TreeView Grid.Row="1" Grid.Column="2" x:Name="tv" ItemContainerStyle="{StaticResource treeViewItemStyle}" Margin="0 0 300 0"
|
ItemTemplate="{StaticResource MyTreeItemTemplate}" BorderThickness="1" BorderBrush="{StaticResource blueBrush}">
|
</TreeView>
|
|
<Button Name="btnCommandSave" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" Style="{DynamicResource BlueButtonStyle}" Content="{x:Static str:UserManagementResource.strSave}"
|
Foreground="White" Background="{DynamicResource blueBrush}" Click="btnCommandSave_Click" Width="80" Height="35" Margin="0 0 300 0" FontSize="16"/>
|
</Grid>
|
</UserControl>
|