Example #1
0
        public void AddCategory()
        {
            Expand();
            ConfigCategory cat      = new ConfigCategory();
            int            n        = 1;
            string         nameBase = "Category";

            cat.CategoryName = nameBase + n.ToString();
            bool b = true;

            while (b)
            {
                b = false;
                for (int i = 0; i < Nodes.Count; i++)
                {
                    TreeNodeCategory cn = Nodes[i] as TreeNodeCategory;
                    if (cn != null)
                    {
                        ConfigCategory c = cn.Category;
                        if (string.Compare(cat.CategoryName, c.CategoryName, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            n++;
                            cat.CategoryName = nameBase + n.ToString();
                            b = true;
                        }
                    }
                }
            }
            TreeNodeCategory tc = new TreeNodeCategory(cat, false);

            Nodes.Add(tc);
            this.Expand();
            this.TreeView.SelectedNode = tc;
        }
Example #2
0
        private void nameChanging(object sender, EventArgs e)
        {
            TreeNode            changedNode = null;
            EventArgvNameChange en          = (EventArgvNameChange)e;
            TreeNodeCategory    tc          = (TreeNodeCategory)Parent;

            for (int i = 0; i < tc.Nodes.Count; i++)
            {
                TreeNodeConfigProperty tp = tc.Nodes[i] as TreeNodeConfigProperty;
                if (tp != null)
                {
                    if (string.CompareOrdinal(en.OldName, tp.Property.DataName) != 0)
                    {
                        if (string.CompareOrdinal(en.NewName, tp.Property.DataName) == 0)
                        {
                            MessageBox.Show(this.TreeView.FindForm(), "The name is in use", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            en.Cancel = true;
                            break;
                        }
                    }
                    else
                    {
                        changedNode = tc.Nodes[i];
                    }
                }
            }
            if (!en.Cancel)
            {
                if (changedNode != null)
                {
                    changedNode.Text = en.NewName;
                }
            }
        }
Example #3
0
        private void toolStripButtonDelCat_Click(object sender, EventArgs e)
        {
            TreeNodeCategory tc = treeView1.SelectedNode as TreeNodeCategory;

            if (tc != null)
            {
                tc.Delete();
            }
        }
Example #4
0
            public override void LoadNextLevel(TreeNodeCat parent)
            {
                TreeNodeCategory tc = (TreeNodeCategory)parent;

                foreach (ConfigProperty p in tc._cat.Properties.Properties)
                {
                    TreeNodeConfigProperty tp = new TreeNodeConfigProperty(p, parent.IsDataOnly);
                    parent.Nodes.Add(tp);
                }
            }
Example #5
0
            public override void LoadNextLevel(TreeNodeCat parent)
            {
                TreeNodeAppConfig ta = (TreeNodeAppConfig)parent;

                foreach (ConfigCategory cat in ta._list.Categories)
                {
                    TreeNodeCategory tc = new TreeNodeCategory(cat, parent.IsDataOnly);
                    parent.Nodes.Add(tc);
                }
            }
Example #6
0
        private void toolStripButtonAddProperty_Click(object sender, EventArgs e)
        {
            TreeNodeCategory tc = treeView1.SelectedNode as TreeNodeCategory;

            if (tc == null)
            {
                if (treeView1.SelectedNode != null)
                {
                    tc = treeView1.SelectedNode.Parent as TreeNodeCategory;
                }
            }
            if (tc != null)
            {
                tc.AddProperty();
            }
        }
Example #7
0
        private void nameChanging(object sender, EventArgs e)
        {
            TreeNodeCategory    changedNode = null;
            EventArgvNameChange en          = (EventArgvNameChange)e;

            if (ApplicationConfiguration.IsReservedWord(en.NewName))
            {
                MessageBox.Show(this.TreeView.FindForm(), "The name is reserved", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                en.Cancel = true;
            }
            else
            {
                for (int i = 0; i < Parent.Nodes.Count; i++)
                {
                    TreeNodeCategory tp = Parent.Nodes[i] as TreeNodeCategory;
                    if (tp != null)
                    {
                        if (string.CompareOrdinal(en.OldName, tp.Category.CategoryName) != 0)
                        {
                            if (string.CompareOrdinal(en.NewName, tp.Category.CategoryName) == 0)
                            {
                                MessageBox.Show(this.TreeView.FindForm(), "The name is in use", "Application Configuration", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                en.Cancel = true;
                                break;
                            }
                        }
                        else
                        {
                            changedNode = tp;
                        }
                    }
                }
            }
            if (!en.Cancel)
            {
                if (changedNode != null)
                {
                    changedNode.Text = en.NewName;
                }
            }
        }
Example #8
0
        private void toolStripButtonOK_Click(object sender, EventArgs e)
        {
            Ret = new CategoryList();
            TreeNodeAppConfig ta = null;

            for (int i = 0; i < treeView1.Nodes.Count; i++)
            {
                ta = treeView1.Nodes[i] as TreeNodeAppConfig;
                if (ta != null)
                {
                    break;
                }
            }
            if (ta != null)
            {
                for (int i = 0; i < ta.Nodes.Count; i++)
                {
                    TreeNodeCategory tc = ta.Nodes[i] as TreeNodeCategory;
                    if (tc != null)
                    {
                        ConfigCategory cat = tc.Category;
                        cat.Properties.Properties.Clear();
                        Ret.Categories.Add(cat);
                        for (int j = 0; j < tc.Nodes.Count; j++)
                        {
                            TreeNodeConfigProperty tp = tc.Nodes[j] as TreeNodeConfigProperty;
                            if (tp != null)
                            {
                                cat.Properties.Properties.Add(tp.Property);
                            }
                        }
                    }
                }
            }
            this.DialogResult = DialogResult.OK;
        }