连接线修改,为支持改变连接点做准备

This commit is contained in:
akwkevin
2021-08-05 18:20:22 +08:00
parent b0c9855d05
commit e9c043ae3a
19 changed files with 405 additions and 50 deletions

View File

@@ -22,7 +22,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
{
public partial class DiagramsViewModel : BindableBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
protected IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
public DiagramsViewModel(string title, string status, DiagramType diagramType)
{
@@ -246,7 +246,7 @@ namespace AIStudio.Wpf.ADiagram.ViewModels
}
}
private void OpenFile(DiagramDocument diagramDocument)
protected virtual void OpenFile(DiagramDocument diagramDocument)
{
Title = diagramDocument.Title;
DiagramType = diagramDocument.DiagramType;

View File

@@ -17,7 +17,7 @@ namespace AIStudio.Wpf.Flowchart
{
public FlowchartViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
}
public FlowchartViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
@@ -27,6 +27,12 @@ namespace AIStudio.Wpf.Flowchart
}
}
protected override void OpenFile(DiagramDocument diagramDocument)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
base.OpenFile(diagramDocument);
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();

View File

@@ -13,13 +13,19 @@ namespace AIStudio.Wpf.Logical
{
public LogicalViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.CornerConnectingLine;
}
public LogicalViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
}
protected override void OpenFile(DiagramDocument diagramDocument)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.CornerConnectingLine;
base.OpenFile(diagramDocument);
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();

View File

