mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-20 00:16:36 +08:00
119 lines
6.8 KiB
XML
119 lines
6.8 KiB
XML
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner"
|
|
xmlns:c="clr-namespace:AIStudio.Wpf.DiagramDesigner.Controls">
|
|
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
|
|
<dd:ConectorOrientationConverter x:Key="ConectorOrientationConverter" />
|
|
<dd:ConectorValueConverter x:Key="ConectorValueConverter"/>
|
|
|
|
<DataTemplate DataType="{x:Type dd:FullyCreatedConnectorInfo}">
|
|
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}">
|
|
<Grid.ContextMenu>
|
|
<ContextMenu ItemsSource="{Binding MenuOptions}" >
|
|
<ContextMenu.ItemContainerStyle>
|
|
<Style TargetType="MenuItem">
|
|
<Setter Property="MenuItem.Header" Value="{Binding Text}" />
|
|
<Setter Property="MenuItem.ItemsSource" Value="{Binding Children}" />
|
|
<Setter Property="MenuItem.Command" Value="{Binding Command}" />
|
|
<Setter Property="MenuItem.Icon" Value="{Binding Icon}" />
|
|
<Setter Property="CommandParameter" Value="{Binding CommandParameter}" />
|
|
<Setter Property="MenuItem.IsCheckable" Value="{Binding IsCheckable}" />
|
|
<Setter Property="MenuItem.IsChecked" Value="{Binding IsChecked}" />
|
|
</Style>
|
|
</ContextMenu.ItemContainerStyle>
|
|
</ContextMenu>
|
|
</Grid.ContextMenu>
|
|
<!-- transparent extra space makes connector easier to hit -->
|
|
<Rectangle Fill="Transparent" Margin="-2" />
|
|
<Rectangle Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" StrokeThickness="1" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
|
|
</Grid>
|
|
</DataTemplate>
|
|
|
|
<DataTemplate DataType="{x:Type dd:LogicalConnectorInfo}">
|
|
<Grid>
|
|
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}" HorizontalAlignment="Left" VerticalAlignment="Top">
|
|
<Grid.ContextMenu>
|
|
<ContextMenu ItemsSource="{Binding MenuOptions}">
|
|
<ContextMenu.ItemContainerStyle>
|
|
<Style TargetType="MenuItem">
|
|
<Setter Property="MenuItem.Header" Value="{Binding Text}" />
|
|
<Setter Property="MenuItem.ItemsSource" Value="{Binding Children}" />
|
|
<Setter Property="MenuItem.Command" Value="{Binding Command}" />
|
|
<Setter Property="MenuItem.Icon" Value="{Binding Icon}" />
|
|
<Setter Property="CommandParameter" Value="{Binding CommandParameter}" />
|
|
<Setter Property="MenuItem.IsCheckable" Value="{Binding IsCheckable}" />
|
|
<Setter Property="MenuItem.IsChecked" Value="{Binding IsChecked}" />
|
|
</Style>
|
|
</ContextMenu.ItemContainerStyle>
|
|
</ContextMenu>
|
|
</Grid.ContextMenu>
|
|
<!-- transparent extra space makes connector easier to hit -->
|
|
<Rectangle Fill="Transparent" Margin="-2" />
|
|
<Rectangle Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" StrokeThickness="1" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
|
|
</Grid>
|
|
|
|
<Control x:Name="label">
|
|
<Control.Template>
|
|
<ControlTemplate>
|
|
<TextBlock x:Name="txtleft" FontSize="10" RenderTransformOrigin="0.5,0.5">
|
|
<TextBlock.Text>
|
|
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
|
<Binding Path="ConnectorValue" />
|
|
<Binding Path="ValueTypePoint"/>
|
|
</MultiBinding>
|
|
</TextBlock.Text>
|
|
<TextBlock.RenderTransform>
|
|
<TransformGroup>
|
|
<ScaleTransform/>
|
|
<SkewTransform/>
|
|
<RotateTransform/>
|
|
<TranslateTransform Y="10" X="{Binding ElementName=txtleft,Path=Text,Converter={StaticResource ConectorOrientationConverter}}"/>
|
|
</TransformGroup>
|
|
</TextBlock.RenderTransform>
|
|
</TextBlock>
|
|
</ControlTemplate>
|
|
</Control.Template>
|
|
</Control>
|
|
|
|
</Grid>
|
|
<DataTemplate.Triggers>
|
|
<DataTrigger Value="Right" Binding="{Binding Orientation}">
|
|
<Setter TargetName="label" Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate>
|
|
<TextBlock x:Name="txtRight" FontSize="10" RenderTransformOrigin="0.5,0.5" >
|
|
<TextBlock.Text>
|
|
<MultiBinding Converter="{StaticResource ConectorValueConverter}">
|
|
<Binding Path="ConnectorValue" />
|
|
<Binding Path="ValueTypePoint"/>
|
|
</MultiBinding>
|
|
</TextBlock.Text>
|
|
<TextBlock.RenderTransform>
|
|
<TransformGroup>
|
|
<ScaleTransform/>
|
|
<SkewTransform/>
|
|
<RotateTransform/>
|
|
<TranslateTransform Y="10" X="5"/>
|
|
</TransformGroup>
|
|
</TextBlock.RenderTransform>
|
|
</TextBlock>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</DataTrigger>
|
|
</DataTemplate.Triggers>
|
|
</DataTemplate>
|
|
|
|
<!-- DragThumb Default Template -->
|
|
<Style TargetType="{x:Type c:DragThumb}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type c:DragThumb}">
|
|
<Rectangle Fill="Transparent" />
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
|
|
</ResourceDictionary> |