Esempio n. 1
0
        private void FillKeywordTree()
        {
            this.treeKeywords.Nodes.Clear();

            ThreeStateTreeNode defaultNode    = null;
            List <string>      neededKeywords = new List <string>();

            foreach (string s in model.KeywordsChecked)
            {
                neededKeywords.Add(s);
            }
            foreach (string s in model.KeywordsUnchecked)
            {
                neededKeywords.Add(s);
            }

            // alle keywords aus den settings in den baum schreiben
            foreach (string g in Settings.Default.GroupedKeywords.GetGroups())
            {
                ThreeStateTreeNode n = new ThreeStateTreeNode(g);
                n.HasCheckBox = false;
                foreach (string v in Settings.Default.GroupedKeywords.GetValues(g))
                {
                    n.Nodes.Add(newNode(v));

                    if (neededKeywords.Contains(v))
                    {
                        neededKeywords.Remove(v);
                    }
                }
                this.treeKeywords.Nodes.Add(n);
                if (keywordTreeHelper.ExpandNode(n.Text))
                {
                    n.Expand();
                }

                if (g == GroupedTagList.DEFAULT_GROUP)
                {
                    defaultNode = n;
                }
            }

            // keywords die im file sind, aber nicht in den settings in die default grouo schreiben
            if (neededKeywords.Count != 0)
            {
                if (defaultNode == null)
                {
                    defaultNode             = new ThreeStateTreeNode(GroupedTagList.DEFAULT_GROUP);
                    defaultNode.HasCheckBox = false;
                    this.treeKeywords.Nodes.Add(defaultNode);
                }
                foreach (string s in neededKeywords)
                {
                    defaultNode.Nodes.Add(newNode(s));
                }

                if (keywordTreeHelper.ExpandNode(defaultNode.Text))
                {
                    defaultNode.Expand();
                }
            }

            this.treeKeywords.UpdateSelectAllCheckBox();

            if (this.treeKeywords.Nodes.Count > 0)
            {
                this.treeKeywords.Nodes[0].EnsureVisible();
            }

            if (Settings.Default.CollapseIptcKeywordGroupsOnStartup)
            {
                treeKeywords.CollapseAll();
            }
        }
Esempio n. 2
0
        // view
        private void FillKeywordTree(bool fromFile)
        {
            this.treeKeywords.Nodes.Clear();

            ThreeStateTreeNode defaultNode = null;
            List <string>      keywords    = new List <string>();

            // alle keywords der Datei auslesen
            if (fromFile)
            {
                foreach (string s in currentPicture.ListKeyword())
                {
                    keywords.Add(s);
                }
            }

            // alle keywords aus den settings in den baum schreiben
            foreach (string g in Settings.Default.GroupedKeywords.GetGroups())
            {
                ThreeStateTreeNode n = new ThreeStateTreeNode(g);
                n.HasCheckBox = false;
                foreach (string v in Settings.Default.GroupedKeywords.GetValues(g))
                {
                    // wenn dieses keyword auch im file -> selektieren
                    if (fromFile && keywords.Contains(v))
                    {
                        ThreeStateTreeNode x = new ThreeStateTreeNode(v, true);
                        x.Bold          = true;
                        x.ShowPlusMinus = false;
                        n.Nodes.Add(x);
                        keywords.Remove(v);
                    }
                    else  // -> nicht selektieren
                    {
                        ThreeStateTreeNode x = new ThreeStateTreeNode(v);
                        x.CheckState    = CheckState.Indeterminate;
                        x.ShowPlusMinus = false;
                        n.Nodes.Add(x);
                    }
                }
                this.treeKeywords.Nodes.Add(n);
                if (keywordTreeHelper.ExpandNode(n.Text))
                {
                    n.Expand();
                }

                if (g == GroupedTagList.DEFAULT_GROUP)
                {
                    defaultNode = n;
                }
            }

            // keywords die im file sind, aber nicht in den settings in die default grouo schreiben
            if (fromFile && keywords.Count != 0)
            {
                if (defaultNode == null)
                {
                    defaultNode             = new ThreeStateTreeNode(GroupedTagList.DEFAULT_GROUP);
                    defaultNode.HasCheckBox = false;
                    this.treeKeywords.Nodes.Add(defaultNode);
                }
                foreach (string s in keywords)
                {
                    ThreeStateTreeNode x = new ThreeStateTreeNode(s, true);
                    x.Bold          = true;
                    x.ShowPlusMinus = false;
                    defaultNode.Nodes.Add(x);
                }
                if (keywordTreeHelper.ExpandNode(defaultNode.Text))
                {
                    defaultNode.Expand();
                }
            }

            this.treeKeywords.UpdateSelectAllCheckBox();

            if (this.treeKeywords.Nodes.Count > 0)
            {
                this.treeKeywords.Nodes[0].EnsureVisible();
            }
        }