Beispiel #1
0
        public static void BuildScoreList(ThreeStateTreeView tree, ScoreCenter center, bool show)
        {
            tree.Nodes.Clear();
            if (center == null || center.Scores.Items == null)
            {
                return;
            }

            tree.BeginUpdate();
            Dictionary <string, ThreeStateTreeNode> nodes = new Dictionary <string, ThreeStateTreeNode>(center.Scores.Items.Count());

            foreach (BaseScore sc in center.Scores.Items)
            {
                ThreeStateTreeNode node = new ThreeStateTreeNode(sc.Name);
                node.Tag = sc;
                nodes.Add(sc.Id, node);
                if (!sc.IsFolder() && sc.enable && show)
                {
                    node.Checked = true;
                    node.State   = CheckBoxState.Checked;
                }
            }

            foreach (KeyValuePair <string, ThreeStateTreeNode> pair in nodes)
            {
                ThreeStateTreeNode node = pair.Value;
                BaseScore          sc   = node.Tag as BaseScore;
                if (String.IsNullOrEmpty(sc.Parent))
                {
                    tree.Nodes.Add(node);
                }
                else
                {
                    if (nodes.ContainsKey(sc.Parent))
                    {
                        nodes[sc.Parent].Nodes.Add(node);
                    }
                }
            }

            RefreshTreeState(tree.Nodes);
            tree.EndUpdate();
            tree.Sort();
        }
        /// <summary>
        /// Manages updating related child and parent nodes of this instance.
        /// </summary>
        public void UpdateStateOfRelatedNodes()
        {
            ThreeStateTreeView tv = this.TreeView as ThreeStateTreeView;

            if ((tv != null) && tv.CheckBoxes && tv.UseThreeStateCheckBoxes)
            {
                tv.BeginUpdate();

                // If want to cascade checkbox state changes to child nodes of this node and
                // if the current state is not intermediate, update the state of child nodes.
                if (this.State != CheckBoxState.Indeterminate)
                {
                    this.UpdateChildNodeState();
                }

                this.UpdateParentNodeState(true);

                tv.EndUpdate();
            }
        }