Fix logging and dialogs in PluginData

This commit is contained in:
Stone_Red
2025-12-25 18:14:57 +01:00
parent 16c5c98f1a
commit 0a57b8a3d6
2 changed files with 19 additions and 4 deletions
+18 -3
View File
@@ -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();
});
}
+1 -1
View File
@@ -49,7 +49,7 @@ public interface IPluginData
/// </summary>
/// <param name="message">The message to display.</param>
/// <param name="title">The title of the message box.</param>
void ShowMessage(string message, string title);
void ShowMessage(string message, string? title = null);
/// <summary>
/// Saves the current state of fields and properties marked with <see cref="PersistStateAttribute"/>