Browse Source

Merge branch 'master' of git://github.com/icsharpcode/SharpDevelop into Edit_PinControl

Conflicts:
	src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs
	src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
	src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs
	src/Main/StartUp/Project/Resources/BitmapResources.resources
pull/11/head
eusebiu 15 years ago
parent
commit
b6976abc2e
  1. 562
      SharpDevelop.Tests.sln
  2. 27
      data/resources/StringResources.resx
  3. 4
      data/resources/image/BitmapResources/BitmapResources.res
  4. BIN
      data/resources/image/BitmapResources/Bookmarks/DeleteAllBreakpoints.PNG
  5. BIN
      data/resources/image/BitmapResources/Bookmarks/DisableAllBreakpoints.PNG
  6. BIN
      data/resources/image/BitmapResources/Bookmarks/NextBreakpoint.png
  7. BIN
      data/resources/image/BitmapResources/Bookmarks/PrevBreakpoint.png
  8. 3
      data/templates/project/VBNet/FormsProject.xpt
  9. 4
      data/templates/project/VBNet/MySettings.settings
  10. 1
      doc/ChangeLog.template.html
  11. 10
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin
  12. 11
      src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj
  13. 26
      src/AddIns/Debugger/Debugger.AddIn/Pads/BreakPointsPad.cs
  14. 22
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml
  15. 190
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml.cs
  16. 56
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/Converters.cs
  17. 74
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeListView.cs
  18. 330
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml
  19. 56
      src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs
  20. 81
      src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs
  21. 2
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml
  22. 52
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs
  23. 149
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
  24. 55
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs
  25. 24
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs
  26. 2
      src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs
  27. 7
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceCodeGeneratorTool.cs
  28. 25
      src/AddIns/DisplayBindings/SettingsEditor/Project/EmptySettingsFile.xft
  29. 81
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsCodeGeneratorTool.cs
  30. 19
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDocument.cs
  31. 11
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.addin
  32. 11
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj
  33. 33
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs
  34. 8
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx
  35. 129
      src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs
  36. 1
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Properties/AssemblyInfo.cs
  37. 7
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.addin
  38. 35
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj
  39. 22
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml
  40. 35
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml.cs
  41. 6
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorController.cs
  42. 37
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorSetupHelper.cs
  43. 3
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/TextEditorContextMenuCommand.cs
  44. 106
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml
  45. 82
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml.cs
  46. 7
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs
  47. 34
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  48. 7
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  49. 11
      src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs
  50. 16
      src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs
  51. 129
      src/Main/Base/Project/Src/Bookmarks/Pad/BookmarkPad.cs
  52. 101
      src/Main/Base/Project/Src/Bookmarks/Pad/BookmarkPadToolbarCommands.cs
  53. 43
      src/Main/Base/Project/Src/Bookmarks/Pad/Controls/ListViewPad.xaml
  54. 243
      src/Main/Base/Project/Src/Bookmarks/Pad/Controls/ListViewPad.xaml.cs
  55. 28
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  56. 31
      src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs
  57. 43
      src/Main/Base/Project/Src/Project/CompilableProject.cs
  58. 12
      src/Main/Base/Project/Src/Project/CustomTool.cs
  59. 86
      src/Main/Base/Project/Src/Util/ExtensionMethods.cs
  60. 12
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs
  61. BIN
      src/Main/StartUp/Project/Resources/BitmapResources.resources
  62. 8
      src/Setup/Files.wxs
  63. 1
      src/Setup/Setup.wxs

562
SharpDevelop.Tests.sln

File diff suppressed because it is too large Load Diff

27
data/resources/StringResources.resx

@ -5645,6 +5645,14 @@ Unable to find 'WelcomeDialogId' in Dialogs.wxs</comment> @@ -5645,6 +5645,14 @@ Unable to find 'WelcomeDialogId' in Dialogs.wxs</comment>
<data name="MainWindow.Windows.BookmarkPad.GotoPrev.ToolTip" xml:space="preserve">
<value>Goto previous bookmark</value>
</data>
<data name="MainWindow.Windows.BookmarkPad.LineText" xml:space="preserve">
<value>{0} @line {1}</value>
<comment>format string for displaying "filename @line #" in the bookmarks pad</comment>
</data>
<data name="MainWindow.Windows.BookmarkPad.LocationText" xml:space="preserve">
<value>Location</value>
<comment>Column title for the bookmark location</comment>
</data>
<data name="MainWindow.Windows.BookmarksLabel" xml:space="preserve">
<value>Bookmarks</value>
</data>
@ -5754,6 +5762,10 @@ Unable to find 'WelcomeDialogId' in Dialogs.wxs</comment> @@ -5754,6 +5762,10 @@ Unable to find 'WelcomeDialogId' in Dialogs.wxs</comment>
<data name="MainWindow.Windows.Debug.Conditional.Breakpoints.Condition" xml:space="preserve">
<value>Conditional</value>
</data>
<data name="MainWindow.Windows.Debug.Conditional.Breakpoints.ConditionalColumnHeader" xml:space="preserve">
<value>Condition</value>
<comment>column title for a conditional breakpoint's condition</comment>
</data>
<data name="MainWindow.Windows.Debug.Conditional.Breakpoints.Continue" xml:space="preserve">
<value>Continue</value>
</data>
@ -6384,6 +6396,17 @@ Removed the end part of the original message ", reason '${Message}'" since this @@ -6384,6 +6396,17 @@ Removed the end part of the original message ", reason '${Message}'" since this
<value>Delete all web references</value>
<comment>Title of the dialog box when the user tries to remove all web references.</comment>
</data>
<data name="ReflectorAddIn.IdeOptions.FindReflectorPath" xml:space="preserve">
<value>Select Reflector path</value>
<comment>Button to select the Reflector path</comment>
</data>
<data name="ReflectorAddIn.IdeOptions.ReflectorFoundInPath" xml:space="preserve">
<value>Reflector was found in the following directory:</value>
</data>
<data name="ReflectorAddIn.IdeOptions.ReflectorTitle" xml:space="preserve">
<value>Reflector</value>
<comment>Title of Reflector path option panel</comment>
</data>
<data name="ReflectorAddIn.OpenReflectorCommand" xml:space="preserve">
<value>Open .NET Reflector</value>
</data>
@ -7835,6 +7858,10 @@ The resources files have been renamed/moved accordingly.</value> @@ -7835,6 +7858,10 @@ The resources files have been renamed/moved accordingly.</value>
<data name="XML.MainMenu.DebugMenu.Error.ProcessRunning" xml:space="preserve">
<value>Can not perform action because process is running.</value>
</data>
<data name="XML.MainMenu.DebugMenu.RemoveAllBreakpoints" xml:space="preserve">
<value>Remove all breakpoints</value>
<comment>Main menu command for removing all breakpoints + tooltip for the corresponding toolbar button (in the breakpoints pad)</comment>
</data>
<data name="XML.MainMenu.DebugMenu.RunWithoutDebug" xml:space="preserve">
<value>Run &amp;without debugger</value>
</data>

4
data/resources/image/BitmapResources/BitmapResources.res

@ -342,6 +342,10 @@ Bookmarks.DisabledBreakpoint = Bookmarks\DisabledBreakpoint @@ -342,6 +342,10 @@ Bookmarks.DisabledBreakpoint = Bookmarks\DisabledBreakpoint
Bookmarks.UnhealthyBreakpoint = Bookmarks\UnhealthyBreakpoint.png
Bookmarks.UnhealthyBreakpointConditional = Bookmarks\UnhealthyBreakpointConditional.png
Bookmarks.CurrentLine = Bookmarks\CurrentLine.png
Bookmarks.DeleteAllBreakpoints = Bookmarks\DeleteAllBreakpoints.png
Bookmarks.DisableAllBreakpoints = Bookmarks\DisableAllBreakpoints.png
Bookmarks.NextBreakpoint = Bookmarks\NextBreakpoint.png
Bookmarks.PrevBreakpoint = Bookmarks\PrevBreakpoint.png
Bookmarks.Pin = Bookmarks\Pin.png

BIN
data/resources/image/BitmapResources/Bookmarks/DeleteAllBreakpoints.PNG

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B

BIN
data/resources/image/BitmapResources/Bookmarks/DisableAllBreakpoints.PNG

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

BIN
data/resources/image/BitmapResources/Bookmarks/NextBreakpoint.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

BIN
data/resources/image/BitmapResources/Bookmarks/PrevBreakpoint.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

3
data/templates/project/VBNet/FormsProject.xpt

@ -105,7 +105,7 @@ Namespace My @@ -105,7 +105,7 @@ Namespace My
MyBase.New(AuthenticationMode.Windows)
Me.IsSingleInstance = False
Me.EnableVisualStyles = True
Me.SaveMySettingsOnExit = False ' MySettings are not supported in SharpDevelop.
Me.SaveMySettingsOnExit = True
Me.ShutDownStyle = ShutdownMode.AfterMainFormCloses
End Sub
@ -116,6 +116,7 @@ Namespace My @@ -116,6 +116,7 @@ Namespace My
End Namespace
]]></File>
<File name="Properties\AssemblyInfo.vb" src="DefaultAssemblyInfo.vb"/>
<File name="Properties\Settings.settings" src="MySettings.settings" Generator="SettingsSingleFileGenerator"/>
</Files>
</Project>
</Template>

4
data/templates/project/VBNet/MySettings.settings

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="True">
<Profiles />
<Settings />
</SettingsFile>

1
doc/ChangeLog.template.html

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
<p>
SharpDevelop $INSERTVERSION$ ($INSERTDATE$)
<ul>
<li>Added settings editor</li>
<li>Bug fixes</li>
</ul>
</p>

10
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin

@ -68,12 +68,12 @@ @@ -68,12 +68,12 @@
</Path>
<Path name = "/SharpDevelop/Workbench/Pads">
<!--<Pad id = "BreakPointsPad"
<Pad id = "BreakPointsPad"
category = "Debugger"
title = "${res:MainWindow.Windows.Debug.Breakpoints}"
icon = "PadIcons.BreakPoints"
class = "ICSharpCode.SharpDevelop.Gui.Pads.BreakPointsPad"
defaultPosition = "Bottom, Hidden" />-->
defaultPosition = "Bottom, Hidden" />
<Pad id = "CallStackPad"
category = "Debugger"
@ -129,15 +129,15 @@ @@ -129,15 +129,15 @@
<MenuItem id="AddWatch" label="${res:MainWindow.Windows.Debug.Watch.AddWatch}" class="Debugger.AddIn.AddWatchCommand" />
<MenuItem id="RemoveWatch" label="${res:MainWindow.Windows.Debug.Watch.RemoveWatch}" class="Debugger.AddIn.RemoveWatchCommand" />
<MenuItem id="ClearWatches" label="${res:MainWindow.Windows.Debug.Watch.RemoveAll}" class="Debugger.AddIn.ClearWatchesCommand" />
<MenuItem id="SelectLanguage" label="Select language" type="Menu">
<MenuItem id="Builder" class="Debugger.AddIn.WatchScriptingLanguageMenuBuilder" type="Builder" />
</MenuItem>
<Condition name = "IsProcessRunning" isdebugging="True">
<Condition name = "IsProcessRunning" isdebugging="True" isprocessrunning="False">
<MenuItem id="Separator1" type="Separator" />
<MenuItem id="RefreshWatches" label="${res:MainWindow.Windows.Debug.Watch.Refresh}" class="Debugger.AddIn.RefreshWatchesCommand" />
</Condition>
</Condition>
<MenuItem id="Separator2" type="Separator" />
<MenuItem id="CopyToClipboard" label="${res:MainWindow.Windows.Debug.LocalVariables.CopyToClipboard}" class="Debugger.AddIn.CopyToClipboardCommand"/>
</Path>
<Path name = "/SharpDevelop/Dialogs/OptionsDialog">

11
src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj

@ -91,6 +91,14 @@ @@ -91,6 +91,14 @@
<DependentUpon>CallStackPad.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Pads\Controls\ConditionCell.xaml.cs">
<DependentUpon>ConditionCell.xaml</DependentUpon>
</Compile>
<Compile Include="Pads\Controls\Converters.cs" />
<Compile Include="Pads\Controls\TreeListView.cs" />
<Compile Include="Pads\Controls\WatchList.xaml.cs">
<DependentUpon>WatchList.xaml</DependentUpon>
</Compile>
<Compile Include="Pads\WatchInputBox.xaml.cs">
<DependentUpon>WatchInputBox.xaml</DependentUpon>
<SubType>Code</SubType>
@ -336,6 +344,8 @@ @@ -336,6 +344,8 @@
</ItemGroup>
<ItemGroup>
<Page Include="Pads\CallStackPad.xaml" />
<Page Include="Pads\Controls\ConditionCell.xaml" />
<Page Include="Pads\Controls\WatchList.xaml" />
<Page Include="Pads\WatchInputBox.xaml" />
<Page Include="Service\EditBreakpointScriptWindow.xaml" />
<Page Include="Visualizers\Graph\Drawing\NodeControlResources.xaml" />
@ -358,6 +368,7 @@ @@ -358,6 +368,7 @@
<Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="Pads\Controls" />
<Folder Include="Visualizers\Graph" />
<Folder Include="Visualizers\Graph\Drawing" />
<Folder Include="Visualizers\Graph\Layout" />

26
src/AddIns/Debugger/Debugger.AddIn/Pads/BreakPointsPad.cs

