LeftCardControl.xaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <UserControl x:Class="GeekDesk.Control.UserControls.PannelCard.LeftCardControl"
  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:local="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
  7. xmlns:hc="https://handyorg.github.io/handycontrol"
  8. xmlns:cvt="clr-namespace:GeekDesk.Converts"
  9. xmlns:DraggAnimatedPanel="clr-namespace:DraggAnimatedPanel"
  10. mc:Ignorable="d"
  11. d:DesignHeight="450" d:DesignWidth="800">
  12. <UserControl.Resources>
  13. <!--左侧栏样式动画-->
  14. <Style x:Key="MenuStyle" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemBaseStyle}">
  15. <Setter Property="FontSize" Value="16"/>
  16. <Setter Property="Margin" Value="0,0,0,1"/>
  17. <Setter Property="Background">
  18. <Setter.Value>
  19. <SolidColorBrush Opacity="0"/>
  20. </Setter.Value>
  21. </Setter>
  22. <Setter Property="FocusVisualStyle" Value="{x:Null}" />
  23. <EventSetter Event="MouseLeftButtonDown" Handler="MenuClick"/>
  24. <EventSetter Event="MouseRightButtonDown" Handler="MenuClick"/>
  25. <Style.Triggers>
  26. <MultiTrigger>
  27. <MultiTrigger.Conditions>
  28. <Condition Property="IsMouseOver" Value="False"/>
  29. <Condition Property="IsSelected" Value="False"/>
  30. </MultiTrigger.Conditions>
  31. <MultiTrigger.EnterActions>
  32. <BeginStoryboard>
  33. <Storyboard Timeline.DesiredFrameRate="60">
  34. <DoubleAnimation To="16" Duration="0:0:0.2" Storyboard.TargetProperty="FontSize"/>
  35. </Storyboard>
  36. </BeginStoryboard>
  37. </MultiTrigger.EnterActions>
  38. <MultiTrigger.ExitActions>
  39. <BeginStoryboard>
  40. <Storyboard Timeline.DesiredFrameRate="60">
  41. <DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
  42. </Storyboard>
  43. </BeginStoryboard>
  44. </MultiTrigger.ExitActions>
  45. </MultiTrigger>
  46. <!--<Trigger Property="IsMouseOver" Value="True">
  47. <Setter Property="Background" Value="#FFE4DBDB"/>
  48. </Trigger>-->
  49. <Trigger Property="IsSelected" Value="true">
  50. <Setter Property="Background" Value="#FFECECEC"/>
  51. <Setter Property="Foreground" Value="Black"/>
  52. </Trigger>
  53. </Style.Triggers>
  54. </Style>
  55. <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
  56. <cvt:OpcityConvert x:Key="OpcityConvert"/>
  57. </UserControl.Resources>
  58. <!--左侧栏-->
  59. <hc:Card x:Name="MyCard"
  60. BorderThickness="1"
  61. Effect="{DynamicResource EffectShadow2}"
  62. Margin="5,0,0,5"
  63. >
  64. <hc:Card.Background>
  65. <SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
  66. </SolidColorBrush>
  67. </hc:Card.Background>
  68. <hc:Card.BorderBrush>
  69. <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
  70. </hc:Card.BorderBrush>
  71. <hc:Card.ContextMenu>
  72. <ContextMenu Width="200">
  73. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  74. </ContextMenu>
  75. </hc:Card.ContextMenu>
  76. <WrapPanel Orientation="Horizontal">
  77. <ListBox x:Name="MenuListBox"
  78. ItemsSource="{Binding MenuList}"
  79. Tag="{Binding AppConfig.MenuCardWidth}"
  80. BorderThickness="0" Foreground="{x:Null}"
  81. SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
  82. VirtualizingPanel.VirtualizationMode="Recycling"
  83. SelectionChanged="menus_SelectionChanged"
  84. >
  85. <ListBox.Resources>
  86. <ContextMenu x:Key="MenuDialog" Width="200">
  87. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  88. <MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
  89. <MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
  90. <MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
  91. </ContextMenu>
  92. </ListBox.Resources>
  93. <ListBox.ItemContainerStyle>
  94. <Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
  95. <Setter Property="ContextMenu" Value="{StaticResource MenuDialog}"/>
  96. </Style>
  97. </ListBox.ItemContainerStyle>
  98. <ListBox.Background>
  99. <SolidColorBrush Color="AliceBlue" Opacity="0"/>
  100. </ListBox.Background>
  101. <ListBox.ItemsPanel>
  102. <ItemsPanelTemplate>
  103. <DraggAnimatedPanel:DraggAnimatedPanel ItemsHeight="33" ItemsWidth="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=10}" HorizontalAlignment="Center" VerticalAlignment="Top" SwapCommand="{Binding SwapCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"/>
  104. </ItemsPanelTemplate>
  105. </ListBox.ItemsPanel>
  106. <ListBox.ItemTemplate>
  107. <DataTemplate>
  108. <StackPanel MouseLeftButtonDown="MenuClick" MouseRightButtonDown="MenuClick" Tag="{Binding}">
  109. <hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
  110. HorizontalAlignment="Left"
  111. Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
  112. FontSize="16"
  113. Height="25"
  114. VerticalAlignment="Center"
  115. TextAlignment="Left"
  116. LostFocus="LostFocusOrEnterDown"
  117. KeyDown="LostFocusOrEnterDown"
  118. Tag="{Binding}"
  119. Margin="2"
  120. IsVisibleChanged="MenuEditWhenVisibilityChanged"
  121. Visibility="{Binding MenuEdit}"/>
  122. <StackPanel Orientation="Horizontal">
  123. <Button Background="Transparent"
  124. BorderThickness="0"
  125. hc:IconElement.Geometry="{Binding MenuGeometry}"
  126. hc:IconElement.Height="18"
  127. hc:IconElement.Width="18"
  128. IsEnabled="False"
  129. Opacity="1"
  130. Foreground="{Binding GeometryColor}"
  131. />
  132. <TextBlock Text="{Binding MenuName}"
  133. HorizontalAlignment="Center"
  134. TextAlignment="Center"
  135. VerticalAlignment="Center"
  136. IsVisibleChanged="MenuWhenVisibilityChanged"
  137. Visibility="{Binding NotMenuEdit}"
  138. />
  139. </StackPanel>
  140. </StackPanel>
  141. </DataTemplate>
  142. </ListBox.ItemTemplate>
  143. </ListBox>
  144. </WrapPanel>
  145. </hc:Card>
  146. </UserControl>