Example #1
0
        public static int InputListBox(string mTitle, IEnumerable<string> mItems)
        {
            var form = new Form();
            var listBox = new ListBox();

            form.Text = mTitle;

            foreach (var item in mItems)
                listBox.Items.Add(item);

            listBox.SetBounds(9, 20, 372, 250);
            listBox.AutoSize = true;

            form.ClientSize = new Size(396, 300);
            form.Controls.AddRange(new Control[] {listBox});
            form.ClientSize = new Size(Math.Max(300, listBox.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            listBox.DoubleClick += (sender, args) => { if (listBox.SelectedIndex != -1) form.Close(); };

            form.ShowDialog();

            return listBox.SelectedIndex;
        }
Example #2
0
        private void Display_Resize(object sender, System.EventArgs e)
        {
            Rectangle r = this.ClientRectangle;

            list.SetBounds(list.Left,
                           list.Top,
                           r.Width - (list.Left * 2),
                           r.Height - (list.Top + list.Left));
        }
Example #3
0
 public Output()
 {
     // Infobox
     infoBox = new ListBox();
     infoBox.MinimumSize = new Size(0, 108);
     infoBox.MaximumSize = new Size(0, 108);
     infoBox.SetBounds(0, 183, 526, 172);
     // Statusbar
     statusStrip = new StatusStrip();
     statusLabel = new ToolStripStatusLabel("statusLabel");
     statusProzentBar = new ToolStripProgressBar();
     statusStrip.Items.Add(statusProzentBar);
     statusStrip.Items.Add(statusLabel);
 }
Example #4
0
 public Output(Form myForm)
 {
     // Infobox
     infoBox = new ListBox();
     infoBox.MinimumSize = new Size(0, 108);
     infoBox.MaximumSize = new Size(0, 108);
     infoBox.SetBounds(0, 215, 526, 172);
     //infoBox.Anchor = AnchorStyles.Bottom;
     // Statusbar
     statusStrip = new StatusStrip();
     statusLabel = new ToolStripStatusLabel("statusLabel");
     statusProzentBar = new ToolStripProgressBar();
     statusStrip.Items.Add(statusProzentBar);
     statusStrip.Items.Add(statusLabel);
     //Form
     myForm.Controls.Add(infoBox);
     myForm.Controls.Add(statusStrip);
 }
        public static DialogResult InputList(string title, string promptText, List<string> listValues, ref string value)
        {
            Form _form = new Form();
            Label _label = new Label();
            ListBox _listBox = new ListBox();
            Button _okButton = new Button();
            Button _cancelButton = new Button();
            DialogResult _dialogResult = new DialogResult();

            try
            {
                _form.Text = title;
                _label.Text = promptText;
                _listBox.Items.Clear();

                // load the list view from the list values
                for (int n = 0; n < listValues.Count; n++)
                {
                    _listBox.Items.Add(listValues[n]);
                }

                _okButton.Text = "OK";
                _cancelButton.Text = "Cancel";
                _okButton.DialogResult = DialogResult.OK;
                _cancelButton.DialogResult = DialogResult.Cancel;

                _form.ClientSize = new Size(900, 300);

                Font _font = new Font("Calibri", 12);
                _form.Font = _font;

                _label.SetBounds(9, 20, 500, 13);
                _label.Font = _font;

                _listBox.SetBounds(12, 40, 800, 200);
                _listBox.Font = _font;

                _cancelButton.SetBounds(800, 300 - 35, 75, 30);
                _cancelButton.Font = _font;
                _okButton.SetBounds(_cancelButton.Left - 100, _cancelButton.Top, 75, 30);
                _okButton.Font = _font;

                _label.AutoSize = true;
                _listBox.Anchor = _listBox.Anchor | AnchorStyles.Right;
                //_okButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
                //_cancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

                _form.Controls.AddRange(new Control[] { _label, _listBox, _okButton, _cancelButton });
                //_form.ClientSize = new Size(Math.Max(300, _label.Right + 10), _form.ClientSize.Height);
                _form.FormBorderStyle = FormBorderStyle.FixedDialog;
                _form.StartPosition = FormStartPosition.CenterScreen;
                _form.MinimizeBox = false;
                _form.MaximizeBox = false;
                _form.AcceptButton = _okButton;
                _form.CancelButton = _cancelButton;

                _listBox.SelectedItems.Clear();

                _dialogResult = _form.ShowDialog();

                if (_listBox.SelectedItems.Count > 0)
                {
                    // get the selected item
                    value = _listBox.SelectedItem.ToString();
                }
            }
            catch (Exception ex)
            {
                CommonRoutines.Log("$E:" + moduleName + ".InputBox > " + ex.Message);
            }

            return _dialogResult;
        }
Example #6
0
        public static void AutoCompleteTextBox(TextBox txtControl, ListBox lstControl, 
            List<string> lstAutoCompleteList, KeyEventArgs txtControlKEA)
        {
            Point cp;
            GetCaretPos(out cp);
            List<string> lstTemp = new List<string>();
            //Positioning the Listbox on TextBox by Type Insertion Cursor position
            lstControl.SetBounds(cp.X + txtControl.Location.X, cp.Y + txtControl.Location.Y + 20, 150, 50);

            var TempFilteredList = lstAutoCompleteList.Where
                (n => n.StartsWith(GetLastString(txtControl.Text))).Select(r => r);

            lstTemp = TempFilteredList.ToList<string>();
            if (lstTemp.Count != 0 && GetLastString(txtControl.Text) != "")
            {
                lstControl.DataSource = lstTemp;
                lstControl.Show();
                lstControl.BringToFront();
            }
            else
            {
                lstControl.Hide();
            }

            //Code for focusing ListBox Items While Pressing Down and UP Key.
            if (txtControlKEA.KeyCode == Keys.Down)
            {
                lstControl.SelectedIndex = 0;
                lstControl.Focus();
                txtControlKEA.Handled = true;
            }
            else if (txtControlKEA.KeyCode == Keys.Up)
            {
                lstControl.SelectedIndex = lstControl.Items.Count - 1;
                lstControl.Focus();
                txtControlKEA.Handled = true;
            }

            //text box key press event
            txtControl.KeyPress += (s, kpeArgs) =>
            {

                if (kpeArgs.KeyChar == (char)Keys.Enter)
                {
                    if (lstControl.Visible)
                    {
                        lstControl.Focus();
                    }
                    kpeArgs.Handled = true;
                }
                else if (kpeArgs.KeyChar == (char)Keys.Escape)
                {
                    lstControl.Visible = false;
                    kpeArgs.Handled = true;
                }
                else if (kpeArgs.KeyChar == (char)Keys.Tab)
                {
                    txtControl.Text = ((ListBox)s).SelectedItem.ToString();
                    txtControl.Select(txtControl.Text.Length, 0);
                    txtControl.Focus();
                    lstControl.Hide();
                }
            };

            txtControl.LostFocus += (s, eventArgs) =>
                {
                    if (!lstControl.Focused)
                        lstControl.Hide();
                };

            //listbox keyup event
            lstControl.KeyUp += (s, kueArgs) =>
            {
                if (kueArgs.KeyCode == Keys.Tab)
                {
                    //string StrLS = GetLastString(txtControl.Text);
                    //int LIOLS = txtControl.Text.LastIndexOf(StrLS);
                    //string TempStr = txtControl.Text.Remove(LIOLS);
                    //txtControl.Text = TempStr + ((ListBox)s).SelectedItem.ToString();
                    txtControl.Text = ((ListBox)s).SelectedItem.ToString();
                    txtControl.Select(txtControl.Text.Length, 0);
                    txtControl.Focus();
                    lstControl.Hide();
                }
                else if (kueArgs.KeyCode == Keys.Escape)
                {
                    lstControl.Hide();
                    txtControl.Focus();
                }
            };
        }
Example #7
0
        public static void InputParametersBox(string title, TDEEntity mEntity)
        {
            var form = new Form();
            var listBox = new ListBox();
            var buttonExit = new Button();
            var textBox = new TextBox();

            form.Text = title;

            foreach (var parameter in mEntity.Parameters)
                listBox.Items.Add(String.Format("Parameter {0}: {1}", parameter.Name, parameter));

            buttonExit.Text = "Finished";
            buttonExit.DialogResult = DialogResult.Cancel;

            textBox.SetBounds(12, 280, 372, 20);
            listBox.SetBounds(9, 20, 372, 250);
            buttonExit.SetBounds(309, 320, 75, 23);

            listBox.AutoSize = true;
            buttonExit.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 615);
            form.Controls.AddRange(new Control[] {listBox, textBox, buttonExit});
            form.ClientSize = new Size(Math.Max(300, listBox.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            listBox.Click += (o, args) =>
                             {
                                 InputParametersBoxChange(mEntity, listBox, textBox.Text);
                                 textBox.Focus();
                             };
            form.CancelButton = buttonExit;

            form.ShowDialog();
        }
Example #8
0
        public static DialogResult InputFolderBox(string title, string promptText, ref string value)
        {
            Form form = new Form();
            Label label = new Label();
            TextBox textBox = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();
            ListBox v_dir = new ListBox();

            form.Text = title;
            label.Text = promptText;
            textBox.Text = value;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label.SetBounds(102, 20, 372, 13);
            textBox.SetBounds(112, 36, 372, 20);
            buttonOk.SetBounds(228, 72, 75, 23);
            buttonCancel.SetBounds(309, 72, 75, 23);

            label.AutoSize = true;
            textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            v_dir.MultiColumn = false;
            v_dir.Items.Add("NONE");
            v_dir.Items.Add("%WinDir%");
            v_dir.Items.Add("%Program Files%");
            v_dir.Items.Add("%System%");
            v_dir.Items.Add("%Fonts%");
            v_dir.Items.Add("%AppData%");
            v_dir.Items.Add("%SendTo%");
            v_dir.Items.Add("%Recent%");
            v_dir.Items.Add("%Recent%");
            v_dir.Items.Add("%Recent%");
            v_dir.Items.Add("%Recent%");
            v_dir.Items.Add("%Recent%");
            v_dir.SetBounds(3,3, 100, 100);

            form.ClientSize = new Size(396, 107);
            form.Controls.AddRange(new Control[] { v_dir,label, textBox, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, v_dir.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value = textBox.Text;
            return dialogResult;
        }