-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoToLineDialog.cs
More file actions
54 lines (48 loc) · 1.55 KB
/
GoToLineDialog.cs
File metadata and controls
54 lines (48 loc) · 1.55 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
namespace MarkdownThing
{
internal sealed class GoToLineDialog : Form
{
private readonly NumericUpDown _lineNumber = new()
{
Minimum = 1,
Maximum = 1_000_000,
Width = 120,
Location = new Point(12, 36)
};
public int SelectedLine => (int)_lineNumber.Value;
public GoToLineDialog(int maxLine, int currentLine)
{
Text = "Go to line";
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
StartPosition = FormStartPosition.CenterParent;
ClientSize = new Size(280, 110);
var label = new Label
{
Text = "Line number:",
AutoSize = true,
Location = new Point(12, 16)
};
_lineNumber.Maximum = Math.Max(1, maxLine);
_lineNumber.Value = Math.Clamp(currentLine, 1, _lineNumber.Maximum);
var ok = new Button
{
Text = "Go",
DialogResult = DialogResult.OK,
Location = new Point(112, 66),
Width = 75
};
var cancel = new Button
{
Text = "Cancel",
DialogResult = DialogResult.Cancel,
Location = new Point(192, 66),
Width = 75
};
Controls.AddRange([label, _lineNumber, ok, cancel]);
AcceptButton = ok;
CancelButton = cancel;
}
}
}