@ -1,7 +1,12 @@ @@ -1,7 +1,12 @@
// 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.Windows;
using System.Windows.Controls;
using Debugger;
using Debugger.AddIn.Pads.Controls;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Services;
@ -16,6 +21,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -16,6 +21,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public BreakPointsPad()
{
InitializeComponents();
myPanel.Children.Add(CreateToolBar());
CreateColumns();
}
void InitializeComponents()
@ -36,6 +45,23 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -36,6 +45,23 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
debuggerCore = debugger.DebuggerCore;
}
protected override ToolBar CreateToolBar()
{
ToolBar toolbar = ToolBarService.CreateToolBar(this, "/SharpDevelop/Pads/BreakpointPad/Toolbar");
toolbar.SetValue(Grid.RowProperty, 0);
return toolbar;
}
protected override void CreateColumns()
{
string conditionHeader = StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.ConditionalColumnHeader}");
// HACK
DataTemplate cellTemplate = new ConditionCell().FindResource("ConditionCellTemplate") as DataTemplate;
listView.AddColumn(conditionHeader, cellTemplate);
}
protected override bool ShowBookmarkInThisPad(SDBookmark mark)
{
return mark.IsVisibleInBookmarkPad && mark is BreakpointBookmark;

22
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
<UserControl x:Class="Debugger.AddIn.Pads.Controls.ConditionCell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:SDGui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"
xmlns:local="clr-namespace:Debugger.AddIn.Pads.Controls">
<UserControl.Resources>
<DataTemplate x:Key="ConditionCellTemplate">
<Grid HorizontalAlignment="Stretch">
<local:ConditionCell
CommandText="{Binding Path=Condition, UpdateSourceTrigger=LostFocus}"
Tag="{Binding Path=Tag, Mode=TwoWay}"/>
</Grid>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="200"/>
</Grid.ColumnDefinitions>
<ContentPresenter
Name="ConsolePanel" />
</Grid>
</UserControl>

190
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/ConditionCell.xaml.cs

@ -0,0 +1,190 @@ @@ -0,0 +1,190 @@

using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace Debugger.AddIn.Pads.Controls
{
public partial class ConditionCell : UserControl
{
private string language;
protected ConsoleControl console;
public static readonly DependencyProperty CommandTextProperty =
DependencyProperty.Register("CommandText", typeof(string), typeof(ConditionCell),
new UIPropertyMetadata(null, new PropertyChangedCallback(OnCommandTextChanged)));
private NRefactoryResolver resolver;
public ConditionCell()
{
InitializeComponent();
console = new ConsoleControl();
console.TextAreaTextEntered += new TextCompositionEventHandler(consoleControl_TextAreaTextEntered);
console.TextAreaPreviewKeyDown += new KeyEventHandler(console_TextAreaPreviewKeyDown);
console.LostFocus += new RoutedEventHandler(console_LostFocus);
console.HideScrollBar();
ConsolePanel.Content = console;
// get language
if (ProjectService.CurrentProject == null)
language = "C#";
else
language = ProjectService.CurrentProject.Language;
resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language));
// FIXME set language
if (language == "VB" || language == "VBNet") {
console.SetHighlighting("VBNET");
}
else {
console.SetHighlighting("C#");
}
}
/// <summary>
/// Gets/sets the command text displayed at the command prompt.
/// </summary>
public string CommandText {
get { return console.CommandText.Trim(); }
set { console.CommandText = value; }
}
private BreakpointBookmark Breakpoint {
get {
var model = Model;
return model.Mark as BreakpointBookmark;
}
}
private ListViewPadItemModel Model {
get { return Tag as ListViewPadItemModel; }
}
private ITextEditor TextEditor {
get {
return console.TextEditor;
}
}
private void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Escape) {
if (e.Key == Key.Escape)
CommandText = string.Empty;
else {
if(!CheckSyntax())
return;
}
UpdateBreakpoint();
e.Handled = true;
}
}
private void console_LostFocus(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(CommandText) || !this.CheckSyntax())
return;
UpdateBreakpoint();
}
private void UpdateBreakpoint()
{
Breakpoint.Condition = CommandText;
Model.Condition = CommandText;
Breakpoint.ScriptLanguage = language;
Model.Language = language;
if (!string.IsNullOrEmpty(console.CommandText)) {
Breakpoint.Action = BreakpointAction.Condition;
Model.Image = PresentationResourceService.GetImage("Bookmarks.BreakpointConditional").Source;
}
else {
Breakpoint.Action = BreakpointAction.Break;
Model.Image = PresentationResourceService.GetImage("Bookmarks.Breakpoint").Source;
}
}
private bool CheckSyntax()
{
string command = CommandText;
// FIXME workaround the NRefactory issue that needs a ; at the end
if (language == "C#") {
if(!command.EndsWith(";"))
command += ";";
// FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
language = "CSharp";
}
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.ToString(), true);
using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(TextEditor.Document.Text))) {
parser.ParseExpression();
if (parser.Errors.Count > 0) {
MessageService.ShowError(parser.Errors.ErrorOutput);
return false;
}
}
return true;
}
private void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e)
{
foreach (char ch in e.Text) {
if (ch == '.') {
ShowDotCompletion(console.CommandText);
}
}
}
private void ShowDotCompletion(string currentText)
{
var seg = Breakpoint;
var expressionFinder = ParserService.GetExpressionFinder(seg.FileName.ToString());
var info = ParserService.GetParseInformation(seg.FileName.ToString());
string text = ParserService.GetParseableFileContent(seg.FileName.ToString()).Text;
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1;
var expr = expressionFinder.FindExpression(currentText, currentOffset);
expr.Region = new DomRegion(seg.LineNumber, seg.ColumnNumber, seg.LineNumber, seg.ColumnNumber);
var rr = resolver.Resolve(expr, info, text);
if (rr != null) {
TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context));
}
}
private static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
var cell = d as ConditionCell;
cell.CommandText = e.NewValue.ToString();
}
}
}

56
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/Converters.cs

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
namespace Debugger.AddIn.Pads.Controls
{
public class TreeListViewConverter : IValueConverter
{
private const double INDENTATION_SIZE = 10;
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return null;
if (targetType == typeof(double) && typeof(DependencyObject).IsAssignableFrom(value.GetType()))
{
DependencyObject element = value as DependencyObject;
int level = -1;
for (; element != null; element = VisualTreeHelper.GetParent(element)) {
if (typeof(TreeViewItem).IsAssignableFrom(element.GetType())) {
level++;
}
}
return INDENTATION_SIZE * level;
}
throw new NotSupportedException();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException("This method is not supported.");
}
}
public class BoolToVisibilityConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType,
object parameter, CultureInfo culture)
{
bool val = bool.Parse(parameter.ToString());
return val == (bool.Parse(values[0].ToString()) && bool.Parse(values[1].ToString())) ? Visibility.Visible : Visibility.Collapsed;
}
public object[] ConvertBack(object value, Type[] targetTypes,
object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

74
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/TreeListView.cs

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using Debugger.AddIn.TreeModel;
namespace Debugger.AddIn.Pads.Controls
{
/// <summary>
/// Represents a control that displays hierarchical data in a tree structure
/// that has items that can expand and collapse.
/// </summary>
public class TreeListView : TreeView
{
static TreeListView()
{
//Override the default style and the default control template
DefaultStyleKeyProperty.OverrideMetadata(typeof(TreeListView), new FrameworkPropertyMetadata(typeof(TreeListView)));
}
/// <summary>
/// Initialize a new instance of TreeListView.
/// </summary>
public TreeListView()
{
Columns = new GridViewColumnCollection();
}
#region Properties
/// <summary>
/// Gets or sets the collection of System.Windows.Controls.GridViewColumn
/// objects that is defined for this TreeListView.
/// </summary>
public GridViewColumnCollection Columns
{
get { return (GridViewColumnCollection)GetValue(ColumnsProperty); }
set { SetValue(ColumnsProperty, value); }
}
/// <summary>
/// Gets or sets whether columns in a TreeListView can be
/// reordered by a drag-and-drop operation. This is a dependency property.
/// </summary>
public bool AllowsColumnReorder
{
get { return (bool)GetValue(AllowsColumnReorderProperty); }
set { SetValue(AllowsColumnReorderProperty, value); }
}
#endregion
#region Static Dependency Properties
// Using a DependencyProperty as the backing store for AllowsColumnReorder. This enables animation, styling, binding, etc...
public static readonly DependencyProperty AllowsColumnReorderProperty =
DependencyProperty.Register("AllowsColumnReorder", typeof(bool), typeof(TreeListView), new UIPropertyMetadata(null));
// Using a DependencyProperty as the backing store for Columns. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColumnsProperty =
DependencyProperty.Register("Columns", typeof(GridViewColumnCollection),
typeof(TreeListView),
new UIPropertyMetadata(null));
#endregion
}
/// <summary>
/// Represents a control that can switch states in order to expand a node of a TreeListView.
/// </summary>
public class TreeListViewExpander : ToggleButton { }
}

330
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml

@ -0,0 +1,330 @@ @@ -0,0 +1,330 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="Debugger.AddIn.Pads.Controls.WatchList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:localControls="clr-namespace:Debugger.AddIn.Pads.Controls" xmlns:core="http://icsharpcode.net/sharpdevelop/core"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
Background="White">
<UserControl.Resources>
<localControls:BoolToVisibilityConverter
x:Key="boolToVisibility" />
<localControls:TreeListViewConverter
x:Key="TreeListViewConverter" />
<Style
x:Key="BorderStyle"
TargetType="Border">
<Setter
Property="BorderBrush"
Value="LightGray" />
<Setter
Property="BorderThickness"
Value="1,0,1,1"></Setter>
<Setter
Property="VerticalAlignment"
Value="Center" />
<Setter
Property="HorizontalAlignment"
Value="Stretch" />
</Style>
<Style
TargetType="{x:Type TextBox}"
x:Key="TextBoxStyle">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="White"/>
<Setter
Property="VerticalAlignment"
Value="Center" />
<Setter
Property="Visibility">
<Setter.Value>
<MultiBinding
Converter="{StaticResource boolToVisibility}"
ConverterParameter="True">
<Binding
Path="CanSetText" />
<Binding
Path="IsSelected"
RelativeSource="{RelativeSource AncestorType=TreeViewItem}" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
<Style
TargetType="{x:Type TextBlock}"
x:Key="TextBlockStyle">
<Setter
Property="VerticalAlignment"
Value="Center" />
<Setter
Property="Visibility">
<Setter.Value>
<MultiBinding
Converter="{StaticResource boolToVisibility}"
ConverterParameter="False">
<Binding
Path="CanSetText" />
<Binding
Path="IsSelected"
RelativeSource="{RelativeSource AncestorType=TreeViewItem}" />
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="ExpandToggleStyle"
TargetType="{x:Type ToggleButton}">
<Setter
Property="Focusable"
Value="False" />
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="ToggleButton">
<Grid
Width="21"
Height="16">
<Path
x:Name="ExpandPath"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="5,0,1,1"
Stroke="Black"
Fill="Transparent"
Data="M 4 0 L 8 4 L 4 8 Z" />
</Grid>
<ControlTemplate.Triggers>
<Trigger
Property="IsChecked"
Value="True">
<Setter
Property="Data"
TargetName="ExpandPath"
Value="M 0 4 L 8 4 L 4 8 Z" />
<Setter
TargetName="ExpandPath"
Property="Fill"
Value="Black" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- TreeViewItem-->
<ControlTemplate
TargetType="TreeViewItem"
x:Key="TreeListViewItem">
<StackPanel>
<Border
Style="{StaticResource BorderStyle}"
x:Name="Border">
<GridViewRowPresenter
Content="{TemplateBinding Header}"
Columns="{Binding Columns,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=localControls:TreeListView}}" />
</Border>
<ItemsPresenter
x:Name="ItemsPresenter"
Visibility="Collapsed" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger
Property="IsExpanded"
Value="True">
<Setter
TargetName="ItemsPresenter"
Property="Visibility"
Value="Visible" />
</Trigger>
<Trigger
Property="IsSelected"
Value="true">
<Setter
TargetName="Border"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
<Setter
Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition
Property="IsSelected"
Value="true" />
<Condition
Property="IsSelectionActive"
Value="false" />
</MultiTrigger.Conditions>
<Setter
TargetName="Border"
Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<Setter
Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
</MultiTrigger>
<Trigger
Property="IsEnabled"
Value="false">
<Setter
Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!--TreeListViewExpander-->
<ControlTemplate
TargetType="{x:Type localControls:TreeListViewExpander}"
x:Key="TreeListViewExpander">
<StackPanel
Orientation="Horizontal"
x:Name="ContainerElement">
<FrameworkElement
Width="{Binding RelativeSource={x:Static RelativeSource.Self},Converter={StaticResource TreeListViewConverter}}" />
<ToggleButton
Style="{StaticResource ExpandToggleStyle}"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=TreeViewItem}}" />
</StackPanel>
</ControlTemplate>
<!--TreeListView-->
<Style
TargetType="{x:Type localControls:TreeListView}">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type localControls:TreeListView}">
<ControlTemplate.Resources>
<Style
TargetType="TreeViewItem">
<Setter
Property="Template"
Value="{StaticResource TreeListViewItem}" />
</Style>
<Style
TargetType="localControls:TreeListViewExpander">
<Setter
Property="Template"
Value="{StaticResource TreeListViewExpander}" />
</Style>
</ControlTemplate.Resources>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Disabled">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="*" />
</Grid.RowDefinitions>
<GridViewHeaderRowPresenter
Columns="{TemplateBinding Columns}"
AllowsColumnReorder="{TemplateBinding AllowsColumnReorder}" />
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto"
Grid.Row="1">
<ItemsPresenter />
</ScrollViewer>
</Grid>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Name column -->
<DataTemplate
x:Key="CellTemplate_Name">
<StackPanel
Orientation="Horizontal">
<localControls:TreeListViewExpander
x:Name="Expander" />
<Image
MaxHeight="16"
MaxWidth="16"
Margin="3,0,0,0"
Source="{Binding Path=ImageSource}"
VerticalAlignment="Center" />
<TextBlock
Margin="3,0,0,0"
MinWidth="400"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Text="{Binding Path=Name}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger
Binding="{Binding Path=HasChildNodes}"
Value="False">
<Setter
TargetName="Expander"
Property="Visibility"
Value="Hidden" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
<!-- Value column -->
<DataTemplate
x:Key="CellTemplate_Value">
<StackPanel
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
MinWidth="200"
Text="{Binding Path=Text}"
Style="{StaticResource TextBlockStyle}" />
<TextBox
Text="{Binding Path=Text, Mode=OneWay}"
Style="{StaticResource TextBoxStyle}" KeyUp="TextBox_KeyUp" />
</StackPanel>
</DataTemplate>
<!-- Type column -->
<DataTemplate
x:Key="CellTemplate_Type">
<TextBlock
VerticalAlignment="Center"
MinWidth="200"
Text="{Binding Path=Type}" />
</DataTemplate>
</UserControl.Resources>
<DockPanel>
<localControls:TreeListView
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding Path=WatchItems}"
x:Name="MyList">
<localControls:TreeListView.ItemTemplate>
<HierarchicalDataTemplate
ItemsSource="{Binding ChildNodes}"/>
</localControls:TreeListView.ItemTemplate>
<localControls:TreeListView.Resources>
<Style x:Key="ColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left"></Setter>
</Style>
</localControls:TreeListView.Resources>
<localControls:TreeListView.Columns>
<GridViewColumn
Width="400"
HeaderContainerStyle="{StaticResource ColumnHeaderStyle}"
Header="{core:Localize Global.Name}"
CellTemplate="{StaticResource CellTemplate_Name}"></GridViewColumn>
<GridViewColumn
Width="200"
HeaderContainerStyle="{StaticResource ColumnHeaderStyle}"
Header="{core:Localize Dialog.HighlightingEditor.Properties.Value}"
CellTemplate="{StaticResource CellTemplate_Value}" />
<GridViewColumn
Width="200"
HeaderContainerStyle="{StaticResource ColumnHeaderStyle}"
Header="{core:Localize ResourceEditor.ResourceEdit.TypeColumn}"
CellTemplate="{StaticResource CellTemplate_Type}" />
</localControls:TreeListView.Columns>
</localControls:TreeListView>
</DockPanel>
</UserControl>

