mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-13 12:46:36 +08:00
项目结构调整
This commit is contained in:
193
Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs
Normal file
193
Extensions/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
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;
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public class DirectoryLayout : IMindLayout
|
||||
{
|
||||
public void Appearance(MindNode mindNode)
|
||||
{
|
||||
Appearance(mindNode, MindTheme.SkyBlue, false);
|
||||
}
|
||||
|
||||
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
||||
{
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 };
|
||||
mindNode.AddConnector(port);
|
||||
}
|
||||
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 };
|
||||
mindNode.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.25, YRatio = 1 };
|
||||
mindNode.AddConnector(port2);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
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);
|
||||
|
||||
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
||||
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
{
|
||||
if (source == null || sink == null)
|
||||
return null;
|
||||
|
||||
if (connector == null)
|
||||
{
|
||||
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString());
|
||||
}
|
||||
connector.EnabledForSelection = false;
|
||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
||||
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void UpdatedLayout(MindNode mindNode)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
{
|
||||
var sizewithSpacing = mindNode.SizeWithSpacing;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, childrensizes.SumOrDefault(p => p.Width)), sizewithSpacing.Height + childrensizes.MaxOrDefault(p => p.Height));
|
||||
}
|
||||
else
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, sizewithSpacing.Width * 0.5 + childrensizes.MaxOrDefault(p => p.Width)), sizewithSpacing.Height + childrensizes.SumOrDefault(p => p.Height));
|
||||
}
|
||||
}
|
||||
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
||||
mindNode.Visible = isExpanded;
|
||||
|
||||
return mindNode.DesiredSize;
|
||||
}
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2 - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
|
||||
left += child.DesiredSize.Width;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.FirstConnector);
|
||||
connector?.SetSinkPort(child.TopConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
334
Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs
Normal file
334
Extensions/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs
Normal file
@@ -0,0 +1,334 @@
|
||||
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;
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public class FishBoneLayout : IMindLayout
|
||||
{
|
||||
public void Appearance(MindNode mindNode)
|
||||
{
|
||||
Appearance(mindNode, MindTheme.SkyBlue, false);
|
||||
}
|
||||
|
||||
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 0.5 };
|
||||
mindNode.AddConnector(port);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
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);
|
||||
}
|
||||
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
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);
|
||||
|
||||
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
||||
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
{
|
||||
if (source == null || sink == null)
|
||||
return null;
|
||||
|
||||
DrawMode drawMode;
|
||||
RouterMode routerMode;
|
||||
if (source.NodeLevel == 0)
|
||||
{
|
||||
drawMode = DrawMode.ConnectingLineStraight;
|
||||
routerMode = RouterMode.RouterFishBone;
|
||||
}
|
||||
else if (source.NodeLevel == 1)
|
||||
{
|
||||
drawMode = DrawMode.ConnectingLineStraight;
|
||||
routerMode = RouterMode.RouterNormal;
|
||||
}
|
||||
else
|
||||
{
|
||||
drawMode = DrawMode.ConnectingLineStraight;
|
||||
routerMode = RouterMode.RouterOrthogonal;
|
||||
}
|
||||
|
||||
if (connector == null)
|
||||
{
|
||||
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, drawMode, routerMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, drawMode.ToString(), routerMode.ToString());
|
||||
}
|
||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
||||
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
||||
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void UpdatedLayout(MindNode mindNode)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
{
|
||||
var sizewithSpacing = mindNode.SizeWithSpacing;
|
||||
var bottomoffset = mindNode.Spacing.Width / 2;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
var tops = mindNode.Children.Where((p, index) => index % 2 == 0).ToList();
|
||||
tops.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.BottomLeft);
|
||||
var topsizes = tops.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
var bottoms = mindNode.Children.Where((p, index) => index % 2 == 1).ToList();
|
||||
bottoms.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.TopLeft);
|
||||
var bottomsizes = bottoms.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
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));
|
||||
}
|
||||
else if (mindNode.NodeLevel == 1)
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
var lastchildsize = childrensizes.LastOrDefault();
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, sizewithSpacing.Width * 0.5 + childrensizes.MaxOrDefault(p => p.Width)), sizewithSpacing.Height + childrensizes.SumOrDefault(p => p.Height));
|
||||
}
|
||||
}
|
||||
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
||||
mindNode.Visible = isExpanded;
|
||||
|
||||
return mindNode.DesiredSize;
|
||||
}
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
|
||||
var tops = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.BottomLeft).ToList();
|
||||
double topleft = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width;
|
||||
double toptop = mindNode.DesiredPosition.Y - mindNode.Spacing.Height;
|
||||
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in tops)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(topleft + child.Spacing.Width, toptop - child.ItemHeight - child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
topleft += child.DesiredSize.Width;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
var bottomoffset = mindNode.Spacing.Width / 2;
|
||||
var bottoms = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.TopLeft).ToList();
|
||||
double bottomleft = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width + bottomoffset;
|
||||
double bottomtop = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in bottoms)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(bottomleft + child.Spacing.Width, bottomtop + child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
bottomleft += child.DesiredSize.Width;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else if (mindNode.NodeLevel == 1)
|
||||
{
|
||||
if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||
{
|
||||
double x0 = mindNode.DesiredPosition.X;
|
||||
double y0 = mindNode.DesiredPosition.Y + mindNode.ItemHeight;
|
||||
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height), y0 - (h + child.DesiredSize.Height - child.Spacing.Height));
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
h += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double x0 = mindNode.DesiredPosition.X;
|
||||
double y0 = mindNode.DesiredPosition.Y;
|
||||
double h = mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
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));
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
h += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||
{
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left, top + child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2;
|
||||
double bottom = mindNode.DesiredPosition.Y - mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left, bottom - child.Spacing.Height - child.ItemHeight);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
bottom -= child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
42
Extensions/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs
Normal file
42
Extensions/AIStudio.Wpf.Mind/Helpers/IMindLayout.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Media;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public interface IMindLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认节点样式设置
|
||||
/// </summary>
|
||||
/// <param name="mindNode"></param>
|
||||
void Appearance(MindNode mindNode);
|
||||
|
||||
/// <summary>
|
||||
/// 节点样式设置
|
||||
/// </summary>
|
||||
/// <param name="mindNode"></param>
|
||||
/// <param name="mindTheme"></param>
|
||||
/// <param name="initAppearance"></param>
|
||||
void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance);
|
||||
|
||||
/// <summary>
|
||||
/// 连线类型设置
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <param name="sink"></param>
|
||||
/// <param name="connector"></param>
|
||||
/// <returns></returns>
|
||||
ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null);
|
||||
|
||||
/// <summary>
|
||||
/// 更新布局
|
||||
/// </summary>
|
||||
/// <param name="mindNode"></param>
|
||||
void UpdatedLayout(MindNode mindNode);
|
||||
}
|
||||
}
|
||||
163
Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs
Normal file
163
Extensions/AIStudio.Wpf.Mind/Helpers/LogicalLayout.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
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;
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public class LogicalLayout : IMindLayout
|
||||
{
|
||||
public void Appearance(MindNode mindNode)
|
||||
{
|
||||
Appearance(mindNode, MindTheme.SkyBlue, false);
|
||||
}
|
||||
|
||||
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
||||
{
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 };
|
||||
mindNode.AddConnector(port);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.Circle;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
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.Right, true) { XRatio = 1, YRatio = 0.5 };
|
||||
mindNode.AddConnector(port2);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 };
|
||||
mindNode.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 };
|
||||
mindNode.AddConnector(port2);
|
||||
|
||||
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
||||
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
{
|
||||
if (source == null || sink == null)
|
||||
return null;
|
||||
|
||||
if (connector == null)
|
||||
{
|
||||
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth.ToString(), RouterMode.RouterNormal.ToString());
|
||||
}
|
||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
||||
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
||||
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void UpdatedLayout(MindNode mindNode)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
{
|
||||
var sizewithSpacing = mindNode.SizeWithSpacing;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(sizewithSpacing.Width + childrensizes.MaxOrDefault(p => p.Width), Math.Max(sizewithSpacing.Height, childrensizes.SumOrDefault(p => p.Height)));
|
||||
}
|
||||
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
||||
mindNode.Visible = isExpanded;
|
||||
|
||||
return mindNode.DesiredSize;
|
||||
}
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
}
|
||||
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight / 2 - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.RightConnector ?? mindNode.FirstConnector);
|
||||
connector?.SetSinkPort(child.LeftConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
248
Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs
Normal file
248
Extensions/AIStudio.Wpf.Mind/Helpers/MindLayout.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
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;
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public class MindLayout : IMindLayout
|
||||
{
|
||||
public void Appearance(MindNode mindNode)
|
||||
{
|
||||
Appearance(mindNode, MindTheme.SkyBlue, false);
|
||||
}
|
||||
|
||||
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
||||
{
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.None, true) { XRatio = 0.5, YRatio = 0.5 };
|
||||
mindNode.AddConnector(port);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.Circle;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
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.Right, true) { XRatio = 1, YRatio = 0.5 };
|
||||
mindNode.AddConnector(port2);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Left, true) { XRatio = 0, YRatio = 1 };
|
||||
mindNode.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Right, true) { XRatio = 1, YRatio = 1 };
|
||||
mindNode.AddConnector(port2);
|
||||
|
||||
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
||||
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 1);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Left;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
{
|
||||
if (source == null || sink == null)
|
||||
return null;
|
||||
|
||||
if (connector == null)
|
||||
{
|
||||
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth, RouterMode.RouterNormal);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineSmooth.ToString(), RouterMode.RouterNormal.ToString());
|
||||
}
|
||||
|
||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||
connector.ShapeViewModel.SinkMarker.SizeStyle = source.ShapeViewModel.SinkMarker.SizeStyle;
|
||||
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
||||
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void UpdatedLayout(MindNode mindNode)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
{
|
||||
var sizewithSpacing = mindNode.SizeWithSpacing;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
var rights = mindNode.Children.Where((p, index) => index % 2 == 0).ToList();
|
||||
rights.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.Left);
|
||||
var rightsizes = rights.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
var lefts = mindNode.Children.Where((p, index) => index % 2 == 1).ToList();
|
||||
lefts.ForEach(p => p.ConnectorOrientation = ConnectorOrientation.Right);
|
||||
var leftsizes = lefts.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(sizewithSpacing.Width + rightsizes.MaxOrDefault(p => p.Width) + +leftsizes.MaxOrDefault(p => p.Width), Math.Max(sizewithSpacing.Height, Math.Max(rightsizes.SumOrDefault(p => p.Height), leftsizes.SumOrDefault(p => p.Height))));
|
||||
}
|
||||
else
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(sizewithSpacing.Width + childrensizes.MaxOrDefault(p => p.Width), Math.Max(sizewithSpacing.Height, childrensizes.SumOrDefault(p => p.Height)));
|
||||
}
|
||||
}
|
||||
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
||||
mindNode.Visible = isExpanded;
|
||||
|
||||
return mindNode.DesiredSize;
|
||||
}
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
var rights = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.Left).ToList();
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width;
|
||||
double lefttop = mindNode.DesiredPosition.Y + mindNode.ItemHeight / 2 - Math.Min(mindNode.DesiredSize.Height, rights.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
foreach (var child in rights)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||
|
||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, lefttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
lefttop += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.FirstConnector);
|
||||
connector?.SetSinkPort(child.LeftConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
|
||||
var lefts = mindNode.Children.Where(p => p.ConnectorOrientation == ConnectorOrientation.Right).ToList();
|
||||
double right = mindNode.DesiredPosition.X - mindNode.Spacing.Width;
|
||||
double righttop = mindNode.DesiredPosition.Y + mindNode.ItemHeight / 2 - Math.Min(mindNode.DesiredSize.Height, lefts.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
foreach (var child in lefts)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, righttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
righttop += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.FirstConnector);
|
||||
connector?.SetSinkPort(child.RightConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.Left)
|
||||
{
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth + mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight / 2 - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||
child.DesiredPosition = new PointBase(left + child.Spacing.Width, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.RightConnector);
|
||||
connector?.SetSinkPort(child.LeftConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double right = mindNode.DesiredPosition.X - mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight / 2 - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);
|
||||
child.DesiredPosition = new PointBase(right - child.Spacing.Width - child.ItemWidth, top + child.DesiredSize.Height / 2 - child.ItemHeight / 2);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
top += child.DesiredSize.Height;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.LeftConnector);
|
||||
connector?.SetSinkPort(child.RightConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
704
Extensions/AIStudio.Wpf.Mind/Helpers/MindThemeHelper.cs
Normal file
704
Extensions/AIStudio.Wpf.Mind/Helpers/MindThemeHelper.cs
Normal file
@@ -0,0 +1,704 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Xml.Linq;
|
||||
using AIStudio.Wpf.DiagramDesigner;
|
||||
using AIStudio.Wpf.DiagramDesigner.Geometrys;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public static class MindThemeHelper
|
||||
{
|
||||
static MindThemeHelper()
|
||||
{
|
||||
MindThemeDictionary = new List<MindThemeModel>()
|
||||
{
|
||||
SkyBlueTheme,
|
||||
SkyBlueMiniTheme,
|
||||
LiteratureGreenTheme,
|
||||
LiteratureGreenMiniTheme,
|
||||
BrainDeadPinkTheme,
|
||||
BrainDeadPinkMiniTheme,
|
||||
RomanticPurpleTheme,
|
||||
RomanticPurpleMiniTheme,
|
||||
FreshRedTheme,
|
||||
FreshRedMiniTheme,
|
||||
EarthyYellowTheme,
|
||||
EarthyYellowMiniTheme,
|
||||
CoolLightYellowTheme,
|
||||
CoolLightYellowMiniTheme
|
||||
};
|
||||
}
|
||||
|
||||
public static MindThemeModel GetTheme(MindTheme theme)
|
||||
{
|
||||
return MindThemeDictionary.FirstOrDefault(p => p.Theme == theme) ?? SkyBlueTheme;
|
||||
}
|
||||
|
||||
public static readonly List<MindThemeModel> MindThemeDictionary;
|
||||
|
||||
public static MindThemeModel SkyBlueTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.SkyBlue,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xee, 0xf3, 0xf6),
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel SkyBlueMiniTheme= new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.SkyBlueMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xee, 0xf3, 0xf6),
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x73, 0xa1, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel LiteratureGreenTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.LiteratureGreen,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xee, 0xf6, 0xee),
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel LiteratureGreenMiniTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.LiteratureGreenMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xee, 0xf6, 0xee),
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x73, 0xbf, 0x76),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel BrainDeadPinkTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.BrainDeadPink,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xee, 0xf2),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel BrainDeadPinkMiniTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.BrainDeadPinkMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xee, 0xf2),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x94),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel RomanticPurpleTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.RomanticPurple,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xef, 0xee, 0xf6),
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel RomanticPurpleMiniTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.RomanticPurpleMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xef, 0xee, 0xf6),
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0x7b, 0x73, 0xbf),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel FreshRedTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.FreshRed,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xee, 0xee),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel FreshRedMiniTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.FreshRedMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xee, 0xee),
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x73, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel EarthyYellowTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.EarthyYellow,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xf2, 0xee),
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel EarthyYellowMiniTheme= new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.EarthyYellowMini,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.White,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xf6, 0xf2, 0xee),
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.Transparent,
|
||||
LineColor = Color.FromRgb(0xbf, 0x93, 0x73),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel CoolLightYellowTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.CoolLightYellow,
|
||||
Dark = true,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xe9, 0xdf, 0x98),
|
||||
LineColor = Color.FromRgb(0xe9, 0xdf, 0x98),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(50, 15),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
|
||||
LineColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.White,
|
||||
LineColor = Colors.White,
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(15, 15),
|
||||
}
|
||||
};
|
||||
|
||||
public static MindThemeModel CoolLightYellowMiniTheme = new MindThemeModel()
|
||||
{
|
||||
Theme = MindTheme.CoolLightYellowMini,
|
||||
Dark = true,
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 120,
|
||||
ItemHeight = 40,
|
||||
FillColor = Color.FromRgb(0xe9, 0xdf, 0x98),
|
||||
LineColor = Color.FromRgb(0xe9, 0xdf, 0x98),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel1 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
|
||||
LineColor = Color.FromRgb(0xa4, 0xc5, 0xc0),
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
},
|
||||
MindThemeLevel2 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = 100,
|
||||
ItemHeight = 25,
|
||||
FillColor = Colors.White,
|
||||
LineColor = Colors.White,
|
||||
FontColor = Colors.Black,
|
||||
FontSize = 15,
|
||||
Spacing = new SizeBase(10, 10),
|
||||
}
|
||||
};
|
||||
|
||||
public static void ThemeChange(MindNode mindNode, MindTheme mindTheme, bool initAppearance = false)
|
||||
{
|
||||
var mindThemeModel = GetTheme(mindTheme);
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
mindNode.ItemWidth = mindThemeModel.MindThemeLevel0.ItemWidth;
|
||||
mindNode.ItemHeight = mindThemeModel.MindThemeLevel0.ItemHeight;
|
||||
}
|
||||
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel0.FillColor;
|
||||
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel0.LineColor;
|
||||
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel0.FontColor;
|
||||
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel0.FontSize;
|
||||
mindNode.Spacing = mindThemeModel.MindThemeLevel0.Spacing;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
mindNode.ItemWidth = mindThemeModel.MindThemeLevel1.ItemWidth;
|
||||
mindNode.ItemHeight = mindThemeModel.MindThemeLevel1.ItemHeight;
|
||||
}
|
||||
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel1.FillColor;
|
||||
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel1.LineColor;
|
||||
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel1.FontColor;
|
||||
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel1.FontSize;
|
||||
mindNode.Spacing = mindThemeModel.MindThemeLevel1.Spacing;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
mindNode.ItemWidth = mindThemeModel.MindThemeLevel2.ItemWidth;
|
||||
mindNode.ItemHeight = mindThemeModel.MindThemeLevel2.ItemHeight;
|
||||
}
|
||||
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel2.FillColor;
|
||||
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel2.LineColor;
|
||||
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel2.FontColor;
|
||||
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel2.FontSize;
|
||||
mindNode.Spacing = mindThemeModel.MindThemeLevel2.Spacing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static MindThemeModel GetNodeTheme(MindNode mindNode)
|
||||
{
|
||||
MindThemeModel mindThemeModel = new MindThemeModel()
|
||||
{
|
||||
MindThemeLevel0 = new MindThemeModelItem()
|
||||
{
|
||||
ItemWidth = mindNode.ItemWidth,
|
||||
ItemHeight = mindNode.ItemHeight,
|
||||
FillColor = mindNode.ColorViewModel.FillColor.Color,
|
||||
LineColor = mindNode.ColorViewModel.LineColor.Color,
|
||||
FontColor = mindNode.FontViewModel.FontColor,
|
||||
FontSize = mindNode.FontViewModel.FontSize,
|
||||
Spacing = mindNode.Spacing,
|
||||
},
|
||||
};
|
||||
return mindThemeModel;
|
||||
}
|
||||
|
||||
public static void SetThemeModel(MindNode mindNode, MindThemeModel mindThemeModel)
|
||||
{
|
||||
mindNode.ItemWidth = mindThemeModel.MindThemeLevel0.ItemWidth;
|
||||
mindNode.ItemHeight = mindThemeModel.MindThemeLevel0.ItemHeight;
|
||||
mindNode.ColorViewModel.FillColor.Color = mindThemeModel.MindThemeLevel0.FillColor;
|
||||
mindNode.ColorViewModel.LineColor.Color = mindThemeModel.MindThemeLevel0.LineColor;
|
||||
mindNode.FontViewModel.FontColor = mindThemeModel.MindThemeLevel0.FontColor;
|
||||
mindNode.FontViewModel.FontSize = mindThemeModel.MindThemeLevel0.FontSize;
|
||||
mindNode.Spacing = mindThemeModel.MindThemeLevel0.Spacing;
|
||||
}
|
||||
|
||||
public static MindThemeModelItem GetNodeDefaultTheme(MindNode mindNode)
|
||||
{
|
||||
var defaultMindTheme = MindThemeDictionary.FirstOrDefault(p => p.Theme == mindNode.MindTheme) ?? SkyBlueTheme;
|
||||
switch(mindNode.NodeLevel)
|
||||
{
|
||||
case 0: return defaultMindTheme.MindThemeLevel0;
|
||||
case 1: return defaultMindTheme.MindThemeLevel1;
|
||||
default: return defaultMindTheme.MindThemeLevel2;
|
||||
}
|
||||
}
|
||||
|
||||
public static IColorViewModel GetColorViewModel(MindNode mindNode)
|
||||
{
|
||||
ColorViewModel colorViewModel = new ColorViewModel();
|
||||
CopyHelper.CopyPropertyValue(mindNode.ColorViewModel, colorViewModel);
|
||||
return colorViewModel;
|
||||
}
|
||||
|
||||
public static IFontViewModel GetFontViewModel(MindNode mindNode)
|
||||
{
|
||||
FontViewModel fontViewModel = new FontViewModel();
|
||||
CopyHelper.CopyPropertyValue(mindNode.FontViewModel, fontViewModel);
|
||||
return fontViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
public class MindThemeModelItem
|
||||
{
|
||||
public double ItemWidth
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public double ItemHeight
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public Color FillColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public Color LineColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public Color FontColor
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public double FontSize
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public SizeBase Spacing
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
|
||||
public class MindThemeModel
|
||||
{
|
||||
public MindTheme Theme
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return Theme.GetDescription();
|
||||
}
|
||||
}
|
||||
public bool Dark
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public MindThemeModelItem MindThemeLevel0
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public MindThemeModelItem MindThemeLevel1
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
public MindThemeModelItem MindThemeLevel2
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
}
|
||||
}
|
||||
166
Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs
Normal file
166
Extensions/AIStudio.Wpf.Mind/Helpers/OrganizationalLayout.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
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;
|
||||
using AIStudio.Wpf.DiagramDesigner.Helpers;
|
||||
using AIStudio.Wpf.Mind.Models;
|
||||
using AIStudio.Wpf.Mind.ViewModels;
|
||||
|
||||
namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
public class OrganizationalLayout : IMindLayout
|
||||
{
|
||||
public void Appearance(MindNode mindNode)
|
||||
{
|
||||
Appearance(mindNode, MindTheme.SkyBlue, false);
|
||||
}
|
||||
|
||||
public void Appearance(MindNode mindNode, MindTheme mindTheme, bool initAppearance)
|
||||
{
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 };
|
||||
mindNode.AddConnector(port);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.None;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 };
|
||||
mindNode.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 };
|
||||
mindNode.AddConnector(port2);
|
||||
}
|
||||
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Top;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (initAppearance)
|
||||
{
|
||||
MindThemeHelper.ThemeChange(mindNode, mindTheme, initAppearance);
|
||||
|
||||
mindNode.ClearConnectors();
|
||||
var port1 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Top, true) { XRatio = 0.5, YRatio = 0 };
|
||||
mindNode.AddConnector(port1);
|
||||
var port2 = new FullyCreatedConnectorInfo(mindNode.Root, mindNode, ConnectorOrientation.Bottom, true) { XRatio = 0.5, YRatio = 1 };
|
||||
mindNode.AddConnector(port2);
|
||||
|
||||
mindNode.CornerRadius = new System.Windows.CornerRadius(0);
|
||||
mindNode.BorderThickness = new System.Windows.Thickness(0, 0, 0, 0);
|
||||
}
|
||||
mindNode.ShapeViewModel.SinkMarker.PathStyle = ArrowPathStyle.None;
|
||||
mindNode.ShapeViewModel.SinkMarker.SizeStyle = ArrowSizeStyle.VerySmall;
|
||||
mindNode.ConnectorOrientation = ConnectorOrientation.Top;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
{
|
||||
if (source == null || sink == null)
|
||||
return null;
|
||||
|
||||
if (connector == null)
|
||||
{
|
||||
connector = new ConnectionViewModel(source.Root, source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight, RouterMode.RouterOrthogonal);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector?.UpdateConnectionMode(source.FirstConnector, sink.FirstConnector, DrawMode.ConnectingLineStraight.ToString(), RouterMode.RouterOrthogonal.ToString());
|
||||
}
|
||||
connector.ColorViewModel.LineColor = source.ColorViewModel.LineColor;
|
||||
connector.ShapeViewModel.SinkMarker.PathStyle = source.ShapeViewModel.SinkMarker.PathStyle;
|
||||
connector.ShapeViewModel.SinkMarker.SizeStyle = sink.ShapeViewModel.SinkMarker.SizeStyle;
|
||||
connector.SetPathGeneratorParameter(smoothMargin: 20, smoothAutoSlope: 0.2, orthogonalShapeMargin: 2, orthogonalGlobalBoundsMargin: 5);
|
||||
|
||||
return connector;
|
||||
}
|
||||
|
||||
public void UpdatedLayout(MindNode mindNode)
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(new SelectableDesignerItemViewModelBase[] { mindNode });
|
||||
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
{
|
||||
var sizewithSpacing = mindNode.SizeWithSpacing;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray();
|
||||
sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, childrensizes.SumOrDefault(p => p.Width)), sizewithSpacing.Height + childrensizes.MaxOrDefault(p => p.Height));
|
||||
}
|
||||
mindNode.DesiredSize = isExpanded ? sizewithSpacing : new SizeBase(0, 0);
|
||||
mindNode.Visible = isExpanded;
|
||||
|
||||
return mindNode.DesiredSize;
|
||||
}
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
}
|
||||
|
||||
double left = mindNode.DesiredPosition.X + mindNode.ItemWidth / 2 - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
||||
double top = mindNode.DesiredPosition.Y + mindNode.ItemHeight + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Offset = new PointBase(child.Offset.X - child.RootNode.Offset.X, child.Offset.Y - child.RootNode.Offset.Y);//按根节点修正Offset
|
||||
child.DesiredPosition = new PointBase(left + child.DesiredSize.Width / 2 - child.ItemWidth / 2, top + child.Spacing.Height);
|
||||
child.Left = child.DesiredPosition.X + child.Offset.X;
|
||||
child.Top = child.DesiredPosition.Y + child.Offset.Y;
|
||||
left += child.DesiredSize.Width;
|
||||
|
||||
ArrangeOverride(child);
|
||||
|
||||
var connector = mindNode.Root?.Items.OfType<ConnectionViewModel>().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child);
|
||||
connector?.SetSourcePort(mindNode.BottomConnector);
|
||||
connector?.SetSinkPort(child.TopConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user