Improve documents

This commit is contained in:
Jack251970 2025-02-26 20:11:27 +08:00
parent 942ea3ec96
commit ed5e0bb2d9
3 changed files with 13 additions and 14 deletions

View file

@ -322,17 +322,16 @@ namespace Flow.Launcher.Plugin
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK); public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK);
/// <summary> /// <summary>
/// Displays a standardised Flow message box. /// Displays a standardised Flow progress box.
/// If there is issue when showing the message box, it will return null.
/// </summary> /// </summary>
/// <param name="caption">The caption of the message box.</param> /// <param name="caption">The caption of the progress box.</param>
/// <param name="reportProgressAsync"> /// <param name="reportProgressAsync">
/// Time-consuming task function, whose input is the action to report progress. /// Time-consuming task function, whose input is the action to report progress.
/// The input of the action is the progress value which is a double value between 0 and 100. /// The input of the action is the progress value which is a double value between 0 and 100.
/// If there are any exceptions, this action will be null. /// If there are any exceptions, this action will be null.
/// </param> /// </param>
/// <param name="forceClosed">When user closes the progress box manually by button or esc key, this action will be called.</param> /// <param name="cancelProgress">When user cancel the progress, this action will be called.</param>
/// <returns>A progress box interface.</returns> /// <returns></returns>
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action forceClosed = null); public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null);
} }
} }

View file

@ -8,15 +8,15 @@ namespace Flow.Launcher
{ {
public partial class ProgressBoxEx : Window public partial class ProgressBoxEx : Window
{ {
private readonly Action _forceClosed; private readonly Action _cancelProgress;
private ProgressBoxEx(Action forceClosed) private ProgressBoxEx(Action cancelProgress)
{ {
_forceClosed = forceClosed; _cancelProgress = cancelProgress;
InitializeComponent(); InitializeComponent();
} }
public static async Task ShowAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action forceClosed = null) public static async Task ShowAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null)
{ {
ProgressBoxEx prgBox = null; ProgressBoxEx prgBox = null;
try try
@ -25,7 +25,7 @@ namespace Flow.Launcher
{ {
await Application.Current.Dispatcher.InvokeAsync(() => await Application.Current.Dispatcher.InvokeAsync(() =>
{ {
prgBox = new ProgressBoxEx(forceClosed) prgBox = new ProgressBoxEx(cancelProgress)
{ {
Title = caption Title = caption
}; };
@ -35,7 +35,7 @@ namespace Flow.Launcher
} }
else else
{ {
prgBox = new ProgressBoxEx(forceClosed) prgBox = new ProgressBoxEx(cancelProgress)
{ {
Title = caption Title = caption
}; };
@ -113,7 +113,7 @@ namespace Flow.Launcher
private void ForceClose() private void ForceClose()
{ {
Close(); Close();
_forceClosed?.Invoke(); _cancelProgress?.Invoke();
} }
} }
} }

View file

@ -324,7 +324,7 @@ namespace Flow.Launcher
public MessageBoxResult ShowMsgBox(string messageBoxText, string caption = "", MessageBoxButton button = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.OK) => 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); MessageBoxEx.Show(messageBoxText, caption, button, icon, defaultResult);
public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action forceClosed = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, forceClosed); public Task ShowProgressBoxAsync(string caption, Func<Action<double>, Task> reportProgressAsync, Action cancelProgress = null) => ProgressBoxEx.ShowAsync(caption, reportProgressAsync, cancelProgress);
#endregion #endregion