56
src/AddIns/Debugger/Debugger.AddIn/Pads/Controls/WatchList.xaml.cs

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Debugger.AddIn.TreeModel;
namespace Debugger.AddIn.Pads.Controls
{
public partial class WatchList : UserControl
{
private ObservableCollection<TreeNode> items = new ObservableCollection<TreeNode>();
public WatchList()
{
InitializeComponent();
}
void TextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key != Key.Enter && e.Key != Key.Escape)
{
e.Handled = true;
return;
}
if (e.Key == Key.Enter) {
if(SelectedNode is ExpressionNode) {
var node = (ExpressionNode)SelectedNode;
node.SetText(((TextBox)sender).Text);
}
}
if (e.Key == Key.Enter || e.Key == Key.Escape) {
for (int i = 0; i < MyList.Items.Count; i++) {
TreeViewItem child = (TreeViewItem)MyList.ItemContainerGenerator.ContainerFromIndex(i);
child.IsSelected = false;
}
}
}
public ObservableCollection<TreeNode> WatchItems { get { return items; } }
public TreeNode SelectedNode {
get {
return this.MyList.SelectedItem as TreeNode;
}
}
}
}

81
src/AddIns/Debugger/Debugger.AddIn/Pads/LocalVarPad.cs

@ -1,26 +1,21 @@ @@ -1,26 +1,21 @@
// 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.Windows.Forms;
using Aga.Controls.Tree;
using Aga.Controls.Tree.NodeControls;
using System.Collections.ObjectModel;
using Debugger;
using Debugger.AddIn.Pads.Controls;
using Debugger.AddIn.TreeModel;
using ICSharpCode.Core;
using Exception=System.Exception;
using Exception = System.Exception;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
public class LocalVarPad : DebuggerPad
{
TreeViewAdv localVarList;
WatchList localVarList;
Process debuggedProcess;
static LocalVarPad instance;
readonly TreeColumn nameColumn = new TreeColumn();
readonly TreeColumn valColumn = new TreeColumn();
readonly TreeColumn typeColumn = new TreeColumn();
public LocalVarPad()
{
instance = this;
@ -46,44 +41,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -46,44 +41,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
protected override void InitializeComponents()
{
localVarList = new TreeViewAdv();
localVarList.Columns.Add(nameColumn);
localVarList.Columns.Add(valColumn);
localVarList.Columns.Add(typeColumn);
localVarList.UseColumns = true;
localVarList.SelectionMode = TreeSelectionMode.Single;
localVarList.LoadOnDemand = true;
NodeIcon iconControl = new ItemIcon();
iconControl.ParentColumn = nameColumn;
localVarList.NodeControls.Add(iconControl);
NodeTextBox nameControl = new ItemName();
nameControl.ParentColumn = nameColumn;
localVarList.NodeControls.Add(nameControl);
NodeTextBox textControl = new ItemText();
textControl.ParentColumn = valColumn;
localVarList.NodeControls.Add(textControl);
NodeTextBox typeControl = new ItemType();
typeControl.ParentColumn = typeColumn;
localVarList.NodeControls.Add(typeControl);
localVarList.AutoRowHeight = true;
RedrawContent();
ResourceService.LanguageChanged += delegate { RedrawContent(); };
}
public void RedrawContent()
{
nameColumn.Header = ResourceService.GetString("Global.Name");
nameColumn.Width = 250;
valColumn.Header = ResourceService.GetString("Dialog.HighlightingEditor.Properties.Value");
valColumn.Width = 300;
typeColumn.Header = ResourceService.GetString("ResourceEditor.ResourceEdit.TypeColumn");
typeColumn.Width = 250;
localVarList = new WatchList();
}
protected override void SelectProcess(Process process)
@ -106,26 +64,39 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -106,26 +64,39 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
public override void RefreshPad()
{
if (debuggedProcess == null || debuggedProcess.IsRunning || debuggedProcess.SelectedStackFrame == null) {
localVarList.Root.Children.Clear();
localVarList.WatchItems.Clear();
return;
}
using(new PrintTimes("Local Variables refresh")) {
try {
localVarList.BeginUpdate();
Utils.DoEvents(debuggedProcess);
TreeViewVarNode.SetContentRecursive(debuggedProcess, localVarList, new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes);
} catch(AbortedBecauseDebuggeeResumedException) {
} catch(Exception) {
foreach (var item in new StackFrameNode(debuggedProcess.SelectedStackFrame).ChildNodes) {
if (!localVarList.WatchItems.ContainsItem(item))
localVarList.WatchItems.Add(item);
}
}
catch(AbortedBecauseDebuggeeResumedException) { }
catch(Exception ex) {
if (debuggedProcess == null || debuggedProcess.HasExited) {
// Process unexpectedly exited
} else {
throw;
MessageService.ShowException(ex);
}
} finally {
localVarList.EndUpdate();
}
}
}
}
public static class ExtensionForWatchItems
{
public static bool ContainsItem(this ObservableCollection<TreeNode> collection, TreeNode node)
{
foreach (var item in collection)
if (item.CompareTo(node) == 0)
return true;
return false;
}
}
}

2
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<src:BaseWatchBox
x:Class="Debugger.AddIn.Pads.WatchInputBox" xmlns:src="clr-namespace:ICSharpCode.SharpDevelop.Gui.Pads;assembly=ICSharpCode.SharpDevelop" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
Style="{x:Static core:GlobalStyles.DialogWindowStyle}"

52
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchInputBox.xaml.cs

@ -1,15 +1,18 @@ @@ -1,15 +1,18 @@
using System;
using System;
using System.IO;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.AvalonEdit;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Services;
namespace Debugger.AddIn.Pads
@ -20,6 +23,7 @@ namespace Debugger.AddIn.Pads @@ -20,6 +23,7 @@ namespace Debugger.AddIn.Pads
public partial class WatchInputBox : BaseWatchBox
{
private NRefactoryResolver resolver;
private string language;
public WatchInputBox(string text, string caption) : base()
{
@ -29,11 +33,20 @@ namespace Debugger.AddIn.Pads @@ -29,11 +33,20 @@ namespace Debugger.AddIn.Pads
text = StringParser.Parse(text);
this.Title = StringParser.Parse(caption);
this.ConsolePanel.Content = console;
if (ProjectService.CurrentProject == null) return;
// get language
language = ProjectService.CurrentProject.Language;
resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language));
// FIXME: for testing only
var language = LanguageProperties.CSharp;
resolver = new NRefactoryResolver(language);
console.SetHighlighting("C#");
// FIXME set language
if (language == "VB" || language == "VBNet") {
console.SetHighlighting("VBNET");
}
else {
console.SetHighlighting("C#");
}
// get process
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger;
@ -83,8 +96,35 @@ namespace Debugger.AddIn.Pads @@ -83,8 +96,35 @@ namespace Debugger.AddIn.Pads
}
}
private bool CheckSyntax()
{
string command = console.CommandText.Trim();
// FIXME workaround the NRefactory issue that needs a ; at the end
if (language == "C#") {
if(!command.EndsWith(";"))
command += ";";
// FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
language = "CSharp";
}
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.ToString(), true);
using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) {
parser.ParseExpression();
if (parser.Errors.Count > 0) {
MessageService.ShowError(parser.Errors.ErrorOutput);
return false;
}
}
return true;
}
private void AcceptButton_Click(object sender, RoutedEventArgs e)
{
if (!this.CheckSyntax())
return;
this.DialogResult = true;
this.Close();
}
@ -95,4 +135,4 @@ namespace Debugger.AddIn.Pads @@ -95,4 +135,4 @@ namespace Debugger.AddIn.Pads
this.Close();
}
}
}
}

149
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs

@ -3,29 +3,26 @@ @@ -3,29 +3,26 @@
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using System.Windows;
using System.Windows.Input;
using Aga.Controls.Tree;
using Aga.Controls.Tree.NodeControls;
using Debugger;
using Debugger.AddIn;
using Debugger.AddIn.Pads.Controls;
using Debugger.AddIn.TreeModel;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop.Project;
using Exception = System.Exception;
namespace ICSharpCode.SharpDevelop.Gui.Pads
{
public class WatchPad : DebuggerPad
{
TreeViewAdv watchList;
WatchList watchList;
Process debuggedProcess;
List<TextNode> watches;
static WatchPad instance;
/// <remarks>Always check if Instance is null, might be null if pad is not opened!</remarks>
@ -37,15 +34,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -37,15 +34,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
{
instance = this;
}
public List<TextNode> Watches {
get { return watches; }
}
readonly TreeColumn nameColumn = new TreeColumn();
readonly TreeColumn valColumn = new TreeColumn();
readonly TreeColumn typeColumn = new TreeColumn();
/// <remarks>
/// This is not used anywhere, but it is neccessary to be overridden in children of AbstractPadContent.
/// </remarks>
@ -61,74 +50,51 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -61,74 +50,51 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
protected override void InitializeComponents()
{
watchList = new TreeViewAdv();
watchList.Columns.Add(nameColumn);
watchList.Columns.Add(valColumn);
watchList.Columns.Add(typeColumn);
watchList.UseColumns = true;
watchList.SelectionMode = TreeSelectionMode.Single;
watchList.LoadOnDemand = true;
NodeIcon iconControl = new ItemIcon();
iconControl.ParentColumn = nameColumn;
watchList.NodeControls.Add(iconControl);
NodeTextBox nameControl = new WatchItemName();
nameControl.ParentColumn = nameColumn;
watchList.NodeControls.Add(nameControl);
NodeTextBox textControl = new ItemText();
textControl.ParentColumn = valColumn;
watchList.NodeControls.Add(textControl);
NodeTextBox typeControl = new ItemType();
typeControl.ParentColumn = typeColumn;
watchList.NodeControls.Add(typeControl);
watchList.AutoRowHeight = true;
watchList.MouseDoubleClick += new MouseEventHandler(watchList_DoubleClick);
watchList.ContextMenuStrip = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
watchList = new WatchList();
watchList.MouseDoubleClick += watchList_DoubleClick;
watchList.ContextMenu = MenuService.CreateContextMenu(this, "/SharpDevelop/Pads/WatchPad/ContextMenu");
watchList.AllowDrop = true;
watchList.DragEnter += new DragEventHandler(watchList_DragEnter);
watchList.DragDrop += new DragEventHandler(watchList_DragDrop);
watchList.KeyUp += new KeyEventHandler(watchList_KeyUp);
watches = new List<TextNode>();
ResourceService.LanguageChanged += delegate { OnLanguageChanged(); };
OnLanguageChanged();
watchList.DragEnter += watchList_DragOver;
watchList.Drop += watchList_Drop;
watchList.KeyUp += watchList_KeyUp;
}
void watchList_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete) {
if (e.Key == Key.Delete) {
RemoveWatchCommand cmd = new RemoveWatchCommand { Owner = this };
cmd.Run();
}
}
void watchList_DragDrop(object sender, DragEventArgs e)
void watchList_Drop(object sender, DragEventArgs e)
{
watchList.BeginUpdate();
TextNode text = new TextNode(e.Data.GetData(DataFormats.StringFormat).ToString(), SupportedLanguage.CSharp);
TreeViewVarNode node = new TreeViewVarNode(this.debuggedProcess, this.watchList, text);
watches.Add(text);
watchList.Root.Children.Add(node);
watchList.EndUpdate();
if (ProjectService.CurrentProject == null) return;
if (e.Data == null) return;
if (!e.Data.GetDataPresent(DataFormats.StringFormat)) return;
if (string.IsNullOrEmpty(e.Data.GetData(DataFormats.StringFormat).ToString())) return;
node.IsSelected = true;
string language = ProjectService.CurrentProject.Language;
// FIXME languages
TextNode text = new TextNode(e.Data.GetData(DataFormats.StringFormat).ToString(),
language == "VB" || language == "VBNet" ? SupportedLanguage.VBNet : SupportedLanguage.CSharp);
if (!watchList.WatchItems.Contains(text))
watchList.WatchItems.ContainsItem(text);
this.RefreshPad();
}
void watchList_DragEnter(object sender, DragEventArgs e)
void watchList_DragOver(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.StringFormat)) {
e.Effect = DragDropEffects.Copy;
e.Effects = DragDropEffects.Copy;
}
else {
e.Effect = DragDropEffects.None;
e.Effects = DragDropEffects.None;
e.Handled = true;
}
}
@ -143,23 +109,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -143,23 +109,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void ResetPad(object sender, EventArgs e)
{
watchList.BeginUpdate();
watchList.Root.Children.Clear();
string language = ProjectService.CurrentProject.Language;
foreach (TextNode text in watches)
watchList.Root.Children.Add(new TreeViewVarNode(this.debuggedProcess, this.watchList, text));
// rebuild list
var nodes = new List<TreeNode>();
foreach (var nod in watchList.WatchItems)
nodes.Add(new TextNode(nod.Name,
language == "VB" || language == "VBNet" ? SupportedLanguage.VBNet : SupportedLanguage.CSharp));
watchList.EndUpdate();
}
void OnLanguageChanged()
{
nameColumn.Header = ResourceService.GetString("Global.Name");
nameColumn.Width = 250;
valColumn.Header = ResourceService.GetString("Dialog.HighlightingEditor.Properties.Value");
valColumn.Width = 300;
typeColumn.Header = ResourceService.GetString("ResourceEditor.ResourceEdit.TypeColumn");
typeColumn.Width = 250;
watchList.WatchItems.Clear();
foreach (var nod in nodes)
watchList.WatchItems.Add(nod);
}
protected override void SelectProcess(Process process)
@ -188,30 +148,31 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -188,30 +148,31 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
using(new PrintTimes("Watch Pad refresh")) {
try {
watchList.BeginUpdate();
Utils.DoEvents(debuggedProcess);
List<TreeViewVarNode> nodes = new List<TreeViewVarNode>();
List<TreeNode> nodes = new List<TreeNode>();
foreach (var nod in watches) {
foreach (var nod in watchList.WatchItems) {
try {
LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(nod.Name) ? "is null or empty!" : nod.Name));
var nodExpression = debugger.GetExpression(nod.Name);
//Value val = ExpressionEvaluator.Evaluate(nod.Name, nod.Language, debuggedProcess.SelectedStackFrame);
ExpressionNode valNode = new ExpressionNode(null, nod.Name, nodExpression);
nodes.Add(new TreeViewVarNode(debuggedProcess, watchList, valNode));
} catch (GetValueException) {
nodes.Add(valNode);
}
catch (GetValueException) {
string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), nod.Name);
ErrorInfoNode infoNode = new ErrorInfoNode(nod.Name, error);
nodes.Add(new TreeViewVarNode(debuggedProcess, watchList, infoNode));
nodes.Add(infoNode);
}
}
watchList.Root.Children.Clear();
foreach (TreeViewVarNode nod in nodes)
watchList.Root.Children.Add(nod);
} catch(AbortedBecauseDebuggeeResumedException) {
} catch(Exception ex) {
// rebuild list
watchList.WatchItems.Clear();
foreach (var nod in nodes)
watchList.WatchItems.Add(nod);
}
catch(AbortedBecauseDebuggeeResumedException) { }
catch(Exception ex) {
if (debuggedProcess == null || debuggedProcess.HasExited) {
// Process unexpectedly exited
} else {
@ -219,8 +180,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -219,8 +180,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
}
}
}
watchList.EndUpdate();
}
}
}

