diff --git a/src/DesktopMagic/BuiltInPlugins/SkiaBenchmarkPlugin.cs b/src/DesktopMagic/BuiltInPlugins/SkiaBenchmarkPlugin.cs
index 79a692f..c7ef00a 100644
--- a/src/DesktopMagic/BuiltInPlugins/SkiaBenchmarkPlugin.cs
+++ b/src/DesktopMagic/BuiltInPlugins/SkiaBenchmarkPlugin.cs
@@ -39,7 +39,7 @@ internal class SkiaBenchmarkPlugin : SkiaPlugin
surface = SKSurface.Create(new SKImageInfo(w, h, SKColorType.Bgra8888, SKAlphaType.Premul));
}
- public override SKImage? Render()
+ public override SKImage? Main()
{
long now = frameTimer.ElapsedMilliseconds;
if (lastFrameMs > 0)
diff --git a/src/DesktopMagic/BuiltInPlugins/TimePlugin.cs b/src/DesktopMagic/BuiltInPlugins/TimePlugin.cs
index 64a06c3..2019c9d 100644
--- a/src/DesktopMagic/BuiltInPlugins/TimePlugin.cs
+++ b/src/DesktopMagic/BuiltInPlugins/TimePlugin.cs
@@ -17,7 +17,7 @@ internal class TimePlugin : SkiaPlugin
public override int UpdateInterval => 1000;
- public override SKImage? Render()
+ public override SKImage? Main()
{
string time = GetTime();
diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
index 82e5002..0b116ca 100644
--- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
+++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs
@@ -1136,11 +1136,11 @@ public partial class PluginWindow : Window, IPluginWindow
if (plugin is SkiaAsyncPlugin skiaAsyncPlugin)
{
CancellationToken token = pluginCancellationTokenSource?.Token ?? CancellationToken.None;
- skImage = await skiaAsyncPlugin.RenderAsync(token);
+ skImage = await skiaAsyncPlugin.MainAsync(token);
}
else if (plugin is SkiaPlugin skiaPlugin)
{
- skImage = skiaPlugin.Render();
+ skImage = skiaPlugin.Main();
}
else
{
diff --git a/src/DesktopMagicPluginAPI/SkiaAsyncPlugin.cs b/src/DesktopMagicPluginAPI/SkiaAsyncPlugin.cs
index 1f6a3ad..1cb7ff7 100644
--- a/src/DesktopMagicPluginAPI/SkiaAsyncPlugin.cs
+++ b/src/DesktopMagicPluginAPI/SkiaAsyncPlugin.cs
@@ -1,5 +1,6 @@
using SkiaSharp;
+using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
@@ -7,29 +8,41 @@ using System.Threading.Tasks;
namespace DesktopMagic.Api;
///
-/// Provides an abstract base class for creating asynchronous plugins using SkiaSharp rendering.
-/// Plugins override and return an
-/// of their own size, just like returns a
-/// . The returned image is scaled to fit the plugin window while preserving
-/// its aspect ratio.
-/// All existing , , and code is unaffected.
+/// Infrastructure base class of . Derive from instead.
///
-public abstract class SkiaAsyncPlugin : AsyncPlugin
+/// This class only exists to seal the based method,
+/// so that can declare its own method returning an .
+[EditorBrowsable(EditorBrowsableState.Never)]
+public abstract class SkiaAsyncPluginBase : AsyncPlugin
{
///
- /// This method is sealed and returns null for async Skia plugins.
- /// Override instead.
+ /// This method should not be called directly! Override and use for asynchronous Skia plugin rendering.
///
+ /// This method only exists to fulfill base class requirements.
+ /// Token signaled when the host requests cancellation.
+ /// A task that always resolves to .
public sealed override Task MainAsync(CancellationToken cancellationToken)
{
return Task.FromResult(null);
}
+}
+///
+/// Provides an abstract base class for creating asynchronous plugins that render with SkiaSharp and can be integrated into the application,
+/// supporting periodic updates, rendering, and user interaction.
+///
+/// Derive from this class to implement custom plugin functionality. The class defines lifecycle methods
+/// such as , , and 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. The image returned by is scaled to fit the
+/// plugin window while preserving its aspect ratio.
+public abstract class SkiaAsyncPlugin : SkiaAsyncPluginBase
+{
///
- /// Called every milliseconds to render the plugin asynchronously.
- /// Return to keep the previously rendered image.
+ /// Occurs when the elapses.
///
/// Token signaled when the host requests cancellation.
/// The rendered image, or to keep the previous frame.
- public abstract Task RenderAsync(CancellationToken cancellationToken);
+ public new abstract Task MainAsync(CancellationToken cancellationToken);
}
diff --git a/src/DesktopMagicPluginAPI/SkiaPlugin.cs b/src/DesktopMagicPluginAPI/SkiaPlugin.cs
index 09cc8d9..334a593 100644
--- a/src/DesktopMagicPluginAPI/SkiaPlugin.cs
+++ b/src/DesktopMagicPluginAPI/SkiaPlugin.cs
@@ -1,32 +1,44 @@
using SkiaSharp;
+using System.ComponentModel;
using System.Drawing;
namespace DesktopMagic.Api;
///
-/// Provides an abstract base class for creating plugins using SkiaSharp rendering.
-/// Plugins override and return an of their own size,
-/// just like returns a . The returned image is
-/// scaled to fit the plugin window while preserving its aspect ratio.
-/// All existing and code is unaffected.
+/// Infrastructure base class of . Derive from instead.
///
-public abstract class SkiaPlugin : Plugin
+/// This class only exists to seal the based method,
+/// so that can declare its own method returning an .
+[EditorBrowsable(EditorBrowsableState.Never)]
+public abstract class SkiaPluginBase : Plugin
{
///
- /// This method is sealed and returns null for Skia plugins.
- /// Override instead.
+ /// This method should not be called directly! Override and use for Skia plugin rendering.
///
- /// Always null.
+ /// This method only exists to fulfill base class requirements.
+ /// Always .
public sealed override Bitmap? Main()
{
return null;
}
+}
+///
+/// Provides an abstract base class for creating plugins that render with SkiaSharp and can be integrated into the application,
+/// supporting periodic updates, rendering, and user interaction.
+///
+/// Derive from this class to implement custom plugin functionality. The class defines lifecycle methods
+/// such as , , and 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. The image returned by is scaled to fit the
+/// plugin window while preserving its aspect ratio.
+public abstract class SkiaPlugin : SkiaPluginBase
+{
///
- /// Called every milliseconds to render the plugin.
- /// Return to keep the previously rendered image.
+ /// Occurs when the elapses.
///
/// The rendered image, or to keep the previous frame.
- public abstract SKImage? Render();
+ public new abstract SKImage? Main();
}