Repository navigation
Expand file tree
/
Copy pathControlListView.cs
More file actions
69 lines (60 loc) · 1.94 KB
/
Copy pathControlListView.cs
File metadata and controls
69 lines (60 loc) · 1.94 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
using System.Linq;
namespace Terminal.Gui.Designer
{
public class ControlListView : FrameView
{
private readonly DesignerState _state;
private readonly List<Type> _controlList = new List<Type>() {
typeof(Button),
typeof(CheckBox),
typeof(ComboBox),
typeof(DateField),
typeof(FrameView),
typeof(GraphView),
typeof(HexView),
typeof(Label),
typeof(ListView),
typeof(MenuBar),
typeof(ProgressBar),
typeof(RadioGroup),
typeof(TableView),
typeof(TimeField),
typeof(TextField),
typeof(TextValidateField),
typeof(TextView),
typeof(TreeView),
typeof(ScrollView),
typeof(ScrollBarView),
typeof(StatusBar),
typeof(Window)
};
private DateTime _lastEnter = DateTime.MinValue;
public ControlListView(DesignerState state) : base("Toolbox")
{
_state = state;
var controlsListView = new ListView()
{
Width = Dim.Fill(),
Height = Dim.Fill()
};
controlsListView.SetSource(_controlList.Select(m => m.Name).ToArray());
Add(controlsListView);
controlsListView.MouseClick += (args) =>
{
if (args.MouseEvent.Flags == MouseFlags.Button1DoubleClicked)
{
if (DateTime.Now - _lastEnter < TimeSpan.FromSeconds(1))
{
return;
}
var item = _controlList[controlsListView.SelectedItem];
var view = _state.CreateView(item);
_state.Add(view);
_lastEnter = DateTime.Now;
}
};
}
}
}