<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:s="clr-namespace:AIStudio.Wpf.DiagramDesigner" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> <UserControl.Resources> <s:ColorBrushConverter x:Key="ColorBrushConverter" /> <s:LineDashConverter x:Key="LineDashConverter"/> <s:ArrowPathConverter x:Key="ArrowPathConverter"/> <s:ArrowSizeConverter x:Key="ArrowSizeConverter"/> <s:MathConverter x:Key="MathAddConverter" Operation="Add" /> <Style x:Key="LineStyle" TargetType="Path"> <Setter Property="Stroke" Value="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"/> <Style.Triggers> <DataTrigger Value="True" Binding="{Binding IsSelected}"> <Setter Property="Stroke" Value="Black"/> </DataTrigger> </Style.Triggers> </Style> <Style x:Key="ArrowStyle" TargetType="Path"> <!--<Setter Property="Stroke" Value="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"/>--> <Setter Property="Fill" Value="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"/> <Style.Triggers> <DataTrigger Value="True" Binding="{Binding IsSelected}"> <!--<Setter Property="Stroke" Value="Black"/>--> <Setter Property="Fill" Value="Black"/> </DataTrigger> </Style.Triggers> </Style> </UserControl.Resources> <Grid> <Canvas x:Name="rootCanvas"> <Path x:Name="line" StrokeThickness="{Binding ColorViewModel.LineWidth}" StrokeDashArray="{Binding ColorViewModel.LineDashStyle,Converter={StaticResource LineDashConverter}}" Style="{StaticResource LineStyle}" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Round"> <Path.Data> <MultiBinding Converter="{x:Static s: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" Style="{StaticResource ArrowStyle}"> <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" Style="{StaticResource ArrowStyle}"> <Path.RenderTransform> <TransformGroup> <RotateTransform Angle="{Binding StartAngle}"/> </TransformGroup> </Path.RenderTransform> </Path> </Grid> <Ellipse x:Name="ball" Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" Width="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}" Height="{Binding ColorViewModel.LineWidth,Converter={StaticResource MathAddConverter},ConverterParameter=4}" Panel.ZIndex="1" /> </Canvas> </Grid> </UserControl>