LeftCardControl.xaml 8.5 KB

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