public void addNVPButton_click(object obj, EventArgs e)
        {
            bool showAgain = false;
            DialogResult dlgResult = DialogResult.Cancel;
            using (NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog("", "", validAddTypes))
            {
                do{
                    showAgain = false;
                    dlgResult = dlg.ShowDialog();
                    if (dlgResult == DialogResult.OK)
                    {
                        // do validation here
                        // if validation fails, set showAgain to true
                        showAgain = ((dlgResult == DialogResult.OK) && (!dlg.okButton_validating()));
                        if (nameValueCollection.NameValuePairKeyList().Contains(dlg.NameTextBoxText))
                        {
                            MessageBox.Show("You have entered a name that is already in the Name Value Object. You should edit it if you want to change its value. Two pairs may not have the same name.", "Error adding name value pair", MessageBoxButtons.OK);
                            showAgain = true;
                        }
                    }

                }while (showAgain);

                if (dlgResult == DialogResult.OK)
                {
                    NameValueCollection.AddNameValuePair(dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.TypeComboBoxSelectedItemAsString);
                }
                else if (dlgResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            loadNameListBox();
        }
Exemple #2
0
        public void addNVPButton_click(object obj, EventArgs e)
        {
            bool         showAgain = false;
            DialogResult dlgResult = DialogResult.Cancel;

            using (NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog("", "", validAddTypes))
            {
                do
                {
                    showAgain = false;
                    dlgResult = dlg.ShowDialog();
                    if (dlgResult == DialogResult.OK)
                    {
                        // do validation here
                        // if validation fails, set showAgain to true
                        showAgain = ((dlgResult == DialogResult.OK) && (!dlg.okButton_validating()));
                        if (nameValueCollection.NameValuePairKeyList().Contains(dlg.NameTextBoxText))
                        {
                            MessageBox.Show("You have entered a name that is already in the Name Value Object. You should edit it if you want to change its value. Two pairs may not have the same name.", "Error adding name value pair", MessageBoxButtons.OK);
                            showAgain = true;
                        }
                    }
                }while (showAgain);

                if (dlgResult == DialogResult.OK)
                {
                    NameValueCollection.AddNameValuePair(dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.TypeComboBoxSelectedItemAsString);
                }
                else if (dlgResult == DialogResult.Cancel)
                {
                    return;
                }
            }
            loadNameListBox();
        }
Exemple #3
0
        public void editNVPButton_click(object obj, EventArgs e)
        {
            valueItem value;

            if (nameListBox.Items.Count > 0 && nameListBox.SelectedItem != null)
            {
                string name = nameListBox.SelectedItem.ToString();
                value = NameValueCollection.LookUp(name);

                NameValueAddEdit_Dialog dlg;
                if (value == null)
                {
                    return;
                }
                if (String.Equals(value.type, "Enum"))
                {
                    dlg = new NameValueAddEdit_Dialog(name, value.value, value.enumList);
                }
                else
                {
                    dlg = new NameValueAddEdit_Dialog(name, value.value, value.type, validAddTypes);
                }
                DialogResult dlgResult = dlg.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    if (String.Equals(value.type, "Enum"))
                    {
                        NameValueCollection.EditNameValuePair(nameListBox.SelectedItem.ToString(), dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.valueComboBox.SelectedItem.ToString(), value.enumList);
                    }
                    else
                    {
                        NameValueCollection.EditNameValuePair(nameListBox.SelectedItem.ToString(), dlg.NameTextBoxText, dlg.ValueTextBoxText, value.type, null);
                    }
                }
                dlg.ValueTextbox.Visible = true;
                dlg.ValueTextbox.Visible = false;
            }
            loadNameListBox();
        }
Exemple #4
0
        private void editNVPButton_clicked(object sender, EventArgs e)
        {
            valueItem     val;
            List <string> enumList = null;

            if (nameListBox.SelectedIndex >= 0)
            {
                string oldName = nameListBox.SelectedItem.ToString().Substring(0, nameListBox.SelectedItem.ToString().IndexOf('='));
                val = NameValueCollection.LookUp(oldName);
                if (val.enumList.Count > 0)
                {
                    enumList = val.enumList;
                }
                if (String.Equals(val.type, "Enum"))
                {
                    using (NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog(oldName, val.value, enumList))
                    {
                        dlg.Text = "Name Value Pair Edit Dialog";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            NameValueCollection.EditNameValuePair(oldName, dlg.NameTextBoxText, dlg.valueComboBox.SelectedItem.ToString(), val.type, enumList);
                        }
                    }
                }
                else
                {
                    using (NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog(oldName, val.value, val.type, validAddTypes))
                    {
                        dlg.Text = "Name Value Pair Edit Dialog";
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            NameValueCollection.EditNameValuePair(oldName, dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.TypeComboBoxSelectedItemAsString, null);
                        }
                    }
                }
                loadNameListBox();
            }
        }
 private void editNVPButton_clicked(object sender, EventArgs e)
 {
     valueItem val;
     List<string> enumList = null;
     if (nameListBox.SelectedIndex >= 0)
     {
         string oldName = nameListBox.SelectedItem.ToString().Substring(0, nameListBox.SelectedItem.ToString().IndexOf('='));
         val = NameValueCollection.LookUp(oldName);
         if (val.enumList.Count > 0)
         {
             enumList = val.enumList;
         }
         if (String.Equals(val.type, "Enum"))
         {
             using (NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog(oldName, val.value, enumList))
             {
                 dlg.Text = "Name Value Pair Edit Dialog";
                 if (dlg.ShowDialog() == DialogResult.OK)
                 {
                     NameValueCollection.EditNameValuePair(oldName, dlg.NameTextBoxText, dlg.valueComboBox.SelectedItem.ToString(), val.type, enumList);
                 }
             }
         }
         else
         {
             using(NameValueAddEdit_Dialog dlg = new NameValueAddEdit_Dialog(oldName, val.value, val.type, validAddTypes))
             {
                 dlg.Text = "Name Value Pair Edit Dialog";
                 if (dlg.ShowDialog() == DialogResult.OK)
                 {
                     NameValueCollection.EditNameValuePair(oldName, dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.TypeComboBoxSelectedItemAsString, null);
                 }
             }
         }
         loadNameListBox();
     }
 }
        public void editNVPButton_click(object obj, EventArgs e)
        {
            valueItem value;
            if (nameListBox.Items.Count > 0 && nameListBox.SelectedItem != null)
            {
                string name = nameListBox.SelectedItem.ToString();
                value = NameValueCollection.LookUp(name);

                NameValueAddEdit_Dialog dlg;
                if (value == null)
                {
                    return;
                }
                if (String.Equals(value.type, "Enum"))
                {
                    dlg = new NameValueAddEdit_Dialog(name, value.value, value.enumList);
                }
                else
                {
                    dlg = new NameValueAddEdit_Dialog(name, value.value, value.type, validAddTypes);
                }
                DialogResult dlgResult = dlg.ShowDialog();
                if (dlgResult == DialogResult.OK)
                {
                    if (String.Equals(value.type, "Enum"))
                    {
                        NameValueCollection.EditNameValuePair(nameListBox.SelectedItem.ToString(), dlg.NameTextBoxText, dlg.ValueTextBoxText, dlg.valueComboBox.SelectedItem.ToString(), value.enumList);
                    }
                    else
                    {
                        NameValueCollection.EditNameValuePair(nameListBox.SelectedItem.ToString(), dlg.NameTextBoxText, dlg.ValueTextBoxText, value.type, null);
                    }
                }
                dlg.ValueTextbox.Visible = true;
                dlg.ValueTextbox.Visible = false;
            }
            loadNameListBox();
        }