Ejemplo n.º 1
0
        private void UpdateParentState(System.Windows.Forms.TreeNode tn)
        {
            if (tn == null)
            {
                return;
            }

            int            OrigStateImageIndex = tn.StateImageIndex;
            CheckedCounter cnt = new CheckedCounter();

            foreach (System.Windows.Forms.TreeNode tnChild in tn.Nodes)
            {
                cnt = cnt + (tnChild.Tag as CheckedCounter);
            }

            if (cnt.Checked == cnt.Total)
            {
                tn.StateImageIndex = (int)CheckedState.Checked;
            }
            else if (cnt.Checked == 0)
            {
                tn.StateImageIndex = (int)CheckedState.UnChecked;
            }
            else
            {
                tn.StateImageIndex = (int)CheckedState.Mixed;
            }

            tn.Tag = cnt;
            UpdateParentState(tn.Parent);
        }
Ejemplo n.º 2
0
 private void UpdateChildState(System.Windows.Forms.TreeNode tn, int value)
 {
     if (tn.Nodes.Count == 0)
     {
         tn.StateImageIndex = value;
         CheckedCounter cnt = tn.Tag as CheckedCounter;
         cnt.Checked = value == (int)CheckedState.Checked ? 1 : 0;
         UpdateParentState(tn.Parent);
     }
     else
     {
         foreach (System.Windows.Forms.TreeNode tnChild in tn.Nodes)
         {
             UpdateChildState(tnChild, value);
         }
     }
 }
Ejemplo n.º 3
0
        private CheckedCounter PrepareNodeCounterOne(System.Windows.Forms.TreeNodeCollection nodes)
        {
            CheckedCounter cnt = new CheckedCounter();

            foreach (System.Windows.Forms.TreeNode node in nodes)
            {
                node.StateImageIndex = (int)CheckedState.UnChecked;
                CheckedCounter tmp;
                if (node.Nodes.Count == 0)
                {
                    tmp = new CheckedCounter(node.StateImageIndex == (int)CheckedState.Checked ? 1 : 0, 1);
                }
                else
                {
                    tmp = PrepareNodeCounterOne(node.Nodes);
                }
                node.Tag = tmp;
                cnt      = cnt + tmp;
            }
            return(cnt);
        }