Esempio n. 1
0
    public static InputBox Show(string title, string label, InputBoxButtons buttons)
    {
        dialogForm dialog = new dialogForm(title, new InputBoxItem[] { new InputBoxItem(label) }, buttons);

        dialog.ShowDialog();
        return(new InputBox(dialog));
    }
Esempio n. 2
0
        public static InputDialog Show(string title, InputDialogItem item, InputBoxButtons buttons)
        {
            dialogForm dialog = new dialogForm(title, new InputDialogItem[] { item }, buttons);

            dialog.ShowDialog();
            return(new InputDialog(dialog));
        }
Esempio n. 3
0
    public static InputBox Show(string title, InputBoxItem[] items, InputBoxButtons buttons)
    {
        dialogForm dialog = new dialogForm(title, items, buttons);

        dialog.ShowDialog();
        return(new InputBox(dialog));
    }
Esempio n. 4
0
        public static InputDialog Show(string title, InputDialogItem[] items, InputBoxButtons buttons)
        {
            dialogForm dialog = new dialogForm(title, items, buttons);

            dialog.StartPosition = FormStartPosition.CenterScreen;
            dialog.ShowDialog();
            return(new InputDialog(dialog));
        }
Esempio n. 5
0
 public DialogResult Show(string title, string[] prompts, string[] defaultText, out string[] value, InputBoxButtons buttons, InputBoxIcon icon, bool confirmation)
 {
     if (prompts.Length > MaxPrompts)
         throw new ArgumentOutOfRangeException("prompts");
     if(defaultText.Length > MaxPrompts)
         throw new ArgumentOutOfRangeException("defaultText");
     BuildView(title, prompts, defaultText, buttons, icon, confirmation);
     value = _results;
     var result = DialogResult;
     return result;
 }
Esempio n. 6
0
    public static InputBox Show(IWin32Window window, string title, string[] labels, InputBoxButtons buttons)
    {
        InputBoxItem[] items = new InputBoxItem[labels.Length];
        for (int i = 0; i < labels.Length; i++)
        {
            items[i] = new InputBoxItem(labels[i]);
        }

        dialogForm dialog = new dialogForm(title, items, buttons);

        dialog.ShowDialog(window);
        return(new InputBox(dialog));
    }
