add control manager for plugins
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.Plugins.Advanced.UI.Extensions;
|
||||
|
||||
public static class ControlFeatureCollectoinExtensions
|
||||
{
|
||||
public static void ExecuteControlFeatures(this IEnumerable<ControlFeature> @this, Control control, bool recursive, PluginFunctionParameter? parameter)
|
||||
{
|
||||
if (control.Name is string name)
|
||||
{
|
||||
foreach (var feature in @this)
|
||||
{
|
||||
if (feature.ControlName is null || feature.ControlName.Equals(control.Name))
|
||||
feature.Execute(control, parameter);
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (var child in control.Controls)
|
||||
{
|
||||
if (child is Control childControl)
|
||||
ExecuteControlFeatures(@this, childControl, true, parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,29 +2,30 @@
|
||||
|
||||
public static class PluginFeatureControllerExtensions
|
||||
{
|
||||
public static ControlManager ApplyControlManager(this PluginFeatureController @this, Control control)
|
||||
public static IControlManager ApplyControlManager(this PluginFeatureController @this, string featureType, Control control)
|
||||
{
|
||||
return ApplyControlManager(@this, control, true, true);
|
||||
return ApplyControlManager(@this, featureType, control, true, true);
|
||||
}
|
||||
|
||||
public static ControlManager ApplyControlManager(this PluginFeatureController @this, Control control, bool recursive, bool autoTrack)
|
||||
public static IControlManager ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, PluginFunctionParameter? parameter)
|
||||
{
|
||||
var manager = new ControlManager(@this, autoTrack);
|
||||
goThrow(control);
|
||||
return ApplyControlManager(@this, featureType, control, true, true, parameter);
|
||||
}
|
||||
|
||||
public static IControlManager ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, bool recursive, bool autoTrack)
|
||||
{
|
||||
return ApplyControlManager(@this, featureType, control, recursive, autoTrack, null);
|
||||
}
|
||||
|
||||
public static IControlManager ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, bool recursive, bool autoTrack, PluginFunctionParameter? parameter)
|
||||
{
|
||||
var manager = new ControlManager(@this.Features.Get(featureType).OfType<ControlFeature>(), control, recursive);
|
||||
|
||||
if (autoTrack)
|
||||
manager.Track();
|
||||
|
||||
manager.Initialize(parameter);
|
||||
|
||||
return manager;
|
||||
|
||||
void goThrow(Control control)
|
||||
{
|
||||
manager.RegisterControl(control);
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (var child in control.Controls)
|
||||
{
|
||||
if (child is Control childControl)
|
||||
goThrow(childControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user