@@ -20,7 +20,7 @@ namespace AIStudio.Wpf.Flowchart
{
public SFCViewModel(string title, string status, DiagramType diagramType) : base(title, status, diagramType)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
}
public SFCViewModel(string filename, DiagramDocument diagramDocument) : base(filename, diagramDocument)
{
@@ -34,6 +34,12 @@ namespace AIStudio.Wpf.Flowchart
readDataTimer.Start();
}
protected override void OpenFile(DiagramDocument diagramDocument)
{
_service.DrawModeViewModel.VectorLineDrawMode = DrawMode.BoundaryConnectingLine;
base.OpenFile(diagramDocument);
}
protected override void InitDiagramViewModel()
{
base.InitDiagramViewModel();

View File

@@ -801,33 +801,41 @@
</Fluent:ToggleButton.ToolTip>
</Fluent:ToggleButton>
<Fluent:SplitButton Header="连接线" GroupName="DrawMode" IsCheckable="True" IsChecked="{Binding VectorLineDrawModeSelected}" Icon="{iconPacks:Material Kind=VectorLine}" Width="50" VerticalAlignment="Top">
<Fluent:SplitButton Header="连接线" GroupName="DrawMode" IsCheckable="True" IsChecked="{Binding VectorLineDrawModeSelected}" Icon="{iconPacks:Material Kind=VectorPolyline}" Width="50" VerticalAlignment="Top">
<Fluent:MenuItem Header="直线连接线" Size="Middle" IsCheckable="True" IsChecked="{Binding VectorLineDrawMode,Converter={converter:ConverterValueMapToBool Parameter='ConnectingLine'}, ConverterParameter='ConnectingLine'}" Icon="{iconPacks:Material Kind=VectorLine}"/>
<Fluent:MenuItem Header="折角连接线" Size="Middle" IsCheckable="True" IsChecked="{Binding VectorLineDrawMode,Converter={converter:ConverterValueMapToBool Parameter='CornerConnectingLine'}, ConverterParameter='CornerConnectingLine'}" Icon="{iconPacks:Material Kind=VectorPolyline}"/>
<Fluent:MenuItem Header="边界连接线" Size="Middle" IsCheckable="True" IsChecked="{Binding VectorLineDrawMode,Converter={converter:ConverterValueMapToBool Parameter='BoundaryConnectingLine'}, ConverterParameter='BoundaryConnectingLine'}" Icon="{iconPacks:Material Kind=VectorPolylineEdit}"/>
<Fluent:MenuItem Header="曲线连接线" Size="Middle" IsCheckable="True" IsChecked="{Binding VectorLineDrawMode,Converter={converter:ConverterValueMapToBool Parameter='RadiusConnectingLine'}, ConverterParameter='RadiusConnectingLine'}" Icon="{iconPacks:Material Kind=VectorRadius}"/>
<Fluent:SplitButton.Style>
<Style TargetType="{x:Type Fluent:SplitButton}" BasedOn="{StaticResource RibbonSplitButtonStyle}">
<Setter Property="LargeIcon">
<Setter.Value>
<iconPacks:PackIconMaterial Kind="VectorLine" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<iconPacks:PackIconMaterial Kind="VectorPolyline" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding ShapeDrawMode}" Value="ConnectingLine">
<DataTrigger Binding="{Binding VectorLineDrawMode}" Value="ConnectingLine">
<Setter Property="LargeIcon">
<Setter.Value>
<iconPacks:PackIconMaterial Kind="VectorLine" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding ShapeDrawMode}" Value="CornerConnectingLine">
<DataTrigger Binding="{Binding VectorLineDrawMode}" Value="CornerConnectingLine">
<Setter Property="LargeIcon">
<Setter.Value>
<iconPacks:PackIconMaterial Kind="VectorPolyline" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding ShapeDrawMode}" Value="RadiusConnectingLine">
<DataTrigger Binding="{Binding VectorLineDrawMode}" Value="BoundaryConnectingLine">
<Setter Property="LargeIcon">
<Setter.Value>
<iconPacks:PackIconMaterial Kind="VectorPolylineEdit" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding VectorLineDrawMode}" Value="RadiusConnectingLine">
<Setter Property="LargeIcon">
<Setter.Value>
<iconPacks:PackIconMaterial Kind="VectorRadius" VerticalAlignment="Center" HorizontalAlignment="Center"/>

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Util.DiagramDesigner;
namespace AIStudio.Wpf.BaseDiagram.Helpers
{
@@ -26,6 +27,11 @@ namespace AIStudio.Wpf.BaseDiagram.Helpers
private static void OnEnumChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
if (DesignerHelper.IsInDesignMode)
{
return;
}
var control = sender as ItemsControl;
if (control != null)

View File

@@ -30,7 +30,7 @@ namespace AIStudio.Wpf.SFC.ViewModels
protected override void Init()
{
IsRatioConnector = true;
IsInnerConnector = true;
ShowRotate = false;
ShowArrow = false;
ShowText = true;

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
namespace Util.DiagramDesigner.Controls
{
public class PointDragThumb : Thumb
{
public PointDragThumb()
{
base.DragDelta += new DragDeltaEventHandler(DragThumb_DragDelta);
base.DragStarted += DragThumb_DragStarted;
base.DragCompleted += DragThumb_DragCompleted;
}
private void DragThumb_DragStarted(object sender, DragStartedEventArgs e)
{
}
private void DragThumb_DragCompleted(object sender, DragCompletedEventArgs e)
{
}
void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
if (this.DataContext is PointInfoBase point)
{
double minLeft = double.MaxValue;
double minTop = double.MaxValue;
double left = point.X;
double top = point.Y;
minLeft = double.IsNaN(left) ? 0 : Math.Min(left, minLeft);
minTop = double.IsNaN(top) ? 0 : Math.Min(top, minTop);
double deltaHorizontal = Math.Max(-minLeft, e.HorizontalChange);
double deltaVertical = Math.Max(-minTop, e.VerticalChange);
point.X += deltaHorizontal;
point.Y += deltaVertical;
}
}
}
}

View File

@@ -25,11 +25,11 @@ namespace Util.DiagramDesigner
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
List<Point> points = (List<Point>)value;
List<PointInfoBase> points = (List<PointInfoBase>)value;
PointCollection pointCollection = new PointCollection();
if (points != null)
{
foreach (Point point in points)
foreach (var point in points)
{
pointCollection.Add(point);
}

View File

@@ -15,7 +15,8 @@ namespace Util.DiagramDesigner
DirectLine = 6,
ConnectingLine = 10,
CornerConnectingLine = 11,
RadiusConnectingLine = 12,
BoundaryConnectingLine = 12,
RadiusConnectingLine = 13,
Text = 20,
}
}

