-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDialog.cs
More file actions
51 lines (44 loc) · 1.32 KB
/
InputDialog.cs
File metadata and controls
51 lines (44 loc) · 1.32 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
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FaviconGenerator
{
// 輸入對話框
public class InputDialog : Form
{
public string InputText { get; private set; }
public InputDialog(string title, string prompt, string defaultValue = "")
{
this.Text = title;
this.ClientSize = new Size(400, 150);
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
var lblPrompt = new Label
{
Text = prompt,
Location = new Point(10, 10),
Width = 380
};
var txtInput = new TextBox
{
Text = defaultValue,
Location = new Point(10, 40),
Width = 380
};
var btnOk = new Button
{
Text = "確定",
DialogResult = DialogResult.OK,
Location = new Point(150, 80)
};
btnOk.Click += (s, e) =>
{
InputText = txtInput.Text;
this.Close();
};
this.Controls.AddRange(new Control[] { lblPrompt, txtInput, btnOk });
this.AcceptButton = btnOk;
}
}
}