mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-11 19:56:36 +08:00
序列化继续整理
This commit is contained in:
@@ -20,7 +20,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
private IDiagramViewModel _viewModel { get { return DataContext as IDiagramViewModel; } }
|
||||
private IDiagramServiceProvider _service { get { return DiagramServicesProvider.Instance.Provider; } }
|
||||
|
||||
private ConnectorViewModel partialConnection;
|
||||
private ConnectionViewModel partialConnection;
|
||||
private List<Connector> connectorsHit = new List<Connector>();
|
||||
|
||||
private Point? rubberbandSelectionStartPoint = null;
|
||||
@@ -217,7 +217,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Rect rectangleBounds = sourceConnector.TransformToVisual(this).TransformBounds(new Rect(sourceConnector.RenderSize));
|
||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
partialConnection = new ConnectorViewModel(_viewModel, sourceDataItem, new PartCreatedConnectionInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
partialConnection = new ConnectionViewModel(_viewModel, sourceDataItem, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
|
||||
_viewModel.DirectAddItemCommand.Execute(partialConnection);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Rect rectangleBounds = new Rect(sourceConnectorInfo.DataItem.Left, sourceConnectorInfo.DataItem.Top, 3, 3);
|
||||
Point point = new Point(rectangleBounds.Left + (rectangleBounds.Width / 2),
|
||||
rectangleBounds.Bottom + (rectangleBounds.Height / 2));
|
||||
partialConnection = new ConnectorViewModel(_viewModel, sourceConnectorInfo, new PartCreatedConnectionInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
partialConnection = new ConnectionViewModel(_viewModel, sourceConnectorInfo, new PartCreatedConnectorInfo(point.X, point.Y), DrawMode, RouterMode);
|
||||
_viewModel.DirectAddItemCommand.Execute(partialConnection);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +323,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
partialConnection.SinkConnectorInfo = new PartCreatedConnectionInfo(currentPoint.X, currentPoint.Y);
|
||||
partialConnection.SinkConnectorInfo = new PartCreatedConnectorInfo(currentPoint.X, currentPoint.Y);
|
||||
HitTesting(currentPoint);
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
int indexOfLastTempConnection = sinkDataItem.DataItem.Root.Items.Count - 1;
|
||||
sinkDataItem.DataItem.Root.DirectRemoveItemCommand.Execute(
|
||||
sinkDataItem.DataItem.Root.Items[indexOfLastTempConnection]);
|
||||
sinkDataItem.DataItem.Root.AddItemCommand.Execute(new ConnectorViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
|
||||
sinkDataItem.DataItem.Root.AddItemCommand.Execute(new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode));
|
||||
}
|
||||
else if (_service.DrawModeViewModel.GetDrawMode() == DrawMode.DirectLine && connectorsHit.Count() == 1)
|
||||
{
|
||||
@@ -387,7 +387,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
_viewModel.DirectRemoveItemCommand.Execute(_viewModel.Items[indexOfLastTempConnection]);
|
||||
_viewModel.DirectAddItemCommand.Execute(pointItemView);
|
||||
|
||||
var connector = new ConnectorViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode);
|
||||
var connector = new ConnectionViewModel(_viewModel, sourceDataItem, sinkDataItem, DrawMode, RouterMode);
|
||||
_viewModel.AddItemCommand.Execute(connector);
|
||||
|
||||
sourceDataItem.DataItem.ZIndex++;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Controls
|
||||
{
|
||||
// we only move DesignerItems
|
||||
designerItems = designerItem.Root.SelectedItems.ToList();
|
||||
if (designerItem is ConnectorViewModel connector)
|
||||
if (designerItem is ConnectionViewModel connector)
|
||||
{
|
||||
designerItems.Add(connector.SourceConnectorInfo.DataItem);
|
||||
if (connector.IsFullConnection)
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public struct ConnectorInfo
|
||||
{
|
||||
public double DesignerItemLeft { get; set; }
|
||||
public double DesignerItemTop { get; set; }
|
||||
public SizeBase DesignerItemSize { get; set; }
|
||||
public PointBase Position { get; set; }
|
||||
public ConnectorOrientation Orientation { get; set; }
|
||||
|
||||
public static ConnectorInfo GetConnectorInfo(ConnectorOrientation orientation, double left, double top, double width, double height, PointBase position)
|
||||
{
|
||||
return new ConnectorInfo()
|
||||
{
|
||||
Orientation = orientation,
|
||||
DesignerItemSize = new SizeBase(width, height),
|
||||
DesignerItemLeft = left,
|
||||
DesignerItemTop = top,
|
||||
Position = position
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public ConnectionItem(ConnectorViewModel viewmodel) : base(viewmodel)
|
||||
public ConnectionItem(ConnectionViewModel viewmodel) : base(viewmodel)
|
||||
{
|
||||
this.SourceId = viewmodel.SourceConnectorInfo.DataItem.Id;
|
||||
this.SourceOrientation = viewmodel.SourceConnectorInfo.Orientation;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 连接点
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorInfoItemBase))]
|
||||
public class ConnectorInfoItemBase : SelectableItemBase
|
||||
{
|
||||
public ConnectorInfoItemBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorInfoItemBase(ConnectorInfoBase viewmodel) : base(viewmodel)
|
||||
{
|
||||
ConnectorWidth = viewmodel.ConnectorWidth;
|
||||
ConnectorHeight = viewmodel.ConnectorHeight;
|
||||
Orientation = viewmodel.Orientation;
|
||||
ConnectorValue = viewmodel.ConnectorValue;
|
||||
}
|
||||
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorHeight
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public ConnectorOrientation Orientation
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorValue
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,27 +9,23 @@ using System.Xml.Serialization;
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接点
|
||||
/// 完整连接点
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlInclude(typeof(ConnectorItem))]
|
||||
public class ConnectorItem : SelectableItemBase
|
||||
[XmlInclude(typeof(FullyCreatedConnectorInfoItem))]
|
||||
public class FullyCreatedConnectorInfoItem : ConnectorInfoItemBase
|
||||
{
|
||||
public ConnectorItem()
|
||||
public FullyCreatedConnectorInfoItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorItem(FullyCreatedConnectorInfo viewmodel) : base(viewmodel)
|
||||
public FullyCreatedConnectorInfoItem(FullyCreatedConnectorInfo viewmodel) : base(viewmodel)
|
||||
{
|
||||
XRatio = viewmodel.XRatio;
|
||||
YRatio = viewmodel.YRatio;
|
||||
ConnectorWidth = viewmodel.ConnectorWidth;
|
||||
ConnectorHeight = viewmodel.ConnectorHeight;
|
||||
Orientation = viewmodel.Orientation;
|
||||
IsInnerPoint = viewmodel.IsInnerPoint;
|
||||
ValueTypePoint = viewmodel.ValueTypePoint;
|
||||
ConnectorValue = viewmodel.ConnectorValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,22 +35,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
[XmlAttribute]
|
||||
public double YRatio { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorWidth { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorHeight { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public ConnectorOrientation Orientation { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public bool IsInnerPoint { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public ValueTypePoint ValueTypePoint { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public double ConnectorValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
public ImageDesignerItem(ImageItemViewModel item) : base(item)
|
||||
{
|
||||
Icon = item.Icon;
|
||||
Connectors = new List<ConnectorItem>();
|
||||
Connectors = new List<FullyCreatedConnectorInfoItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<ConnectorItem> Connectors { get; set; }
|
||||
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
public LogicalGateDesignerItemBase(LogicalGateItemViewModelBase item) : base(item)
|
||||
{
|
||||
this.Connectors = new List<ConnectorItem>();
|
||||
this.Connectors = new List<FullyCreatedConnectorInfoItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
|
||||
this.Connectors.Add(connector);
|
||||
}
|
||||
this.OrderNumber = item.OrderNumber;
|
||||
@@ -28,7 +28,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<ConnectorItem> Connectors { get; set; }
|
||||
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
|
||||
|
||||
[XmlAttribute]
|
||||
public int OrderNumber { get; set; }
|
||||
|
||||
@@ -12,26 +12,26 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public MediaDesignerItem(GifImageItemViewModel item) : base(item)
|
||||
{
|
||||
Connectors = new List<ConnectorItem>();
|
||||
Connectors = new List<FullyCreatedConnectorInfoItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
|
||||
public MediaDesignerItem(MediaItemViewModel item) : base(item)
|
||||
{
|
||||
Connectors = new List<ConnectorItem>();
|
||||
Connectors = new List<FullyCreatedConnectorInfoItem>();
|
||||
foreach (var fullyCreatedConnectorInfo in item.Connectors)
|
||||
{
|
||||
ConnectorItem connector = new ConnectorItem(fullyCreatedConnectorInfo);
|
||||
FullyCreatedConnectorInfoItem connector = new FullyCreatedConnectorInfoItem(fullyCreatedConnectorInfo);
|
||||
Connectors.Add(connector);
|
||||
}
|
||||
}
|
||||
|
||||
[XmlArray]
|
||||
public List<ConnectorItem> Connectors { get; set; }
|
||||
public List<FullyCreatedConnectorInfoItem> Connectors { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectingLineBoundary : IPathGenerator
|
||||
{
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
return PathGenerators.Boundary(_, link, route, source, target);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectingLineCorner : IPathGenerator
|
||||
{
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
return PathGenerators.Corner(_, link, route, source, target);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectingLineSmooth : IPathGenerator
|
||||
{
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
return PathGenerators.Smooth(_, link, route, source, target);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectingLineStraight : IPathGenerator
|
||||
{
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public PathGeneratorResult Get(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
return PathGenerators.Straight(_, link, route, source, target);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IPathGenerator
|
||||
{
|
||||
PathGeneratorResult Get(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target);
|
||||
PathGeneratorResult Get(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class PathGenerators
|
||||
{
|
||||
public static PathGeneratorResult Boundary(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public static PathGeneratorResult Boundary(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
route = ConcatRouteAndSourceAndTarget(route, source, target);
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new PathGeneratorResult(paths, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
|
||||
}
|
||||
|
||||
private static PointBase[] GetRouteWithMiddlePoints(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route)
|
||||
private static PointBase[] GetRouteWithMiddlePoints(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route)
|
||||
{
|
||||
var middle = GetMiddlePoints(
|
||||
link.SourceConnectorInfo.MiddlePosition,
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class PathGenerators
|
||||
{
|
||||
public static PathGeneratorResult Corner(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public static PathGeneratorResult Corner(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
route = ConcatRouteAndSourceAndTarget(route, source, target);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private const int const_margin = 20;
|
||||
|
||||
private static PointBase[] GetRouteWithFullConnectionLine(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route)
|
||||
private static PointBase[] GetRouteWithFullConnectionLine(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route)
|
||||
{
|
||||
var sourceInnerPoint = link.SourceConnectorInfo.IsInnerPoint;
|
||||
PointBase sourcePoint = link.SourceConnectorInfo.MiddlePosition;
|
||||
@@ -240,7 +240,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return linePoints.ToArray();
|
||||
}
|
||||
|
||||
private static PointBase[] GetRouteWithPartConnectionLine(IDiagramViewModel diagramViewModel, ConnectorViewModel link, PointBase[] route)
|
||||
private static PointBase[] GetRouteWithPartConnectionLine(IDiagramViewModel diagramViewModel, ConnectionViewModel link, PointBase[] route)
|
||||
{
|
||||
var sourceInnerPoint = link.SourceConnectorInfo.IsInnerPoint;
|
||||
PointBase sourcePoint = link.SourceConnectorInfo.MiddlePosition;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
private const double _margin = 125;
|
||||
|
||||
public static PathGeneratorResult Smooth(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public static PathGeneratorResult Smooth(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
route = ConcatRouteAndSourceAndTarget(route, source, target);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new PathGeneratorResult(new[] { path }, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
|
||||
}
|
||||
|
||||
private static PathGeneratorResult CurveThroughPoints(PointBase[] route, ConnectorViewModel link)
|
||||
private static PathGeneratorResult CurveThroughPoints(PointBase[] route, ConnectionViewModel link)
|
||||
{
|
||||
double sourceAngle = SourceMarkerAdjustement(route, link.ColorViewModel.LeftArrowSize);
|
||||
double targetAngle = TargetMarkerAdjustement(route, link.ColorViewModel.RightArrowSize);
|
||||
@@ -50,7 +50,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new PathGeneratorResult(paths, sourceAngle, route[0], targetAngle, route[route.Length - 1]);
|
||||
}
|
||||
|
||||
private static PointBase[] GetRouteWithCurvePoints(ConnectorViewModel link, PointBase[] route)
|
||||
private static PointBase[] GetRouteWithCurvePoints(ConnectionViewModel link, PointBase[] route)
|
||||
{
|
||||
if (link.IsPortless)
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class PathGenerators
|
||||
{
|
||||
public static PathGeneratorResult Straight(IDiagramViewModel _, ConnectorViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
public static PathGeneratorResult Straight(IDiagramViewModel _, ConnectionViewModel link, PointBase[] route, PointBase source, PointBase target)
|
||||
{
|
||||
route = ConcatRouteAndSourceAndTarget(route, source, target);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void DoShift(PointBase[] points, ConnectorViewModel link)
|
||||
private static void DoShift(PointBase[] points, ConnectionViewModel link)
|
||||
{
|
||||
double left = link.Area.Left;
|
||||
double top = link.Area.Top;
|
||||
|
||||
@@ -7,6 +7,6 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public interface IRouter
|
||||
{
|
||||
PointBase[] Get(IDiagramViewModel _, ConnectorViewModel link);
|
||||
PointBase[] Get(IDiagramViewModel _, ConnectionViewModel link);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class RouterNormal : IRouter
|
||||
{
|
||||
public PointBase[] Get(IDiagramViewModel _, ConnectorViewModel link)
|
||||
public PointBase[] Get(IDiagramViewModel _, ConnectionViewModel link)
|
||||
{
|
||||
return Routers.Normal(_, link);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class RouterOrthogonal : IRouter
|
||||
{
|
||||
public PointBase[] Get(IDiagramViewModel _, ConnectorViewModel link)
|
||||
public PointBase[] Get(IDiagramViewModel _, ConnectionViewModel link)
|
||||
{
|
||||
return Routers.Orthogonal(_, link);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class Routers
|
||||
{
|
||||
public static PointBase[] Normal(IDiagramViewModel _, ConnectorViewModel link)
|
||||
public static PointBase[] Normal(IDiagramViewModel _, ConnectionViewModel link)
|
||||
{
|
||||
return link.Vertices.Select(v => v.MiddlePosition).ToArray();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public static partial class Routers
|
||||
{
|
||||
public static PointBase[] Orthogonal(IDiagramViewModel _, ConnectorViewModel link)
|
||||
public static PointBase[] Orthogonal(IDiagramViewModel _, ConnectionViewModel link)
|
||||
{
|
||||
if (link.IsPortless)
|
||||
throw new Exception("Orthogonal router doesn't work with portless links yet");
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return (Style)itemsControl.FindResource("designerItemStyle");
|
||||
}
|
||||
|
||||
if (item is ConnectorViewModel)
|
||||
if (item is ConnectionViewModel)
|
||||
{
|
||||
return (Style)itemsControl.FindResource("connectorItemStyle");
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private void LineControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is ConnectorViewModel connector)
|
||||
if (this.DataContext is ConnectionViewModel connector)
|
||||
{
|
||||
connector.PropertyChanged -= Connector_PropertyChanged;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private async void PathAnimation_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.DataContext is ConnectorViewModel connector)
|
||||
if (this.DataContext is ConnectionViewModel connector)
|
||||
{
|
||||
connector.PropertyChanged -= Connector_PropertyChanged;
|
||||
connector.PropertyChanged += Connector_PropertyChanged;
|
||||
@@ -70,8 +70,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
case nameof(ConnectorViewModel.LineAnimation):
|
||||
case nameof(ConnectorViewModel.PathGeneratorResult):
|
||||
case nameof(ConnectionViewModel.LineAnimation):
|
||||
case nameof(ConnectionViewModel.PathGeneratorResult):
|
||||
await DoAnimation();
|
||||
break;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private async Task DoAnimation()
|
||||
{
|
||||
if (this.DataContext is ConnectorViewModel connector && connector.IsFullConnection)
|
||||
if (this.DataContext is ConnectionViewModel connector && connector.IsFullConnection)
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(100);
|
||||
switch (connector.LineAnimation)
|
||||
|
||||
@@ -13,9 +13,9 @@ using SvgPathProperties;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectorViewModel : SelectableDesignerItemViewModelBase
|
||||
public class ConnectionViewModel : SelectableDesignerItemViewModelBase
|
||||
{
|
||||
public ConnectorViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode)
|
||||
public ConnectionViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode)
|
||||
{
|
||||
Root = root;
|
||||
PathMode = drawMode.ToString();
|
||||
@@ -23,16 +23,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
}
|
||||
|
||||
public ConnectorViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, ConnectionItem designer) : base(root, designer)
|
||||
public ConnectionViewModel(IDiagramViewModel root, FullyCreatedConnectorInfo sourceConnectorInfo, FullyCreatedConnectorInfo sinkConnectorInfo, ConnectionItem designer) : base(root, designer)
|
||||
{
|
||||
PathMode = designer.PathMode;
|
||||
RouterMode = designer.RouterMode;
|
||||
|
||||
Init(sourceConnectorInfo, sinkConnectorInfo);
|
||||
LoadDesignerItemViewModel(designer);
|
||||
}
|
||||
|
||||
public ConnectorViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
|
||||
public ConnectionViewModel(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo, DrawMode drawMode, RouterMode routerMode) : this(null, sourceConnectorInfo, sinkConnectorInfo, drawMode, routerMode)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -65,11 +64,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
AddLabelCommand = new SimpleCommand(AddLabel);
|
||||
}
|
||||
|
||||
protected void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
ConnectionItem designer = designerbase as ConnectionItem;
|
||||
Vertices = new ObservableCollection<ConnectorVertexModel>(designer.Vertices.Select(p => new ConnectorVertexModel(this, new PointBase(p.X, p.Y))));
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectionItem designer)
|
||||
{
|
||||
Vertices = new ObservableCollection<ConnectorVertexModel>(designer.Vertices.Select(p => new ConnectorVertexModel(this.Root, this, designer)));
|
||||
Labels = new ObservableCollection<ConnectorLabelModel>(designer.Labels.Select(p => new ConnectorLabelModel(this.Root, this, designer)));
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
@@ -364,11 +367,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public PartCreatedConnectionInfo SinkConnectorInfoPart
|
||||
public PartCreatedConnectorInfo SinkConnectorInfoPart
|
||||
{
|
||||
get
|
||||
{
|
||||
return SinkConnectorInfo as PartCreatedConnectionInfo;
|
||||
return SinkConnectorInfo as PartCreatedConnectorInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +413,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
private void ConnectorViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (sender is ConnectorViewModel)
|
||||
if (sender is ConnectionViewModel)
|
||||
{
|
||||
switch (e.PropertyName)
|
||||
{
|
||||
@@ -15,6 +15,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.Orientation = orientation;
|
||||
}
|
||||
|
||||
public ConnectorInfoBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorInfoBase(IDiagramViewModel root, string json) : base(root, json)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -26,6 +36,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectorInfoItemBase designer)
|
||||
{
|
||||
ConnectorWidth = designer.ConnectorWidth;
|
||||
ConnectorHeight = designer.ConnectorHeight;
|
||||
Orientation = designer.Orientation;
|
||||
ConnectorValue = designer.ConnectorValue;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new ConnectorInfoItemBase(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectorInfoBase);
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public virtual PointBase Position
|
||||
{
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using SvgPathProperties;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectorLabelModel : ConnectorPointModel, ISelectable
|
||||
{
|
||||
public ConnectorLabelModel(ConnectorViewModel connector, string content, double? distance = null, PointBase? offset = null)
|
||||
public ConnectorLabelModel(ConnectionViewModel connector, string content, double? distance = null, PointBase? offset = null)
|
||||
{
|
||||
Parent = connector;
|
||||
Text = content;
|
||||
@@ -14,6 +15,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Offset = offset ?? new PointBase();
|
||||
}
|
||||
|
||||
public ConnectorLabelModel(IDiagramViewModel root, ConnectionViewModel connector, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
Parent = connector;
|
||||
}
|
||||
|
||||
public ConnectorLabelModel(IDiagramViewModel root, ConnectionViewModel connector, string json) : base(root, json)
|
||||
{
|
||||
Parent = connector;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -21,12 +32,33 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
DeleteLabelCommand = new SimpleCommand(DeleteLabel);
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectorLabelItem designer)
|
||||
{
|
||||
Distance = designer.Distance;
|
||||
Offset = designer.Offset;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new ConnectorLabelItem(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectorLabelItem);
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public ConnectorViewModel Connector
|
||||
public ConnectionViewModel Connector
|
||||
{
|
||||
get
|
||||
{
|
||||
return Parent as ConnectorViewModel;
|
||||
return Parent as ConnectionViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,16 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public ConnectorPointModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ConnectorPointModel(IDiagramViewModel root, string json) : base(root, json)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -37,6 +47,29 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectorPointItem designer)
|
||||
{
|
||||
X = designer.X;
|
||||
Y = designer.Y;
|
||||
ConnectorWidth = designer.ConnectorWidth;
|
||||
ConnectorHeight = designer.ConnectorHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new ConnectorPointItem(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectorPointItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 中间X
|
||||
/// </summary>
|
||||
@@ -1,16 +1,27 @@
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using System;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class ConnectorVertexModel : ConnectorPointModel
|
||||
{
|
||||
public ConnectorVertexModel(ConnectorViewModel connector, PointBase? position = null)
|
||||
public ConnectorVertexModel(ConnectionViewModel connector, PointBase? position = null)
|
||||
{
|
||||
Parent = connector;
|
||||
X = position?.X ?? 0;
|
||||
Y = position?.Y ?? 0;
|
||||
}
|
||||
|
||||
public ConnectorVertexModel(IDiagramViewModel root, ConnectionViewModel connector, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
Parent = connector;
|
||||
}
|
||||
|
||||
public ConnectorVertexModel(IDiagramViewModel root, ConnectionViewModel connector, string json) : base(root, json)
|
||||
{
|
||||
Parent = connector;
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -22,13 +33,28 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is ConnectorVertexItem designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ConnectorViewModel Connector
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new ConnectorVertexItem(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(ConnectorVertexModel);
|
||||
}
|
||||
|
||||
public ConnectionViewModel Connector
|
||||
{
|
||||
get
|
||||
{
|
||||
return Parent as ConnectorViewModel;
|
||||
return Parent as ConnectionViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,70 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class FullyCreatedConnectorInfo : ConnectorInfoBase
|
||||
{
|
||||
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, ValueTypePoint valueTypePoint = 0)
|
||||
: base(orientation)
|
||||
{
|
||||
this.DataItem = dataItem;
|
||||
this.IsInnerPoint = isInnerPoint;
|
||||
this.ValueTypePoint = valueTypePoint;
|
||||
if (IsInnerPoint == true)
|
||||
{
|
||||
BuildMenuOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
this.DataItem = dataItem;
|
||||
if (IsInnerPoint == true)
|
||||
{
|
||||
BuildMenuOptions();
|
||||
}
|
||||
}
|
||||
|
||||
public FullyCreatedConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, string json) : base(root, json)
|
||||
{
|
||||
this.DataItem = dataItem;
|
||||
if (IsInnerPoint == true)
|
||||
{
|
||||
BuildMenuOptions();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
menuOptions = new List<CinchMenuItem>();
|
||||
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
||||
DeleteCommand = new SimpleCommand(ExecuteDeleteCommand);
|
||||
|
||||
}
|
||||
|
||||
protected override void LoadDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designerbase)
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
if (designerbase is FullyCreatedConnectorInfoItem designer)
|
||||
{
|
||||
XRatio = designer.XRatio;
|
||||
YRatio = designer.YRatio;
|
||||
IsInnerPoint = designer.IsInnerPoint;
|
||||
ValueTypePoint = designer.ValueTypePoint;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
{
|
||||
return new FullyCreatedConnectorInfoItem(this);
|
||||
}
|
||||
|
||||
public override Type ToXmlType()
|
||||
{
|
||||
return typeof(FullyCreatedConnectorInfo);
|
||||
}
|
||||
|
||||
#region 属性
|
||||
public override PointBase Position
|
||||
{
|
||||
get
|
||||
@@ -18,62 +82,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
|
||||
private List<CinchMenuItem> menuOptions;
|
||||
|
||||
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, ValueTypePoint valueTypePoint = 0)
|
||||
: base(orientation)
|
||||
public IEnumerable<CinchMenuItem> MenuOptions
|
||||
{
|
||||
this.DataItem = dataItem;
|
||||
this.IsInnerPoint = isInnerPoint;
|
||||
this.ValueTypePoint = valueTypePoint;
|
||||
|
||||
menuOptions = new List<CinchMenuItem>();
|
||||
MenuItemCommand = new SimpleCommand(ExecuteMenuItemCommand);
|
||||
DeleteCommand = new SimpleCommand(ExecuteDeleteCommand);
|
||||
if (IsInnerPoint == true)
|
||||
get
|
||||
{
|
||||
BuildMenuOptions();
|
||||
return menuOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public void ExecuteMenuItemCommand(object arg)
|
||||
{
|
||||
Orientation = (ConnectorOrientation)arg;
|
||||
}
|
||||
|
||||
public void ExecuteDeleteCommand(object arg)
|
||||
{
|
||||
DataItem.RemoveConnector(this);
|
||||
|
||||
}
|
||||
|
||||
private void BuildMenuOptions()
|
||||
{
|
||||
menuOptions.Clear();
|
||||
var orientation = new CinchMenuItem("方向");
|
||||
var top = new CinchMenuItem("上");
|
||||
top.Command = MenuItemCommand;
|
||||
top.CommandParameter = ConnectorOrientation.Top;
|
||||
var bottom = new CinchMenuItem("下");
|
||||
bottom.Command = MenuItemCommand;
|
||||
bottom.CommandParameter = ConnectorOrientation.Bottom;
|
||||
var left = new CinchMenuItem("左");
|
||||
left.Command = MenuItemCommand;
|
||||
left.CommandParameter = ConnectorOrientation.Left;
|
||||
var right = new CinchMenuItem("右");
|
||||
right.Command = MenuItemCommand;
|
||||
right.CommandParameter = ConnectorOrientation.Right;
|
||||
orientation.Children.Add(top);
|
||||
orientation.Children.Add(bottom);
|
||||
orientation.Children.Add(left);
|
||||
orientation.Children.Add(right);
|
||||
|
||||
var delete = new CinchMenuItem("删除");
|
||||
delete.Command = DeleteCommand;
|
||||
|
||||
menuOptions.Add(orientation);
|
||||
menuOptions.Add(delete);
|
||||
}
|
||||
|
||||
public DesignerItemViewModelBase DataItem
|
||||
{
|
||||
get; private set;
|
||||
@@ -148,7 +164,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SetProperty(ref _style, value);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 方法
|
||||
public SimpleCommand DeleteCommand
|
||||
{
|
||||
get; private set;
|
||||
@@ -157,13 +175,45 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public IEnumerable<CinchMenuItem> MenuOptions
|
||||
public void ExecuteMenuItemCommand(object arg)
|
||||
{
|
||||
get
|
||||
{
|
||||
return menuOptions;
|
||||
}
|
||||
Orientation = (ConnectorOrientation)arg;
|
||||
}
|
||||
|
||||
public void ExecuteDeleteCommand(object arg)
|
||||
{
|
||||
DataItem.RemoveConnector(this);
|
||||
|
||||
}
|
||||
|
||||
private void BuildMenuOptions()
|
||||
{
|
||||
menuOptions.Clear();
|
||||
var orientation = new CinchMenuItem("方向");
|
||||
var top = new CinchMenuItem("上");
|
||||
top.Command = MenuItemCommand;
|
||||
top.CommandParameter = ConnectorOrientation.Top;
|
||||
var bottom = new CinchMenuItem("下");
|
||||
bottom.Command = MenuItemCommand;
|
||||
bottom.CommandParameter = ConnectorOrientation.Bottom;
|
||||
var left = new CinchMenuItem("左");
|
||||
left.Command = MenuItemCommand;
|
||||
left.CommandParameter = ConnectorOrientation.Left;
|
||||
var right = new CinchMenuItem("右");
|
||||
right.Command = MenuItemCommand;
|
||||
right.CommandParameter = ConnectorOrientation.Right;
|
||||
orientation.Children.Add(top);
|
||||
orientation.Children.Add(bottom);
|
||||
orientation.Children.Add(left);
|
||||
orientation.Children.Add(right);
|
||||
|
||||
var delete = new CinchMenuItem("删除");
|
||||
delete.Command = DeleteCommand;
|
||||
|
||||
menuOptions.Add(orientation);
|
||||
menuOptions.Add(delete);
|
||||
}
|
||||
|
||||
public double GetXRatioFromConnector()
|
||||
@@ -7,7 +7,7 @@ using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class PartCreatedConnectionInfo : ConnectorInfoBase
|
||||
public class PartCreatedConnectorInfo : ConnectorInfoBase
|
||||
{
|
||||
private PointBase position;
|
||||
public override PointBase Position
|
||||
@@ -18,7 +18,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
}
|
||||
|
||||
public PartCreatedConnectionInfo(double X, double Y) : base(ConnectorOrientation.None)
|
||||
public PartCreatedConnectorInfo(double X, double Y) : base(ConnectorOrientation.None)
|
||||
{
|
||||
this.position = new PointBase(X, Y);
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
ShapeDefiner = Shapes.Rectangle;
|
||||
}
|
||||
|
||||
public DesignerItemViewModelBase(IDiagramViewModel root, DesignerItemBase designer) : base(root, designer)
|
||||
public DesignerItemViewModelBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
ShapeDefiner = Shapes.Rectangle;
|
||||
}
|
||||
@@ -39,16 +39,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
DesignerItemBase designer = designerbase as DesignerItemBase;
|
||||
|
||||
this.Left = designer.Left;
|
||||
this.Top = designer.Top;
|
||||
this.Angle = designer.Angle;
|
||||
this.ScaleX = designer.ScaleX;
|
||||
this.ScaleY = designer.ScaleY;
|
||||
this.ItemWidth = designer.ItemWidth;
|
||||
this.ItemHeight = designer.ItemHeight;
|
||||
this.Icon = designer.Icon;
|
||||
if (designerbase is DesignerItemBase designer)
|
||||
{
|
||||
this.Left = designer.Left;
|
||||
this.Top = designer.Top;
|
||||
this.Angle = designer.Angle;
|
||||
this.ScaleX = designer.ScaleX;
|
||||
this.ScaleY = designer.ScaleY;
|
||||
this.ItemWidth = designer.ItemWidth;
|
||||
this.ItemHeight = designer.ItemHeight;
|
||||
this.Icon = designer.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
public override SelectableItemBase ToXmlObject()
|
||||
|
||||
@@ -1361,10 +1361,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
List<DesignerItemViewModelBase> selectedDesignerItems =
|
||||
SelectedItems.OfType<DesignerItemViewModelBase>().ToList();
|
||||
|
||||
List<ConnectorViewModel> selectedConnections =
|
||||
SelectedItems.OfType<ConnectorViewModel>().ToList();
|
||||
List<ConnectionViewModel> selectedConnections =
|
||||
SelectedItems.OfType<ConnectionViewModel>().ToList();
|
||||
|
||||
foreach (ConnectorViewModel connection in Items.OfType<ConnectorViewModel>())
|
||||
foreach (ConnectionViewModel connection in Items.OfType<ConnectionViewModel>())
|
||||
{
|
||||
if (!selectedConnections.Contains(connection))
|
||||
{
|
||||
@@ -1458,7 +1458,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint);
|
||||
|
||||
ConnectorViewModel connectionVM = new ConnectorViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||
connectors.Add(connectionVM);
|
||||
}
|
||||
|
||||
@@ -1537,7 +1537,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
List<SelectableDesignerItemViewModelBase> itemsToRemove = SelectedItems.OfType<SelectableDesignerItemViewModelBase>().ToList();
|
||||
List<SelectableDesignerItemViewModelBase> connectionsToAlsoRemove = new List<SelectableDesignerItemViewModelBase>();
|
||||
|
||||
foreach (var connector in Items.OfType<ConnectorViewModel>())
|
||||
foreach (var connector in Items.OfType<ConnectionViewModel>())
|
||||
{
|
||||
if (ItemsToDeleteHasConnector(itemsToRemove, connector.SourceConnectorInfo))
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
}
|
||||
|
||||
public GifImageItemViewModel(IDiagramViewModel root, MediaDesignerItem designer) : base(root, designer)
|
||||
public GifImageItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -64,17 +64,14 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
MediaDesignerItem designer = designerbase as MediaDesignerItem;
|
||||
|
||||
this.Icon = designer.Icon;
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designerbase is MediaDesignerItem designer)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this, connector.Orientation, true);
|
||||
fullyCreatedConnectorInfo.XRatio = connector.XRatio;
|
||||
fullyCreatedConnectorInfo.YRatio = connector.YRatio;
|
||||
fullyCreatedConnectorInfo.ConnectorWidth = connector.ConnectorWidth;
|
||||
fullyCreatedConnectorInfo.ConnectorHeight = connector.ConnectorHeight;
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
this.Icon = designer.Icon;
|
||||
foreach (var connector in designer.Connectors)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
}
|
||||
|
||||
public ImageItemViewModel(IDiagramViewModel root, ImageDesignerItem designer) : base(root, designer)
|
||||
public ImageItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -118,18 +118,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
ImageDesignerItem designer = designerbase as ImageDesignerItem;
|
||||
|
||||
this.Icon = designer.Icon;
|
||||
Suffix = Path.GetExtension(this.Icon).ToLower();
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designerbase is ImageDesignerItem designer)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this, connector.Orientation, true);
|
||||
fullyCreatedConnectorInfo.XRatio = connector.XRatio;
|
||||
fullyCreatedConnectorInfo.YRatio = connector.YRatio;
|
||||
fullyCreatedConnectorInfo.ConnectorWidth = connector.ConnectorWidth;
|
||||
fullyCreatedConnectorInfo.ConnectorHeight = connector.ConnectorHeight;
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
this.Icon = designer.Icon;
|
||||
Suffix = Path.GetExtension(this.Icon).ToLower();
|
||||
foreach (var connector in designer.Connectors)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
this.ClearConnectors();
|
||||
this.AddConnector(new FullyCreatedConnectorInfo(this, ConnectorOrientation.None, true));
|
||||
|
||||
ItemWidth = 5;
|
||||
ItemHeight = 5;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
BuildMenuOptions();
|
||||
}
|
||||
|
||||
public LogicalGateItemViewModelBase(IDiagramViewModel root, LogicalGateDesignerItemBase designer) : base(root, designer)
|
||||
public LogicalGateItemViewModelBase(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
BuildMenuOptions();
|
||||
}
|
||||
@@ -141,37 +141,31 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(root, designerbase);
|
||||
|
||||
LogicalGateDesignerItemBase designer = designerbase as LogicalGateDesignerItemBase;
|
||||
this.LogicalType = designer.LogicalType;
|
||||
this.OrderNumber = designer.OrderNumber;
|
||||
this.Value = designer.Value;
|
||||
this.IsEnabled = designer.IsEnabled;
|
||||
|
||||
ClearConnectors();
|
||||
Input.Clear();
|
||||
Output.Clear();
|
||||
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designerbase is LogicalGateDesignerItemBase designer)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this, connector.Orientation, true);
|
||||
fullyCreatedConnectorInfo.XRatio = connector.XRatio;
|
||||
fullyCreatedConnectorInfo.YRatio = connector.YRatio;
|
||||
fullyCreatedConnectorInfo.ConnectorWidth = connector.ConnectorWidth;
|
||||
fullyCreatedConnectorInfo.ConnectorHeight = connector.ConnectorHeight;
|
||||
fullyCreatedConnectorInfo.Orientation = connector.Orientation;
|
||||
fullyCreatedConnectorInfo.IsInnerPoint = connector.IsInnerPoint;
|
||||
fullyCreatedConnectorInfo.ValueTypePoint = connector.ValueTypePoint;
|
||||
fullyCreatedConnectorInfo.ConnectorValue = connector.ConnectorValue;
|
||||
this.LogicalType = designer.LogicalType;
|
||||
this.OrderNumber = designer.OrderNumber;
|
||||
this.Value = designer.Value;
|
||||
this.IsEnabled = designer.IsEnabled;
|
||||
|
||||
if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Left)
|
||||
ClearConnectors();
|
||||
Input.Clear();
|
||||
Output.Clear();
|
||||
|
||||
foreach (var connector in designer.Connectors)
|
||||
{
|
||||
Input.Add(Input.Count, fullyCreatedConnectorInfo);
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
|
||||
if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Left)
|
||||
{
|
||||
Input.Add(Input.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
else if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Right)
|
||||
{
|
||||
Output.Add(Output.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
else if (fullyCreatedConnectorInfo.Orientation == ConnectorOrientation.Right)
|
||||
{
|
||||
Output.Add(Output.Count, fullyCreatedConnectorInfo);
|
||||
}
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public MediaItemViewModel(IDiagramViewModel root, MediaDesignerItem designer) : base(root, designer)
|
||||
public MediaItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -46,18 +46,15 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
base.LoadDesignerItemViewModel(parent, designerbase);
|
||||
|
||||
MediaDesignerItem designer = designerbase as MediaDesignerItem;
|
||||
|
||||
this.Icon = designer.Icon;
|
||||
|
||||
foreach (var connector in designer.Connectors)
|
||||
if (designerbase is MediaDesignerItem designer)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this, connector.Orientation, true);
|
||||
fullyCreatedConnectorInfo.XRatio = connector.XRatio;
|
||||
fullyCreatedConnectorInfo.YRatio = connector.YRatio;
|
||||
fullyCreatedConnectorInfo.ConnectorWidth = connector.ConnectorWidth;
|
||||
fullyCreatedConnectorInfo.ConnectorHeight = connector.ConnectorHeight;
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
this.Icon = designer.Icon;
|
||||
|
||||
foreach (var connector in designer.Connectors)
|
||||
{
|
||||
FullyCreatedConnectorInfo fullyCreatedConnectorInfo = new FullyCreatedConnectorInfo(this.Root, this, connector);
|
||||
AddConnector(fullyCreatedConnectorInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
public TextDesignerItemViewModel(IDiagramViewModel root, DesignerItemBase designer) : base(root, designer)
|
||||
public TextDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
}
|
||||
|
||||
public VideoItemViewModel(IDiagramViewModel root, MediaDesignerItem designer) : base(root, designer)
|
||||
public VideoItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user