/// <summary> /// Set the Enabled state of the Toll MenuItems /// </summary> /// <param name="mi"></param> /// <param name="pfd"></param> /// <param name="package"></param> public void EnableMenuItems(System.Windows.Forms.MenuItem mi, Interfaces.Files.IPackedFileDescriptor pfd, Interfaces.Files.IPackageFile package) { foreach (System.Windows.Forms.MenuItem item in mi.MenuItems) { try { ToolMenuItem tmi = (ToolMenuItem)item; tmi.Package = package; tmi.FileDescriptor = pfd; tmi.UpdateEnabledState(); } catch (Exception) {} } }
/// <summary> /// Adds the Tool Plugins to the passed menu /// </summary> /// <param name="mi">The Menu you want to add Items to</param> /// <param name="chghandler">A Function to call when the Package was chaged by a Tool</param> public void AddMenuItems(System.Windows.Forms.MenuItem mi, System.EventHandler chghandler) { ITool[] tools = treg.Tools; foreach (SimPe.Interfaces.ITool tool in tools) { ToolMenuItem item = new ToolMenuItem(tool, chghandler); mi.MenuItems.Add(item); } foreach (SimPe.Interfaces.IToolPlugin tool in treg.Docks) { if (tool.GetType().GetInterface("SimPe.Interfaces.ITool", true) == typeof(SimPe.Interfaces.ITool)) { ToolMenuItem item = new ToolMenuItem((SimPe.Interfaces.ITool)tool, chghandler); mi.MenuItems.Add(item); } } EnableMenuItems(mi, null, null); }