XList <int> CalculateRow(Topic parent, Topic[] children, MindMapLayoutArgs e) { XList <int> listHeight = new XList <int>(); if (!parent.IsRoot) { parent.TextSize = CalculateTextSize(parent, e); listHeight.Add(parent.ContentBounds.Height); } XList <int> prevSubListHeight = new XList <int>(); bool isIncrease = parent.IsRoot || parent.Type == TopicType.Barrier; int i = isIncrease ? 0 : children.Length - 1; while (i > -1 && i < children.Length) { Topic subTopic = children[i]; XList <int> subListHeight = CalculateRow(subTopic, e); if (subTopic.Type == TopicType.Barrier && prevSubListHeight.Count > 1) { prevSubListHeight.RemoveAt(0); if (subListHeight.IsEmpty) { subListHeight.AddRange(prevSubListHeight); } else { XList <int> savedList = subListHeight; subListHeight = new XList <int>(); subListHeight.Add(savedList[0]); subListHeight.AddRange(prevSubListHeight); savedList.RemoveAt(0); subListHeight.AddRange(savedList); } } if (parent.Type == TopicType.Barrier || parent.IsRoot) { // Append row listHeight.AddRange(subListHeight); } else { // Merge rows for (int k = 0, n = listHeight.Count; k < n; ++k) { if (k < subListHeight.Count) { listHeight[k] = Math.Max(subListHeight[k], listHeight[k]); } else { break; } } if (listHeight.Count < subListHeight.Count) { for (int k = listHeight.Count, n = subListHeight.Count; k < n; ++k) { listHeight.Add(subListHeight[k]); } } } prevSubListHeight = subListHeight; if (isIncrease) { ++i; } else { --i; } } return(listHeight); }
public void RemoveFirst() { content.RemoveAt(0); XList.RemoveAt(0); YList.RemoveAt(0); }