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. 65
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Commands/FormsCommands.cs
  2. 25
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/MenuCommandService.cs

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

@ -42,7 +42,7 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -42,7 +42,7 @@ namespace ICSharpCode.FormsDesigner.Commands
}
public override void Run()
{
try {
FormsDesignerViewContent formDesigner = FormDesigner;
if (formDesigner != null && CanExecuteCommand(formDesigner.Host)) {
@ -53,11 +53,22 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -53,11 +53,22 @@ namespace ICSharpCode.FormsDesigner.Commands
MessageService.ShowError(e);
}
}
internal virtual void CommandCallBack(object sender, EventArgs e)
{
this.Run();
}
}
public class ViewCode : AbstractMenuCommand
public class ViewCode : AbstractFormsDesignerCommand
{
FormsDesignerViewContent FormDesigner {
public override CommandID CommandID {
get {
return StandardCommands.ViewCode;
}
}
FormsDesignerViewContent FormDesigner {
get {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window == null) {
@ -66,6 +77,7 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -66,6 +77,7 @@ namespace ICSharpCode.FormsDesigner.Commands
return window.ActiveViewContent as FormsDesignerViewContent;
}
}
public override void Run()
{
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
@ -76,13 +88,18 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -76,13 +88,18 @@ namespace ICSharpCode.FormsDesigner.Commands
FormsDesignerViewContent formDesigner = FormDesigner;
if (formDesigner != null) {
formDesigner.ShowSourceCode();
}
}
}
public class ShowProperties : AbstractMenuCommand
public class ShowProperties : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
get {
return StandardCommands.PropertiesWindow;
}
}
public override void Run()
{
PadDescriptor padContent = WorkbenchSingleton.Workbench.GetPad(typeof(ICSharpCode.SharpDevelop.Gui.PropertyPad));
@ -99,7 +116,7 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -99,7 +116,7 @@ namespace ICSharpCode.FormsDesigner.Commands
IMenuCommandService menuCommandService = (IMenuCommandService)owner;
List<ToolStripItem> items = new List<ToolStripItem>();
foreach (DesignerVerb verb in menuCommandService.Verbs) {
items.Add(new ContextMenuCommand(verb));
}
@ -136,7 +153,7 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -136,7 +153,7 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
#region Align Commands
#region Align Commands
public class AlignToGrid : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -199,9 +216,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -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 override CommandID CommandID {
@ -237,9 +254,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -237,9 +254,9 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
#region Horizontal Spacing Commands
#region Horizontal Spacing Commands
public class HorizSpaceMakeEqual : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -281,9 +298,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -281,9 +298,9 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
#region Vertical Spacing Commands
#region Vertical Spacing Commands
public class VertSpaceMakeEqual : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -326,9 +343,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -326,9 +343,9 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
#region Center Commands
#region Center Commands
public class CenterHorizontally : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -345,9 +362,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -345,9 +362,9 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
#region Order Commands
#region Order Commands
public class SendToBack : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -365,9 +382,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -365,9 +382,9 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
#region Tray Commands
#region Tray Commands
public class LineUpIcons : AbstractFormsDesignerCommand
{
@ -418,9 +435,9 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -418,9 +435,9 @@ namespace ICSharpCode.FormsDesigner.Commands
{
}
}
#endregion
#endregion
#region Global Commands
#region Global Commands
public class LockControls : AbstractFormsDesignerCommand
{
public override CommandID CommandID {
@ -469,5 +486,5 @@ namespace ICSharpCode.FormsDesigner.Commands @@ -469,5 +486,5 @@ namespace ICSharpCode.FormsDesigner.Commands
}
}
}
#endregion
#endregion
}

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

@ -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,8 +25,26 @@ namespace ICSharpCode.FormsDesigner.Services @@ -23,8 +25,26 @@ 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)
{
string contextMenuPath = "/SharpDevelop/FormsDesigner/ContextMenus/";
@ -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);
}
}
}

Loading…
Cancel
Save