55
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadCommands.cs

@ -3,10 +3,12 @@ @@ -3,10 +3,12 @@
using System;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows.Forms;
using Aga.Controls.Tree;
using Debugger.AddIn.Pads;
using Debugger.AddIn.Pads.Controls;
using Debugger.AddIn.TreeModel;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
@ -14,6 +16,7 @@ using ICSharpCode.Core.WinForms; @@ -14,6 +16,7 @@ using ICSharpCode.Core.WinForms;
using ICSharpCode.NRefactory;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui.Pads;
using ICSharpCode.SharpDevelop.Project;
namespace Debugger.AddIn
{
@ -23,7 +26,6 @@ namespace Debugger.AddIn @@ -23,7 +26,6 @@ namespace Debugger.AddIn
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
TreeViewAdv ctrl = (TreeViewAdv)pad.Control;
var inputWindow = new WatchInputBox(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.AddWatch}"),
StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.EnterExpression}"));
@ -35,13 +37,17 @@ namespace Debugger.AddIn @@ -35,13 +37,17 @@ namespace Debugger.AddIn
string input = inputWindow.CommandText;
if (!string.IsNullOrEmpty(input)) {
ctrl.BeginUpdate();
TextNode text = new TextNode(input, SupportedLanguage.CSharp);
TreeViewVarNode node = new TreeViewVarNode(pad.Process, ctrl, text);
// get language
if (ProjectService.CurrentProject == null) return;
pad.Watches.Add(text);
ctrl.Root.Children.Add(node);
ctrl.EndUpdate();
string language = ProjectService.CurrentProject.Language;
TextNode text = new TextNode(input,
language == "VB" || language == "VBNet" ? SupportedLanguage.VBNet : SupportedLanguage.CSharp);
var list = (WatchList)pad.Control;
if(!list.WatchItems.ContainsItem(text))
list.WatchItems.Add(text);
}
pad.RefreshPad();
@ -55,19 +61,14 @@ namespace Debugger.AddIn @@ -55,19 +61,14 @@ namespace Debugger.AddIn
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
TreeNodeAdv node = ((TreeViewAdv)pad.Control).SelectedNode;
var list = (WatchList)pad.Control;
var node = list.SelectedNode;
if (node == null)
return;
while (node.Parent != ((TreeViewAdv)pad.Control).Root)
{
node = node.Parent;
}
pad.Watches.RemoveAt(node.Index);
((TreeViewAdv)pad.Control).Root.Children.Remove(node);
list.WatchItems.Remove(node);
((WatchPad)this.Owner).RefreshPad();
}
@ -90,11 +91,23 @@ namespace Debugger.AddIn @@ -90,11 +91,23 @@ namespace Debugger.AddIn
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
((TreeViewAdv)pad.Control).BeginUpdate();
pad.Watches.Clear();
((TreeViewAdv)pad.Control).Root.Children.Clear();
((TreeViewAdv)pad.Control).EndUpdate();
var list = (WatchList)pad.Control;
list.WatchItems.Clear();
}
}
}
public class CopyToClipboardCommand : AbstractMenuCommand
{
public override void Run()
{
if (this.Owner is WatchPad) {
WatchPad pad = (WatchPad)this.Owner;
var list = (WatchList)pad.Control;
if (list.SelectedNode is ExpressionNode) {
string text = ((ExpressionNode)list.SelectedNode).FullText;
ClipboardWrapper.SetText(text);
}
}
}
}

24
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPadModel.cs

@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -19,7 +19,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
this.Language = language;
}
public new bool CanSetText {
public override bool CanSetText {
get {
return true;
}
@ -74,17 +74,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -74,17 +74,17 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
MessageBox.Show("You can not set name to an empty string!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
if (((TreeViewVarNode)node).Content is ExpressionNode) {
WatchPad.Instance.Watches.RemoveAll(item => item.Name == ((ExpressionNode)((TreeViewVarNode)node).Content).Name);
((ExpressionNode)((TreeViewVarNode)node).Content).Name = value.ToString();
} else {
if (((TreeViewVarNode)node).Content is TextNode) {
WatchPad.Instance.Watches.RemoveAll(item => item.Name == ((TextNode)((TreeViewVarNode)node).Content).Name);
((TextNode)((TreeViewVarNode)node).Content).Name = value.ToString();
}
}
WatchPad.Instance.Watches.Add(new TextNode(value as string, SupportedLanguage.CSharp));
// if (((TreeViewVarNode)node).Content is ExpressionNode) {
// WatchPad.Instance.Watches.RemoveAll(item => item.Name == ((ExpressionNode)((TreeViewVarNode)node).Content).Name);
// ((ExpressionNode)((TreeViewVarNode)node).Content).Name = value.ToString();
// } else {
// if (((TreeViewVarNode)node).Content is TextNode) {
// WatchPad.Instance.Watches.RemoveAll(item => item.Name == ((TextNode)((TreeViewVarNode)node).Content).Name);
// ((TextNode)((TreeViewVarNode)node).Content).Name = value.ToString();
// }
// }
//
// WatchPad.Instance.Watches.Add(new TextNode(value as string, SupportedLanguage.CSharp));
}
}
public override void MouseDown(TreeNodeAdvMouseEventArgs args)

2
src/AddIns/Debugger/Debugger.AddIn/TreeModel/ExpressionNode.cs

@ -430,4 +430,4 @@ namespace Debugger.AddIn.TreeModel @@ -430,4 +430,4 @@ namespace Debugger.AddIn.TreeModel
}
}
}
}
}

7
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/ResourceCodeGeneratorTool.cs

@ -57,13 +57,6 @@ namespace ResourceEditor @@ -57,13 +57,6 @@ namespace ResourceEditor
string[] unmatchable = null;
string generatedCodeNamespace = context.OutputNamespace;
if (context.Project.LanguageProperties == ICSharpCode.SharpDevelop.Dom.LanguageProperties.VBNet) {
if (generatedCodeNamespace == context.Project.RootNamespace) {
generatedCodeNamespace = null; // namespace is implicit in VB
} else if (generatedCodeNamespace.StartsWith(context.Project.RootNamespace + ".", StringComparison.OrdinalIgnoreCase)) {
generatedCodeNamespace = generatedCodeNamespace.Substring(context.Project.RootNamespace.Length + 1);
}
}
context.WriteCodeDomToFile(
item,

25
src/AddIns/DisplayBindings/SettingsEditor/Project/EmptySettingsFile.xft

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<?xml version="1.0"?>
<Template author="Daniel Grunwald" version="1.0">
<Config
name = "Settings"
icon = "Icons.32x32.ResourceFileIcon"
category = "${res:Templates.File.Categories.Misc}"
defaultname = "Settings${Number}.settings"
language = "SettingsFiles"/>
<Description>${res:Templates.File.Resource.EmptyResourceFile.Description}</Description>
<Files>
<File name="${FullName}" language="ResourceFiles" Generator="SettingsSingleFileGenerator"><![CDATA[<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="${StandardNamespace}" GeneratedClassName="${ClassName}">
<Profiles />
<Settings />
</SettingsFile>
]]> </File>
</Files>
<AdditionalOptions/>
</Template>

81
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsCodeGeneratorTool.cs

@ -3,12 +3,14 @@ @@ -3,12 +3,14 @@
using System;
using System.CodeDom;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Reflection;
using System.Xml;
using ICSharpCode.EasyCodeDom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SettingsEditor
@ -26,7 +28,11 @@ namespace ICSharpCode.SettingsEditor @@ -26,7 +28,11 @@ namespace ICSharpCode.SettingsEditor
}
CodeCompileUnit ccu = new CodeCompileUnit();
ccu.AddNamespace(setDoc.GeneratedClassNamespace).Types.Add(CreateClass(setDoc));
var ns = ccu.AddNamespace(setDoc.GeneratedClassNamespace);
ns.Types.Add(CreateClass(setDoc));
if (setDoc.UseMySettingsClassName) {
ns.Types.Add(CreateMySettingsProperty(setDoc));
}
context.WriteCodeDomToFile(item, context.GetOutputFileName(item, ".Designer"), ccu);
}
@ -47,7 +53,12 @@ namespace ICSharpCode.SettingsEditor @@ -47,7 +53,12 @@ namespace ICSharpCode.SettingsEditor
.InvokeMethod("Synchronized", Easy.New(Easy.TypeRef(c)))
.CastTo(Easy.TypeRef(c));
c.AddProperty(f, "Default");
var defaultProperty = c.AddProperty(f, "Default");
if (setDoc.UseMySettingsClassName) {
c.AddAttribute(typeof(EditorBrowsableAttribute), Easy.Prim(EditorBrowsableState.Advanced));
AddAutoSaveLogic(c, defaultProperty);
}
foreach (SettingsEntry entry in setDoc.Entries) {
Type entryType = entry.Type ?? typeof(string);
@ -99,6 +110,72 @@ namespace ICSharpCode.SettingsEditor @@ -99,6 +110,72 @@ namespace ICSharpCode.SettingsEditor
return c;
}
void AddAutoSaveLogic(CodeTypeDeclaration c, CodeMemberProperty defaultProperty)
{
// VB auto-safe logic:
c.Members.Add(new CodeSnippetTypeMember(
@" #Region ""Support for My.Application.SaveMySettingsOnExit""
#If _MyType = ""WindowsForms"" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region".Replace("\t", EditorControlService.GlobalOptions.IndentationString)
));
defaultProperty.GetStatements.Insert(0, new CodeSnippetStatement(
@" #If _MyType = ""WindowsForms"" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If".Replace("\t", EditorControlService.GlobalOptions.IndentationString)
));
}
class CodeLiteralDirective : CodeDirective
{
string text;
public CodeLiteralDirective(string text)
{
this.text = text;
}
public override string ToString()
{
return text;
}
}
CodeTypeDeclaration CreateMySettingsProperty(SettingsDocument setDoc)
{
CodeTypeDeclaration c = new CodeTypeDeclaration("MySettingsProperty");
c.UserData["Module"] = true;
c.AddAttribute(new CodeTypeReference("Microsoft.VisualBasic.HideModuleNameAttribute"));
c.AddAttribute(typeof(DebuggerNonUserCodeAttribute));
c.AddAttribute(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute));
c.TypeAttributes = TypeAttributes.NotPublic;
CodeTypeReference r = new CodeTypeReference(setDoc.GeneratedFullClassName);
var p = c.AddProperty(r, "Settings");
p.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
p.Getter.Return(Easy.Type(r).Property("Default"));
p.AddAttribute(typeof(System.ComponentModel.Design.HelpKeywordAttribute), Easy.Prim("My.Settings"));
return c;
}
}
public class PublicSettingsCodeGeneratorTool : SettingsCodeGeneratorTool

