aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-02-18 14:04:51 -0500
committerMichael <[email protected]>2017-02-18 14:04:51 -0500
commit476b82264fe6f8cb1a6381d9a4fe4025505ee4a5 (patch)
tree6696bf4a4329d68283912ef6964feb57b241e0ab
parent423569f4ae2558b135f92d2f9cb7e163eb7bcc22 (diff)
downloadshiftos_thereturn-476b82264fe6f8cb1a6381d9a4fe4025505ee4a5.tar.gz
shiftos_thereturn-476b82264fe6f8cb1a6381d9a4fe4025505ee4a5.tar.bz2
shiftos_thereturn-476b82264fe6f8cb1a6381d9a4fe4025505ee4a5.zip
Flow, panel, button and label controls in lua
-rw-r--r--ShiftOS.WinForms/GUIFunctions.cs86
-rw-r--r--ShiftOS_TheReturn/Skinning.cs5
2 files changed, 91 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")]
diff --git a/ShiftOS_TheReturn/Skinning.cs b/ShiftOS_TheReturn/Skinning.cs
index 63dfe13..3a32c9f 100644
--- a/ShiftOS_TheReturn/Skinning.cs
+++ b/ShiftOS_TheReturn/Skinning.cs
@@ -55,6 +55,11 @@ namespace ShiftOS.Engine {
Utils.WriteAllText(Paths.GetPath("skin.json"), JsonConvert.SerializeObject(skn));
SkinEngine.LoadSkin();
}
+
+ public dynamic getImage(string id)
+ {
+ return SkinEngine.GetImage(id);
+ }
}