mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-28 04:03:23 +08:00
offset修复一半
This commit is contained in:
@@ -102,13 +102,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,9 +144,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Left = left + child.DesiredSize.Width / 2 - child.ItemWidth / 2 + child.Offset.X;
|
||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
@@ -159,18 +161,20 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X;
|
||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
double left = mindNode.DesiredMiddlePosition.X;
|
||||
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Left = left + child.Offset.X;
|
||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
|
||||
switch (mindNode.NodeLevel)
|
||||
{
|
||||
@@ -83,7 +83,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public ConnectionViewModel GetOrSetConnectionViewModel(MindNode source, MindNode sink, ConnectionViewModel connector = null)
|
||||
@@ -129,13 +129,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
@@ -184,9 +184,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
foreach (var child in tops)
|
||||
{
|
||||
child.Left = topleft + child.Spacing.Width + child.Offset.X;
|
||||
child.Top = toptop - child.ItemHeight - child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
@@ -207,9 +208,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
foreach (var child in bottoms)
|
||||
{
|
||||
child.Left = bottomleft + child.Spacing.Width + child.Offset.X;
|
||||
child.Top = bottomtop + child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
@@ -222,21 +224,23 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else if (mindNode.NodeLevel == 1)
|
||||
{
|
||||
if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||
{
|
||||
double x0 = mindNode.Left;
|
||||
double y0 = mindNode.Top + mindNode.ItemHeight;
|
||||
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.Left = x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height) + child.Offset.X;
|
||||
child.Top = y0 - (h + child.DesiredSize.Height - child.Spacing.Height) + child.Offset.Y;
|
||||
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);
|
||||
@@ -250,16 +254,17 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
double x0 = mindNode.Left;
|
||||
double y0 = mindNode.Top;
|
||||
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.Left = x0 + (h + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height) + child.Offset.X;
|
||||
child.Top = y0 + (h + child.DesiredSize.Height - child.ItemHeight - child.Spacing.Height) + child.Offset.Y;
|
||||
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);
|
||||
@@ -274,17 +279,18 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mindNode.GetLevel2Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.BottomLeft)
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X;
|
||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
double left = mindNode.DesiredMiddlePosition.X;
|
||||
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Left = left + child.Offset.X;
|
||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
@@ -298,15 +304,16 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X;
|
||||
double bottom = mindNode.MiddlePosition.Y - mindNode.ItemHeight / 2 - mindNode.Spacing.Height;
|
||||
double left = mindNode.DesiredMiddlePosition.X;
|
||||
double bottom = mindNode.DesiredMiddlePosition.Y - mindNode.ItemHeight / 2 - mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Left = left + child.Offset.X;
|
||||
child.Top = bottom - child.Spacing.Height - child.ItemHeight + child.Offset.Y;
|
||||
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);
|
||||
|
||||
@@ -101,13 +101,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
@@ -126,15 +126,21 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
}
|
||||
|
||||
double left = mindNode.DesiredMiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredMiddlePosition.Y - 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.Left = left + child.Spacing.Width + child.Offset.X;
|
||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y;
|
||||
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);
|
||||
@@ -144,8 +150,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
connector?.SetSinkPort(child.LeftConnector);
|
||||
connector?.SetVisible(child.Visible);
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,13 +103,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(mindNode.Root.Items.OfType<DesignerItemViewModelBase>());
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
@@ -150,9 +150,11 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
double lefttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, rights.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
foreach (var child in rights)
|
||||
{
|
||||
child.Left = left + child.Spacing.Width + child.Offset.X - child.RootNode.Offset.X;
|
||||
child.Top = lefttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
||||
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);
|
||||
@@ -168,9 +170,10 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
double righttop = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, lefts.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
foreach (var child in lefts)
|
||||
{
|
||||
child.Left = right - child.Spacing.Width - child.ItemWidth + child.Offset.X - child.RootNode.Offset.X;
|
||||
child.Top = righttop + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
||||
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);
|
||||
@@ -182,22 +185,23 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
//mindNode.Offset = new PointBase();
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mindNode.GetLevel2Node().ConnectorOrientation == ConnectorOrientation.Left)
|
||||
if (mindNode.GetLevel1Node().ConnectorOrientation == ConnectorOrientation.Left)
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
double left = mindNode.DesiredMiddlePosition.X + mindNode.ItemWidth / 2 + mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredMiddlePosition.Y - 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.Left = left + child.Spacing.Width + child.Offset.X - child.RootNode.Offset.X;
|
||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
||||
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);
|
||||
@@ -211,15 +215,16 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
double right = mindNode.MiddlePosition.X - mindNode.ItemWidth / 2 - mindNode.Spacing.Width;
|
||||
double top = mindNode.MiddlePosition.Y - Math.Min(mindNode.DesiredSize.Height, mindNode.Children.SumOrDefault(p => p.DesiredSize.Height)) / 2;
|
||||
double right = mindNode.DesiredMiddlePosition.X - mindNode.ItemWidth / 2 - mindNode.Spacing.Width;
|
||||
double top = mindNode.DesiredMiddlePosition.Y - 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.Left = right - child.Spacing.Width - child.ItemWidth + child.Offset.X - child.RootNode.Offset.X;
|
||||
child.Top = top + child.DesiredSize.Height / 2 - child.ItemHeight / 2 + child.Offset.Y - child.RootNode.Offset.Y;
|
||||
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);
|
||||
|
||||
@@ -103,13 +103,13 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
{
|
||||
if (mindNode == null) return;
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = true;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = true;
|
||||
var size = MeasureOverride(mindNode);
|
||||
ArrangeOverride(mindNode);
|
||||
|
||||
mindNode.Root.BringToFrontCommand.Execute(new SelectableDesignerItemViewModelBase[] { mindNode });
|
||||
|
||||
mindNode.GetLevel1Node().LayoutUpdating = false;
|
||||
mindNode.GetLevel0Node().LayoutUpdating = false;
|
||||
}
|
||||
|
||||
public SizeBase MeasureOverride(MindNode mindNode, bool isExpanded = true)
|
||||
@@ -128,15 +128,21 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
|
||||
public void ArrangeOverride(MindNode mindNode)
|
||||
{
|
||||
double left = mindNode.MiddlePosition.X - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
||||
double top = mindNode.MiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
}
|
||||
|
||||
double left = mindNode.DesiredMiddlePosition.X - Math.Max(mindNode.DesiredSize.Width, mindNode.Children.SumOrDefault(p => p.DesiredSize.Width)) / 2;
|
||||
double top = mindNode.DesiredMiddlePosition.Y + mindNode.ItemHeight / 2 + mindNode.Spacing.Height;
|
||||
if (mindNode.Children?.Count > 0)
|
||||
{
|
||||
foreach (var child in mindNode.Children)
|
||||
{
|
||||
child.Left = left + child.DesiredSize.Width / 2 - child.ItemWidth / 2 + child.Offset.X;
|
||||
child.Top = top + child.Spacing.Height + child.Offset.Y;
|
||||
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);
|
||||
@@ -151,7 +157,7 @@ namespace AIStudio.Wpf.Mind.Helpers
|
||||
|
||||
if (mindNode.NodeLevel == 0)
|
||||
{
|
||||
mindNode.DesiredPosition = mindNode.Position;
|
||||
mindNode.Offset = new PointBase();//修正后归0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user