FlatRedBall.Glue.Controls.TextInputWindow.AddControl C# (CSharp) Méthode

AddControl() public méthode

Adds a control to the TextInputWindow. The control will automatically be positioned below the previously-added control. The spacing can be controlled through the control's Margin property.
If you are adding a control after a label, you may need to adjust the label's height. By default it's bigger than usually desired.
public AddControl ( Control control, AboveOrBelow aboveOrBelow = AboveOrBelow.Below ) : void
control System.Windows.Forms.Control The control to add
aboveOrBelow AboveOrBelow
Résultat void
        public void AddControl(Control control, AboveOrBelow aboveOrBelow = AboveOrBelow.Below)
        {
            bool isFirst = (aboveOrBelow == AboveOrBelow.Below && this.ExtraControlsPanel.Controls.Count == 0)
                ||
                (aboveOrBelow == AboveOrBelow.Above && this.ExtraControlsPanelAbove.Controls.Count == 0)
                ;
            if (isFirst)
            {
                this.Height += 5;
            }

            if (aboveOrBelow == AboveOrBelow.Above)
            {
                this.ExtraControlsPanelAbove.Controls.Add(control);
            }
            else
            {
                // below
                this.ExtraControlsPanel.Controls.Add(control);

            }
            this.Height += control.Height;
            this.textBox1.Focus();
            this.DefaultControlPanel.Location = new Point(0, ExtraControlsPanelAbove.Height);



        }

Usage Example

        internal static void AddEntityToolStripClick()
        {
            // search:  addentity, add entity
            if (ProjectManager.GlueProjectSave == null)
            {
                System.Windows.Forms.MessageBox.Show("You need to load a project first.");
            }
            else
            {
                if (ProjectManager.StatusCheck() == ProjectManager.CheckResult.Passed)
                {
                    TextInputWindow tiw = new TextInputWindow();
                    tiw.DisplayText = "Enter a name for the new Entity";
                    tiw.Text = "New Entity";

                    CheckBox is2DCheckBox = new CheckBox();
                    is2DCheckBox.Text = "Is 2D";
                    is2DCheckBox.Checked = true;
                    is2DCheckBox.Margin = new Padding(2, 0, 0, 0);

                    tiw.AddControl(is2DCheckBox);

                    if (tiw.ShowDialog(MainGlueWindow.Self) == DialogResult.OK)
                    {

                        string entityName = tiw.Result;

                        string whyIsntValid;
                        string directory = "";

                        if (EditorLogic.CurrentTreeNode.IsDirectoryNode())
                        {
                            directory = EditorLogic.CurrentTreeNode.GetRelativePath();
                            directory = directory.Replace('/', '\\');
                        }

                        if (!NameVerifier.IsEntityNameValid(tiw.Result, null, out whyIsntValid))
                        {
                            MessageBox.Show(whyIsntValid);
                        }
                        else
                        {
                            var newElement = 
                                GlueCommands.Self.GluxCommands.EntityCommands.AddEntity(directory + tiw.Result, is2DCheckBox.Checked);

                            GlueState.Self.CurrentElement = newElement;

                        }
                    }
                }
            }
        }
All Usage Examples Of FlatRedBall.Glue.Controls.TextInputWindow::AddControl