LeftCardControl.xaml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. <Style.Triggers>
  23. <MultiTrigger>
  24. <MultiTrigger.Conditions>
  25. <Condition Property="IsMouseOver" Value="False"/>
  26. <Condition Property="IsSelected" Value="False"/>
  27. </MultiTrigger.Conditions>
  28. <MultiTrigger.EnterActions>
  29. <BeginStoryboard>
  30. <Storyboard>
  31. <DoubleAnimation To="15" Duration="0:0:0.5" Storyboard.TargetProperty="FontSize"/>
  32. </Storyboard>
  33. </BeginStoryboard>
  34. </MultiTrigger.EnterActions>
  35. <MultiTrigger.ExitActions>
  36. <BeginStoryboard>
  37. <Storyboard Timeline.DesiredFrameRate="60">
  38. <DoubleAnimation To="18" Duration="0:0:0.001" Storyboard.TargetProperty="FontSize"/>
  39. </Storyboard>
  40. </BeginStoryboard>
  41. </MultiTrigger.ExitActions>
  42. </MultiTrigger>
  43. <Trigger Property="IsMouseOver" Value="True">
  44. <Setter Property="Background" Value="#FFE4DBDB"/>
  45. </Trigger>
  46. <Trigger Property="IsSelected" Value="true">
  47. <Setter Property="Background" Value="#FFECECEC"/>
  48. <Setter Property="Foreground" Value="Black"/>
  49. </Trigger>
  50. </Style.Triggers>
  51. </Style>
  52. <cvt:MenuWidthConvert x:Key="MenuWidthConvert"/>
  53. <cvt:OpcityConvert x:Key="OpcityConvert"/>
  54. </UserControl.Resources>
  55. <!--左侧栏-->
  56. <hc:Card
  57. BorderThickness="1"
  58. Effect="{DynamicResource EffectShadow2}"
  59. Margin="5,0,0,5"
  60. >
  61. <hc:Card.Background>
  62. <SolidColorBrush Color="#FFFFFFFF" Opacity="{Binding AppConfig.CardOpacity, Mode=TwoWay, Converter={StaticResource OpcityConvert}}"/>
  63. </hc:Card.Background>
  64. <hc:Card.BorderBrush>
  65. <SolidColorBrush Color="#FFFFFFFF" Opacity="0"/>
  66. </hc:Card.BorderBrush>
  67. <hc:Card.ContextMenu>
  68. <ContextMenu Width="200">
  69. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  70. </ContextMenu>
  71. </hc:Card.ContextMenu>
  72. <WrapPanel Orientation="Horizontal">
  73. <ListBox x:Name="menus"
  74. ItemsSource="{Binding MenuList}"
  75. Tag="{Binding AppConfig.MenuCardWidth}"
  76. BorderThickness="0" Foreground="{x:Null}"
  77. SelectedIndex="{Binding AppConfig.SelectedMenuIndex}"
  78. VirtualizingPanel.VirtualizationMode="Recycling"
  79. >
  80. <ListBox.Resources>
  81. <ContextMenu x:Key="menuDialog" Width="200">
  82. <MenuItem Header="新建菜单" Click="CreateMenu"/>
  83. <MenuItem Header="重命名" Click="RenameMenu" Tag="{Binding}"/>
  84. <MenuItem Header="修改图标" Click="EditMenuGeometry" Tag="{Binding}"/>
  85. <MenuItem Header="删除" Click="DeleteMenu" Tag="{Binding}"/>
  86. </ContextMenu>
  87. </ListBox.Resources>
  88. <ListBox.ItemContainerStyle>
  89. <Style TargetType="ListBoxItem" BasedOn="{StaticResource MenuStyle}">
  90. <Setter Property="ContextMenu" Value="{StaticResource menuDialog}"/>
  91. </Style>
  92. </ListBox.ItemContainerStyle>
  93. <ListBox.Background>
  94. <SolidColorBrush Color="AliceBlue" Opacity="0"/>
  95. </ListBox.Background>
  96. <ListBox.ItemsPanel>
  97. <ItemsPanelTemplate>
  98. <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}}}"/>
  99. </ItemsPanelTemplate>
  100. </ListBox.ItemsPanel>
  101. <ListBox.ItemTemplate>
  102. <DataTemplate>
  103. <StackPanel MouseLeftButtonDown="MenuClick" Tag="{Binding}">
  104. <hc:TextBox Text="{Binding Path=MenuName, Mode=TwoWay}"
  105. HorizontalAlignment="Left"
  106. Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ListBox},AncestorLevel=1},Path=Tag, Mode=TwoWay, Converter={StaticResource MenuWidthConvert}}"
  107. FontSize="15"
  108. TextAlignment="Left"
  109. LostFocus="LostFocusOrEnterDown"
  110. KeyDown="LostFocusOrEnterDown"
  111. Tag="{Binding}"
  112. IsVisibleChanged="MenuEditWhenVisibilityChanged"
  113. Visibility="{Binding MenuEdit}"/>
  114. <StackPanel Orientation="Horizontal">
  115. <!--<Button Background="Transparent"
  116. BorderThickness="0"
  117. hc:IconElement.Geometry="{StaticResource test}"
  118. hc:IconElement.Height="18"
  119. hc:IconElement.Width="18"
  120. />-->
  121. <!--<Button Background="Transparent" BorderThickness="0" Height="10" Width="10">
  122. <Canvas>
  123. <Path Fill="#92E3C3" Data="M391.68 957.44h-66.56v-158.4128H66.56v-66.56h258.56v-174.08H66.56v-66.56h258.56V307.2h66.56l-0.0512 184.6272h240.6912V307.2h66.56l-0.0512 184.6272H957.44v307.2h-258.6112V957.44h-66.4576l-0.0512-158.4128H391.6288V957.44z m-0.0512-224.9728h240.6912v-174.08H391.6288v174.08z m565.8112-174.08h-258.6112v174.08H957.44v-174.08z"/>
  124. <Path Fill="#5D7092" Data="M51.2 51.2h921.6v256H51.2z"/>
  125. <Path Fill="#5D7092" Data="M921.6 0a102.4 102.4 0 0 1 102.4 102.4v819.2a102.4 102.4 0 0 1-102.4 102.4H102.4a102.4 102.4 0 0 1-102.4-102.4V102.4a102.4 102.4 0 0 1 102.4-102.4h819.2z m0 66.56H102.4a35.84 35.84 0 0 0-35.5328 30.976L66.56 102.4v819.2a35.84 35.84 0 0 0 30.976 35.5328L102.4 957.44h819.2a35.84 35.84 0 0 0 35.5328-30.976L957.44 921.6V102.4a35.84 35.84 0 0 0-30.976-35.5328L921.6 66.56z"/>
  126. </Canvas>
  127. </Button>-->
  128. <!--<TextBlock Text="&#xe606;" Style="{StaticResource MyIcon}"/>-->
  129. <TextBlock Text="&#xe614;" FontFamily="/#IconFont" FontSize="40"/>
  130. <TextBlock Text="{Binding MenuName}"
  131. VerticalAlignment="Center"
  132. IsVisibleChanged="MenuWhenVisibilityChanged"
  133. Visibility="{Binding NotMenuEdit}"
  134. />
  135. </StackPanel>
  136. </StackPanel>
  137. </DataTemplate>
  138. </ListBox.ItemTemplate>
  139. </ListBox>
  140. </WrapPanel>
  141. </hc:Card>
  142. </UserControl>