Browse Source

View menu builder works again.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@32 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 21 years ago
parent
commit
d6ff64a02f
  1. 10
      AddIns/ICSharpCode.SharpDevelop.addin
  2. 97
      src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs
  3. 3
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  4. 4
      src/Main/Base/Project/Src/Internal/Erbauer/PadDescriptor.cs
  5. 12
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  6. 19
      src/Main/Core/Project/Src/AddInTree/AddIn/StandardErbauer/MenuItem/Gui/Menu.cs
  7. 23
      src/Main/Core/Project/Src/AddInTree/AddIn/StandardErbauer/MenuItem/Gui/MenuCommand.cs

10
AddIns/ICSharpCode.SharpDevelop.addin

@ -1101,10 +1101,16 @@
<MenuItem id = "View" label = "${res:XML.MainMenu.ViewMenu}" type="Menu"> <MenuItem id = "View" label = "${res:XML.MainMenu.ViewMenu}" type="Menu">
<MenuItem id = "MainViewBuilder" type = "Builder" class = "ICSharpCode.SharpDevelop.Commands.MainSelectionMenuBuilder" /> <MenuItem id = "MainViewMenuBuilder"
type = "Builder"
class = "ICSharpCode.SharpDevelop.Commands.MainViewMenuBuilder" />
<MenuItem id = "Tools" label = "${res:XML.MainMenu.ViewMenu.ToolsMenu}" type="Menu"> <MenuItem id = "Tools" label = "${res:XML.MainMenu.ViewMenu.ToolsMenu}" type="Menu">
<MenuItem id = "ViewBuilder" type = "Builder" class = "ICSharpCode.SharpDevelop.Commands.SelectionMenuBuilder" /> <MenuItem id = "ToolsViewMenuBuilder"
type = "Builder"
class = "ICSharpCode.SharpDevelop.Commands.ToolsViewMenuBuilder" />
</MenuItem> </MenuItem>
<MenuItem id = "ViewItemsSeparator" type = "Separator" /> <MenuItem id = "ViewItemsSeparator" type = "Separator" />
<MenuItem id = "FullScreen" <MenuItem id = "FullScreen"
label = "${res:XML.MainMenu.ViewMenu.FullScreen}" label = "${res:XML.MainMenu.ViewMenu.FullScreen}"

97
src/Main/Base/Project/Src/Commands/MenuItemBuilders.cs

