public static ToolStripMenuItem add_MenuItem(this ToolStripMenuItem menuItem, string text, bool returnParentMenuItem, Action <ToolStripMenuItem> onClick) { return(menuItem.toolStrip().invokeOnThread( () => { if (menuItem.isNull()) { return null; } var clildMenuItem = new ToolStripMenuItem { Text = text }; clildMenuItem.Click += (sender, e) => O2Thread.mtaThread(() => onClick(clildMenuItem)); menuItem.DropDownItems.Add(clildMenuItem); if (returnParentMenuItem) { return menuItem; } return clildMenuItem; })); }
public static ToolStripMenuItem click(this ToolStripMenuItem toolStripMenuItem) { toolStripMenuItem.toolStrip().invokeOnThread(toolStripMenuItem.PerformClick); return(toolStripMenuItem); }