add a uniquie event for plugin function execution
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
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;
|
||||
|
||||
@@ -40,17 +31,22 @@ public abstract class PluginModule<TPluginModuleUI> : PluginModuleBase where TPl
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
public virtual TPluginModuleUI? CreateUI()
|
||||
{
|
||||
return CreateUI(null);
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI(PluginFunctionParameter? @params)
|
||||
public virtual TPluginModuleUI? CreateUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
var ui = CreateNewUI(@params);
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
object? ui = default;
|
||||
|
||||
if (!OnPreExecute(@params, ref ui))
|
||||
ui = CreateNewUI(@params);
|
||||
|
||||
OnPostExecute(@params, ref ui);
|
||||
|
||||
return ui as TPluginModuleUI;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI(PluginFunctionParameter? @params);
|
||||
protected abstract TPluginModuleUI? CreateNewUI(PluginFunctionParameter? @params);
|
||||
}
|
||||
Reference in New Issue
Block a user