LeftCardControl.xaml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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="MouseEnter" Handler="Menu_MouseEnter"/>
  24. <!--<EventSetter Event="Unselected" Handler="Lbi_Unselected"/>-->
  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.Setters>
  46. <Setter Property="Background" Value="Transparent"/>
  47. <Setter Property="Foreground" Value="Black"/>
  48. </MultiTrigger.Setters>
  49. </MultiTrigger>
  50. <!--移到代码设置-->
  51. <!--<Trigger Property="IsSelected" Value="False">
  52. <Setter Property="Background" Value="Transparent"/>
  53. <Setter Property="Foreground" Value="Black"/>
  54. </Trigger>
  55. <Trigger Property="IsSelected" Value="True">
  56. <Setter Property="Background" Value="#ECECEC"/>
  57. <Setter Property="Foreground" Value="Black"/>
  58. </Trigger>
  59. <Trigger Property="IsMouseOver" Value="False">
  60. <Setter Property="Background" Value="Transparent"/>
  61. <Setter Property="Foreground" Value="Black"/>
  62. </Trigger>-->
  63. <Trigger Property="IsMouseOver" Value="False">
  64. <Setter Property="Background" Value="Transparent"/>
  65. <Setter Property="Foreground" Value="Black"/>
  66. </Trigger>
  67. </Style.Triggers>
  68. </Style>
  69. <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
  70. <cvt:OpcityConvert x:Key="OpcityConvert"/>
  71. </UserControl.Resources>
  72. <!--左侧栏-->
  73. <hc:Card x:Name="MyCard"
  74. BorderThickness="1"
  75. Effect="{DynamicResource EffectShadow2}"
  76. Margin="5,0,0,5"
  77. MouseDown="MyCard_MouseDown"
  78. >
  79. <hc:Card.Background>
  80. <SolidColorBrush Color="#FFFFFFFF" hc:GeometryEffect.GeometryEffect="20" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}">
  81. </SolidColorBrush>
  82. </hc:Card.Background>
  83. <hc:Card.BorderBrush>
  84. <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
  85. </hc:Card.BorderBrush>
  86. <hc:Card.ContextMenu>
  87. <ContextMenu Width="200">
  88. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  89. </ContextMenu>
  90. </hc:Card.ContextMenu>
  91. <WrapPanel Orientation="Horizontal">
  92. <ListBox x:Name="MenuListBox"
  93. Padding="2,3,0,2"
  94. ItemsSource="{Binding MenuList}"
  95. Tag="{Binding AppConfig.MenuCardWidth}"
  96. BorderThickness="0" Foreground="{x:Null}"
  97. SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
  98. VirtualizingPanel.VirtualizationMode="Recycling"
  99. SelectionChanged="Menu_SelectionChanged"
  100. >
  101. <ListBox.Resources>
  102. <ContextMenu x:Key="MenuDialog" Width="200">
  103. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  104. <MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
  105. <MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
  106. <MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
  107. </ContextMenu>
  108. </ListBox.Resources>
  109. <ListBox.ItemContainerStyle>
  110. <Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
  111. <Setter Property="ContextMenu" Value="{StaticResource MenuDialog}"/>
  112. </Style>
  113. </ListBox.ItemContainerStyle>
  114. <ListBox.Background>
  115. <SolidColorBrush Color="AliceBlue" Opacity="0"/>
  116. </ListBox.Background>
  117. <ListBox.ItemsPanel>
  118. <ItemsPanelTemplate>
  119. <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}}}"/>
  120. </ItemsPanelTemplate>
  121. </ListBox.ItemsPanel>
  122. <ListBox.ItemTemplate>
  123. <DataTemplate>
  124. <StackPanel Tag="{Binding}" MouseDown="ListBoxItem_MouseDown">
  125. <TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
  126. HorizontalAlignment="Left"
  127. Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}, ConverterParameter=35}"
  128. FontSize="16"
  129. Height="28"
  130. VerticalAlignment="Center"
  131. TextAlignment="Left"
  132. LostFocus="LostFocusOrEnterDown"
  133. KeyDown="LostFocusOrEnterDown"
  134. Tag="{Binding}"
  135. Padding="2"
  136. BorderThickness="0"
  137. IsVisibleChanged="MenuEditWhenVisibilityChanged"
  138. Visibility="{Binding MenuEdit}"/>
  139. <StackPanel Orientation="Horizontal"
  140. IsVisibleChanged="MenuWhenVisibilityChanged"
  141. Visibility="{Binding NotMenuEdit}">
  142. <Button Background="Transparent"
  143. BorderThickness="0"
  144. hc:IconElement.Geometry="{Binding MenuGeometry}"
  145. hc:IconElement.Height="18"
  146. hc:IconElement.Width="18"
  147. IsEnabled="False"
  148. Opacity="1"
  149. Foreground="{Binding GeometryColor}"
  150. />
  151. <TextBlock Text="{Binding MenuName}"
  152. HorizontalAlignment="Center"
  153. TextAlignment="Center"
  154. VerticalAlignment="Center"
  155. />
  156. </StackPanel>
  157. </StackPanel>
  158. </DataTemplate>
  159. </ListBox.ItemTemplate>
  160. </ListBox>
  161. </WrapPanel>
  162. </hc:Card>
  163. </UserControl>