diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj
index d0a039257..de0643562 100644
--- a/ILSpy/ILSpy.csproj
+++ b/ILSpy/ILSpy.csproj
@@ -110,6 +110,9 @@
+
+
+
@@ -201,25 +204,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -238,6 +226,14 @@
+
+
+
+
+
+
+
+
@@ -261,6 +257,5 @@
ICSharpCode.TreeView
-
\ No newline at end of file
diff --git a/ILSpy/Images/Class.png b/ILSpy/Images/Class.png
index a8d001cba..762c9f217 100644
Binary files a/ILSpy/Images/Class.png and b/ILSpy/Images/Class.png differ
diff --git a/ILSpy/Images/Constructor.png b/ILSpy/Images/Constructor.png
new file mode 100644
index 000000000..0d60fe517
Binary files /dev/null and b/ILSpy/Images/Constructor.png differ
diff --git a/ILSpy/Images/Delegate.png b/ILSpy/Images/Delegate.png
index 05707079d..84339edea 100644
Binary files a/ILSpy/Images/Delegate.png and b/ILSpy/Images/Delegate.png differ
diff --git a/ILSpy/Images/Enum.png b/ILSpy/Images/Enum.png
index 3fbb2c149..28e989f0f 100644
Binary files a/ILSpy/Images/Enum.png and b/ILSpy/Images/Enum.png differ
diff --git a/ILSpy/Images/EnumValue.png b/ILSpy/Images/EnumValue.png
new file mode 100644
index 000000000..5affdbf99
Binary files /dev/null and b/ILSpy/Images/EnumValue.png differ
diff --git a/ILSpy/Images/Event.png b/ILSpy/Images/Event.png
index aa3204ebc..9ceb80759 100644
Binary files a/ILSpy/Images/Event.png and b/ILSpy/Images/Event.png differ
diff --git a/ILSpy/Images/ExtensionMethod.png b/ILSpy/Images/ExtensionMethod.png
index e76e2fbf3..8545a4d4e 100644
Binary files a/ILSpy/Images/ExtensionMethod.png and b/ILSpy/Images/ExtensionMethod.png differ
diff --git a/ILSpy/Images/Field.png b/ILSpy/Images/Field.png
index 05318b85e..603039740 100644
Binary files a/ILSpy/Images/Field.png and b/ILSpy/Images/Field.png differ
diff --git a/ILSpy/Images/FieldReadOnly.png b/ILSpy/Images/FieldReadOnly.png
new file mode 100644
index 000000000..3f3385220
Binary files /dev/null and b/ILSpy/Images/FieldReadOnly.png differ
diff --git a/ILSpy/Images/Images.cs b/ILSpy/Images/Images.cs
index dfe0f681a..0309cd82e 100644
--- a/ILSpy/Images/Images.cs
+++ b/ILSpy/Images/Images.cs
@@ -3,6 +3,9 @@
using System;
using System.Windows.Media.Imaging;
+using System.Windows.Media;
+using System.Windows;
+using System.Collections.Generic;
namespace ICSharpCode.ILSpy
{
@@ -14,61 +17,58 @@ namespace ICSharpCode.ILSpy
image.Freeze();
return image;
}
-
+
public static readonly BitmapImage ViewCode = LoadBitmap("ViewCode");
public static readonly BitmapImage Save = LoadBitmap("SaveFile");
public static readonly BitmapImage OK = LoadBitmap("OK");
-
+
+ public static readonly BitmapImage Delete = LoadBitmap("Delete");
+ public static readonly BitmapImage Search = LoadBitmap("Search");
+
public static readonly BitmapImage Assembly = LoadBitmap("Assembly");
public static readonly BitmapImage AssemblyWarning = LoadBitmap("AssemblyWarning");
public static readonly BitmapImage AssemblyLoading = LoadBitmap("FindAssembly");
-
+
public static readonly BitmapImage Library = LoadBitmap("Library");
public static readonly BitmapImage Namespace = LoadBitmap("NameSpace");
-
+
public static readonly BitmapImage ReferenceFolderOpen = LoadBitmap("ReferenceFolder.Open");
public static readonly BitmapImage ReferenceFolderClosed = LoadBitmap("ReferenceFolder.Closed");
-
+
public static readonly BitmapImage SubTypes = LoadBitmap("SubTypes");
public static readonly BitmapImage SuperTypes = LoadBitmap("SuperTypes");
-
+
public static readonly BitmapImage Resource = LoadBitmap("Resource");
-
+
public static readonly BitmapImage Class = LoadBitmap("Class");
+ public static readonly BitmapImage Struct = LoadBitmap("Struct");
+ public static readonly BitmapImage Interface = LoadBitmap("Interface");
public static readonly BitmapImage Delegate = LoadBitmap("Delegate");
public static readonly BitmapImage Enum = LoadBitmap("Enum");
- public static readonly BitmapImage Interface = LoadBitmap("Interface");
- public static readonly BitmapImage Struct = LoadBitmap("Struct");
- public static readonly BitmapImage Field = LoadBitmap("Field");
- public static readonly BitmapImage Method = LoadBitmap("Method");
- public static readonly BitmapImage ExtensionMethod = LoadBitmap("ExtensionMethod");
- public static readonly BitmapImage Literal = LoadBitmap("Literal");
- public static readonly BitmapImage Property = LoadBitmap("Property");
- public static readonly BitmapImage Event = LoadBitmap("Event");
- public static readonly BitmapImage Indexer = LoadBitmap("Indexer");
- public static readonly BitmapImage Operator = LoadBitmap("Operator");
-
- public static readonly BitmapImage InternalClass = LoadBitmap("InternalClass");
- public static readonly BitmapImage InternalDelegate = LoadBitmap("InternalDelegate");
- public static readonly BitmapImage InternalEnum = LoadBitmap("InternalEnum");
- public static readonly BitmapImage InternalInterface = LoadBitmap("InternalInterface");
- public static readonly BitmapImage InternalStruct = LoadBitmap("InternalStruct");
-
- public static readonly BitmapImage PrivateClass = LoadBitmap("PrivateClass");
- public static readonly BitmapImage PrivateDelegate = LoadBitmap("PrivateDelegate");
- public static readonly BitmapImage PrivateEnum = LoadBitmap("PrivateEnum");
- public static readonly BitmapImage PrivateInterface = LoadBitmap("PrivateInterface");
- public static readonly BitmapImage PrivateStruct = LoadBitmap("PrivateStruct");
-
- public static readonly BitmapImage ProtectedClass = LoadBitmap("ProtectedClass");
- public static readonly BitmapImage ProtectedDelegate = LoadBitmap("ProtectedDelegate");
- public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum");
- public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface");
- public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct");
-
- public static readonly BitmapImage Delete = LoadBitmap("Delete");
- public static readonly BitmapImage Search = LoadBitmap("Search");
-
+
+
+ private static readonly BitmapImage Field = LoadBitmap("Field");
+ private static readonly BitmapImage FieldReadOnly = LoadBitmap("FieldReadOnly");
+ private static readonly BitmapImage Literal = LoadBitmap("Literal");
+ private static readonly BitmapImage EnumValue = LoadBitmap("EnumValue");
+
+ private static readonly BitmapImage Method = LoadBitmap("Method");
+ private static readonly BitmapImage Constructor = LoadBitmap("Constructor");
+ private static readonly BitmapImage Operator = LoadBitmap("Operator");
+ private static readonly BitmapImage ExtensionMethod = LoadBitmap("ExtensionMethod");
+
+ private static readonly BitmapImage Property = LoadBitmap("Property");
+ private static readonly BitmapImage Indexer = LoadBitmap("Indexer");
+
+ private static readonly BitmapImage Event = LoadBitmap("Event");
+
+ private static readonly BitmapImage OverlayProtected = LoadBitmap("OverlayProtected");
+ private static readonly BitmapImage OverlayInternal = LoadBitmap("OverlayInternal");
+ private static readonly BitmapImage OverlayProtectedInternal = LoadBitmap("OverlayProtectedInternal");
+ private static readonly BitmapImage OverlayPrivate = LoadBitmap("OverlayPrivate");
+
+ private static readonly BitmapImage OverlayStatic = LoadBitmap("OverlayStatic");
+
public static BitmapImage LoadImage(object part, string icon)
{
Uri uri;
@@ -80,5 +80,202 @@ namespace ICSharpCode.ILSpy
image.Freeze();
return image;
}
+
+
+ private static TypeIconCache typeIconCache = new TypeIconCache();
+ private static MemberIconCache memberIconCache = new MemberIconCache();
+
+ public static ImageSource GetIcon(TypeIcon icon, OverlayIcon overlay)
+ {
+ return typeIconCache.GetIcon(icon, overlay, false);
+ }
+
+ public static ImageSource GetIcon(MemberIcon icon, OverlayIcon overlay, bool isStatic)
+ {
+ return memberIconCache.GetIcon(icon, overlay, isStatic);
+ }
+
+ #region icon caches & overlay management
+
+ private class TypeIconCache : IconCache
+ {
+ public TypeIconCache()
+ {
+ PreloadPublicIconToCache(TypeIcon.Class, Images.Class);
+ PreloadPublicIconToCache(TypeIcon.Enum, Images.Enum);
+ PreloadPublicIconToCache(TypeIcon.Struct, Images.Struct);
+ PreloadPublicIconToCache(TypeIcon.Interface, Images.Interface);
+ PreloadPublicIconToCache(TypeIcon.Delegate, Images.Delegate);
+ }
+
+ protected override ImageSource GetBaseImage(TypeIcon icon)
+ {
+ ImageSource baseImage;
+ switch (icon) {
+ case TypeIcon.Class:
+ baseImage = Images.Class;
+ break;
+ case TypeIcon.Enum:
+ baseImage = Images.Enum;
+ break;
+ case TypeIcon.Struct:
+ baseImage = Images.Struct;
+ break;
+ case TypeIcon.Interface:
+ baseImage = Images.Interface;
+ break;
+ case TypeIcon.Delegate:
+ baseImage = Images.Delegate;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+
+ return baseImage;
+ }
+ }
+
+ private class MemberIconCache : IconCache
+ {
+ public MemberIconCache()
+ {
+ PreloadPublicIconToCache(MemberIcon.Field, Images.Field);
+ PreloadPublicIconToCache(MemberIcon.FieldReadOnly, Images.FieldReadOnly);
+ PreloadPublicIconToCache(MemberIcon.Literal, Images.Literal);
+ PreloadPublicIconToCache(MemberIcon.EnumValue, Images.EnumValue);
+ PreloadPublicIconToCache(MemberIcon.Property, Images.Property);
+ PreloadPublicIconToCache(MemberIcon.Indexer, Images.Indexer);
+ PreloadPublicIconToCache(MemberIcon.Method, Images.Method);
+ PreloadPublicIconToCache(MemberIcon.Constructor, Images.Constructor);
+ PreloadPublicIconToCache(MemberIcon.Operator, Images.Operator);
+ PreloadPublicIconToCache(MemberIcon.ExtensionMethod, Images.ExtensionMethod);
+ PreloadPublicIconToCache(MemberIcon.Event, Images.Event);
+ }
+
+ protected override ImageSource GetBaseImage(MemberIcon icon)
+ {
+ ImageSource baseImage;
+ switch (icon) {
+ case MemberIcon.Field:
+ baseImage = Images.Field;
+ break;
+ case MemberIcon.FieldReadOnly:
+ baseImage = Images.FieldReadOnly;
+ break;
+ case MemberIcon.Literal:
+ baseImage = Images.Literal;
+ break;
+ case MemberIcon.EnumValue:
+ baseImage = Images.Literal;
+ break;
+ case MemberIcon.Property:
+ baseImage = Images.Property;
+ break;
+ case MemberIcon.Indexer:
+ baseImage = Images.Indexer;
+ break;
+ case MemberIcon.Method:
+ baseImage = Images.Method;
+ break;
+ case MemberIcon.Constructor:
+ baseImage = Images.Constructor;
+ break;
+ case MemberIcon.Operator:
+ baseImage = Images.Operator;
+ break;
+ case MemberIcon.ExtensionMethod:
+ baseImage = Images.ExtensionMethod;
+ break;
+ case MemberIcon.Event:
+ baseImage = Images.Event;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+
+ return baseImage;
+ }
+ }
+
+ private abstract class IconCache
+ {
+ private Dictionary, ImageSource> cache = new Dictionary, ImageSource>();
+
+ protected void PreloadPublicIconToCache(T icon, ImageSource image)
+ {
+ var iconKey = new Tuple(icon, OverlayIcon.Public, false);
+ cache.Add(iconKey, image);
+ }
+
+ public ImageSource GetIcon(T icon, OverlayIcon overlay, bool isStatic)
+ {
+ var iconKey = new Tuple(icon, overlay, isStatic);
+ if (cache.ContainsKey(iconKey)) {
+ return cache[iconKey];
+ } else {
+ ImageSource result = BuildMemberIcon(icon, overlay, isStatic);
+ cache.Add(iconKey, result);
+ return result;
+ }
+ }
+
+ private ImageSource BuildMemberIcon(T icon, OverlayIcon overlay, bool isStatic)
+ {
+ ImageSource baseImage = GetBaseImage(icon);
+ ImageSource overlayImage = GetOverlayImage(overlay);
+
+ return CreateOverlayImage(baseImage, overlayImage, isStatic);
+ }
+
+ protected abstract ImageSource GetBaseImage(T icon);
+
+ private static ImageSource GetOverlayImage(OverlayIcon overlay)
+ {
+ ImageSource overlayImage;
+ switch (overlay) {
+ case OverlayIcon.Public:
+ overlayImage = null;
+ break;
+ case OverlayIcon.Protected:
+ overlayImage = Images.OverlayProtected;
+ break;
+ case OverlayIcon.Internal:
+ overlayImage = Images.OverlayInternal;
+ break;
+ case OverlayIcon.ProtectedInternal:
+ overlayImage = Images.OverlayProtectedInternal;
+ break;
+ case OverlayIcon.Private:
+ overlayImage = Images.OverlayPrivate;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+ return overlayImage;
+ }
+
+ private static readonly Rect iconRect = new Rect(0, 0, 16, 16);
+
+ private static ImageSource CreateOverlayImage(ImageSource baseImage, ImageSource overlay, bool isStatic)
+ {
+ var group = new DrawingGroup();
+
+ group.Children.Add(new ImageDrawing(baseImage, iconRect));
+
+ if (overlay != null) {
+ group.Children.Add(new ImageDrawing(overlay, iconRect));
+ }
+
+ if (isStatic) {
+ group.Children.Add(new ImageDrawing(Images.OverlayStatic, iconRect));
+ }
+
+ var image = new DrawingImage(group);
+ image.Freeze();
+ return image;
+ }
+ }
+
+ #endregion
}
}
diff --git a/ILSpy/Images/Indexer.png b/ILSpy/Images/Indexer.png
index 63cee80b1..86a9082cc 100644
Binary files a/ILSpy/Images/Indexer.png and b/ILSpy/Images/Indexer.png differ
diff --git a/ILSpy/Images/Interface.png b/ILSpy/Images/Interface.png
index d8f6f4153..788cc1778 100644
Binary files a/ILSpy/Images/Interface.png and b/ILSpy/Images/Interface.png differ
diff --git a/ILSpy/Images/InternalClass.png b/ILSpy/Images/InternalClass.png
deleted file mode 100644
index 0530af7e8..000000000
Binary files a/ILSpy/Images/InternalClass.png and /dev/null differ
diff --git a/ILSpy/Images/InternalDelegate.png b/ILSpy/Images/InternalDelegate.png
deleted file mode 100644
index 9ee36aff7..000000000
Binary files a/ILSpy/Images/InternalDelegate.png and /dev/null differ
diff --git a/ILSpy/Images/InternalEnum.png b/ILSpy/Images/InternalEnum.png
deleted file mode 100644
index f5f901693..000000000
Binary files a/ILSpy/Images/InternalEnum.png and /dev/null differ
diff --git a/ILSpy/Images/InternalInterface.png b/ILSpy/Images/InternalInterface.png
deleted file mode 100644
index fd818fe2a..000000000
Binary files a/ILSpy/Images/InternalInterface.png and /dev/null differ
diff --git a/ILSpy/Images/InternalStruct.png b/ILSpy/Images/InternalStruct.png
deleted file mode 100644
index e067f1b54..000000000
Binary files a/ILSpy/Images/InternalStruct.png and /dev/null differ
diff --git a/ILSpy/Images/Literal.png b/ILSpy/Images/Literal.png
index 077075c13..55a693d29 100644
Binary files a/ILSpy/Images/Literal.png and b/ILSpy/Images/Literal.png differ
diff --git a/ILSpy/Images/MemberIcon.cs b/ILSpy/Images/MemberIcon.cs
new file mode 100644
index 000000000..187adf31f
--- /dev/null
+++ b/ILSpy/Images/MemberIcon.cs
@@ -0,0 +1,37 @@
+// 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
+{
+ internal enum MemberIcon
+ {
+ Literal,
+ FieldReadOnly,
+ Field,
+ EnumValue,
+ Property,
+ Indexer,
+ Method,
+ Constructor,
+ Operator,
+ ExtensionMethod,
+ Event
+ }
+}
diff --git a/ILSpy/Images/Method.png b/ILSpy/Images/Method.png
index 3ba3a9952..7cce8baf3 100644
Binary files a/ILSpy/Images/Method.png and b/ILSpy/Images/Method.png differ
diff --git a/ILSpy/Images/Operator.png b/ILSpy/Images/Operator.png
index fda73d089..6fa32b91e 100644
Binary files a/ILSpy/Images/Operator.png and b/ILSpy/Images/Operator.png differ
diff --git a/ILSpy/Images/OverlayIcon.cs b/ILSpy/Images/OverlayIcon.cs
new file mode 100644
index 000000000..6c4e729c4
--- /dev/null
+++ b/ILSpy/Images/OverlayIcon.cs
@@ -0,0 +1,34 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+// 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
+{
+ internal enum OverlayIcon
+ {
+ Public,
+ Protected,
+ Internal,
+ ProtectedInternal,
+ Private,
+ }
+}
diff --git a/ILSpy/Images/OverlayInternal.png b/ILSpy/Images/OverlayInternal.png
new file mode 100644
index 000000000..fcc53bdde
Binary files /dev/null and b/ILSpy/Images/OverlayInternal.png differ
diff --git a/ILSpy/Images/OverlayPrivate.png b/ILSpy/Images/OverlayPrivate.png
new file mode 100644
index 000000000..13ee614f8
Binary files /dev/null and b/ILSpy/Images/OverlayPrivate.png differ
diff --git a/ILSpy/Images/OverlayProtected.png b/ILSpy/Images/OverlayProtected.png
new file mode 100644
index 000000000..0d125f7d2
Binary files /dev/null and b/ILSpy/Images/OverlayProtected.png differ
diff --git a/ILSpy/Images/OverlayProtectedInternal.png b/ILSpy/Images/OverlayProtectedInternal.png
new file mode 100644
index 000000000..dacce33c4
Binary files /dev/null and b/ILSpy/Images/OverlayProtectedInternal.png differ
diff --git a/ILSpy/Images/OverlayStatic.png b/ILSpy/Images/OverlayStatic.png
new file mode 100644
index 000000000..f12f33739
Binary files /dev/null and b/ILSpy/Images/OverlayStatic.png differ
diff --git a/ILSpy/Images/PrivateClass.png b/ILSpy/Images/PrivateClass.png
deleted file mode 100644
index 370aa1c76..000000000
Binary files a/ILSpy/Images/PrivateClass.png and /dev/null differ
diff --git a/ILSpy/Images/PrivateDelegate.png b/ILSpy/Images/PrivateDelegate.png
deleted file mode 100644
index b6d652811..000000000
Binary files a/ILSpy/Images/PrivateDelegate.png and /dev/null differ
diff --git a/ILSpy/Images/PrivateEnum.png b/ILSpy/Images/PrivateEnum.png
deleted file mode 100644
index 968aabfbb..000000000
Binary files a/ILSpy/Images/PrivateEnum.png and /dev/null differ
diff --git a/ILSpy/Images/PrivateInterface.png b/ILSpy/Images/PrivateInterface.png
deleted file mode 100644
index c81bb655f..000000000
Binary files a/ILSpy/Images/PrivateInterface.png and /dev/null differ
diff --git a/ILSpy/Images/PrivateStruct.png b/ILSpy/Images/PrivateStruct.png
deleted file mode 100644
index a8812254f..000000000
Binary files a/ILSpy/Images/PrivateStruct.png and /dev/null differ
diff --git a/ILSpy/Images/Property.png b/ILSpy/Images/Property.png
index 091e7ab2c..69899b4c4 100644
Binary files a/ILSpy/Images/Property.png and b/ILSpy/Images/Property.png differ
diff --git a/ILSpy/Images/ProtectedClass.png b/ILSpy/Images/ProtectedClass.png
deleted file mode 100644
index 6f97213ea..000000000
Binary files a/ILSpy/Images/ProtectedClass.png and /dev/null differ
diff --git a/ILSpy/Images/ProtectedDelegate.png b/ILSpy/Images/ProtectedDelegate.png
deleted file mode 100644
index 9bb2f8815..000000000
Binary files a/ILSpy/Images/ProtectedDelegate.png and /dev/null differ
diff --git a/ILSpy/Images/ProtectedEnum.png b/ILSpy/Images/ProtectedEnum.png
deleted file mode 100644
index 1912ed883..000000000
Binary files a/ILSpy/Images/ProtectedEnum.png and /dev/null differ
diff --git a/ILSpy/Images/ProtectedInterface.png b/ILSpy/Images/ProtectedInterface.png
deleted file mode 100644
index d8fedab14..000000000
Binary files a/ILSpy/Images/ProtectedInterface.png and /dev/null differ
diff --git a/ILSpy/Images/ProtectedStruct.png b/ILSpy/Images/ProtectedStruct.png
deleted file mode 100644
index fec00cced..000000000
Binary files a/ILSpy/Images/ProtectedStruct.png and /dev/null differ
diff --git a/ILSpy/Images/Resource.png b/ILSpy/Images/Resource.png
index 2d8840719..0cbdb7320 100644
Binary files a/ILSpy/Images/Resource.png and b/ILSpy/Images/Resource.png differ
diff --git a/ILSpy/Images/ResourceImage.png b/ILSpy/Images/ResourceImage.png
new file mode 100644
index 000000000..3c0cf56cd
Binary files /dev/null and b/ILSpy/Images/ResourceImage.png differ
diff --git a/ILSpy/Images/Struct.png b/ILSpy/Images/Struct.png
index 4a1928a79..6b17b613b 100644
Binary files a/ILSpy/Images/Struct.png and b/ILSpy/Images/Struct.png differ
diff --git a/ILSpy/Images/SubTypes.png b/ILSpy/Images/SubTypes.png
index 82bfe26d7..e04de5c6a 100644
Binary files a/ILSpy/Images/SubTypes.png and b/ILSpy/Images/SubTypes.png differ
diff --git a/ILSpy/Images/SuperTypes.png b/ILSpy/Images/SuperTypes.png
index 831e43bb1..fe099afbd 100644
Binary files a/ILSpy/Images/SuperTypes.png and b/ILSpy/Images/SuperTypes.png differ
diff --git a/ILSpy/Images/TypeIcon.cs b/ILSpy/Images/TypeIcon.cs
new file mode 100644
index 000000000..2e5f3f498
--- /dev/null
+++ b/ILSpy/Images/TypeIcon.cs
@@ -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
+{
+ internal enum TypeIcon
+ {
+ Class,
+ Enum,
+ Struct,
+ Interface,
+ Delegate
+ }
+}
diff --git a/ILSpy/TreeNodes/EventTreeNode.cs b/ILSpy/TreeNodes/EventTreeNode.cs
index aad7263b7..c54540f38 100644
--- a/ILSpy/TreeNodes/EventTreeNode.cs
+++ b/ILSpy/TreeNodes/EventTreeNode.cs
@@ -55,12 +55,29 @@ namespace ICSharpCode.ILSpy.TreeNodes
get { return HighlightSearchMatch(ev.Name, " : " + this.Language.TypeToString(ev.EventType, false, ev)); }
}
- public override object Icon {
- get {
- return Images.Event;
+ public override object Icon
+ {
+ get { return Images.GetIcon(MemberIcon.Event, GetOverlayIcon(ev.AddMethod.Attributes), ev.AddMethod.IsStatic); }
+ }
+
+ private static OverlayIcon GetOverlayIcon(MethodAttributes methodAttributes)
+ {
+ switch (methodAttributes & MethodAttributes.MemberAccessMask) {
+ case MethodAttributes.Public:
+ return OverlayIcon.Public;
+ case MethodAttributes.Assembly:
+ case MethodAttributes.FamANDAssem:
+ return OverlayIcon.Internal;
+ case MethodAttributes.Family:
+ case MethodAttributes.FamORAssem:
+ return OverlayIcon.Protected;
+ case MethodAttributes.Private:
+ return OverlayIcon.Private;
+ default:
+ throw new NotSupportedException();
}
}
-
+
public override FilterResult Filter(FilterSettings settings)
{
if (settings.SearchTermMatches(ev.Name) && settings.Language.ShowMember(ev))
diff --git a/ILSpy/TreeNodes/FieldTreeNode.cs b/ILSpy/TreeNodes/FieldTreeNode.cs
index 88cf533a9..a967d3109 100644
--- a/ILSpy/TreeNodes/FieldTreeNode.cs
+++ b/ILSpy/TreeNodes/FieldTreeNode.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Windows.Media;
using ICSharpCode.Decompiler;
using Mono.Cecil;
@@ -28,34 +29,60 @@ namespace ICSharpCode.ILSpy.TreeNodes
public sealed class FieldTreeNode : ILSpyTreeNode, IMemberTreeNode
{
readonly FieldDefinition field;
-
- public FieldDefinition FieldDefinition {
+
+ public FieldDefinition FieldDefinition
+ {
get { return field; }
}
-
+
public FieldTreeNode(FieldDefinition field)
{
if (field == null)
throw new ArgumentNullException("field");
this.field = field;
}
-
- public override object Text {
+
+ public override object Text
+ {
get { return HighlightSearchMatch(field.Name, " : " + this.Language.TypeToString(field.FieldType, false, field)); }
}
-
- public override object Icon {
+
+ public override object Icon
+ {
get { return GetIcon(field); }
}
-
- public static object GetIcon(FieldDefinition field)
+
+ public static ImageSource GetIcon(FieldDefinition field)
{
+ if (field.DeclaringType.IsEnum && !field.Attributes.HasFlag(FieldAttributes.SpecialName))
+ return Images.GetIcon(MemberIcon.EnumValue, GetOverlayIcon(field.Attributes), false);
+
if (field.IsLiteral)
- return Images.Literal;
+ return Images.GetIcon(MemberIcon.Literal, GetOverlayIcon(field.Attributes), false);
+ else if (field.IsInitOnly)
+ return Images.GetIcon(MemberIcon.FieldReadOnly, GetOverlayIcon(field.Attributes), field.IsStatic);
else
- return Images.Field;
+ return Images.GetIcon(MemberIcon.Field, GetOverlayIcon(field.Attributes), field.IsStatic);
+ }
+
+ private static OverlayIcon GetOverlayIcon(FieldAttributes fieldAttributes)
+ {
+ switch (fieldAttributes & FieldAttributes.FieldAccessMask) {
+ case FieldAttributes.Public:
+ return OverlayIcon.Public;
+ case FieldAttributes.Assembly:
+ case FieldAttributes.FamANDAssem:
+ return OverlayIcon.Internal;
+ case FieldAttributes.Family:
+ case FieldAttributes.FamORAssem:
+ return OverlayIcon.Protected;
+ case FieldAttributes.Private:
+ return OverlayIcon.Private;
+ default:
+ throw new NotSupportedException();
+ }
}
-
+
public override FilterResult Filter(FilterSettings settings)
{
if (settings.SearchTermMatches(field.Name) && settings.Language.ShowMember(field))
@@ -63,13 +90,14 @@ namespace ICSharpCode.ILSpy.TreeNodes
else
return FilterResult.Hidden;
}
-
+
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.DecompileField(field, output, options);
}
-
- MemberReference IMemberTreeNode.Member {
+
+ MemberReference IMemberTreeNode.Member
+ {
get { return field; }
}
}
diff --git a/ILSpy/TreeNodes/MethodTreeNode.cs b/ILSpy/TreeNodes/MethodTreeNode.cs
index 0e23aa02d..97df9ac92 100644
--- a/ILSpy/TreeNodes/MethodTreeNode.cs
+++ b/ILSpy/TreeNodes/MethodTreeNode.cs
@@ -18,8 +18,7 @@
using System;
using System.Text;
-using System.Windows.Media.Imaging;
-
+using System.Windows.Media;
using ICSharpCode.Decompiler;
using Mono.Cecil;
@@ -31,20 +30,23 @@ namespace ICSharpCode.ILSpy.TreeNodes
public sealed class MethodTreeNode : ILSpyTreeNode, IMemberTreeNode
{
MethodDefinition method;
-
- public MethodDefinition MethodDefinition {
+
+ public MethodDefinition MethodDefinition
+ {
get { return method; }
}
-
+
public MethodTreeNode(MethodDefinition method)
{
if (method == null)
throw new ArgumentNullException("method");
this.method = method;
}
-
- public override object Text {
- get {
+
+ public override object Text
+ {
+ get
+ {
return GetText(method, Language);
}
}
@@ -62,31 +64,57 @@ namespace ICSharpCode.ILSpy.TreeNodes
b.Append(language.TypeToString(method.ReturnType, false, method.MethodReturnType));
return HighlightSearchMatch(method.Name, b.ToString());
}
-
- public override object Icon {
- get {
- return GetIcon(method);
- }
+
+ public override object Icon
+ {
+ get { return GetIcon(method); }
}
- public static BitmapImage GetIcon(MethodDefinition method)
+ public static ImageSource GetIcon(MethodDefinition method)
{
- if (method.IsSpecialName && method.Name.StartsWith("op_", StringComparison.Ordinal))
- return Images.Operator;
+ if (method.IsSpecialName && method.Name.StartsWith("op_", StringComparison.Ordinal)) {
+ return Images.GetIcon(MemberIcon.Operator, GetOverlayIcon(method.Attributes), false);
+ }
+
if (method.IsStatic && method.HasCustomAttributes) {
foreach (var ca in method.CustomAttributes) {
- if (ca.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute")
- return Images.ExtensionMethod;
+ if (ca.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute") {
+ return Images.GetIcon(MemberIcon.ExtensionMethod, GetOverlayIcon(method.Attributes), false);
+ }
}
}
- return Images.Method;
+
+ if (method.IsSpecialName &&
+ (method.Name == ".ctor" || method.Name == ".cctor")) {
+ return Images.GetIcon(MemberIcon.Constructor, GetOverlayIcon(method.Attributes), false);
+ }
+
+ return Images.GetIcon(MemberIcon.Method, GetOverlayIcon(method.Attributes), method.IsStatic);
}
-
+
+ private static OverlayIcon GetOverlayIcon(MethodAttributes methodAttributes)
+ {
+ switch (methodAttributes & MethodAttributes.MemberAccessMask) {
+ case MethodAttributes.Public:
+ return OverlayIcon.Public;
+ case MethodAttributes.Assembly:
+ case MethodAttributes.FamANDAssem:
+ return OverlayIcon.Internal;
+ case MethodAttributes.Family:
+ case MethodAttributes.FamORAssem:
+ return OverlayIcon.Protected;
+ case MethodAttributes.Private:
+ return OverlayIcon.Private;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.DecompileMethod(method, output, options);
}
-
+
public override FilterResult Filter(FilterSettings settings)
{
if (settings.SearchTermMatches(method.Name) && settings.Language.ShowMember(method))
@@ -94,8 +122,9 @@ namespace ICSharpCode.ILSpy.TreeNodes
else
return FilterResult.Hidden;
}
-
- MemberReference IMemberTreeNode.Member {
+
+ MemberReference IMemberTreeNode.Member
+ {
get { return method; }
}
}
diff --git a/ILSpy/TreeNodes/PropertyTreeNode.cs b/ILSpy/TreeNodes/PropertyTreeNode.cs
index 466543bd6..98596b7c5 100644
--- a/ILSpy/TreeNodes/PropertyTreeNode.cs
+++ b/ILSpy/TreeNodes/PropertyTreeNode.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Windows.Media;
using ICSharpCode.Decompiler;
using Mono.Cecil;
@@ -29,14 +30,16 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
readonly PropertyDefinition property;
readonly bool isIndexer;
-
+ readonly MethodAttributes attributesOfMostAccessibleMethod;
+
public PropertyTreeNode(PropertyDefinition property, bool isIndexer)
{
if (property == null)
throw new ArgumentNullException("property");
this.property = property;
this.isIndexer = isIndexer;
-
+ this.attributesOfMostAccessibleMethod = GetAttributesOfMostAccessibleMethod(this.property);
+
if (property.GetMethod != null)
this.Children.Add(new MethodTreeNode(property.GetMethod));
if (property.SetMethod != null)
@@ -46,21 +49,90 @@ namespace ICSharpCode.ILSpy.TreeNodes
this.Children.Add(new MethodTreeNode(m));
}
}
-
+
public PropertyDefinition PropertyDefinition {
get { return property; }
}
-
- public override object Text {
+
+ public override object Text
+ {
get { return HighlightSearchMatch(property.Name, " : " + this.Language.TypeToString(property.PropertyType, false, property)); }
}
-
- public override object Icon {
- get {
- return isIndexer ? Images.Indexer : Images.Property;
+
+ public override object Icon
+ {
+ get { return GetIcon(property); }
+ }
+
+ private ImageSource GetIcon(PropertyDefinition property)
+ {
+ MemberIcon icon = this.isIndexer ? MemberIcon.Indexer : MemberIcon.Property;
+ return Images.GetIcon(icon, GetOverlayIcon(attributesOfMostAccessibleMethod), IsStatic);
+ }
+
+ private static OverlayIcon GetOverlayIcon(MethodAttributes methodAttributes)
+ {
+ switch (methodAttributes & MethodAttributes.MemberAccessMask) {
+ case MethodAttributes.Public:
+ return OverlayIcon.Public;
+ case MethodAttributes.Assembly:
+ case MethodAttributes.FamANDAssem:
+ return OverlayIcon.Internal;
+ case MethodAttributes.Family:
+ case MethodAttributes.FamORAssem:
+ return OverlayIcon.Protected;
+ case MethodAttributes.Private:
+ return OverlayIcon.Private;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
+ public bool IsStatic
+ {
+ get { return (attributesOfMostAccessibleMethod & MethodAttributes.Static) != 0; }
+ }
+
+ private static MethodAttributes GetAttributesOfMostAccessibleMethod(PropertyDefinition property)
+ {
+ // There should always be at least one method from which to
+ // obtain the result, but the compiler doesn't know this so
+ // initialize the result with a default value
+ MethodAttributes result = (MethodAttributes)0;
+
+ // Method access is defined from inaccessible (lowest) to public (highest)
+ // in numeric order, so we can do an integer comparison of the masked attribute
+ int accessLevel = 0;
+
+ if (property.GetMethod != null) {
+ int methodAccessLevel = (int)(property.GetMethod.Attributes & MethodAttributes.MemberAccessMask);
+ if (accessLevel < methodAccessLevel) {
+ accessLevel = methodAccessLevel;
+ result = property.GetMethod.Attributes;
+ }
+ }
+
+ if (property.SetMethod != null) {
+ int methodAccessLevel = (int)(property.SetMethod.Attributes & MethodAttributes.MemberAccessMask);
+ if (accessLevel < methodAccessLevel) {
+ accessLevel = methodAccessLevel;
+ result = property.SetMethod.Attributes;
+ }
}
+
+ if (property.HasOtherMethods) {
+ foreach (var m in property.OtherMethods) {
+ int methodAccessLevel = (int)(m.Attributes & MethodAttributes.MemberAccessMask);
+ if (accessLevel < methodAccessLevel) {
+ accessLevel = methodAccessLevel;
+ result = m.Attributes;
+ }
+ }
+ }
+
+ return result;
}
-
+
public override FilterResult Filter(FilterSettings settings)
{
if (settings.SearchTermMatches(property.Name) && settings.Language.ShowMember(property))
@@ -68,13 +140,14 @@ namespace ICSharpCode.ILSpy.TreeNodes
else
return FilterResult.Hidden;
}
-
+
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
{
language.DecompileProperty(property, output, options);
}
-
- MemberReference IMemberTreeNode.Member {
+
+ MemberReference IMemberTreeNode.Member
+ {
get { return property; }
}
}
diff --git a/ILSpy/TreeNodes/TypeTreeNode.cs b/ILSpy/TreeNodes/TypeTreeNode.cs
index 4fd691323..bd0cb0544 100644
--- a/ILSpy/TreeNodes/TypeTreeNode.cs
+++ b/ILSpy/TreeNodes/TypeTreeNode.cs
@@ -129,82 +129,62 @@ namespace ICSharpCode.ILSpy.TreeNodes
{
language.DecompileType(type, output, options);
}
-
+
#region Icon
- enum ClassType
+ public override object Icon
{
- Class,
- Enum,
- Struct,
- Interface,
- Delegate
+ get { return GetIcon(type); }
}
-
- static ClassType GetClassType(TypeDefinition type)
+
+ public static ImageSource GetIcon(TypeDefinition type)
+ {
+ TypeIcon typeIcon = GetTypeIcon(type);
+ OverlayIcon overlayIcon = GetOverlayIcon(type);
+
+ return Images.GetIcon(typeIcon, overlayIcon);
+ }
+
+ static TypeIcon GetTypeIcon(TypeDefinition type)
{
if (type.IsValueType) {
if (type.IsEnum)
- return ClassType.Enum;
+ return TypeIcon.Enum;
else
- return ClassType.Struct;
+ return TypeIcon.Struct;
} else {
if (type.IsInterface)
- return ClassType.Interface;
+ return TypeIcon.Interface;
else if (type.BaseType != null && type.BaseType.FullName == typeof(MulticastDelegate).FullName)
- return ClassType.Delegate;
+ return TypeIcon.Delegate;
else
- return ClassType.Class;
- }
- }
-
- public override object Icon {
- get {
- return GetIcon(type);
+ return TypeIcon.Class;
}
}
-
- public static ImageSource GetIcon(TypeDefinition type)
+
+ private static OverlayIcon GetOverlayIcon(TypeDefinition type)
{
+ OverlayIcon overlay;
switch (type.Attributes & TypeAttributes.VisibilityMask) {
case TypeAttributes.Public:
case TypeAttributes.NestedPublic:
- switch (GetClassType(type)) {
- case ClassType.Delegate: return Images.Delegate;
- case ClassType.Enum: return Images.Enum;
- case ClassType.Interface: return Images.Interface;
- case ClassType.Struct: return Images.Struct;
- default: return Images.Class;
- }
+ overlay = OverlayIcon.Public;
+ break;
case TypeAttributes.NotPublic:
case TypeAttributes.NestedAssembly:
case TypeAttributes.NestedFamANDAssem:
- switch (GetClassType(type)) {
- case ClassType.Delegate: return Images.InternalDelegate;
- case ClassType.Enum: return Images.InternalEnum;
- case ClassType.Interface: return Images.InternalInterface;
- case ClassType.Struct: return Images.InternalStruct;
- default: return Images.InternalClass;
- }
+ overlay = OverlayIcon.Internal;
+ break;
case TypeAttributes.NestedFamily:
case TypeAttributes.NestedFamORAssem:
- switch (GetClassType(type)) {
- case ClassType.Delegate: return Images.ProtectedDelegate;
- case ClassType.Enum: return Images.ProtectedEnum;
- case ClassType.Interface: return Images.ProtectedInterface;
- case ClassType.Struct: return Images.ProtectedStruct;
- default: return Images.ProtectedClass;
- }
+ overlay = OverlayIcon.Protected;
+ break;
case TypeAttributes.NestedPrivate:
- switch (GetClassType(type)) {
- case ClassType.Delegate: return Images.PrivateDelegate;
- case ClassType.Enum: return Images.PrivateEnum;
- case ClassType.Interface: return Images.PrivateInterface;
- case ClassType.Struct: return Images.PrivateStruct;
- default: return Images.PrivateClass;
- }
+ overlay = OverlayIcon.Private;
+ break;
default:
throw new NotSupportedException();
}
+ return overlay;
}
#endregion