From b568d2dd950cf85ae3ff652ec526c5d9ea305d6d Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sun, 1 Dec 2024 19:55:07 +0800
Subject: [PATCH] Combine ShowMsgBox into one function.
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 81 ++-----------------
Flow.Launcher/PublicAPIInstance.cs | 12 +--
2 files changed, 9 insertions(+), 84 deletions(-)
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index a747ba340..282bb6e43 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -299,81 +299,16 @@ 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.
+ /// Displays a message box like
///
- /// 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);
+ /// The message of the message box.
+ /// The caption of the message box.
+ /// Specifies which button or buttons to display.
+ /// Specifies the icon to display.
+ /// Specifies the default result of the message box.
+ /// Specifies which message box button is clicked by the user.
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK);
}
}
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 33739bda2..0e567cdd4 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -319,17 +319,7 @@ 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) =>
+ public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK) =>
MessageBoxEx.Show(messageBoxText, caption, button, icon, defaultResult);
#endregion