View File

@@ -0,0 +1,45 @@
using System.ComponentModel;
using System.Threading;
using System.Windows;
namespace Util.DiagramDesigner
{
public class DesignerHelper
{
private static bool? _isInDesignMode;
public static bool IsInDesignMode
{
get
{
if (!_isInDesignMode.HasValue)
{
_isInDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue;
}
return _isInDesignMode.Value;
}
}
#region IsInMainThread
/// <summary>
/// 是否是在主线程中处理
/// </summary>
public static bool IsInMainThread
{
get
{
if (Thread.CurrentThread.IsBackground || Thread.CurrentThread.IsThreadPoolThread) return false;
if (Thread.CurrentThread.Name == "主线程") return true;
if (Application.Current == null)
return true;
return Thread.CurrentThread == Application.Current.Dispatcher.Thread;
}
}
#endregion
}
}

View File

@@ -274,6 +274,22 @@
</Setter>
</Style>
<!-- Connector Style -->
<Style x:Key="pointConnector1" TargetType="{x:Type s:PointConnector}">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type s:PointConnector}">
<Grid Width="{Binding ConnectorWidth}" Height="{Binding ConnectorHeight}">
<!-- transparent extra space makes connector easier to hit -->
<Ellipse Fill="Transparent" Margin="-2" />
<Ellipse Fill="{Binding ColorViewModel.FillColor,Converter={StaticResource ColorBrushConverter}}" StrokeThickness="1" Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="normalConnectorContainer" TargetType="{x:Type s:ConnectorContainer}">
<Setter Property="Template">
<Setter.Value>
@@ -293,7 +309,7 @@
</Setter>
</Style>
<Style x:Key="logicConnectorContainer" TargetType="{x:Type s:ConnectorContainer}">
<Style x:Key="innerConnectorContainer" TargetType="{x:Type ItemsControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ItemsControl}">
@@ -333,16 +349,16 @@
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="RatioConnectorDecoratorTemplate"
<ControlTemplate x:Key="InnerConnectorDecoratorTemplate"
TargetType="{x:Type Control}">
<s:ConnectorContainer x:Name="PART_ConnectorContainer" Style="{StaticResource logicConnectorContainer}" ItemsSource="{Binding Connectors}" Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<s:ConnectorContainer x:Name="PART_ConnectorContainer" Style="{StaticResource innerConnectorContainer}" ItemsSource="{Binding Connectors}" Visibility="{Binding Path=ShowConnectors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<s:ConnectorContainer.ItemTemplate>
<DataTemplate>
<Grid>
<s:Connector Style="{StaticResource normalConnector}"/>
</Grid>
</DataTemplate>
</s:ConnectorContainer.ItemTemplate>
</s:ConnectorContainer.ItemTemplate>
</s:ConnectorContainer>
</ControlTemplate>
@@ -359,10 +375,10 @@
<ItemsControl.Resources>
<Style x:Key="designerItemStyle"
TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Top"
Value="{Binding Top}" />
<Setter Property="Canvas.Left"
Value="{Binding Left}" />
<Setter Property="Canvas.Top"
Value="{Binding Top}" />
<Setter Property="Canvas.ZIndex"
Value="{Binding ZIndex}" />
<Setter Property="s:SelectionProps.EnabledForSelection"
@@ -474,8 +490,8 @@
<Setter TargetName="PART_ConnectorDecorator" Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Value="True"
Binding="{Binding IsRatioConnector}">
<Setter TargetName="PART_ConnectorDecorator" Property="Template" Value="{StaticResource RatioConnectorDecoratorTemplate}" />
Binding="{Binding IsInnerConnector}">
<Setter TargetName="PART_ConnectorDecorator" Property="Template" Value="{StaticResource InnerConnectorDecoratorTemplate}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
@@ -528,8 +544,8 @@
Points="{Binding Path=ConnectionPoints, Converter={x:Static s:ConnectionPathConverter.Instance}}"
Stroke="{Binding ColorViewModel.LineColor,Converter={StaticResource ColorBrushConverter}}"
StrokeThickness="{Binding ColorViewModel.LineWidth}"
StrokeDashArray="{Binding ColorViewModel.LineDashStyle,Converter={StaticResource LineDashConverter}}" />
StrokeDashArray="{Binding ColorViewModel.LineDashStyle,Converter={StaticResource LineDashConverter}}" />
<Path x:Name="rightarrow"
Data="{Binding ColorViewModel.RightArrowPathStyle,Converter={StaticResource ArrowPathConverter}}"
Visibility="{Binding Path=IsFullConnection, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"
@@ -574,6 +590,24 @@
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding }" />
</c:DragThumb.InputBindings>
</c:DragThumb>
<s:PointContainer x:Name="PART_PointContainer" Style="{StaticResource innerConnectorContainer}" ItemsSource="{Binding ConnectionPoints}" Visibility="Collapsed">
<s:PointContainer.ItemTemplate>
<DataTemplate>
<Grid>
<s:PointConnector Style="{StaticResource pointConnector1}"/>
<c:PointDragThumb Cursor="SizeAll" Opacity="0"/>
</Grid>
</DataTemplate>
</s:PointContainer.ItemTemplate>
<s:PointContainer.Resources>
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding Left}" />
<Setter Property="Canvas.Top" Value="{Binding Top}" />
</Style>
</s:PointContainer.Resources>
</s:PointContainer>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Value="True"
@@ -587,6 +621,9 @@
<Setter TargetName="rightarrow"
Property="Fill"
Value="Black" />
<Setter TargetName="PART_PointContainer"
Property="Visibility"
Value="Visible"/>
</DataTrigger>
<!--右箭头-->
@@ -816,7 +853,7 @@
</Grid.ContextMenu>
<!--PART_ConnectorDecorator-->
<s:ConnectorContainer x:Name="PART_ConnectorContainer" Style="{StaticResource logicConnectorContainer}" ItemsSource="{Binding Connectors}" Margin="0,0,0,0">
<s:ConnectorContainer x:Name="PART_ConnectorContainer" Style="{StaticResource innerConnectorContainer}" ItemsSource="{Binding Connectors}" Margin="0,0,0,0">
<s:ConnectorContainer.ItemTemplate>
<DataTemplate>
<Grid>

