From 02fd7a883b4592a2200c4f3e912e56bdc09bfdbc Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Mar 2017 09:53:00 -0500 Subject: [PATCH] callback action can be fired when user closes infobox --- ShiftOS.WinForms/Applications/Dialog.cs | 6 +++++- ShiftOS_TheReturn/Infobox.cs | 6 +++--- ShiftOS_TheReturn/Scripting.cs | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ShiftOS.WinForms/Applications/Dialog.cs b/ShiftOS.WinForms/Applications/Dialog.cs index 26e3040..11fbf1e 100644 --- a/ShiftOS.WinForms/Applications/Dialog.cs +++ b/ShiftOS.WinForms/Applications/Dialog.cs @@ -76,12 +76,16 @@ namespace ShiftOS.WinForms.Applications btnok.Click += (o, a) => { AppearanceManager.Close(this); + OpenCallback?.Invoke(); }; } - public void Open(string title, string msg) + private Action OpenCallback = null; + + public void Open(string title, string msg, Action c = null) { + OpenCallback = c; new Dialog().OpenInternal(title, msg); } diff --git a/ShiftOS_TheReturn/Infobox.cs b/ShiftOS_TheReturn/Infobox.cs index 3e8fa30..e3308dc 100644 --- a/ShiftOS_TheReturn/Infobox.cs +++ b/ShiftOS_TheReturn/Infobox.cs @@ -55,11 +55,11 @@ namespace ShiftOS.Engine /// /// Infobox title /// Infobox message - public static void Show(string title, string message) + public static void Show(string title, string message, Action callback = null) { title = Localization.Parse(title); message = Localization.Parse(message); - _infobox.Open(title, message); + _infobox.Open(title, message, callback); } public static void PromptText(string title, string message, Action callback) @@ -89,7 +89,7 @@ namespace ShiftOS.Engine // Infobox Interface public interface IInfobox { - void Open(string title, string msg); + void Open(string title, string msg, Action callback = null); void PromptText(string title, string message, Action callback); void PromptYesNo(string title, string message, Action callback); } diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 940e998..b3e5208 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -357,9 +357,9 @@ end"); [Exposed("infobox")] public class InfoboxFunctions { - public void show(string title, string message) + public void show(string title, string message, Action callback = null) { - Infobox.Show(title, message); + Infobox.Show(title, message, callback); } public void question(string title, string message, Action callback)