-
Notifications
You must be signed in to change notification settings - Fork 2
/
MappingsDialog.cs
70 lines (58 loc) · 1.58 KB
/
MappingsDialog.cs
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
using Terminal.Gui;
namespace AppCompare;
public class MappingsDialog : Dialog {
readonly Button map;
readonly Button cancel;
readonly TextField tf;
readonly ComboBox cf;
public MappingsDialog (string? fileA, string? fileB, List<string> list) : base ("Map Files")
{
Label file1label = new ("File A:") {
X = 1,
Y = 1,
};
Label file2label = new ("File B:") {
X = 1,
Y = Pos.Bottom (file1label) + 1,
};
cf = new () {
X = Pos.Right (file1label) + 1,
Y = fileA is null ? file1label.Y : file2label.Y,
Width = Dim.Fill () - 1,
Height = list.Count + 1,
ReadOnly = true,
Text = "",
};
cf.SetSource (list);
cf.SelectedItemChanged += SelectionChanged;
tf = new () {
X = Pos.Right (file2label) + 1,
Y = fileB is null ? file1label.Y : file2label.Y,
Width = Dim.Fill () - 1,
ReadOnly = true,
Text = fileA ?? fileB,
};
Height = 12;
Add (file1label, fileA is null ? cf : tf, file2label, fileB is null ? cf : tf);
map = new ("Map", true);
map.Clicked += () => {
FileA = (fileA is null ? cf.Text : tf.Text).ToString ();
FileB = (fileB is null ? cf.Text : tf.Text).ToString ();
Application.RequestStop ();
};
cancel = new ("Cancel");
cancel.Clicked += () => {
FileA = null;
FileB = null;
Application.RequestStop ();
};
AddButton (map);
AddButton (cancel);
}
void SelectionChanged (ListViewItemEventArgs obj)
{
map.Enabled = !string.IsNullOrEmpty (cf.Text.ToString ()) && !string.IsNullOrEmpty (tf.Text.ToString ());
}
public string? FileA { get; private set; }
public string? FileB { get; private set; }
}