private void node_CheckStateChanged(object sender, EventArgs e) { Node node = (Node)sender; // for leaf nodes, update the underlying item AuthorityTokenTableEntry token = (AuthorityTokenTableEntry)node.Tag; bool nodeChecked = node.CheckState == CheckState.Checked; if (token != null && token.Selected != nodeChecked) { token.Selected = nodeChecked; } // check if this event should be ignored because it was not generated by a user action if (IgnoreCheckStateEventsScope.Ignore) { return; } if (node.CheckState == CheckState.Mixed) { // don't allow the user to set the state to mixed - force it to unchecked node.CheckState = CheckState.Unchecked; } else { // otherwise, update child and parent nodes appropriately using (new IgnoreCheckStateEventsScope()) { PropagateCheckStateDown(node); if (node.Parent != null) { PropagateCheckStateUp(node.Parent); } } } }
private void InsertToken(NodeCollection nodeCollection, AuthorityTokenTableEntry token, int depth) { // check if a node for this path segment already exists in the tree PathSegment segment = token.Path.Segments[depth]; Node node = CollectionUtils.SelectFirst <Node>(nodeCollection, delegate(Node n) { return(n.Text == segment.LocalizedText); }); // if not, create the node if (node == null) { node = new Node(segment.LocalizedText); node.CheckStateChanged += new EventHandler(node_CheckStateChanged); nodeCollection.Add(node); } // if this is a leaf node, set the properties of the tree node accordingly if (segment == token.Path.LastSegment) { node.Tag = token; node.Tooltip = token.Description; node.CheckState = token.Selected ? CheckState.Checked : CheckState.Unchecked; // addition of this leaf may need to alter the check state of the parent if (node.Parent != null) { PropagateCheckStateUp(node.Parent); } } else { // otherwise, recur until we hit the leaf InsertToken(node.Nodes, token, depth + 1); } }
private void InsertToken(NodeCollection nodeCollection, AuthorityTokenTableEntry token, int depth) { // check if a node for this path segment already exists in the tree PathSegment segment = token.Path.Segments[depth]; Node node = CollectionUtils.SelectFirst<Node>(nodeCollection, delegate(Node n) { return n.Text == segment.LocalizedText; }); // if not, create the node if(node == null) { node = new Node(segment.LocalizedText); node.CheckStateChanged += new EventHandler(node_CheckStateChanged); nodeCollection.Add(node); } // if this is a leaf node, set the properties of the tree node accordingly if (segment == token.Path.LastSegment) { node.Tag = token; node.Tooltip = token.Description; node.CheckState = token.Selected ? CheckState.Checked : CheckState.Unchecked; // addition of this leaf may need to alter the check state of the parent if (node.Parent != null) { PropagateCheckStateUp(node.Parent); } } else { // otherwise, recur until we hit the leaf InsertToken(node.Nodes, token, depth + 1); } }