/// <summary>
		/// Brings up a UI for the user to edit a cusotm enum.
		/// </summary>
		/// <param name="enumValues">The existing collection of Enum values to edit.</param>
		/// <returns>True if the user accepted changes to the Enum values.</returns>
		public static bool EditEnum(List<string> enumValues)
		{
			EditCustomEnumOrDescription frm = new EditCustomEnumOrDescription();
			frm.Text = "Edit Custom Enum";
			frm._allowNewLineCharacters = true;
			foreach (string enm in enumValues)
			{
				frm.tbxValues.Text += enm + Environment.NewLine;
			}
			if (frm.tbxValues.TextLength > 0)
			{
				frm.tbxValues.Text = frm.tbxValues.Text.Substring(0, frm.tbxValues.Text.LastIndexOf(Environment.NewLine));
			}
			DialogResult rslt = frm.ShowDialog();
			if (rslt == DialogResult.OK)
			{
				enumValues.Clear();
				foreach (string line in frm.tbxValues.Lines)
				{
					enumValues.Add(line);
				}
				return true;
			}
			return false;
		}
        /// <summary>
        /// Brings up a UI for the user to edit a cusotm enum.
        /// </summary>
        /// <param name="enumValues">The existing collection of Enum values to edit.</param>
        /// <returns>True if the user accepted changes to the Enum values.</returns>
        public static bool EditEnum(List <string> enumValues)
        {
            EditCustomEnumOrDescription frm = new EditCustomEnumOrDescription();

            frm.Text = "Edit Custom Enum";
            frm._allowNewLineCharacters = true;
            foreach (string enm in enumValues)
            {
                frm.tbxValues.Text += enm + Environment.NewLine;
            }
            if (frm.tbxValues.TextLength > 0)
            {
                frm.tbxValues.Text = frm.tbxValues.Text.Substring(0, frm.tbxValues.Text.LastIndexOf(Environment.NewLine));
            }
            DialogResult rslt = frm.ShowDialog();

            if (rslt == DialogResult.OK)
            {
                enumValues.Clear();
                foreach (string line in frm.tbxValues.Lines)
                {
                    enumValues.Add(line);
                }
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        private void btnEditDescription_Click(object sender, EventArgs e)
        {
            string desc = tbxDescription.Text;

            if (EditCustomEnumOrDescription.EditDescription(ref desc))
            {
                tbxDescription.Text = desc;
            }
        }
Beispiel #4
0
        private void btnEditCustomEnum_Click(object sender, EventArgs e)
        {
            if (_definitionNode != null)
            {
                List <string> enums = new List <string>();
                XmlNodeList   nodes = _definitionNode.SelectNodes("def:CustomEnumValues/def:CustomEnumValue", CustomPropertiesManager.NamespaceManager);
                foreach (XmlNode customEnumValue in nodes)
                {
                    enums.Add(customEnumValue.Attributes["value"].Value);
                }
                if (EditCustomEnumOrDescription.EditEnum(enums))
                {
                    XmlNode valuesCol = _definitionNode.SelectSingleNode("def:CustomEnumValues", CustomPropertiesManager.NamespaceManager);
                    if (valuesCol == null)
                    {
                        valuesCol = CustomPropertiesManager.LoadedDocument.CreateElement("CustomEnumValues", CustomPropertiesDomainModel.XmlNamespace);
                        _definitionNode.AppendChild(valuesCol);
                    }
                    else
                    {
                        valuesCol.RemoveAll();
                    }

                    tbxCustomEnum.Clear();
                    tbxCustomEnum.Text = string.Join("; ", enums.ToArray());

                    foreach (string newValue in enums)
                    {
                        XmlNode      newNode     = CustomPropertiesManager.LoadedDocument.CreateElement("CustomEnumValue", CustomPropertiesDomainModel.XmlNamespace);
                        XmlAttribute valueAttrib = CustomPropertiesManager.LoadedDocument.CreateAttribute("value");
                        newNode.Attributes.Append(valueAttrib);

                        valueAttrib.Value = newValue;

                        valuesCol.AppendChild(newNode);
                    }
                }
            }

            if (_definitionObject != null)
            {
                List <string> values = new List <string>();
                values.AddRange(_definitionObject.CustomEnumValue.Split('\0'));
                if (EditCustomEnumOrDescription.EditEnum(values))
                {
                    _definitionObject.CustomEnumValue = string.Join("\0", values.ToArray());
                    tbxCustomEnum.Text = string.Join("; ", values.ToArray());
                }
            }
        }
        /// <summary>
        /// Brings up a UI for the user to edit a description.
        /// </summary>
        /// <param name="desc">The existing description to edit.</param>
        /// <returns>True if the user accepted changes to the description.</returns>
        public static bool EditDescription(ref string desc)
        {
            EditCustomEnumOrDescription frm = new EditCustomEnumOrDescription();

            frm.Text = "Edit Description";
            frm._allowNewLineCharacters = false;
            frm.tbxValues.Text          = desc;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                desc = frm.tbxValues.Text;
                return(true);
            }
            return(false);
        }
		/// <summary>
		/// Brings up a UI for the user to edit a description.
		/// </summary>
		/// <param name="desc">The existing description to edit.</param>
		/// <returns>True if the user accepted changes to the description.</returns>
		public static bool EditDescription(ref string desc)
		{
			EditCustomEnumOrDescription frm = new EditCustomEnumOrDescription();
			frm.Text = "Edit Description";
			frm._allowNewLineCharacters = false;
			frm.tbxValues.Text = desc;
			if (frm.ShowDialog() == DialogResult.OK)
			{
				desc = frm.tbxValues.Text;
				return true;
			}
			return false;
		}