using SkiaSharp;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
namespace DesktopMagic.Api;
///
/// Infrastructure base class of . Derive from instead.
///
/// 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 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
{
///
/// Occurs when the elapses.
///
/// Token signaled when the host requests cancellation.
/// The rendered image, or to keep the previous frame.
public new abstract Task MainAsync(CancellationToken cancellationToken);
}