using System; using System.Drawing; using System.Windows.Forms; namespace Ringtoets.Piping.Forms.Extensions { /// /// Extension methods for . /// public static class ContextMenuStripExtensions { /// /// Adds a new with all standard parameters. /// /// The parent menu to which the new item is added. /// Value for . /// Value for . /// Value for . /// Method to handle the user clicking on the item.. public static void AddMenuItem(this ContextMenuStrip parentMenu, string text, string tooltip, Image icon, EventHandler clickHandler) { var newItem = new ToolStripMenuItem(text) { ToolTipText = tooltip, Image = icon }; newItem.Click += clickHandler; parentMenu.Items.Add(newItem); } } }