准备添加中间端点

This commit is contained in:
艾竹
2023-01-15 11:59:51 +08:00
parent 717cc43827
commit 7d77864311
19 changed files with 1440 additions and 117 deletions

View File

@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Input;
//using System.Windows;
using System.Windows.Media;
using AIStudio.Wpf.DiagramDesigner.Geometrys;
@@ -44,6 +47,7 @@ namespace AIStudio.Wpf.DiagramDesigner
this.SourceConnectorInfo = sourceConnectorInfo;
this.SinkConnectorInfo = sinkConnectorInfo;
DeleteConnectionCommand = new SimpleCommand(DeleteConnection);
AddVertexCommand = new SimpleCommand(AddVertex);
if (Parent != null && Parent.ColorViewModel != null)
{
@@ -106,8 +110,8 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private List<ConnectorPoint> _connectionPoints;
public List<ConnectorPoint> ConnectionPoints
private ObservableCollection<ConnectorPoint> _connectionPoints = new ObservableCollection<ConnectorPoint>();
public ObservableCollection<ConnectorPoint> ConnectionPoints
{
get
{
@@ -117,12 +121,18 @@ namespace AIStudio.Wpf.DiagramDesigner
{
if (_connectionPoints != null)
{
_connectionPoints.ForEach(p => p.PropertyChanged -= new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler);
foreach (var connectionPoint in _connectionPoints)
{
connectionPoint.PropertyChanged -= new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler;
}
}
SetProperty(ref _connectionPoints, value);
if (_connectionPoints != null)
{
_connectionPoints.ForEach(p => p.PropertyChanged += new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler);
foreach (var connectionPoint in _connectionPoints)
{
connectionPoint.PropertyChanged += new WeakINPCEventHandler(ConnectionPoint_PropertyChanged).Handler;
}
}
}
}
@@ -153,6 +163,32 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private double _startAngle;
public double StartAngle
{
get
{
return _startAngle;
}
private set
{
SetProperty(ref _startAngle, value);
}
}
private double _endAngle;
public double EndAngle
{
get
{
return _endAngle;
}
private set
{
SetProperty(ref _endAngle, value);
}
}
private RectangleBase _area;
public RectangleBase Area
{
@@ -204,6 +240,19 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private bool _shouldInsertAnchor;
public bool ShouldInsertAnchor
{
get
{
return _shouldInsertAnchor;
}
set
{
SetProperty(ref _shouldInsertAnchor, value);
}
}
//待完善这两处
public List<LinkVertexModel> Vertices { get; } = new List<LinkVertexModel>();
public List<LinkLabelModel> Labels { get; set; } = new List<LinkLabelModel>();
@@ -307,8 +356,10 @@ namespace AIStudio.Wpf.DiagramDesigner
return;
PathGeneratorResult = PathGenerator.Get(Parent, this, route, source.Value, target.Value);
StartPoint = PathGeneratorResult.SourceMarkerPosition ?? new PointBase();
EndPoint = PathGeneratorResult.TargetMarkerPosition ?? new PointBase();
StartPoint = PathGeneratorResult.SourceMarkerPosition;
EndPoint = PathGeneratorResult.TargetMarkerPosition;
StartAngle = PathGeneratorResult.SourceMarkerAngle;
EndAngle = PathGeneratorResult.TargetMarkerAngle;
}
private void ConnectorViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -346,6 +397,11 @@ namespace AIStudio.Wpf.DiagramDesigner
get; set;
}
public SimpleCommand AddVertexCommand
{
get; set;
}
private void DeleteConnection(object args)
{
if (this.Parent is IDiagramViewModel)
@@ -355,6 +411,19 @@ namespace AIStudio.Wpf.DiagramDesigner
}
}
private void AddVertex(object parameter)
{
MouseButtonEventArgs mosueArg = ((EventToCommandArgs)parameter).EventArgs as MouseButtonEventArgs;
var position = mosueArg.GetPosition(((EventToCommandArgs)parameter).Sender as IInputElement);
ConnectionPoints.Add(new ConnectorPoint(position.X, position.Y));
if (!((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control))
{
ShouldInsertAnchor = false;
}
}
protected override void ExecuteEditCommand(object param)
{
if (this.OutTextItem != null) return;