diff --git a/src/AddIns/Debugger/Debugger.AddIn/BreakpointChangeMenuBuilder.cs b/src/AddIns/Debugger/Debugger.AddIn/BreakpointChangeMenuBuilder.cs deleted file mode 100644 index d43121392a..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/BreakpointChangeMenuBuilder.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Windows.Controls; - -using Debugger.AddIn.Service; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Gui.Pads; - -namespace Debugger.AddIn -{ - public class BreakpointChangeMenuBuilder : ISubmenuBuilder, IMenuItemBuilder - { - public ToolStripItem[] BuildSubmenu(Codon codon, object owner) - { - List items = new List(); - - ITextEditorProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorProvider; - - BreakpointBookmark point = null; - - foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { - if ((breakpoint.FileName == provider.TextEditor.FileName) && - (breakpoint.LineNumber == provider.TextEditor.Caret.Line)) { - point = breakpoint; - break; - } - } - - if (point != null) { - foreach (string item in BreakpointAction.GetNames(typeof(BreakpointAction))) { - items.Add(MakeItem("${res:MainWindow.Windows.Debug.Conditional.Breakpoints." + item + "}", item, point, point.Action.ToString(), delegate(object sender, EventArgs e) {HandleItem(sender);})); - } - } - - return items.ToArray(); - } - - public ICollection BuildItems(Codon codon, object owner) - { - return BuildSubmenu(codon, owner).TranslateToWpf(); - } - - void HandleItem(object sender) - { - MenuItem item = null; - if (sender is MenuItem) - item = (MenuItem)sender; - - if (item != null) { - BreakpointBookmark bookmark = (BreakpointBookmark)item.Tag; - - switch (item.Name) { - case "Break": - bookmark.Action = BreakpointAction.Break; - break; - case "Condition": - EditBreakpointScriptWindow window = new EditBreakpointScriptWindow(bookmark) { - Owner = WorkbenchSingleton.MainWindow - }; - - if (window.ShowDialog() ?? false) { - bookmark = window.Data; - } - break; - case "Trace": - bookmark.Action = BreakpointAction.Trace; - break; - } - } - } - - ToolStripMenuItem MakeItem(string title, string name, BreakpointBookmark tag, string data, EventHandler onClick) - { - ToolStripMenuItem menuItem = new ToolStripMenuItem(StringParser.Parse(title)); - menuItem.Click += onClick; - menuItem.Name = name; - menuItem.Tag = tag; - - if (name == tag.Action.ToString()) - menuItem.Checked = true; - - return menuItem; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin index 9c20250c3c..a5435a18ef 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin @@ -61,10 +61,9 @@ class="Debugger.AddIn.EnableBreakpointMenuCommand" label= "${res:MainWindow.Windows.Debug.Conditional.Breakpoints.EnableBreakpoint}" /> - + @@ -148,8 +147,6 @@ - diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj index 4badfa23d5..976b5add29 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj @@ -106,14 +106,9 @@ Code - - - - - UserControl @@ -134,6 +129,7 @@ Form + Form diff --git a/src/AddIns/Debugger/Debugger.AddIn/DisableBreakpointMenuCommand.cs b/src/AddIns/Debugger/Debugger.AddIn/DisableBreakpointMenuCommand.cs deleted file mode 100644 index f17794a529..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/DisableBreakpointMenuCommand.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using ICSharpCode.SharpDevelop.Gui.Pads; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Windows.Forms; -using Debugger.AddIn.Service; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; - -namespace Debugger.AddIn -{ - public class DisableBreakpointMenuCommand : AbstractMenuCommand - { - public override void Run() - { - ITextEditor editor = SD.GetActiveViewContentService(); - if (editor == null) - return; - - BreakpointBookmark point = null; - - foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { - if ((breakpoint.FileName == editor.FileName) && - (breakpoint.LineNumber == editor.Caret.Line)) { - point = breakpoint; - break; - } - } - - if (point != null) { - point.IsEnabled = false; - } - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/EnableBreakpointMenuCommand.cs b/src/AddIns/Debugger/Debugger.AddIn/EnableBreakpointMenuCommand.cs deleted file mode 100644 index b77f57aada..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/EnableBreakpointMenuCommand.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using ICSharpCode.SharpDevelop.Gui.Pads; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Windows.Forms; -using Debugger.AddIn.Service; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; - -namespace Debugger.AddIn -{ - public class EnableBreakpointMenuCommand : AbstractMenuCommand - { - public override void Run() - { - ITextEditor editor = SD.GetActiveViewContentService(); - if (editor == null) - return; - - BreakpointBookmark point = null; - - foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { - if ((breakpoint.FileName == editor.FileName) && - (breakpoint.LineNumber == editor.Caret.Line)) { - point = breakpoint; - break; - } - } - - if (point != null) { - point.IsEnabled = true; - } - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/IsActiveBreakpointCondition.cs b/src/AddIns/Debugger/Debugger.AddIn/IsActiveBreakpointCondition.cs deleted file mode 100644 index e6fab5342a..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/IsActiveBreakpointCondition.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using ICSharpCode.SharpDevelop.Gui.Pads; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Windows.Forms; -using Debugger.AddIn.Service; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; - -namespace Debugger.AddIn -{ - public class IsActiveBreakpointCondition : IConditionEvaluator - { - public IsActiveBreakpointCondition() - { - } - - public bool IsValid(object caller, Condition condition) - { - ITextEditor editor = SD.GetActiveViewContentService(); - if (editor == null) - return false; - if (string.IsNullOrEmpty(editor.FileName)) - return false; - - BreakpointBookmark point = null; - - foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { - if ((breakpoint.FileName == editor.FileName) && - (breakpoint.LineNumber == editor.Caret.Line)) { - point = breakpoint; - break; - } - } - - if (point != null) { - return point.IsEnabled; - } - - return false; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/IsBreakpointCondition.cs b/src/AddIns/Debugger/Debugger.AddIn/IsBreakpointCondition.cs deleted file mode 100644 index f459ec02c1..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/IsBreakpointCondition.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using ICSharpCode.SharpDevelop.Gui.Pads; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Windows.Forms; -using Debugger.AddIn.Service; -using ICSharpCode.Core; -using ICSharpCode.Core.Presentation; -using ICSharpCode.Core.WinForms; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.SharpDevelop.Gui; - -namespace Debugger.AddIn -{ - public class IsBreakpointCondition : IConditionEvaluator - { - public IsBreakpointCondition() - { - } - - public bool IsValid(object caller, Condition condition) - { - ITextEditor editor = SD.GetActiveViewContentService(); - if (editor == null) - return false; - if (string.IsNullOrEmpty(editor.FileName)) - return false; - - foreach (BreakpointBookmark mark in DebuggerService.Breakpoints) { - if ((mark.FileName == editor.FileName) && - (mark.LineNumber == editor.Caret.Line)) - return true; - } - - return false; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/SelectLanguageCommand.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/SelectLanguageCommand.cs deleted file mode 100644 index 304b5538d8..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/Commands/SelectLanguageCommand.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) - -using System; -using Debugger; -using Debugger.AddIn; -using ICSharpCode.Core; -using ICSharpCode.NRefactory; -using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Services; -using System.Windows.Controls; - -namespace ICSharpCode.SharpDevelop.Gui.Pads -{ - #warning AbstractComboBoxCommand - /* - class SelectLanguageCommand : AbstractComboBoxCommand - { - ConsolePad pad; - ComboBox box; - - protected override void OnOwnerChanged(EventArgs e) - { - this.pad = this.Owner as ConsolePad; - if (this.pad == null) - return; - - box = this.ComboBox as ComboBox; - - if (this.box == null) - return; - - foreach (var name in Enum.GetNames(typeof(SupportedLanguage))) - box.Items.Add(name); - - box.SelectedIndex = 0; - - base.OnOwnerChanged(e); - } - - public override void Run() - { - if (this.pad != null && this.box != null) { - pad.SelectedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), box.SelectedValue.ToString()); - } - base.Run(); - } - }*/ -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/BreakpointCommands.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/BreakpointCommands.cs new file mode 100644 index 0000000000..c32e38a372 --- /dev/null +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/BreakpointCommands.cs @@ -0,0 +1,75 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the BSD license (for details please see \src\AddIns\Debugger\Debugger.AddIn\license.txt) + +using System; +using System.Collections.Generic; +using System.Linq; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.SharpDevelop.Editor; + +namespace Debugger.AddIn +{ + public static class BreakpointUtil + { + public static IEnumerable BreakpointsOnCaret { + get { + ITextEditor editor = SD.GetActiveViewContentService(); + if (editor == null) + return new BreakpointBookmark[0]; + + return SD.BookmarkManager.Bookmarks.OfType().Where(bp => bp.FileName == editor.FileName && bp.LineNumber == editor.Caret.Line); + } + } + } + + public class EnableBreakpointMenuCommand : AbstractMenuCommand + { + public override void Run() + { + foreach (BreakpointBookmark bp in BreakpointUtil.BreakpointsOnCaret) { + bp.IsEnabled = true; + } + } + } + + public class DisableBreakpointMenuCommand : AbstractMenuCommand + { + public override void Run() + { + foreach (BreakpointBookmark bp in BreakpointUtil.BreakpointsOnCaret) { + bp.IsEnabled = false; + } + } + } + + public class EditBreakpointMenuCommand : AbstractMenuCommand + { + public override void Run() + { + foreach (BreakpointBookmark bp in BreakpointUtil.BreakpointsOnCaret) { + EditBreakpointScriptWindow window = new EditBreakpointScriptWindow(bp) { + Owner = SD.Workbench.MainWindow + }; + window.ShowDialog(); + } + } + } + + public class IsActiveBreakpointCondition : IConditionEvaluator + { + public bool IsValid(object caller, Condition condition) + { + return BreakpointUtil.BreakpointsOnCaret.Any(bp => bp.IsEnabled); + } + } + + public class IsBreakpointCondition : IConditionEvaluator + { + public bool IsValid(object caller, Condition condition) + { + return BreakpointUtil.BreakpointsOnCaret.Any(); + } + } +} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml b/src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml index 36a9adccb1..0d1e335879 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/EditBreakpointScriptWindow.xaml @@ -1,11 +1,6 @@  - + - -