ToolChromeControl.axaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:converters="clr-namespace:Dock.Avalonia.Converters;assembly=SukiUI.Dock"
  4. xmlns:controls="using:Dock.Model.Controls">
  5. <Design.PreviewWith>
  6. <ToolChromeControl Width="300" Height="400" />
  7. </Design.PreviewWith>
  8. <MenuFlyout x:Key="ToolChromeControlContextMenu"
  9. x:DataType="controls:IToolDock" x:CompileBindings="True">
  10. <MenuItem Header="_Float"
  11. Command="{Binding Owner.Factory.FloatDockable}"
  12. CommandParameter="{Binding ActiveDockable}"
  13. IsVisible="{Binding ActiveDockable.CanFloat, FallbackValue=False}"/>
  14. <MenuItem Header="_Dock"
  15. Command="{Binding Owner.Factory.PinDockable}"
  16. CommandParameter="{Binding ActiveDockable}"
  17. IsEnabled="{Binding ActiveDockable.OriginalOwner, Converter={x:Static ObjectConverters.IsNotNull}, FallbackValue=False}"
  18. IsVisible="{Binding ActiveDockable.CanPin, FallbackValue=False}"/>
  19. <MenuItem Header="_Auto Hide"
  20. Command="{Binding Owner.Factory.PinDockable}"
  21. CommandParameter="{Binding ActiveDockable}"
  22. IsEnabled="{Binding ActiveDockable.OriginalOwner, Converter={x:Static ObjectConverters.IsNull}, FallbackValue=False}">
  23. <MenuItem.IsVisible>
  24. <MultiBinding Converter="{x:Static BoolConverters.And}">
  25. <Binding Path="ActiveDockable.CanPin" FallbackValue="{x:False}" />
  26. <Binding Path="$parent[ToolChromeControl].IsFloating" Converter="{x:Static BoolConverters.Not}" />
  27. </MultiBinding>
  28. </MenuItem.IsVisible>
  29. </MenuItem>
  30. <MenuItem Header="_Close"
  31. Command="{Binding Owner.Factory.CloseDockable}"
  32. CommandParameter="{Binding ActiveDockable}"
  33. IsVisible="{Binding ActiveDockable.CanClose, FallbackValue=False}"/>
  34. </MenuFlyout>
  35. <ControlTheme x:Key="ChromeButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}" >
  36. <Setter Property="Margin" Value="2 0 0 0" />
  37. <Setter Property="Padding" Value="3" />
  38. <Setter Property="Background" Value="Transparent" />
  39. <Setter Property="BorderThickness" Value="0" />
  40. <Setter Property="Width" Value="18" />
  41. <Setter Property="Height" Value="16" />
  42. </ControlTheme>
  43. <ControlTheme x:Key="{x:Type ToolChromeControl}" TargetType="ToolChromeControl">
  44. <Setter Property="Background" Value="{DynamicResource DockThemeBackgroundBrush}" />
  45. <Setter Property="BorderBrush" Value="Transparent" />
  46. <Setter Property="BorderThickness" Value="0" />
  47. <Setter Property="Padding" Value="0" />
  48. <Setter Property="IsPinned" Value="{CompiledBinding ActiveDockable.OriginalOwner, FallbackValue=False, Converter={x:Static ObjectConverters.IsNotNull}}" x:DataType="controls:IToolDock" />
  49. <Setter Property="IsMaximized" Value="{CompiledBinding $parent[HostWindow].WindowState, FallbackValue=False, Converter={x:Static IsMaximizedConverter.Instance}}" />
  50. <Setter Property="Template">
  51. <ControlTemplate>
  52. <Grid RowDefinitions="Auto,*" x:DataType="controls:IToolDock" x:CompileBindings="True">
  53. <ContentPresenter x:Name="PART_ContentPresenter"
  54. Background="{TemplateBinding Background}"
  55. BorderBrush="{TemplateBinding BorderBrush}"
  56. BorderThickness="{TemplateBinding BorderThickness}"
  57. Content="{TemplateBinding Content}"
  58. Padding="{TemplateBinding Padding}"
  59. Grid.Row="1" />
  60. <Border x:Name="PART_Border"
  61. BorderBrush="{TemplateBinding BorderBrush}"
  62. VerticalAlignment="Top"
  63. ContextFlyout="{DynamicResource ToolChromeControlContextMenu}"
  64. Grid.Row="{Binding GripMode, Converter={x:Static converters:GripModeConverters.GridRowAutoHideConverter}}">
  65. <Grid x:Name="PART_Grip">
  66. <DockPanel LastChildFill="True" Margin="8 0">
  67. <Panel DockPanel.Dock="Left">
  68. <TextBlock x:Name="PART_Title" FontWeight="DemiBold" FontSize="14"
  69. Text="{Binding ActiveDockable.Title, FallbackValue=TITLE}" />
  70. </Panel>
  71. <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
  72. <Button x:Name="PART_MenuButton"
  73. Theme="{StaticResource ChromeButton}"
  74. Flyout="{StaticResource ToolChromeControlContextMenu}">
  75. <Viewbox Margin="2">
  76. <Path Fill="{DynamicResource SukiLowText}" x:Name="PART_MenuPath" />
  77. </Viewbox>
  78. </Button>
  79. <Button x:Name="PART_PinButton"
  80. Command="{Binding Owner.Factory.PinDockable}"
  81. CommandParameter="{Binding ActiveDockable}"
  82. Theme="{StaticResource ChromeButton}">
  83. <Button.IsVisible>
  84. <MultiBinding Converter="{x:Static BoolConverters.And}">
  85. <Binding Path="ActiveDockable.CanPin" FallbackValue="{x:False}" />
  86. <TemplateBinding Property="IsFloating" Converter="{x:Static BoolConverters.Not}" />
  87. </MultiBinding>
  88. </Button.IsVisible>
  89. <Viewbox>
  90. <Path Fill="{DynamicResource SukiLowText}" x:Name="PART_PinPath" />
  91. </Viewbox>
  92. </Button>
  93. <Button x:Name="PART_MaximizeRestoreButton"
  94. IsVisible="{TemplateBinding IsFloating}"
  95. Theme="{StaticResource ChromeButton}">
  96. <Viewbox>
  97. <Path Fill="{DynamicResource SukiLowText}" x:Name="PART_MaximizeRestorePath" />
  98. </Viewbox>
  99. </Button>
  100. <Button x:Name="PART_CloseButton"
  101. Command="{Binding Owner.Factory.CloseDockable}"
  102. CommandParameter="{Binding ActiveDockable}"
  103. IsVisible="{Binding ActiveDockable.CanClose, FallbackValue=False}"
  104. Theme="{StaticResource ChromeButton}">
  105. <Viewbox>
  106. <Path Fill="{DynamicResource SukiLowText}" x:Name="PART_ClosePath" />
  107. </Viewbox>
  108. </Button>
  109. </StackPanel>
  110. <Panel></Panel>
  111. </DockPanel>
  112. </Grid>
  113. </Border>
  114. <Panel x:Name="PART_Panel"
  115. Background="{TemplateBinding BorderBrush}"
  116. Height="1"
  117. VerticalAlignment="Top"
  118. Grid.Row="{Binding GripMode, Converter={x:Static converters:GripModeConverters.GridRowAutoHideConverter}}" />
  119. </Grid>
  120. </ControlTemplate>
  121. </Setter>
  122. <Style Selector="^/template/ Border#PART_Border">
  123. <Setter Property="BorderThickness" Value="0 0 0 0" />
  124. <Setter Property="IsVisible"
  125. Value="{Binding GripMode, Converter={x:Static converters:GripModeConverters.IsVisibleVisibleConverter}}" />
  126. </Style>
  127. <Style Selector="^:pointerover /template/ Border#PART_Border">
  128. <Setter Property="IsVisible"
  129. Value="{Binding GripMode, Converter={x:Static converters:GripModeConverters.IsVisibleAutoHideOrVisibleConverter}}" />
  130. </Style>
  131. <Style Selector="^:floating /template/ Border#PART_Border">
  132. <Setter Property="BorderThickness" Value="0" />
  133. </Style>
  134. <Style Selector="^/template/ Panel#PART_Panel">
  135. <Setter Property="IsVisible"
  136. Value="{Binding GripMode, Converter={x:Static converters:GripModeConverters.IsVisibleAutoHideOrHiddenConverter}}" />
  137. </Style>
  138. <Style Selector="^:pointerover /template/ Panel#PART_Panel">
  139. <Setter Property="IsVisible"
  140. Value="{Binding GripMode, Converter={x:Static converters:GripModeConverters.IsVisibleVisibleOrHiddenConverter}}" />
  141. </Style>
  142. <Style Selector="^:floating:pointerover /template/ Panel#PART_Panel">
  143. <Setter Property="Height" Value="0" />
  144. <Setter Property="IsVisible" Value="False" />
  145. </Style>
  146. <Style Selector="^/template/ TextBlock#PART_Title">
  147. <Setter Property="Background" Value="Transparent" />
  148. <Setter Property="HorizontalAlignment" Value="Left" />
  149. <Setter Property="TextAlignment" Value="Left" />
  150. <Setter Property="VerticalAlignment" Value="Stretch" />
  151. <Setter Property="Margin" Value="0 4 8 4" />
  152. <Setter Property="(TextElement.FontSize)" Value="{DynamicResource DockFontSizeNormal}" />
  153. </Style>
  154. <Style Selector="^:active /template/ TextBlock#PART_Title">
  155. <Setter Property="Background" Value="Transparent" />
  156. <Setter Property="Foreground" Value="{DynamicResource DockApplicationAccentForegroundBrush}" />
  157. </Style>
  158. <Style Selector="^/template/ Grid#PART_Grip">
  159. <Setter Property="Background" Value="{DynamicResource DockThemeBackgroundBrush}" />
  160. </Style>
  161. <Style Selector="^/template/ Grid#PART_Grip">
  162. <Setter Property="(DockProperties.IsDragArea)" Value="True" />
  163. </Style>
  164. <Style Selector="^:floating /template/ Grid#PART_Grip">
  165. <Setter Property="(DockProperties.IsDragArea)" Value="{Binding $parent[HostWindow].ToolChromeControlsWholeWindow, Mode=OneWay, Converter={x:Static BoolConverters.Not}}" />
  166. </Style>
  167. <Style Selector="^:active /template/ Grid#PART_Grip">
  168. <Setter Property="Background" Value="Transparent" />
  169. </Style>
  170. <Style Selector="^/template/ Path">
  171. <Setter Property="Stretch" Value="UniformToFill" />
  172. </Style>
  173. <Style Selector="^/template/ Path#PART_ClosePath">
  174. <Setter Property="Data"
  175. Value="M1169 1024l879 -879l-145 -145l-879 879l-879 -879l-145 145l879 879l-879 879l145 145l879 -879l879 879l145 -145z" />
  176. </Style>
  177. <Style Selector="^/template/ Path#PART_MaximizeRestorePath">
  178. <Setter Property="Data" Value="M0,0L0,9 9,9 9,0 0,0 0,3 8,3 8,8 1,8 1,3 0,3z" />
  179. </Style>
  180. <Style Selector="^/template/ Path#PART_PinPath">
  181. <Setter Property="Data" Value="m0 1345.575 218.834 0 0-1121.5042 0-177.2397 0-46.8138 673.827 0 416.57 0 32.417 0 0 1345.5577 230.153 0 0 224.0546-672.133 0 0 894.3935-225.764 0 0-894.3935-673.904 0 0-224.0546zm444.598-1121.4996 0 1121.4996 448.063 0 0-1121.4996-448.063 0z" />
  182. </Style>
  183. <Style Selector="^/template/ Path#PART_MenuPath">
  184. <Setter Property="Data" Value="M 352.041,32.0005L 320,0.000162761L 384,0.000162761L 352.041,32.0005 Z " />
  185. </Style>
  186. <Style Selector="^:pinned /template/ Path#PART_PinPath">
  187. <Setter Property="Data" Value="m1119 0 0 218.834 1121.5042 0 177.2397 0 46.8138 0 0 673.827 0 416.57 0 32.417-1345.5577 0 0 230.153-224.0546 0 0-672.133-894.3935 0 0-225.764 894.3935 0 0-673.904zm1121.4996 444.598-1121.4996 0 0 448.063 1121.4996 0 0-448.063z" />
  188. </Style>
  189. <Style Selector="^:maximized /template/ Path#PART_MaximizeRestorePath">
  190. <Setter Property="Data" Value="M0,10L0,3 3,3 3,0 10,0 10,2 4,2 4,3 7,3 7,6 6,6 6,5 1,5 1,10z M1,10L7,10 7,7 10,7 10,2 9,2 9,6 6,6 6,9 1,9z" />
  191. </Style>
  192. </ControlTheme>
  193. </ResourceDictionary>