From 0a57b8a3d647b2440a30b97ab100a25481903bf7 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 25 Dec 2025 18:14:46 +0100 Subject: [PATCH] Fix logging and dialogs in PluginData --- src/DesktopMagic/Plugins/PluginData.cs | 21 ++++++++++++++++++--- src/DesktopMagicPluginAPI/IPluginData.cs | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/DesktopMagic/Plugins/PluginData.cs b/src/DesktopMagic/Plugins/PluginData.cs index 757903c..fd53d7e 100644 --- a/src/DesktopMagic/Plugins/PluginData.cs +++ b/src/DesktopMagic/Plugins/PluginData.cs @@ -31,14 +31,29 @@ internal class PluginData(PluginWindow window, PluginSettings pluginSettings) : _ => LogSeverity.Info, }; - App.Logger.Log($"\"{PluginName}\" - Stopping plugin", "Plugin", severity); + App.Logger.Log($"\"{PluginName}\" - {message}", "Plugin", severity); } - public void ShowMessage(string message, string title) + public void ShowMessage(string message, string? title = null) { + title ??= PluginName; + window.Dispatcher.Invoke(() => { - _ = System.Windows.MessageBox.Show(window, message, title); + System.Windows.Window temporaryOwner = new() + { + AllowsTransparency = true, + ShowInTaskbar = false, + WindowStyle = System.Windows.WindowStyle.None, + Background = System.Windows.Media.Brushes.Transparent, + Topmost = true, + }; + + temporaryOwner.Show(); + + _ = System.Windows.MessageBox.Show(temporaryOwner, message, $"{App.AppName} - {title}"); + + temporaryOwner.Close(); }); } diff --git a/src/DesktopMagicPluginAPI/IPluginData.cs b/src/DesktopMagicPluginAPI/IPluginData.cs index 7ce2a07..10a6639 100644 --- a/src/DesktopMagicPluginAPI/IPluginData.cs +++ b/src/DesktopMagicPluginAPI/IPluginData.cs @@ -49,7 +49,7 @@ public interface IPluginData /// /// The message to display. /// The title of the message box. - void ShowMessage(string message, string title); + void ShowMessage(string message, string? title = null); /// /// Saves the current state of fields and properties marked with