-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDialog.cs
More file actions
72 lines (61 loc) · 2.76 KB
/
Copy pathInputDialog.cs
File metadata and controls
72 lines (61 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Drawing;
using System.Windows.Forms;
namespace PingMonitor
{
public static class InputDialog
{
public static string Show(string title, string promptText, string defaultValue = "")
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = defaultValue;
buttonOk.Text = Lang.Get("ok");
buttonCancel.Text = Lang.Get("input_cancel");
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
// Стилизация под тему
form.BackColor = Theme.BgWindow;
form.ForeColor = Theme.Text;
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterParent;
form.MaximizeBox = false;
form.MinimizeBox = false;
form.ClientSize = new Size(380, 150);
label.SetBounds(20, 18, 340, 18);
label.Font = new Font("Segoe UI", 10);
textBox.SetBounds(20, 44, 340, 24);
textBox.Font = new Font("Segoe UI", 10);
textBox.BackColor = Theme.BgInput;
textBox.ForeColor = Theme.Text;
textBox.BorderStyle = BorderStyle.FixedSingle;
buttonOk.SetBounds(180, 90, 85, 30);
buttonCancel.SetBounds(275, 90, 85, 30);
// Кнопки
buttonOk.BackColor = Theme.Accent;
buttonOk.ForeColor = Theme.AccentText;
buttonOk.FlatStyle = FlatStyle.Flat;
buttonOk.FlatAppearance.BorderSize = 0;
buttonOk.Cursor = Cursors.Hand;
buttonOk.MouseEnter += (s, e) => buttonOk.BackColor = Theme.AccentHover;
buttonOk.MouseLeave += (s, e) => buttonOk.BackColor = Theme.Accent;
buttonCancel.BackColor = Theme.BgInput;
buttonCancel.ForeColor = Theme.Text;
buttonCancel.FlatStyle = FlatStyle.Flat;
buttonCancel.FlatAppearance.BorderSize = 0;
buttonCancel.Cursor = Cursors.Hand;
buttonCancel.MouseEnter += (s, e) => buttonCancel.BackColor = Theme.BgHover;
buttonCancel.MouseLeave += (s, e) => buttonCancel.BackColor = Theme.BgInput;
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
return dialogResult == DialogResult.OK ? textBox.Text : null;
}
}
}