Files
Pilz/Pilz.UI.WinForms.Features/Extensions/PluginFeatureControllerExtensions.cs
2025-11-06 11:51:05 +01:00

39 lines
1.4 KiB
C#

using Pilz.Features;
namespace Pilz.UI.WinForms.Features.Extensions;
public static class PluginFeatureControllerExtensions
{
public static IControlListener ApplyControlManager(this PluginFeatureController @this, string featureType, Control control)
{
return @this.ApplyControlManager(featureType, control, true, true);
}
public static IControlListener ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, PluginFunctionParameter? parameter)
{
return @this.ApplyControlManager(featureType, control, true, true, parameter);
}
public static IControlListener ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, bool recursive, bool autoTrack)
{
return @this.ApplyControlManager(featureType, control, recursive, autoTrack, null);
}
public static IControlListener ApplyControlManager(this PluginFeatureController @this, string featureType, Control control, bool recursive, bool autoTrack, PluginFunctionParameter? parameter)
{
var features = @this.Features.Get(featureType).OfType<ControlListenerFeature>();
if (!features.Any())
return new ControlListenerDummy([], control, recursive);
var manager = new ControlListener(features, control, recursive);
if (autoTrack)
manager.Track();
manager.Initialize(parameter);
return manager;
}
}