aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/GUIFunctions.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-02-18 10:37:11 -0500
committerMichael <[email protected]>2017-02-18 10:37:11 -0500
commit9b8d5861a954610713ae66a53d2ac067991d9b68 (patch)
treee550f758e52ec8ca12357d91c9fa13907e70c4f3 /ShiftOS.WinForms/GUIFunctions.cs
parent30823a0778614d0f9fd6f82b5d9eb03aab41280d (diff)
downloadshiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.gz
shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.tar.bz2
shiftos_thereturn-9b8d5861a954610713ae66a53d2ac067991d9b68.zip
WHOA LUA STUFF :dancer:
Diffstat (limited to 'ShiftOS.WinForms/GUIFunctions.cs')
-rw-r--r--ShiftOS.WinForms/GUIFunctions.cs85
1 files changed, 85 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/GUIFunctions.cs b/ShiftOS.WinForms/GUIFunctions.cs
new file mode 100644
index 0000000..edccea9
--- /dev/null
+++ b/ShiftOS.WinForms/GUIFunctions.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ShiftOS.Engine.Scripting;
+using System.Drawing;
+using ShiftOS.Engine;
+
+namespace ShiftOS.WinForms
+{
+ [Exposed("gui")]
+ public class GUIFunctions
+ {
+ public dynamic color(int r, int g, int b)
+ {
+ return Color.FromArgb(r, g, b);
+ }
+
+ public dynamic color(string name)
+ {
+ return Color.FromName(name);
+ }
+
+ public dynamic point(int x, int y)
+ {
+ return new Point(x, y);
+ }
+
+ public dynamic size(int w, int h)
+ {
+ return new Size(w, h);
+ }
+
+ public dynamic font(string name, float size, bool bold, bool italic, bool strikethrough, bool underline)
+ {
+ FontStyle fs = FontStyle.Regular;
+ if (bold)
+ fs = fs | FontStyle.Bold;
+ if (italic)
+ fs = fs | FontStyle.Italic;
+ if (underline)
+ fs = fs | FontStyle.Underline;
+ if (strikethrough)
+ fs = fs | FontStyle.Strikeout;
+
+ return new Font(name, size, fs);
+ }
+
+ public dynamic createWindow(string name, dynamic size)
+ {
+ var win = new Window();
+ win.Size = size;
+ AppearanceManager.SetupWindow(win);
+ return win;
+ }
+ }
+
+ [Exposed("clr")]
+ public class CommonLanguageRuntimeInterop
+ {
+ public dynamic construct(Type type, dynamic[] ctorParams)
+ {
+ return Activator.CreateInstance(type, ctorParams);
+ }
+
+ public dynamic typeOf(string typeName)
+ {
+ return Type.GetType(typeName);
+ }
+
+ public void throwException(string message)
+ {
+ throw new UserException(message);
+ }
+ }
+
+ public class UserException : Exception
+ {
+ public UserException(string message) :base("User threw exception using clr:throwException().\r\n\r\n" + message)
+ {
+
+ }
+ }
+}