internal void SetParent(GroupNode parent) { // Make sure we don't create a loop in the heirarchy structure. IDiagramPositionable node = parent; while (node != null) { if (node == this) { return; } node = node.Parent; } if (this.ParentNode != parent) { // Detach event handlers. if (this.ParentNode != null) { this.ParentNode.BoundsChanged -= new EventHandler(Parent_BoundsChanged); GroupNode group = this.ParentNode as GroupNode; if (group != null) { group.IsExpandedChanged -= new EventHandler(Group_IsExpandedChanged); group.IsVisibleChanged -= new EventHandler(Group_IsVisibleChanged); } } this.ParentNode = parent; // Set the parent. // Attach event handlers. if (this.ParentNode != null) { this.ParentNode.BoundsChanged += new EventHandler(Parent_BoundsChanged); GroupNode group = this.ParentNode as GroupNode; if (group != null) { group.IsExpandedChanged += new EventHandler(Group_IsExpandedChanged); group.IsVisibleChanged += new EventHandler(Group_IsVisibleChanged); } } } this.ParentNode.AddChild(this); }
private void Group_IsExpandedChanged(object sender, EventArgs e) { GroupNode group = sender as GroupNode; IsVisible = group.IsVisible && group.IsExpanded; }