mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
Fix logging and dialogs in PluginData
This commit is contained in:
@@ -31,14 +31,29 @@ internal class PluginData(PluginWindow window, PluginSettings pluginSettings) :
|
|||||||
_ => LogSeverity.Info,
|
_ => 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(() =>
|
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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public interface IPluginData
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">The message to display.</param>
|
/// <param name="message">The message to display.</param>
|
||||||
/// <param name="title">The title of the message box.</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>
|
/// <summary>
|
||||||
/// Saves the current state of fields and properties marked with <see cref="PersistStateAttribute"/>
|
/// Saves the current state of fields and properties marked with <see cref="PersistStateAttribute"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user