@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
|
||||
namespace ILSpy.BamlDecompiler |
||||
{ |
||||
public static class Extensions |
||||
{ |
||||
public static string TrimEnd(this string target, Func<char, bool> predicate) |
||||
{ |
||||
if (target == null) |
||||
throw new ArgumentNullException("target"); |
||||
|
||||
while (predicate(target.LastOrDefault())) |
||||
target = target.Remove(target.Length - 1); |
||||
|
||||
return target; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace Ricciolo.StylesExplorer.MarkupReflection |
||||
{ |
||||
class XmlBamlSimpleProperty : XmlBamlNode |
||||
{ |
||||
public string NamespaceName { get; private set; } |
||||
public string LocalName { get; private set; } |
||||
public string Value { get; private set; } |
||||
|
||||
public XmlBamlSimpleProperty(string namespaceName, string localName, string value) |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(namespaceName)) |
||||
throw new ArgumentException("namespaceName"); |
||||
if (string.IsNullOrWhiteSpace(localName)) |
||||
throw new ArgumentException("localName"); |
||||
if (value == null) |
||||
throw new ArgumentNullException("value"); |
||||
this.NamespaceName = namespaceName; |
||||
this.LocalName = localName; |
||||
this.Value = value; |
||||
} |
||||
|
||||
public override XmlNodeType NodeType { |
||||
get { return XmlNodeType.Attribute; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
<Window x:Class="ILSpy.BamlDecompiler.Tests.Cases.Simple" Title="ILSpy.BamlDecompiler.Tests.Cases" Height="300" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<Grid /> |
||||
</Window> |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// 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.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; |
||||
|
||||
namespace ILSpy.BamlDecompiler.Tests.Cases |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for Simple.xaml
|
||||
/// </summary>
|
||||
public partial class Simple : Window |
||||
{ |
||||
public Simple() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"></ResourceDictionary> |
||||
@ -0,0 +1,109 @@
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{1169E6D1-1899-43D4-A500-07CE4235B388}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ILSpy.BamlDecompiler.Tests</RootNamespace> |
||||
<AssemblyName>ILSpy.BamlDecompiler.Tests</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\bin\Debug\</OutputPath> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\bin\Release\</OutputPath> |
||||
<DebugSymbols>false</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="DiffLib"> |
||||
<HintPath>..\..\packages\DiffLib.1.0.0.55\lib\net35-Client\DiffLib.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="nunit.framework"> |
||||
<HintPath>..\..\ICSharpCode.Decompiler\Tests\nunit.framework.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="PresentationCore"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xaml"> |
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Cases\Simple.xaml.cs"> |
||||
<DependentUpon>Simple.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
<Compile Include="TestRunner.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\ICSharpCode.Decompiler\Tests\ICSharpCode.Decompiler.Tests.csproj"> |
||||
<Project>{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}</Project> |
||||
<Name>ICSharpCode.Decompiler.Tests</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\ILSpy\ILSpy.csproj"> |
||||
<Project>{1E85EFF9-E370-4683-83E4-8A3D063FF791}</Project> |
||||
<Name>ILSpy</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\Mono.Cecil\Mono.Cecil.csproj"> |
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project> |
||||
<Name>Mono.Cecil</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\SharpTreeView\ICSharpCode.TreeView.csproj"> |
||||
<Project>{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}</Project> |
||||
<Name>ICSharpCode.TreeView</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ILSpy.BamlDecompiler.csproj"> |
||||
<Project>{A6BAD2BA-76BA-461C-8B6D-418607591247}</Project> |
||||
<Name>ILSpy.BamlDecompiler</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Cases" /> |
||||
<Folder Include="Properties" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Cases\Simple.xaml"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Page> |
||||
<Page Include="Cases\SimpleDictionary.xaml" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ILSpy.BamlDecompiler.Tests")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("ILSpy.BamlDecompiler.Tests")] |
||||
[assembly: AssemblyCopyright("Copyright 2011")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
// 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; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Resources; |
||||
using System.Xml.Linq; |
||||
using ICSharpCode.Decompiler.Tests.Helpers; |
||||
using ICSharpCode.ILSpy; |
||||
using Mono.Cecil; |
||||
using NUnit.Framework; |
||||
using Ricciolo.StylesExplorer.MarkupReflection; |
||||
|
||||
namespace ILSpy.BamlDecompiler.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class TestRunner |
||||
{ |
||||
[Test] |
||||
public void Simple() |
||||
{ |
||||
RunTest("cases/simple"); |
||||
} |
||||
|
||||
[Test] |
||||
public void SimpleDictionary() |
||||
{ |
||||
RunTest("cases/simpledictionary"); |
||||
} |
||||
|
||||
void RunTest(string name) |
||||
{ |
||||
string asmPath = typeof(TestRunner).Assembly.Location; |
||||
var assembly = AssemblyDefinition.ReadAssembly(asmPath); |
||||
Resource res = assembly.MainModule.Resources.First(); |
||||
Stream bamlStream = LoadBaml(res, name + ".baml"); |
||||
Assert.IsNotNull(bamlStream); |
||||
XDocument document = BamlResourceEntryNode.LoadIntoDocument(new DefaultAssemblyResolver(), assembly, bamlStream); |
||||
string path = Path.Combine("..\\..\\Tests", name + ".xaml"); |
||||
|
||||
CodeAssert.AreEqual(document.ToString(), File.ReadAllText(path)); |
||||
} |
||||
|
||||
Stream LoadBaml(Resource res, string name) |
||||
{ |
||||
EmbeddedResource er = res as EmbeddedResource; |
||||
if (er != null) { |
||||
Stream s = er.GetResourceStream(); |
||||
s.Position = 0; |
||||
ResourceReader reader; |
||||
try { |
||||
reader = new ResourceReader(s); |
||||
} |
||||
catch (ArgumentException) { |
||||
return null; |
||||
} |
||||
foreach (DictionaryEntry entry in reader.Cast<DictionaryEntry>().OrderBy(e => e.Key.ToString())) { |
||||
if (entry.Key.ToString() == name) { |
||||
if (entry.Value is Stream) |
||||
return (Stream)entry.Value; |
||||
if (entry.Value is byte[]) |
||||
return new MemoryStream((byte[])entry.Value); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
// 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.Generic; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.ILSpy.Bookmarks; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
/// <summary>
|
||||
/// Represents a text marker.
|
||||
/// </summary>
|
||||
public interface ITextMarker |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the start offset of the marked text region.
|
||||
/// </summary>
|
||||
int StartOffset { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the end offset of the marked text region.
|
||||
/// </summary>
|
||||
int EndOffset { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the length of the marked region.
|
||||
/// </summary>
|
||||
int Length { get; } |
||||
|
||||
/// <summary>
|
||||
/// Deletes the text marker.
|
||||
/// </summary>
|
||||
void Delete(); |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the text marker was deleted.
|
||||
/// </summary>
|
||||
bool IsDeleted { get; } |
||||
|
||||
/// <summary>
|
||||
/// Event that occurs when the text marker is deleted.
|
||||
/// </summary>
|
||||
event EventHandler Deleted; |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the background color.
|
||||
/// </summary>
|
||||
Color? BackgroundColor { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the foreground color.
|
||||
/// </summary>
|
||||
Color? ForegroundColor { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the type of the marker. Use TextMarkerType.None for normal markers.
|
||||
/// </summary>
|
||||
TextMarkerType MarkerType { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the color of the marker.
|
||||
/// </summary>
|
||||
Color MarkerColor { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets an object with additional data for this text marker.
|
||||
/// </summary>
|
||||
object Tag { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets an object that will be displayed as tooltip in the text editor.
|
||||
/// </summary>
|
||||
object ToolTip { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the marker is visible or not.
|
||||
/// </summary>
|
||||
Predicate<object> IsVisible { get; set; } |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bookmark.
|
||||
/// </summary>
|
||||
IBookmark Bookmark { get; set; } |
||||
} |
||||
|
||||
public enum TextMarkerType |
||||
{ |
||||
/// <summary>
|
||||
/// Use no marker
|
||||
/// </summary>
|
||||
None, |
||||
/// <summary>
|
||||
/// Use squiggly underline marker
|
||||
/// </summary>
|
||||
SquigglyUnderline |
||||
} |
||||
|
||||
public interface ITextMarkerService |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a new text marker. The text marker will be invisible at first,
|
||||
/// you need to set one of the Color properties to make it visible.
|
||||
/// </summary>
|
||||
ITextMarker Create(int startOffset, int length); |
||||
|
||||
/// <summary>
|
||||
/// Gets the list of text markers.
|
||||
/// </summary>
|
||||
IEnumerable<ITextMarker> TextMarkers { get; } |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified text marker.
|
||||
/// </summary>
|
||||
void Remove(ITextMarker marker); |
||||
|
||||
/// <summary>
|
||||
/// Removes all text markers that match the condition.
|
||||
/// </summary>
|
||||
void RemoveAll(Predicate<ITextMarker> predicate); |
||||
} |
||||
} |
||||
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.ILSpy.Bookmarks; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
/// <summary>
|
||||
/// Stores the entries in the icon bar margin. Multiple icon bar margins
|
||||
/// can use the same manager if split view is used.
|
||||
/// </summary>
|
||||
public class IconBarManager : IBookmarkMargin |
||||
{ |
||||
ObservableCollection<IBookmark> bookmarks = new ObservableCollection<IBookmark>(); |
||||
|
||||
public IconBarManager() |
||||
{ |
||||
bookmarks.CollectionChanged += bookmarks_CollectionChanged; |
||||
} |
||||
|
||||
public IList<IBookmark> Bookmarks { |
||||
get { return bookmarks; } |
||||
} |
||||
|
||||
void bookmarks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) |
||||
{ |
||||
Redraw(); |
||||
} |
||||
|
||||
public void Redraw() |
||||
{ |
||||
if (RedrawRequested != null) |
||||
RedrawRequested(this, EventArgs.Empty); |
||||
} |
||||
|
||||
public event EventHandler RedrawRequested; |
||||
|
||||
internal void UpdateClassMemberBookmarks(IEnumerable<AstNode> nodes) |
||||
{ |
||||
this.bookmarks.Clear(); |
||||
|
||||
if (nodes == null || nodes.Count() == 0) |
||||
return; |
||||
|
||||
foreach (var n in nodes) { |
||||
switch (n.NodeType) { |
||||
case NodeType.TypeDeclaration: |
||||
case NodeType.TypeReference: |
||||
this.bookmarks.Add(new TypeBookmark(n)); |
||||
break; |
||||
case NodeType.Member: |
||||
this.bookmarks.Add(new MemberBookmark(n)); |
||||
break; |
||||
default: |
||||
// do nothing
|
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -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.Generic; |
||||
using System.ComponentModel.Composition; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.AvalonEdit.Editing; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
using ICSharpCode.AvalonEdit.Utils; |
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.ILSpy.Bookmarks; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
public class IconBarMargin : AbstractMargin, IDisposable |
||||
{ |
||||
readonly IconBarManager manager; |
||||
|
||||
public IconBarMargin(IconBarManager manager) |
||||
{ |
||||
BookmarkManager.Added += delegate { InvalidateVisual(); }; |
||||
BookmarkManager.Removed += delegate { InvalidateVisual(); }; |
||||
|
||||
this.manager = manager; |
||||
} |
||||
|
||||
public IconBarManager Manager { |
||||
get { return manager; } |
||||
} |
||||
|
||||
public IList<MemberReference> DecompiledMembers { get; set; } |
||||
|
||||
public virtual void Dispose() |
||||
{ |
||||
this.TextView = null; // detach from TextView (will also detach from manager)
|
||||
} |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) |
||||
{ |
||||
// accept clicks even when clicking on the background
|
||||
return new PointHitTestResult(this, hitTestParameters.HitPoint); |
||||
} |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Size MeasureOverride(Size availableSize) |
||||
{ |
||||
return new Size(18, 0); |
||||
} |
||||
|
||||
protected override void OnRender(DrawingContext drawingContext) |
||||
{ |
||||
Size renderSize = this.RenderSize; |
||||
drawingContext.DrawRectangle(SystemColors.ControlBrush, null, |
||||
new Rect(0, 0, renderSize.Width, renderSize.Height)); |
||||
drawingContext.DrawLine(new Pen(SystemColors.ControlDarkBrush, 1), |
||||
new Point(renderSize.Width - 0.5, 0), |
||||
new Point(renderSize.Width - 0.5, renderSize.Height)); |
||||
|
||||
ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; |
||||
if (textView != null && textView.VisualLinesValid) { |
||||
// create a dictionary line number => first bookmark
|
||||
Dictionary<int, IBookmark> bookmarkDict = new Dictionary<int, IBookmark>(); |
||||
foreach (var bm in BookmarkManager.Bookmarks) { |
||||
if (!DecompiledMembers.Contains(bm.MemberReference)) |
||||
continue; |
||||
int line = bm.LineNumber; |
||||
IBookmark existingBookmark; |
||||
if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) |
||||
bookmarkDict[line] = bm; |
||||
} |
||||
|
||||
foreach (var bm in manager.Bookmarks) { |
||||
int line = bm.LineNumber; |
||||
IBookmark existingBookmark; |
||||
if (!bookmarkDict.TryGetValue(line, out existingBookmark) || bm.ZOrder > existingBookmark.ZOrder) |
||||
bookmarkDict[line] = bm; |
||||
} |
||||
|
||||
Size pixelSize = PixelSnapHelpers.GetPixelSize(this); |
||||
foreach (VisualLine line in textView.VisualLines) { |
||||
int lineNumber = line.FirstDocumentLine.LineNumber; |
||||
IBookmark bm; |
||||
if (bookmarkDict.TryGetValue(lineNumber, out bm)) { |
||||
Rect rect = new Rect(0, PixelSnapHelpers.Round(line.VisualTop - textView.VerticalOffset, pixelSize.Height), 16, 16); |
||||
if (dragDropBookmark == bm && dragStarted) |
||||
drawingContext.PushOpacity(0.5); |
||||
drawingContext.DrawImage(bm.Image, rect); |
||||
if (dragDropBookmark == bm && dragStarted) |
||||
drawingContext.Pop(); |
||||
} |
||||
} |
||||
if (dragDropBookmark != null && dragStarted) { |
||||
Rect rect = new Rect(0, PixelSnapHelpers.Round(dragDropCurrentPoint - 8, pixelSize.Height), 16, 16); |
||||
drawingContext.DrawImage(dragDropBookmark.Image, rect); |
||||
} |
||||
} |
||||
} |
||||
|
||||
IBookmark dragDropBookmark; // bookmark being dragged (!=null if drag'n'drop is active)
|
||||
double dragDropStartPoint; |
||||
double dragDropCurrentPoint; |
||||
bool dragStarted; // whether drag'n'drop operation has started (mouse was moved minimum distance)
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e) |
||||
{ |
||||
base.OnMouseDown(e); |
||||
int line = GetLineFromMousePosition(e); |
||||
if (!e.Handled && line > 0) { |
||||
IBookmark bm = GetBookmarkFromLine(line); |
||||
if (bm != null) { |
||||
bm.MouseDown(e); |
||||
if (!e.Handled) { |
||||
if (e.ChangedButton == MouseButton.Left && bm.CanDragDrop && CaptureMouse()) { |
||||
StartDragDrop(bm, e); |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
// don't allow selecting text through the IconBarMargin
|
||||
if (e.ChangedButton == MouseButton.Left) |
||||
e.Handled = true; |
||||
} |
||||
|
||||
IBookmark GetBookmarkFromLine(int line) |
||||
{ |
||||
BookmarkBase result = null; |
||||
foreach (BookmarkBase bm in BookmarkManager.Bookmarks) { |
||||
if (bm.LineNumber == line && |
||||
this.DecompiledMembers != null && this.DecompiledMembers.Contains(bm.MemberReference)) { |
||||
if (result == null || bm.ZOrder > result.ZOrder) |
||||
return result; |
||||
} |
||||
} |
||||
|
||||
return manager.Bookmarks.FirstOrDefault(b => b.LineNumber == line); |
||||
} |
||||
|
||||
protected override void OnLostMouseCapture(MouseEventArgs e) |
||||
{ |
||||
CancelDragDrop(); |
||||
base.OnLostMouseCapture(e); |
||||
} |
||||
|
||||
void StartDragDrop(IBookmark bm, MouseEventArgs e) |
||||
{ |
||||
dragDropBookmark = bm; |
||||
dragDropStartPoint = dragDropCurrentPoint = e.GetPosition(this).Y; |
||||
if (TextView != null) { |
||||
TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea; |
||||
if (area != null) |
||||
area.PreviewKeyDown += TextArea_PreviewKeyDown; |
||||
} |
||||
} |
||||
|
||||
void CancelDragDrop() |
||||
{ |
||||
if (dragDropBookmark != null) { |
||||
dragDropBookmark = null; |
||||
dragStarted = false; |
||||
if (TextView != null) { |
||||
TextArea area = TextView.Services.GetService(typeof(TextArea)) as TextArea; |
||||
if (area != null) |
||||
area.PreviewKeyDown -= TextArea_PreviewKeyDown; |
||||
} |
||||
ReleaseMouseCapture(); |
||||
InvalidateVisual(); |
||||
} |
||||
} |
||||
|
||||
void TextArea_PreviewKeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
// any key press cancels drag'n'drop
|
||||
CancelDragDrop(); |
||||
if (e.Key == Key.Escape) |
||||
e.Handled = true; |
||||
} |
||||
|
||||
internal int GetLineFromMousePosition(MouseEventArgs e) |
||||
{ |
||||
ICSharpCode.AvalonEdit.Rendering.TextView textView = this.TextView; |
||||
if (textView == null) |
||||
return 0; |
||||
VisualLine vl = textView.GetVisualLineFromVisualTop(e.GetPosition(textView).Y + textView.ScrollOffset.Y); |
||||
if (vl == null) |
||||
return 0; |
||||
return vl.FirstDocumentLine.LineNumber; |
||||
} |
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e) |
||||
{ |
||||
base.OnMouseMove(e); |
||||
if (dragDropBookmark != null) { |
||||
dragDropCurrentPoint = e.GetPosition(this).Y; |
||||
if (Math.Abs(dragDropCurrentPoint - dragDropStartPoint) > SystemParameters.MinimumVerticalDragDistance) |
||||
dragStarted = true; |
||||
InvalidateVisual(); |
||||
} |
||||
} |
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e) |
||||
{ |
||||
base.OnMouseUp(e); |
||||
int line = GetLineFromMousePosition(e); |
||||
if (!e.Handled && dragDropBookmark != null) { |
||||
if (dragStarted) { |
||||
if (line != 0) |
||||
dragDropBookmark.Drop(line); |
||||
e.Handled = true; |
||||
} |
||||
CancelDragDrop(); |
||||
} |
||||
if (!e.Handled && line != 0) { |
||||
var bm = GetBookmarkFromLine(line); |
||||
if (bm != null) { |
||||
bm.MouseUp(e); |
||||
|
||||
if (bm is BookmarkBase) { |
||||
if ((bm as BookmarkBase).CanToggle) { |
||||
BookmarkManager.RemoveMark(bm as BookmarkBase); |
||||
InvalidateVisual(); |
||||
} |
||||
} |
||||
if (e.Handled) |
||||
return; |
||||
} |
||||
if (e.ChangedButton == MouseButton.Left) { |
||||
// TODO: notify subscribers
|
||||
} |
||||
InvalidateVisual(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,189 @@
@@ -0,0 +1,189 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Composition; |
||||
using System.Linq; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.ILSpy.Bookmarks; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
#region Context menu extensibility
|
||||
public interface IBookmarkContextMenuEntry |
||||
{ |
||||
bool IsVisible(IBookmark[] bookmarks); |
||||
bool IsEnabled(IBookmark[] bookmarks); |
||||
void Execute(IBookmark[] bookmarks); |
||||
} |
||||
|
||||
public interface IBookmarkContextMenuEntryMetadata |
||||
{ |
||||
string Icon { get; } |
||||
string Header { get; } |
||||
string Category { get; } |
||||
|
||||
double Order { get; } |
||||
} |
||||
|
||||
[MetadataAttribute] |
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] |
||||
public class ExportBookmarkContextMenuEntryAttribute : ExportAttribute, IBookmarkContextMenuEntryMetadata |
||||
{ |
||||
public ExportBookmarkContextMenuEntryAttribute() |
||||
: base(typeof(IBookmarkContextMenuEntry)) |
||||
{ |
||||
} |
||||
|
||||
public string Icon { get; set; } |
||||
public string Header { get; set; } |
||||
public string Category { get; set; } |
||||
public double Order { get; set; } |
||||
} |
||||
#endregion
|
||||
|
||||
#region Actions (simple clicks) - this will be used for creating bookmarks (e.g. Breakpoint bookmarks)
|
||||
|
||||
public interface IBookmarkActionEntry |
||||
{ |
||||
bool IsEnabled(); |
||||
void Execute(); |
||||
} |
||||
|
||||
public interface IBookmarkActionMetadata |
||||
{ |
||||
string Category { get; } |
||||
|
||||
double Order { get; } |
||||
} |
||||
|
||||
[MetadataAttribute] |
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] |
||||
public class ExportBookmarkActionEntryAttribute : ExportAttribute, IBookmarkActionMetadata |
||||
{ |
||||
public ExportBookmarkActionEntryAttribute() |
||||
: base(typeof(IBookmarkActionEntry)) |
||||
{ |
||||
} |
||||
|
||||
public string Icon { get; set; } |
||||
public string Header { get; set; } |
||||
public string Category { get; set; } |
||||
public double Order { get; set; } |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
internal class IconMarginActionsProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Enables extensible context menu support for the specified icon margin.
|
||||
/// </summary>
|
||||
public static void Add(IconBarMargin margin) |
||||
{ |
||||
var provider = new IconMarginActionsProvider(margin); |
||||
margin.MouseDown += provider.MouseDown; |
||||
margin.ContextMenu = new ContextMenu(); |
||||
} |
||||
|
||||
readonly IconBarMargin margin; |
||||
|
||||
[ImportMany(typeof(IBookmarkContextMenuEntry))] |
||||
Lazy<IBookmarkContextMenuEntry, IBookmarkContextMenuEntryMetadata>[] contextEntries = null; |
||||
|
||||
[ImportMany(typeof(IBookmarkActionEntry))] |
||||
Lazy<IBookmarkActionEntry, IBookmarkActionMetadata>[] actionEntries = null; |
||||
|
||||
private IconMarginActionsProvider(IconBarMargin margin) |
||||
{ |
||||
this.margin = margin; |
||||
App.CompositionContainer.ComposeParts(this); |
||||
} |
||||
|
||||
void MouseDown(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
int line = margin.GetLineFromMousePosition(e); |
||||
|
||||
var bookmarks = margin.Manager.Bookmarks.ToArray(); |
||||
if (bookmarks.Length == 0) { |
||||
// don't show the menu
|
||||
e.Handled = true; |
||||
this.margin.ContextMenu = null; |
||||
return; |
||||
} |
||||
|
||||
if (e.LeftButton == MouseButtonState.Pressed) { |
||||
foreach (var category in actionEntries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) { |
||||
foreach (var entryPair in category) { |
||||
IBookmarkActionEntry entry = entryPair.Value; |
||||
|
||||
if (entryPair.Value.IsEnabled()) { |
||||
entry.Execute(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (e.RightButton == MouseButtonState.Pressed) { |
||||
// check if we are on a Member
|
||||
var bookmark = bookmarks.FirstOrDefault(b => b.LineNumber == line); |
||||
if (bookmark == null) { |
||||
// don't show the menu
|
||||
e.Handled = true; |
||||
this.margin.ContextMenu = null; |
||||
return; |
||||
} |
||||
|
||||
var marks = new[] { bookmark }; |
||||
ContextMenu menu = new ContextMenu(); |
||||
foreach (var category in contextEntries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) { |
||||
if (menu.Items.Count > 0) { |
||||
menu.Items.Add(new Separator()); |
||||
} |
||||
foreach (var entryPair in category) { |
||||
IBookmarkContextMenuEntry entry = entryPair.Value; |
||||
if (entry.IsVisible(marks)) { |
||||
MenuItem menuItem = new MenuItem(); |
||||
menuItem.Header = entryPair.Metadata.Header; |
||||
if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) { |
||||
menuItem.Icon = new Image { |
||||
Width = 16, |
||||
Height = 16, |
||||
Source = Images.LoadImage(entry, entryPair.Metadata.Icon) |
||||
}; |
||||
} |
||||
if (entryPair.Value.IsEnabled(marks)) { |
||||
menuItem.Click += delegate { entry.Execute(marks); }; |
||||
} else |
||||
menuItem.IsEnabled = false; |
||||
menu.Items.Add(menuItem); |
||||
} |
||||
} |
||||
} |
||||
if (menu.Items.Count > 0) |
||||
margin.ContextMenu = menu; |
||||
else |
||||
// hide the context menu.
|
||||
e.Handled = true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.AvalonEdit.Utils; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
public static class TextEditorWeakEventManager |
||||
{ |
||||
public sealed class MouseHover : WeakEventManagerBase<MouseHover, TextEditor> |
||||
{ |
||||
protected override void StopListening(TextEditor source) |
||||
{ |
||||
source.MouseHover -= DeliverEvent; |
||||
} |
||||
|
||||
protected override void StartListening(TextEditor source) |
||||
{ |
||||
source.MouseHover += DeliverEvent; |
||||
} |
||||
} |
||||
|
||||
public sealed class MouseHoverStopped : WeakEventManagerBase<MouseHoverStopped, TextEditor> |
||||
{ |
||||
protected override void StopListening(TextEditor source) |
||||
{ |
||||
source.MouseHoverStopped -= DeliverEvent; |
||||
} |
||||
|
||||
protected override void StartListening(TextEditor source) |
||||
{ |
||||
source.MouseHoverStopped += DeliverEvent; |
||||
} |
||||
} |
||||
|
||||
public sealed class MouseDown : WeakEventManagerBase<MouseDown, TextEditor> |
||||
{ |
||||
protected override void StopListening(TextEditor source) |
||||
{ |
||||
source.MouseDown -= DeliverEvent; |
||||
} |
||||
|
||||
protected override void StartListening(TextEditor source) |
||||
{ |
||||
source.MouseDown += DeliverEvent; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,292 @@
@@ -0,0 +1,292 @@
|
||||
// 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.Generic; |
||||
using System.ComponentModel.Composition; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using System.Windows.Media; |
||||
using System.Windows.Threading; |
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.AvalonEdit.Document; |
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
using ICSharpCode.ILSpy.Bookmarks; |
||||
|
||||
namespace ICSharpCode.ILSpy.AvalonEdit |
||||
{ |
||||
/// <summary>
|
||||
/// Handles the text markers for a code editor.
|
||||
/// </summary>
|
||||
public sealed class TextMarkerService : DocumentColorizingTransformer, IBackgroundRenderer, ITextMarkerService |
||||
{ |
||||
TextEditor codeEditor; |
||||
|
||||
TextSegmentCollection<TextMarker> markers = new TextSegmentCollection<TextMarker>(); |
||||
|
||||
public TextMarkerService() |
||||
{ |
||||
} |
||||
|
||||
public TextEditor CodeEditor { |
||||
get { return codeEditor; } |
||||
set { codeEditor = value; } |
||||
} |
||||
|
||||
#region ITextMarkerService
|
||||
public ITextMarker Create(int startOffset, int length) |
||||
{ |
||||
int textLength = codeEditor.TextArea.TextView.Document.TextLength; |
||||
if (startOffset < 0 || startOffset > textLength) |
||||
throw new ArgumentOutOfRangeException("startOffset", startOffset, "Value must be between 0 and " + textLength); |
||||
if (length < 0 || startOffset + length > textLength) |
||||
throw new ArgumentOutOfRangeException("length", length, "length must not be negative and startOffset+length must not be after the end of the document"); |
||||
|
||||
TextMarker m = new TextMarker(this, startOffset, length); |
||||
markers.Add(m); |
||||
// no need to mark segment for redraw: the text marker is invisible until a property is set
|
||||
return m; |
||||
} |
||||
|
||||
public IEnumerable<ITextMarker> GetMarkersAtOffset(int offset) |
||||
{ |
||||
return markers.FindSegmentsContaining(offset); |
||||
} |
||||
|
||||
public IEnumerable<ITextMarker> TextMarkers { |
||||
get { return markers; } |
||||
} |
||||
|
||||
public void RemoveAll(Predicate<ITextMarker> predicate) |
||||
{ |
||||
if (predicate == null) |
||||
throw new ArgumentNullException("predicate"); |
||||
foreach (TextMarker m in markers.ToArray()) { |
||||
if (predicate(m)) |
||||
Remove(m); |
||||
} |
||||
} |
||||
|
||||
public void Remove(ITextMarker marker) |
||||
{ |
||||
if (marker == null) |
||||
return; |
||||
|
||||
TextMarker m = marker as TextMarker; |
||||
if (markers.Remove(m)) { |
||||
Redraw(m); |
||||
m.OnDeleted(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Redraws the specified text segment.
|
||||
/// </summary>
|
||||
public void Redraw(ISegment segment) |
||||
{ |
||||
codeEditor.TextArea.TextView.Redraw(segment, DispatcherPriority.Normal); |
||||
} |
||||
#endregion
|
||||
|
||||
#region DocumentColorizingTransformer
|
||||
protected override void ColorizeLine(DocumentLine line) |
||||
{ |
||||
if (markers == null) |
||||
return; |
||||
int lineStart = line.Offset; |
||||
int lineEnd = lineStart + line.Length; |
||||
foreach (TextMarker marker in markers.FindOverlappingSegments(lineStart, line.Length).Reverse()) { |
||||
if (!marker.IsVisible(marker.Bookmark)) |
||||
continue; |
||||
|
||||
Brush foregroundBrush = null; |
||||
if (marker.ForegroundColor != null) { |
||||
foregroundBrush = new SolidColorBrush(marker.ForegroundColor.Value); |
||||
foregroundBrush.Freeze(); |
||||
} |
||||
ChangeLinePart( |
||||
Math.Max(marker.StartOffset, lineStart), |
||||
Math.Min(marker.EndOffset, lineEnd), |
||||
element => { |
||||
if (foregroundBrush != null) { |
||||
element.TextRunProperties.SetForegroundBrush(foregroundBrush); |
||||
} |
||||
} |
||||
); |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region IBackgroundRenderer
|
||||
public KnownLayer Layer { |
||||
get { |
||||
// draw behind selection
|
||||
return KnownLayer.Selection; |
||||
} |
||||
} |
||||
|
||||
public void Draw(ICSharpCode.AvalonEdit.Rendering.TextView textView, DrawingContext drawingContext) |
||||
{ |
||||
if (textView == null) |
||||
throw new ArgumentNullException("textView"); |
||||
if (drawingContext == null) |
||||
throw new ArgumentNullException("drawingContext"); |
||||
if (markers == null || !textView.VisualLinesValid) |
||||
return; |
||||
var visualLines = textView.VisualLines; |
||||
if (visualLines.Count == 0) |
||||
return; |
||||
int viewStart = visualLines.First().FirstDocumentLine.Offset; |
||||
int viewEnd = visualLines.Last().LastDocumentLine.Offset + visualLines.Last().LastDocumentLine.Length; |
||||
foreach (TextMarker marker in markers.FindOverlappingSegments(viewStart, viewEnd - viewStart).Reverse()) { |
||||
if (!marker.IsVisible(marker.Bookmark)) |
||||
continue; |
||||
|
||||
if (marker.BackgroundColor != null) { |
||||
BackgroundGeometryBuilder geoBuilder = new BackgroundGeometryBuilder(); |
||||
geoBuilder.AlignToWholePixels = true; |
||||
geoBuilder.CornerRadius = 3; |
||||
geoBuilder.AddSegment(textView, marker); |
||||
Geometry geometry = geoBuilder.CreateGeometry(); |
||||
if (geometry != null) { |
||||
Color color = marker.BackgroundColor.Value; |
||||
SolidColorBrush brush = new SolidColorBrush(color); |
||||
brush.Freeze(); |
||||
drawingContext.DrawGeometry(brush, null, geometry); |
||||
} |
||||
} |
||||
if (marker.MarkerType != TextMarkerType.None) { |
||||
foreach (Rect r in BackgroundGeometryBuilder.GetRectsForSegment(textView, marker)) { |
||||
Point startPoint = r.BottomLeft; |
||||
Point endPoint = r.BottomRight; |
||||
|
||||
Pen usedPen = new Pen(new SolidColorBrush(marker.MarkerColor), 1); |
||||
usedPen.Freeze(); |
||||
switch (marker.MarkerType) { |
||||
case TextMarkerType.SquigglyUnderline: |
||||
double offset = 2.5; |
||||
|
||||
int count = Math.Max((int)((endPoint.X - startPoint.X) / offset) + 1, 4); |
||||
|
||||
StreamGeometry geometry = new StreamGeometry(); |
||||
|
||||
using (StreamGeometryContext ctx = geometry.Open()) { |
||||
ctx.BeginFigure(startPoint, false, false); |
||||
ctx.PolyLineTo(CreatePoints(startPoint, endPoint, offset, count).ToArray(), true, false); |
||||
} |
||||
|
||||
geometry.Freeze(); |
||||
|
||||
drawingContext.DrawGeometry(Brushes.Transparent, usedPen, geometry); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
IEnumerable<Point> CreatePoints(Point start, Point end, double offset, int count) |
||||
{ |
||||
for (int i = 0; i < count; i++) |
||||
yield return new Point(start.X + i * offset, start.Y - ((i + 1) % 2 == 0 ? offset : 0)); |
||||
} |
||||
#endregion
|
||||
} |
||||
|
||||
sealed class TextMarker : TextSegment, ITextMarker |
||||
{ |
||||
readonly TextMarkerService service; |
||||
|
||||
public TextMarker(TextMarkerService service, int startOffset, int length) |
||||
{ |
||||
if (service == null) |
||||
throw new ArgumentNullException("service"); |
||||
this.service = service; |
||||
this.StartOffset = startOffset; |
||||
this.Length = length; |
||||
this.markerType = TextMarkerType.None; |
||||
} |
||||
|
||||
public event EventHandler Deleted; |
||||
|
||||
public bool IsDeleted { |
||||
get { return !this.IsConnectedToCollection; } |
||||
} |
||||
|
||||
public void Delete() |
||||
{ |
||||
service.Remove(this); |
||||
} |
||||
|
||||
internal void OnDeleted() |
||||
{ |
||||
if (Deleted != null) |
||||
Deleted(this, EventArgs.Empty); |
||||
} |
||||
|
||||
void Redraw() |
||||
{ |
||||
service.Redraw(this); |
||||
} |
||||
|
||||
Color? backgroundColor; |
||||
|
||||
public Color? BackgroundColor { |
||||
get { return backgroundColor; } |
||||
set { |
||||
if (backgroundColor != value) { |
||||
backgroundColor = value; |
||||
Redraw(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
Color? foregroundColor; |
||||
|
||||
public Color? ForegroundColor { |
||||
get { return foregroundColor; } |
||||
set { |
||||
if (foregroundColor != value) { |
||||
foregroundColor = value; |
||||
Redraw(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public object Tag { get; set; } |
||||
|
||||
TextMarkerType markerType; |
||||
|
||||
public TextMarkerType MarkerType { |
||||
get { return markerType; } |
||||
set { |
||||
if (markerType != value) { |
||||
markerType = value; |
||||
Redraw(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
Color markerColor; |
||||
|
||||
public Color MarkerColor { |
||||
get { return markerColor; } |
||||
set { |
||||
if (markerColor != value) { |
||||
markerColor = value; |
||||
Redraw(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
/// <inheritdoc/>
|
||||
public object ToolTip { get; set; } |
||||
|
||||
/// <inheritdoc/>
|
||||
public Predicate<object> IsVisible { get; set; } |
||||
|
||||
/// <inheritdoc/>
|
||||
public IBookmark Bookmark { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,97 @@
@@ -0,0 +1,97 @@
|
||||
// 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.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// A bookmark that can be attached to an AvalonEdit TextDocument.
|
||||
/// </summary>
|
||||
public class BookmarkBase : IBookmark |
||||
{ |
||||
AstLocation location; |
||||
|
||||
protected virtual void RemoveMark() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public AstLocation Location { |
||||
get { return location; } |
||||
set { location = value; } |
||||
} |
||||
|
||||
public event EventHandler DocumentChanged; |
||||
|
||||
protected virtual void OnDocumentChanged(EventArgs e) |
||||
{ |
||||
if (DocumentChanged != null) { |
||||
DocumentChanged(this, e); |
||||
} |
||||
} |
||||
|
||||
protected virtual void Redraw() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public MemberReference MemberReference { get; set; } |
||||
|
||||
public int LineNumber { |
||||
get { return location.Line; } |
||||
} |
||||
|
||||
public int ColumnNumber { |
||||
get { return location.Column; } |
||||
} |
||||
|
||||
public virtual int ZOrder { |
||||
get { return 0; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets if the bookmark can be toggled off using the 'set/unset bookmark' command.
|
||||
/// </summary>
|
||||
public virtual bool CanToggle { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public BookmarkBase(MemberReference member, AstLocation location) |
||||
{ |
||||
this.MemberReference = member; |
||||
this.Location = location; |
||||
} |
||||
|
||||
public virtual ImageSource Image { |
||||
get { return null; } |
||||
} |
||||
|
||||
public virtual void MouseDown(MouseButtonEventArgs e) |
||||
{ |
||||
} |
||||
|
||||
public virtual void MouseUp(MouseButtonEventArgs e) |
||||
{ |
||||
if (e.ChangedButton == MouseButton.Left && CanToggle) { |
||||
RemoveMark(); |
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
public virtual bool CanDragDrop { |
||||
get { return false; } |
||||
} |
||||
|
||||
public virtual void Drop(int lineNumber) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
public delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// Description of BookmarkEventHandler.
|
||||
/// </summary>
|
||||
public class BookmarkEventArgs : EventArgs |
||||
{ |
||||
BookmarkBase bookmark; |
||||
|
||||
public BookmarkBase Bookmark { |
||||
get { |
||||
return bookmark; |
||||
} |
||||
} |
||||
|
||||
public BookmarkEventArgs(BookmarkBase bookmark) |
||||
{ |
||||
this.bookmark = bookmark; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,116 @@
@@ -0,0 +1,116 @@
|
||||
// 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.Generic; |
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using Mono.Cecil; |
||||
using Mono.CSharp; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// Static class that maintains the list of bookmarks and breakpoints.
|
||||
/// </summary>
|
||||
public static partial class BookmarkManager |
||||
{ |
||||
static List<BookmarkBase> bookmarks = new List<BookmarkBase>(); |
||||
|
||||
public static List<BookmarkBase> Bookmarks { |
||||
get { |
||||
return bookmarks; |
||||
} |
||||
} |
||||
|
||||
public static List<BookmarkBase> GetBookmarks(string typeName) |
||||
{ |
||||
if (typeName == null) |
||||
throw new ArgumentNullException("typeName"); |
||||
|
||||
List<BookmarkBase> marks = new List<BookmarkBase>(); |
||||
|
||||
foreach (BookmarkBase mark in bookmarks) { |
||||
if (typeName == mark.MemberReference.FullName) { |
||||
marks.Add(mark); |
||||
} |
||||
} |
||||
|
||||
return marks; |
||||
} |
||||
|
||||
public static void AddMark(BookmarkBase bookmark) |
||||
{ |
||||
if (bookmark == null) return; |
||||
if (bookmarks.Contains(bookmark)) return; |
||||
if (bookmarks.Exists(b => IsEqualBookmark(b, bookmark))) return; |
||||
bookmarks.Add(bookmark); |
||||
OnAdded(new BookmarkEventArgs(bookmark)); |
||||
} |
||||
|
||||
static bool IsEqualBookmark(BookmarkBase a, BookmarkBase b) |
||||
{ |
||||
if (a == b) |
||||
return true; |
||||
if (a == null || b == null) |
||||
return false; |
||||
if (a.GetType() != b.GetType()) |
||||
return false; |
||||
if (a.MemberReference.FullName != b.MemberReference.FullName) |
||||
return false; |
||||
return a.LineNumber == b.LineNumber; |
||||
} |
||||
|
||||
public static void RemoveMark(BookmarkBase bookmark) |
||||
{ |
||||
bookmarks.Remove(bookmark); |
||||
OnRemoved(new BookmarkEventArgs(bookmark)); |
||||
} |
||||
|
||||
public static void Clear() |
||||
{ |
||||
while (bookmarks.Count > 0) { |
||||
var b = bookmarks[bookmarks.Count - 1]; |
||||
bookmarks.RemoveAt(bookmarks.Count - 1); |
||||
OnRemoved(new BookmarkEventArgs(b)); |
||||
} |
||||
} |
||||
|
||||
internal static void Initialize() |
||||
{ |
||||
|
||||
} |
||||
|
||||
static void OnRemoved(BookmarkEventArgs e) |
||||
{ |
||||
if (Removed != null) { |
||||
Removed(null, e); |
||||
} |
||||
} |
||||
|
||||
static void OnAdded(BookmarkEventArgs e) |
||||
{ |
||||
if (Added != null) { |
||||
Added(null, e); |
||||
} |
||||
} |
||||
|
||||
public static void ToggleBookmark(string typeName, int line, |
||||
Predicate<BookmarkBase> canToggle, |
||||
Func<AstLocation, BookmarkBase> bookmarkFactory) |
||||
{ |
||||
foreach (BookmarkBase bookmark in GetBookmarks(typeName)) { |
||||
if (canToggle(bookmark) && bookmark.LineNumber == line) { |
||||
BookmarkManager.RemoveMark(bookmark); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
// no bookmark at that line: create a new bookmark
|
||||
BookmarkManager.AddMark(bookmarkFactory(new AstLocation(line, 0))); |
||||
} |
||||
|
||||
public static event BookmarkEventHandler Removed; |
||||
public static event BookmarkEventHandler Added; |
||||
} |
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using ICSharpCode.ILSpy.AvalonEdit; |
||||
using ICSharpCode.ILSpy.TreeNodes.Analyzer; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
[ExportBookmarkContextMenuEntry(Header = "Analyze", Icon = "images/Search.png", Category="Default")] |
||||
internal sealed class AnalyzeBookmarkEntry : IBookmarkContextMenuEntry |
||||
{ |
||||
public bool IsVisible(IBookmark[] marks) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public bool IsEnabled(IBookmark[] marks) |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
public void Execute(IBookmark[] marks) |
||||
{ |
||||
foreach (var mark in marks) { |
||||
if (!(mark is MemberBookmark)) |
||||
continue; |
||||
|
||||
var member = (mark as MemberBookmark).Node.Annotation<MemberReference>(); |
||||
AnalyzeContextMenuEntry.Analyze(member); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// 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.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Collections.Specialized; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// The bookmark margin.
|
||||
/// </summary>
|
||||
public interface IBookmarkMargin |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the list of bookmarks.
|
||||
/// </summary>
|
||||
IList<IBookmark> Bookmarks { get; } |
||||
|
||||
/// <summary>
|
||||
/// Redraws the bookmark margin. Bookmarks need to call this method when the Image changes.
|
||||
/// </summary>
|
||||
void Redraw(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents a bookmark in the bookmark margin.
|
||||
/// </summary>
|
||||
public interface IBookmark |
||||
{ |
||||
/// <summary>
|
||||
/// Gets the line number of the bookmark.
|
||||
/// </summary>
|
||||
int LineNumber { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the image.
|
||||
/// </summary>
|
||||
ImageSource Image { get; } |
||||
|
||||
/// <summary>
|
||||
/// Gets the Z-Order of the bookmark icon.
|
||||
/// </summary>
|
||||
int ZOrder { get; } |
||||
|
||||
/// <summary>
|
||||
/// Handles the mouse down event.
|
||||
/// </summary>
|
||||
void MouseDown(MouseButtonEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// Handles the mouse up event.
|
||||
/// </summary>
|
||||
void MouseUp(MouseButtonEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// Gets whether this bookmark can be dragged around.
|
||||
/// </summary>
|
||||
bool CanDragDrop { get; } |
||||
|
||||
/// <summary>
|
||||
/// Notifies the bookmark that it was dropped on the specified line.
|
||||
/// </summary>
|
||||
void Drop(int lineNumber); |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
// 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 ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.ILSpy.AvalonEdit; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
public abstract class MarkerBookmark : BookmarkBase |
||||
{ |
||||
public MarkerBookmark(MemberReference member, AstLocation location) : base(member, location) |
||||
{ |
||||
} |
||||
|
||||
public ITextMarker Marker { get; set; } |
||||
|
||||
public abstract ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length); |
||||
} |
||||
} |
||||
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
// 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.Windows; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.NRefactory.CSharp; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.Bookmarks |
||||
{ |
||||
/// <summary>
|
||||
/// Bookmark used to give additional operations for class members.
|
||||
/// Does not derive from SDBookmark because it is not stored in the central BookmarkManager,
|
||||
/// but only in the document's BookmarkManager.
|
||||
/// </summary>
|
||||
public class MemberBookmark : IBookmark |
||||
{ |
||||
AstNode node; |
||||
|
||||
public AstNode Node { |
||||
get { |
||||
return node; |
||||
} |
||||
} |
||||
|
||||
public MemberBookmark(AstNode node) |
||||
{ |
||||
this.node = node; |
||||
} |
||||
|
||||
public virtual ImageSource Image { |
||||
get { |
||||
var attrNode = (AttributedNode)node; |
||||
if (node is EnumMemberDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.EnumValue); |
||||
|
||||
if (node is FieldDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Field); |
||||
|
||||
if (node is PropertyDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Property); |
||||
|
||||
if (node is EventDeclaration || node is CustomEventDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Event); |
||||
|
||||
if (node is IndexerDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Indexer); |
||||
|
||||
if (node is OperatorDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Operator); |
||||
|
||||
if (node is ConstructorDeclaration || node is DestructorDeclaration) |
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Constructor); |
||||
|
||||
return GetMemberOverlayedImage(attrNode, MemberIcon.Method); |
||||
} |
||||
} |
||||
|
||||
ImageSource GetMemberOverlayedImage(AttributedNode attrNode, MemberIcon icon) |
||||
{ |
||||
switch (attrNode.Modifiers & Modifiers.VisibilityMask) { |
||||
case Modifiers.Protected: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Protected, (attrNode.Modifiers & Modifiers.Static) == Modifiers.Static); |
||||
case Modifiers.Private: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Private, (attrNode.Modifiers & Modifiers.Static) == Modifiers.Static); |
||||
case Modifiers.Internal: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Internal, (attrNode.Modifiers & Modifiers.Static) == Modifiers.Static); |
||||
} |
||||
|
||||
return Images.GetIcon(icon, AccessOverlayIcon.Public, (attrNode.Modifiers & Modifiers.Static) == Modifiers.Static); |
||||
} |
||||
|
||||
public int LineNumber { |
||||
get { |
||||
var t = node.Annotation<Tuple<int, int>>(); |
||||
if (t != null) |
||||
return t.Item1; |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public virtual void MouseDown(MouseButtonEventArgs e) |
||||
{ |
||||
} |
||||
|
||||
public virtual void MouseUp(MouseButtonEventArgs e) |
||||
{ |
||||
} |
||||
|
||||
int IBookmark.ZOrder { |
||||
get { return -10; } |
||||
} |
||||
|
||||
bool IBookmark.CanDragDrop { |
||||
get { return false; } |
||||
} |
||||
|
||||
void IBookmark.Drop(int lineNumber) |
||||
{ |
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
|
||||
public class TypeBookmark : MemberBookmark |
||||
{ |
||||
public TypeBookmark(AstNode node) : base (node) |
||||
{ |
||||
} |
||||
|
||||
public override ImageSource Image { |
||||
get { |
||||
var attrNode = (AttributedNode)Node; |
||||
|
||||
if (Node is DelegateDeclaration) |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Delegate); |
||||
|
||||
if (Node is TypeDeclaration) { |
||||
var n = Node as TypeDeclaration; |
||||
switch (n.ClassType) |
||||
{ |
||||
case ClassType.Delegate: |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Delegate); |
||||
case ClassType.Enum: |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Enum); |
||||
case ClassType.Struct: |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Struct); |
||||
case ClassType.Interface: |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Interface); |
||||
} |
||||
} |
||||
|
||||
if ((attrNode.Modifiers & Modifiers.Static) == Modifiers.Static) |
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.StaticClass); |
||||
|
||||
return GetTypeOverlayedImage(attrNode, TypeIcon.Class); |
||||
} |
||||
} |
||||
|
||||
ImageSource GetTypeOverlayedImage(AttributedNode attrNode, TypeIcon icon) |
||||
{ |
||||
switch (attrNode.Modifiers & Modifiers.VisibilityMask) { |
||||
case Modifiers.Protected: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Protected); |
||||
case Modifiers.Private: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Private); |
||||
case Modifiers.Internal: |
||||
return Images.GetIcon(icon, AccessOverlayIcon.Internal); |
||||
} |
||||
|
||||
return Images.GetIcon(icon, AccessOverlayIcon.Public); |
||||
} |
||||
} |
||||
} |
||||
@ -1,178 +0,0 @@
@@ -1,178 +0,0 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.ComponentModel.Composition; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
using ICSharpCode.ILSpy.TreeNodes; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "E_xit", MenuOrder = 99999, MenuCategory = "Exit")] |
||||
sealed class ExitCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.Close(); |
||||
} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Back", ToolbarIcon = "Images/Back.png", ToolbarCategory = "Navigation", ToolbarOrder = 0)] |
||||
sealed class BrowseBackCommand : CommandWrapper { |
||||
public BrowseBackCommand() : base(NavigationCommands.BrowseBack) {} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Forward", ToolbarIcon = "Images/Forward.png", ToolbarCategory = "Navigation", ToolbarOrder = 1)] |
||||
sealed class BrowseForwardCommand : CommandWrapper { |
||||
public BrowseForwardCommand() : base(NavigationCommands.BrowseForward) {} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Open", ToolbarIcon = "Images/Open.png", ToolbarCategory = "Open", ToolbarOrder = 0)] |
||||
[ExportMainMenuCommand(Menu = "_File", MenuIcon = "Images/Open.png", MenuCategory = "Open", MenuOrder = 0)] |
||||
sealed class OpenCommand : CommandWrapper { |
||||
public OpenCommand() : base(ApplicationCommands.Open) {} |
||||
} |
||||
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Open from _GAC", MenuCategory = "Open", MenuOrder = 1)] |
||||
sealed class OpenFromGacCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
OpenFromGacDialog dlg = new OpenFromGacDialog(); |
||||
dlg.Owner = MainWindow.Instance; |
||||
if (dlg.ShowDialog() == true) { |
||||
MainWindow.Instance.OpenFiles(dlg.SelectedFileNames); |
||||
} |
||||
} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Reload all assemblies", ToolbarIcon = "Images/Refresh.png", ToolbarCategory = "Open", ToolbarOrder = 2)] |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Reload", MenuIcon = "Images/Refresh.png", MenuCategory = "Open", MenuOrder = 2)] |
||||
sealed class RefreshCommand : CommandWrapper { |
||||
public RefreshCommand() : base(NavigationCommands.Refresh) {} |
||||
} |
||||
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "_Save Code...", MenuIcon = "Images/SaveFile.png", MenuCategory = "Save", MenuOrder = 0)] |
||||
sealed class SaveCommand : CommandWrapper |
||||
{ |
||||
public SaveCommand() : base(ApplicationCommands.Save) {} |
||||
} |
||||
|
||||
#if DEBUG
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "DEBUG -- Decompile All", MenuCategory = "Open", MenuOrder = 2.5)] |
||||
sealed class DecompileAllCommand : SimpleCommand |
||||
{ |
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
return System.IO.Directory.Exists("c:\\temp\\decompiled"); |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.TextView.RunWithCancellation( |
||||
ct => Task<AvalonEditTextOutput>.Factory.StartNew( |
||||
() => { |
||||
AvalonEditTextOutput output = new AvalonEditTextOutput(); |
||||
Parallel.ForEach( |
||||
MainWindow.Instance.CurrentAssemblyList.GetAssemblies(), |
||||
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = ct }, |
||||
delegate (LoadedAssembly asm) { |
||||
if (!asm.HasLoadError) { |
||||
Stopwatch w = Stopwatch.StartNew(); |
||||
Exception exception = null; |
||||
using (var writer = new System.IO.StreamWriter("c:\\temp\\decompiled\\" + asm.ShortName + ".cs")) { |
||||
try { |
||||
new CSharpLanguage().DecompileAssembly( |
||||
asm, new Decompiler.PlainTextOutput(writer), |
||||
new DecompilationOptions { FullDecompilation = true, CancellationToken = ct }); |
||||
} catch (Exception ex) { |
||||
writer.WriteLine(ex.ToString()); |
||||
exception = ex; |
||||
} |
||||
} |
||||
lock (output) { |
||||
output.Write(asm.ShortName + " - " + w.Elapsed); |
||||
if (exception != null) { |
||||
output.Write(" - "); |
||||
output.Write(exception.GetType().Name); |
||||
} |
||||
output.WriteLine(); |
||||
} |
||||
} |
||||
}); |
||||
return output; |
||||
} |
||||
), |
||||
task => MainWindow.Instance.TextView.ShowText(task.Result)); |
||||
} |
||||
} |
||||
#endif
|
||||
|
||||
class CommandWrapper : ICommand |
||||
{ |
||||
ICommand wrappedCommand; |
||||
|
||||
public CommandWrapper(ICommand wrappedCommand) |
||||
{ |
||||
this.wrappedCommand = wrappedCommand; |
||||
} |
||||
|
||||
public static ICommand Unwrap(ICommand command) |
||||
{ |
||||
CommandWrapper w = command as CommandWrapper; |
||||
if (w != null) |
||||
return w.wrappedCommand; |
||||
else |
||||
return command; |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged { |
||||
add { wrappedCommand.CanExecuteChanged += value; } |
||||
remove { wrappedCommand.CanExecuteChanged -= value; } |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
wrappedCommand.Execute(parameter); |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
return wrappedCommand.CanExecute(parameter); |
||||
} |
||||
} |
||||
|
||||
public abstract class SimpleCommand : ICommand |
||||
{ |
||||
public event EventHandler CanExecuteChanged { |
||||
add { CommandManager.RequerySuggested += value; } |
||||
remove { CommandManager.RequerySuggested -= value; } |
||||
} |
||||
|
||||
public abstract void Execute(object parameter); |
||||
|
||||
public virtual bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Back", ToolbarIcon = "Images/Back.png", ToolbarCategory = "Navigation", ToolbarOrder = 0)] |
||||
sealed class BrowseBackCommand : CommandWrapper |
||||
{ |
||||
public BrowseBackCommand() |
||||
: base(NavigationCommands.BrowseBack) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Forward", ToolbarIcon = "Images/Forward.png", ToolbarCategory = "Navigation", ToolbarOrder = 1)] |
||||
sealed class BrowseForwardCommand : CommandWrapper |
||||
{ |
||||
public BrowseForwardCommand() |
||||
: base(NavigationCommands.BrowseForward) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
class CommandWrapper : ICommand |
||||
{ |
||||
private ICommand wrappedCommand; |
||||
|
||||
public CommandWrapper(ICommand wrappedCommand) |
||||
{ |
||||
this.wrappedCommand = wrappedCommand; |
||||
} |
||||
|
||||
public static ICommand Unwrap(ICommand command) |
||||
{ |
||||
CommandWrapper w = command as CommandWrapper; |
||||
if (w != null) |
||||
return w.wrappedCommand; |
||||
else |
||||
return command; |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged |
||||
{ |
||||
add { wrappedCommand.CanExecuteChanged += value; } |
||||
remove { wrappedCommand.CanExecuteChanged -= value; } |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
wrappedCommand.Execute(parameter); |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
return wrappedCommand.CanExecute(parameter); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#if DEBUG
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Threading.Tasks; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "DEBUG -- Decompile All", MenuCategory = "Open", MenuOrder = 2.5)] |
||||
sealed class DecompileAllCommand : SimpleCommand |
||||
{ |
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
return System.IO.Directory.Exists("c:\\temp\\decompiled"); |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.TextView.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => { |
||||
AvalonEditTextOutput output = new AvalonEditTextOutput(); |
||||
Parallel.ForEach(MainWindow.Instance.CurrentAssemblyList.GetAssemblies(), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = ct }, delegate(LoadedAssembly asm) { |
||||
if (!asm.HasLoadError) { |
||||
Stopwatch w = Stopwatch.StartNew(); |
||||
Exception exception = null; |
||||
using (var writer = new System.IO.StreamWriter("c:\\temp\\decompiled\\" + asm.ShortName + ".cs")) { |
||||
try { |
||||
new CSharpLanguage().DecompileAssembly(asm, new Decompiler.PlainTextOutput(writer), new DecompilationOptions { FullDecompilation = true, CancellationToken = ct }); |
||||
} |
||||
catch (Exception ex) { |
||||
writer.WriteLine(ex.ToString()); |
||||
exception = ex; |
||||
} |
||||
} |
||||
lock (output) { |
||||
output.Write(asm.ShortName + " - " + w.Elapsed); |
||||
if (exception != null) { |
||||
output.Write(" - "); |
||||
output.Write(exception.GetType().Name); |
||||
} |
||||
output.WriteLine(); |
||||
} |
||||
} |
||||
}); |
||||
return output; |
||||
}), task => MainWindow.Instance.TextView.ShowText(task.Result)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endif
|
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "E_xit", MenuOrder = 99999, MenuCategory = "Exit")] |
||||
sealed class ExitCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.Close(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Open", ToolbarIcon = "Images/Open.png", ToolbarCategory = "Open", ToolbarOrder = 0)] |
||||
[ExportMainMenuCommand(Menu = "_File", MenuIcon = "Images/Open.png", MenuCategory = "Open", MenuOrder = 0)] |
||||
sealed class OpenCommand : CommandWrapper |
||||
{ |
||||
public OpenCommand() |
||||
: base(ApplicationCommands.Open) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Open from _GAC", MenuCategory = "Open", MenuOrder = 1)] |
||||
sealed class OpenFromGacCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
OpenFromGacDialog dlg = new OpenFromGacDialog(); |
||||
dlg.Owner = MainWindow.Instance; |
||||
if (dlg.ShowDialog() == true) |
||||
MainWindow.Instance.OpenFiles(dlg.SelectedFileNames); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Reload all assemblies", ToolbarIcon = "Images/Refresh.png", ToolbarCategory = "Open", ToolbarOrder = 2)] |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Reload", MenuIcon = "Images/Refresh.png", MenuCategory = "Open", MenuOrder = 2)] |
||||
sealed class RefreshCommand : CommandWrapper |
||||
{ |
||||
public RefreshCommand() |
||||
: base(NavigationCommands.Refresh) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "_Save Code...", MenuIcon = "Images/SaveFile.png", MenuCategory = "Save", MenuOrder = 0)] |
||||
sealed class SaveCommand : CommandWrapper |
||||
{ |
||||
public SaveCommand() |
||||
: base(ApplicationCommands.Save) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_View", Header = "_Analyzer", MenuCategory = "ShowPane", MenuOrder = 100)] |
||||
sealed class ShowAnalyzerCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
AnalyzerTreeView.Instance.Show(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public abstract class SimpleCommand : ICommand |
||||
{ |
||||
public event EventHandler CanExecuteChanged |
||||
{ |
||||
add { CommandManager.RequerySuggested += value; } |
||||
remove { CommandManager.RequerySuggested -= value; } |
||||
} |
||||
|
||||
public abstract void Execute(object parameter); |
||||
|
||||
public virtual bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public interface IPane |
||||
{ |
||||
void Closed(); |
||||
} |
||||
} |
||||
|
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
|
After Width: | Height: | Size: 465 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel.Composition.Hosting; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public static class Languages |
||||
{ |
||||
private static ReadOnlyCollection<Language> allLanguages; |
||||
|
||||
/// <summary>
|
||||
/// A list of all languages.
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<Language> AllLanguages |
||||
{ |
||||
get { return allLanguages; } |
||||
} |
||||
|
||||
internal static void Initialize(CompositionContainer composition) |
||||
{ |
||||
List<Language> languages = new List<Language>(); |
||||
languages.AddRange(composition.GetExportedValues<Language>()); |
||||
languages.Add(new ILLanguage(true)); |
||||
#if DEBUG
|
||||
languages.AddRange(ILAstLanguage.GetDebugLanguages()); |
||||
languages.AddRange(CSharpLanguage.GetDebugLanguages()); |
||||
#endif
|
||||
allLanguages = languages.AsReadOnly(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a language using its name.
|
||||
/// If the language is not found, C# is returned instead.
|
||||
/// </summary>
|
||||
public static Language GetLanguage(string name) |
||||
{ |
||||
return AllLanguages.FirstOrDefault(l => l.Name == name) ?? AllLanguages.First(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.TreeView; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
sealed class BaseTypesEntryNode : ILSpyTreeNode, IMemberTreeNode |
||||
{ |
||||
private TypeReference tr; |
||||
private TypeDefinition def; |
||||
private bool isInterface; |
||||
|
||||
public BaseTypesEntryNode(TypeReference tr, bool isInterface) |
||||
{ |
||||
if (tr == null) |
||||
throw new ArgumentNullException("tr"); |
||||
this.tr = tr; |
||||
this.def = tr.Resolve(); |
||||
this.isInterface = isInterface; |
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override bool ShowExpander |
||||
{ |
||||
get { return def != null && (def.BaseType != null || def.HasInterfaces); } |
||||
} |
||||
|
||||
public override object Text |
||||
{ |
||||
get { return this.Language.TypeToString(tr, true); } |
||||
} |
||||
|
||||
public override object Icon |
||||
{ |
||||
get |
||||
{ |
||||
if (def != null) |
||||
return TypeTreeNode.GetIcon(def); |
||||
else |
||||
return isInterface ? Images.Interface : Images.Class; |
||||
} |
||||
} |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
if (def != null) |
||||
BaseTypesTreeNode.AddBaseTypes(this.Children, def); |
||||
} |
||||
|
||||
public override void ActivateItem(System.Windows.RoutedEventArgs e) |
||||
{ |
||||
// on item activation, try to resolve once again (maybe the user loaded the assembly in the meantime)
|
||||
if (def == null) { |
||||
def = tr.Resolve(); |
||||
if (def != null) |
||||
this.LazyLoading = true; |
||||
// re-load children
|
||||
} |
||||
e.Handled = ActivateItem(this, def); |
||||
} |
||||
|
||||
internal static bool ActivateItem(SharpTreeNode node, TypeDefinition def) |
||||
{ |
||||
if (def != null) { |
||||
var assemblyListNode = node.Ancestors().OfType<AssemblyListTreeNode>().FirstOrDefault(); |
||||
if (assemblyListNode != null) { |
||||
assemblyListNode.Select(assemblyListNode.FindTypeNode(def)); |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, language.TypeToString(tr, true)); |
||||
} |
||||
|
||||
MemberReference IMemberTreeNode.Member |
||||
{ |
||||
get { return tr; } |
||||
} |
||||
} |
||||
} |
||||