From cc58644082d93acdd8aafdccd383db8827faeb65 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 15 Mar 2024 21:59:39 +0100 Subject: [PATCH] Added new icons for TypeReference, ExportedType and MemberReference --- ILSpy/Images/ExportOverlay.svg | 86 +++++++++++++++++++ ILSpy/Images/ExportOverlay.xaml | 18 ++++ ILSpy/Images/Images.cs | 81 ++++++++++------- ILSpy/Images/README.md | 4 +- ILSpy/Images/ReferenceOverlay.svg | 55 ++++++++++++ ILSpy/Images/ReferenceOverlay.xaml | 12 +++ ...ssemblyReferenceReferencedTypesTreeNode.cs | 2 +- ILSpy/TreeNodes/ExportedTypeTreeNode.cs | 2 +- ILSpy/TreeNodes/MemberReferenceTreeNode.cs | 6 +- ILSpy/TreeNodes/TypeReferenceTreeNode.cs | 2 +- 10 files changed, 228 insertions(+), 40 deletions(-) create mode 100644 ILSpy/Images/ExportOverlay.svg create mode 100644 ILSpy/Images/ExportOverlay.xaml create mode 100644 ILSpy/Images/ReferenceOverlay.svg create mode 100644 ILSpy/Images/ReferenceOverlay.xaml diff --git a/ILSpy/Images/ExportOverlay.svg b/ILSpy/Images/ExportOverlay.svg new file mode 100644 index 0000000000..d396359683 --- /dev/null +++ b/ILSpy/Images/ExportOverlay.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ILSpy/Images/ExportOverlay.xaml b/ILSpy/Images/ExportOverlay.xaml new file mode 100644 index 0000000000..387c04fb4e --- /dev/null +++ b/ILSpy/Images/ExportOverlay.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/Images/Images.cs b/ILSpy/Images/Images.cs index ab1012278f..5b48f10bc8 100644 --- a/ILSpy/Images/Images.cs +++ b/ILSpy/Images/Images.cs @@ -27,6 +27,8 @@ namespace ICSharpCode.ILSpy { static class Images { + private static readonly Rect iconRect = new Rect(0, 0, 16, 16); + static ImageSource Load(string icon) { var image = new DrawingImage(LoadDrawingGroup(null, "Images/" + icon)); @@ -85,6 +87,7 @@ static ImageSource Load(string icon) public static readonly ImageSource Interface = Load("Interface"); public static readonly ImageSource Delegate = Load("Delegate"); public static readonly ImageSource Enum = Load("Enum"); + public static readonly ImageSource Type = Load("ShowPublicOnly"); public static readonly ImageSource Field = Load("Field"); public static readonly ImageSource FieldReadOnly = Load("FieldReadOnly"); @@ -109,9 +112,15 @@ static ImageSource Load(string icon) private static readonly ImageSource OverlayPrivate = Load("OverlayPrivate"); private static readonly ImageSource OverlayPrivateProtected = Load("OverlayPrivateProtected"); private static readonly ImageSource OverlayCompilerControlled = Load("OverlayCompilerControlled"); + private static readonly ImageSource OverlayReference = Load("ReferenceOverlay"); private static readonly ImageSource OverlayStatic = Load("OverlayStatic"); + public static readonly ImageSource TypeReference = GetIcon("ShowPublicOnly", "ReferenceOverlay"); + public static readonly ImageSource MethodReference = GetIcon("Method", "ReferenceOverlay"); + public static readonly ImageSource FieldReference = GetIcon("Field", "ReferenceOverlay"); + public static readonly ImageSource ExportedType = GetIcon("ShowPublicOnly", "ExportOverlay"); + public static ImageSource Load(object part, string icon) { if (icon.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) @@ -202,6 +211,45 @@ public static ImageSource GetIcon(MemberIcon icon, AccessOverlayIcon overlay, bo return memberIconCache.GetIcon(icon, overlay, isStatic); } + private static ImageSource GetIcon(string baseImage, string overlay = null, bool isStatic = false) + { + ImageSource baseImageSource = Load(baseImage); + ImageSource overlayImageSource = overlay != null ? Load(overlay) : null; + + return CreateOverlayImage(baseImageSource, overlayImageSource, isStatic); + } + + private static ImageSource CreateOverlayImage(ImageSource baseImage, ImageSource overlay, bool isStatic) + { + var group = new DrawingGroup(); + + Drawing baseDrawing = new ImageDrawing(baseImage, iconRect); + + if (overlay != null) + { + var nestedGroup = new DrawingGroup { Transform = new ScaleTransform(0.8, 0.8) }; + nestedGroup.Children.Add(baseDrawing); + group.Children.Add(nestedGroup); + group.Children.Add(new ImageDrawing(overlay, iconRect)); + } + else + { + group.Children.Add(baseDrawing); + } + + if (isStatic) + { + group.Children.Add(new ImageDrawing(Images.OverlayStatic, iconRect)); + } + + var image = new DrawingImage(group); + if (image.CanFreeze) + { + image.Freeze(); + } + return image; + } + #region icon caches & overlay management private class TypeIconCache : IconCache @@ -380,39 +428,6 @@ private static ImageSource GetOverlayImage(AccessOverlayIcon overlay) } 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(); - - Drawing baseDrawing = new ImageDrawing(baseImage, iconRect); - - if (overlay != null) - { - var nestedGroup = new DrawingGroup { Transform = new ScaleTransform(0.8, 0.8) }; - nestedGroup.Children.Add(baseDrawing); - group.Children.Add(nestedGroup); - group.Children.Add(new ImageDrawing(overlay, iconRect)); - } - else - { - group.Children.Add(baseDrawing); - } - - if (isStatic) - { - group.Children.Add(new ImageDrawing(Images.OverlayStatic, iconRect)); - } - - var image = new DrawingImage(group); - if (image.CanFreeze) - { - image.Freeze(); - } - return image; - } } #endregion diff --git a/ILSpy/Images/README.md b/ILSpy/Images/README.md index 82decd3387..05dcc6f092 100644 --- a/ILSpy/Images/README.md +++ b/ILSpy/Images/README.md @@ -18,6 +18,7 @@ Icons used in ILSpy: | Enum | x | x | VS 2017 Icon Pack (Enumerator) | | | EnumValue | x | x | VS 2017 Icon Pack (EnumItem) | | | Event | x | x | VS 2017 Icon Pack (Event) | | +| ExportOverlay | x | x | slightly modified VS 2017 Icon Pack (Export) | | | ExtensionMethod | x | x | VS 2017 Icon Pack (ExtensionMethod) | | | Field | x | x | VS 2017 Icon Pack (Field) | | | FieldReadOnly | x | x | VS 2017 Icon Pack (Field) with different color | | @@ -53,12 +54,13 @@ Icons used in ILSpy: | ProgramDebugDatabase | x | x | VS 2017 Icon Pack (ProgramDebugDatabase) | | | Property | x | x | VS 2017 Icon Pack (Property) | | | ReferenceFolder | x | x | combined VS 2017 Icon Pack (Reference) two times | | +| ReferenceOverlay | x | x | extracted arrow from VS 2017 Icon Pack (TypeShortcut) | | | Refresh | x | x | VS 2017 Icon Pack (Refresh) | | | Resource | x | x | VS 2017 Icon Pack (Document) | | | ResourceImage | x | x | VS 2017 Icon Pack (Image) | | | ResourceResourcesFile | x | x | VS 2017 Icon Pack (LocalResources) | | | ResourceXml | x | x | VS 2017 Icon Pack (XMLFile) | | -| ResourceXsd | x | x | combined VS 2017 Icon Pack (XMLSchema) with the "file symbol in ResourceXslt | | +| ResourceXsd | x | x | combined VS 2017 Icon Pack (XMLSchema) with the file symbol in ResourceXslt | | | ResourceXsl | x | x | VS 2017 Icon Pack (XMLTransformation) | | | ResourceXslt | x | x | VS 2017 Icon Pack (XSLTTemplate) | | | Save | x | x | VS 2017 Icon Pack (Save) | | diff --git a/ILSpy/Images/ReferenceOverlay.svg b/ILSpy/Images/ReferenceOverlay.svg new file mode 100644 index 0000000000..8d6a8ef7af --- /dev/null +++ b/ILSpy/Images/ReferenceOverlay.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + diff --git a/ILSpy/Images/ReferenceOverlay.xaml b/ILSpy/Images/ReferenceOverlay.xaml new file mode 100644 index 0000000000..a07e0cb790 --- /dev/null +++ b/ILSpy/Images/ReferenceOverlay.xaml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ILSpy/TreeNodes/AssemblyReferenceReferencedTypesTreeNode.cs b/ILSpy/TreeNodes/AssemblyReferenceReferencedTypesTreeNode.cs index 37511236f2..642cb80eef 100644 --- a/ILSpy/TreeNodes/AssemblyReferenceReferencedTypesTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyReferenceReferencedTypesTreeNode.cs @@ -41,7 +41,7 @@ public AssemblyReferenceReferencedTypesTreeNode(MetadataModule module, AssemblyR } public override object Text => $"Referenced Types ({r.TypeReferences.Length + r.ExportedTypes.Length})"; - public override object Icon => Images.Class; + public override object Icon => Images.MetadataTable; protected override void LoadChildren() { diff --git a/ILSpy/TreeNodes/ExportedTypeTreeNode.cs b/ILSpy/TreeNodes/ExportedTypeTreeNode.cs index b01e0c1dfc..262d4c7a99 100644 --- a/ILSpy/TreeNodes/ExportedTypeTreeNode.cs +++ b/ILSpy/TreeNodes/ExportedTypeTreeNode.cs @@ -45,7 +45,7 @@ public ExportedTypeTreeNode(MetadataModule module, ExportedTypeMetadata r) public override object Text => Language.TypeToString(resolvedType, includeNamespace: true) + GetSuffixString(r.Handle); - public override object Icon => Images.Library; + public override object Icon => Images.ExportedType; protected override void LoadChildren() { diff --git a/ILSpy/TreeNodes/MemberReferenceTreeNode.cs b/ILSpy/TreeNodes/MemberReferenceTreeNode.cs index a320d5ccb7..33ae47cffc 100644 --- a/ILSpy/TreeNodes/MemberReferenceTreeNode.cs +++ b/ILSpy/TreeNodes/MemberReferenceTreeNode.cs @@ -50,9 +50,9 @@ public MemberReferenceTreeNode(MetadataModule module, MemberReferenceMetadata r) public override object Text => Signature + GetSuffixString(r.Handle); public override object Icon => r.MemberReferenceKind switch { - MemberReferenceKind.Method => Images.Method, - MemberReferenceKind.Field => Images.Field, - _ => Images.Class, + MemberReferenceKind.Method => Images.MethodReference, + MemberReferenceKind.Field => Images.FieldReference, + _ => throw new NotSupportedException(), }; public string Signature => resolvedMember is IMethod m ? Language.MethodToString(m, false, false, false) : Language.FieldToString((IField)resolvedMember, false, false, false); diff --git a/ILSpy/TreeNodes/TypeReferenceTreeNode.cs b/ILSpy/TreeNodes/TypeReferenceTreeNode.cs index 36ddc15b8c..d8039181cf 100644 --- a/ILSpy/TreeNodes/TypeReferenceTreeNode.cs +++ b/ILSpy/TreeNodes/TypeReferenceTreeNode.cs @@ -45,7 +45,7 @@ public TypeReferenceTreeNode(MetadataModule module, TypeReferenceMetadata r) public override object Text => Language.TypeToString(resolvedType, includeNamespace: false) + GetSuffixString(r.Handle); - public override object Icon => Images.Class; + public override object Icon => Images.TypeReference; protected override void LoadChildren() {