@@ -22,6 +22,17 @@ public static class MessageBoxHelper
2222 /// show a confirm box on owner, the default value owner is MainWindowViewModel
2323 /// </summary>
2424 public static bool Confirm(string content, string title = "", bool useNativeBox = false, object? ownerViewModel = null)
25+ {
26+ return Confirm(content,
27+ IoC.Get<ILanguageService>().Translate("OK"),
28+ IoC.Get<ILanguageService>().Translate("Cancel"),
29+ title, useNativeBox, ownerViewModel);
30+ }
31+
32+ /// <summary>
33+ /// show a confirm box on owner, the default value owner is MainWindowViewModel
34+ /// </summary>
35+ public static bool Confirm(string content, string yesButtonText, string noButtonText, string title = "", bool useNativeBox = false, object? ownerViewModel = null)
2536 {
2637 if (string.IsNullOrEmpty(title))
2738 title = IoC.Get<ILanguageService>().Translate("Warning");
@@ -56,14 +67,17 @@ public static bool Confirm(string content, string title = "", bool useNativeBox
5667 buttons: MessageBoxButton.YesNo,
5768 buttonLabels: new Dictionary<MessageBoxResult, string>()
5869 {
59- { MessageBoxResult.Yes, IoC.Get<ILanguageService>().Translate("OK") },
60- { MessageBoxResult.No, IoC.Get<ILanguageService>().Translate("Cancel") },
70+ { MessageBoxResult.Yes, yesButtonText },
71+ { MessageBoxResult.No, noButtonText },
6172 });
6273 if (vm is Screen screen)
6374 {
6475 screen.Activated += MessageBoxOnActivated;
6576 }
66- IoC.Get<IWindowManager>().ShowDialog(vm, ownerViewAware ?? mainWindowViewModel);
77+ Execute.OnUIThreadSync(() =>
78+ {
79+ IoC.Get<IWindowManager>().ShowDialog(vm, ownerViewAware ?? mainWindowViewModel);
80+ });
6781 var ret = MessageBoxResult.Yes == vm.ClickedButton;
6882 if (layerContainer != null)
6983 MaskLayerController.HideMask(layerId, layerContainer);
0 commit comments