-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMenuBarItemView.cs
More file actions
53 lines (41 loc) · 1.25 KB
/
MenuBarItemView.cs
File metadata and controls
53 lines (41 loc) · 1.25 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
using System;
using System.Collections.Generic;
using System.Linq;
namespace Terminal.Gui.Designer
{
public class MenuBarItemView : Dialog
{
public MenuBarItemView(MenuBarItem[] value, string name) : base(name)
{
Width = 50;
Height = 15;
var ok = new Button("Ok");
var cancel = new Button("Cancel");
var names = Enum.GetNames(value.GetType());
var list = new ListView();
ok.Clicked += () =>
{
if (ValueChanged != null)
{
var name1 = names[list.SelectedItem];
var val = Enum.Parse(value.GetType(), name1);
ValueChanged(this, val);
}
Application.RequestStop();
};
cancel.Clicked += () =>
{
Application.RequestStop();
};
list.Height = Dim.Fill() - 1;
list.Width = Dim.Fill();
list.SetSource(names);
ok.X = Pos.Bottom(list);
cancel.X = Pos.Bottom(list);
Add(list);
AddButton(ok);
AddButton(cancel);
}
public event EventHandler<object> ValueChanged;
}
}