mind 工具栏

This commit is contained in:
艾竹
2023-03-19 12:38:08 +08:00
parent 8d87f61c07
commit c2f4d3c706
12 changed files with 312 additions and 213 deletions

View File

@@ -7,35 +7,34 @@
<ResourceDictionary Source="pack://application:,,,/AIStudio.Wpf.Mind;component/Controls/ColorCanvas.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Geometry x:Key="DownArrowGeometry">M0,0 L3,0 4.5,1.5 6,0 9,0 4.5,4.5 z</Geometry>
<Geometry x:Key="DownArrowGeometry">M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z</Geometry>
<Style x:Key="ColorPickerToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid SnapsToDevicePixels="True">
<Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<ContentPresenter Content="{TemplateBinding Content}"
<ContentPresenter Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</Border>
<Grid x:Name="arrowGlyph" Grid.Column="1" Margin="5">
<Grid x:Name="arrowGlyph" Grid.Column="1">
<Path x:Name="Arrow"
Width="9"
Height="5"
Height="6"
Margin="0 0 3 0"
Stretch="Fill"
Data="{StaticResource DownArrowGeometry}"
Fill="#FF000000"
Margin="0,1,0,0"/>
Fill="#FF000000"/>
</Grid>
</Grid>
@@ -113,12 +112,6 @@
<Setter TargetName="_outerBorder" Property="BorderBrush" Value="#FFFF0000" />
<Setter TargetName="_innerBorder" Property="BorderBrush" Value="#FFFFFF00" />
</Trigger>
<DataTrigger Binding="{Binding DisplayColorAndName, RelativeSource={RelativeSource AncestorType={x:Type controls:ColorPicker}}}"
Value="False">
<Setter Property="ToolTip"
Value="{x:Static sys:String.Empty}"
TargetName="mainGrid" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
@@ -196,11 +189,9 @@
<ContentPresenter x:Name="contentPresenter"
ContentSource="Header"
Focusable="False"
HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Grid>
<ControlTemplate.Triggers>
<MultiDataTrigger>
@@ -224,45 +215,37 @@
<Setter Property="Background" Value="White" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BorderBrush" Value="Gray" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="MaxDropDownWidth" Value="218" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="Padding" Value="3,0" />
<Setter Property="DisplayColorAndName" Value="True"/>
<Setter Property="Padding" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ColorPicker}">
<Grid x:Name="PART_Root">
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
CornerRadius="3"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"/>
<Grid x:Name="PART_InnerGrid" Margin="{TemplateBinding Padding}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0" />
</Grid.ColumnDefinitions>
<Grid>
<ContentControl x:Name="ColorOnly" Style="{StaticResource ColorDisplayStyle}" />
<Border x:Name="ColorAndName" Background="White" Visibility="Hidden">
<StackPanel Orientation="Horizontal">
<ContentControl HorizontalAlignment="Left" Width="20" Margin="2,1,4,1" Style="{StaticResource ColorDisplayStyle}" BorderThickness="1" BorderBrush="#FFC9CACA" />
<TextBlock Text="{Binding SelectedColorText, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" />
</StackPanel>
</Border>
</Grid>
<!--下拉按钮-->
<ToggleButton x:Name="PART_ColorPickerToggleButton" Panel.ZIndex="1" IsTabStop="False" Style="{StaticResource ColorPickerToggleButtonStyle}"
<ToggleButton x:Name="PART_ColorPickerToggleButton" Panel.ZIndex="1" IsTabStop="False"
Style="{StaticResource ColorPickerToggleButtonStyle}"
IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Grid.Column="0" Grid.ColumnSpan="2" Margin="0"
Foreground="{TemplateBinding BorderBrush}"/>
Foreground="{TemplateBinding BorderBrush}">
<!--<ContentControl x:Name="ColorOnly" Style="{StaticResource ColorDisplayStyle}" />-->
<ContentControl x:Name="ColorOnly"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{Binding Content, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False" Margin="0,0,0,0" />
</ToggleButton>
</Grid>
@@ -365,11 +348,6 @@
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="DisplayColorAndName" Value="True">
<Setter TargetName="ColorOnly" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ColorAndName" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="ShowTabHeaders"
Value="False">
<Setter Property="Visibility"