Size CalculateSizes(Topic parent, Size parentFullSize, Topic[] subTopics, MindMapLayoutArgs e, Vector4 vector, Hashtable layoutInfos) { Size fullSize = parentFullSize;// parent.Size; if (subTopics != null && subTopics.Length > 0) { bool first = true; foreach (Topic subTopic in subTopics) { subTopic.Size = CalculateNodeSize(subTopic, e); var subTopicFullSize = LayoutAttachments(subTopic, e); Size subSize = CalculateSizes(subTopic, subTopicFullSize, e, vector, layoutInfos); if (first) { fullSize.Height = Math.Max(parent.Size.Height, subSize.Height); first = false; } else { fullSize.Width = Math.Max(fullSize.Width, subSize.Width); fullSize.Height += subSize.Height + e.ItemsSpace; //fullSize.Height += subSize.Height + (int)((parent.IsRoot ? NodeSpaceRoot_V : NodeSpace_V) * args.Zoom); } } fullSize.Width += e.LayerSpace + parent.Size.Width / 2; } layoutInfos[parent] = new TopicLayoutInfo(fullSize); return(fullSize); }
private Rectangle LayoutRoot(Topic topic, MindMapLayoutArgs e) { Hashtable layoutInfos = new Hashtable(); CalculateSizes(topic, layoutInfos, e); if (!layoutInfos.Contains(topic)) { return(Rectangle.Empty); } TopicLayoutInfo tli = (TopicLayoutInfo)layoutInfos[topic]; int y = 0; int x; if (Vector == MindMapLayoutType.LogicLeft) { x = tli.FullSize.Width - e.LayerSpace; } else { x = 0; } LayoutTopic(topic, layoutInfos, x, y, e); return(new Rectangle(0, 0, tli.FullSize.Width, tli.FullSize.Height)); }
void LayoutTopic(Topic topic, Hashtable layoutInfos, int x, int y, MindMapLayoutArgs e) { var tli = (TopicLayoutInfo)layoutInfos[topic]; int foldBtnSize = FoldingButtonSize; int x2; if (Vector == MindMapLayoutType.TreeLeft) { topic.Location = new Point(x - topic.Width, y); topic.FoldingButton = new Rectangle(topic.Right, topic.Top + (int)Math.Round((topic.Height - foldBtnSize) / 2.0f, MidpointRounding.AwayFromZero), foldBtnSize, foldBtnSize); x2 = topic.Left + topic.Width / 2 - e.LayerSpace; } else { topic.Location = new Point(x, y); topic.FoldingButton = new Rectangle(topic.Left - foldBtnSize, topic.Top + (int)Math.Round((topic.Height - foldBtnSize) / 2.0f, MidpointRounding.AwayFromZero), foldBtnSize, foldBtnSize); x2 = topic.Left + topic.Width / 2 + e.LayerSpace; } topic.Lines.Clear(); if (!topic.Children.IsEmpty && !topic.Folded) { y += topic.Height + e.ItemsSpace; foreach (Topic subTopic in topic.Children) { LayoutTopic(subTopic, layoutInfos, x2, y, e); if (layoutInfos.Contains(subTopic)) { TopicLayoutInfo tli2 = (TopicLayoutInfo)layoutInfos[subTopic]; y += tli2.FullSize.Height + e.ItemsSpace; } // line var line = CreateTopicLine(e, topic, subTopic); if (line != null) { topic.Lines.Add(line); } } } }
void CalculateSizes(Topic topic, Hashtable layoutInfos, MindMapLayoutArgs e) { if (topic == null) { return; } topic.Size = CalculateNodeSize(topic, e); var topicFullSize = LayoutAttachments(topic, e); TopicLayoutInfo tlf = new TopicLayoutInfo(); int w = 0; int h = 0; if (!topic.Children.IsEmpty && !topic.Folded) { foreach (Topic subTopic in topic.Children) { CalculateSizes(subTopic, layoutInfos, e); if (layoutInfos.Contains(subTopic)) { TopicLayoutInfo tli = (TopicLayoutInfo)layoutInfos[subTopic]; h += tli.FullSize.Height; w = Math.Max(w, tli.FullSize.Width); } if (subTopic != topic.Children[0]) { h += e.ItemsSpace; } } tlf.ChildrenSize = new Size(w, h); tlf.FullSize = new Size(Math.Max(topicFullSize.Width, w + topicFullSize.Width / 2 + e.LayerSpace), topicFullSize.Height + e.ItemsSpace + h); } else { tlf.FullSize = new Size(topicFullSize.Width, topicFullSize.Height); } //if (!topic.Children.IsEmpty) //tlf.FullSize.Height += FoldingButtonSize; layoutInfos[topic] = tlf; }
void CalculateSizes(Topic topic, Hashtable layoutInfos, MindMapLayoutArgs e) { if (topic == null) { return; } Size size = CalculateNodeSize(topic, e); if (size.Width % 2 == 0) { size = new Size(size.Width + 1, size.Height); } topic.Size = size; var topicFullSize = LayoutAttachments(topic, e); int w = 0; int h = 0; if (!topic.Children.IsEmpty && !topic.Folded) { foreach (var subTopic in topic.Children) { CalculateSizes(subTopic, layoutInfos, e); if (layoutInfos.Contains(subTopic)) { TopicLayoutInfo tli = (TopicLayoutInfo)layoutInfos[subTopic]; w += tli.FullSize.Width; h = Math.Max(h, tli.FullSize.Height); } if (subTopic != topic.Children[0]) { w += e.ItemsSpace; } } } TopicLayoutInfo tlf = new TopicLayoutInfo(); tlf.ChildrenSize = new Size(w, h); tlf.FullSize = new Size(Math.Max(w, topicFullSize.Width), h + topicFullSize.Height + e.LayerSpace); layoutInfos[topic] = tlf; }