19
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsDocument.cs

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Xml;
using System.Collections.Generic;
using System.Xml;
namespace ICSharpCode.SettingsEditor
{
@ -23,6 +23,20 @@ namespace ICSharpCode.SettingsEditor @@ -23,6 +23,20 @@ namespace ICSharpCode.SettingsEditor
set { generatedClassName = value ?? ""; }
}
public string GeneratedFullClassName {
get {
if (string.IsNullOrEmpty(generatedClassNamespace))
return generatedClassName;
else
return generatedClassNamespace + "." + generatedClassName;
}
}
/// <summary>
/// VB "My" namespace integration
/// </summary>
public bool UseMySettingsClassName { get; set; }
public List<SettingsEntry> Entries {
get { return entries; }
}
@ -37,6 +51,7 @@ namespace ICSharpCode.SettingsEditor @@ -37,6 +51,7 @@ namespace ICSharpCode.SettingsEditor
{
generatedClassNamespace = settingsFile.GetAttribute("GeneratedClassNamespace");
generatedClassName = settingsFile.GetAttribute("GeneratedClassName");
this.UseMySettingsClassName = "true".Equals(settingsFile.GetAttribute("UseMySettingsClassName"), StringComparison.OrdinalIgnoreCase);
XmlElement settings = settingsFile["Settings"];
@ -53,6 +68,8 @@ namespace ICSharpCode.SettingsEditor @@ -53,6 +68,8 @@ namespace ICSharpCode.SettingsEditor
writer.WriteAttributeString("CurrentProfile", "(Default)");
writer.WriteAttributeString("GeneratedClassNamespace", generatedClassNamespace);
writer.WriteAttributeString("GeneratedClassName", generatedClassName);
if (this.UseMySettingsClassName)
writer.WriteAttributeString("UseMySettingsClassName", "true");
writer.WriteStartElement("Profiles");
writer.WriteStartElement("Profile");

11
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.addin

@ -12,6 +12,17 @@ @@ -12,6 +12,17 @@
<Import assembly = "SettingsEditor.dll"/>
</Runtime>
<Path name = "/SharpDevelop/BackendBindings/Templates">
<Directory id = "settings" path = "." />
</Path>
<Path name = "/SharpDevelop/Workbench/FileFilter">
<FileFilter id = "Settings"
insertbefore="AllFiles"
name = "Settings (*.settings)"
extensions = "*.settings"/>
</Path>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "SettingsEditor"
insertbefore = "Text"

11
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsEditor.csproj

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.SettingsEditor</RootNamespace>
@ -6,7 +7,7 @@ @@ -6,7 +7,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{85226AFB-CE71-4851-9A75-7EEC663A8E8A}</ProjectGuid>
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\SettingsEditor\</OutputPath>
<OutputPath>..\..\..\..\..\AddIns\DisplayBindings\SettingsEditor\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
@ -45,8 +46,14 @@ @@ -45,8 +46,14 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="EmptySettingsFile.xft">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SettingsEditor.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

33
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.Designer.cs generated

@ -33,21 +33,17 @@ namespace ICSharpCode.SettingsEditor @@ -33,21 +33,17 @@ namespace ICSharpCode.SettingsEditor
{
this.components = new System.ComponentModel.Container();
this.grid = new System.Windows.Forms.DataGridView();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
this.label1 = new System.Windows.Forms.Label();
this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.TypeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.ScopeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
this.ValueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.bindingSource = new System.Windows.Forms.BindingSource(this.components);
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).BeginInit();
this.SuspendLayout();
//
// grid
//
this.grid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.grid.AutoGenerateColumns = false;
this.grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.grid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
@ -56,28 +52,15 @@ namespace ICSharpCode.SettingsEditor @@ -56,28 +52,15 @@ namespace ICSharpCode.SettingsEditor
this.ScopeColumn,
this.ValueColumn});
this.grid.DataSource = this.bindingSource;
this.grid.Dock = System.Windows.Forms.DockStyle.Fill;
this.grid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.grid.Location = new System.Drawing.Point(3, 38);
this.grid.Location = new System.Drawing.Point(0, 0);
this.grid.Name = "grid";
this.grid.Size = new System.Drawing.Size(480, 321);
this.grid.Size = new System.Drawing.Size(486, 362);
this.grid.TabIndex = 0;
this.grid.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.GridDataError);
this.grid.SelectionChanged += new System.EventHandler(this.GridSelectionChanged);
//
// bindingSource
//
this.bindingSource.DataSource = typeof(ICSharpCode.SettingsEditor.SettingsEntry);
this.bindingSource.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.BindingSourceAddingNew);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(4, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(292, 13);
this.label1.TabIndex = 1;
this.label1.Text = "SettingsView prototype. Code generation not implemented!";
//
// NameColumn
//
this.NameColumn.DataPropertyName = "Name";
@ -111,25 +94,27 @@ namespace ICSharpCode.SettingsEditor @@ -111,25 +94,27 @@ namespace ICSharpCode.SettingsEditor
this.ValueColumn.MinimumWidth = 50;
this.ValueColumn.Name = "ValueColumn";
//
// bindingSource
//
this.bindingSource.DataSource = typeof(ICSharpCode.SettingsEditor.SettingsEntry);
this.bindingSource.AddingNew += new System.ComponentModel.AddingNewEventHandler(this.BindingSourceAddingNew);
//
// SettingsView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.label1);
this.Controls.Add(this.grid);
this.Name = "SettingsView";
this.Size = new System.Drawing.Size(486, 362);
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.bindingSource)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.DataGridViewComboBoxColumn TypeColumn;
private System.Windows.Forms.DataGridViewComboBoxColumn ScopeColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn ValueColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn NameColumn;
private System.Windows.Forms.BindingSource bindingSource;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridView grid;
}
}

8
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsView.resx

@ -112,15 +112,15 @@ @@ -112,15 +112,15 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="TypeColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="TypeColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="bindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>28, 18</value>
</metadata>
</root>

129
src/AddIns/DisplayBindings/SettingsEditor/Project/SettingsViewContent.cs

@ -4,13 +4,15 @@ @@ -4,13 +4,15 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SettingsEditor
{
@ -19,17 +21,41 @@ namespace ICSharpCode.SettingsEditor @@ -19,17 +21,41 @@ namespace ICSharpCode.SettingsEditor
SettingsView view = new SettingsView();
PropertyContainer propertyContainer = new PropertyContainer();
SettingsDocument setDoc = new SettingsDocument();
MemoryStream appConfigStream;
OpenedFile appConfigFile;
public SettingsViewContent(OpenedFile file) : base(file)
{
TryOpenAppConfig(false);
view.SelectionChanged += delegate {
propertyContainer.SelectedObjects = view.GetSelectedEntriesForPropertyGrid().ToArray();
};
view.SettingsChanged += delegate {
this.PrimaryFile.MakeDirty();
if (appConfigFile != null)
appConfigFile.MakeDirty();
};
}
void TryOpenAppConfig(bool createIfNotExists)
{
if (appConfigFile != null) // already open
return;
if (ProjectService.OpenSolution == null)
return;
IProject p = ProjectService.OpenSolution.FindProjectContainingFile(this.PrimaryFileName);
if (p == null)
return;
FileName appConfigFileName = CompilableProject.GetAppConfigFile(p, createIfNotExists);
if (appConfigFileName != null) {
appConfigFile = FileService.GetOrCreateOpenedFile(appConfigFileName);
this.Files.Add(appConfigFile);
if (createIfNotExists)
appConfigFile.MakeDirty();
appConfigFile.ForceInitializeView(this);
}
}
public override object Control {
get {
return view;
@ -48,6 +74,9 @@ namespace ICSharpCode.SettingsEditor @@ -48,6 +74,9 @@ namespace ICSharpCode.SettingsEditor
} catch (XmlException ex) {
ShowLoadError(ex.Message);
}
} else if (file == appConfigFile) {
appConfigStream = new MemoryStream();
stream.WriteTo(appConfigStream);
}
}
@ -68,13 +97,109 @@ namespace ICSharpCode.SettingsEditor @@ -68,13 +97,109 @@ namespace ICSharpCode.SettingsEditor
setDoc.Entries.Clear();
setDoc.Entries.AddRange(view.GetAllEntries());
if (setDoc.Entries.Count > 0)
TryOpenAppConfig(true);
setDoc.Save(writer);
writer.WriteEndDocument();
}
} else if (file == appConfigFile) {
appConfigStream.Position = 0;
XDocument appConfigDoc;
try {
appConfigDoc = XDocument.Load(appConfigStream, LoadOptions.PreserveWhitespace);
} catch (XmlException) {
appConfigDoc = null;
}
if (appConfigDoc != null) {
UpdateAppConfig(appConfigDoc);
appConfigDoc.Save(stream, SaveOptions.DisableFormatting);
} else {
appConfigStream.Position = 0;
appConfigStream.WriteTo(stream);
}
}
}
#region Update app.config
void UpdateAppConfig(XDocument appConfigDoc)
{
var entries = view.GetAllEntries();
var userEntries = entries.Where(e => e.Scope == SettingScope.User);
var appEntries = entries.Where(e => e.Scope == SettingScope.Application);
XElement configuration = appConfigDoc.Root;
XElement configSections = configuration.Element("configSections");
if (configSections == null) {
configSections = configuration.AddFirstWithIndentation(new XElement("configSections"));
}
RegisterAppConfigSection(configSections, userEntries.Any(), appEntries.Any());
XElement userSettings = configuration.Element("userSettings");
if (userSettings == null && userEntries.Any()) {
userSettings = configuration.AddWithIndentation(new XElement("userSettings"));
}
if (userSettings != null) {
UpdateSettings(userSettings, userEntries);
}
XElement appSettings = configuration.Element("applicationSettings");
if (appSettings == null && appEntries.Any()) {
appSettings = configuration.AddWithIndentation(new XElement("applicationSettings"));
}
if (appSettings != null) {
UpdateSettings(appSettings, appEntries);
}
}
void RegisterAppConfigSection(XElement configSections, bool hasUserEntries, bool hasAppEntries)
{
if (hasUserEntries) {
XElement userSettings = configSections.Elements("sectionGroup").FirstOrDefault(e => (string)e.Attribute("name") == "userSettings");
if (userSettings == null) {
userSettings = configSections.AddWithIndentation(new XElement("sectionGroup", new XAttribute("name", "userSettings")));
userSettings.Add(new XAttribute("type", "System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
}
RegisterAppConfigSectionInGroup(userSettings, SettingScope.User);
}
if (hasAppEntries) {
XElement appSettings = configSections.Elements("sectionGroup").FirstOrDefault(e => (string)e.Attribute("name") == "applicationSettings");
if (appSettings == null) {
appSettings = configSections.AddWithIndentation(new XElement("sectionGroup", new XAttribute("name", "applicationSettings")));
appSettings.Add(new XAttribute("type", "System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
}
RegisterAppConfigSectionInGroup(appSettings, SettingScope.Application);
}
}
void RegisterAppConfigSectionInGroup(XElement sectionGroup, SettingScope scope)
{
if (!sectionGroup.Elements("section").Any(e => (string)e.Attribute("name") == setDoc.GeneratedFullClassName)) {
XElement section = new XElement("section", new XAttribute("name", setDoc.GeneratedFullClassName));
section.Add(new XAttribute("type", "System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"));
if (scope == SettingScope.User) {
section.Add(new XAttribute("allowExeDefinition", "MachineToLocalUser"));
}
section.Add(new XAttribute("requirePermission", false));
sectionGroup.AddWithIndentation(section);
}
}
void UpdateSettings(XElement settingsContainer, IEnumerable<SettingsEntry> entries)
{
XElement settings = settingsContainer.Element(setDoc.GeneratedFullClassName);
if (settings == null) {
settings = settingsContainer.AddWithIndentation(new XElement(setDoc.GeneratedFullClassName));
}
settings.RemoveAll();
foreach (SettingsEntry entry in entries) {
XElement setting = new XElement("setting", new XAttribute("name", entry.Name));
settings.Add(new XAttribute("serializeAs", "String"));
settings.Add(new XElement("value", entry.SerializedValue));
}
settings.ReplaceWith(settings.FormatXml(2));
}
#endregion
public PropertyContainer PropertyContainer {
get {

1
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Properties/AssemblyInfo.cs

@ -21,4 +21,3 @@ using System.Reflection; @@ -21,4 +21,3 @@ using System.Reflection;
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: System.CLSCompliant(true)]

7
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.addin

@ -30,5 +30,10 @@ @@ -30,5 +30,10 @@
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu">
<MenuItem id="Reflector" type="Item" label="${res:ReflectorAddIn.OpenReflectorCommand}" class="ReflectorAddIn.TextEditorContextMenuCommand"/>
</Path>
<!-- Options panel -->
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id = "ChangeReflectorPathOptionPanel"
label = "${res:ReflectorAddIn.IdeOptions.ReflectorTitle}"
class = "ReflectorAddIn.OptionPanels.ChangeReflectorPath"/>
</Path>
</AddIn>

35
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj

@ -40,12 +40,18 @@ @@ -40,12 +40,18 @@
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
@ -53,22 +59,25 @@ @@ -53,22 +59,25 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Src\NativeMethods.cs" />
<Compile Include="Src\OptionPanels\ChangeReflectorPath.xaml.cs">
<DependentUpon>ChangeReflectorPath.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\ReflectorController.cs" />
<Compile Include="Src\ReflectorSetupHelper.cs" />
<Compile Include="Src\SetReflectorPathDialog.cs" />
<Compile Include="Src\SetReflectorPathDialog.Designer.cs">
<DependentUpon>SetReflectorPathDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\TextEditorContextMenuCommand.cs" />
<Compile Include="Src\Windows\SetReflectorPath.xaml.cs">
<DependentUpon>SetReflectorPath.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<None Include="ReflectorAddIn.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Src\SetReflectorPathDialog.resx">
<DependentUpon>SetReflectorPathDialog.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Src" />
<Folder Include="Src\Windows" />
<Folder Include="Src\OptionPanels" />
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
@ -79,10 +88,22 @@ @@ -79,10 +88,22 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\OptionPanels\ChangeReflectorPath.xaml" />
<Page Include="Src\Windows\SetReflectorPath.xaml" />
</ItemGroup>
</Project>

22
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ReflectorAddIn.OptionPanels.ChangeReflectorPath" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel
Orientation="Vertical">
<GroupBox
Header="{core:Localize ReflectorAddIn.SetReflectorPathDialogTitle}">
<widgets:StackPanelWithSpacing>
<TextBlock
TextWrapping="Wrap"
Height="46"
Name="StatusLabel" />
<Button
HorizontalAlignment="Center"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Name="OpenSearchPathButton"
Content="{core:Localize ReflectorAddIn.IdeOptions.FindReflectorPath}"
Click="FindReflectorPathClick" />
</widgets:StackPanelWithSpacing>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

35
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@

using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ReflectorAddIn.OptionPanels
{
public partial class ChangeReflectorPath : OptionPanel
{
public ChangeReflectorPath()
{
InitializeComponent();
Loaded += delegate { ShowStatus(); };
}
void ShowStatus()
{
string path = PropertyService.Get(ReflectorSetupHelper.ReflectorExePathPropertyName);
if (string.IsNullOrEmpty(path)) {
StatusLabel.Text = StringParser.Parse("${res:ReflectorAddIn.ReflectorPathNotSet}");
} else {
StatusLabel.Text = StringParser.Parse("${res:ReflectorAddIn.IdeOptions.ReflectorFoundInPath}")
+ Environment.NewLine + path;
}
}
void FindReflectorPathClick(object sender, EventArgs e)
{
ReflectorSetupHelper.OpenReflectorExeFullPathInteractiver();
ShowStatus();
}
}
}

6
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorController.cs

@ -1,15 +1,13 @@ @@ -1,15 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Dom;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Remoting;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
namespace ReflectorAddIn

37
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorSetupHelper.cs

@ -1,12 +1,13 @@ @@ -1,12 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ReflectorAddIn.Windows;
namespace ReflectorAddIn
{
@ -31,19 +32,31 @@ namespace ReflectorAddIn @@ -31,19 +32,31 @@ namespace ReflectorAddIn
}
if (askReason != null) {
using(SetReflectorPathDialog dialog = new SetReflectorPathDialog(path, askReason)) {
if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK || !File.Exists(dialog.SelectedFile)) {
return null;
}
path = dialog.SelectedFile;
PropertyService.Set(ReflectorExePathPropertyName, path);
}
SetReflectorPath dialog = new SetReflectorPath(path, askReason);
dialog.Owner = WorkbenchSingleton.MainWindow;
bool? result = dialog.ShowDialog();
if (!result.HasValue || !result.Value || !File.Exists(dialog.SelectedFile))
return null;
path = dialog.SelectedFile;
PropertyService.Set(ReflectorExePathPropertyName, path);
}
return path;
}
internal static void OpenReflectorExeFullPathInteractiver() {
string path = PropertyService.Get(ReflectorExePathPropertyName);
string askReason = null;
SetReflectorPath dialog = new SetReflectorPath(path, askReason);
dialog.Owner = WorkbenchSingleton.MainWindow;
bool? result = dialog.ShowDialog();
if (!result.HasValue || !result.Value || !File.Exists(dialog.SelectedFile))
return;
PropertyService.Set(ReflectorExePathPropertyName, dialog.SelectedFile);
}
}
}

3
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/TextEditorContextMenuCommand.cs

@ -2,14 +2,11 @@ @@ -2,14 +2,11 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.ClassBrowser;
using ICSharpCode.SharpDevelop.Project;

106
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml

@ -0,0 +1,106 @@ @@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="ReflectorAddIn.Windows.SetReflectorPath"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
WindowStartupLocation="CenterOwner"
Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
ResizeMode="NoResize"
WindowStyle="ToolWindow"
ShowInTaskbar="False"
SizeToContent="Height"
Width="446">
<Window.Resources>
<Style
x:Key="LinkButton"
TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="Button">
<ControlTemplate.Resources>
<Style
TargetType="{x:Type TextBlock}">
<Setter
Property="TextDecorations"
Value="Underline" />
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter
Property="Foreground"
Value="Blue" />
<Setter
Property="Cursor"
Value="Hand" />
<Style.Triggers>
<Trigger
Property="IsMouseOver"
Value="true">
<Setter
Property="Foreground"
Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<widgets:StackPanelWithSpacing>
<TextBlock
Margin="12,12,12,0"
HorizontalAlignment="Left"
TextWrapping="Wrap"
Name="txtReason"/>
<TextBlock
Margin="12"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Name="txtReflectorExplanation"
Text="{core:Localize ReflectorAddIn.SetReflectorPathDialog.ReflectorInfo}"/>
<Button Margin="20,0,0,15"
Name="OpenReflectorPageButton"
Content="http://reflector.red-gate.com/Download.aspx"
Style="{StaticResource LinkButton}"
Click="OpenReflectorPageButton_Click" />
<GroupBox Margin="12,0,0,15"
Header="{core:Localize ReflectorAddIn.SetReflectorPathDialog.PathToReflectorExe}">
<widgets:StackPanelWithSpacing
Orientation="Horizontal">
<TextBox
IsReadOnly="True"
Name="slePath"
Width="310"
Height="20" />
<Button Margin="15,0,0,0"
HorizontalAlignment="Right"
Name="BrowseButton"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Content="{core:Localize Global.BrowseButtonText}"
Click="BrowseButton_Click" />
</widgets:StackPanelWithSpacing>
</GroupBox>
<widgets:UniformGridWithSpacing
Columns="2"
Margin="0,0,12,12"
HorizontalAlignment="Right">
<Button
Name="OkButton"
IsDefault="True"
Content="{core:Localize Global.OKButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="OkButton_Click"/>
<Button
Name="CancelButton"
IsCancel="True"
Content="{core:Localize Global.CancelButtonText}"
Click="CancelButton_Click"
Style="{x:Static core:GlobalStyles.ButtonStyle}" />
</widgets:UniformGridWithSpacing>
</widgets:StackPanelWithSpacing>
</StackPanel>
</Window>

82
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.Core;
using Microsoft.Win32;
namespace ReflectorAddIn.Windows
{
public partial class SetReflectorPath : Window
{
public SetReflectorPath(string oldPath, string reason)
{
InitializeComponent();
this.Title = ResourceService.GetString("ReflectorAddIn.SetReflectorPathDialogTitle");
if (reason != null)
this.txtReason.Text = reason;
else
this.txtReason.Visibility = Visibility.Collapsed;
if (!String.IsNullOrEmpty(oldPath)) {
this.slePath.Text = oldPath;
}
}
public string SelectedFile {
get {
return slePath.Text;
}
}
void OpenReflectorPageButton_Click(object sender, RoutedEventArgs e)
{
try {
using(System.Diagnostics.Process.Start("http://reflector.red-gate.com/Download.aspx")) {
}
} catch (Exception ex) {
MessageService.ShowError(ex.Message);
}
}
void OkButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Close();
}
void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
Close();
}
void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = this.Title;
dialog.DefaultExt = "exe";
dialog.RestoreDirectory = true;
dialog.Filter = "Reflector.exe|Reflector.exe";
if (!String.IsNullOrEmpty(this.slePath.Text)) {
dialog.FileName = this.slePath.Text;
}
bool? result = dialog.ShowDialog(this);
if (result.HasValue && result.Value) {
this.slePath.Text = dialog.FileName;
}
}
}
}

