2014-07-08 12:58:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Core
|
|
|
|
|
{
|
|
|
|
|
class InputBox
|
|
|
|
|
{
|
|
|
|
|
public static DialogResult Show(string title, string promptText, ref string value)
|
|
|
|
|
{
|
2014-07-18 15:05:44 +00:00
|
|
|
|
DialogResult dialogResult = DialogResult.Cancel;
|
|
|
|
|
using (var form = new Form())
|
|
|
|
|
{
|
|
|
|
|
Label label = new Label();
|
|
|
|
|
TextBox textBox = new TextBox();
|
|
|
|
|
Button buttonOk = new Button();
|
|
|
|
|
Button buttonCancel = new Button();
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
form.Text = title;
|
|
|
|
|
label.Text = promptText;
|
|
|
|
|
textBox.Text = value;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
buttonOk.Text = "OK";
|
|
|
|
|
buttonCancel.Text = "Cancel";
|
|
|
|
|
buttonOk.DialogResult = DialogResult.OK;
|
|
|
|
|
buttonCancel.DialogResult = DialogResult.Cancel;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
label.SetBounds(9, 20, 372, 13);
|
|
|
|
|
textBox.SetBounds(12, 36, 372, 20);
|
|
|
|
|
buttonOk.SetBounds(228, 72, 75, 23);
|
|
|
|
|
buttonCancel.SetBounds(309, 72, 75, 23);
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
label.AutoSize = true;
|
|
|
|
|
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
|
|
|
|
|
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
|
|
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
form.ClientSize = new Size(396, 107);
|
|
|
|
|
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
|
|
|
|
|
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 = buttonOk;
|
|
|
|
|
form.CancelButton = buttonCancel;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2014-07-18 15:05:44 +00:00
|
|
|
|
dialogResult = form.ShowDialog();
|
|
|
|
|
value = textBox.Text;
|
|
|
|
|
}
|
|
|
|
|
return dialogResult;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|