@ -324,77 +324,17 @@ namespace ICSharpCode.SharpDevelop.Commands
} }
} }
} }
public class MainViewMenuBuilder : ViewMenuBuilder
{
protected override string Category {
get {
return "Main";
}
}
}
public class ViewMenuBuilder : ISubmenuBuilder public class ToolsViewMenuBuilder : ViewMenuBuilder
{
class MyMenuItem : MenuCheckBox
{
PadDescriptor padContent;
bool IsPadVisible {
get {
return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(padContent);
}
}
public MyMenuItem(PadDescriptor padContent) : base(null, null)
{
this.padContent = padContent;
Checked = IsPadVisible;
Text = StringParser.Parse(padContent.Title);
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (IsPadVisible) {
WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(padContent);
} else {
WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(padContent);
}
Checked = IsPadVisible;
}
public override void UpdateStatus()
{
base.UpdateStatus();
Checked = IsPadVisible;
}
}
protected virtual string Category {
get {
return null;
}
}
public ToolStripItem[] BuildSubmenu(Codon codon, object owner)
{
ArrayList items = new ArrayList();
foreach (PadDescriptor padContent in WorkbenchSingleton.Workbench.PadContentCollection) {
if (padContent.Category == Category) {
items.Add(new MyMenuItem(padContent));
}
}
return (ToolStripItem[])items.ToArray(typeof(ToolStripItem));
}
}
public class DebugSelectionMenuBuilder : SelectionMenuBuilder
{ {
protected override string Category { protected override string Category {
get { get {
return "Debugger"; return "Tools";
} }
} }
} }
public class MainSelectionMenuBuilder : SelectionMenuBuilder
public class MainViewMenuBuilder : ViewMenuBuilder
{ {
protected override string Category { protected override string Category {
get { get {
@ -403,27 +343,29 @@ namespace ICSharpCode.SharpDevelop.Commands
} }
} }
public class SelectionMenuBuilder : ISubmenuBuilder public abstract class ViewMenuBuilder : ISubmenuBuilder
{ {
class MyMenuItem : MenuCommand class MyMenuItem : MenuCommand
{ {
PadDescriptor padDescriptor; PadDescriptor padDescriptor;
bool IsPadVisible {
get {
return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(padDescriptor);
}
}
public MyMenuItem(PadDescriptor padDescriptor) : base(null, null) public MyMenuItem(PadDescriptor padDescriptor) : base(null, null)
{ {
this.padDescriptor = padDescriptor; this.padDescriptor = padDescriptor;
Text = StringParser.Parse(padDescriptor.Title); Text = StringParser.Parse(padDescriptor.Title);
if (padDescriptor.Icon != null) { if (padDescriptor.Icon != null) {
base.Image = IconService.GetBitmap(padDescriptor.Icon); base.Image = IconService.GetBitmap(padDescriptor.Icon);
} }
if (padDescriptor.Shortcut != null) { if (padDescriptor.Shortcut != null) {
try { ShortcutKeys = ICSharpCode.Core.MenuCommand.ParseShortcut(padDescriptor.Shortcut);
foreach (string key in padDescriptor.Shortcut) {
ShortcutKeys |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
}
} catch (Exception) {
ShortcutKeys = System.Windows.Forms.Keys.None;
}
} }
} }
@ -432,18 +374,19 @@ namespace ICSharpCode.SharpDevelop.Commands
base.OnClick(e); base.OnClick(e);
padDescriptor.BringPadToFront(); padDescriptor.BringPadToFront();
} }
} }
protected abstract string Category {
protected virtual string Category { get;
get {
return null;
}
} }
public ToolStripItem[] BuildSubmenu(Codon codon, object owner) public ToolStripItem[] BuildSubmenu(Codon codon, object owner)
{ {
Console.WriteLine("Sub menu : " + Category);
Console.WriteLine(WorkbenchSingleton.Workbench.PadContentCollection.Count);
ArrayList items = new ArrayList(); ArrayList items = new ArrayList();
foreach (PadDescriptor padContent in WorkbenchSingleton.Workbench.PadContentCollection) { foreach (PadDescriptor padContent in WorkbenchSingleton.Workbench.PadContentCollection) {
Console.WriteLine(padContent.Category);
if (padContent.Category == Category) { if (padContent.Category == Category) {
items.Add(new MyMenuItem(padContent)); items.Add(new MyMenuItem(padContent));
} }

3
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -368,6 +368,9 @@ namespace ICSharpCode.SharpDevelop.Gui
public void ShowPad(PadDescriptor content) public void ShowPad(PadDescriptor content)
{ {
if (content == null) {
return;
}
if (!contentHash.ContainsKey(content.Class)) { if (!contentHash.ContainsKey(content.Class)) {
DockContent newContent = CreateContent(content); DockContent newContent = CreateContent(content);
newContent.Show(dockPanel); newContent.Show(dockPanel);

4
src/Main/Base/Project/Src/Internal/Erbauer/PadDescriptor.cs

@ -52,9 +52,9 @@ namespace ICSharpCode.Core
/// <summary> /// <summary>
/// Returns the menu shortcut for the view menu item. /// Returns the menu shortcut for the view menu item.
/// </summary> /// </summary>
public string[] Shortcut { public string Shortcut {
get { get {
return codon.Properties["category"].Split('|'); return codon.Properties["shortcut"];
} }
} }

12
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -335,7 +335,6 @@ namespace ICSharpCode.SharpDevelop.Project
} }
} }
static Regex versionPattern = new Regex("Microsoft Visual Studio Solution File, Format Version\\s+(?<Version>.*)", RegexOptions.Compiled); static Regex versionPattern = new Regex("Microsoft Visual Studio Solution File, Format Version\\s+(?<Version>.*)", RegexOptions.Compiled);
static Regex projectLinePattern = new Regex("Project\\(\"(?<ProjectGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"", RegexOptions.Compiled); static Regex projectLinePattern = new Regex("Project\\(\"(?<ProjectGuid>.*)\"\\)\\s+=\\s+\"(?<Title>.*)\",\\s*\"(?<Location>.*)\",\\s*\"(?<Guid>.*)\"", RegexOptions.Compiled);
@ -348,7 +347,6 @@ namespace ICSharpCode.SharpDevelop.Project
using (StreamReader sr = File.OpenText(fileName)) { using (StreamReader sr = File.OpenText(fileName)) {
string line = sr.ReadLine(); string line = sr.ReadLine();
Console.WriteLine("line '{0}'", line);
Match match = versionPattern.Match(line); Match match = versionPattern.Match(line);
if (!match.Success) { if (!match.Success) {
MessageService.ShowError(fileName + " is not a valid solution file."); MessageService.ShowError(fileName + " is not a valid solution file.");
@ -356,6 +354,16 @@ namespace ICSharpCode.SharpDevelop.Project
} }
switch (match.Result("${Version}")) { switch (match.Result("${Version}")) {
case "7.00":
if (!MessageService.AskQuestion("Found VS.NET 2000 Project. Should I convert it to Solution Format 9.00 (VS.NET 2005) ?")) {
return false;
}
break;
case "8.00":
if (!MessageService.AskQuestion("Found VS.NET 2003 Project. Should I convert it to Solution Format 9.00 (VS.NET 2005) ?")) {
return false;
}
break;
case "9.00": case "9.00":
break; break;
default: default:

19
src/Main/Core/Project/Src/AddInTree/AddIn/StandardErbauer/MenuItem/Gui/Menu.cs

@ -29,6 +29,9 @@ namespace ICSharpCode.Core
this.RightToLeft = RightToLeft.Inherit; this.RightToLeft = RightToLeft.Inherit;
CreateDropDownItems(); CreateDropDownItems();
if (DropDownItems.Count == 0 && subItems.Count > 0) {
DropDownItems.Add(new ToolStripMenuItem());
}
} }
void CreateDropDownItems() void CreateDropDownItems()
@ -37,6 +40,7 @@ namespace ICSharpCode.Core
foreach (object item in subItems) { foreach (object item in subItems) {
if (item is ToolStripItem) { if (item is ToolStripItem) {
DropDownItems.Add((ToolStripItem)item); DropDownItems.Add((ToolStripItem)item);
((IStatusUpdate)item).UpdateStatus();
} else { } else {
ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item; ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
DropDownItems.AddRange(submenuBuilder.BuildSubmenu(codon, caller)); DropDownItems.AddRange(submenuBuilder.BuildSubmenu(codon, caller));
@ -46,13 +50,14 @@ namespace ICSharpCode.Core
protected override void OnDropDownShow(EventArgs e) protected override void OnDropDownShow(EventArgs e)
{ {
base.OnDropDownShow(e); base.OnDropDownShow(e);
foreach (object item in subItems) { CreateDropDownItems();
if (item is ToolStripItem) { // foreach (object item in subItems) {
if (item is IStatusUpdate) { // if (item is ToolStripItem) {
((IStatusUpdate)item).UpdateStatus(); // if (item is IStatusUpdate) {
} // ((IStatusUpdate)item).UpdateStatus();
} // }
} // }
// }
} }
protected override void OnDropDownOpened(System.EventArgs e) protected override void OnDropDownOpened(System.EventArgs e)

23
src/Main/Core/Project/Src/AddInTree/AddIn/StandardErbauer/MenuItem/Gui/MenuCommand.cs

@ -54,6 +54,19 @@ namespace ICSharpCode.Core
} }
public static Keys ParseShortcut(string shortcutString)
{
Keys shortCut = Keys.None;
try {
foreach (string key in shortcutString.Split('|')) {
shortCut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
}
} catch (Exception) {
return System.Windows.Forms.Keys.None;
}
return shortCut;
}
public MenuCommand(Codon codon, object caller, bool createCommand) public MenuCommand(Codon codon, object caller, bool createCommand)
{ {
this.RightToLeft = RightToLeft.Inherit; this.RightToLeft = RightToLeft.Inherit;
@ -65,15 +78,7 @@ namespace ICSharpCode.Core
} }
if (codon.Properties.Contains("shortcut")) { if (codon.Properties.Contains("shortcut")) {
Keys shortCut = Keys.None; ShortcutKeys = ParseShortcut(codon.Properties["shortcut"]);
try {
foreach (string key in codon.Properties["shortcut"].Split('|')) {
shortCut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
}
} catch (Exception) {
shortCut = System.Windows.Forms.Keys.None;
}
ShortcutKeys = shortCut;
} }
} }

Loading…
Cancel
Save