add a simple plugin system
This commit is contained in:
40
Pilz.Plugins.Advanced/PluginModule.cs
Normal file
40
Pilz.Plugins.Advanced/PluginModule.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Pilz.UI.Telerik;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace Pilz.Plugins.Advanced
|
||||
{
|
||||
public abstract class PluginModule
|
||||
{
|
||||
public string Type { get; init; }
|
||||
public string Name { get; init; }
|
||||
public RadSvgImage? Icon { get; set; }
|
||||
public bool Visible { get; set; } = true;
|
||||
public bool RequiresRomManager { get; set; } = true;
|
||||
public bool AllowEmbedding { get; set; } = true;
|
||||
|
||||
protected PluginModule(string moduleType, string moduleName)
|
||||
{
|
||||
Type = moduleType;
|
||||
Name = moduleName;
|
||||
}
|
||||
|
||||
public virtual void ShowUI()
|
||||
{
|
||||
if (CreateNewUI() is PluginModuleUI ui)
|
||||
{
|
||||
ui.BackColor = Color.Transparent;
|
||||
DialogBaseForm.Show(ui, Name, Icon!.ToImage().ToIcon()!);
|
||||
}
|
||||
}
|
||||
|
||||
public PluginModuleUI CreateUI()
|
||||
{
|
||||
return CreateNewUI();
|
||||
}
|
||||
|
||||
protected abstract PluginModuleUI CreateNewUI();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user