diff --git a/docs/Changelog.md b/docs/Changelog.md index d923735..163c1d8 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,6 +1,9 @@ 5.4.9.5 Beta (2021-??-??) +- Message boxes are themed. + + 5.4.9.4 Beta (2021-08-24) - Fix of command palette crash on Windows 7. diff --git a/src/.editorconfig b/src/.editorconfig index fcfc0fc..480ec2a 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -5,3 +5,15 @@ dotnet_diagnostic.IDE0058.severity = none # IDE0055: Fix formatting dotnet_diagnostic.IDE0055.severity = none + +# IDE0022: Use block body for methods +dotnet_diagnostic.IDE0022.severity = none + +# IDE0040: Add accessibility modifiers +dotnet_diagnostic.IDE0040.severity = none + +# IDE0011: Add braces +dotnet_diagnostic.IDE0011.severity = none + +# IDE0010: Add missing cases +dotnet_diagnostic.IDE0010.severity = none diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index cd26b63..100171a 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -122,7 +122,7 @@ namespace mpvnet else { if (Msg.ShowQuestion("Create history.txt file in config folder?", - "mpv.net will write the date, time and filename of opened files to it.") == DialogResult.OK) + "mpv.net will write the date, time and filename of opened files to it.") == MessageBoxResult.OK) File.WriteAllText(Core.ConfigFolder + "history.txt", ""); } diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 8c36d11..6cf46af 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -1161,18 +1161,19 @@ namespace mpvnet if (gb < 10) { - DialogResult result = Msg.ShowQuestion("Click Yes for Blu-ray and No for DVD.", - null, MessageBoxButtons.YesNoCancel); + System.Windows.MessageBoxResult result = + Msg.ShowQuestion("Click Yes for Blu-ray and No for DVD.", + null, System.Windows.MessageBoxButton.YesNoCancel); switch (result) { - case DialogResult.Yes: + case System.Windows.MessageBoxResult.Yes: Command("stop"); Thread.Sleep(500); SetPropertyString("bluray-device", path); LoadFiles(new[] { @"bd://" }, false, false); break; - case DialogResult.No: + case System.Windows.MessageBoxResult.No: Command("stop"); Thread.Sleep(500); SetPropertyString("dvd-device", path); diff --git a/src/Misc/Msg.cs b/src/Misc/Msg.cs index b5053c5..1fb80bb 100644 --- a/src/Misc/Msg.cs +++ b/src/Misc/Msg.cs @@ -1,41 +1,50 @@  using System; -using System.Windows.Forms; +using System.Windows; + +using WinForms = System.Windows.Forms; using static mpvnet.Global; +using MsgBoxEx; + public class Msg { + private static readonly string WindowTitle = WinForms.Application.ProductName; + public static void ShowInfo(object title, object content = null) { - Show(title, content, MessageBoxIcon.Information); + Show(title, content, MessageBoxImage.Information); } public static void ShowError(object title, object content = null) { - Show(title, content, MessageBoxIcon.Error); + Show(title, content, MessageBoxImage.Error); } public static void ShowWarning(object title, object content = null) { - Show(title, content, MessageBoxIcon.Warning); + Show(title, content, MessageBoxImage.Warning); } - public static DialogResult ShowQuestion(object title, object content = null, - MessageBoxButtons buttons = MessageBoxButtons.OKCancel) + public static MessageBoxResult ShowQuestion(object title, object content = null, + MessageBoxButton buttons = MessageBoxButton.OKCancel) { - return Show(title, content, MessageBoxIcon.Question, buttons); + return Show(title, content, MessageBoxImage.Question, buttons); } public static void ShowException(Exception exception) { - Show(exception, null, MessageBoxIcon.Error); + Show(exception, null, MessageBoxImage.Error); } - public static DialogResult Show(object title, object content, MessageBoxIcon icon, - MessageBoxButtons buttons = MessageBoxButtons.OK) + public static MessageBoxResult Show( + object title, + object content, + MessageBoxImage img, + MessageBoxButton buttons = MessageBoxButton.OK) { string msg = (title?.ToString().TrimEx() + BR2 + content?.ToString().TrimEx()).Trim(); - return MessageBox.Show(msg, Application.ProductName, buttons, icon); + return MessageBoxEx.OpenMessageBox(null, msg, WindowTitle, buttons, img); } } diff --git a/src/Misc/UpdateCheck.cs b/src/Misc/UpdateCheck.cs index 939b142..fabdab8 100644 --- a/src/Misc/UpdateCheck.cs +++ b/src/Misc/UpdateCheck.cs @@ -51,7 +51,8 @@ namespace mpvnet if ((App.Settings.UpdateCheckVersion != onlineVersion.ToString() || showUpToDateMessage) && Msg.ShowQuestion( - $"New version {onlineVersion} is available, update now?") == DialogResult.OK) + $"New version {onlineVersion} is available, update now?") == + System.Windows.MessageBoxResult.OK) { string url = $"https://github.com/stax76/mpv.net/releases/download/{onlineVersion}/mpv.net-{onlineVersion}-portable.zip"; diff --git a/src/WPF/ConfWindow.xaml.cs b/src/WPF/ConfWindow.xaml.cs index 38fbbd0..2331c91 100644 --- a/src/WPF/ConfWindow.xaml.cs +++ b/src/WPF/ConfWindow.xaml.cs @@ -109,7 +109,7 @@ namespace mpvnet App.UpdateWpfColors(); if (ThemeConf != GetThemeConf()) - Msg.ShowInfo("Changed theme settings require mpv.net being restarted."); + MessageBox.Show("Changed theme settings require mpv.net being restarted.", "Info"); } string GetCompareString() diff --git a/src/WPF/InputWindow.xaml.cs b/src/WPF/InputWindow.xaml.cs index 5a226df..afeca7f 100644 --- a/src/WPF/InputWindow.xaml.cs +++ b/src/WPF/InputWindow.xaml.cs @@ -151,7 +151,7 @@ namespace mpvnet DataGrid grid = (DataGrid)sender; if (e.Command == DataGrid.DeleteCommand) - if (Msg.ShowQuestion($"Confirm to delete: {(grid.SelectedItem as CommandItem).Input} ({(grid.SelectedItem as CommandItem).Path})") != System.Windows.Forms.DialogResult.OK) + if (Msg.ShowQuestion($"Confirm to delete: {(grid.SelectedItem as CommandItem).Input} ({(grid.SelectedItem as CommandItem).Path})") != MessageBoxResult.OK) e.Handled = true; } diff --git a/src/WPF/MsgBox/MessageBoxEx.xaml b/src/WPF/MsgBox/MessageBoxEx.xaml new file mode 100644 index 0000000..4c860dc --- /dev/null +++ b/src/WPF/MsgBox/MessageBoxEx.xaml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +