mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-05 00:37:19 +08:00
xx
This commit is contained in:
@@ -273,7 +273,6 @@ namespace AIStudio.Wpf.DiagramApp.ViewModels
|
||||
ConnectorOrientation sinkConnectorOrientation = connection.SinkOrientation;
|
||||
FullyCreatedConnectorInfo sinkConnectorInfo = GetFullConnectorInfo(connection.Id, sinkItem, sinkConnectorOrientation, connection.SinkXRatio, connection.SinkYRatio, connection.SinkInnerPoint);
|
||||
|
||||
|
||||
ConnectorViewModel connectionVM = new ConnectorViewModel(viewModel, sourceConnectorInfo, sinkConnectorInfo, connection);
|
||||
DesignerItemViewModelBase textItem = viewModel.Items.OfType<DesignerItemViewModelBase>().FirstOrDefault(x => x.ParentId == connection.Id);
|
||||
if (textItem != null)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
@@ -37,31 +39,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
this.SinkInnerPoint = viewmodel.SinkConnectorInfoFully.IsInnerPoint;
|
||||
this.RouterMode = viewmodel.RouterMode;
|
||||
this.PathMode = viewmodel.PathMode;
|
||||
this.Vertices = viewmodel.Vertices.Select(p => (Point)p.MiddlePosition).ToList();
|
||||
}
|
||||
|
||||
//public ConnectionItem(Guid sourceId, ConnectorOrientation sourceOrientation, Type sourceType, double sourceXRatio, double sourceYRatio, bool sourceInnerPoint,
|
||||
// Guid sinkId, ConnectorOrientation sinkOrientation, Type sinkType, double sinkXRatio, double sinkYRatio, bool sinkInnerPoint, ConnectorViewModel viewmodel) : base(viewmodel)
|
||||
//{
|
||||
|
||||
|
||||
// this.SourceId = sourceId;
|
||||
// this.SourceOrientation = sourceOrientation;
|
||||
// this.SourceType = sourceType;
|
||||
// this.SourceTypeName = sourceType.FullName;
|
||||
// this.SourceXRatio = sourceXRatio;
|
||||
// this.SourceYRatio = sourceYRatio;
|
||||
// this.SourceInnerPoint = sourceInnerPoint;
|
||||
|
||||
// this.SinkId = sinkId;
|
||||
// this.SinkOrientation = sinkOrientation;
|
||||
// this.SinkType = sinkType;
|
||||
// this.SinkTypeName = sinkType.FullName;
|
||||
// this.SinkXRatio = sinkXRatio;
|
||||
// this.SinkYRatio = sinkYRatio;
|
||||
// this.SinkInnerPoint = sinkInnerPoint;
|
||||
// this.RouterMode = viewmodel.RouterMode;
|
||||
// this.DrawMode = viewmodel.DrawMode;
|
||||
//}
|
||||
|
||||
[XmlAttribute]
|
||||
public Guid SourceId { get; set; }
|
||||
@@ -116,5 +96,25 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public List<Point> Vertices
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
[XmlAttribute("Vertices")]
|
||||
public string XmlVertices
|
||||
{
|
||||
get
|
||||
{
|
||||
return SerializeHelper.SerializePointList(Vertices);
|
||||
}
|
||||
set
|
||||
{
|
||||
Vertices = SerializeHelper.DeserializePointList(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
public static string SerializeColorList(IEnumerable<Color> colors)
|
||||
{
|
||||
return string.Join("-", colors.Select(color => string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", color.A, color.R, color.G, color.B)));
|
||||
return string.Join("-", colors.Select(color => SerializeColor(color)));
|
||||
}
|
||||
|
||||
public static List<Color> DeserializeColorList(string colorstring)
|
||||
@@ -473,6 +473,22 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new Point(double.Parse(pieces[0]), double.Parse(pieces[1]));
|
||||
}
|
||||
|
||||
public static string SerializePointList(List<Point> points)
|
||||
{
|
||||
return string.Join("-", points.Select(point => SerializePoint(point)));
|
||||
}
|
||||
|
||||
public static List<Point> DeserializePointList(string pointstring)
|
||||
{
|
||||
List<Point> pointlist = new List<Point>();
|
||||
var points = pointstring.Split('-');
|
||||
foreach (var point in points)
|
||||
{
|
||||
pointlist.Add(DeserializePoint(point));
|
||||
}
|
||||
return pointlist;
|
||||
}
|
||||
|
||||
public static string SerializeSize(Size size)
|
||||
{
|
||||
return string.Format("{0},{1}", size.Width, size.Height);
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return new PointBase(Left, Top);
|
||||
}
|
||||
}
|
||||
public virtual PointBase MiddlePosition => new PointBase(Left + ConnectorWidth / 2, Top + ConnectorHeight / 2);
|
||||
public virtual PointBase MiddlePosition => new PointBase(X, Y);
|
||||
|
||||
private double connectorWidth = 8;
|
||||
public double ConnectorWidth
|
||||
|
||||
@@ -26,7 +26,9 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
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)
|
||||
@@ -34,7 +36,7 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
|
||||
}
|
||||
|
||||
private void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||
protected virtual void Init(FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||
{
|
||||
this.Parent = sourceConnectorInfo.DataItem.Parent;
|
||||
|
||||
@@ -61,9 +63,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
AddVertexCommand = new SimpleCommand(AddVertex);
|
||||
}
|
||||
|
||||
private void ConnectorViewModel_PropertyChanged1(object sender, PropertyChangedEventArgs e)
|
||||
protected void LoadDesignerItemViewModel(SelectableDesignerItemBase designerbase)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ConnectionItem designer = designerbase as ConnectionItem;
|
||||
Vertices = new ObservableCollection<LinkVertexModel>(designer.Vertices.Select(p => new LinkVertexModel(this, new PointBase(p.X, p.Y))));
|
||||
|
||||
}
|
||||
|
||||
public override SelectableDesignerItemBase ToXmlObject()
|
||||
|
||||
Reference in New Issue
Block a user