private void DrawComponentTree(Object o, TreeNode tnControl) { TreeNode tnSubtreeRoot; Button btn = new Button(); btn.Content = o.GetType().Name; if (tnControl == null) { tnSubtreeRoot = tcMain.AddRoot(btn); } else { tnSubtreeRoot = tcMain.AddNode(btn, tnControl); } DependencyObject dob = o as DependencyObject; if (dob != null) { if (fUseLogicalTree) { foreach (object objChild in LogicalTreeHelper.GetChildren(dob)) { DrawComponentTree(objChild, tnSubtreeRoot); } } else { for (int iChild = 0; iChild < VisualTreeHelper.GetChildrenCount(dob); iChild++) { DrawComponentTree(VisualTreeHelper.GetChild(dob, iChild), tnSubtreeRoot); } } } }
private void SetCtlInfo(object o, TreeNode tnControl) { Button btn = new Button(); string strContent = o.GetType().Name; btn.Content = strContent; tnControl.Content = btn; string name = strContent + (nSerial++).ToString(); tnControl.Name = name; }
private void DrawLogicalTree() { TreeNode tnRoot = new TreeNode(); tnRoot.Name = "Root"; TreeContainer.TreeContainer.SetRoot(tcMain, "Root"); tcMain.Children.Clear(); tcMain.Children.Add(tnRoot); DrawLogicalTree(spnlDialog, tnRoot); }
private void DrawLogicalTree(Object o, TreeNode tnControl) { SetCtlInfo(o, tnControl); foreach (object objChild in LogicalTreeHelper.GetChildren(o as DependencyObject)) { TreeNode tnNew = new TreeNode(); SetCtlInfo(objChild, tnNew); tnControl.TreeChildren.Add(tnNew); tcMain.Children.Add(tnNew); } }
private void RefreshGraph(Node <string> Root, TreeContainer.TreeNode Parent) { TreeContainer.TreeNode SubTree; if (Parent == null) { SubTree = Tree.AddRoot(Root.Name); } else { SubTree = Tree.AddNode(Root.Name, Parent); } foreach (var Child in Root.Children) { RefreshGraph(Child, SubTree); } }
public static TreeNode GetParentElement(TreeNode tn) { TreeContainer tc; TreeNode tnParent; if (tn == null) { return null; } tc = tn.Parent as TreeContainer; if (tc == null) { return null; } string strParent = tn.TreeParent; if (strParent == null) { return null; } tnParent = tc.FindName(strParent) as TreeNode; if (tnParent == null) { return null; } return tnParent; }
private void SetParents(TreeNode tnRoot) { // First pass to clear all parents foreach (UIElement uiel in InternalChildren) { TreeNode tn = uiel as TreeNode; if (tn != null) { tn.ClearParent(); } } // Second pass to properly set them from their children... foreach (UIElement uiel in InternalChildren) { TreeNode tn = uiel as TreeNode; if (tn != null && tn != tnRoot) { tn.SetParent(); } } }
private void SetName(TreeNode tn, string strName) { tn.Name = strName; RegisterName(strName, tn); }
public TreeNode AddRoot(Object objContent, string strName) { TreeNode tnNew = new TreeNode(); SetName(tnNew, strName); tnNew.Content = objContent; Children.Add(tnNew); Root = strName; return tnNew; }
public TreeNode AddNode(Object objContent, TreeNode tnParent) { return AddNode(objContent, StrNextName(), tnParent.Name); }
public TreeNode AddNode(Object objContent, string strName, TreeNode tnParent) { return AddNode(objContent, strName, tnParent.Name); }
public TreeNode AddNode(Object objContent, string strName, string strParent) { TreeNode tnNew = new TreeNode(); SetName(tnNew, strName); tnNew.Content = objContent; tnNew.TreeParent = strParent; Children.Add(tnNew); return tnNew; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Tree = ((TreeContainer.TreeContainer)(target)); return; case 2: this.O = ((TreeContainer.TreeNode)(target)); return; case 3: this.E = ((TreeContainer.TreeNode)(target)); return; case 4: this.F = ((TreeContainer.TreeNode)(target)); return; case 5: this.N = ((TreeContainer.TreeNode)(target)); return; case 6: this.A = ((TreeContainer.TreeNode)(target)); return; case 7: this.D = ((TreeContainer.TreeNode)(target)); return; case 8: this.B = ((TreeContainer.TreeNode)(target)); return; case 9: this.C = ((TreeContainer.TreeNode)(target)); return; case 10: this.G = ((TreeContainer.TreeNode)(target)); return; case 11: this.M = ((TreeContainer.TreeNode)(target)); return; case 12: this.H = ((TreeContainer.TreeNode)(target)); return; case 13: this.I = ((TreeContainer.TreeNode)(target)); return; case 14: this.J = ((TreeContainer.TreeNode)(target)); return; case 15: this.K = ((TreeContainer.TreeNode)(target)); return; case 16: this.L = ((TreeContainer.TreeNode)(target)); return; } this._contentLoaded = true; }
private void Delete_Node(TreeNode node) { List<TreeNode> nodesToRemove = new List<TreeNode>(); List<DialogEntry> dialogToRemove = new List<DialogEntry>(); TreeNode mainNode = node; NodeControl nodeControl = mainNode.Content as NodeControl; mainNode = tcMain.FindName(currentNode.Remove(0, 1)) as TreeNode; nodesToRemove.Add(mainNode); dialogToRemove.Add(projie.Assets.Conversations[loadedConversation].DialogEntries.First(p => p.ID == (int)nodeControl.lblID.Content)); foreach (TreeNode subnode in tcMain.Children.OfType<TreeNode>().Where(p => p.TreeParent == currentNode.Remove(0, 1))) { nodeControl = subnode.Content as NodeControl; nodesToRemove.Add(subnode); dialogToRemove.Add(projie.Assets.Conversations[loadedConversation].DialogEntries.First(p => p.ID == (int)nodeControl.lblID.Content)); } history.Do("remove", nodesToRemove, dialogToRemove); foreach (TreeNode subnode in nodesToRemove) { nodeControl = subnode.Content as NodeControl; projie.Assets.Conversations[loadedConversation].DialogEntries.Remove(projie.Assets.Conversations[loadedConversation].DialogEntries.First(p => p.ID == (int)nodeControl.lblID.Content)); tcMain.Children.Remove(subnode); tcMain.UnregisterName(subnode.Name); } }
private void PrintTree(DecisionNode tree, TreeNode tnControl = null) { TreeNode tnSubtreeRoot; Label label = new Label(); label.BorderBrush = Brushes.White; label.BorderThickness = new Thickness(0.5); label.Foreground = Brushes.Orange; // Is this a leaf node? if (tree.Results != null) { StringBuilder str = new StringBuilder(); foreach (var res in tree.Results) { str.Append("{"+Result+": '" + res.Key + "'}"); } label.Content = str.ToString(); label.Foreground = Brushes.YellowGreen; if(tnControl == null) { tnSubtreeRoot = tcMain.AddRoot(label); } else { tnSubtreeRoot = tcMain.AddNode(label, tnControl); } } else { string name = Headers[tree.Column] + " : " + tree.Value + " ?"; label.Content = name; if(tnControl == null) { tnSubtreeRoot = tcMain.AddRoot(label); } else { tnSubtreeRoot = tcMain.AddNode(label, tnControl); } PrintTree(tree.NextFalseNode, tnSubtreeRoot); PrintTree(tree.NextTrueNode, tnSubtreeRoot); } }