2023-02-22 19:50:00 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Algorithms;
|
|
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
2023-03-05 21:30:53 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
2023-04-02 12:01:46 +08:00
|
|
|
|
using AIStudio.Wpf.Mind.Models;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
using AIStudio.Wpf.Mind.ViewModels;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Wpf.Mind.Helpers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class FishBoneLayout : IMindLayout
|
|
|
|
|
|
{
|
2023-03-11 22:27:23 +08:00
|
|
|
|
public void Appearance(MindNode mindNode)
|
|
|
|
|
|
{
|
2023-04-02 12:01:46 +08:00
|
|
|
|
Appearance(mindNode, MindTheme.SkyBlue, false);
|
2023-03-11 22:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-02 12:01:46 +08:00
|
|
|
|
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-02-22 23:01:22 +08:00
|
|
|
|
if (mindNode == null) return;
|
|
|
|
|
|
|
2023-03-28 23:16:56 +08:00
|
|
|
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
|
2023-02-22 19:50:00 +08:00
|
|
|
|
switch (mindNode.NodeLevel)
|
|
|
|
|
|
{
|
2023-03-05 23:22:34 +08:00
|
|
|
|
case 0:
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-03-10 12:09:13 +08:00
|
|
|
|
if (initAppearance)
|
|
|
|
|
|
{
|
2023-04-02 12:01:46 +08:00
|
|
|
|
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-03-11 22:27:23 +08:00
|
|
|
|
mindNode.ClearConnectors();
|
2023-03-10 12:09:13 +08:00
|
|
|
|
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 };
|
|
|
|
|
|
mindNode.AddConnector(port);
|
|
|
|
|
|
}
|
2023-04-29 18:36:50 +08:00
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.PathStyle = PathStyle.None;
|
|
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.SizeStyle = SizeStyle.VerySmall;
|
2023-03-05 21:30:53 +08:00
|
|
|
|
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
case 1:
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-03-10 12:09:13 +08:00
|
|
|
|
if (initAppearance)
|
|
|
|
|
|
{
|
2023-04-02 12:01:46 +08:00
|
|
|
|
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-03-11 22:27:23 +08:00
|
|
|
|
mindNode.ClearConnectors();
|
2023-03-10 12:09:13 +08:00
|
|
|
|
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.BottomLeft, true) { XRatio = 0, YRatio = 1 };
|
|
|
|
|
|
mindNode.AddConnector(port1);
|
|
|
|
|
|
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.TopLeft, true) { XRatio = 0, YRatio = 0 };
|
|
|
|
|
|
mindNode.AddConnector(port2);
|
|
|
|
|
|
}
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.PathStyle = PathStyle.None;
|
|
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.SizeStyle = SizeStyle.VerySmall;
|
2023-03-10 12:09:13 +08:00
|
|
|
|
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
default:
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-03-10 12:09:13 +08:00
|
|
|
|
if (initAppearance)
|
2023-04-02 12:01:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
2023-03-10 12:09:13 +08:00
|
|
|
|
|
2023-03-11 22:27:23 +08:00
|
|
|
|
mindNode.ClearConnectors();
|
2023-03-10 12:09:13 +08:00
|
|
|
|
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 0.5 };
|
|
|
|
|
|
mindNode.AddConnector(port1);
|
|
|
|
|
|
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 };
|
|
|
|
|
|
mindNode.AddConnector(port2);
|
|
|
|
|
|
var port3 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.25, YRatio = 0 };
|
|
|
|
|
|
mindNode.AddConnector(port3);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-03-10 12:09:13 +08:00
|
|
|
|
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
2023-03-11 22:27:23 +08:00
|
|
|
|
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0);
|
2023-03-10 12:09:13 +08:00
|
|
|
|
}
|
2023-04-29 18:36:50 +08:00
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.PathStyle = PathStyle.None;
|
|
|
|
|
|
mindNode.ShapeViewModel.SinkMarker.SizeStyle = SizeStyle.VerySmall;
|
2023-03-10 12:09:13 +08:00
|
|
|
|
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-02-22 23:01:22 +08:00
|
|
|
|
|
2023-03-28 23:16:56 +08:00
|
|
|
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
2023-02-27 20:18:58 +08:00
|
|
|
|
{
|
2023-03-26 23:23:34 +08:00
|
|
|
|
if (source == null || sink == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
2023-02-28 22:07:40 +08:00
|
|
|
|
DrawMode drawMode;
|
|
|
|
|
|
RouterMode routerMode;
|
2023-03-05 23:22:34 +08:00
|
|
|
|
if (source.NodeLevel == 0)
|
2023-02-27 20:18:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
drawMode = DrawMode.ConnectingLineStraight;
|
|
|
|
|
|
routerMode = RouterMode.RouterFishBone;
|
|
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
else if (source.NodeLevel == 1)
|
2023-02-28 22:07:40 +08:00
|
|
|
|
{
|
|
|
|
|
|
drawMode = DrawMode.ConnectingLineStraight;
|
|
|
|
|
|
routerMode = RouterMode.RouterNormal;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
drawMode = DrawMode.ConnectingLineStraight;
|
|
|
|
|
|
routerMode = RouterMode.RouterOrthogonal;
|
|
|
|
|
|
}
|
2023-02-27 20:18:58 +08:00
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
if (connector == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, drawMode, routerMode);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-03-19 23:26:14 +08:00
|
|
|
|
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, drawMode.ToString(), routerMode.ToString());
|
2023-03-05 23:22:34 +08:00
|
|
|
|
}
|
2023-02-27 20:18:58 +08:00
|
|
|
|
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
|
|
|
|
|
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
|
|
|
|
|
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
2023-03-25 22:10:49 +08:00
|
|
|
|
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
2023-02-27 20:18:58 +08:00
|
|
|
|
|
|
|
|
|
|
return connector;
|
|
|
|
|
|
}
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-04-02 21:47:55 +08:00
|
|
|
|
public void UpdatedLayout(MindNode mindNode)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (mindNode == null) return;
|
|
|
|
|
|
|
2023-03-28 23:16:56 +08:00
|
|
|
|
mindNode.GetLevel0Node().LayoutUpdating = true;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
var size = MeasureOverride(mindNode);
|
|
|
|
|
|
ArrangeOverride(mindNode);
|
|
|
|
|
|
|
2023-02-27 23:18:31 +08:00
|
|
|
|
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-03-28 23:16:56 +08:00
|
|
|
|
mindNode.GetLevel0Node().LayoutUpdating = false;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
var sizewithSpacing = mindNode.SizeWithSpacing;
|
2023-02-28 22:07:40 +08:00
|
|
|
|
var bottomoffset = mindNode.Spacing.Width / 2;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
if (mindNode.Children?.Count > 0)
|
|
|
|
|
|
{
|
2023-03-05 23:22:34 +08:00
|
|
|
|
if (mindNode.NodeLevel == 0)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
var tops = mindNode.Children.Where((p, index) => index % 2 == 0).ToList();
|
2023-02-22 23:01:22 +08:00
|
|
|
|
tops.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.BottomLeft);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
var topsizes = tops.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
|
|
|
|
|
var bottoms = mindNode.Children.Where((p, index) => index % 2 == 1).ToList();
|
2023-02-22 23:01:22 +08:00
|
|
|
|
bottoms.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.TopLeft);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
var bottomsizes = bottoms.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
2023-03-05 21:30:53 +08:00
|
|
|
|
sizewithSpacing = new SizeBase(sizewithSpacing.Width + bottomoffset + Math.Max(topsizes.SumOrDefault(p => p.Width), bottomsizes.SumOrDefault(p => p.Width)), sizewithSpacing.Height + topsizes.MaxOrDefault(p => p.Height) + bottomsizes.MaxOrDefault(p => p.Height));
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
else if (mindNode.NodeLevel == 1)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
|
|
|
|
|
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
2023-02-22 23:01:22 +08:00
|
|
|
|
var lastchildsize = childrensizes.LastOrDefault();
|
2023-03-05 21:30:53 +08:00
|
|
|
|
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, sizewithSpacing.Height + childrensizes.SumOrDefault(p => p.Height) - lastchildsize.Height / 2 + lastchildsize.Width), sizewithSpacing.Height + childrensizes.SumOrDefault(p => p.Height));
|
2023-02-22 23:01:22 +08:00
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
else
|
2023-02-22 23:01:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
2023-03-05 21:30:53 +08:00
|
|
|
|
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, sizewithSpacing.Width * 0.5 + childrensizes.MaxOrDefault(p => p.Width)), sizewithSpacing.Height + childrensizes.SumOrDefault(p => p.Height));
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
|
|
|
|
|
mindNode.Visible = isExpanded;
|
|
|
|
|
|
|
|
|
|
|
|
return mindNode.DesiredSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ArrangeOverride(MindNode mindNode)
|
|
|
|
|
|
{
|
2023-03-05 23:22:34 +08:00
|
|
|
|
if (mindNode.NodeLevel == 0)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-03-29 22:55:12 +08:00
|
|
|
|
mindNode.DesiredPosition = mindNode.Position;
|
|
|
|
|
|
|
2023-02-22 23:01:22 +08:00
|
|
|
|
var tops = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.BottomLeft).ToList();
|
2023-03-29 22:55:12 +08:00
|
|
|
|
double topleft = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width;
|
|
|
|
|
|
double toptop = mindNode.DesiredPosition.Y - mindNode.Spacing.Height;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (mindNode.Children?.Count > 0)
|
2023-02-22 19:50:00 +08:00
|
|
|
|
{
|
2023-02-22 23:01:22 +08:00
|
|
|
|
foreach (var child in tops)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(topleft + child.Spacing.Width, toptop - child.ItemHeight - child.Spacing.Height);
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
topleft += child.DesiredSize.Width;
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-02-22 23:01:22 +08:00
|
|
|
|
ArrangeOverride(child);
|
2023-02-22 19:50:00 +08:00
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.RightConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.BottomLeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-22 23:01:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-28 22:07:40 +08:00
|
|
|
|
var bottomoffset = mindNode.Spacing.Width / 2;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
var bottoms = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.TopLeft).ToList();
|
2023-03-29 22:55:12 +08:00
|
|
|
|
double bottomleft = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width + bottomoffset;
|
|
|
|
|
|
double bottomtop = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (mindNode.Children?.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var child in bottoms)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(bottomleft + child.Spacing.Width, bottomtop + child.Spacing.Height);
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-22 23:01:22 +08:00
|
|
|
|
bottomleft += child.DesiredSize.Width;
|
|
|
|
|
|
|
|
|
|
|
|
ArrangeOverride(child);
|
|
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.RightConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.TopLeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-22 23:01:22 +08:00
|
|
|
|
}
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
2023-03-29 22:55:12 +08:00
|
|
|
|
|
2023-03-28 23:16:56 +08:00
|
|
|
|
mindNode.Offset = new PointBase();//修正后归0
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
else if (mindNode.NodeLevel == 1)
|
2023-02-22 23:01:22 +08:00
|
|
|
|
{
|
2023-02-27 20:19:08 +08:00
|
|
|
|
if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
double x0 = mindNode.DesiredPosition.X;
|
|
|
|
|
|
double y0 = mindNode.DesiredPosition.Y + mindNode.ItemHeight;
|
2023-02-28 18:53:34 +08:00
|
|
|
|
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
2023-02-27 20:19:08 +08:00
|
|
|
|
if (mindNode.Children?.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var child in mindNode.Children)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 - (h + child.DesiredSize.Height - child.Spacing.Height));
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-28 18:53:34 +08:00
|
|
|
|
h += child.DesiredSize.Height;
|
2023-02-27 20:19:08 +08:00
|
|
|
|
|
|
|
|
|
|
ArrangeOverride(child);
|
|
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.BottomLeftConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.LeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-27 20:19:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
double x0 = mindNode.DesiredPosition.X;
|
|
|
|
|
|
double y0 = mindNode.DesiredPosition.Y;
|
2023-02-28 18:53:34 +08:00
|
|
|
|
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
2023-02-27 20:19:08 +08:00
|
|
|
|
if (mindNode.Children?.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var child in mindNode.Children)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 + (h + child.DesiredSize.Height - child.ItemHeight - child.Spacing.Height));
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-28 18:53:34 +08:00
|
|
|
|
h += child.DesiredSize.Height;
|
2023-02-27 20:19:08 +08:00
|
|
|
|
|
|
|
|
|
|
ArrangeOverride(child);
|
|
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.TopLeftConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.LeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-27 20:19:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-02-22 23:01:22 +08:00
|
|
|
|
}
|
2023-03-05 23:22:34 +08:00
|
|
|
|
else
|
2023-02-28 18:53:34 +08:00
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
2023-02-28 18:53:34 +08:00
|
|
|
|
{
|
2023-03-29 22:55:12 +08:00
|
|
|
|
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2;
|
|
|
|
|
|
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
2023-02-28 22:07:40 +08:00
|
|
|
|
if (mindNode.Children?.Count > 0)
|
2023-02-28 18:53:34 +08:00
|
|
|
|
{
|
2023-02-28 22:07:40 +08:00
|
|
|
|
foreach (var child in mindNode.Children)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-28 22:07:40 +08:00
|
|
|
|
top += child.DesiredSize.Height;
|
2023-02-28 18:53:34 +08:00
|
|
|
|
|
2023-02-28 22:07:40 +08:00
|
|
|
|
ArrangeOverride(child);
|
2023-02-28 18:53:34 +08:00
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.BottomConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.LeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-28 22:07:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2023-03-29 22:55:12 +08:00
|
|
|
|
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2;
|
|
|
|
|
|
double bottom = mindNode.DesiredPosition.Y - mindNode.Spacing.Height;
|
2023-02-28 22:07:40 +08:00
|
|
|
|
if (mindNode.Children?.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var child in mindNode.Children)
|
|
|
|
|
|
{
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
2023-03-25 22:10:49 +08:00
|
|
|
|
child.DesiredPosition = new PointBase(left, bottom - child.Spacing.Height - child.ItemHeight);
|
2023-03-28 23:16:56 +08:00
|
|
|
|
child.Left = child.DesiredPosition.X + child.Offset.X;
|
|
|
|
|
|
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
2023-02-28 22:07:40 +08:00
|
|
|
|
bottom -= child.DesiredSize.Height;
|
|
|
|
|
|
|
|
|
|
|
|
ArrangeOverride(child);
|
|
|
|
|
|
|
2023-03-05 23:22:34 +08:00
|
|
|
|
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
|
|
|
|
|
connector?.SetSourcePort(mindNode.TopConnector);
|
|
|
|
|
|
connector?.SetSinkPort(child.LeftConnector);
|
|
|
|
|
|
connector?.SetVisible(child.Visible);
|
2023-02-28 22:07:40 +08:00
|
|
|
|
}
|
2023-02-28 18:53:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-02-22 19:50:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|