mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-03-03 08:10:50 +08:00
mind的拷贝完成
This commit is contained in:
@@ -63,10 +63,10 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.ShapeViewModel.PropertyChanged += ConnectorViewModel_PropertyChanged;
|
||||
this.PropertyChanged += ConnectorViewModel_PropertyChanged;
|
||||
|
||||
var routetype = GlobalType.AllTypes.Where(p => typeof(IRouter).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == RouterMode);
|
||||
var routetype = TypeHelper.GetType(RouterMode);
|
||||
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
||||
|
||||
var pathGeneratortype = GlobalType.AllTypes.Where(p => typeof(IPathGenerator).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == PathMode);
|
||||
var pathGeneratortype = TypeHelper.GetType(PathMode);
|
||||
PathGenerator = pathGeneratortype != null ? (System.Activator.CreateInstance(pathGeneratortype) as IPathGenerator) : new ConnectingLineSmooth();
|
||||
|
||||
this.SourceConnectorInfo = sourceConnectorInfo;
|
||||
@@ -497,12 +497,12 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
break;
|
||||
case nameof(RouterMode):
|
||||
var routetype = GlobalType.AllTypes.Where(p => typeof(IRouter).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == RouterMode);
|
||||
var routetype = TypeHelper.GetType(RouterMode);
|
||||
Router = routetype != null ? (System.Activator.CreateInstance(routetype) as IRouter) : new RouterNormal();
|
||||
UpdatePathGeneratorResult();
|
||||
break;
|
||||
case nameof(PathMode):
|
||||
var pathGeneratortype = GlobalType.AllTypes.Where(p => typeof(IPathGenerator).IsAssignableFrom(p)).FirstOrDefault(p => p.Name == PathMode);
|
||||
var pathGeneratortype = TypeHelper.GetType(PathMode);
|
||||
PathGenerator = pathGeneratortype != null ? (System.Activator.CreateInstance(pathGeneratortype) as IPathGenerator) : new ConnectingLineSmooth();
|
||||
UpdatePathGeneratorResult();
|
||||
break;
|
||||
@@ -729,6 +729,35 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
SinkConnectorInfo = sink;
|
||||
}
|
||||
|
||||
public void SetPathGeneratorParameter(double smoothMargin, double smoothAutoSlope, double orthogonalShapeMargin, double orthogonalGlobalBoundsMargin)
|
||||
{
|
||||
bool hasChanged = false;
|
||||
if (SmoothMargin != smoothMargin)
|
||||
{
|
||||
hasChanged = true;
|
||||
SmoothMargin = smoothMargin;
|
||||
}
|
||||
if (SmoothAutoSlope != smoothAutoSlope)
|
||||
{
|
||||
hasChanged = true;
|
||||
SmoothAutoSlope = smoothAutoSlope;
|
||||
}
|
||||
if (OrthogonalShapeMargin != orthogonalShapeMargin)
|
||||
{
|
||||
hasChanged = true;
|
||||
OrthogonalShapeMargin = orthogonalShapeMargin;
|
||||
}
|
||||
if (OrthogonalGlobalBoundsMargin != orthogonalGlobalBoundsMargin)
|
||||
{
|
||||
hasChanged = true;
|
||||
OrthogonalGlobalBoundsMargin = orthogonalGlobalBoundsMargin;
|
||||
}
|
||||
if (hasChanged)
|
||||
{
|
||||
UpdatePathGeneratorResult();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetVisible(bool visible)
|
||||
{
|
||||
Visible = visible;
|
||||
|
||||
@@ -318,6 +318,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public virtual bool CanAttachTo(FullyCreatedConnectorInfo port)
|
||||
=> port != this && !port.IsReadOnly && DataItem != port.DataItem;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({GetXRatioFromConnector()},{GetYRatioFromConnector()})";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -634,8 +634,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public event DiagramEventHandler Event;
|
||||
|
||||
private double OffsetX = 10;
|
||||
private double OffsetY = 10;
|
||||
protected double OffsetX = 10;
|
||||
protected double OffsetY = 10;
|
||||
#endregion
|
||||
|
||||
#region 命令
|
||||
@@ -1508,8 +1508,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
Connections = selectedConnections.Select(p => p.ToSerializableItem(".json")).Where(p => p != null).ToList(),
|
||||
}.ToJson();
|
||||
|
||||
OffsetX = 10;
|
||||
OffsetY = 10;
|
||||
OffsetX = 0;
|
||||
OffsetY = 0;
|
||||
System.Windows.Clipboard.Clear();
|
||||
System.Windows.Clipboard.SetData(System.Windows.DataFormats.Serializable, json);
|
||||
|
||||
@@ -1531,6 +1531,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return false;
|
||||
try
|
||||
{
|
||||
OffsetX += 10;
|
||||
OffsetY += 10;
|
||||
|
||||
List<SelectableDesignerItemViewModelBase> items = new List<SelectableDesignerItemViewModelBase>();
|
||||
SerializableObject copyitem = JsonConvert.DeserializeObject<SerializableObject>(clipboardData);
|
||||
|
||||
@@ -1555,10 +1558,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
items.Add(newItem);
|
||||
}
|
||||
}
|
||||
|
||||
OffsetX += 10;
|
||||
OffsetY += 10;
|
||||
}
|
||||
|
||||
List<SelectableDesignerItemViewModelBase> connectors = new List<SelectableDesignerItemViewModelBase>();
|
||||
foreach (var connection in copyitem.Connections)
|
||||
@@ -1570,8 +1570,8 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
connectionItem.SourceId = mappingOldToNewIDs[connectionItem.SourceId];
|
||||
connectionItem.SinkId = mappingOldToNewIDs[connectionItem.SinkId];
|
||||
|
||||
connectionItem.SourceType = System.Type.GetType(connectionItem.SourceTypeName);
|
||||
connectionItem.SinkType = System.Type.GetType(connectionItem.SinkTypeName);
|
||||
connectionItem.SourceType = TypeHelper.GetType(connectionItem.SourceTypeName);
|
||||
connectionItem.SinkType = TypeHelper.GetType(connectionItem.SinkTypeName);
|
||||
DesignerItemViewModelBase sourceItem = DiagramViewModelHelper.GetConnectorDataItem(items, connectionItem.SourceId, connectionItem.SourceType);
|
||||
ConnectorOrientation sourceConnectorOrientation = connectionItem.SourceOrientation;
|
||||
FullyCreatedConnectorInfo sourceConnectorInfo = sourceItem.GetFullConnectorInfo(connectionItem.Id, sourceConnectorOrientation, connectionItem.SourceXRatio, connectionItem.SourceYRatio, connectionItem.SourceInnerPoint, connectionItem.SourceIsPortless);
|
||||
@@ -1581,6 +1581,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = sinkItem.GetFullConnectorInfo(connectionItem.Id, sinkConnectorOrientation, connectionItem.SinkXRatio, connectionItem.SinkYRatio, connectionItem.SinkInnerPoint, connectionItem.SinkIsPortless);
|
||||
|
||||
ConnectionViewModel connectionVM = new ConnectionViewModel(this, sourceConnectorInfo, sinkConnectorInfo, connectionItem);
|
||||
connectionVM.Id = Guid.NewGuid();
|
||||
connectors.Add(connectionVM);
|
||||
}
|
||||
|
||||
@@ -1634,8 +1635,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
if (Paste(null) == false)
|
||||
return false;
|
||||
OffsetX = 0;
|
||||
OffsetY = 0;
|
||||
|
||||
if (Delete(null) == false)
|
||||
return false;
|
||||
|
||||
@@ -2102,6 +2102,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ExecuteSendToBackCommand(object parameter)
|
||||
{
|
||||
List<SelectableDesignerItemViewModelBase> selectionSorted;
|
||||
@@ -2151,6 +2152,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ExecuteDistributeHorizontalCommand(object parameter)
|
||||
{
|
||||
IEnumerable<DesignerItemViewModelBase> selectedItems;
|
||||
@@ -2214,6 +2216,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteDistributeVerticalCommand(object parameter)
|
||||
{
|
||||
IEnumerable<DesignerItemViewModelBase> selectedItems;
|
||||
|
||||
Reference in New Issue
Block a user