View File

@@ -0,0 +1,14 @@
<ItemsControl x:Class="Util.DiagramDesigner.PointContainer"
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:local="clr-namespace:Util.DiagramDesigner"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas x:Name="rootCanvas"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Util.DiagramDesigner
{
/// <summary>
/// PointContainer.xaml 的交互逻辑
/// </summary>
public partial class PointContainer : ItemsControl
{
public PointContainer()
{
InitializeComponent();
}
}
}

View File

@@ -27,6 +27,7 @@ namespace Util.DiagramDesigner
return DrawMode.Normal;
}
public void ResetDrawMode()
{
CursorDrawModeSelected = true;
@@ -104,7 +105,7 @@ namespace Util.DiagramDesigner
}
}
private DrawMode _vectorLineDrawMode = DrawMode.ConnectingLine;
private DrawMode _vectorLineDrawMode = DrawMode.RadiusConnectingLine;
public DrawMode VectorLineDrawMode
{
get

View File

@@ -12,5 +12,6 @@ namespace Util.DiagramDesigner
void ResetDrawMode();
CursorMode CursorMode { get; set; }
DrawMode VectorLineDrawMode { get; set; }
}
}

View File

@@ -271,7 +271,7 @@ namespace Util.DiagramDesigner
/// <summary>
/// 连接点是否可以按偏移自定义
/// </summary>
public bool IsRatioConnector { get; set; }
public bool IsInnerConnector { get; set; }
private ObservableCollection<FullyCreatedConnectorInfo> connectors = new ObservableCollection<FullyCreatedConnectorInfo>();
public IEnumerable<FullyCreatedConnectorInfo> Connectors { get { return connectors; } }

