separate plugin ui & make Pilz.Plugins.Advanced package platform independent
This commit is contained in:
48
Pilz.Plugins.Advanced.UI/PluginModule.cs
Normal file
48
Pilz.Plugins.Advanced.UI/PluginModule.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI
|
||||
{
|
||||
public abstract class PluginModule<TPluginModuleUI> : PluginModuleBase where TPluginModuleUI : Control
|
||||
{
|
||||
public delegate void PluginModuleUIEventHandler(PluginModuleBase module, TPluginModuleUI ui);
|
||||
|
||||
/// <summary>
|
||||
/// Fires when a <see cref="PluginModuleUI"/> instance has been created.
|
||||
/// </summary>
|
||||
public static event PluginModuleUIEventHandler? OnUICreated;
|
||||
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool AllowEmbedding { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Wrapper for the <see cref="PluginFeature.Icon"/> property to directly use it as <see cref="System.Drawing.Image"/>.
|
||||
/// </summary>
|
||||
public Image? Image
|
||||
{
|
||||
get => base.Icon as Image;
|
||||
set => base.Icon = value;
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier) : base(moduleType, moduleIdentifier)
|
||||
{
|
||||
}
|
||||
|
||||
protected PluginModule(string moduleType, string moduleIdentifier, string moduleName) : base(moduleType, moduleIdentifier, moduleName)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ShowUI()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
{
|
||||
var ui = CreateNewUI();
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user