Skip to content

Commit

Permalink
Added new icons for TypeReference, ExportedType and MemberReference
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Mar 15, 2024
1 parent 71d2faf commit 661c411
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 34 deletions.
86 changes: 86 additions & 0 deletions ILSpy/Images/ExportOverlay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions ILSpy/Images/ExportOverlay.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="12.444443702697754" Y="12.444443702697754" />
</DrawingGroup.Transform>
<DrawingGroup Opacity="1" Transform="0.5625,0,0,1,7,12.444445">
<GeometryDrawing Geometry="F1 M16,16z M0,0z M16,-12.444444L16,3.5555556 -12.444444,3.5555556 -12.444444,-12.444444z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FFF6F6F6" Opacity="0" />
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup>
<DrawingGroup Opacity="1" Transform="0.5625,0,0,0.5625,7,7">
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1 M16,16z M0,0z M5.793,0.879L8.621,3.707 7.328,5 10.5,5C13.533,5 16,7.467 16,10.5 16,13.532 13.533,16 10.5,16L9.5,16 9.5,12 10.5,12C11.327,12 12,11.327 12,10.5 12,9.673 11.327,9 10.5,9L7.328,9 8.621,10.293 5.793,13.121 0,7.328 0,6.672z" />
</DrawingGroup>
<DrawingGroup Opacity="1" Transform="0.5625,0,0,0.5625,7,7">
<GeometryDrawing Brush="#FF00539C" Geometry="F1 M16,16z M0,0z M5.793,2.293L7.207,3.707 4.914,6 10.5,6C12.981,6 15,8.019 15,10.5 15,12.981 12.981,15 10.5,15L10.5,13C11.878,13 13,11.879 13,10.5 13,9.121 11.878,8 10.5,8L4.914,8 7.207,10.293 5.793,11.707 1.086,7z" />
</DrawingGroup>
</DrawingGroup>
81 changes: 48 additions & 33 deletions ILSpy/Images/Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand All @@ -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))
Expand Down Expand Up @@ -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<TypeIcon>
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ILSpy/Images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand Down Expand Up @@ -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) | |
Expand Down
55 changes: 55 additions & 0 deletions ILSpy/Images/ReferenceOverlay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions ILSpy/Images/ReferenceOverlay.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<DrawingGroup Opacity="1">
<GeometryDrawing Geometry="F1 M16,16z M0,0z M0,0L16,0 16,16 0,16z">
<GeometryDrawing.Brush>
<SolidColorBrush Color="#FFF6F6F6" Opacity="0" />
</GeometryDrawing.Brush>
</GeometryDrawing>
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1 M16,16z M0,0z M9,9L9,16 16,16 16,9z" />
</DrawingGroup>
<GeometryDrawing Brush="#FF424242" Geometry="F1 M16,16z M0,0z M10,10L10,15 15,15 15,10 10,10z M14,13L13,14 13,12.5 11.5,14 11,13.5 12.5,12 11,12 12,11 14,11 14,13z" />
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1 M16,16z M0,0z M14,11L14,13 13,14 13,12.5 11.5,14 11,13.5 12.5,12 11,12 12,11z" />
</DrawingGroup>

0 comments on commit 661c411

Please sign in to comment.