|
@@ -521,15 +521,18 @@ public static class WPFUtils
|
|
|
|
|
|
return item;
|
|
return item;
|
|
}
|
|
}
|
|
- private static MenuItem DoAddMenuItem<T>(ItemsControl menu, string caption, Bitmap? image, T tag, Action<T> click, bool enabled, int index = -1)
|
|
|
|
|
|
+ private static MenuItem DoAddMenuItem<T>(ItemsControl menu, string caption, Bitmap? image, T tag, Action<T>? click, bool enabled, int index = -1)
|
|
{
|
|
{
|
|
var item = DoAddMenuItem(menu, caption, image, enabled, index);
|
|
var item = DoAddMenuItem(menu, caption, image, enabled, index);
|
|
|
|
|
|
item.Tag = tag;
|
|
item.Tag = tag;
|
|
- item.Click += (o, e) =>
|
|
|
|
|
|
+ if(click != null)
|
|
{
|
|
{
|
|
- click((T)(o as MenuItem)!.Tag);
|
|
|
|
- };
|
|
|
|
|
|
+ item.Click += (o, e) =>
|
|
|
|
+ {
|
|
|
|
+ click((T)(o as MenuItem)!.Tag);
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
|
|
return item;
|
|
return item;
|
|
}
|
|
}
|
|
@@ -613,9 +616,9 @@ public static class WPFUtils
|
|
=> DoAddMenuItem(menu, caption, image, click, enabled, index);
|
|
=> DoAddMenuItem(menu, caption, image, click, enabled, index);
|
|
public static MenuItem AddItem(this MenuItem menu, string caption, Bitmap? image, Action? click, bool enabled = true, int index = -1)
|
|
public static MenuItem AddItem(this MenuItem menu, string caption, Bitmap? image, Action? click, bool enabled = true, int index = -1)
|
|
=> DoAddMenuItem(menu, caption, image, click, enabled, index);
|
|
=> DoAddMenuItem(menu, caption, image, click, enabled, index);
|
|
- public static MenuItem AddItem<T>(this ContextMenu menu, string caption, Bitmap? image, T tag, Action<T> click, bool enabled = true, int index = -1)
|
|
|
|
|
|
+ public static MenuItem AddItem<T>(this ContextMenu menu, string caption, Bitmap? image, T tag, Action<T>? click, bool enabled = true, int index = -1)
|
|
=> DoAddMenuItem(menu, caption, image, tag, click, enabled, index);
|
|
=> DoAddMenuItem(menu, caption, image, tag, click, enabled, index);
|
|
- public static MenuItem AddItem<T>(this MenuItem menu, string caption, Bitmap? image, T tag, Action<T> click, bool enabled = true, int index = -1)
|
|
|
|
|
|
+ public static MenuItem AddItem<T>(this MenuItem menu, string caption, Bitmap? image, T tag, Action<T>? click, bool enabled = true, int index = -1)
|
|
=> DoAddMenuItem(menu, caption, image, tag, click, enabled, index);
|
|
=> DoAddMenuItem(menu, caption, image, tag, click, enabled, index);
|
|
public static MenuItem AddCheckItem(this ContextMenu menu, string caption, CheckToggleAction click, bool isChecked = false, bool enabled = true, int index = -1)
|
|
public static MenuItem AddCheckItem(this ContextMenu menu, string caption, CheckToggleAction click, bool isChecked = false, bool enabled = true, int index = -1)
|
|
=> DoAddCheckItem(menu, caption, click, isChecked, enabled, index);
|
|
=> DoAddCheckItem(menu, caption, click, isChecked, enabled, index);
|