예제 #1
0
        public void SetCheckState(TristateTreeNodeState state, bool bubbleToChildren, bool bubbleToParent)
        {
            bool disabled = (this.checkboxState & TristateTreeNodeState.Disabled) > 0;
            TristateTreeNodeState flags = disabled ? TristateTreeNodeState.Disabled : TristateTreeNodeState.Empty;

            flags |= state;
            this.checkboxState = flags;

            if (bubbleToChildren)
            {
                ModifyChildState();
            }

            //Update parent
            if (this.parent is TristateTreeNode && bubbleToParent)
            {
                ((TristateTreeNode)this.parent).UpdateCheckState(false, true);
            }

            if (this.nodeType == TristateTreeNodeType.RadioChild && state == TristateTreeNodeState.Checked)
            {
                //iterate through parent and set everyone else to off
                if (this.parent is TristateTreeNode)
                {
                    foreach (TristateTreeNode neighbor in ((TristateTreeNode)this.parent).nodes.ToList())
                    {
                        if (neighbor != this)
                        {
                            neighbor.SetCheckState(TristateTreeNodeState.Unchecked, true, false);
                        }
                    }
                }
                else
                {
                    foreach (TristateTreeNode neighbor in ((TristateTreeView)this.parent).Nodes.ToList())
                    {
                        if (neighbor != this)
                        {
                            neighbor.SetCheckState(TristateTreeNodeState.Unchecked, true, false);
                        }
                    }
                }
                this.checkboxState = TristateTreeNodeState.Checked;
            }
        }
예제 #2
0
        public void UpdateCheckState(bool bubbleToChildren, bool bubbleToParent)
        {
            if (this.nodes.Count == 0)
            {
                return;
            }
            bool allChecked = true;
            bool allEmpty   = true;

            for (int i = 0; i < this.nodes.Count; i++)
            {
                TristateTreeNodeState state = this.nodes[i].CheckState;
                if (state == TristateTreeNodeState.Checked)
                {
                    allEmpty = false;
                }
                else if (state == TristateTreeNodeState.Unchecked)
                {
                    allChecked = false;
                }
                else //partial
                {
                    allEmpty   = false;
                    allChecked = false;
                }
            }
            if (allChecked)
            {
                SetCheckState(TristateTreeNodeState.Checked, bubbleToChildren, bubbleToParent);
            }
            else if (allEmpty)
            {
                SetCheckState(TristateTreeNodeState.Unchecked, bubbleToChildren, bubbleToParent);
            }
            else
            {
                SetCheckState(TristateTreeNodeState.Partial, bubbleToChildren, bubbleToParent);
            }
        }
예제 #3
0
        public void SetCheckState(TristateTreeNodeState state, bool bubbleToChildren, bool bubbleToParent)
        {
            bool disabled = (this.checkboxState & TristateTreeNodeState.Disabled) > 0;
            TristateTreeNodeState flags = disabled ? TristateTreeNodeState.Disabled : TristateTreeNodeState.Empty;
            flags |= state;
            this.checkboxState = flags;

            if(bubbleToChildren)
                ModifyChildState();

            //Update parent
            if (this.parent is TristateTreeNode && bubbleToParent)
                ((TristateTreeNode)this.parent).UpdateCheckState(false, true);

            if (this.nodeType == TristateTreeNodeType.RadioChild && state == TristateTreeNodeState.Checked)
            {
                //iterate through parent and set everyone else to off
                if (this.parent is TristateTreeNode)
                    foreach (TristateTreeNode neighbor in ((TristateTreeNode)this.parent).nodes.ToList())
                    {
                        if (neighbor != this)
                            neighbor.SetCheckState(TristateTreeNodeState.Unchecked, true, false);
                    }
                else
                    foreach (TristateTreeNode neighbor in ((TristateTreeView)this.parent).Nodes.ToList())
                    {
                        if (neighbor != this)
                            neighbor.SetCheckState(TristateTreeNodeState.Unchecked, true, false);
                    }
                this.checkboxState = TristateTreeNodeState.Checked;
            }
        }