自定义工具栏连接线显示

This commit is contained in:
艾竹
2023-12-23 10:14:08 +08:00
parent 41f711f11a
commit c2bce7c912
2 changed files with 378 additions and 351 deletions

View File

@@ -21,365 +21,384 @@
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ResourceDictionary>
<conventer:StringPathConverter x:Key="stringPathConverter"/>
<conventer:IntVisibilityConverter x:Key="IntVisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding ToolBoxViewModel.DeleteItemCommand}"/>
<dd:MathConverter x:Key="MathAddConverter" Operation="Add" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<conventer:StringPathConverter x:Key="stringPathConverter"/>
<conventer:IntVisibilityConverter x:Key="IntVisibilityConverter"/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<dd:EnumDescriptionConverter x:Key="EnumDescriptionConverter"/>
<command:CommandReference x:Key="DeleteItemCommandReference" Command="{Binding ToolBoxViewModel.DeleteItemCommand}"/>
<dd:MathConverter x:Key="MathAddConverter" Operation="Add" />
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Image IsHitTestVisible="True"
Stretch="Fill"
Margin="2"
Source="{Binding Icon, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:MediaToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Image IsHitTestVisible="True"
Stretch="Fill"
Margin="2"
Source="{Binding Text, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:TextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Rectangle Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
<TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:EllipseTextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Ellipse Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Ellipse Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
<TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:PathToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Path Style="{StaticResource PathItemStyle}" ToolTip="Document" Margin="2"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:SvgToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<svg:PackSvg Width="Auto" Height="Auto" Path="{Binding Icon}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:DesignerItemToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
</ContextMenu>
</Grid.ContextMenu>
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Viewbox Stretch="Uniform" DataContext="{Binding DesignerItemViewModel}" Margin="2">
<Grid Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
<ContentControl Content="{Binding .}" />
<TextBox Text="{Binding Text}"
IsReadOnly="True"
TextWrapping="Wrap"
Background ="Transparent"
BorderThickness="0"
Margin="5"
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
FontSize="{Binding FontViewModel.FontSize}"
FontFamily="{Binding FontViewModel.FontFamily}"
FontWeight="{Binding FontViewModel.FontWeight}"
FontStyle="{Binding FontViewModel.FontStyle}"
FontStretch="{Binding FontViewModel.FontStretch}"
TextDecorations="{Binding FontViewModel.TextDecorations}"
HorizontalContentAlignment="{Binding FontViewModel.HorizontalAlignment}"
VerticalContentAlignment="{Binding FontViewModel.VerticalAlignment}"
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"/>
<DataTemplate DataType="{x:Type model:ImageToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Image IsHitTestVisible="True"
Stretch="Fill"
Margin="2"
Source="{Binding Icon, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
</Grid>
</Viewbox>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:MediaToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Image IsHitTestVisible="True"
Stretch="Fill"
Margin="2"
Source="{Binding Text, Converter={x:Static dd:ImageUrlConverter.Instance}}" />
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:TextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Rectangle Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
<TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:EllipseTextToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Ellipse Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Ellipse Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Margin="2"/>
<TextBlock Text="{Binding Text}" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:PathToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Path Style="{StaticResource PathItemStyle}" ToolTip="Document" Margin="2"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:SvgToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<svg:PackSvg Width="Auto" Height="Auto" Path="{Binding Icon}" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}"/>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:DesignerItemToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
</ContextMenu>
</Grid.ContextMenu>
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Viewbox Stretch="Uniform" DataContext="{Binding DesignerItemViewModel}" Margin="2">
<Grid Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
<ContentControl Content="{Binding .}" />
<TextBox Text="{Binding Text}"
IsReadOnly="True"
TextWrapping="Wrap"
Background ="Transparent"
BorderThickness="0"
Margin="5"
Foreground="{Binding FontViewModel.FontColor,Converter={StaticResource ColorBrushConverter}}"
FontSize="{Binding FontViewModel.FontSize}"
FontFamily="{Binding FontViewModel.FontFamily}"
FontWeight="{Binding FontViewModel.FontWeight}"
FontStyle="{Binding FontViewModel.FontStyle}"
FontStretch="{Binding FontViewModel.FontStretch}"
TextDecorations="{Binding FontViewModel.TextDecorations}"
HorizontalContentAlignment="{Binding FontViewModel.HorizontalAlignment}"
VerticalContentAlignment="{Binding FontViewModel.VerticalAlignment}"
TextBlock.LineHeight="{Binding FontViewModel.LineHeight}"/>
</Grid>
</Viewbox>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:MultipleDesignerItemToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
</ContextMenu>
</Grid.ContextMenu>
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Viewbox Stretch="Uniform" Margin="2">
<ItemsControl ItemsSource="{Binding SelectableDesignerItemViewModels}"
Width="{Binding CanvasWidth}"
Height="{Binding CanvasHeight}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas x:Name="rootCanvas"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Grid>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
<ContentControl Content="{Binding .}" Margin="2"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Resources>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding Left}" />
<Setter Property="Canvas.Top" Value="{Binding Top}" />
</Style>
</ItemsControl.Resources>
</ItemsControl>
</Viewbox>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type model:MultipleDesignerItemToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="删除" Command="{StaticResource DeleteItemCommandReference}" CommandParameter="{Binding .}"/>
</ContextMenu>
</Grid.ContextMenu>
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Viewbox Stretch="Uniform" Margin="2">
<ItemsControl ItemsSource="{Binding SelectableDesignerItemViewModels}"
Width="{Binding CanvasWidth}"
Height="{Binding CanvasHeight}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas x:Name="rootCanvas"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Grid>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</Grid>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" IsHitTestVisible="False">
<ContentControl Content="{Binding .}" Margin="2"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Canvas.Left" Value="{Binding Left}" />
<Setter Property="Canvas.Top" Value="{Binding Top}" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsConnection}" Value="True">
<Setter Property="Canvas.Left" Value="{Binding Area.Left}" />
<Setter Property="Canvas.Top" Value="{Binding Area.Top}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type dd:ConnectionViewModel}">
<Grid>
<dd:LineControl x:Name="line"/>
</Grid>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Viewbox>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type flowchartmodel:FlowchartToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
<TextBlock Text="{Binding Text}" Margin="5" TextWrapping="WrapWithOverflow" FontSize="9" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type sfcmodel:SFCToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
</Grid>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type dd:ToolBoxCategory}">
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<Expander Header="{Binding Header}"
IsExpanded="{Binding IsExpanded}"
BorderThickness="0"
Background="Transparent"
Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}"
Style="{StaticResource AIStudio.DiagramApp.Styles.Expander}">
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type flowchartmodel:FlowchartToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Description}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomFlowNodeStyle}" Margin="2"/>
<TextBlock Text="{Binding Text}" Margin="5" TextWrapping="WrapWithOverflow" FontSize="9" Foreground="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type sfcmodel:SFCToolBoxData}">
<Grid Width="{Binding Width}" Height="{Binding Height}" ToolTip="{Binding Kind,Converter={StaticResource EnumDescriptionConverter}}">
<Rectangle Name="Border"
StrokeThickness="1"
StrokeDashArray="2"
Fill="Transparent"
SnapsToDevicePixels="true"/>
<Grid IsHitTestVisible="False">
<ContentControl Style="{StaticResource CustomSFCNodeStyle}" Margin="2" />
</Grid>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Border" Property="Stroke" Value="Gray"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<DataTemplate DataType="{x:Type dd:ToolBoxCategory}">
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<Expander Header="{Binding Header}"
IsExpanded="{Binding IsExpanded}"
BorderThickness="0"
Background="Transparent"
Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}"
Style="{StaticResource AIStudio.DiagramApp.Styles.Expander}">
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Control.Padding"
Value="10" />
<Setter Property="ContentControl.HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="ContentControl.VerticalContentAlignment"
Value="Stretch" />
<Setter Property="ToolTip"
Value="{Binding ToolTip}" />
<Setter Property="dd:DragAndDropProps.EnabledForDrag"
Value="True" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Expander>
<Button Margin="5" ToolTip="移除" Command="{Binding DataContext.ToolBoxViewModel.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16" HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
</Button>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:MineToolBoxCategory}">
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<Expander Header="{Binding Header}"
IsExpanded="{Binding IsExpanded}"
BorderThickness="0"
Background="Transparent"
Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}"
Style="{StaticResource AIStudio.DiagramApp.Styles.Expander}">
<Grid>
<Border BorderThickness="1" CornerRadius="5" Margin="5" Padding="10" Visibility="{Binding ToolBoxItems.Count, Converter={StaticResource IntVisibilityConverter}, ConverterParameter='0'}">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.8"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
<TextBlock Text="添加形状到我的符号" HorizontalAlignment="Center" Foreground="{DynamicResource GrayBrush2}"/>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Control.Padding"
Value="10" />
<Setter Property="ContentControl.HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="ContentControl.VerticalContentAlignment"
Value="Stretch" />
<Setter Property="ToolTip"
Value="{Binding ToolTip}" />
<Setter Property="dd:DragAndDropProps.EnabledForDrag"
Value="True" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Expander>
<Button Margin="5" ToolTip="移除" Command="{Binding DataContext.ToolBoxViewModel.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16" HorizontalAlignment="Right" VerticalAlignment="Top" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
</Button>
</Grid>
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodels:MineToolBoxCategory}">
<Grid Visibility="{Binding IsChecked,Converter={StaticResource boolToVisibilityConverter}}">
<Expander Header="{Binding Header}"
IsExpanded="{Binding IsExpanded}"
BorderThickness="0"
Background="Transparent"
Foreground="{DynamicResource Fluent.Ribbon.Brushes.LabelTextBrush}"
Style="{StaticResource AIStudio.DiagramApp.Styles.Expander}">
<Grid>
<Border BorderThickness="1" CornerRadius="5" Margin="5" Padding="10" Visibility="{Binding ToolBoxItems.Count, Converter={StaticResource IntVisibilityConverter}, ConverterParameter='0'}">
<Border.BorderBrush>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,5" EndPoint="5,0" MappingMode="Absolute">
<LinearGradientBrush.GradientStops>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.2"/>
<GradientStop Color="Transparent" Offset="0.4"/>
<GradientStop Color="Transparent" Offset="0.6"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="0.8"/>
<GradientStop Color="{DynamicResource Fluent.Ribbon.Colors.AccentBaseColor}" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
<TextBlock Text="添加形状到我的符号" HorizontalAlignment="Center" Foreground="{DynamicResource GrayBrush2}"/>
</Border>
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Control.Padding"
Value="10" />
<Setter Property="ContentControl.HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="ContentControl.VerticalContentAlignment"
Value="Stretch" />
<Setter Property="ToolTip"
Value="{Binding ToolTip}" />
<Setter Property="dd:DragAndDropProps.EnabledForDrag"
Value="True" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
<ItemsControl ItemsSource="{Binding ToolBoxItems}">
<ItemsControl.Template>
<ControlTemplate TargetType="{x:Type ItemsControl}">
<Border BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ItemsControl}}, Path=ActualWidth}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Control.Padding"
Value="10" />
<Setter Property="ContentControl.HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="ContentControl.VerticalContentAlignment"
Value="Stretch" />
<Setter Property="ToolTip"
Value="{Binding ToolTip}" />
<Setter Property="dd:DragAndDropProps.EnabledForDrag"
Value="True" />
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Grid>
</Expander>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
<Button Margin="0,5,2,5" ToolTip="导入到我的符号" Command="{Binding DataContext.ToolBoxViewModel.ImportItemCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z" ></Path>
</Button>
<Button Margin="0,5,2,5" ToolTip="添加到我的符号" Command="{Binding DataContext.ToolBoxViewModel.AddCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M938.666667 426.666667h-341.333334V85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333s-85.333333 38.4-85.333333 85.333333v341.333334H85.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333h341.333334v341.333334c0 46.933333 38.4 85.333333 85.333333 85.333333s85.333333-38.4 85.333333-85.333333v-341.333334h341.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333z" ></Path>
</Button>
<Button Margin="0,5,5,5" ToolTip="移除" Command="{Binding DataContext.ToolBoxViewModel.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
</Button>
</StackPanel>
</Grid>
</Expander>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
<Button Margin="0,5,2,5" ToolTip="导入到我的符号" Command="{Binding DataContext.ToolBoxViewModel.ImportItemCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z" ></Path>
</Button>
<Button Margin="0,5,2,5" ToolTip="添加到我的符号" Command="{Binding DataContext.ToolBoxViewModel.AddCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="{DynamicResource GrayBrush2}" Data="M938.666667 426.666667h-341.333334V85.333333c0-46.933333-38.4-85.333333-85.333333-85.333333s-85.333333 38.4-85.333333 85.333333v341.333334H85.333333c-46.933333 0-85.333333 38.4-85.333333 85.333333s38.4 85.333333 85.333333 85.333333h341.333334v341.333334c0 46.933333 38.4 85.333333 85.333333 85.333333s85.333333-38.4 85.333333-85.333333v-341.333334h341.333334c46.933333 0 85.333333-38.4 85.333333-85.333333s-38.4-85.333333-85.333333-85.333333z" ></Path>
</Button>
<Button Margin="0,5,5,5" ToolTip="移除" Command="{Binding DataContext.ToolBoxViewModel.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" CommandParameter="{Binding .}" Width="16" Height="16" Foreground="{DynamicResource BlackBrush}" Background="{DynamicResource WhiteBrush}" BorderBrush="Transparent">
<Path Stretch="Fill" Margin="2" Fill="Red" Data="M0.7,0 L5,4.3 L9.3,0 L10,0.7 L5.7,5 L10,9.3 L9.3,10 L5,5.7 L0.7,10 L0,9.3 L4.3,5 L0,0.7 z" ></Path>
</Button>
</StackPanel>
</Grid>
</DataTemplate>
</DataTemplate>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Expander x:Name="expanderLeft" ExpandDirection="Left" IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=views:ToolBoxControl}}" Style="{StaticResource AIStudio.DiagramApp.Styles.Expander.AutoHide}" Margin="0,0,1,0">

View File

@@ -345,6 +345,14 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
public bool IsConnection
{
get
{
return this is ConnectionViewModel;
}
}
private IColorViewModel _colorViewModel;
public IColorViewModel ColorViewModel
{