From 9b75acdf217b0f93c942d7cbde5e31015158378d Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Wed, 27 Nov 2024 10:07:03 +0800
Subject: [PATCH] Add ShowMsgBox functions in public api
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 77 +++++++++++++++++++
Flow.Launcher/PublicAPIInstance.cs | 14 ++++
2 files changed, 91 insertions(+)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index c95a8ce7b..a747ba340 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -7,6 +7,7 @@ using System.IO;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows;
namespace Flow.Launcher.Plugin
{
@@ -298,5 +299,81 @@ namespace Flow.Launcher.Plugin
///
/// Choose the first result after reload if true; keep the last selected result if false. Default is true.
public void ReQuery(bool reselect = true);
+
+ ///
+ /// Displays a message box that has a message and that returns a result.
+ ///
+ /// A System.String that specifies the text to display.
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies which message box button
+ /// is clicked by the user.
+ ///
+ public MessageBoxResult ShowMsgBox(string messageBoxText);
+
+ ///
+ /// Displays a message box that has a message and title bar caption; and that returns
+ /// a result.
+ ///
+ /// A System.String that specifies the text to display.
+ /// A System.String that specifies the title bar caption to display.
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies which message box button
+ /// is clicked by the user.
+ ///
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption);
+
+ ///
+ /// Displays a message box that has a message, title bar caption, and button; and
+ /// that returns a result.
+ ///
+ /// A System.String that specifies the text to display.
+ /// A System.String that specifies the title bar caption to display.
+ ///
+ /// A System.Windows.MessageBoxButton value that specifies which button or buttons
+ /// to display.
+ ///
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies which message box button
+ /// is clicked by the user.
+ ///
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button);
+
+ ///
+ /// Displays a message box that has a message, title bar caption, button, and icon;
+ /// and that returns a result.
+ ///
+ /// A System.String that specifies the text to display.
+ /// A System.String that specifies the title bar caption to display.
+ ///
+ /// A System.Windows.MessageBoxButton value that specifies which button or buttons
+ /// to display.
+ ///
+ /// A System.Windows.MessageBoxImage value that specifies the icon to display.
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies which message box button
+ /// is clicked by the user.
+ ///
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon);
+
+ ///
+ /// Displays a message box that has a message, title bar caption, button, and icon;
+ /// and that accepts a default message box result and returns a result.
+ ///
+ /// A System.String that specifies the text to display.
+ /// A System.String that specifies the title bar caption to display.
+ ///
+ /// A System.Windows.MessageBoxButton value that specifies which button or buttons
+ /// to display.
+ ///
+ /// A System.Windows.MessageBoxImage value that specifies the icon to display.
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies the default result of
+ /// the message box.
+ ///
+ ///
+ /// A System.Windows.MessageBoxResult value that specifies which message box button
+ /// is clicked by the user.
+ ///
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult);
}
}
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 20b02ddee..33739bda2 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -25,6 +25,7 @@ using Flow.Launcher.Infrastructure.Storage;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Collections.Specialized;
+using Flow.Launcher.Core;
namespace Flow.Launcher
{
@@ -318,6 +319,19 @@ namespace Flow.Launcher
public void ReQuery(bool reselect = true) => _mainVM.ReQuery(reselect);
+ public MessageBoxResult ShowMsgBox(string messageBoxText) => MessageBoxEx.Show(messageBoxText);
+
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption) => MessageBoxEx.Show(messageBoxText, caption);
+
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button) =>
+ MessageBoxEx.Show(messageBoxText, caption, button);
+
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon) =>
+ MessageBoxEx.Show(messageBoxText, caption, button, icon);
+
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) =>
+ MessageBoxEx.Show(messageBoxText, caption, button, icon, defaultResult);
+
#endregion
#region Private Methods