blob: e52a17f3fa7986df86cca2a6e635b472d56be844 (
plain) (
blame)
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Frontend.GUI
{
public class ItemGroup : Control
{
private int _gap = 3;
private FlowDirection _flowDir = FlowDirection.LeftToRight;
private int _initialgap = 2;
protected override void OnLayout()
{
if (AutoSize)
{
int _highesty = _initialgap;
int _xx = _initialgap;
foreach(var ctrl in Children)
{
_xx += ctrl.Width + _gap;
if (_highesty < ctrl.Height + _initialgap + _gap)
_highesty = ctrl.Height + _initialgap + _gap;
}
Width = _xx;
Height = _highesty;
}
int _x = _initialgap;
int _y = _initialgap;
int _maxYForRow = 0;
foreach (var ctrl in Children)
{
if (_x + ctrl.Width + _gap > Width)
{
_x = _initialgap;
_y = _maxYForRow;
_maxYForRow = 0;
if (_maxYForRow < ctrl.Height + _gap)
_maxYForRow = ctrl.Height + _gap;
}
ctrl.X = _x;
ctrl.Y = _y;
ctrl.Dock = DockStyle.None;
ctrl.Layout();
_x += ctrl.Width + _gap;
if (_maxYForRow < ctrl.Height + _gap)
_maxYForRow = ctrl.Height + _gap;
}
}
}
public enum FlowDirection
{
LeftToRight,
TopDown,
RightToLeft,
BottomUp
}
}
|