Пример #1
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;
                }
            }
        }
Пример #2
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;
                }
            }
        }