fix: add custom event handler if not default
This commit is contained in:
@@ -65,7 +65,7 @@ namespace Pilz.Plugins.Advanced
|
||||
/// You usually don't set customClickHandler if you set this parameter to <see cref="true"/>.</param>
|
||||
/// <param name="customClickHandler">Adds a custom click handler. If addDefaultHandler is true, it will only work on <see cref="PluginFeature"/>s.<br/>
|
||||
/// You usually don't set addDefaultHandler to true if you set this parameter to something not null.</param>
|
||||
public static void InsertItemsTo(this IEnumerable<PluginFeature> features, RadItemOwnerCollection itemsCollection, bool addDefaultHandler = false, EventHandler? customClickHandler = null, FeatureInsertMode insertMode = FeatureInsertMode.Default, int? customDefault = null, int? customTop = null, int? customBottom = null)
|
||||
public static void InsertItemsTo(this IEnumerable<PluginFeature> features, RadItemOwnerCollection itemsCollection, bool addDefaultHandler = false, EventHandler? customClickHandler = null, FeatureInsertMode insertMode = FeatureInsertMode.Default, int? customDefault = null, int? customTop = null, int? customBottom = null, FeatureInsertPosition insertSplitter = FeatureInsertPosition.None)
|
||||
{
|
||||
var insertDefault = customDefault ?? (insertMode.HasFlag(FeatureInsertMode.DefaultStart) ? 0 : itemsCollection.Count);
|
||||
var insertTop = customTop ?? (insertMode.HasFlag(FeatureInsertMode.InsertTop) || insertMode.HasFlag(FeatureInsertMode.DefaultStart) ? 0 : insertDefault);
|
||||
@@ -82,21 +82,27 @@ namespace Pilz.Plugins.Advanced
|
||||
else
|
||||
item = feature.GetAsItem(null);
|
||||
|
||||
if (!addDefaultHandler && customClickHandler != null)
|
||||
item.Click += customClickHandler;
|
||||
|
||||
switch (feature.Prioritization)
|
||||
{
|
||||
case FeaturePrioritization.High:
|
||||
if (insertDefault >= insertTop) insertDefault++;
|
||||
if (insertBottom >= insertTop) insertBottom++;
|
||||
// ...
|
||||
itemsCollection.Insert(insertTop++, item);
|
||||
break;
|
||||
case FeaturePrioritization.Default:
|
||||
if (insertBottom >= insertDefault) insertBottom++;
|
||||
if (insertTop >= insertDefault) insertTop++;
|
||||
// ...
|
||||
itemsCollection.Insert(insertDefault++, item);
|
||||
break;
|
||||
case FeaturePrioritization.Low:
|
||||
if (insertTop >= insertBottom) insertTop++;
|
||||
if (insertDefault >= insertBottom) insertDefault++;
|
||||
// ...
|
||||
itemsCollection.Insert(insertBottom++, item);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user