|
|
|
@ -6,12 +6,14 @@
@@ -6,12 +6,14 @@
|
|
|
|
|
// </file>
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
|
using System.ComponentModel.Design; |
|
|
|
|
using System.Drawing; |
|
|
|
|
using System.Windows.Forms; |
|
|
|
|
using System.Windows.Forms.Design; |
|
|
|
|
|
|
|
|
|
using ICSharpCode.Core; |
|
|
|
|
using ICSharpCode.FormsDesigner.Commands; |
|
|
|
|
using CommandID = System.ComponentModel.Design.CommandID; |
|
|
|
|
using MenuCommand = System.ComponentModel.Design.MenuCommand; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.FormsDesigner.Services |
|
|
|
|
{ |
|
|
|
@ -23,6 +25,24 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -23,6 +25,24 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
public MenuCommandService(Control panel, IServiceProvider serviceProvider) : base(serviceProvider) |
|
|
|
|
{ |
|
|
|
|
this.panel = panel; |
|
|
|
|
this.InitializeGlobalCommands( ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void InitializeGlobalCommands() |
|
|
|
|
{ |
|
|
|
|
//Most commands like Delete, Cut, Copy and paste are all added to the MenuCommandService
|
|
|
|
|
// by the other services like the DesignerHost. Commands like ViewCode and ShowProperties
|
|
|
|
|
// need to be added by the IDE because only the IDE would know how to perform those actions.
|
|
|
|
|
// This allows people to call MenuCommandSerice.GlobalInvoke( StandardCommands.ViewCode );
|
|
|
|
|
// from designers and what not. .Net Control Designers like the TableLayoutPanelDesigner
|
|
|
|
|
// build up their own context menus instead of letting the MenuCommandService build it.
|
|
|
|
|
// The context menus they build up are in the format that Visual studio expects and invokes
|
|
|
|
|
// the ViewCode and Properties commands by using GlobalInvoke.
|
|
|
|
|
|
|
|
|
|
AbstractFormsDesignerCommand viewCodeCommand = new ViewCode(); |
|
|
|
|
AbstractFormsDesignerCommand propertiesCodeCommand = new ShowProperties(); |
|
|
|
|
this.AddCommand( new MenuCommand(viewCodeCommand.CommandCallBack, viewCodeCommand.CommandID)); |
|
|
|
|
this.AddCommand( new MenuCommand(propertiesCodeCommand.CommandCallBack, propertiesCodeCommand.CommandID)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void ShowContextMenu(CommandID menuID, int x, int y) |
|
|
|
@ -45,6 +65,5 @@ namespace ICSharpCode.FormsDesigner.Services
@@ -45,6 +65,5 @@ namespace ICSharpCode.FormsDesigner.Services
|
|
|
|
|
|
|
|
|
|
MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|