7
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/TextView.cs

@ -56,6 +56,7 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -56,6 +56,7 @@ namespace ICSharpCode.AvalonEdit.Rendering
layers = new UIElementCollection(this, this);
InsertLayer(textLayer, KnownLayer.Text, LayerInsertionPosition.Replace);
}
#endregion
#region Document Property
@ -688,7 +689,9 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -688,7 +689,9 @@ namespace ICSharpCode.AvalonEdit.Rendering
double heightTreeHeight = this.DocumentHeight;
TextEditorOptions options = this.Options;
if (options.AllowScrollBelowDocument) {
heightTreeHeight = Math.Max(heightTreeHeight, Math.Min(heightTreeHeight - 50, scrollOffset.Y) + scrollViewport.Height);
if (!double.IsInfinity(scrollViewport.Height)) {
heightTreeHeight = Math.Max(heightTreeHeight, Math.Min(heightTreeHeight - 50, scrollOffset.Y) + scrollViewport.Height);
}
}
SetScrollData(availableSize,
@ -1525,6 +1528,8 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -1525,6 +1528,8 @@ namespace ICSharpCode.AvalonEdit.Rendering
};
RaiseEvent(args2);
}
#endregion
/// <summary>

34
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -139,12 +139,12 @@ @@ -139,12 +139,12 @@
class = "ICSharpCode.SharpDevelop.Editor.Search.SearchResultsPad"
defaultPosition = "Bottom, Hidden" />
<!--<Pad id = "Bookmarks"
<Pad id = "Bookmarks"
category = "Tools"
title = "${res:MainWindow.Windows.BookmarksLabel}"
icon = "PadIcons.Bookmarks"
class = "ICSharpCode.SharpDevelop.Bookmarks.BookmarkPad"
defaultPosition = "Bottom, Hidden" />-->
defaultPosition = "Bottom, Hidden" />
<Pad id = "DefinitionView"
category = "Tools"
@ -967,6 +967,32 @@ @@ -967,6 +967,32 @@
class="ICSharpCode.SharpDevelop.Commands.NavigateForward"/>
</Condition>
</Path>
<Path name="/SharpDevelop/Pads/BreakpointPad/Toolbar">
<ToolbarItem id = "GotoPrev"
icon = "Bookmarks.PrevBreakpoint"
tooltip = "${res:MainWindow.Windows.BookmarkPad.GotoPrev.ToolTip}"
class = "ICSharpCode.SharpDevelop.Bookmarks.PrevBookmarkPadCommand"/>
<ToolbarItem id = "GotoNext"
icon = "Bookmarks.NextBreakpoint"
tooltip = "${res:MainWindow.Windows.BookmarkPad.GotoNext.ToolTip}"
class = "ICSharpCode.SharpDevelop.Bookmarks.NextBookmarkPadCommand"/>
<ToolbarItem id = "GotoInFolderSeparator" type = "Separator" />
<ToolbarItem id = "DisableAllBreakpoints"
icon = "Bookmarks.DisableAllBreakpoints"
tooltip = "${res:MainWindow.Windows.BookmarkPad.EnableDisableAll.ToolTip}"
class = "ICSharpCode.SharpDevelop.Bookmarks.EnableDisableAll"/>
<ToolbarItem id = "EnableDisableSeparator" type = "Separator" />
<ToolbarItem id = "DeleteMark"
icon = "Icons.16x16.DeleteIcon"
tooltip = "${res:MainWindow.Windows.BookmarkPad.DeleteMark.ToolTip}"
class = "ICSharpCode.SharpDevelop.Project.Commands.DeleteBreakpointCommand"/>
<ToolbarItem id = "EnableDisableSeparator" type = "Separator" />
<ToolbarItem id = "DeleteAllBreakpoints"
icon = "Bookmarks.DeleteAllBreakpoints"
tooltip = "${res:XML.MainMenu.DebugMenu.RemoveAllBreakpoints}"
class = "ICSharpCode.SharpDevelop.Project.Commands.RemoveAllBreakpointsCommand"/>
</Path>
<!-- end toolbars -->
<Path name = "/SharpDevelop/Workbench/OpenFileTab/ContextMenu">
@ -1922,11 +1948,11 @@ @@ -1922,11 +1948,11 @@
<ToolbarItem id = "GotoPrev"
icon = "Bookmarks.GotoPrev"
tooltip = "${res:MainWindow.Windows.BookmarkPad.GotoPrev.ToolTip}"
class = "ICSharpCode.SharpDevelop.Bookmarks.GotoPrev"/>
class = "ICSharpCode.SharpDevelop.Bookmarks.PrevBookmarkPadCommand"/>
<ToolbarItem id = "GotoNext"
icon = "Bookmarks.GotoNext"
tooltip = "${res:MainWindow.Windows.BookmarkPad.GotoNext.ToolTip}"
class = "ICSharpCode.SharpDevelop.Bookmarks.GotoNext"/>
class = "ICSharpCode.SharpDevelop.Bookmarks.NextBookmarkPadCommand"/>
<ToolbarItem id = "GotoInFolderSeparator" type = "Separator" />
<ToolbarItem id = "EnableDisableAll"
icon = "Bookmarks.EnableDisableAll"

7
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -92,6 +92,9 @@ @@ -92,6 +92,9 @@
<Compile Include="..\..\ICSharpCode.SharpDevelop.BuildWorker\ExtendedBinaryReader.cs">
<Link>Src\Project\MSBuildEngine\ExtendedBinaryReader.cs</Link>
</Compile>
<Compile Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml.cs">
<DependentUpon>ListViewPad.xaml</DependentUpon>
</Compile>
<Compile Include="Src\Commands\SharpDevelopRoutedCommands.cs" />
<Compile Include="Src\Editor\AddInHighlightingResource.cs" />
<Compile Include="Src\Editor\AvalonEdit\AvalonEditDocumentAdapter.cs" />
@ -821,8 +824,7 @@ @@ -821,8 +824,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Page Include="Src\Services\Debugger\Tooltips\PinCloseControl.xaml" />
<Page Include="Src\Services\Debugger\Tooltips\PinControlsDictionary.xaml" />
<Page Include="Src\Bookmarks\Pad\Controls\ListViewPad.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsBulbControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsHeaderedControl.xaml" />
@ -846,6 +848,7 @@ @@ -846,6 +848,7 @@
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<Folder Include="Src\Bookmarks\Pad\Controls" />
<Folder Include="Src\Editor\AvalonEdit" />
<Folder Include="Src\Editor\CodeCompletion" />
<Folder Include="Src\Editor\Commands" />

11
src/Main/Base/Project/Src/Bookmarks/BookmarkConverter.cs

@ -8,7 +8,6 @@ using System.Text; @@ -8,7 +8,6 @@ using System.Text;
using ICSharpCode.Core;
using ICSharpCode.NRefactory;
using Services.Debugger.Tooltips;
namespace ICSharpCode.SharpDevelop.Bookmarks
{
@ -103,16 +102,6 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -103,16 +102,6 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
b.Append(bbm.Condition);
}
// if (bookmark is PinBookmark) {
// var pin = (PinBookmark)bookmark;
// b.Append(pin.Comment ?? string.Empty);
// foreach(var node in pin.Nodes) {
// b.Append('|');
// b.Append(node.Name);
// b.Append('|');
// b.Append(node.Text);
// }
// }
return b.ToString();
} else {
return base.ConvertTo(context, culture, value, destinationType);

16
src/Main/Base/Project/Src/Bookmarks/BookmarkManager.cs

@ -90,7 +90,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -90,7 +90,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
static void OnAdded(BookmarkEventArgs e)
{
if (Added != null) {
Added(null, e);
Added(null, e);
}
}
@ -121,6 +121,20 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -121,6 +121,20 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
BookmarkManager.AddMark(bookmarkFactory(new Location(column, line)));
}
public static void RemoveAll(Predicate<SDBookmark> match)
{
if (match == null)
throw new ArgumentNullException("Predicate is null!");
for(int index = bookmarks.Count - 1; index >= 0; --index){
SDBookmark bookmark = bookmarks[index];
if(match(bookmark)) {
bookmarks.RemoveAt(index);
OnRemoved(new BookmarkEventArgs(bookmark));
}
}
}
public static event BookmarkEventHandler Removed;
public static event BookmarkEventHandler Added;
}

129
src/Main/Base/Project/Src/Bookmarks/Pad/BookmarkPad.cs

