From 6464cad46e7f3c1fba4ca37397711c5b71eb4948 Mon Sep 17 00:00:00 2001 From: kwai Date: Mon, 27 Feb 2023 20:19:08 +0800 Subject: [PATCH] xx --- AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs | 1 + AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs | 49 +++++++++++++++++++- AIStudio.Wpf.Mind/Helpers/MindLayout.cs | 1 + AIStudio.Wpf.Mind/ViewModels/MindNode.cs | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs index b74f4d4..6541dd2 100644 --- a/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/DirectoryLayout.cs @@ -54,6 +54,7 @@ namespace AIStudio.Wpf.Mind.Helpers break; } case NodeLevel.Level3: + case NodeLevel.Level4: { mindNode.ItemWidth = 80; mindNode.ItemHeight = 25; diff --git a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs index d5bc62b..3852b6b 100644 --- a/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/FishBoneLayout.cs @@ -153,7 +153,7 @@ namespace AIStudio.Wpf.Mind.Helpers var lastchildsize = childrensizes.LastOrDefault(); sizewithSpacing = new SizeBase(sizewithSpacing.Width + childrensizes.Sum(p => p.Height) - lastchildsize.Height / 2 + lastchildsize.Width, sizewithSpacing.Height + childrensizes.Sum(p => p.Height)); } - else if (mindNode.NodeLevel == NodeLevel.Level3) + else if (mindNode.NodeLevel == NodeLevel.Level3 || mindNode.NodeLevel == NodeLevel.Level4) { var childrensizes = mindNode.Children.Select(p => MeasureOverride(p, mindNode.IsExpanded && isExpanded)).ToArray(); sizewithSpacing = new SizeBase(Math.Max(sizewithSpacing.Width, sizewithSpacing.Width * 0.5 + childrensizes.Max(p => p.Width)), sizewithSpacing.Height + childrensizes.Sum(p => p.Height)); @@ -215,7 +215,54 @@ namespace AIStudio.Wpf.Mind.Helpers } else if (mindNode.NodeLevel == NodeLevel.Level2) { + if (mindNode.ConnectorOrientation == ConnectorOrientation.BottomLeft) + { + double left = mindNode.Left - mindNode.Spacing.Width + mindNode.DesiredSize.Height; + double top = mindNode.Top - mindNode.Spacing.Height; + if (mindNode.Children?.Count > 0) + { + foreach (var child in mindNode.Children) + { + child.Left = left + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height + child.Offset.X; + child.Top = top - child.DesiredSize.Height + child.ItemHeight / 2 + child.Spacing.Height + child.Offset.Y; + child.DesiredPosition = child.Position; + top -= child.DesiredSize.Height; + left += child.DesiredSize.Height; + + ArrangeOverride(child); + + var connect = mindNode.Root?.Items.OfType().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child); + connect?.SetSourcePort(mindNode.BottomLeftConnector); + connect?.SetSinkPort(child.LeftConnector); + connect?.SetVisible(child.Visible); + } + } + } + else + { + double left = mindNode.Left - mindNode.Spacing.Width + mindNode.DesiredSize.Height; + double top = mindNode.Top - mindNode.Spacing.Height; + if (mindNode.Children?.Count > 0) + { + + foreach (var child in mindNode.Children) + { + child.Left = left + child.DesiredSize.Height - child.ItemHeight / 2 - child.Spacing.Height + child.Offset.X; + child.Top = top - child.DesiredSize.Height + child.ItemHeight / 2 + child.Spacing.Height + child.Offset.Y; + child.DesiredPosition = child.Position; + top -= child.DesiredSize.Height; + left += child.DesiredSize.Height; + + ArrangeOverride(child); + + var connect = mindNode.Root?.Items.OfType().FirstOrDefault(p => p.SourceConnectorInfo?.DataItem == mindNode && p.SinkConnectorInfoFully?.DataItem == child); + connect?.SetSourcePort(mindNode.BottomLeftConnector); + connect?.SetSinkPort(child.LeftConnector); + connect?.SetVisible(child.Visible); + } + } + } } } } diff --git a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs index 0ea6eb9..0440ab2 100644 --- a/AIStudio.Wpf.Mind/Helpers/MindLayout.cs +++ b/AIStudio.Wpf.Mind/Helpers/MindLayout.cs @@ -55,6 +55,7 @@ namespace AIStudio.Wpf.Mind.Helpers break; } case NodeLevel.Level3: + case NodeLevel.Level4: { mindNode.ItemWidth = 80; mindNode.ItemHeight = 25; diff --git a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs index 6df6028..a5e2e57 100644 --- a/AIStudio.Wpf.Mind/ViewModels/MindNode.cs +++ b/AIStudio.Wpf.Mind/ViewModels/MindNode.cs @@ -356,7 +356,7 @@ namespace AIStudio.Wpf.Mind.ViewModels } else { - node = new MindNode(Root, NodeLevel + 1, this.MindType) { Text = "分支主题" }; + node = new MindNode(Root, (NodeLevel)Math.Min((int)NodeLevel + 1, (int)NodeLevel.Level4), this.MindType) { Text = "分支主题" }; } AddChild(node);