mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 15:00:29 +00:00
120 lines
4.0 KiB
C#
120 lines
4.0 KiB
C#
/*
|
|
_ _ _ ____ _ _____
|
|
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
|
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
|
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
|
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
|
|
|
Copyright 2015-2016 Łukasz "JustArchi" Domeradzki
|
|
Contact: JustArchi@JustArchi.net
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ConfigGenerator {
|
|
class DialogBox {
|
|
public static DialogResult InputBox(string title, string promptText, out string value) {
|
|
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
|
value = null;
|
|
return DialogResult.Abort;
|
|
}
|
|
|
|
Form form = new Form();
|
|
Label label = new Label();
|
|
TextBox textBox = new TextBox();
|
|
|
|
textBox.Width = 1000;
|
|
Button buttonOk = new Button();
|
|
Button buttonCancel = new Button();
|
|
|
|
form.Text = title;
|
|
label.Text = promptText;
|
|
|
|
buttonOk.Text = "OK";
|
|
buttonCancel.Text = "Cancel";
|
|
buttonOk.DialogResult = DialogResult.OK;
|
|
buttonCancel.DialogResult = DialogResult.Cancel;
|
|
|
|
label.SetBounds(9, 20, 372, 13);
|
|
textBox.SetBounds(12, 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;
|
|
|
|
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;
|
|
|
|
DialogResult dialogResult = form.ShowDialog();
|
|
value = textBox.Text;
|
|
return dialogResult;
|
|
}
|
|
|
|
public static DialogResult YesNoBox(string title, string promptText) {
|
|
if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(promptText)) {
|
|
return DialogResult.Abort;
|
|
}
|
|
|
|
Form form = new Form();
|
|
Label label = new Label();
|
|
|
|
Button buttonOk = new Button();
|
|
Button buttonCancel = new Button();
|
|
|
|
form.Text = title;
|
|
label.Text = promptText;
|
|
|
|
buttonOk.Text = "Yes";
|
|
buttonCancel.Text = "No";
|
|
buttonOk.DialogResult = DialogResult.Yes;
|
|
buttonCancel.DialogResult = DialogResult.No;
|
|
|
|
label.SetBounds(9, 20, 372, 13);
|
|
buttonOk.SetBounds(228, 50, 75, 23);
|
|
buttonCancel.SetBounds(309, 50, 75, 23);
|
|
|
|
label.AutoSize = true;
|
|
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
|
|
form.ClientSize = new Size(396, 80);
|
|
form.Controls.AddRange(new Control[] { label, 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;
|
|
|
|
DialogResult dialogResult = form.ShowDialog();
|
|
return dialogResult;
|
|
}
|
|
}
|
|
}
|