mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-26 19:23:24 +08:00
offset修复一半
This commit is contained in:
@@ -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