-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathStringListView.cs
More file actions
51 lines (42 loc) · 1.38 KB
/
StringListView.cs
File metadata and controls
51 lines (42 loc) · 1.38 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.Collections.Generic;
using System.Linq;
using NStack;
namespace Terminal.Gui.Designer
{
public class StringListView : Dialog
{
public StringListView(ustring[] values, string name) : base(name)
{
Width = 50;
Height = 15;
var ok = new Button("Ok");
var cancel = new Button("Cancel");
var textField = new TextView();
textField.Height = 12;
textField.Width = Dim.Fill();
var str = string.Join("\n", values.Select(m => m.ToString()));
textField.Text = str;
ok.Clicked += () =>
{
if (ValueChanged != null)
{
var text = textField.Text.ToString();
var vals = text.Split('\n').Select(m => m.TrimEnd()).Where(m => !string.IsNullOrEmpty(m)).Select(m => ustring.Make(m)).ToArray();
ValueChanged(this, vals);
}
Application.RequestStop();
};
cancel.Clicked += () =>
{
Application.RequestStop();
};
ok.X = Pos.Bottom(textField);
cancel.X = Pos.Bottom(textField);
Add(textField);
AddButton(ok);
AddButton(cancel);
}
public event EventHandler<object> ValueChanged;
}
}