void _viewer_OnObjectSelected() { if (_makingChanges) { return; //we're doing it, so do nothing } //get selected node Separator currentlySelectedSeparator = _viewer.getSeparatorForSelection(); if (currentlySelectedSeparator == null) { return; //shouldn't be, but lets double check. } TreeNode selectedTreeNode = findTreeNodeContainingCoinNode(currentlySelectedSeparator); if (selectedTreeNode != null) { _makingChanges = true; treeViewScene.SelectedNode = selectedTreeNode; _makingChanges = false; } }
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); }