From 7a8e910697a88de1542d7cd453e99cee89d3ea70 Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 14 Jul 2022 00:50:50 -0600 Subject: [PATCH] Add Avalonia MessageBox --- .../AvaloniaUI/Assets/MBIcons/Asterisk.png | Bin 0 -> 2471 bytes .../AvaloniaUI/Assets/MBIcons/Exclamation.png | Bin 0 -> 1864 bytes .../AvaloniaUI/Assets/MBIcons/Question.png | Bin 0 -> 2538 bytes .../AvaloniaUI/Assets/MBIcons/error.png | Bin 0 -> 2375 bytes .../ViewModels/Dialogs/MessageBoxViewModel.cs | 77 ++++++ .../ViewModels/MainWindowViewModel.cs | 12 + .../AvaloniaUI/ViewModels/ProcessBook2.cs | 23 +- .../AvaloniaUI/Views/Dialogs/MessageBox.cs | 240 ++++++++++++++++++ .../Views/Dialogs/MessageBoxWindow.axaml | 41 +++ .../Views/Dialogs/MessageBoxWindow.axaml.cs | 115 +++++++++ .../MainWindow/MainWindow.Export.axaml.cs | 5 +- .../MainWindow/MainWindow.Filter.axaml.cs | 16 +- .../MainWindow/MainWindow.Liberate.axaml.cs | 9 +- .../MainWindow.ProcessQueue.axaml.cs | 5 +- .../MainWindow/MainWindow.ScanManual.axaml.cs | 7 +- .../MainWindow/MainWindow.Settings.axaml.cs | 7 +- .../Views/MainWindow/MainWindow.axaml | 4 +- .../Views/MainWindow/MainWindow.axaml.cs | 34 ++- .../ProductsDisplay2.Buttons.xaml.cs | 2 +- .../LibationWinForms/LibationWinForms.csproj | 8 + 20 files changed, 570 insertions(+), 35 deletions(-) create mode 100644 Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png create mode 100644 Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Exclamation.png create mode 100644 Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Question.png create mode 100644 Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/error.png create mode 100644 Source/LibationWinForms/AvaloniaUI/ViewModels/Dialogs/MessageBoxViewModel.cs create mode 100644 Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs create mode 100644 Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBox.cs create mode 100644 Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml create mode 100644 Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml.cs diff --git a/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png b/Source/LibationWinForms/AvaloniaUI/Assets/MBIcons/Asterisk.png new file mode 100644 index 0000000000000000000000000000000000000000..c345a8f9df11890ea4999481630d70e81f4ad609 GIT binary patch literal 2471 zcmV;Y30U@tP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2|P(eK~z{r#aC%i zQ&|@Ff6w%f`7tvk0*Zi*3nDIPk1bh90z^O%cSQvRL~uc{K~Ygaz-1g4Y_%;x92I3Z z2}ux0kR_~wM37ZTgP>B*bla`fqvAK`z9e+J%#2-KU303w%FBEAo$tHnoO|wl<3855 zgooP^HV{q|v;+g;M-$jJyT_ifF?Occe!Y=1-maLKi*d2B-(_TEywGa3qg`EHc>44y zUcGw7fnBqE>=_%w#Rx0fJL{5SV-)K?ho}abGRM_9?MHH3RCBau%64%m?$u ze45<^m_f9-Ukm*qG`nWoBu%c>4(^SY#1R&A0hDYW2{RahF|<3yy6V- z+tY^?dwa2b&wZ@e-Hes7H3;}pfrQkrDK*_-zL-zu+eGtWV=CD|gTa9Mh6WVe>Yy19 zA?(OQ1RZ{YjVX_@Hu*8uBo1T6fnl7;dxk4z&k=TX2%gbh@QLk$*RFPW?Ys-0C>{Kx z)Ch?=kBZw>U_MPEJ{$>pV8cSi)H3p{o1NHtydQxn12o%5Sd%o2)rpU=>fjK~d;qG3 zf5B`&yaYC-^g+C>9Uf6_kZivTQRE#+B6RSMR3TuyQ3UgCO2_*(!HR|Di-kQSrvZ`2 z`Vf$0Ai{@ObzlH15{&SRH(+hz0A9Z_v778#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<@wb)HHU3p7(>+&Q29Pj&tHqd@m%0fPhQNq+knPe;qA6 z2Oh}8WR$M(bSz@ntGT9zwlZIQ5k8|H2IGjsNQ6v=kK;VvYEoW#1+m;9AwEq_=J8v5 z`7&acMc@biF9SsgNWW)N1zd7nNG)Lv1#)s=;KfBkU&pl$?y*gnh&&Q{>~Sm-x{!1+ z*XL%0A%Xc9PX$o)kJ?k_xui!3NchEjsd62`#aqdnoWEUkqPLn@A#&BRGz2_&p5?iID`<7JbC~Qfd{~)KXpCV<&h9+q5M&_dj1s zL&62a*K$dR92{p}eHC#mAgO$*jYkPck4u}G$Bab{fo)uy`@##z=PfD7!Suw}@{kBi z303IBq?PSe_Qeq-PMwBW<}-!H(@7?aBrZ`eQ}qPSW1FQCT(^5Sui`ms!9DedNl3V1 z_|uG&a!{^p-5j6S3JR3!lP8tJeS47}u>>jMvyn$nO`m-RH$Tt1cu)o9(@d`)l)Yj@ tY-whnUby-H^Kts9(AfXr^L*5(e*o5CX@M&~^gRFo002ovPDHLkV1jyCYfS(E literal 0 HcmV?d00001 diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/Dialogs/MessageBoxViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/Dialogs/MessageBoxViewModel.cs new file mode 100644 index 00000000..51e0fab2 --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/Dialogs/MessageBoxViewModel.cs @@ -0,0 +1,77 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Media; +using LibationWinForms.AvaloniaUI.Views.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LibationWinForms.AvaloniaUI.ViewModels.Dialogs +{ + public class MessageBoxViewModel + { + private string _message; + public string Message { get { return _message; } set { _message = value; } } + public string Caption { get; } = "Message Box"; + private MessageBoxButtons _button; + private MessageBoxIcon _icon; + private MessageBoxDefaultButton _defaultButton; + + public MessageBoxButtons Buttons => _button; + + public bool IsAsterisk => _icon == MessageBoxIcon.Asterisk; + public bool IsError => _icon == MessageBoxIcon.Error; + public bool IsQuestion => _icon == MessageBoxIcon.Question; + public bool IsExclamation => _icon == MessageBoxIcon.Exclamation; + + public bool HasButton3 => !string.IsNullOrEmpty(Button3Text); + public bool HasButton2 => !string.IsNullOrEmpty(Button2Text); + + public int WindowHeight { get;private set; } + public int WindowWidth { get;private set; } + + public string Button1Text => _button switch + { + MessageBoxButtons.OK => "OK", + MessageBoxButtons.OKCancel => "OK", + MessageBoxButtons.AbortRetryIgnore => "Abort", + MessageBoxButtons.YesNoCancel => "Yes", + MessageBoxButtons.YesNo => "Yes", + MessageBoxButtons.RetryCancel => "Retry", + MessageBoxButtons.CancelTryContinue => "Cancel", + _ => string.Empty, + }; + + public string Button2Text => _button switch + { + MessageBoxButtons.OKCancel => "Cancel", + MessageBoxButtons.AbortRetryIgnore => "Retry", + MessageBoxButtons.YesNoCancel => "No", + MessageBoxButtons.YesNo => "No", + MessageBoxButtons.RetryCancel => "Cancel", + MessageBoxButtons.CancelTryContinue => "Try", + _ => string.Empty, + }; + + public string Button3Text => _button switch + { + MessageBoxButtons.AbortRetryIgnore => "Ignore", + MessageBoxButtons.YesNoCancel => "Cancel", + MessageBoxButtons.CancelTryContinue => "Continue", + _ => string.Empty, + }; + + public MessageBoxViewModel() { } + public MessageBoxViewModel(string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultBtn) + { + + Message = message; + Caption = caption; + _button = buttons; + _icon = icon; + _defaultButton = defaultBtn; + } + } +} diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs new file mode 100644 index 00000000..5edcb26b --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LibationWinForms.AvaloniaUI.ViewModels +{ + public class MainWindowViewModel + { + } +} diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs index 4e4e9290..5a56d6e0 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProcessBook2.cs @@ -9,6 +9,7 @@ using DataLayer; using Dinah.Core; using FileLiberator; using LibationFileManager; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using ReactiveUI; namespace LibationWinForms.AvaloniaUI.ViewModels @@ -152,7 +153,7 @@ namespace LibationWinForms.AvaloniaUI.ViewModels finally { if (Result == ProcessBookResult.None) - Result = showRetry(LibraryBook); + Result = await showRetry(LibraryBook); Status = Result switch { @@ -313,15 +314,15 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #region Failure Handler - private ProcessBookResult showRetry(LibraryBook libraryBook) + private async Task showRetry(LibraryBook libraryBook) { Logger.Error("ERROR. All books have not been processed. Most recent book: processing failed"); - System.Windows.Forms.DialogResult? dialogResult = Configuration.Instance.BadBook switch + DialogResult? dialogResult = Configuration.Instance.BadBook switch { - Configuration.BadBookAction.Abort => System.Windows.Forms.DialogResult.Abort, - Configuration.BadBookAction.Retry => System.Windows.Forms.DialogResult.Retry, - Configuration.BadBookAction.Ignore => System.Windows.Forms.DialogResult.Ignore, + Configuration.BadBookAction.Abort => DialogResult.Abort, + Configuration.BadBookAction.Retry => DialogResult.Retry, + Configuration.BadBookAction.Ignore => DialogResult.Ignore, Configuration.BadBookAction.Ask => null, _ => null }; @@ -346,9 +347,9 @@ $@" Title: {libraryBook.Book.Title} } // if null then ask user - dialogResult ??= System.Windows.Forms.MessageBox.Show(string.Format(SkipDialogText + "\r\n\r\nSee Settings to avoid this box in the future.", details), "Skip importing this book?", SkipDialogButtons, System.Windows.Forms.MessageBoxIcon.Question, SkipDialogDefaultButton); + dialogResult ??= await MessageBox.Show(string.Format(SkipDialogText + "\r\n\r\nSee Settings to avoid this box in the future.", details), "Skip importing this book?", SkipDialogButtons, MessageBoxIcon.Question, SkipDialogDefaultButton); - if (dialogResult == System.Windows.Forms.DialogResult.Abort) + if (dialogResult == DialogResult.Abort) return ProcessBookResult.FailedAbort; if (dialogResult == SkipResult) @@ -373,9 +374,9 @@ An error occurred while trying to process this book. - IGNORE: Permanently ignore this book. Continue processing books. (Will not try this book again later.) ".Trim(); - private System.Windows.Forms.MessageBoxButtons SkipDialogButtons => System.Windows.Forms.MessageBoxButtons.AbortRetryIgnore; - private System.Windows.Forms.MessageBoxDefaultButton SkipDialogDefaultButton => System.Windows.Forms.MessageBoxDefaultButton.Button1; - private System.Windows.Forms.DialogResult SkipResult => System.Windows.Forms.DialogResult.Ignore; + private MessageBoxButtons SkipDialogButtons => MessageBoxButtons.AbortRetryIgnore; + private MessageBoxDefaultButton SkipDialogDefaultButton => MessageBoxDefaultButton.Button1; + private DialogResult SkipResult => DialogResult.Ignore; } #endregion diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBox.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBox.cs new file mode 100644 index 00000000..bf71753a --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBox.cs @@ -0,0 +1,240 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.ApplicationLifetimes; +using LibationWinForms.AvaloniaUI.ViewModels.Dialogs; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace LibationWinForms.AvaloniaUI.Views.Dialogs +{ + public class MessageBox + { + + /// Displays a message box with the specified text, caption, buttons, icon, and default button. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values that specifies which icon to display in the message box. + /// One of the values that specifies the default button for the message box. + /// One of the values. + /// + /// is not a member of . + /// -or- + /// is not a member of . + /// -or- + /// is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + public static async Task Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) + { + return await ShowCore(null, text, caption, buttons, icon, defaultButton); + } + + + /// Displays a message box with specified text, caption, buttons, and icon. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values that specifies which icon to display in the message box. + /// One of the values. + /// The parameter specified is not a member of . + /// -or- + /// The parameter specified is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + public static async Task Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) + { + return await ShowCore(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1); + } + + + /// Displays a message box with specified text, caption, and buttons. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values. + /// The parameter specified is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + public static async Task Show(string text, string caption, MessageBoxButtons buttons) + { + return await ShowCore(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + + /// Displays a message box with specified text and caption. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values. + public static async Task Show(string text, string caption) + { + return await ShowCore(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + /// Displays a message box with specified text. + /// The text to display in the message box. + /// One of the values. + public static async Task Show(string text) + { + return await ShowCore(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + + /// Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, default button, and options. + /// An implementation of that will own the modal dialog box. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values that specifies which icon to display in the message box. + /// One of the values the specifies the default button for the message box. + /// One of the values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults. + /// One of the values. + /// + /// is not a member of . + /// -or- + /// is not a member of . + /// -or- + /// is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + /// + /// -or- + /// specified an invalid combination of . + public static async Task Show(Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) + { + return await ShowCore(owner, text, caption, buttons, icon, defaultButton); + } + + + /// Displays a message box in front of the specified object and with the specified text, caption, buttons, and icon. + /// An implementation of that will own the modal dialog box. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values that specifies which icon to display in the message box. + /// One of the values. + /// + /// is not a member of . + /// -or- + /// is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + public static async Task Show(Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) + { + return await ShowCore(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1); + } + + /// Displays a message box in front of the specified object and with the specified text, caption, and buttons. + /// An implementation of that will own the modal dialog box. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values that specifies which buttons to display in the message box. + /// One of the values. + /// + /// is not a member of . + /// An attempt was made to display the in a process that is not running in User Interactive mode. This is specified by the property. + public static async Task Show(Window owner, string text, string caption, MessageBoxButtons buttons) + { + return await ShowCore(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + /// Displays a message box in front of the specified object and with the specified text and caption. + /// An implementation of that will own the modal dialog box. + /// The text to display in the message box. + /// The text to display in the title bar of the message box. + /// One of the values. + public static async Task Show(Window owner, string text, string caption) + { + return await ShowCore(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + /// Displays a message box in front of the specified object and with the specified text. + /// An implementation of that will own the modal dialog box. + /// The text to display in the message box. + /// One of the values. + public static async Task Show(Window owner, string text) + { + return await ShowCore(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); + } + + private static async Task ShowCore(Window owner, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) + { + if (Avalonia.Threading.Dispatcher.UIThread.CheckAccess()) + return await ShowCore2(owner, message, caption, buttons, icon, defaultButton); + else + return await Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() => ShowCore2(owner, message, caption, buttons, icon, defaultButton)); + + } + private static async Task ShowCore2(Window owner, string message, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) + { + var dialog = new MessageBoxWindow(); + var vm = new MessageBoxViewModel(message, caption, buttons, icon, defaultButton); + dialog.DataContext = vm; + dialog.CanResize = false; + + var thisScreen = (owner ?? dialog).Screens.ScreenFromVisual(owner ?? dialog); + var tbx = dialog.FindControl("messageTextBlock"); + tbx.Text = message; + + var maxSize = new Size(0.6 * thisScreen.Bounds.Width - 72, 0.9 * thisScreen.Bounds.Height); + + var desiredMax = maxSize; + + //Try to minimize the TextBlock area. + List<(double, Size)> areas = new(); + for (int i = 0; i < 20; i++) + { + tbx.Measure(desiredMax); + + var area = tbx.DesiredSize.Width * tbx.DesiredSize.Height; + areas.Add((area, new Size(tbx.DesiredSize.Width, tbx.DesiredSize.Height))); + + if (tbx.DesiredSize.Height < maxSize.Height - 20) + { + if (desiredMax.Width / 2 < tbx.MinWidth) + desiredMax = new Size(desiredMax.Width * 1.5 + 1, desiredMax.Height); + else + desiredMax = new Size(desiredMax.Width / 2, desiredMax.Height); + } + } + + var min = areas.Min(a => a.Item1); + var mindim = areas.First(a => a.Item1 == min); + + var desiredSize = new Size(dialog.MinWidth - tbx.MinWidth + mindim.Item2.Width, dialog.MinHeight - tbx.MinHeight + mindim.Item2.Height); + + dialog.Width = desiredSize.Width; + dialog.Height = desiredSize.Height; + tbx.Width = mindim.Item2.Width; + tbx.Height = mindim.Item2.Height; + + if (owner is null) + { + if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { + return await dialog.ShowDialog(desktop.MainWindow); + } + else + { + var window = new Window + { + IsVisible = false, + Height = 1, + Width = 1, + SystemDecorations = SystemDecorations.None, + ShowInTaskbar = false + }; + + window.Show(); + var result = await dialog.ShowDialog(window); + window.Close(); + return result; + } + + } + else + { + return await dialog.ShowDialog(owner); + } + } + } +} diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml new file mode 100644 index 00000000..1e88cbc8 --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml.cs new file mode 100644 index 00000000..f0e61464 --- /dev/null +++ b/Source/LibationWinForms/AvaloniaUI/Views/Dialogs/MessageBoxWindow.axaml.cs @@ -0,0 +1,115 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; +using Avalonia.ReactiveUI; +using LibationWinForms.AvaloniaUI.ViewModels.Dialogs; + +namespace LibationWinForms.AvaloniaUI.Views.Dialogs +{ + + public enum DialogResult + { + None = 0, + OK = 1, + Cancel = 2, + Abort = 3, + Retry = 4, + Ignore = 5, + Yes = 6, + No = 7, + TryAgain = 10, + Continue = 11 + } + + + public enum MessageBoxIcon + { + None = 0, + Error = 16, + Hand = 16, + Stop = 16, + Question = 32, + Exclamation = 48, + Warning = 48, + Asterisk = 64, + Information = 64 + } + public enum MessageBoxButtons + { + OK, + OKCancel, + AbortRetryIgnore, + YesNoCancel, + YesNo, + RetryCancel, + CancelTryContinue + } + + public enum MessageBoxDefaultButton + { + Button1, + Button2 = 256, + Button3 = 512, + } + public partial class MessageBoxWindow : ReactiveWindow + { + public MessageBoxWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + public DialogResult DialogResult { get; private set; } + + public void Button1_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) + { + var vm = DataContext as MessageBoxViewModel; + DialogResult = vm.Buttons switch + { + MessageBoxButtons.OK => DialogResult.OK, + MessageBoxButtons.OKCancel => DialogResult.OK, + MessageBoxButtons.AbortRetryIgnore => DialogResult.Abort, + MessageBoxButtons.YesNoCancel => DialogResult.Yes, + MessageBoxButtons.YesNo => DialogResult.Yes, + MessageBoxButtons.RetryCancel => DialogResult.Retry, + MessageBoxButtons.CancelTryContinue => DialogResult.Cancel, + _ => DialogResult.None + }; + Close(DialogResult); + } + public void Button2_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) + { + var vm = DataContext as MessageBoxViewModel; + DialogResult = vm.Buttons switch + { + MessageBoxButtons.OKCancel => DialogResult.Cancel, + MessageBoxButtons.AbortRetryIgnore => DialogResult.Retry, + MessageBoxButtons.YesNoCancel => DialogResult.No, + MessageBoxButtons.YesNo => DialogResult.No, + MessageBoxButtons.RetryCancel => DialogResult.Cancel, + MessageBoxButtons.CancelTryContinue => DialogResult.TryAgain, + _ => DialogResult.None + }; + Close(DialogResult); + } + public void Button3_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) + { + var vm = DataContext as MessageBoxViewModel; + DialogResult = vm.Buttons switch + { + MessageBoxButtons.AbortRetryIgnore => DialogResult.Ignore, + MessageBoxButtons.YesNoCancel => DialogResult.Cancel, + MessageBoxButtons.CancelTryContinue => DialogResult.Continue, + _ => DialogResult.None + }; + Close(DialogResult); + } + } +} diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Export.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Export.axaml.cs index 445ba0cd..bac291bf 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Export.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Export.axaml.cs @@ -1,4 +1,5 @@ using ApplicationServices; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using System; using System.Linq; @@ -9,7 +10,7 @@ namespace LibationWinForms.AvaloniaUI.Views { private void Configure_Export() { } - public void exportLibraryToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) + public async void exportLibraryToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) { try { @@ -37,7 +38,7 @@ namespace LibationWinForms.AvaloniaUI.Views break; } - System.Windows.Forms.MessageBox.Show("Library exported to:\r\n" + saveFileDialog.FileName); + await MessageBox.Show("Library exported to:\r\n" + saveFileDialog.FileName); } catch (Exception ex) { diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Filter.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Filter.axaml.cs index cb97905f..e9f08819 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Filter.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Filter.axaml.cs @@ -1,7 +1,9 @@ using Avalonia.Input; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using LibationWinForms.Dialogs; using System; using System.Linq; +using System.Threading.Tasks; namespace LibationWinForms.AvaloniaUI.Views { @@ -13,22 +15,22 @@ namespace LibationWinForms.AvaloniaUI.Views public void filterHelpBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => new SearchSyntaxDialog().ShowDialog(); - public void filterSearchTb_KeyPress(object sender, KeyEventArgs e) + public async void filterSearchTb_KeyPress(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { - performFilter(this.filterSearchTb.Text); + await performFilter(this.filterSearchTb.Text); // silence the 'ding' e.Handled = true; } } - public void filterBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) - => performFilter(this.filterSearchTb.Text); + public async void filterBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) + => await performFilter(this.filterSearchTb.Text); private string lastGoodFilter = ""; - private void performFilter(string filterString) + private async Task performFilter(string filterString) { this.filterSearchTb.Text = filterString; @@ -39,10 +41,10 @@ namespace LibationWinForms.AvaloniaUI.Views } catch (Exception ex) { - System.Windows.Forms.MessageBox.Show($"Bad filter string:\r\n\r\n{ex.Message}", "Bad filter string", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + await MessageBox.Show($"Bad filter string:\r\n\r\n{ex.Message}", "Bad filter string", MessageBoxButtons.OK, MessageBoxIcon.Error); // re-apply last good filter - performFilter(lastGoodFilter); + await performFilter(lastGoodFilter); } } } diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Liberate.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Liberate.axaml.cs index a9da48d6..82c27a02 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Liberate.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Liberate.axaml.cs @@ -1,4 +1,5 @@ using DataLayer; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using System; using System.Linq; using System.Threading.Tasks; @@ -40,15 +41,15 @@ namespace LibationWinForms.AvaloniaUI.Views public async void convertAllM4bToMp3ToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args) { - var result = System.Windows.Forms.MessageBox.Show( + var result = await MessageBox.Show( "This converts all m4b titles in your library to mp3 files. Original files are not deleted." + "\r\nFor large libraries this will take a long time and will take up more disk space." + "\r\n\r\nContinue?" + "\r\n\r\n(To always download titles as mp3 instead of m4b, go to Settings: Download my books as .MP3 files)", "Convert all M4b => Mp3?", - System.Windows.Forms.MessageBoxButtons.YesNo, - System.Windows.Forms.MessageBoxIcon.Warning); - if (result == System.Windows.Forms.DialogResult.Yes) + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning); + if (result == DialogResult.Yes) { SetQueueCollapseState(false); await Task.Run(() => processBookQueue1.AddConvertMp3(ApplicationServices.DbContexts.GetLibrary_Flat_NoTracking() diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ProcessQueue.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ProcessQueue.axaml.cs index 5d166aba..d2d069f3 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ProcessQueue.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ProcessQueue.axaml.cs @@ -1,6 +1,7 @@ using DataLayer; using Dinah.Core; using LibationFileManager; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using System; using System.Linq; @@ -15,7 +16,7 @@ namespace LibationWinForms.AvaloniaUI.Views SetQueueCollapseState(collapseState); } - public void ProductsDisplay_LiberateClicked(object sender, LibraryBook libraryBook) + public async void ProductsDisplay_LiberateClicked(object sender, LibraryBook libraryBook) { try { @@ -38,7 +39,7 @@ namespace LibationWinForms.AvaloniaUI.Views if (!Go.To.File(filePath?.ShortPathName)) { var suffix = string.IsNullOrWhiteSpace(filePath) ? "" : $":\r\n{filePath}"; - System.Windows.Forms.MessageBox.Show($"File not found" + suffix); + await MessageBox.Show($"File not found" + suffix); } } } diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ScanManual.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ScanManual.axaml.cs index 719b7e1a..ff158e0c 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ScanManual.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.ScanManual.axaml.cs @@ -2,6 +2,7 @@ using AudibleUtilities; using Avalonia.Controls; using LibationFileManager; +using LibationWinForms.AvaloniaUI.Views.Dialogs; using LibationWinForms.Dialogs; using System; using System.Collections.Generic; @@ -49,9 +50,9 @@ namespace LibationWinForms.AvaloniaUI.Views } } - public void noAccountsYetAddAccountToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) + public async void noAccountsYetAddAccountToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) { - System.Windows.Forms.MessageBox.Show("To load your Audible library, come back here to the Import menu after adding your account"); + await MessageBox.Show("To load your Audible library, come back here to the Import menu after adding your account"); new AccountsDialog().ShowDialog(); } @@ -91,7 +92,7 @@ namespace LibationWinForms.AvaloniaUI.Views // this is here instead of ScanEnd so that the following is only possible when it's user-initiated, not automatic loop if (Configuration.Instance.ShowImportedStats && newAdded > 0) - System.Windows.Forms.MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}"); + await MessageBox.Show($"Total processed: {totalProcessed}\r\nNew: {newAdded}"); } catch (Exception ex) { diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Settings.axaml.cs b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Settings.axaml.cs index cc84bbe8..f0ac8324 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Settings.axaml.cs +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.Settings.axaml.cs @@ -1,4 +1,5 @@ -using LibationWinForms.Dialogs; +using LibationWinForms.AvaloniaUI.Views.Dialogs; +using LibationWinForms.Dialogs; using System; using System.Linq; @@ -13,7 +14,7 @@ namespace LibationWinForms.AvaloniaUI.Views public void basicSettingsToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) => new SettingsDialog().ShowDialog(); - public void aboutToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) - => System.Windows.Forms.MessageBox.Show($"Running Libation version {AppScaffolding.LibationScaffolding.BuildVersion}", $"Libation v{AppScaffolding.LibationScaffolding.BuildVersion}"); + public async void aboutToolStripMenuItem_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e) + => await MessageBox.Show($"Running Libation version {AppScaffolding.LibationScaffolding.BuildVersion}", $"Libation v{AppScaffolding.LibationScaffolding.BuildVersion}"); } } diff --git a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml index 22204a5a..d6853ad0 100644 --- a/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml +++ b/Source/LibationWinForms/AvaloniaUI/Views/MainWindow/MainWindow.axaml @@ -14,7 +14,7 @@ - + @@ -106,7 +106,9 @@ +