some improvements
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pilz.Plugins.Advanced\Pilz.Plugins.Advanced.csproj" />
|
||||
<ProjectReference Include="..\Pilz.UI\Pilz.UI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
19
Pilz.Plugins.Advanced.UI/Pilz.Plugins.Advanced.UI.csproj.bak
Normal file
19
Pilz.Plugins.Advanced.UI/Pilz.Plugins.Advanced.UI.csproj.bak
Normal file
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0-windows</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.1.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Pilz.Plugins.Advanced\Pilz.Plugins.Advanced.csproj" />
|
||||
<ProjectReference Include="..\Pilz.UI\Pilz.UI.vbproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,56 +1,22 @@
|
||||
using System.Reflection.Metadata;
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
public abstract class PluginModule<TPluginModuleUI> : PluginModuleBase where TPluginModuleUI : Control
|
||||
public abstract class PluginModule : PluginModule<PluginModuleUI>
|
||||
{
|
||||
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 override void ShowUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
ShowUI(null);
|
||||
if (CreateNewUI(@params) is PluginModuleUI ui)
|
||||
{
|
||||
ui.BackColor = Color.Transparent;
|
||||
DialogBase.Show(ui, Name!, Image!.ToIcon());
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ShowUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
{
|
||||
return CreateUI(null);
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
var ui = CreateNewUI(@params);
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI(PluginFunctionParameter? @params);
|
||||
}
|
||||
}
|
||||
|
||||
11
Pilz.Plugins.Advanced.UI/PluginModuleUI.cs
Normal file
11
Pilz.Plugins.Advanced.UI/PluginModuleUI.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Pilz.UI.Dialogs;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI;
|
||||
|
||||
public partial class PluginModuleUI : FlyoutBase, ILoadContent
|
||||
{
|
||||
public PluginModuleUI()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
56
Pilz.Plugins.Advanced.UI/PluginModule{T}.cs
Normal file
56
Pilz.Plugins.Advanced.UI/PluginModule{T}.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Reflection.Metadata;
|
||||
|
||||
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()
|
||||
{
|
||||
ShowUI(null);
|
||||
}
|
||||
|
||||
public virtual void ShowUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI()
|
||||
{
|
||||
return CreateUI(null);
|
||||
}
|
||||
|
||||
public virtual TPluginModuleUI CreateUI(PluginFunctionParameter? @params)
|
||||
{
|
||||
var ui = CreateNewUI(@params);
|
||||
OnUICreated?.Invoke(this, ui);
|
||||
return ui;
|
||||
}
|
||||
|
||||
protected abstract TPluginModuleUI CreateNewUI(PluginFunctionParameter? @params);
|
||||
}
|
||||
Reference in New Issue
Block a user