FlatRedBall.Glue.Controls.NewFileWindow.AddTextBox C# (CSharp) Method

AddTextBox() public method

public AddTextBox ( string label ) : int
label string
return int
        public int AddTextBox(string label)
        {
            flowLayoutPanel1.SuspendLayout();
            flowLayoutPanel1.Controls.Remove(OkCancelPanel);

            List<string> labels = new List<string>();
            
            labels.Add(label);
            int labelId = mDynamicUiHelper.AddUi(flowLayoutPanel1, labels, UiType.Label);

            Label labelControl = mDynamicUiHelper.GetControl(labelId) as Label;
            labelControl.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
            labelControl.Height = 16;

            List<string> values = new List<string>();
            values.Add("");
            int returnValue = mDynamicUiHelper.AddUi(flowLayoutPanel1, values, UiType.TextBox);

            TextBox textBox = mDynamicUiHelper.GetControl(returnValue) as TextBox;

            textBox.Margin = new Padding(3, 0, 3, 3);
            flowLayoutPanel1.Controls.Add(OkCancelPanel);
            flowLayoutPanel1.ResumeLayout();
            flowLayoutPanel1.PerformLayout();
            

            return returnValue;
        }

Usage Example

        public BuildToolAssociation GetBuildToolAssocationAndNameFor(string fileName, out bool userCancelled, out string rfsName, out string extraCommandLineArguments)
        {
            userCancelled = false;
            rfsName = null;

            BuildToolAssociation buildToolAssociation = null;

            string sourceExtension = FileManager.GetExtension(fileName);

            List<BuildToolAssociation> btaList = new List<BuildToolAssociation>();
            foreach (BuildToolAssociation bta in BuildToolAssociationManager.Self.ProjectSpecificBuildTools.BuildToolList)
            {
                if (bta.SourceFileType != null && bta.SourceFileType.ToLower() == sourceExtension.ToLower())
                {
                    btaList.Add(bta);
                }
            }



            NewFileWindow nfw = new NewFileWindow();
            nfw.ComboBoxMessage = "Which builder would you like to use for this file?";

            int commandLineArgumentsId = nfw.AddTextBox("Enter extra command line arguments:");

            foreach (BuildToolAssociation bta in btaList)
            {
                nfw.AddOption(bta);
            }

            if (btaList.Count != 0)
            {
                nfw.SelectedItem = btaList[0];
            }

            nfw.ResultName = FileManager.RemoveExtension(FileManager.RemovePath(fileName));
            //DialogResult result = cbmb.ShowDialog();
            DialogResult result = nfw.ShowDialog();
            extraCommandLineArguments = "";

            if (result == DialogResult.OK)
            {
                buildToolAssociation = nfw.SelectedItem as BuildToolAssociation;
                rfsName = nfw.ResultName;
                extraCommandLineArguments = nfw.GetValueFromId(commandLineArgumentsId);
            }
            else
            {
                userCancelled = true;
            }




            return buildToolAssociation;
        }