mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 08:56:15 +02:00
Add plugin methods for changed themes, settings showing message boxes and logging
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
@@ -8,14 +7,6 @@ namespace DesktopMagic.Api;
|
||||
/// </summary>
|
||||
public interface IPluginData
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when the application's theme has changed.
|
||||
/// </summary>
|
||||
/// <remarks>Subscribe to this event to be notified when the theme changes, allowing UI elements or
|
||||
/// components to update their appearance accordingly. The event is raised after the theme change has been
|
||||
/// applied.</remarks>
|
||||
event EventHandler? ThemeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current theme setting of the main application.
|
||||
/// </summary>
|
||||
@@ -45,4 +36,18 @@ public interface IPluginData
|
||||
/// Updates the plugin window.
|
||||
/// </summary>
|
||||
void UpdateWindow();
|
||||
|
||||
/// <summary>
|
||||
/// Logs a message to the application log.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to log.</param>
|
||||
/// <param name="level">The log level (Info, Warning, Error).</param>
|
||||
void Log(string message, LogLevel level = LogLevel.Info);
|
||||
|
||||
/// <summary>
|
||||
/// Shows a message box to the user.
|
||||
/// </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);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the severity level of a log message.
|
||||
/// </summary>
|
||||
public enum LogLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Informational message for general information.
|
||||
/// </summary>
|
||||
Info,
|
||||
|
||||
/// <summary>
|
||||
/// Warning message indicating a potential issue.
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>
|
||||
/// Error message indicating a failure or critical issue.
|
||||
/// </summary>
|
||||
Error
|
||||
}
|
||||
@@ -7,8 +7,14 @@ using System.Drawing;
|
||||
namespace DesktopMagic.Api;
|
||||
|
||||
/// <summary>
|
||||
/// The plugin class.
|
||||
/// Provides an abstract base class for creating plugins that can be integrated into the application, supporting periodic updates,
|
||||
/// rendering, and user interaction.
|
||||
/// </summary>
|
||||
/// <remarks>Derive from this class to implement custom plugin functionality. The class defines lifecycle methods
|
||||
/// such as <see cref="Start"/>, <see cref="Stop"/>, and <see cref="Main"/> for activation, deactivation, and periodic
|
||||
/// execution. It also provides event handlers for mouse and theme interactions, as well as access to application data
|
||||
/// and rendering configuration. Implementations should override relevant methods to respond to user input, update
|
||||
/// intervals, and configuration changes as needed.</remarks>
|
||||
public abstract class Plugin
|
||||
{
|
||||
[Setting("desktopmagic-horizontal-alignment", "Horizontal Alignment", -999)]
|
||||
@@ -86,4 +92,18 @@ public abstract class Plugin
|
||||
public virtual void OnMouseWheel(Point position, int delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the application's theme has changed.
|
||||
/// </summary>
|
||||
public virtual void OnThemeChanged()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the settings have changed to allow derived classes to respond to configuration updates.
|
||||
/// </summary>
|
||||
public virtual void OnSettingsChanged()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user