View File

@@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
namespace Util.DiagramDesigner
{
public class PointInfoBase : BindableBase
{
public PointInfoBase()
{
ColorViewModel = new ColorViewModel()
{
LineColor = new ColorObject() { Color = Color.FromArgb(0xAA, 0x00, 0x00, 0x80) },
FillColor = new ColorObject() { Color = Colors.Lavender },
};
}
public PointInfoBase(Point point) : this()
{
X = point.X;
Y = point.Y;
}
private double _x;
public double X
{
get
{
return _x;
}
set
{
if(SetProperty(ref _x, value))
{
RaisePropertyChanged(nameof(Left));
}
}
}
private double _y;
public double Y
{
get
{
return _y;
}
set
{
if (SetProperty(ref _y, value))
{
RaisePropertyChanged(nameof(Top));
}
}
}
public double Left
{
get
{
return X - ConnectorWidth / 2;
}
}
public double Top
{
get
{
return Y - ConnectorHeight / 2;
}
}
private double connectorWidth = 8;
public double ConnectorWidth
{
get { return connectorWidth; }
set { connectorWidth = value; }
}
private double connectorHeight = 8;
public double ConnectorHeight
{
get { return connectorHeight; }
set { connectorHeight = value; }
}
private IColorViewModel _colorViewModel;
public IColorViewModel ColorViewModel
{
get
{
return _colorViewModel;
}
set
{
SetProperty(ref _colorViewModel, value);
}
}
public static implicit operator PointInfoBase(Point point)
{
return new PointInfoBase(point);
}
public static implicit operator Point(PointInfoBase pointInfoBase)
{
return new Point(pointInfoBase.X, pointInfoBase.Y);
}
public static List<PointInfoBase> ToList(List<Point> lst)
{
return lst.Select(p => (PointInfoBase)p).ToList();
}
}
}

View File