Esempio n. 7
0
        public dialogForm(string title, InputBoxItem[] items, InputBoxButtons buttons)
        {
            int minWidth = 312;

            label = new Label[items.Length];
            for (int i = 0; i < label.Length; i++)
            {
                label[i] = new Label();
            }
            textBox = new TextBox[items.Length];
            for (int i = 0; i < textBox.Length; i++)
            {
                textBox[i] = new TextBox();
            }
            button2 = new Button();
            button3 = new Button();
            button1 = new Button();
            SuspendLayout();
            //
            // label
            //
            for (int i = 0; i < items.Length; i++)
            {
                label[i].AutoSize = true;
                label[i].Location = new Point(12, 9 + (i * 39));
                label[i].Name     = "label[" + i + "]";
                label[i].Text     = items[i].Label;
                if (label[i].Width > minWidth)
                {
                    minWidth = label[i].Width;
                }
            }
            //
            // textBox
            //
            for (int i = 0; i < items.Length; i++)
            {
                textBox[i].Anchor   = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
                textBox[i].Location = new Point(12, 25 + (i * 39));
                textBox[i].Name     = "textBox[" + i + "]";
                textBox[i].Size     = new Size(288, 20);
                textBox[i].TabIndex = i;
                textBox[i].Text     = items[i].Text;
                if (items[i].IsPassword)
                {
                    textBox[i].UseSystemPasswordChar = true;
                }
            }
            //
            // button1
            //
            button1.Anchor   = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right);
            button1.Location = new Point(208, 15 + (39 * label.Length));
            button1.Name     = "button1";
            button1.Size     = new Size(92, 23);
            button1.TabIndex = items.Length + 2;
            button1.Text     = "button1";
            button1.UseVisualStyleBackColor = true;
            //
            // button2
            //
            button2.Anchor   = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right);
            button2.Location = new Point(110, 15 + (39 * label.Length));
            button2.Name     = "button2";
            button2.Size     = new Size(92, 23);
            button2.TabIndex = items.Length + 1;
            button2.Text     = "button2";
            button2.UseVisualStyleBackColor = true;
            //
            // button3
            //
            button3.Anchor   = (AnchorStyles)(AnchorStyles.Bottom | AnchorStyles.Right);
            button3.Location = new Point(12, 15 + (39 * label.Length));
            button3.Name     = "button3";
            button3.Size     = new Size(92, 23);
            button3.TabIndex = items.Length;
            button3.Text     = "button3";
            button3.UseVisualStyleBackColor = true;
            //
            // Evaluate MessageBoxButtons
            //
            switch (buttons)
            {
            case InputBoxButtons.OK:
                button1.Text    = "OK";
                button1.Click  += OK_Click;
                button2.Visible = false;
                button3.Visible = false;
                AcceptButton    = button1;
                break;

            case InputBoxButtons.OKCancel:
                button1.Text    = "Cancel";
                button1.Click  += Cancel_Click;
                button2.Text    = "OK";
                button2.Click  += OK_Click;
                button3.Visible = false;
                AcceptButton    = button2;
                break;

            case InputBoxButtons.YesNo:
                button1.Text    = "No";
                button1.Click  += No_Click;
                button2.Text    = "Yes";
                button2.Click  += Yes_Click;
                button3.Visible = false;
                AcceptButton    = button2;
                break;

            case InputBoxButtons.YesNoCancel:
                button1.Text   = "Cancel";
                button1.Click += Cancel_Click;
                button2.Text   = "No";
                button2.Click += No_Click;
                button3.Text   = "Yes";
                button3.Click += Yes_Click;
                AcceptButton   = button3;
                break;

            case InputBoxButtons.Save:
                button1.Text    = "Save";
                button1.Click  += Save_Click;
                button2.Visible = false;
                button3.Visible = false;
                AcceptButton    = button1;
                break;

            case InputBoxButtons.SaveCancel:
                button1.Text    = "Cancel";
                button1.Click  += Cancel_Click;
                button2.Text    = "Save";
                button2.Click  += Save_Click;
                button3.Visible = false;
                AcceptButton    = button2;
                break;

            default:
                throw new Exception("Invalid InputBoxButton Value");
            }
            //
            // dialogForm
            //
            AutoScaleDimensions = new SizeF(6F, 13F);
            AutoScaleMode       = AutoScaleMode.Font;
            ClientSize          = new Size(312, 47 + (39 * items.Length));
            for (int i = 0; i < label.Length; i++)
            {
                Controls.Add(label[i]);
            }
            for (int i = 0; i < textBox.Length; i++)
            {
                Controls.Add(textBox[i]);
            }
            Controls.Add(button1);
            Controls.Add(button2);
            Controls.Add(button3);
            MaximizeBox   = false;
            MinimizeBox   = false;
            MaximumSize   = new Size(99999, 85 + (39 * items.Length));
            Name          = "dialogForm";
            ShowIcon      = false;
            ShowInTaskbar = false;
            Text          = title;
            ResumeLayout(false);
            PerformLayout();
            foreach (Label l in label)
            {
                if (l.Width > minWidth)
                {
                    minWidth = l.Width;
                }
            }
            ClientSize  = new Size(minWidth + 24, 47 + (39 * items.Length));
            MinimumSize = new Size(minWidth + 40, 85 + (39 * items.Length));
        }
Esempio n. 8
0
    public static InputBox Show(IWin32Window window, string title, InputBoxItem item, InputBoxButtons buttons)
    {
        dialogForm dialog = new dialogForm(title, new InputBoxItem[] { item }, buttons);

        dialog.ShowDialog(window);
        return(new InputBox(dialog));
    }
