public void TestInitialConditions() { Assert.AreEqual(0, _objectUnderTest.Children.Count); _factoryMock.Verify(x => x(), Times.Never); TreeLeaf loadingPlaceholder = _objectUnderTest.LoadingPlaceholder; Assert.AreEqual(Resources.CloudExplorerPubSubLoadingTopicsCaption, loadingPlaceholder.Caption); Assert.IsTrue(loadingPlaceholder.IsLoading); Assert.IsFalse(loadingPlaceholder.IsWarning); Assert.IsFalse(loadingPlaceholder.IsError); TreeLeaf noItemsPlaceholder = _objectUnderTest.NoItemsPlaceholder; Assert.AreEqual(Resources.CloudExplorerPubSubNoTopicsFoundCaption, noItemsPlaceholder.Caption); Assert.IsFalse(noItemsPlaceholder.IsLoading); Assert.IsTrue(noItemsPlaceholder.IsWarning); Assert.IsFalse(noItemsPlaceholder.IsError); TreeLeaf errorPlaceholder = _objectUnderTest.ErrorPlaceholder; Assert.AreEqual(Resources.CloudExplorerPubSubListTopicsErrorCaption, errorPlaceholder.Caption); Assert.IsFalse(errorPlaceholder.IsLoading); Assert.IsFalse(errorPlaceholder.IsWarning); Assert.IsTrue(errorPlaceholder.IsError); Assert.AreEqual(Resources.CloudExplorerPubSubRootCaption, _objectUnderTest.RootCaption); }
public void Bind(TreeLeaf leaf) { if (m_LeafList.IndexOf(leaf) == -1) { m_LeafList.Add(leaf); } }
private TreeLeaf CreateOpenedLeaf(GUIContent title) { TreeLeaf leaf = CreateLeaf(title); closedLeafs.Remove(leaf); return(leaf); }
public bool TryCompose(Processor <string> processor, TypedValue instance, ref Tree <string> result) { result = new TreeLeaf <string>(instance.IsVoid ? voidResult : instance.Value == null ? nullResult : instance.Value.ToString()); return(true); }
public void oneNodeHeightTest() { Tree root = new TreeLeaf(); HeightVisitor visitor = new HeightVisitor(); root.Accept(visitor); Assert.AreEqual(0, visitor.height); }
public void CloseLeaf(TreeLeaf leaf) { root.RemoveLeaf(leaf); closedLeafs.Add(leaf); if (onCloseLeaf != null) { onCloseLeaf(leaf); } }
public bool TryCompose(Processor <string> processor, TypedValue instance, ref Tree <string> result) { if (instance.Type != typeof(bool)) { return(false); } result = new TreeLeaf <string>((bool)instance.Value ? "true" : "false"); return(true); }
public void Visit(TreeLeaf leaf) { _currentDepth++; if (_currentDepth > Depth) { Depth = _currentDepth; } _currentDepth--; }
public bool TryCompose(Processor <string> processor, TypedValue instance, ref Tree <string> result) { if (!IsMatch(instance.Type)) { return(false); } result = new TreeLeaf <string>(Compose((T)instance.Value)); return(true); }
static void Main(string[] args) { // Example 1 Tree root = new TreeNode() { Left = new TreeNode() { Left = new TreeLeaf() { Value = 1 }, Right = new TreeLeaf() { Value = 2 }, }, Right = new TreeLeaf() { Value = 3 } }; TreeHeightVisitor visitor = new TreeHeightVisitor(); visitor.Visit(root); Console.WriteLine("Tree 1 height: " + visitor.maxHeight); // Example 2 Tree singleLeaf = new TreeLeaf() { Value = 2 }; TreeHeightVisitor visitor2 = new TreeHeightVisitor(); visitor2.Visit(singleLeaf); Console.WriteLine("Tree 2 height: " + visitor2.maxHeight); // Example 3 Tree singleNode = new TreeNode() { Left = new TreeLeaf() { Value = 2 }, Right = new TreeLeaf() { Value = 3 } }; TreeHeightVisitor visitor3 = new TreeHeightVisitor(); visitor3.Visit(singleNode); Console.WriteLine("Tree 3 height: " + visitor3.maxHeight); }
private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Node.Tag is TreeLeaf item) { _node = e.Node; _currentLeaf = item; titleTextBox.Text = item.Title; descriptionTexBox.Text = item.Description; } }
protected override async Task LoadDataOverrideAsync() { try { Debug.WriteLine("Loading list of services."); GaeApplication = await _dataSource.Value.GetApplicationAsync(); if (GaeApplication == null) { var noAppEngineAppPlaceholder = new TreeLeaf { Caption = Resources.CloudExplorerGaeNoAppFoundCaption, IsError = true, ContextMenu = new ContextMenu { ItemsSource = new List <MenuItem> { new MenuItem { Header = Resources.CloudExplorerGaeSetAppRegionMenuHeader, Command = new ProtectedAsyncCommand(OnSetAppRegionAsync) } } } }; Children.Clear(); Children.Add(noAppEngineAppPlaceholder); return; } IList <ServiceViewModel> services = await LoadServiceListAsync(); Children.Clear(); foreach (var item in services) { Children.Add(item); } if (Children.Count == 0) { Children.Add(s_noItemsPlacehoder); } EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Success)); } catch (DataSourceException ex) { await GcpOutputWindow.Default.OutputLineAsync(Resources.CloudExplorerGaeFailedServicesMessage); await GcpOutputWindow.Default.OutputLineAsync(ex.Message); await GcpOutputWindow.Default.ActivateAsync(); EventsReporterWrapper.ReportEvent(GaeServicesLoadedEvent.Create(CommandStatus.Failure)); throw new CloudExplorerSourceException(ex.Message, ex); } }
private void ReadClosedLeafs(XmlElement root) { for (int i = 0; i < root.ChildNodes.Count; i++) { XmlElement ele = root.ChildNodes[i] as XmlElement; TreeLeaf leaf = CreateLeaf(null); leaf.DeSerialize(ele); DockLeaf(leaf, DockType.Down); CloseLeaf(leaf); } }
public void Broadcast(TreeLeaf fromLeaf, string msg, object content) { for (int i = 0; i < m_LeafList.Count; i++) { TreeLeaf leaf = m_LeafList[i]; if (leaf.IsActive()) { leaf.OnMessage(msg, content); } } }
public void ClearLeafs() { index = 0; closedLeafs.Clear(); for (int i = allLeafs.Count - 1; i >= 0; i--) { TreeLeaf leaf = allLeafs[i]; allLeafs.Remove(leaf); if (onClearLeaf != null) { onClearLeaf(leaf); } } root.Clear(); }
private void DockLeaf(TreeTrunk trunk, TreeLeaf leaf, DockType dockType) { if (!closedLeafs.Contains(leaf)) { Log.E("Err: Have Exist"); } else { trunk.DockLeaf(leaf, dockType); closedLeafs.Remove(leaf); if (onDockLeaf != null) { onDockLeaf(leaf); } } }
public TreeLeaf CreateLeaf(GUIContent title) { if (title == null) { title = new GUIContent("window ".Append((++index).ToString("X3"))); } TreeLeaf leaf = new TreeLeaf(title); if (onCreatLeaf != null) { onCreatLeaf(leaf); } closedLeafs.Add(leaf); allLeafs.Add(leaf); return(leaf); }
static GuideTree <T> GenerateTwoLeafTree(double[,] distanceMatrix, T[] leafDataList) { GuideTree <T> tree = new GuideTree <T>(); TreeNode rootNode = new TreeNode(); TreeLeaf leaf1 = new TreeLeaf(leafDataList[0], tree); TreeLeaf leaf2 = new TreeLeaf(leafDataList[1], tree); double branchLength = 0.5 * distanceMatrix[0, 1]; GuideTree <T> .TreeBranch.Build(rootNode, leaf1, branchLength); GuideTree <T> .TreeBranch.Build(rootNode, leaf2, branchLength); tree.root = rootNode; return(tree); }
public void Add(TreeLeaf item) { list.Add(item); if (First == null && Last == null) { First = item; Last = item; item.Next = null; item.Previous = null; return; } Last.Next = item; item.Previous = Last; Last = item; }
public override void DeSerialize(XmlElement root) { base.DeSerialize(root); DeSerializeField(root, "SplitType", ref splitType); DeSerializeField(root, "SplitWidth", ref splitWidth); XmlNode ts = root.SelectSingleNode("Trunks"); for (int i = 0; i < ts.ChildNodes.Count; i++) { TreeTrunk trunk = new TreeTrunk(); trunk.parent = this; trunk.DeSerialize(ts.ChildNodes[i] as XmlElement); trunks.Add(trunk); } XmlNode ls = root.SelectSingleNode("Leafs"); for (int i = 0; i < ls.ChildNodes.Count; i++) { TreeLeaf leaf = tree.CreateOpenedLeaf(null); leaf.parent = this; leaf.DeSerialize(ls.ChildNodes[i] as XmlElement); leafs.Add(leaf); } }
private void DragWindow() { List <TreeLeaf> OpenLeafs = allLeafs.FindAll((leaf) => { return(!closedLeafs.Contains(leaf)); }); Event e = Event.current; if (e.button != 0) { return; } if (!position.Contains(e.mousePosition)) { return; } if (e.type == EventType.Repaint && dragleaf != null) { Styles.FlowWindow.Draw(new Rect(e.mousePosition, Vector2.one * 150), dragleaf.titleContent, false, false, false, false); Styles.SelectRect.Draw(selectionRect, false, false, false, false); } if (e.type == EventType.MouseDrag) { if (dragleaf == null) { dragleaf = OpenLeafs.Find((leaf) => { return(leaf.IsOverTitle(e.mousePosition)); }); } if (dragleaf == null) { return; } var overLeaf = OpenLeafs.Find((leaf) => { return(leaf.IsOver(e.mousePosition)); }); if (overLeaf == null) { selectionRect = Rect.zero; return; } Vector2 v = e.mousePosition; Rect r = overLeaf.position; float spH = r.height / 3; float spW = r.width / 3; if (v.y < r.yMin + spH && v.x > r.xMin + spW && v.x < r.xMax - spW) { selectionRect = new Rect(r.position, new Vector2(r.width, spH)); docktype = DockType.Up; } else if (v.y > r.yMax - spH && v.x > r.xMin + spW && v.x < r.xMax - spW) { selectionRect = new Rect(new Vector2(r.x, r.yMax - spH), new Vector2(r.width, spH)); docktype = DockType.Down; } else if (v.x > r.xMax - spW && v.y < r.yMax - spH && v.y > r.yMin + spH) { selectionRect = new Rect(new Vector2(r.xMax - spW, r.y), new Vector2(spW, r.height)); docktype = DockType.Right; } else if (v.x < r.xMin + spW && v.y < r.yMax - spH && v.y > r.yMin + spH) { selectionRect = new Rect(r.position, new Vector2(spW, r.height)); docktype = DockType.Left; } else { selectionRect = Rect.zero; } Repaint(); } else if (e.type == EventType.MouseUp) { if (dragleaf != null) { var overLeaf = OpenLeafs.Find((leaf) => { return(leaf.IsOver(e.mousePosition)); }); if (overLeaf != null && selectionRect != Rect.zero && overLeaf != dragleaf) { root.RemoveLeaf(dragleaf); TreeTrunk node = overLeaf.parent as TreeTrunk; node.DockLeaf(overLeaf, dragleaf, docktype); } dragleaf = null; selectionRect = Rect.zero; Repaint(); } } }
public void Visit(TreeLeaf leaf) { if (leaf == this.Target) this.ContainsTarget = true; }
public Data.Mesh3D LightMesh(Data.Mesh3D mesh, OpenTK.Matrix4 world_mat) { Data.Mesh3D res_msh = new Data.Mesh3D(mesh.TriData.Length * 3, mesh.VertexData.Length); Data.Vertex[] verts = mesh.VertexData; Data.Tri[] tris = mesh.TriData; int vi = 0; foreach (Data.Vertex ov in mesh.VertexData) { res_msh.SetVertex(vi, ov.Pos, ov.Tan, ov.BiNorm, ov.Norm, ov.UV); vi++; } res_msh.Transform(world_mat); int ti = 0; foreach (Data.Tri tri in tris) { res_msh.SetTri(ti, tri.V0, tri.V1, tri.v2); ti++; MapVertex lvert = new MapVertex(); lvert.Verts[0] = verts[tri.V0]; lvert.Verts[1] = verts[tri.V1]; lvert.Verts[2] = verts[tri.v2]; MapVertex dvert = new MapVertex(); dvert.Verts[0] = verts[tri.V0]; dvert.Verts[1] = verts[tri.V1]; dvert.Verts[2] = verts[tri.v2]; OpenTK.Vector3 tri_norm = verts[tri.V0].Norm; tri_norm.Normalize(); OpenTK.Vector3 pointonplane = lvert.Verts[0].Pos; int flag = -1; if (Math.Abs(tri_norm.X) > Math.Abs(tri_norm.Y) && Math.Abs(tri_norm.X) > Math.Abs(tri_norm.Z)) { flag = 1; lvert.Verts[0].UV.X = dvert.Verts[0].Pos.Y; lvert.Verts[0].UV.Y = dvert.Verts[0].Pos.Z; lvert.Verts[1].UV.X = dvert.Verts[1].Pos.Y; lvert.Verts[1].UV.Y = dvert.Verts[1].Pos.Z; lvert.Verts[2].UV.X = dvert.Verts[2].Pos.Y; lvert.Verts[2].UV.Y = dvert.Verts[2].Pos.Z; } else if (Math.Abs(tri_norm.Y) > Math.Abs(tri_norm.X) && Math.Abs(tri_norm.Y) > Math.Abs(tri_norm.Z)) { flag = 2; lvert.Verts[0].UV.X = dvert.Verts[0].Pos.X; lvert.Verts[0].UV.Y = dvert.Verts[0].Pos.Z; lvert.Verts[1].UV.X = dvert.Verts[1].Pos.X; lvert.Verts[1].UV.Y = dvert.Verts[1].Pos.Z; lvert.Verts[2].UV.X = dvert.Verts[2].Pos.X; lvert.Verts[2].UV.Y = dvert.Verts[2].Pos.Z; } else { flag = 3; lvert.Verts[0].UV.X = dvert.Verts[0].Pos.X; lvert.Verts[0].UV.Y = dvert.Verts[0].Pos.Y; lvert.Verts[1].UV.X = dvert.Verts[1].Pos.X; lvert.Verts[1].UV.Y = dvert.Verts[1].Pos.Y; lvert.Verts[2].UV.X = dvert.Verts[2].Pos.X; lvert.Verts[2].UV.Y = dvert.Verts[2].Pos.Y; } float min_u = lvert.Verts[0].UV.X; float min_v = lvert.Verts[0].UV.Y; float max_u = lvert.Verts[0].UV.X; float max_v = lvert.Verts[0].UV.Y; for (int i = 0; i < 3; i++) { if (lvert.Verts[i].UV.X < min_u) { min_u = lvert.Verts[i].UV.X; } if (lvert.Verts[i].UV.X < min_v) { min_v = lvert.Verts[i].UV.Y; } if (lvert.Verts[i].UV.X > max_u) { max_u = lvert.Verts[i].UV.X; } if (lvert.Verts[i].UV.Y > max_v) { max_v = lvert.Verts[i].UV.Y; } } float delta_u = max_u - min_u; float delta_v = max_v - min_v; for (int i = 0; i < 3; i++) { lvert.Verts[i].UV.X = lvert.Verts[i].UV.X - min_u; lvert.Verts[i].UV.Y = lvert.Verts[i].UV.Y - min_v; lvert.Verts[i].UV.X = lvert.Verts[i].UV.X / delta_u; lvert.Verts[i].UV.Y = lvert.Verts[i].UV.Y / delta_v; } float dist = (tri_norm.X * pointonplane.X + tri_norm.Y * pointonplane.Y + tri_norm.Z * pointonplane.Z); float X, Y, Z; OpenTK.Vector3 UVVector = OpenTK.Vector3.Zero; OpenTK.Vector3 vec1 = OpenTK.Vector3.Zero, vec2 = OpenTK.Vector3.Zero; switch (flag) { case 1: X = -(tri_norm.Y * min_u + tri_norm.Z * min_v + dist) / tri_norm.X; UVVector.X = X; UVVector.Y = min_u; UVVector.Z = min_v; X = -(tri_norm.Y * max_u + tri_norm.Z * min_v + dist) / tri_norm.X; vec1.X = X; vec1.Y = max_u; vec1.Z = min_v; X = -(tri_norm.Y * min_u + tri_norm.Z * max_v + dist) / tri_norm.X; vec2.X = X; vec2.Y = min_u; vec2.Z = max_v; break; case 2: Y = -(tri_norm.X * min_u + tri_norm.Z * min_v + dist) / tri_norm.Y; UVVector.X = min_u; UVVector.Y = Y; UVVector.Z = min_v; Y = -(tri_norm.X * max_u + tri_norm.Z * min_v + dist) / tri_norm.Y; vec1.X = max_u; vec1.Y = Y; vec1.Z = min_v; Y = -(tri_norm.X * min_u + tri_norm.Z * max_v + dist) / tri_norm.Y; vec2.X = min_u; vec2.Y = Y; vec2.Z = max_v; break; case 3: Z = -(tri_norm.X * min_u + tri_norm.Y * min_v + dist) / tri_norm.Z; UVVector.X = min_u; UVVector.Y = min_v; UVVector.Z = Z; Z = -(tri_norm.X * max_u + tri_norm.Y * min_v + dist) / tri_norm.Z; vec1.X = max_u; vec1.Y = min_v; vec1.Z = Z; Z = -(tri_norm.X * min_u + tri_norm.Y * max_v + dist) / tri_norm.Z; vec2.X = min_u; vec2.Y = max_v; vec2.Z = Z; break; } OpenTK.Vector3 edge1; edge1.X = vec1.X - UVVector.X; edge1.Y = vec1.Y - UVVector.Y; edge1.Z = vec1.Z - UVVector.Z; OpenTK.Vector3 edge2; edge2.X = vec2.X - UVVector.X; edge2.Y = vec2.Y - UVVector.Y; edge2.Z = vec2.Z - UVVector.Z; // Console.WriteLine ( "Grabbing TexLeaf" ); TreeLeaf tex_node = FinalMap.Insert(Tri_W, Tri_H); byte[] rgb = new byte[Tri_W * Tri_H * 3]; OpenTK.Vector3[,] lumels = new OpenTK.Vector3[Tri_W, Tri_H]; for (int iX = 0; iX < Tri_W; iX++) { for (int iY = 0; iY < Tri_H; iY++) { float ufactor = (iX / (float)Tri_W); float vfactor = (iY / (float)Tri_H); OpenTK.Vector3 newedge1; newedge1.X = edge1.X * ufactor; newedge1.Y = edge1.Y * ufactor; newedge1.Z = edge1.Z * ufactor; OpenTK.Vector3 newedge2; newedge2.X = edge2.X * vfactor; newedge2.Y = edge2.Y * vfactor; newedge2.Z = edge2.Z * vfactor; int rloc = (iY * Tri_W * 3) + iX * 3; lumels[iX, iY].X = UVVector.X + newedge2.X + newedge1.X; lumels[iX, iY].Y = UVVector.Y + newedge2.Y + newedge1.Y; lumels[iX, iY].Z = UVVector.Z + newedge2.Z + newedge1.Z; rgb[rloc] = 255; rgb[rloc + 1] = 0; rgb[rloc + 2] = 0; } } for (int cv = 0; cv < 3; cv++) { float lx = ((tex_node.RC.X + 1) + (tex_node.RC.W - 2) * lvert.Verts[cv].UV.X) / tex_node.Root.RC.W; float ly = ((tex_node.RC.Y + 1) + (tex_node.RC.H - 2) * lvert.Verts[cv].UV.Y) / tex_node.Root.RC.H; lvert.Verts[cv].UV.X = lx; lvert.Verts[cv].UV.Y = ly; // Console.WriteLine ( "LX:" + lx + " LY:" + ly ); res_msh.VertexData [ tri.V0 // ].UV = new OpenTK.Vector2 ( lx, ly ); } res_msh.VertexData[tri.V0].UV = lvert.Verts[0].UV; res_msh.VertexData[tri.V1].UV = lvert.Verts[1].UV; res_msh.VertexData[tri.v2].UV = lvert.Verts[2].UV; tex_node.SetRaw(rgb); } res_msh.Material = new Material.Material3D(); res_msh.Final(); return(res_msh); }
public void Remove(TreeLeaf leaf) { m_LeafList.Remove(leaf); }
public int VisitLeaf(TreeLeaf leaf) { return(0); }
public void DockLeaf(TreeLeaf underLeaf, TreeLeaf dockLeaf, DockType dockType) { DockLeaf((underLeaf.parent as TreeTrunk), dockLeaf, dockType); }
public void DockLeaf(TreeLeaf leaf, DockType dockType) { DockLeaf(root, leaf, dockType); }
internal void DockLeaf(TreeLeaf underLeaf, TreeLeaf dockLeaf, DockType dockType) { if (hasChildTrunks) { Log.E("Err Tree"); } else { if (leafCount == 0 || leafCount == 1) { dockLeaf.parent = this; switch (dockType) { case DockType.Down: leafs.Add(dockLeaf); splitType = SplitType.Horizontal; break; case DockType.Up: leafs.Insert(0, dockLeaf); splitType = SplitType.Horizontal; break; case DockType.Left: leafs.Insert(0, dockLeaf); splitType = SplitType.Vertical; break; case DockType.Right: leafs.Add(dockLeaf); splitType = SplitType.Vertical; break; } } else { int index = 0; for (; index < leafCount; index++) { if (leafs[index] == underLeaf) { break; } } if (index == 2) { Log.E("Err Tree"); } else { trunks.Add(new TreeTrunk() { parent = this }); trunks.Add(new TreeTrunk() { parent = this }); TreeLeaf leaf0 = leafs[0]; TreeLeaf leaf1 = leafs[1]; leafs.Clear(); DockType orgDockType = DockType.Down; switch (dockType) { case DockType.Down: orgDockType = DockType.Up; break; case DockType.Up: orgDockType = DockType.Down; break; case DockType.Left: orgDockType = DockType.Right; break; case DockType.Right: orgDockType = DockType.Left; break; } if (index == 0) { trunks[0].DockLeaf(leaf0, orgDockType); trunks[0].DockLeaf(dockLeaf, dockType); trunks[1].DockLeaf(leaf1, orgDockType); } else { trunks[0].DockLeaf(leaf0, orgDockType); trunks[1].DockLeaf(dockLeaf, dockType); trunks[1].DockLeaf(leaf1, orgDockType); } } } } }
internal void DockLeaf(TreeLeaf leaf, DockType dockType) { if (hasChildTrunks) { trunks[0].DockLeaf(leaf, dockType); } else if (!hasChildTrunks) { if (leafCount == 0 || leafCount == 1) { leaf.parent = this; switch (dockType) { case DockType.Down: leafs.Add(leaf); splitType = SplitType.Horizontal; break; case DockType.Up: leafs.Insert(0, leaf); splitType = SplitType.Horizontal; break; case DockType.Left: leafs.Insert(0, leaf); splitType = SplitType.Vertical; break; case DockType.Right: leafs.Add(leaf); splitType = SplitType.Vertical; break; } } else { trunks.Add(new TreeTrunk() { parent = this }); trunks.Add(new TreeTrunk() { parent = this }); TreeLeaf leaf0 = leafs[0]; TreeLeaf leaf1 = leafs[1]; leafs.Clear(); switch (dockType) { case DockType.Down: case DockType.Up: splitType = SplitType.Horizontal; break; case DockType.Left: case DockType.Right: splitType = SplitType.Vertical; break; } switch (splitType) { case SplitType.Vertical: trunks[0].DockLeaf(leaf0, DockType.Left); trunks[1].DockLeaf(leaf1, DockType.Right); break; case SplitType.Horizontal: trunks[0].DockLeaf(leaf0, DockType.Up); trunks[1].DockLeaf(leaf1, DockType.Down); break; } trunks[0].DockLeaf(leaf, dockType); } } }
private bool IsLeafOpen(TreeLeaf leaf) { return(!closedLeafs.Contains(leaf) && allLeafs.Contains(leaf)); }
internal bool RemoveLeaf(TreeLeaf leaf) { if (hasChildTrunks) { if (trunks[0].RemoveLeaf(leaf)) { return(true); } return(trunks[1].RemoveLeaf(leaf)); } else { if (!leafs.Contains(leaf)) { return(false); } leafs.Remove(leaf); leaf.parent = null; if (leafCount == 1) { if (!isRoot) { int index = 0; TreeTrunk brother = default(TreeTrunk); for (; index < parentTrunk.trunkCount; index++) { if (parentTrunk.trunks[index] != this) { brother = parentTrunk.trunks[index]; break; } } if (brother != null && !brother.hasChildTrunks && brother.leafCount == 1) { parentTrunk.trunks.Clear(); switch (parentTrunk.splitType) { case SplitType.Vertical: if (index == 0) { parentTrunk.DockLeaf(brother.leafs[0], DockType.Left); parentTrunk.DockLeaf(leafs[0], DockType.Right); } else { parentTrunk.DockLeaf(brother.leafs[0], DockType.Right); parentTrunk.DockLeaf(leafs[0], DockType.Left); } break; case SplitType.Horizontal: if (index == 0) { parentTrunk.DockLeaf(brother.leafs[0], DockType.Up); parentTrunk.DockLeaf(leafs[0], DockType.Down); } else { parentTrunk.DockLeaf(brother.leafs[0], DockType.Down); parentTrunk.DockLeaf(leafs[0], DockType.Up); } break; } } } } else if (leafCount == 0) { if (!isRoot) { TreeTrunk brother = default(TreeTrunk); for (int i = 0; i < parentTrunk.trunkCount; i++) { if (parentTrunk.trunks[i] != this) { brother = parentTrunk.trunks[i]; } } parentTrunk.trunks.Clear(); if (brother != null) { if (brother.hasChildTrunks) { parentTrunk.splitType = brother.splitType; for (int i = 0; i < brother.trunkCount; i++) { brother.trunks[i].parent = parentTrunk; parentTrunk.trunks.Add(brother.trunks[i]); } } else { for (int i = 0; i < brother.leafCount; i++) { TreeLeaf tmpLeaf = brother.leafs[i]; tmpLeaf.parent = null; switch (brother.splitType) { case SplitType.Vertical: if (i == 0) { parentTrunk.DockLeaf(tmpLeaf, DockType.Left); } else if (i == 1) { parentTrunk.DockLeaf(tmpLeaf, DockType.Right); } break; case SplitType.Horizontal: if (i == 0) { parentTrunk.DockLeaf(tmpLeaf, DockType.Up); } else if (i == 1) { parentTrunk.DockLeaf(tmpLeaf, DockType.Down); } break; } } } } } //parent = null; } return(true); } }