Exemplo n.º 1
0
        /// <summary>Adds a ComboBox to the form.</summary>
        /// <param name="caption">The ComboBox's caption.</param>
        /// <param name="selectionHandler">The handler for the selection changed event.</param>
        /// <param name="options">The options to display in the ComboBox.</param>
        public SimpleComboBox AddComboBox(string caption, MultiControlTextEventHandler selectionHandler, params string[] options)
        {
            var lbl = new Label()
            {
                Text      = caption,
                AutoSize  = true,
                Dock      = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleLeft
            };
            var cbo = new ComboBox()
            {
                Dock          = DockStyle.Fill,
                DropDownStyle = ComboBoxStyle.DropDownList,
            };

            cbo.Items.AddRange(options);
            this.Form.AddToControls(lbl, cbo);

            var scbo = new SimpleComboBox(lbl, cbo);

            if (selectionHandler != null)
            {
                cbo.SelectedIndexChanged += (o, e) => {
                    selectionHandler.Invoke(scbo, cbo.Items[cbo.SelectedIndex].ToString());
                }
            }
            ;

            return(scbo);
        }
Exemplo n.º 2
0
        /// <summary>Adds a text box to the form.</summary>
        /// <param name="caption">The caption for the text box.</param>
        /// <param name="inputHandler">The event handler for text input.</param>
        public SimpleTextBox AddTextBox(string caption, MultiControlTextEventHandler inputHandler)
        {
            var lbl = new Label()
            {
                Text      = caption,
                AutoSize  = true,
                Dock      = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleLeft
            };
            var txt = new TextBox()
            {
                Dock = DockStyle.Fill
            };

            this.Form.AddToControls(lbl, txt);

            var stb = new SimpleTextBox(lbl, txt);

            if (inputHandler != null)
            {
                txt.KeyDown += (o, e) => {
                    if (e.KeyCode == Keys.Enter)
                    {
                        inputHandler.Invoke(stb, txt.Text);
                    }
                }
            }
            ;

            return(stb);
        }
    }
Exemplo n.º 3
0
        /// <summary>Adds a ComboBox to the form.</summary>
        /// <param name="caption">The ComboBox's caption.</param>
        /// <param name="selectionHandler">The handler for the selection changed event.</param>
        /// <param name="options">The options to display in the ComboBox.</param>
        public SimpleComboBox AddComboBox(string caption, MultiControlTextEventHandler selectionHandler, params string[] options)
        {
            var lbl = new Label() {
                Text = caption,
                AutoSize = true,
                Dock = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleLeft
            };
            var cbo = new ComboBox() {
                Dock = DockStyle.Fill,
                DropDownStyle = ComboBoxStyle.DropDownList,
            };
            cbo.Items.AddRange(options);
            this.Form.AddToControls(lbl, cbo);

            var scbo = new SimpleComboBox(lbl, cbo);
            if (selectionHandler != null)
                cbo.SelectedIndexChanged += (o, e) => {
                    selectionHandler.Invoke(scbo, cbo.Items[cbo.SelectedIndex].ToString());
                };

            return scbo;
        }
Exemplo n.º 4
0
        /// <summary>Adds a text box to the form.</summary>
        /// <param name="caption">The caption for the text box.</param>
        /// <param name="inputHandler">The event handler for text input.</param>
        public SimpleTextBox AddTextBox(string caption, MultiControlTextEventHandler inputHandler)
        {
            var lbl = new Label() {
                Text = caption,
                AutoSize = true,
                Dock = DockStyle.Fill,
                TextAlign = ContentAlignment.MiddleLeft
            };
            var txt = new TextBox() { Dock = DockStyle.Fill };
            this.Form.AddToControls(lbl, txt);

            var stb = new SimpleTextBox(lbl, txt);
            if (inputHandler != null)
                txt.KeyDown += (o, e) => {
                    if (e.KeyCode == Keys.Enter) inputHandler.Invoke(stb, txt.Text);
                };

            return stb;
        }