HaloMap.Meta.Meta.askForTagName C# (CSharp) Method

askForTagName() public static method

Asks for a tag name for export.
public static askForTagName ( string newName ) : string
newName string The new name.
return string
        public static string askForTagName(string newName)
        {
            Form newForm = new Form();
            newForm.Name = "newForm";
            newForm.Size = new Size(500, 110);
            newForm.Text = "Select exported tag name";
            newForm.FormBorderStyle = FormBorderStyle.FixedDialog;

            #region label data

            Label newLabel = new Label();
            newLabel.Location = new Point(10, 14);
            newLabel.Name = "newLabel";
            newLabel.Size = new Size(68, 18);
            newLabel.Text = "Export As";

            #endregion

            #region Textbox Data

            TextBox newTextBox = new TextBox();
            newTextBox.Location = new Point(80, 10);
            newTextBox.Name = "newTextBox";
            newTextBox.Size = new Size(400, 10);
            newTextBox.Text = newName; // Set the name to our predicted name

            #endregion

            #region Button Data

            Button newAddButton = new Button();
            newAddButton.AutoSize = false;
            newAddButton.Name = "newAddButton";
            newAddButton.Size = new Size(160, 30);
            newAddButton.Location = new Point(170, 40);
            newAddButton.Parent = newForm;
            newAddButton.Text = "Save tag";
            newAddButton.DialogResult = DialogResult.OK;

            #endregion

            #region Add Controls

            newForm.Controls.Add(newLabel);
            newForm.Controls.Add(newTextBox);
            newForm.Controls.Add(newAddButton);
            DialogResult result = newForm.ShowDialog();

            #endregion

            if (result == DialogResult.OK)
            {
                return newTextBox.Text;
            }
            else
            {
                return string.Empty;
            }
        }