Esempio n. 9
0
    public static InputBox Show(IWin32Window window, string title, string label, string text, InputBoxButtons buttons)
    {
        dialogForm dialog = new dialogForm(title, new InputBoxItem[] { new InputBoxItem(label, text) }, buttons);

        dialog.ShowDialog(window);
        return(new InputBox(dialog));
    }
Esempio n. 10
0
        public static InputDialog Show(IWin32Window window, string title, InputDialogItem[] items, InputBoxButtons buttons)
        {
            dialogForm dialog = new dialogForm(title, items, buttons);

            dialog.ShowDialog(window);
            return(new InputDialog(dialog));
        }
Esempio n. 11
0
        private void BuildView(string title, string[] prompts, string[] defaultTest, InputBoxButtons buttons, InputBoxIcon icon, bool confirmation)
        {
            _confirmation = confirmation;
            _prompts = prompts;
            var textBoxWidth = icon == InputBoxIcon.None ? 448 : 340;
            Text = title;
            _textboxes = new TextBox[defaultTest.Length];
            _labels = new Label[defaultTest.Length];
            switch (icon)
            {
                case InputBoxIcon.None:
                    splitContainer1.Panel1Collapsed = true;
                    break;
                case InputBoxIcon.Information:
                    splitContainer1.Panel1Collapsed = false;
                    pictureBox1.Image = Resources.Information;
                    break;
                case InputBoxIcon.Error:
                    splitContainer1.Panel1Collapsed = false;
                    pictureBox1.Image = Resources.Error;
                    break;
                case InputBoxIcon.Question:
                    splitContainer1.Panel1Collapsed = false;
                    pictureBox1.Image = Resources.Question;
                    break;
                case InputBoxIcon.Warning:
                    splitContainer1.Panel1Collapsed = false;
                    pictureBox1.Image = Resources.Warning;
                    break;
            }
            switch (buttons)
            {
                case InputBoxButtons.OkCancel:
                    button3.Visible = false;
                    button1.Text = @"Ok";
                    button1.Click += (OkBtnClick);
                    break;
                case InputBoxButtons.OkClearCancel:
                    button3.Visible = true;
                    button3.Text = @"Ok";
                    button3.Click += (OkBtnClick);
                    button1.Text = @"Clear";
                    button1.Click += (s, ee) =>
                                         {
                                             foreach (var textBox in _textboxes)
                                             {
                                                 textBox.Clear();
                                             }
                                         };
                    break;
            }
            button2.Text = @"Cancel";
            button2.Click += (s, ee) =>
                                 {
                                     Hide();
                                     DialogResult = DialogResult.Cancel;
                                 };

            for (var i = 0; i < defaultTest.Length; i++)
            {
                _labels[i] = new Label
                                 {
                                     Text = prompts[i],
                                     Location = new Point(LabelOne.X,LabelOne.Y + (YDelta * i))
                                 };
                _textboxes[i] = new TextBox
                                    {
                                        Text = defaultTest[i],
                                        Location = new Point(TextBoxOne.X,TextBoxOne.Y + (YDelta * i)),
                                        Size = new Size(textBoxWidth,20)
                                    };
                _textboxes[i].BringToFront();
                splitContainer1.Panel2.Controls.Add(_labels[i]);
                splitContainer1.Panel2.Controls.Add(_textboxes[i]);
            }
            if(_prompts.Length > 2)
            {
                Size = new Size(Size.Width,170 +((YDelta+20) * (_prompts.Length - 2)));
            }
            ShowDialog();
        }
Esempio n. 12
0
 public DialogResult Show(string title, string[] prompts, string[] defaultText, out string[] value, InputBoxButtons buttons)
 {
     return Show(title, prompts, defaultText, out value, buttons, InputBoxIcon.None, false);
 }