/
ControlCollection.cs
103 lines (85 loc) · 1.82 KB
/
ControlCollection.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Linq;
using AppKit;
namespace System.Windows.Forms
{
public class ControlCollection
{
private NSView theView;
public ControlCollection (NSView view)
{
theView = view;
}
public void Add (Control item)
{
theView.AddSubview (item);
SetTab ();
}
public void AddRange (Control[] InControls)
{
foreach (var view in InControls)
{
theView.AddSubview (view);
}
}
public void Clear ()
{
foreach (var view in theView.Subviews)
{
view.RemoveFromSuperview ();
}
}
public bool Contains (Control item)
{
return theView.Subviews.Contains (item);
}
public void CopyTo (Control[] array, int arrayIndex)
{
theView.Subviews.CopyTo (array, arrayIndex);
}
public Control[] GetAllControls ()
{
return theView.Subviews.Select(x=> (x as IViewHelper).Host).ToArray();
}
public bool Remove (Control item)
{
item.NSViewForControl.RemoveFromSuperview ();
SetTab ();
return true;
}
public int Count {
get { return theView.Subviews.Count (); }
}
public bool IsReadOnly {
get { return false; }
}
public int IndexOf (Control item)
{
return theView.Subviews.ToList ().IndexOf (item);
}
public void Insert (int index, Control item)
{
if (index == 0)
{
theView.AddSubview (item, NSWindowOrderingMode.Below, null);
return;
}
var rowBelow = theView.Subviews[index - 1];
theView.AddSubview (item, NSWindowOrderingMode.Below, rowBelow);
SetTab ();
}
public void RemoveAt (int index)
{
theView.Subviews[index].RemoveFromSuperview ();
SetTab ();
}
public Control this[int index] {
get { return (theView.Subviews[index] as IViewHelper).Host ; }
set { theView.Subviews[index] = value; }
}
//TODO: Make it work, It doesn't work as is
public void SetTab ()
{
}
}
}