@ -3,10 +3,13 @@ @@ -3,10 +3,13 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.Core;
using ICSharpCode.Core.WinForms;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Bookmarks
@ -24,18 +27,27 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -24,18 +27,27 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
}
}
protected override ToolBar CreateToolBar()
{
ToolBar toolbar = ToolBarService.CreateToolBar(this, "/SharpDevelop/Pads/BookmarkPad/Toolbar");
toolbar.SetValue(Grid.RowProperty, 0);
return toolbar;
}
protected override void CreateColumns() { }
public BookmarkPad()
{
instance = this;
instance = this;
myPanel.Children.Add(CreateToolBar());
listView.HideColumns(3, 0);
}
}
public abstract class BookmarkPadBase : AbstractPadContent
{
Panel myPanel = new Panel();
ExtTreeView bookmarkTreeView = new ExtTreeView();
Dictionary<FileName, BookmarkFolderNode> fileNodes = new Dictionary<FileName, BookmarkFolderNode>();
protected Grid myPanel = new Grid();
protected ListViewPad listView = new ListViewPad();
public override object Control {
get {
@ -43,88 +55,82 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -43,88 +55,82 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
}
}
public TreeNode CurrentNode {
public ListViewPadItemModel CurrentItem {
get {
return bookmarkTreeView.SelectedNode as TreeNode;
return listView.CurrentItem;
}
}
protected virtual ToolStrip CreateToolStrip()
{
ToolStrip toolStrip = ToolbarService.CreateToolStrip(this, "/SharpDevelop/Pads/BookmarkPad/Toolbar");
toolStrip.Stretch = true;
toolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
return toolStrip;
}
protected abstract ToolBar CreateToolBar();
protected abstract void CreateColumns();
protected BookmarkPadBase()
{
bookmarkTreeView.Dock = DockStyle.Fill;
bookmarkTreeView.CheckBoxes = true;
bookmarkTreeView.HideSelection = false;
bookmarkTreeView.Font = ExtTreeNode.RegularBigFont;
bookmarkTreeView.IsSorted = false;
myPanel.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
myPanel.RowDefinitions.Add(new RowDefinition());
listView.SetValue(Grid.RowProperty, 1);
myPanel.Children.Add(listView);
myPanel.Controls.AddRange(new Control[] { bookmarkTreeView, CreateToolStrip()} );
BookmarkManager.Added += new BookmarkEventHandler(BookmarkManagerAdded);
BookmarkManager.Removed += new BookmarkEventHandler(BookmarkManagerRemoved);
foreach (SDBookmark mark in BookmarkManager.Bookmarks) {
AddMark(mark);
}
listView.ItemActivated += new EventHandler(listView_ItemActivated);
}
public IEnumerable<TreeNode> AllNodes {
public IEnumerable<ListViewPadItemModel> AllItems {
get {
Stack<TreeNode> treeNodes = new Stack<TreeNode>();
foreach (TreeNode node in bookmarkTreeView.Nodes) {
treeNodes.Push(node);
}
while (treeNodes.Count > 0) {
TreeNode node = treeNodes.Pop();
foreach (TreeNode childNode in node.Nodes) {
treeNodes.Push(childNode);
}
yield return node;
foreach (var item in listView.ItemCollection) {
yield return item;
}
}
}
public ListViewPadItemModel NextItem {
get {
return this.listView.NextItem;
}
}
public ListViewPadItemModel PrevItem {
get {
return this.listView.PrevItem;
}
}
public void EnableDisableAll()
{
bool isOneChecked = false;
foreach (TreeNode node in AllNodes) {
if (node is BookmarkNode) {
if (((BookmarkNode)node).Checked) {
isOneChecked = true;
break;
}
}
}
foreach (TreeNode node in AllNodes) {
if (node is BookmarkNode) {
((BookmarkNode)node).Checked = !isOneChecked;
foreach (var node in AllItems) {
if (node.IsChecked) {
isOneChecked = true;
break;
}
}
foreach (var node in AllItems)
node.IsChecked = !isOneChecked;
}
public void SelectItem(ListViewPadItemModel model)
{
listView.CurrentItem = model;
}
void AddMark(SDBookmark mark)
{
if (!ShowBookmarkInThisPad(mark))
return;
if (!fileNodes.ContainsKey(mark.FileName)) {
BookmarkFolderNode folderNode = new BookmarkFolderNode(mark.FileName);
fileNodes.Add(mark.FileName, folderNode);
bookmarkTreeView.Nodes.Add(folderNode);
}
fileNodes[mark.FileName].AddMark(mark);
fileNodes[mark.FileName].Expand();
listView.Add(new ListViewPadItemModel(mark));
}
protected virtual bool ShowBookmarkInThisPad(SDBookmark mark)
{
return mark.IsVisibleInBookmarkPad;
return mark.IsVisibleInBookmarkPad && !(mark is BreakpointBookmark);
}
void BookmarkManagerAdded(object sender, BookmarkEventArgs e)
@ -134,25 +140,18 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -134,25 +140,18 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
void BookmarkManagerRemoved(object sender, BookmarkEventArgs e)
{
if (fileNodes.ContainsKey(e.Bookmark.FileName)) {
fileNodes[e.Bookmark.FileName].RemoveMark(e.Bookmark);
if (fileNodes[e.Bookmark.FileName].Marks.Count == 0) {
bookmarkTreeView.Nodes.Remove(fileNodes[e.Bookmark.FileName]);
fileNodes.Remove(e.Bookmark.FileName);
}
}
listView.Remove(new ListViewPadItemModel(e.Bookmark));
}
void TreeViewDoubleClick(object sender, EventArgs e)
void listView_ItemActivated(object sender, EventArgs e)
{
TreeNode node = bookmarkTreeView.SelectedNode;
var node = CurrentItem;
if (node != null) {
SDBookmark mark = node.Tag as SDBookmark;
SDBookmark mark = node.Mark as SDBookmark;
if (mark != null) {
FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 1);
}
}
}
}
}
}

101
src/Main/Base/Project/Src/Bookmarks/Pad/BookmarkPadToolbarCommands.cs

@ -3,40 +3,83 @@ @@ -3,40 +3,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls;
using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.SharpDevelop.Bookmarks
{
#region Goto Commands
/*
public class GotoNext : AbstractEditActionMenuCommand
public abstract class NextPrevBookmarkPadCommand : AbstractMenuCommand
{
public override IEditAction EditAction {
get {
return new ICSharpCode.TextEditor.Actions.GotoNextBookmark(PrevBookmark.AcceptOnlyStandardBookmarks);
public void Run(ListViewPadItemModel item)
{
var bookmarkBase = (BookmarkPadBase)Owner;
if (item == null) return;
// get next bookmark
int line = (item.Mark as SDBookmark).LineNumber;
SDBookmark bookmark;
if (item.Mark is BreakpointBookmark) {
var bookmarks = DebuggerService.Breakpoints;
bookmark = bookmarks.FirstOrDefault(b => b.LineNumber == line);
if (bookmark == null && bookmarks.Count > 0) {
bookmark = bookmarks[0]; // jump around to first bookmark
}
}
else {
var bookmarks = BookmarkManager.Bookmarks;
bookmark = bookmarks.FirstOrDefault(b => b.LineNumber == line);
if (bookmark == null && bookmarks.Count > 0) {
bookmark = bookmarks[0]; // jump around to first bookmark
}
}
if (bookmark != null) {
FileService.JumpToFilePosition(bookmark.FileName, bookmark.LineNumber, bookmark.ColumnNumber);
}
// select in tree
bookmarkBase.SelectItem(item);
}
}
public class GotoPrev : AbstractEditActionMenuCommand
public sealed class NextBookmarkPadCommand : NextPrevBookmarkPadCommand
{
public override IEditAction EditAction {
get {
return new ICSharpCode.TextEditor.Actions.GotoPrevBookmark(PrevBookmark.AcceptOnlyStandardBookmarks);
}
public override void Run()
{
var bookmarkBase = (BookmarkPadBase)Owner;
var nextItem = bookmarkBase.NextItem;
base.Run(nextItem);
}
}
public sealed class PrevBookmarkPadCommand : NextPrevBookmarkPadCommand
{
public override void Run()
{
var bookmarkBase = (BookmarkPadBase)Owner;
var prevItem = bookmarkBase.PrevItem;
base.Run(prevItem);
}
}
*/
#endregion Goto Commands
#region Delete BookMark(s) commands
public abstract class AbstractDeleteMarkClass : AbstractMenuCommand
{
protected void deleteBookMark (BookmarkNode node) {
ICSharpCode.SharpDevelop.Bookmarks.BookmarkManager.RemoveMark(node.Bookmark);
protected void deleteBookMark (SDBookmark bookmark) {
if (bookmark == null) return;
if (bookmark is BreakpointBookmark) return;
ICSharpCode.SharpDevelop.Bookmarks.BookmarkManager.RemoveMark(bookmark);
}
}
@ -47,23 +90,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -47,23 +90,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
{
public override void Run()
{
IEnumerable<TreeNode> nodes = ((BookmarkPadBase)Owner).AllNodes;
foreach(TreeNode innerNode in nodes) {
BookmarkFolderNode folderNode = innerNode as BookmarkFolderNode;
// Its problebly not the most effecient way of doing it, but it works.
if (folderNode != null) {
for (int i = folderNode.Nodes.Count - 1; i >= 0 ; i--)
{
if (folderNode.Nodes[i] is BookmarkNode) {
deleteBookMark(folderNode.Nodes[i] as BookmarkNode);
}
}
}
}
BookmarkManager.RemoveAll(b => !(b is BreakpointBookmark));
}
}
/// <summary>
/// Deletes the currently selected <see cref="BookmarkNode" /> or <see cref="BookmarkFolderNode" />
/// </summary>
@ -71,21 +101,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks @@ -71,21 +101,10 @@ namespace ICSharpCode.SharpDevelop.Bookmarks
{
public override void Run()
{
TreeNode node = ((BookmarkPadBase)Owner).CurrentNode;
var node = ((BookmarkPadBase)Owner).CurrentItem;
if (node == null) return;
if (node is BookmarkNode) {
deleteBookMark(node as BookmarkNode);
}
if (node is BookmarkFolderNode) {
BookmarkFolderNode folderNode = node as BookmarkFolderNode;
// We have to start from the top of the array to prevent reordering.
for (int i = folderNode.Nodes.Count - 1; i >= 0 ; i--)
{
if (folderNode.Nodes[i] is BookmarkNode) {
deleteBookMark(folderNode.Nodes[i] as BookmarkNode);
}
}
}
deleteBookMark(node.Mark as SDBookmark);
}
}

43
src/Main/Base/Project/Src/Bookmarks/Pad/Controls/ListViewPad.xaml

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls.ListViewPad" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls" xmlns:core="http://icsharpcode.net/sharpdevelop/core"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
<Grid.Resources>
<DataTemplate
x:Key="CheckBoxTemplate">
<CheckBox
IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" />
</DataTemplate>
<DataTemplate
x:Key="ImageTemplate">
<Image
Source="{Binding Path=Image, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</Grid.Resources>
<ListView
Name="MyListView"
ItemsSource="{Binding ItemCollection}">
<ListView.View>
<GridView>
<GridViewColumn
Header=""
Width="Auto"
CellTemplate="{StaticResource CheckBoxTemplate}" />
<GridViewColumn
Header=""
Width="Auto"
CellTemplate="{StaticResource ImageTemplate}" />
<GridViewColumn
Header="{core:Localize MainWindow.Windows.BookmarkPad.LocationText}"
Width="Auto"
DisplayMemberBinding="{Binding Path=Location}" />
<GridViewColumn
Header="{core:Localize MainWindow.Windows.Debug.CallStack.Language}"
Width="Auto"
DisplayMemberBinding="{Binding Path=Language, UpdateSourceTrigger=PropertyChanged}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</UserControl>

243
src/Main/Base/Project/Src/Bookmarks/Pad/Controls/ListViewPad.xaml.cs

@ -0,0 +1,243 @@ @@ -0,0 +1,243 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
namespace ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls
{
/// <summary>
/// ListViewPad inside WPF pads.
/// </summary>
public sealed partial class ListViewPad : UserControl
{
ObservableCollection<ListViewPadItemModel> itemCollection = new ObservableCollection<ListViewPadItemModel>();
public ObservableCollection<ListViewPadItemModel> ItemCollection {
get { return itemCollection; }
}
public event EventHandler ItemActivated;
public ListViewPad()
{
InitializeComponent();
this.MyListView.PreviewMouseDoubleClick += new MouseButtonEventHandler(ListViewPad_PreviewMouseDoubleClick);
this.MyListView.KeyDown += new KeyEventHandler(ListViewPad_KeyDown);
}
public ListViewPadItemModel CurrentItem {
get {
if (MyListView.SelectedItem == null && MyListView.Items.Count > 0)
this.MyListView.SelectedItem = MyListView.Items[0];
return MyListView.SelectedItem as ListViewPadItemModel;
}
set {
if (value == null) return;
this.MyListView.SelectedItem = value;
}
}
public ListViewPadItemModel NextItem {
get {
bool found = false;
foreach (var line in ItemCollection) {
if (found)
return line;
if (line == CurrentItem)
found = true;
}
return null;
}
}
public ListViewPadItemModel PrevItem {
get {
bool found = false;
ListViewPadItemModel prev = null;
foreach (var line in ItemCollection) {
if (found)
return prev;
if (line == CurrentItem) {
found = true;
}
else {
prev = line;
}
}
return prev;
}
}
public void Add(ListViewPadItemModel item)
{
if (item == null) return;
ItemCollection.Add(item);
}
public void Remove(ListViewPadItemModel item)
{
SDBookmark bookmark1 = item.Mark as SDBookmark;
if (bookmark1 is CurrentLineBookmark)
return;
foreach (var line in itemCollection) {
SDBookmark bookmark2 = line.Mark as SDBookmark;
if (bookmark1.FileName == bookmark2.FileName &&
bookmark1.LineNumber == bookmark2.LineNumber) {
ItemCollection.Remove(line);
break;
}
}
}
public void AddColumn(string header, DataTemplate cellTemplate)
{
GridViewColumn column = new GridViewColumn();
column.Header = header;
column.CellTemplate = cellTemplate;
((GridView)this.MyListView.View).Columns.Add(column);
}
/// <summary>
/// Indexes from end to start.
/// </summary>
/// <param name="columnIndex"></param>
public void HideColumns(params int[] columnIndexes)
{
foreach(int i in columnIndexes)
((GridView)MyListView.View).Columns.RemoveAt(i);
}
private void ListViewPad_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var handler = ItemActivated;
if (handler != null)
ItemActivated(this, EventArgs.Empty);
}
private void ListViewPad_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape) {
this.MyListView.UnselectAll();
e.Handled = true;
}
}
}
public sealed class ListViewPadItemModel : INotifyPropertyChanged
{
bool isChecked;
object tag;
string language;
string condition;
ImageSource imageSource;
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
public ListViewPadItemModel(SDBookmark mark)
{
if (mark is BreakpointBookmark) {
isChecked = ((BreakpointBookmark)mark).IsEnabled;
condition = ((BreakpointBookmark)mark).Condition;
language = ((BreakpointBookmark)mark).ScriptLanguage;
}
imageSource = mark.Image.ImageSource;
Location = GetLocation(mark);
Mark = mark;
tag = this;
}
public bool IsChecked {
get {
return isChecked;
}
set {
if (value != isChecked)
{
isChecked = value;
NotifyPropertyChanged("IsChecked");
}
}
}
public SDBookmark Mark {
get; set;
}
public ImageSource Image {
get { return imageSource; }
set {
imageSource = value;
NotifyPropertyChanged("Image");
}
}
public string Location {
get; private set;
}
public string Language {
get { return language; }
set {
language = value;
NotifyPropertyChanged("Language");
}
}
public string Condition {
get { return condition; }
set {
condition = value;
NotifyPropertyChanged("Condition");
}
}
public object Tag {
get { return tag;}
set {
tag = value;
NotifyPropertyChanged("Tag");
}
}
private string GetLocation(SDBookmark bookmark)
{
return string.Format(StringParser.Parse("${res:MainWindow.Windows.BookmarkPad.LineText}"),
Path.GetFileName(bookmark.FileName), bookmark.LineNumber);
}
private void NotifyPropertyChanged(string property)
{
if (property == "IsChecked")
{
if (Mark is BreakpointBookmark)
(Mark as BreakpointBookmark).IsEnabled = isChecked;
}
if (PropertyChanged != null)
{
PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(property));
}
}
}
}

28
src/Main/Base/Project/Src/Commands/DebugCommands.cs

