aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms
diff options
context:
space:
mode:
Diffstat (limited to 'ShiftOS.WinForms')
-rw-r--r--ShiftOS.WinForms/GUIFunctions.cs86
1 files changed, 86 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/GUIFunctions.cs b/ShiftOS.WinForms/GUIFunctions.cs
index edccea9..5ee974c 100644
--- a/ShiftOS.WinForms/GUIFunctions.cs
+++ b/ShiftOS.WinForms/GUIFunctions.cs
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
using ShiftOS.Engine.Scripting;
using System.Drawing;
using ShiftOS.Engine;
+using System.Windows.Forms;
+using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms
{
@@ -54,6 +56,90 @@ namespace ShiftOS.WinForms
AppearanceManager.SetupWindow(win);
return win;
}
+
+ public dynamic panel(Control parent, Point loc, Size size)
+ {
+ var pnl = new Panel();
+ pnl.Location = loc;
+ pnl.Size = size;
+ parent.Controls.Add(pnl);
+ pnl.Show();
+ return pnl;
+ }
+
+ public DockStyle dock(string type)
+ {
+ DockStyle d = DockStyle.None;
+ switch (type.ToLower())
+ {
+ case "top":
+ d = DockStyle.Top;
+ break;
+ case "bottom":
+ d = DockStyle.Bottom;
+ break;
+ case "left":
+ d = DockStyle.Left;
+ break;
+ case "right":
+ d = DockStyle.Right;
+ break;
+ case "fill":
+ d = DockStyle.Fill;
+ break;
+ }
+ return d;
+ }
+
+ public AnchorStyles anchor(bool top, bool left, bool bottom, bool right)
+ {
+ AnchorStyles a = AnchorStyles.None;
+ if (top)
+ a = a | AnchorStyles.Top;
+ if (left)
+ a = a | AnchorStyles.Left;
+ if (bottom)
+ a = a | AnchorStyles.Bottom;
+ if (right)
+ a = a | AnchorStyles.Right;
+ return a;
+ }
+
+ public dynamic flow(Control parent, Point loc, Size size)
+ {
+ var pnl = new FlowLayoutPanel();
+ pnl.Size = size;
+ pnl.Location = loc;
+ parent.Controls.Add(pnl);
+ pnl.Show();
+ return pnl;
+ }
+
+ private Control addToParent(Control parent, Point loc, Size size, Control newControl)
+ {
+ newControl.Size = size;
+ newControl.Location = loc;
+ parent.Controls.Add(newControl);
+ newControl.Show();
+ ControlManager.SetupControls(parent);
+ return newControl;
+ }
+
+ public dynamic button(Control parent, Point loc, Size size, string text)
+ {
+ var btn = new Button();
+ btn.Text = text;
+ btn.AutoSize = false;
+ return addToParent(parent, loc, size, btn);
+ }
+
+ public dynamic label(Control parent, Point loc, Size size, string text)
+ {
+ var lbl = new Label();
+ lbl.Text = text;
+ lbl.AutoSize = false;
+ return addToParent(parent, loc, size, lbl);
+ }
}
[Exposed("clr")]