Files
2023-05-14 00:31:25 +08:00

84 lines
4.5 KiB
XML

<UserControl x:Class="AIStudio.Wpf.DiagramDesigner.LineControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="clr-namespace:AIStudio.Wpf.DiagramDesigner"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<dd:ColorBrushConverter x:Key="ColorBrushConverter" />
<dd:LineDashConverter x:Key="LineDashConverter"/>
<dd:ArrowPathConverter x:Key="ArrowPathConverter"/>
<dd:ArrowSizeConverter x:Key="ArrowSizeConverter"/>
<dd:MathConverter x:Key="MathAddConverter" Operation="Add" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</UserControl.Resources>
<Grid>
<Canvas x:Name="rootCanvas">
<Path x:Name="line" StrokeThickness="{Binding ColorViewModel.LineWidth}"
StrokeDashArray="{Binding ColorViewModel.LineDashStyle,Converter={StaticResource LineDashConverter}}"
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
StrokeLineJoin="Round"
StrokeStartLineCap="Round"
StrokeEndLineCap="Round">
<Path.Data>
<MultiBinding Converter="{x:Static dd:ConnectionPathConverter.Instance}">
<Binding Path="PathGeneratorResult"/>
</MultiBinding>
</Path.Data>
</Path>
<Grid Canvas.Left="{Binding EndRectangle.Left}"
Canvas.Top="{Binding EndRectangle.Top}"
Width="{Binding EndRectangle.Width}"
Height="{Binding EndRectangle.Height}">
<Path x:Name="rightarrow"
Data="{Binding ShapeViewModel.SinkMarker.Path}"
Width="{Binding ShapeViewModel.SinkMarker.Width}"
Height="{Binding ShapeViewModel.SinkMarker.Height}"
Stretch="Fill"
VerticalAlignment="Center"
HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5"
Fill="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="{Binding EndAngle}"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<Grid Canvas.Left="{Binding StartRectangle.Left}"
Canvas.Top="{Binding StartRectangle.Top}"
Width="{Binding StartRectangle.Width}"
Height="{Binding StartRectangle.Height}">
<Path x:Name="leftarrow"
Data="{Binding ShapeViewModel.SourceMarker.Path}"
Width="{Binding ShapeViewModel.SourceMarker.Width}"
Height="{Binding ShapeViewModel.SourceMarker.Height}"
Stretch="Fill"
VerticalAlignment="Center"
HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5"
Fill="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="{Binding StartAngle}"/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<Path x:Name="ball"
Stretch="Fill"
Data="{Binding AnimationViewModel.AnimationPath.Path}"
Fill="{Binding AnimationViewModel.Color,Converter={StaticResource ColorBrushConverter}}"
Width="{Binding AnimationViewModel.AnimationPath.Width}"
Height="{Binding AnimationViewModel.AnimationPath.Height}"
Panel.ZIndex="1" />
</Canvas>
</Grid>
</UserControl>