-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UITabs.cs
74 lines (56 loc) · 2.12 KB
/
UITabs.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
71
72
73
74
using System;
using System.Windows.Forms;
using System.Collections.Generic;
namespace WinForMono {
public class UITabs : UIElement {
public class UITabPage : UIElement {
public UITabPage(string name) {
derived_underlying = new TabPage(name);
CALL_THIS_AFTER_CONSTRUCTION_PLEASE();
}
public override Control underlying {
get => (Control)derived_underlying;
set => derived_underlying = (TabPage)value;
}
private TabPage derived_underlying;
}
public UITabs() {
derived_underlying = new TabControl();
pages = new Dictionary<string, UITabPage>();
}
public UITabs(params string[] tabs) {
derived_underlying = new TabControl();
pages = new Dictionary<string, UITabPage>();
foreach (string s in tabs) { this.add_tab(s); }
}
public void add_tab(string name) {
UITabPage new_page = new UITabPage(name);
add_element(new_page);
pages[name] = new_page;
}
public void bind_tab(string name) {
UIElement.bind_parent(pages[name]);
}
public UITabPage get_tab(string name) => pages[name];
public void remove_tab(string name, bool error=true) {
if (pages.ContainsKey(name)) {
remove_element(pages[name]);
pages.Remove(name);
} else {
if (error) throw new Exception("Attempt to remove tab that didn't exist!");
}
}
public void add_tab_element(string tab_name, UIElement element) {
element.parent = pages[tab_name];
}
public void remove_tab_element(string tab_name, UIElement element) {
element.parent = WinformWrapper.NULL;
}
private Dictionary<string, UITabPage> pages;
public override Control underlying {
get => (Control)derived_underlying;
set => derived_underlying = (TabControl)value;
}
private TabControl derived_underlying;
}
}