// Copyright Epic Games, Inc. All Rights Reserved. using Avalonia.Controls; using FluentAvalonia.UI.Controls; namespace UnrealToolbox { enum TrayAppPluginState { Undefined, Ok, Busy, Paused, Error } /// /// Reported status of a plugin /// record class ToolboxPluginStatus(TrayAppPluginState State, string? Message = null) { public static ToolboxPluginStatus Default { get; } = new ToolboxPluginStatus(TrayAppPluginState.Undefined); } /// /// Plugin for the tray app /// interface IToolboxPlugin : IAsyncDisposable { /// /// Name of the plugin to show in the settings page /// string Name { get; } /// /// Icon to show on the settings page /// IconSource Icon { get; } /// /// Url protocol handlers that this plugin supports /// IReadOnlyList UrlProtocols { get; } /// /// Refresh the state of this plugin. Called when the application is activated or focussed. /// /// True if the plugin status has changed, and the context menu needs to be rebuilt bool Refresh(); /// /// Handles a url passed on the commandline /// bool HandleUrl(Uri url); /// /// Get the current status of this plugin /// ToolboxPluginStatus GetStatus(); /// /// Determines if the plugin should be shown in the settings page /// bool HasSettingsPage(); /// /// Create a settings page for this plugin /// Control CreateSettingsPage(SettingsContext context); /// /// Allow the plugin to customize the tray icon context menu /// void PopulateContextMenu(NativeMenu contextMenu); } /// /// Base implementation of /// abstract class ToolboxPluginBase : IToolboxPlugin { /// public abstract string Name { get; } /// public virtual IconSource Icon => new SymbolIconSource() { Symbol = Symbol.Help }; /// public virtual IReadOnlyList UrlProtocols => Array.Empty(); /// public virtual bool Refresh() => false; /// public virtual bool HandleUrl(Uri url) => false; /// public virtual Control CreateSettingsPage(SettingsContext context) => throw new NotSupportedException(); /// public virtual ValueTask DisposeAsync() { GC.SuppressFinalize(this); return default; } /// public virtual ToolboxPluginStatus GetStatus() => ToolboxPluginStatus.Default; /// public virtual bool HasSettingsPage() => false; /// public virtual void PopulateContextMenu(NativeMenu contextMenu) { } } }