From 9b8d5861a954610713ae66a53d2ac067991d9b68 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 18 Feb 2017 10:37:11 -0500 Subject: WHOA LUA STUFF :dancer: --- ShiftOS.WinForms/GUIFunctions.cs | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 ShiftOS.WinForms/GUIFunctions.cs (limited to 'ShiftOS.WinForms/GUIFunctions.cs') 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) + { + + } + } +} -- cgit v1.2.3