mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-05-03 14:31:28 +08:00
Portless序列化
This commit is contained in:
@@ -268,11 +268,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connectionItem.SourceId, connectionItem.SourceType);
|
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connectionItem.SourceId, connectionItem.SourceType);
|
||||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||||
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint);
|
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceInnerPoint);
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connectionItem.SinkId, connectionItem.SinkType);
|
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connectionItem.SinkId, connectionItem.SinkType);
|
||||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint);
|
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkInnerPoint);
|
||||||
|
|
||||||
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||||
viewModel.Items.Add(connectionVM);
|
viewModel.Items.Add(connectionVM);
|
||||||
@@ -354,25 +354,36 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
return dataItem;
|
return dataItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, DesignerItemViewModelBase dataItem, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint)
|
private FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, DesignerItemViewModelBase dataItem, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint,bool isPortless)
|
||||||
{
|
{
|
||||||
if (isInnerPoint)
|
if (isInnerPoint)
|
||||||
{
|
{
|
||||||
return dataItem.Connectors.Where(p => p.XRatio == xRatio && p.YRatio == yRatio).FirstOrDefault();
|
return dataItem.Connectors.Where(p => p.XRatio == xRatio && p.YRatio == yRatio).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
else if(isPortless)
|
||||||
|
{
|
||||||
|
return dataItem.PortlessConnector;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (connectorOrientation)
|
switch (connectorOrientation)
|
||||||
{
|
{
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return dataItem.TopConnector;
|
|
||||||
case ConnectorOrientation.Left:
|
case ConnectorOrientation.Left:
|
||||||
return dataItem.LeftConnector;
|
return dataItem.LeftConnector;
|
||||||
|
case ConnectorOrientation.TopLeft:
|
||||||
|
return dataItem.TopLeftConnector;
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return dataItem.TopConnector;
|
||||||
|
case ConnectorOrientation.TopRight:
|
||||||
|
return dataItem.TopRightConnector;
|
||||||
case ConnectorOrientation.Right:
|
case ConnectorOrientation.Right:
|
||||||
return dataItem.RightConnector;
|
return dataItem.RightConnector;
|
||||||
|
case ConnectorOrientation.BottomRight:
|
||||||
|
return dataItem.BottomRightConnector;
|
||||||
case ConnectorOrientation.Bottom:
|
case ConnectorOrientation.Bottom:
|
||||||
return dataItem.BottomConnector;
|
return dataItem.BottomConnector;
|
||||||
|
case ConnectorOrientation.BottomLeft:
|
||||||
|
return dataItem.BottomLeftConnector;
|
||||||
default:
|
default:
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
string.Format("Found invalid persisted Connector Orientation for Connector Id: {0}", connectorId));
|
string.Format("Found invalid persisted Connector Orientation for Connector Id: {0}", connectorId));
|
||||||
@@ -539,11 +550,11 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
|||||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connectionItem.SourceId, connectionItem.SourceType);
|
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(viewModel, connectionItem.SourceId, connectionItem.SourceType);
|
||||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||||
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint);
|
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connectionItem.SinkId, connectionItem.SinkType);
|
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(viewModel, connectionItem.SinkId, connectionItem.SinkType);
|
||||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint);
|
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
|
||||||
|
|
||||||
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
ConnectionViewModel connectionVM = new ConnectionViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||||
viewModel.Items.Add(connectionVM);
|
viewModel.Items.Add(connectionVM);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace AIStudio.Wpf.DiagramDesigner.Demo.ViewModels
|
|||||||
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.PortlessConnector, node2.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
ConnectionViewModel connector1 = new ConnectionViewModel(DiagramViewModel, node1.PortlessConnector, node2.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||||
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
DiagramViewModel.DirectAddItemCommand.Execute(connector1);
|
||||||
|
|
||||||
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.PortlessConnector, node3.RightConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
ConnectionViewModel connector2 = new ConnectionViewModel(DiagramViewModel, node2.PortlessConnector, node3.TopConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||||
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
DiagramViewModel.DirectAddItemCommand.Execute(connector2);
|
||||||
|
|
||||||
ConnectionViewModel connector3 = new ConnectionViewModel(DiagramViewModel, node3.LeftConnector, node4.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
ConnectionViewModel connector3 = new ConnectionViewModel(DiagramViewModel, node3.LeftConnector, node4.PortlessConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.SourceXRatio = viewmodel.SourceConnectorInfo.GetXRatioFromConnector();
|
this.SourceXRatio = viewmodel.SourceConnectorInfo.GetXRatioFromConnector();
|
||||||
this.SourceYRatio = viewmodel.SourceConnectorInfo.GetYRatioFromConnector();
|
this.SourceYRatio = viewmodel.SourceConnectorInfo.GetYRatioFromConnector();
|
||||||
this.SourceInnerPoint = viewmodel.SourceConnectorInfo.IsInnerPoint;
|
this.SourceInnerPoint = viewmodel.SourceConnectorInfo.IsInnerPoint;
|
||||||
|
this.SourceIsPortless = viewmodel.SourceConnectorInfo.IsPortless;
|
||||||
|
|
||||||
this.SinkId = viewmodel.SinkConnectorInfoFully.DataItem.Id;
|
this.SinkId = viewmodel.SinkConnectorInfoFully.DataItem.Id;
|
||||||
this.SinkOrientation = viewmodel.SinkConnectorInfoFully.Orientation;
|
this.SinkOrientation = viewmodel.SinkConnectorInfoFully.Orientation;
|
||||||
@@ -40,6 +41,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
this.SinkXRatio = viewmodel.SinkConnectorInfoFully.GetXRatioFromConnector();
|
this.SinkXRatio = viewmodel.SinkConnectorInfoFully.GetXRatioFromConnector();
|
||||||
this.SinkYRatio = viewmodel.SinkConnectorInfoFully.GetYRatioFromConnector();
|
this.SinkYRatio = viewmodel.SinkConnectorInfoFully.GetYRatioFromConnector();
|
||||||
this.SinkInnerPoint = viewmodel.SinkConnectorInfoFully.IsInnerPoint;
|
this.SinkInnerPoint = viewmodel.SinkConnectorInfoFully.IsInnerPoint;
|
||||||
|
this.SinkIsPortless = viewmodel.SourceConnectorInfo.IsPortless;
|
||||||
|
|
||||||
this.RouterMode = viewmodel.RouterMode;
|
this.RouterMode = viewmodel.RouterMode;
|
||||||
this.PathMode = viewmodel.PathMode;
|
this.PathMode = viewmodel.PathMode;
|
||||||
this.Vertices = viewmodel.Vertices.Select(p => new ConnectorVertexItem(p)).ToList();
|
this.Vertices = viewmodel.Vertices.Select(p => new ConnectorVertexItem(p)).ToList();
|
||||||
@@ -68,6 +71,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public bool SourceInnerPoint { get; set; }
|
public bool SourceInnerPoint { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public bool SourceIsPortless
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public Guid SinkId { get; set; }
|
public Guid SinkId { get; set; }
|
||||||
|
|
||||||
@@ -89,6 +98,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public bool SinkInnerPoint { get; set; }
|
public bool SinkInnerPoint { get; set; }
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public bool SinkIsPortless
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public string RouterMode
|
public string RouterMode
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,23 +27,41 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
XRatio = viewmodel.XRatio;
|
XRatio = viewmodel.XRatio;
|
||||||
YRatio = viewmodel.YRatio;
|
YRatio = viewmodel.YRatio;
|
||||||
IsInnerPoint = viewmodel.IsInnerPoint;
|
IsInnerPoint = viewmodel.IsInnerPoint;
|
||||||
|
IsPortless = viewmodel.IsPortless;
|
||||||
ValueTypePoint = viewmodel.ValueTypePoint;
|
ValueTypePoint = viewmodel.ValueTypePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public double XRatio { get; set; }
|
public double XRatio
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public double YRatio { get; set; }
|
public double YRatio
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public bool IsInnerPoint { get; set; }
|
public bool IsInnerPoint
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
[XmlAttribute]
|
[XmlAttribute]
|
||||||
public ValueTypePoint ValueTypePoint { get; set; }
|
public bool IsPortless
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlAttribute]
|
||||||
|
public ValueTypePoint ValueTypePoint
|
||||||
|
{
|
||||||
|
get; set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
var pt = port.Position;
|
var pt = port.Position;
|
||||||
switch (port.Orientation)
|
switch (port.Orientation)
|
||||||
{
|
{
|
||||||
|
case ConnectorOrientation.Left:
|
||||||
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight / 2);
|
||||||
|
case ConnectorOrientation.TopLeft:
|
||||||
|
return new PointBase(pt.X, pt.Y);
|
||||||
case ConnectorOrientation.Top:
|
case ConnectorOrientation.Top:
|
||||||
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y);
|
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y);
|
||||||
case ConnectorOrientation.TopRight:
|
case ConnectorOrientation.TopRight:
|
||||||
@@ -21,9 +25,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
case ConnectorOrientation.Bottom:
|
case ConnectorOrientation.Bottom:
|
||||||
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y + port.ConnectorHeight);
|
return new PointBase(pt.X + port.ConnectorWidth / 2, pt.Y + port.ConnectorHeight);
|
||||||
case ConnectorOrientation.BottomLeft:
|
case ConnectorOrientation.BottomLeft:
|
||||||
return new PointBase(pt.X, pt.Y + port.ConnectorHeight);
|
return new PointBase(pt.X, pt.Y + port.ConnectorHeight);
|
||||||
case ConnectorOrientation.Left:
|
|
||||||
return new PointBase(pt.X, pt.Y + port.ConnectorHeight / 2);
|
|
||||||
default:
|
default:
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -550,7 +550,7 @@
|
|||||||
<s:LineControl x:Name="line"/>
|
<s:LineControl x:Name="line"/>
|
||||||
|
|
||||||
<!-- PART_DragThumb -->
|
<!-- PART_DragThumb -->
|
||||||
<c:DragThumb x:Name="PART_DragThumb"
|
<c:DragThumb x:Name="PART_DragThumb" Margin="8"
|
||||||
Cursor="SizeAll" >
|
Cursor="SizeAll" >
|
||||||
<c:DragThumb.InputBindings>
|
<c:DragThumb.InputBindings>
|
||||||
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding }" />
|
<MouseBinding MouseAction="LeftDoubleClick" Command="{Binding EditCommand}" CommandParameter="{Binding }" />
|
||||||
|
|||||||
@@ -10,16 +10,17 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
public class FullyCreatedConnectorInfo : ConnectorInfoBase
|
public class FullyCreatedConnectorInfo : ConnectorInfoBase
|
||||||
{
|
{
|
||||||
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, ValueTypePoint valueTypePoint = 0)
|
public FullyCreatedConnectorInfo(DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueTypePoint valueTypePoint = 0)
|
||||||
: this(null, dataItem, orientation, isInnerPoint, valueTypePoint)
|
: this(null, dataItem, orientation, isInnerPoint, isPortless, valueTypePoint)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public FullyCreatedConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, ValueTypePoint valueTypePoint = 0)
|
public FullyCreatedConnectorInfo(IDiagramViewModel root, DesignerItemViewModelBase dataItem, ConnectorOrientation orientation, bool isInnerPoint = false, bool isPortless = false, ValueTypePoint valueTypePoint = 0)
|
||||||
: base(root, orientation)
|
: base(root, orientation)
|
||||||
{
|
{
|
||||||
this.Parent = dataItem;
|
this.Parent = dataItem;
|
||||||
this.IsInnerPoint = isInnerPoint;
|
this.IsInnerPoint = isInnerPoint;
|
||||||
|
this.IsPortless = IsPortless;
|
||||||
this.ValueTypePoint = valueTypePoint;
|
this.ValueTypePoint = valueTypePoint;
|
||||||
if (IsInnerPoint == true)
|
if (IsInnerPoint == true)
|
||||||
{
|
{
|
||||||
@@ -69,6 +70,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
XRatio = designer.XRatio;
|
XRatio = designer.XRatio;
|
||||||
YRatio = designer.YRatio;
|
YRatio = designer.YRatio;
|
||||||
IsInnerPoint = designer.IsInnerPoint;
|
IsInnerPoint = designer.IsInnerPoint;
|
||||||
|
IsPortless = designer.IsPortless;
|
||||||
ValueTypePoint = designer.ValueTypePoint;
|
ValueTypePoint = designer.ValueTypePoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,18 +233,30 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
return XRatio;
|
return XRatio;
|
||||||
}
|
}
|
||||||
|
else if (IsPortless)
|
||||||
|
{
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (Orientation)
|
switch (Orientation)
|
||||||
{
|
{
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return 0.5;
|
|
||||||
case ConnectorOrientation.Left:
|
case ConnectorOrientation.Left:
|
||||||
return 0;
|
return 0;
|
||||||
case ConnectorOrientation.Bottom:
|
case ConnectorOrientation.TopLeft:
|
||||||
|
return 0;
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
return 0.5;
|
return 0.5;
|
||||||
|
case ConnectorOrientation.TopRight:
|
||||||
|
return 1;
|
||||||
case ConnectorOrientation.Right:
|
case ConnectorOrientation.Right:
|
||||||
return 1;
|
return 1;
|
||||||
|
case ConnectorOrientation.BottomRight:
|
||||||
|
return 1;
|
||||||
|
case ConnectorOrientation.Bottom:
|
||||||
|
return 0.5;
|
||||||
|
case ConnectorOrientation.BottomLeft:
|
||||||
|
return 0;
|
||||||
default: return XRatio;
|
default: return XRatio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -254,18 +268,30 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
return YRatio;
|
return YRatio;
|
||||||
}
|
}
|
||||||
|
else if (IsPortless)
|
||||||
|
{
|
||||||
|
return 0.5;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (Orientation)
|
switch (Orientation)
|
||||||
{
|
{
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return 0;
|
|
||||||
case ConnectorOrientation.Left:
|
case ConnectorOrientation.Left:
|
||||||
return 0.5;
|
return 0.5;
|
||||||
case ConnectorOrientation.Bottom:
|
case ConnectorOrientation.TopLeft:
|
||||||
return 1;
|
return 0;
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return 0;
|
||||||
|
case ConnectorOrientation.TopRight:
|
||||||
|
return 0;
|
||||||
case ConnectorOrientation.Right:
|
case ConnectorOrientation.Right:
|
||||||
return 0.5;
|
return 0.5;
|
||||||
|
case ConnectorOrientation.BottomRight:
|
||||||
|
return 1;
|
||||||
|
case ConnectorOrientation.Bottom:
|
||||||
|
return 1;
|
||||||
|
case ConnectorOrientation.BottomLeft:
|
||||||
|
return 1;
|
||||||
default: return YRatio;
|
default: return YRatio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1479,11 +1479,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||||
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(this, connectionItem.SourceId, connectionItem.SourceType);
|
DesignerItemViewModelBase sourceItem = GetConnectorDataItem(this, connectionItem.SourceId, connectionItem.SourceType);
|
||||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||||
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint);
|
FullyCreatedConnectorInfo sourceConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sourceItem, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||||
|
|
||||||
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(this, connectionItem.SinkId, connectionItem.SinkType);
|
DesignerItemViewModelBase sinkItem = GetConnectorDataItem(this, connectionItem.SinkId, connectionItem.SinkType);
|
||||||
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
ConnectorOrientation sinkConnectorOrientation = connectionItem.SinkOrientation;
|
||||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint);
|
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connectionItem.Id, sinkItem, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
|
||||||
|
|
||||||
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||||
connectors.Add(connectionVM);
|
connectors.Add(connectionVM);
|
||||||
@@ -1514,24 +1514,36 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
return dataItem;
|
return dataItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, DesignerItemViewModelBase dataItem, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint)
|
private FullyCreatedConnectorInfo GetFullConnectorInfo(Guid connectorId, DesignerItemViewModelBase dataItem, ConnectorOrientation connectorOrientation, double xRatio, double yRatio, bool isInnerPoint, bool isPortless)
|
||||||
{
|
{
|
||||||
if (isInnerPoint)
|
if (isInnerPoint)
|
||||||
{
|
{
|
||||||
return dataItem.Connectors.Where(p => p.XRatio == xRatio && p.YRatio == yRatio).FirstOrDefault();
|
return dataItem.Connectors.Where(p => p.XRatio == xRatio && p.YRatio == yRatio).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
else if (isPortless)
|
||||||
|
{
|
||||||
|
return dataItem.PortlessConnector;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch (connectorOrientation)
|
switch (connectorOrientation)
|
||||||
{
|
{
|
||||||
case ConnectorOrientation.Top:
|
|
||||||
return dataItem.TopConnector;
|
|
||||||
case ConnectorOrientation.Left:
|
case ConnectorOrientation.Left:
|
||||||
return dataItem.LeftConnector;
|
return dataItem.LeftConnector;
|
||||||
|
case ConnectorOrientation.TopLeft:
|
||||||
|
return dataItem.TopLeftConnector;
|
||||||
|
case ConnectorOrientation.Top:
|
||||||
|
return dataItem.TopConnector;
|
||||||
|
case ConnectorOrientation.TopRight:
|
||||||
|
return dataItem.TopRightConnector;
|
||||||
case ConnectorOrientation.Right:
|
case ConnectorOrientation.Right:
|
||||||
return dataItem.RightConnector;
|
return dataItem.RightConnector;
|
||||||
|
case ConnectorOrientation.BottomRight:
|
||||||
|
return dataItem.BottomRightConnector;
|
||||||
case ConnectorOrientation.Bottom:
|
case ConnectorOrientation.Bottom:
|
||||||
return dataItem.BottomConnector;
|
return dataItem.BottomConnector;
|
||||||
|
case ConnectorOrientation.BottomLeft:
|
||||||
|
return dataItem.BottomLeftConnector;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
{
|
{
|
||||||
this.ItemHeight = this.ItemHeight * (Input.Values.Count + 1) / Input.Values.Count;
|
this.ItemHeight = this.ItemHeight * (Input.Values.Count + 1) / Input.Values.Count;
|
||||||
}
|
}
|
||||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true, ValueTypeInput.Count > index ? ValueTypeInput[index] : ValueTypeInput[0]);
|
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Left, true, false, ValueTypeInput.Count > index ? ValueTypeInput[index] : ValueTypeInput[0]);
|
||||||
connector.XRatio = 0;
|
connector.XRatio = 0;
|
||||||
Input.Add(Input.Count, connector);
|
Input.Add(Input.Count, connector);
|
||||||
for (int i = 0; i < Input.Values.Count; i++)
|
for (int i = 0; i < Input.Values.Count; i++)
|
||||||
@@ -234,7 +234,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
|||||||
|
|
||||||
public virtual void ExecuteAddOutput(object parameter, int index = 0)
|
public virtual void ExecuteAddOutput(object parameter, int index = 0)
|
||||||
{
|
{
|
||||||
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right, true, ValueTypeOutput.Count > index ? ValueTypeOutput[index] : ValueTypeInput[0]);
|
FullyCreatedConnectorInfo connector = new FullyCreatedConnectorInfo(this, ConnectorOrientation.Right, true, false, ValueTypeOutput.Count > index ? ValueTypeOutput[index] : ValueTypeInput[0]);
|
||||||
connector.XRatio = 1;
|
connector.XRatio = 1;
|
||||||
Output.Add(Output.Count, connector);
|
Output.Add(Output.Count, connector);
|
||||||
for (int i = 0; i < Output.Values.Count; i++)
|
for (int i = 0; i < Output.Values.Count; i++)
|
||||||
|
|||||||
Reference in New Issue
Block a user