aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GUI/ItemGroup.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-07-02 21:48:10 -0400
committerMichael <[email protected]>2017-07-02 21:48:10 -0400
commit6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604 (patch)
tree9f138619a1cf4ebe7a7ece6c6a411adbe64843d6 /ShiftOS.Frontend/GUI/ItemGroup.cs
parent5d5f351138b55b27fe92690d824257b6b6e1a469 (diff)
downloadshiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.gz
shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.tar.bz2
shiftos_thereturn-6f3a5cba2ea08ea6f442e2336b74f32f4bbc0604.zip
A day's worth of hell... which is turning into heaven.
Diffstat (limited to 'ShiftOS.Frontend/GUI/ItemGroup.cs')
-rw-r--r--ShiftOS.Frontend/GUI/ItemGroup.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/ShiftOS.Frontend/GUI/ItemGroup.cs b/ShiftOS.Frontend/GUI/ItemGroup.cs
new file mode 100644
index 0000000..e52a17f
--- /dev/null
+++ b/ShiftOS.Frontend/GUI/ItemGroup.cs
@@ -0,0 +1,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
+ }
+}