@@ -10,6 +10,8 @@ namespace Util.DiagramDesigner
{
public class ConnectorViewModel : SelectableDesignerItemViewModelBase
{
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
public ConnectorViewModel(IDiagramViewModel parent, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo,
SelectableDesignerItemBase designer) : base(parent, designer)
{
@@ -61,8 +63,8 @@ namespace Util.DiagramDesigner
}
}
private List<Point> _connectionPoints;
public List<Point> ConnectionPoints
private List<PointInfoBase> _connectionPoints;
public List<PointInfoBase> ConnectionPoints
{
get
{
@@ -70,7 +72,15 @@ namespace Util.DiagramDesigner
}
private set
{
if (_connectionPoints != null)
{
_connectionPoints.ForEach(p => p.PropertyChanged -= new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler);
}
SetProperty(ref _connectionPoints, value);
if (_connectionPoints != null)
{
_connectionPoints.ForEach(p => p.PropertyChanged += new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler);
}
}
}
@@ -179,35 +189,36 @@ namespace Util.DiagramDesigner
private void UpdateConnectionPoints()
{
if (SinkConnectorInfo is FullyCreatedConnectorInfo && SourceConnectorInfo.DataItem is LinkPointDesignerItemViewModel && ((FullyCreatedConnectorInfo)SinkConnectorInfo).DataItem is LinkPointDesignerItemViewModel)
if (_service.DrawModeViewModel.VectorLineDrawMode == DrawMode.ConnectingLine)
{
UpdateConnectionPointsByLine();
return;
}
if (Parent.DiagramType == DiagramType.FlowChart || Parent.DiagramType == DiagramType.SFC)
else if (_service.DrawModeViewModel.VectorLineDrawMode == DrawMode.BoundaryConnectingLine)
{
UpdateConnectionPointsByFlowChart();
UpdateConnectionPointsByBoundary();
}
else
{
UpdateConnectionPointsByNormal();
UpdateConnectionPointsByCorner();
}
}
private void UpdateConnectionPointsByLine()
{
ConnectionPoints = new List<Point>()
ConnectionPoints = PointInfoBase.ToList(new List<Point>()
{
new Point(SourceA.X < SourceB.X ? 0d : Area.Width, SourceA.Y < SourceB.Y ? 0d : Area.Height ),
new Point(SourceA.X > SourceB.X ? 0d : Area.Width, SourceA.Y > SourceB.Y ? 0d : Area.Height)
};
});
StartPoint = ConnectionPoints[0];
EndPoint = ConnectionPoints.Last();
}
private void UpdateConnectionPointsByNormal()
private void UpdateConnectionPointsByCorner()
{
ConnectionPoints = new List<Point>()
var points = new List<Point>()
{
new Point(SourceA.X < SourceB.X ? 0d : Area.Width, SourceA.Y < SourceB.Y ? 0d : Area.Height ),
@@ -215,34 +226,34 @@ namespace Util.DiagramDesigner
};
ConnectorInfo sourceInfo = ConnectorInfo(SourceConnectorInfo.Orientation,
ConnectionPoints[0].X,
ConnectionPoints[0].Y,
points[0].X,
points[0].Y,
SourceConnectorInfo.DataItem.ItemWidth,
SourceConnectorInfo.DataItem.ItemHeight,
ConnectionPoints[0]);
points[0]);
StartPoint = ConnectionPoints[0];
StartPoint = points[0];
if (IsFullConnection)
{
EndPoint = ConnectionPoints.Last();
EndPoint = points.Last();
ConnectorInfo sinkInfo = ConnectorInfo(SinkConnectorInfo.Orientation,
ConnectionPoints[1].X,
ConnectionPoints[1].Y,
points[1].X,
points[1].Y,
((FullyCreatedConnectorInfo)_sinkConnectorInfo).DataItem.ItemWidth,
((FullyCreatedConnectorInfo)_sinkConnectorInfo).DataItem.ItemHeight,
ConnectionPoints[1]);
points[1]);
ConnectionPoints = PathFinder.GetConnectionLine(sourceInfo, sinkInfo, false, SourceConnectorInfo.IsInnerPoint);
ConnectionPoints = PointInfoBase.ToList(PathFinder.GetConnectionLine(sourceInfo, sinkInfo, false, SourceConnectorInfo.IsInnerPoint));
}
else
{
ConnectionPoints = PathFinder.GetConnectionLine(sourceInfo, ConnectionPoints[1], SourceConnectorInfo.Orientation, SourceConnectorInfo.IsInnerPoint);
ConnectionPoints = PointInfoBase.ToList(PathFinder.GetConnectionLine(sourceInfo, points[1], SourceConnectorInfo.Orientation, SourceConnectorInfo.IsInnerPoint));
EndPoint = new Point();
}
}
#region
private void UpdateConnectionPointsByFlowChart()
private void UpdateConnectionPointsByBoundary()
{
var points = new List<Point>();
var ends = GetEndPoinds();
@@ -253,7 +264,7 @@ namespace Util.DiagramDesigner
var res = points.ToArray();
//UpdateEdges(res);
DoShift(res);
ConnectionPoints = res.ToList();
ConnectionPoints = PointInfoBase.ToList(res.ToList());
StartPoint = ConnectionPoints[0];
EndPoint = ConnectionPoints.Last();
}
@@ -372,6 +383,18 @@ namespace Util.DiagramDesigner
}
}
private void ConnectionPoint_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "Left":
case "Top":
RaisePropertyChanged(nameof(ConnectionPoints));
break;
}
}
private void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
{
this.Parent = sourceConnectorInfo.DataItem.Parent;