@ -2,7 +2,13 @@ @@ -2,7 +2,13 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Bookmarks.Pad.Controls;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -30,6 +36,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -30,6 +36,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
build.Run();
}
}
public class ExecuteWithoutDebugger : Execute
{
public override void Run()
@ -113,6 +120,27 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -113,6 +120,27 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
}
}
public class RemoveAllBreakpointsCommand : AbstractMenuCommand
{
public override void Run()
{
BookmarkManager.RemoveAll(b => b is BreakpointBookmark);
}
}
public class DeleteBreakpointCommand : AbstractMenuCommand
{
public override void Run()
{
var bookmarkBase = (BookmarkPadBase)Owner;
var item = bookmarkBase.CurrentItem;
if (item.Mark is BreakpointBookmark) {
BookmarkManager.RemoveMark(item.Mark);
}
}
}
public class AttachToProcessCommand : AbstractMenuCommand
{
public override void Run()

31
src/Main/Base/Project/Src/Gui/Pads/AbstractConsolePad.cs

@ -262,6 +262,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -262,6 +262,9 @@ namespace ICSharpCode.SharpDevelop.Gui
internal ITextEditor editorAdapter;
internal BeginReadOnlySectionProvider readOnlyRegion;
public event TextCompositionEventHandler TextAreaTextEntered;
public event KeyEventHandler TextAreaPreviewKeyDown;
public ConsoleControl()
{
this.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
@ -279,6 +282,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -279,6 +282,9 @@ namespace ICSharpCode.SharpDevelop.Gui
this.Children.Add(editor);
editor.TextArea.ReadOnlySectionProvider = readOnlyRegion = new BeginReadOnlySectionProvider();
editor.TextArea.TextEntered += new TextCompositionEventHandler(editor_TextArea_TextEntered);
editor.TextArea.PreviewKeyDown += new KeyEventHandler(editor_TextArea_PreviewKeyDown);
}
public ITextEditor TextEditor {
@ -313,6 +319,15 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -313,6 +319,15 @@ namespace ICSharpCode.SharpDevelop.Gui
readOnlyRegion.EndOffset = editor.Document.TextLength;
}
/// <summary>
/// Hides the scroll bar.
/// </summary>
public void HideScrollBar()
{
this.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
this.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
}
public int CommandOffset {
get { return readOnlyRegion.EndOffset; }
}
@ -328,6 +343,22 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -328,6 +343,22 @@ namespace ICSharpCode.SharpDevelop.Gui
editor.Document.Replace(new TextSegment() { StartOffset = readOnlyRegion.EndOffset, EndOffset = editor.Document.TextLength }, value);
}
}
void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs e)
{
TextCompositionEventHandler handler = TextAreaTextEntered;
if (handler != null)
handler(this, e);
}
void editor_TextArea_PreviewKeyDown(object sender, KeyEventArgs e)
{
KeyEventHandler handler = TextAreaPreviewKeyDown;
if (handler != null)
handler(this, e);
}
}
public class BeginReadOnlySectionProvider : IReadOnlySectionProvider

43
src/Main/Base/Project/Src/Project/CompilableProject.cs

@ -1,18 +1,16 @@ @@ -1,18 +1,16 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Xml.Linq;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project.Converter;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Internal.Templates;
using ICSharpCode.SharpDevelop.Project.Converter;
using ICSharpCode.SharpDevelop.Util;
namespace ICSharpCode.SharpDevelop.Project
@ -580,31 +578,39 @@ namespace ICSharpCode.SharpDevelop.Project @@ -580,31 +578,39 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
void UpdateAppConfig(TargetFramework newFramework)
public static FileName GetAppConfigFile(IProject project, bool createIfNotExists)
{
// When changing the target framework, update any existing app.config
// Also, for applications (not libraries), create an app.config is it is required for the target framework
bool createAppConfig = newFramework.RequiresAppConfigEntry && (this.OutputType != OutputType.Library && this.OutputType != OutputType.Module);
string appConfigFileName = Path.Combine(this.Directory, "app.config");
FileName appConfigFileName = Core.FileName.Create(Path.Combine(project.Directory, "app.config"));
if (!File.Exists(appConfigFileName)) {
if (createAppConfig) {
if (createIfNotExists) {
File.WriteAllText(appConfigFileName,
"<?xml version=\"1.0\"?>" + Environment.NewLine +
"<configuration>" + Environment.NewLine
+ "</configuration>");
} else {
return;
return null;
}
}
if (!IsFileInProject(appConfigFileName)) {
FileProjectItem fpi = new FileProjectItem(this, ItemType.None, "app.config");
ProjectService.AddProjectItem(this, fpi);
if (!project.IsFileInProject(appConfigFileName)) {
FileProjectItem fpi = new FileProjectItem(project, ItemType.None, "app.config");
ProjectService.AddProjectItem(project, fpi);
FileService.FireFileCreated(appConfigFileName, false);
ProjectBrowserPad.RefreshViewAsync();
}
return appConfigFileName;
}
void UpdateAppConfig(TargetFramework newFramework)
{
// When changing the target framework, update any existing app.config
// Also, for applications (not libraries), create an app.config is it is required for the target framework
bool createAppConfig = newFramework.RequiresAppConfigEntry && (this.OutputType != OutputType.Library && this.OutputType != OutputType.Module);
string appConfigFileName = GetAppConfigFile(this, createAppConfig);
if (appConfigFileName == null)
return;
using (FakeXmlViewContent xml = new FakeXmlViewContent(appConfigFileName)) {
if (xml.Document != null) {
@ -616,13 +622,12 @@ namespace ICSharpCode.SharpDevelop.Project @@ -616,13 +622,12 @@ namespace ICSharpCode.SharpDevelop.Project
// <configSections> must be first element
configuration.Elements().First().AddAfterSelf(startup);
} else {
configuration.AddFirst(startup);
startup = configuration.AddFirstWithIndentation(startup);
}
}
XElement supportedRuntime = startup.Element("supportedRuntime");
if (supportedRuntime == null) {
supportedRuntime = new XElement("supportedRuntime");
startup.AddFirst(supportedRuntime);
supportedRuntime = startup.AddFirstWithIndentation(new XElement("supportedRuntime"));
}
supportedRuntime.SetAttributeValue("version", newFramework.SupportedRuntimeVersion);
supportedRuntime.SetAttributeValue("sku", newFramework.SupportedSku);

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

@ -12,6 +12,7 @@ using System.Text; @@ -12,6 +12,7 @@ using System.Text;
using System.Text.RegularExpressions;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop.Project
@ -145,6 +146,17 @@ namespace ICSharpCode.SharpDevelop.Project @@ -145,6 +146,17 @@ namespace ICSharpCode.SharpDevelop.Project
CodeDomProvider provider = project.LanguageProperties.CodeDomProvider;
CodeGeneratorOptions options = new CodeDOMGeneratorUtility().CreateCodeGeneratorOptions;
if (project.LanguageProperties == LanguageProperties.VBNet) {
// the root namespace is implicit in VB
foreach (CodeNamespace ns in ccu.Namespaces) {
if (string.Equals(ns.Name, project.RootNamespace, StringComparison.OrdinalIgnoreCase)) {
ns.Name = string.Empty;
} else if (ns.Name.StartsWith(project.RootNamespace + ".", StringComparison.OrdinalIgnoreCase)) {
ns.Name = ns.Name.Substring(project.RootNamespace.Length + 1);
}
}
}
string codeOutput;
using (StringWriter writer = new StringWriter()) {
if (provider == null) {

86
src/Main/Base/Project/Src/Util/ExtensionMethods.cs

@ -5,14 +5,18 @@ using System; @@ -5,14 +5,18 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Media;
using System.Xml;
using System.Xml.Linq;
using ICSharpCode.Core.Presentation;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
@ -347,7 +351,7 @@ namespace ICSharpCode.SharpDevelop @@ -347,7 +351,7 @@ namespace ICSharpCode.SharpDevelop
}
/// <summary>
/// Takes at most <param name="length" /> first characters from string.
/// Takes at most <param name="length" /> first characters from string.
/// String can be null.
/// </summary>
public static string TakeStart(this string s, int length)
@ -358,7 +362,7 @@ namespace ICSharpCode.SharpDevelop @@ -358,7 +362,7 @@ namespace ICSharpCode.SharpDevelop
}
/// <summary>
/// Takes at most <param name="length" /> first characters from string, and appends '...' if string is longer.
/// Takes at most <param name="length" /> first characters from string, and appends '...' if string is longer.
/// String can be null.
/// </summary>
public static string TakeStartEllipsis(this string s, int length)
@ -498,5 +502,81 @@ namespace ICSharpCode.SharpDevelop @@ -498,5 +502,81 @@ namespace ICSharpCode.SharpDevelop
{
return expr.Region.IsEmpty;
}
public static void WriteTo(this Stream sourceStream, Stream targetStream)
{
byte[] buffer = new byte[4096];
int bytes;
while ((bytes = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
targetStream.Write(buffer, 0, bytes);
}
public static XElement FormatXml(this XElement element, int indentationLevel)
{
StringWriter sw = new StringWriter();
using (XmlTextWriter xmlW = new XmlTextWriter(sw)) {
if (EditorControlService.GlobalOptions.ConvertTabsToSpaces) {
xmlW.IndentChar = ' ';
xmlW.Indentation = EditorControlService.GlobalOptions.IndentationSize;
} else {
xmlW.Indentation = 1;
xmlW.IndentChar = '\t';
}
xmlW.Formatting = Formatting.Indented;
element.WriteTo(xmlW);
}
string xmlText = sw.ToString();
xmlText = xmlText.Replace(sw.NewLine, sw.NewLine + GetIndentation(indentationLevel));
return XElement.Parse(xmlText, LoadOptions.PreserveWhitespace);
}
static string GetIndentation(int level)
{
StringBuilder indentation = new StringBuilder();
for (int i = 0; i < level; i++) {
indentation.Append(EditorControlService.GlobalOptions.IndentationString);
}
return indentation.ToString();
}
public static XElement AddWithIndentation(this XElement element, XElement newContent)
{
int indentationLevel = 0;
XElement tmp = element;
while (tmp != null) {
tmp = tmp.Parent;
indentationLevel++;
}
if (!element.Nodes().Any()) {
element.Add(new XText(Environment.NewLine + GetIndentation(indentationLevel - 1)));
}
XText whitespace = element.Nodes().Last() as XText;
if (whitespace != null && string.IsNullOrWhiteSpace(whitespace.Value)) {
whitespace.AddBeforeSelf(new XText(Environment.NewLine + GetIndentation(indentationLevel)));
whitespace.AddBeforeSelf(newContent = FormatXml(newContent, indentationLevel));
} else {
element.Add(new XText(Environment.NewLine + GetIndentation(indentationLevel)));
element.Add(newContent = FormatXml(newContent, indentationLevel));
}
return newContent;
}
public static XElement AddFirstWithIndentation(this XElement element, XElement newContent)
{
int indentationLevel = 0;
StringBuilder indentation = new StringBuilder();
XElement tmp = element;
while (tmp != null) {
tmp = tmp.Parent;
indentationLevel++;
indentation.Append(EditorControlService.GlobalOptions.IndentationString);
}
if (!element.Nodes().Any()) {
element.Add(new XText(Environment.NewLine + GetIndentation(indentationLevel - 1)));
}
element.AddFirst(newContent = FormatXml(newContent, indentationLevel));
element.AddFirst(new XText(Environment.NewLine + indentation.ToString()));
return newContent;
}
}
}

12
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/LanguageProperties.cs

@ -243,6 +243,18 @@ namespace ICSharpCode.SharpDevelop.Dom @@ -243,6 +243,18 @@ namespace ICSharpCode.SharpDevelop.Dom
return "[" + base.ToString() + "]";
}
public static LanguageProperties GetLanguage(string language)
{
switch(language)
{
case "VBNet":
case "VB":
return LanguageProperties.VBNet;
default:
return LanguageProperties.CSharp;
}
}
#region CSharpProperties
internal sealed class CSharpProperties : LanguageProperties
{

BIN
src/Main/StartUp/Project/Resources/BitmapResources.resources

Binary file not shown.

8
src/Setup/Files.wxs

@ -816,6 +816,7 @@ @@ -816,6 +816,7 @@
<File Source="..\..\data\templates\project\VBNet\Service.xpt" Name="Service.xpt" Id="VBNetService.xpt" />
<File Source="..\..\data\templates\project\VBNet\SharedAddin.xpt" Id="VBNetSharedAddin.xpt" Name="SharedAddin.xpt" />
<File Source="..\..\data\templates\project\VBNet\SharpDevelopAddin.xpt" Id="VBNetSharpDevelopAddin.xpt" Name="SharpDevelopAddin.xpt" />
<File Id="MySettings.settings" Name="MySettings.settings" Source="..\..\data\templates\project\VBNet\MySettings.settings" />
</Component>
</Directory>
<Component Guid="73EAC135-57B6-46C0-9F24-70A347B9AAC8" Id="ExampleProjectTemplate" DiskId="1">
@ -1326,6 +1327,13 @@ @@ -1326,6 +1327,13 @@
</Directory>
</Directory>
</Directory>
<Directory Id="SettingsEditor" Name="SettingsEditor">
<Component Id="SettingsEditorFiles" Guid="4A12129A-6BB5-4CC7-A105-C1F6FDF345F2" DiskId="1">
<File Id="SettingsEditor.dll" Name="SettingsEditor.dll" Source="..\..\AddIns\DisplayBindings\SettingsEditor\SettingsEditor.dll" KeyPath="yes" />
<File Id="SettingsEditor.addin" Name="SettingsEditor.addin" Source="..\..\AddIns\DisplayBindings\SettingsEditor\SettingsEditor.addin" />
<File Id="EmptySettingsFile.xft" Name="EmptySettingsFile.xft" Source="..\..\AddIns\DisplayBindings\SettingsEditor\EmptySettingsFile.xft" />
</Component>
</Directory>
</Directory>
<Directory Id="DebuggerFolder" Name="Debugger">
<Component Guid="27C66A5A-0149-45F4-B1AF-C320FE005E6B" Id="DebuggerAddInFiles" DiskId="1">

1
src/Setup/Setup.wxs

@ -345,6 +345,7 @@ @@ -345,6 +345,7 @@
<ComponentRef Id="IconEditorAddInFiles"/>
<ComponentRef Id="IconEditorExe"/>
<ComponentRef Id="ResourceEditorFiles"/>
<ComponentRef Id="SettingsEditorFiles"/>
<ComponentRef Id="ClassDiagramResources"/>
<ComponentRef Id="ClassDiagramAddInFiles"/>
<ComponentRef Id="ClassCanvasDll"/>

Loading…
Cancel
Save