/
MultiSplitContainer.cs
81 lines (71 loc) · 2.23 KB
/
MultiSplitContainer.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
using System.Windows.Forms;
using System.Collections.Generic;
class MultiSplitContainer : SplitContainer
{
private List<Control> _controls;
public List<Control> controls
{
get { return _controls; }
set
{
if (value != null)
{
if (value.Count >= 2)
{
_controls = value;
}
else
{
throw new System.Exception("Multi split needs atleast 2 controls");
}
}
}
}
public List<SplitContainer> childContainers = new List<SplitContainer>();
/// <summary>
/// # Will take the controls list and setup the multi split
/// </summary>
public void Init()
{
int controlCount = _controls.Count;
this.Panel1.Controls.Add(_controls[0]);
this.Panel2.Controls.Add(_controls[1]);
SplitContainer prevContainer = this;
for (int i = 2; i < controlCount; i++)
{
SplitContainer container = new SplitContainer();
container.Dock = DockStyle.Fill;
container.Orientation = this.Orientation;
container.SplitterWidth = this.SplitterWidth;
container.Panel1.Controls.Add(prevContainer.Panel2.Controls[0]);
container.Panel2.Controls.Add(_controls[i]);
prevContainer.Panel2.Controls.Clear();
prevContainer.Panel2.Controls.Add(container);
prevContainer = container;
childContainers.Add(container);
}
}
/// <summary>
/// # Will return back the child container of the index supplied.
/// </summary>
/// <param name="index">This is the child container index. Each control has it's own split container.</param>
public SplitContainer GetChildContainer(int index)
{
return childContainers[index];
}
/// <summary>
/// # Will return the panel of the control by the index supplied.
/// </summary>
/// <param name="index">control index</param>
public Panel GetPanel(int index)
{
if (index == 0)
{
return this.Panel1;
}
else
{
return childContainers[index].Panel2;
}
}
}