mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-08 10:16:36 +08:00
简单demo继续完善
This commit is contained in:
@@ -15,7 +15,61 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
private const int const_margin = 20;
|
||||
|
||||
public List<Point> GetConnectionLine(ConnectorInfo source, ConnectorInfo sink, bool showLastLine, bool sourceInnerPoint = false)
|
||||
public List<PointInfoBase> UpdateConnectionPoints(IDiagramViewModel diagramViewModel, Point sourceA, Point sourceB, FullyCreatedConnectorInfo sourceConnectorInfo, ConnectorInfoBase sinkConnectorInfo)
|
||||
{
|
||||
List<PointInfoBase> connectionPoints;
|
||||
var isFullConnection = sinkConnectorInfo is FullyCreatedConnectorInfo;
|
||||
var area = new Rect(sourceA, sourceB);
|
||||
|
||||
var points = new List<Point>()
|
||||
{
|
||||
new Point(sourceA.X < sourceB.X ? 0d : area.Width, sourceA.Y < sourceB.Y ? 0d : area.Height ),
|
||||
new Point(sourceA.X > sourceB.X ? 0d : area.Width, sourceA.Y > sourceB.Y ? 0d : area.Height)
|
||||
};
|
||||
|
||||
ConnectorInfo sourceInfo = ConnectorInfo(sourceConnectorInfo.Orientation,
|
||||
points[0].X,
|
||||
points[0].Y,
|
||||
sourceConnectorInfo.DataItem.ItemWidth,
|
||||
sourceConnectorInfo.DataItem.ItemHeight,
|
||||
points[0]);
|
||||
|
||||
//StartPoint = points[0];
|
||||
if (isFullConnection)
|
||||
{
|
||||
|
||||
ConnectorInfo sinkInfo = ConnectorInfo(sinkConnectorInfo.Orientation,
|
||||
points[1].X,
|
||||
points[1].Y,
|
||||
((FullyCreatedConnectorInfo)sinkConnectorInfo).DataItem.ItemWidth,
|
||||
((FullyCreatedConnectorInfo)sinkConnectorInfo).DataItem.ItemHeight,
|
||||
points[1]);
|
||||
|
||||
connectionPoints = PointInfoBase.ToList(GetConnectionLine(diagramViewModel, sourceInfo, sinkInfo, false, sourceConnectorInfo.IsInnerPoint));
|
||||
//EndPoint = ConnectionPoints.Last();
|
||||
}
|
||||
else
|
||||
{
|
||||
connectionPoints = PointInfoBase.ToList(GetConnectionLine(diagramViewModel, sourceInfo, points[1], sourceConnectorInfo.Orientation, false, sourceConnectorInfo.IsInnerPoint));
|
||||
//EndPoint = new Point();
|
||||
}
|
||||
|
||||
return connectionPoints;
|
||||
}
|
||||
|
||||
public ConnectorInfo ConnectorInfo(ConnectorOrientation orientation, double left, double top, double width, double height, Point position)
|
||||
{
|
||||
return new ConnectorInfo()
|
||||
{
|
||||
Orientation = orientation,
|
||||
DesignerItemSize = new Size(width, height),
|
||||
DesignerItemLeft = left,
|
||||
DesignerItemTop = top,
|
||||
Position = position
|
||||
};
|
||||
}
|
||||
|
||||
public List<Point> GetConnectionLine(IDiagramViewModel diagramViewModel, ConnectorInfo source, ConnectorInfo sink, bool showLastLine, bool sourceInnerPoint = false)
|
||||
{
|
||||
List<Point> linePoints = new List<Point>();
|
||||
int margin1 = sourceInnerPoint ? 0 : const_margin;
|
||||
@@ -213,11 +267,11 @@ namespace AIStudio.Wpf.DiagramDesigner
|
||||
return linePoints;
|
||||
}
|
||||
|
||||
public List<Point> GetConnectionLine(ConnectorInfo source, Point sinkPoint, ConnectorOrientation preferredOrientation, bool showLastLine, bool isInnerPoint = false)
|
||||
public List<Point> GetConnectionLine(IDiagramViewModel diagramViewModel, ConnectorInfo source, Point sinkPoint, ConnectorOrientation preferredOrientation, bool showLastLine, bool isInnerPoint = false)
|
||||
{
|
||||
List<Point> linePoints = new List<Point>();
|
||||
int margin = isInnerPoint ? 0 : const_margin;
|
||||
|
||||
int margin = isInnerPoint ? 0 : const_margin;
|
||||
|
||||
Rect rectSource = GetRectWithMargin(source, margin);
|
||||
Point startPoint = GetOffsetPoint(source, rectSource, isInnerPoint);
|
||||
Point endPoint = sinkPoint;
|
||||
|
||||
Reference in New Issue
Block a user