diff options
| author | Michael <[email protected]> | 2017-02-19 11:30:11 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-19 11:30:11 -0500 |
| commit | b5a9b4caf2ae6e9d1712c65cbc1017ecbdad9ce4 (patch) | |
| tree | 31eb01fa2b09b3495728bc360fe14516310357be | |
| parent | 1a0d863263eed70268ae110d0f6b546a8e09325a (diff) | |
| download | shiftos_thereturn-b5a9b4caf2ae6e9d1712c65cbc1017ecbdad9ce4.tar.gz shiftos_thereturn-b5a9b4caf2ae6e9d1712c65cbc1017ecbdad9ce4.tar.bz2 shiftos_thereturn-b5a9b4caf2ae6e9d1712c65cbc1017ecbdad9ce4.zip | |
More Lua GUI functions
| -rw-r--r-- | ShiftOS.WinForms/GUIFunctions.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/GUIFunctions.cs b/ShiftOS.WinForms/GUIFunctions.cs index 5ee974c..ac058a6 100644 --- a/ShiftOS.WinForms/GUIFunctions.cs +++ b/ShiftOS.WinForms/GUIFunctions.cs @@ -140,11 +140,84 @@ namespace ShiftOS.WinForms lbl.AutoSize = false; return addToParent(parent, loc, size, lbl); } + + public dynamic menu(Control parent) + { + var mnu = new MenuStrip(); + parent.Controls.Add(mnu); + mnu.Dock = DockStyle.Top; + mnu.Show(); + return mnu; + } + + public dynamic menuitem(MenuStrip parent, string text, Action onClick = null) + { + var mitem = new ToolStripMenuItem(); + parent.Items.Add(mitem); + mitem.Text = text; + mitem.Click += (o, a) => + { + onClick?.Invoke(); + }; + return mitem; + } + + public dynamic menuitem(ToolStripMenuItem parent, string text, Action onClick = null) + { + var mitem = new ToolStripMenuItem(); + parent.DropDownItems.Add(mitem); + mitem.Text = text; + mitem.Click += (o, a) => + { + onClick?.Invoke(); + }; + return mitem; + } + + public dynamic textbox(Control parent, Point loc, int width) + { + var txt = new TextBox(); + txt.Location = loc; + txt.Width = width; + parent.Controls.Add(txt); + txt.Show(); + ControlManager.SetupControls(parent); + return txt; + } + + public dynamic timer(int interval, Action elapsed) + { + var tmr = new System.Windows.Forms.Timer(); + tmr.Interval = interval; + tmr.Tick += (o, a) => + { + elapsed?.Invoke(); + }; + return tmr; + } } [Exposed("clr")] public class CommonLanguageRuntimeInterop { + public void tryCode(Action code, Action<Exception> error) + { + try + { + code?.Invoke(); + } + catch (Exception ex) + { + error?.Invoke(ex); + } + } + + public void throwError(string error) + { + throw new Exception(error); + } + + public dynamic construct(Type type, dynamic[] ctorParams) { return Activator.CreateInstance(type, ctorParams); |
