Example #1
0
        /// <summary>
        /// Changes the name of the ComponentPropertiesTabPage if the name is not already taken.
        /// </summary>
        public void ChangeName()
        {
            EnterNameDialog nameDialog = new EnterNameDialog();

            if (nameDialog.ShowDialog(this).Equals(DialogResult.OK))
            {
                if (parentControl.TabPages.ContainsKey(nameDialog.nameTextBox.Text) && !Name.ToLower().Equals(nameDialog.nameTextBox.Text.ToLower()))
                {
                    MessageBox.Show("Name is already taken.", "Invalid name.");
                }
                else
                {
                    SetName(nameDialog.nameTextBox.Text);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Adds a ComponentPropertiesTab if the EnterNameDialog returns OK and the name isn't already taken.
        /// </summary>
        /// <returns>true if OK is pressed</returns>
        public bool AddComponentPropertiesTab()
        {
            EnterNameDialog nameDialog = new EnterNameDialog();

            if (nameDialog.ShowDialog(this).Equals(DialogResult.OK))
            {
                if (TabPages.ContainsKey(nameDialog.nameTextBox.Text))
                {
                    MessageBox.Show("Name is already taken.", "Invalid name.");
                    return(false);
                }
                else
                {
                    ComponentPropertiesTabPage page = new ComponentPropertiesTabPage(this, nameDialog.nameTextBox.Text);
                    TabPages.Insert(TabPages.Count - 1, page);
                    SelectedTab = page;
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }