28 lines
845 B
C#
28 lines
845 B
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|