3 files changed
+48
-23
No files matched your search
+10
-11
@@ -34,7 +34,7 @@
|
||||
this.buttonOk = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxInput = new System.Windows.Forms.TextBox();
|
||||
this.checkBoxIsRoot = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxQuestion = new System.Windows.Forms.CheckBox();
|
||||
this.tableLayout.SuspendLayout();
|
||||
this.flowLayoutBottom.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -72,7 +72,7 @@
|
||||
//
|
||||
this.flowLayoutBottom.Controls.Add(this.buttonOk);
|
||||
this.flowLayoutBottom.Controls.Add(this.buttonCancel);
|
||||
this.flowLayoutBottom.Controls.Add(this.checkBoxIsRoot);
|
||||
this.flowLayoutBottom.Controls.Add(this.checkBoxQuestion);
|
||||
this.flowLayoutBottom.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutBottom.Location = new System.Drawing.Point(3, 68);
|
||||
this.flowLayoutBottom.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
@@ -120,14 +120,13 @@
|
||||
//
|
||||
// checkBoxIsRoot
|
||||
//
|
||||
this.checkBoxIsRoot.AutoSize = true;
|
||||
this.checkBoxIsRoot.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.checkBoxIsRoot.Location = new System.Drawing.Point(253, 3);
|
||||
this.checkBoxIsRoot.Name = "checkBoxIsRoot";
|
||||
this.checkBoxIsRoot.Size = new System.Drawing.Size(458, 60);
|
||||
this.checkBoxIsRoot.TabIndex = 3;
|
||||
this.checkBoxIsRoot.Text = "Add a root node (i.e. ignoring the selected node)";
|
||||
this.checkBoxIsRoot.UseVisualStyleBackColor = true;
|
||||
this.checkBoxQuestion.AutoSize = true;
|
||||
this.checkBoxQuestion.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.checkBoxQuestion.Location = new System.Drawing.Point(253, 3);
|
||||
this.checkBoxQuestion.Name = "checkBoxQuestion";
|
||||
this.checkBoxQuestion.Size = new System.Drawing.Size(458, 60);
|
||||
this.checkBoxQuestion.TabIndex = 3;
|
||||
this.checkBoxQuestion.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// InputDialog
|
||||
//
|
||||
@@ -161,6 +160,6 @@
|
||||
private TextBox textBoxInput;
|
||||
private Button buttonOk;
|
||||
private Button buttonCancel;
|
||||
private CheckBox checkBoxIsRoot;
|
||||
private CheckBox checkBoxQuestion;
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,39 @@
|
||||
|
||||
public partial class InputDialog : Form
|
||||
{
|
||||
public readonly record struct Options(
|
||||
string Message,
|
||||
string Title,
|
||||
string Placeholder = "",
|
||||
string PreloadedText = "",
|
||||
string OkButtonText = "Ok",
|
||||
string CancelButtonText = "Cancel",
|
||||
bool ShowQuestionCheckbox = false,
|
||||
string QuestionCheckboxText = ""
|
||||
);
|
||||
|
||||
private InputDialog()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public static InputResult Show(string message, string title, string placeholder = "", string preloadedText = "", string okButtonText = "Ok", string cancelButtonText = "Cancel")
|
||||
public static InputResult Show(Options options)
|
||||
{
|
||||
using var inputDialog = new InputDialog();
|
||||
inputDialog.labelHead.Text = message;
|
||||
inputDialog.Text = title;
|
||||
inputDialog.textBoxInput.PlaceholderText = placeholder;
|
||||
inputDialog.textBoxInput.Text = preloadedText;
|
||||
inputDialog.buttonOk.Text = okButtonText;
|
||||
inputDialog.buttonCancel.Text = cancelButtonText;
|
||||
inputDialog.labelHead.Text = options.Message;
|
||||
inputDialog.Text = options.Title;
|
||||
inputDialog.textBoxInput.PlaceholderText = options.Placeholder;
|
||||
inputDialog.textBoxInput.Text = options.PreloadedText;
|
||||
inputDialog.buttonOk.Text = options.OkButtonText;
|
||||
inputDialog.buttonCancel.Text = options.CancelButtonText;
|
||||
inputDialog.checkBoxQuestion.Visible = options.ShowQuestionCheckbox;
|
||||
inputDialog.checkBoxQuestion.Text = options.QuestionCheckboxText;
|
||||
|
||||
return new InputResult(inputDialog.ShowDialog(), inputDialog.textBoxInput.Text, inputDialog.checkBoxIsRoot.Checked);
|
||||
return new InputResult(
|
||||
inputDialog.ShowDialog(),
|
||||
inputDialog.textBoxInput.Text,
|
||||
inputDialog.checkBoxQuestion.Checked
|
||||
);
|
||||
}
|
||||
|
||||
private void textBoxInput_KeyUp(object sender, KeyEventArgs e)
|
||||
@@ -35,5 +52,5 @@ public partial class InputDialog : Form
|
||||
}
|
||||
}
|
||||
|
||||
public readonly record struct InputResult(DialogResult DialogResult, string Text, bool IsRoot);
|
||||
public readonly record struct InputResult(DialogResult DialogResult, string Text, bool AnswerToQuestion);
|
||||
}
|
||||
Reference in new issue
Block a user