Browse Source

Fixed SD2-1238: Menu items View Code and Properties shown when right clicking a menu strip in the designer do nothing (patch by Aaron Carlson)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2172 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
700dc8fe57
  1. 55
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Commands/FormsCommands.cs
  2. 23
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/MenuCommandService.cs

55
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Commands/FormsCommands.cs

@ -53,10 +53,21 @@ namespace ICSharpCode.FormsDesigner.Commands
MessageService.ShowError(e); MessageService.ShowError(e);
} }
} }
internal virtual void CommandCallBack(object sender, EventArgs e)
{
this.Run();
}
} }
public class ViewCode : AbstractMenuCommand public class ViewCode : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID {
get {
return StandardCommands.ViewCode;
}
}
FormsDesignerViewContent FormDesigner { FormsDesignerViewContent FormDesigner {
get { get {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
@ -66,6 +77,7 @@ namespace ICSharpCode.FormsDesigner.Commands
return window.ActiveViewContent as FormsDesignerViewContent; return window.ActiveViewContent as FormsDesignerViewContent;
} }
} }
public override void Run() public override void Run()
{ {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
@ -76,13 +88,18 @@ namespace ICSharpCode.FormsDesigner.Commands
FormsDesignerViewContent formDesigner = FormDesigner; FormsDesignerViewContent formDesigner = FormDesigner;
if (formDesigner != null) { if (formDesigner != null) {
formDesigner.ShowSourceCode(); formDesigner.ShowSourceCode();
} }
} }
} }
public class ShowProperties : AbstractMenuCommand public class ShowProperties : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID {
get {
return StandardCommands.PropertiesWindow;
}
}
public override void Run() public override void Run()
{ {
PadDescriptor padContent = WorkbenchSingleton.Workbench.GetPad(typeof(ICSharpCode.SharpDevelop.Gui.PropertyPad)); PadDescriptor padContent = WorkbenchSingleton.Workbench.GetPad(typeof(ICSharpCode.SharpDevelop.Gui.PropertyPad));
@ -136,7 +153,7 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
#region Align Commands #region Align Commands
public class AlignToGrid : AbstractFormsDesignerCommand public class AlignToGrid : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -199,9 +216,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Make Same Size Commands #region Make Same Size Commands
public class SizeToGrid : AbstractFormsDesignerCommand public class SizeToGrid : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -237,9 +254,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Horizontal Spacing Commands #region Horizontal Spacing Commands
public class HorizSpaceMakeEqual : AbstractFormsDesignerCommand public class HorizSpaceMakeEqual : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -281,9 +298,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Vertical Spacing Commands #region Vertical Spacing Commands
public class VertSpaceMakeEqual : AbstractFormsDesignerCommand public class VertSpaceMakeEqual : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -326,9 +343,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Center Commands #region Center Commands
public class CenterHorizontally : AbstractFormsDesignerCommand public class CenterHorizontally : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -345,9 +362,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Order Commands #region Order Commands
public class SendToBack : AbstractFormsDesignerCommand public class SendToBack : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -365,9 +382,9 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
#region Tray Commands #region Tray Commands
public class LineUpIcons : AbstractFormsDesignerCommand public class LineUpIcons : AbstractFormsDesignerCommand
{ {
@ -418,9 +435,9 @@ namespace ICSharpCode.FormsDesigner.Commands
{ {
} }
} }
#endregion #endregion
#region Global Commands #region Global Commands
public class LockControls : AbstractFormsDesignerCommand public class LockControls : AbstractFormsDesignerCommand
{ {
public override CommandID CommandID { public override CommandID CommandID {
@ -469,5 +486,5 @@ namespace ICSharpCode.FormsDesigner.Commands
} }
} }
} }
#endregion #endregion
} }

23
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/MenuCommandService.cs

@ -6,12 +6,14 @@
// </file> // </file>
using System; using System;
using System.ComponentModel.Design;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Forms.Design; using System.Windows.Forms.Design;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.FormsDesigner.Commands;
using CommandID = System.ComponentModel.Design.CommandID;
using MenuCommand = System.ComponentModel.Design.MenuCommand;
namespace ICSharpCode.FormsDesigner.Services namespace ICSharpCode.FormsDesigner.Services
{ {
@ -23,6 +25,24 @@ namespace ICSharpCode.FormsDesigner.Services
public MenuCommandService(Control panel, IServiceProvider serviceProvider) : base(serviceProvider) public MenuCommandService(Control panel, IServiceProvider serviceProvider) : base(serviceProvider)
{ {
this.panel = panel; 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) public override void ShowContextMenu(CommandID menuID, int x, int y)
@ -45,6 +65,5 @@ namespace ICSharpCode.FormsDesigner.Services
MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y); MenuService.ShowContextMenu(this, contextMenuPath, panel, p.X, p.Y);
} }
} }
} }

Loading…
Cancel
Save