private void deleteCurrentlySelectedNode() { if (treeViewScene.SelectedNode == null) { return; } TreeNode current = treeViewScene.SelectedNode; TreeNode parrent = current.Parent; if (parrent == null) { //tried to delete the _root node, yell at the user string msg = "You can not delete the Root node!"; MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (!checkUserConfirmsFirstDelete()) { return; //check if we are allowed to delete } //green light, lets find the parent and delete it :) ScenegraphNode currentNode = (ScenegraphNode)current.Tag; ScenegraphNode parrentNode = (ScenegraphNode)parrent.Tag; Separator parrentSeparator = parrentNode.ToSeparator(); parrentSeparator.removeChild(currentNode); //remove node from scene graph and make its parrent selected parrent.Nodes.Remove(current); treeViewScene.SelectedNode = parrent; }
private TreeNode buildTree(ScenegraphNode node, Separator initiallySelectedNodeToFind) { TreeNode tNode = new TreeNode(); tNode.Tag = node; //check for this being the currently selected node... if (node.isEqualSeparator(initiallySelectedNodeToFind)) { _initiallySelected = tNode; } string formatedName = node.Name.Length == 0 ? node.TypeName : String.Format("{0} ({1})", node.TypeName, node.Name); tNode.Text = formatedName; ScenegraphNode[] children = node.getChildren(); foreach (ScenegraphNode child in children) { tNode.Nodes.Add(buildTree(child, initiallySelectedNodeToFind)); } return(tNode); }
private TreeNode findTreeNodeContainingCoinNodeHelper(Separator nodeToSearchFor, TreeNode searchBase) { ScenegraphNode baseNode = (ScenegraphNode)searchBase.Tag; if (baseNode.isEqualSeparator(nodeToSearchFor)) { return(searchBase); } foreach (TreeNode child in searchBase.Nodes) { TreeNode subSearchResult = findTreeNodeContainingCoinNodeHelper(nodeToSearchFor, child); if (subSearchResult != null) { return(subSearchResult); } } //no luck return(null); }
private bool _makingChanges = false; //prevents looping on ourselves public ScenegraphTreeViewer(ExaminerViewer viewer, Separator root) { InitializeComponent(); this.Text = Application.ProductName; _viewer = viewer; _root = root; _rootScenegraph = new ScenegraphNode(_root); //get the currently selected node. Separator initiallySelectedSeparator = _viewer.getSeparatorForSelection(); treeViewScene.Nodes.Add(buildTree(_rootScenegraph, initiallySelectedSeparator)); if (_initiallySelected != null) { treeViewScene.SelectedNode = _initiallySelected; } //setup listener _viewer.OnNewSceneGraphLoaded += new NewSceneGraphLoadedHandler(_viewer_OnNewSceneGraphLoaded); _viewer.OnObjectSelected += new ObjectSelectedHandler(_viewer_OnObjectSelected); }