aboutsummaryrefslogtreecommitdiff
path: root/source/WindowsFormsApplication1/Engine
diff options
context:
space:
mode:
authorMichaelTheShifter <[email protected]>2016-07-05 18:29:22 -0400
committerMichaelTheShifter <[email protected]>2016-07-05 18:29:22 -0400
commitb2b7d4c442dffc518f0f29d3fabb9c06ea9c4229 (patch)
tree60eaef98a9bfe60748b457471970e8ec5c54fd53 /source/WindowsFormsApplication1/Engine
parentad0e84c4be1411321e36a9f6ab022195c0d006b3 (diff)
downloadshiftos-c-_theultimatehacker-b2b7d4c442dffc518f0f29d3fabb9c06ea9c4229.tar.gz
shiftos-c-_theultimatehacker-b2b7d4c442dffc518f0f29d3fabb9c06ea9c4229.tar.bz2
shiftos-c-_theultimatehacker-b2b7d4c442dffc518f0f29d3fabb9c06ea9c4229.zip
on_window_open(userdata ShiftOSDesktop,
string) and on_window_close(userdata ShiftOSDesktop, string) now report window GUIDs to their handlers instead of userdata Form objects. You can now use get_window(string) to get a Form from a window GUID.
Diffstat (limited to 'source/WindowsFormsApplication1/Engine')
-rw-r--r--source/WindowsFormsApplication1/Engine/Lua_Interp.cs52
1 files changed, 38 insertions, 14 deletions
diff --git a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs
index 5b338ae..529518e 100644
--- a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs
+++ b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs
@@ -137,16 +137,24 @@ namespace ShiftOS
{
desktop.WindowOpened += (win) =>
{
- mod.win = win;
- mod(func + "(win)");
+ mod(func + $"(\"{API.OpenGUIDs[win]}\")");
};
});
+ mod.get_window = new Func<string, Form>((guid) =>
+ {
+ Form frm = null;
+ foreach(var kv in API.OpenGUIDs)
+ {
+ if (kv.Value == guid)
+ frm = kv.Key;
+ }
+ return frm;
+ });
mod.on_window_close += new Action<ShiftOSDesktop, string>((desktop, func) =>
{
desktop.WindowClosed += (win) =>
{
- mod.win = win;
- mod(func + "(win)");
+ mod(func + $"(\"{API.OpenGUIDs[win]}\")");
};
});
mod.on_window_titlebar_redraw += new Action<ShiftOSDesktop, string>((desktop, func) =>
@@ -342,6 +350,25 @@ end");
mod.json_serialize = new Func<object, string>((objectToSerialize) => Newtonsoft.Json.JsonConvert.SerializeObject(objectToSerialize));
mod.json_unserialize = new Func<string, object>((json_string) => Newtonsoft.Json.JsonConvert.DeserializeObject(json_string));
mod.open_image = new Func<string, Image>((filename) => OpenImage(filename));
+ mod.list_add = new Action<Control, string>((lst, itm) =>
+ {
+ if(lst is ListBox)
+ {
+ var box = lst as ListBox;
+ box.Items.Add(itm);
+ }
+ });
+ mod.list_get_selected = new Func<Control, string>((lst) =>
+ {
+ if(lst is ListBox)
+ {
+ return (lst as ListBox).SelectedItem?.ToString();
+ }
+ else
+ {
+ return null;
+ }
+ });
mod.get_skin = new Func<Skinning.Skin>(() =>
{
return API.CurrentSkin;
@@ -618,16 +645,9 @@ end");
mod.toggle_unity = new Action(() => API.CurrentSession.SetUnityMode());
mod.lua = new Func<string, string>((luacode) =>
{
- var li = new LuaInterpreter();
- try
- {
- li.mod(luacode);
- return "success";
- }
- catch (Exception ex)
- {
- return ex.Message;
- }
+ mod(luacode);
+ return "success";
+
});
mod.fileskimmer_open += new Action<string, string>((filters, func) =>
{
@@ -1063,6 +1083,10 @@ end");
stxt.SetLanguage(SyntaxSettings.Language.Lua);
ctrl = stxt;
break;
+ case "list":
+ var lst = new ListBox();
+ ctrl = lst;
+ break;
case "button":
var btn = new Button();
btn.FlatStyle = FlatStyle.Flat;