mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Add extension overlay icon
This commit is contained in:
+32
-27
@@ -119,6 +119,7 @@ namespace ICSharpCode.ILSpy
|
||||
private static readonly ImageSource OverlayReference = Load("ReferenceOverlay");
|
||||
|
||||
private static readonly ImageSource OverlayStatic = Load("OverlayStatic");
|
||||
private static readonly ImageSource OverlayExtension = Load("OverlayExtension");
|
||||
|
||||
public static readonly ImageSource TypeReference = GetIcon("ShowPublicOnly", "ReferenceOverlay");
|
||||
public static readonly ImageSource MethodReference = GetIcon("Method", "ReferenceOverlay");
|
||||
@@ -203,16 +204,16 @@ namespace ICSharpCode.ILSpy
|
||||
private static readonly TypeIconCache typeIconCache = new TypeIconCache();
|
||||
private static readonly MemberIconCache memberIconCache = new MemberIconCache();
|
||||
|
||||
public static ImageSource GetIcon(TypeIcon icon, AccessOverlayIcon overlay, bool isStatic = false)
|
||||
public static ImageSource GetIcon(TypeIcon icon, AccessOverlayIcon overlay, bool isStatic = false, bool isExtension = false)
|
||||
{
|
||||
lock (typeIconCache)
|
||||
return typeIconCache.GetIcon(icon, overlay, isStatic);
|
||||
return typeIconCache.GetIcon(icon, overlay, isStatic, isExtension);
|
||||
}
|
||||
|
||||
public static ImageSource GetIcon(MemberIcon icon, AccessOverlayIcon overlay, bool isStatic)
|
||||
public static ImageSource GetIcon(MemberIcon icon, AccessOverlayIcon overlay, bool isStatic, bool isExtension)
|
||||
{
|
||||
lock (memberIconCache)
|
||||
return memberIconCache.GetIcon(icon, overlay, isStatic);
|
||||
return memberIconCache.GetIcon(icon, overlay, isStatic, isExtension);
|
||||
}
|
||||
|
||||
public static AccessOverlayIcon GetOverlayIcon(Accessibility accessibility)
|
||||
@@ -236,30 +237,30 @@ namespace ICSharpCode.ILSpy
|
||||
}
|
||||
}
|
||||
|
||||
private static ImageSource GetIcon(string baseImage, string overlay = null, bool isStatic = false)
|
||||
private static ImageSource GetIcon(string baseImage, string overlay = null, bool isStatic = false, bool isExtension = false)
|
||||
{
|
||||
ImageSource baseImageSource = Load(baseImage);
|
||||
ImageSource overlayImageSource = overlay != null ? Load(overlay) : null;
|
||||
|
||||
return CreateOverlayImage(baseImageSource, overlayImageSource, isStatic);
|
||||
return CreateOverlayImage(baseImageSource, overlayImageSource, isStatic, isExtension);
|
||||
}
|
||||
|
||||
private static ImageSource CreateOverlayImage(ImageSource baseImage, ImageSource overlay, bool isStatic)
|
||||
private static ImageSource CreateOverlayImage(ImageSource baseImage, ImageSource overlay, bool isStatic, bool isExtension)
|
||||
{
|
||||
var group = new DrawingGroup();
|
||||
var baseDrawingGroup = new DrawingGroup();
|
||||
|
||||
Drawing baseDrawing = new ImageDrawing(baseImage, iconRect);
|
||||
|
||||
if (overlay != null)
|
||||
baseDrawingGroup.Children.Add(baseDrawing);
|
||||
|
||||
if (isExtension)
|
||||
{
|
||||
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);
|
||||
var extensionGroup = new DrawingGroup();
|
||||
extensionGroup.Children.Add(baseDrawingGroup);
|
||||
baseDrawingGroup.Transform = new ScaleTransform(0.8, 8.0);
|
||||
extensionGroup.Children.Add(new ImageDrawing(Images.OverlayExtension, iconRect));
|
||||
baseDrawingGroup = extensionGroup;
|
||||
}
|
||||
|
||||
if (isStatic)
|
||||
@@ -267,6 +268,14 @@ namespace ICSharpCode.ILSpy
|
||||
group.Children.Add(new ImageDrawing(Images.OverlayStatic, iconRect));
|
||||
}
|
||||
|
||||
if (overlay != null)
|
||||
{
|
||||
baseDrawingGroup.Transform = new ScaleTransform(0.8, 0.8);
|
||||
group.Children.Add(new ImageDrawing(overlay, iconRect));
|
||||
}
|
||||
|
||||
group.Children.Add(baseDrawingGroup);
|
||||
|
||||
var image = new DrawingImage(group);
|
||||
if (image.CanFreeze)
|
||||
{
|
||||
@@ -330,7 +339,6 @@ namespace ICSharpCode.ILSpy
|
||||
PreloadPublicIconToCache(MemberIcon.Constructor, Images.Constructor);
|
||||
PreloadPublicIconToCache(MemberIcon.VirtualMethod, Images.VirtualMethod);
|
||||
PreloadPublicIconToCache(MemberIcon.Operator, Images.Operator);
|
||||
PreloadPublicIconToCache(MemberIcon.ExtensionMethod, Images.ExtensionMethod);
|
||||
PreloadPublicIconToCache(MemberIcon.PInvokeMethod, Images.PInvokeMethod);
|
||||
PreloadPublicIconToCache(MemberIcon.Event, Images.Event);
|
||||
}
|
||||
@@ -370,9 +378,6 @@ namespace ICSharpCode.ILSpy
|
||||
case MemberIcon.Operator:
|
||||
baseImage = Images.Operator;
|
||||
break;
|
||||
case MemberIcon.ExtensionMethod:
|
||||
baseImage = Images.ExtensionMethod;
|
||||
break;
|
||||
case MemberIcon.PInvokeMethod:
|
||||
baseImage = Images.PInvokeMethod;
|
||||
break;
|
||||
@@ -389,35 +394,35 @@ namespace ICSharpCode.ILSpy
|
||||
|
||||
private abstract class IconCache<T>
|
||||
{
|
||||
private readonly Dictionary<(T, AccessOverlayIcon, bool), ImageSource> cache = new Dictionary<(T, AccessOverlayIcon, bool), ImageSource>();
|
||||
private readonly Dictionary<(T, AccessOverlayIcon, bool, bool), ImageSource> cache = new Dictionary<(T, AccessOverlayIcon, bool, bool), ImageSource>();
|
||||
|
||||
protected void PreloadPublicIconToCache(T icon, ImageSource image)
|
||||
{
|
||||
var iconKey = (icon, AccessOverlayIcon.Public, false);
|
||||
var iconKey = (icon, AccessOverlayIcon.Public, false, false);
|
||||
cache.Add(iconKey, image);
|
||||
}
|
||||
|
||||
public ImageSource GetIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
|
||||
public ImageSource GetIcon(T icon, AccessOverlayIcon overlay, bool isStatic, bool isExtension)
|
||||
{
|
||||
var iconKey = (icon, overlay, isStatic);
|
||||
var iconKey = (icon, overlay, isStatic, isExtension);
|
||||
if (cache.ContainsKey(iconKey))
|
||||
{
|
||||
return cache[iconKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageSource result = BuildMemberIcon(icon, overlay, isStatic);
|
||||
ImageSource result = BuildMemberIcon(icon, overlay, isStatic, isExtension);
|
||||
cache.Add(iconKey, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private ImageSource BuildMemberIcon(T icon, AccessOverlayIcon overlay, bool isStatic)
|
||||
private ImageSource BuildMemberIcon(T icon, AccessOverlayIcon overlay, bool isStatic, bool isExtension)
|
||||
{
|
||||
ImageSource baseImage = GetBaseImage(icon);
|
||||
ImageSource overlayImage = GetOverlayImage(overlay);
|
||||
|
||||
return CreateOverlayImage(baseImage, overlayImage, isStatic);
|
||||
return CreateOverlayImage(baseImage, overlayImage, isStatic, isExtension);
|
||||
}
|
||||
|
||||
protected abstract ImageSource GetBaseImage(T icon);
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace ICSharpCode.ILSpy
|
||||
Constructor,
|
||||
VirtualMethod,
|
||||
Operator,
|
||||
ExtensionMethod,
|
||||
PInvokeMethod,
|
||||
Event
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
viewBox="0 0 16 16"
|
||||
enable-background="new 0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg2"
|
||||
sodipodi:docname="ExtensionOverlay.svg"
|
||||
inkscape:version="1.4.2 (f4327f4, 2025-05-13)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="namedview2"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:zoom="72.9375"
|
||||
inkscape:cx="8"
|
||||
inkscape:cy="8"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1369"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="373"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg2" />
|
||||
<style
|
||||
type="text/css"
|
||||
id="style1">.icon-canvas-transparent{opacity:0;fill:#F6F6F6;} .icon-vs-out{fill:#F6F6F6;} .icon-vs-bg{fill:#424242;} .icon-vs-fg{fill:#F0EFF1;} .icon-vs-action-purple{fill:#652D90;}</style>
|
||||
<path
|
||||
class="icon-canvas-transparent"
|
||||
d="M 16,16 H 0 V 0 h 16 z"
|
||||
id="canvas"
|
||||
style="display:inline" />
|
||||
<path
|
||||
class="icon-vs-out"
|
||||
d="M 14.47,9.056 14,9.525 V 5 H 10 V 9.525 L 9.53,9.055 8,10.586 v 1.889 L 11.525,16 h 0.949 L 16,12.475 v -1.889 z"
|
||||
id="outline"
|
||||
style="display:inline"
|
||||
sodipodi:nodetypes="ccccccccccccc" />
|
||||
<path
|
||||
class="icon-vs-bg"
|
||||
d="M 13,9 H 11 V 8 h 2 z m 0,-3 h -2 v 1 h 2 z M 14.47,10.47 13,11.939 V 10 h -2 v 1.939 L 9.53,10.469 8.47,11.53 12,15.06 15.53,11.53 Z"
|
||||
id="path2" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
@@ -0,0 +1,11 @@
|
||||
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Geometry="F1 M16,16z M0,0z M16,16L0,16 0,0 16,0z">
|
||||
<GeometryDrawing.Brush>
|
||||
<SolidColorBrush Color="#FFF6F6F6" Opacity="0" />
|
||||
</GeometryDrawing.Brush>
|
||||
</GeometryDrawing>
|
||||
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1 M16,16z M0,0z M14.47,9.056L14,9.525 14,5 10,5 10,9.525 9.53,9.055 8,10.586 8,12.475 11.525,16 12.474,16 16,12.475 16,10.586z" />
|
||||
<GeometryDrawing Brush="#FF424242" Geometry="F1 M16,16z M0,0z M13,9L11,9 11,8 13,8z M13,6L11,6 11,7 13,7z M14.47,10.47L13,11.939 13,10 11,10 11,11.939 9.53,10.469 8.47,11.53 12,15.06 15.53,11.53z" />
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
@@ -68,7 +68,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
|
||||
public static ImageSource GetIcon(IEvent @event)
|
||||
{
|
||||
return Images.GetIcon(MemberIcon.Event, Images.GetOverlayIcon(@event.Accessibility), @event.IsStatic);
|
||||
return Images.GetIcon(MemberIcon.Event, Images.GetOverlayIcon(@event.Accessibility), @event.IsStatic, false);
|
||||
}
|
||||
|
||||
public override FilterResult Filter(LanguageSettings settings)
|
||||
|
||||
@@ -61,15 +61,15 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
public static ImageSource GetIcon(IField field)
|
||||
{
|
||||
if (field.DeclaringType.Kind == TypeKind.Enum && field.ReturnType.Kind == TypeKind.Enum)
|
||||
return Images.GetIcon(MemberIcon.EnumValue, Images.GetOverlayIcon(field.Accessibility), false);
|
||||
return Images.GetIcon(MemberIcon.EnumValue, Images.GetOverlayIcon(field.Accessibility), false, false);
|
||||
|
||||
if (field.IsConst)
|
||||
return Images.GetIcon(MemberIcon.Literal, Images.GetOverlayIcon(field.Accessibility), false);
|
||||
return Images.GetIcon(MemberIcon.Literal, Images.GetOverlayIcon(field.Accessibility), false, false);
|
||||
|
||||
if (field.IsReadOnly)
|
||||
return Images.GetIcon(MemberIcon.FieldReadOnly, Images.GetOverlayIcon(field.Accessibility), field.IsStatic);
|
||||
return Images.GetIcon(MemberIcon.FieldReadOnly, Images.GetOverlayIcon(field.Accessibility), field.IsStatic, false);
|
||||
|
||||
return Images.GetIcon(MemberIcon.Field, Images.GetOverlayIcon(field.Accessibility), field.IsStatic);
|
||||
return Images.GetIcon(MemberIcon.Field, Images.GetOverlayIcon(field.Accessibility), field.IsStatic, false);
|
||||
}
|
||||
|
||||
public override FilterResult Filter(LanguageSettings settings)
|
||||
|
||||
@@ -61,19 +61,19 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
public static ImageSource GetIcon(IMethod method)
|
||||
{
|
||||
if (method.IsOperator)
|
||||
return Images.GetIcon(MemberIcon.Operator, Images.GetOverlayIcon(method.Accessibility), false);
|
||||
return Images.GetIcon(MemberIcon.Operator, Images.GetOverlayIcon(method.Accessibility), false, method.IsExtensionMethod);
|
||||
|
||||
if (method.IsExtensionMethod)
|
||||
return Images.GetIcon(MemberIcon.ExtensionMethod, Images.GetOverlayIcon(method.Accessibility), false);
|
||||
return Images.GetIcon(MemberIcon.Method, Images.GetOverlayIcon(method.Accessibility), false, true);
|
||||
|
||||
if (method.IsConstructor)
|
||||
return Images.GetIcon(MemberIcon.Constructor, Images.GetOverlayIcon(method.Accessibility), method.IsStatic);
|
||||
return Images.GetIcon(MemberIcon.Constructor, Images.GetOverlayIcon(method.Accessibility), method.IsStatic, false);
|
||||
|
||||
if (!method.HasBody && method.HasAttribute(KnownAttribute.DllImport))
|
||||
return Images.GetIcon(MemberIcon.PInvokeMethod, Images.GetOverlayIcon(method.Accessibility), true);
|
||||
return Images.GetIcon(MemberIcon.PInvokeMethod, Images.GetOverlayIcon(method.Accessibility), true, false);
|
||||
|
||||
return Images.GetIcon(method.IsVirtual ? MemberIcon.VirtualMethod : MemberIcon.Method,
|
||||
Images.GetOverlayIcon(method.Accessibility), method.IsStatic);
|
||||
Images.GetOverlayIcon(method.Accessibility), method.IsStatic, false);
|
||||
}
|
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
|
||||
public static ImageSource GetIcon(IProperty property)
|
||||
{
|
||||
return Images.GetIcon(property.IsIndexer ? MemberIcon.Indexer : MemberIcon.Property,
|
||||
Images.GetOverlayIcon(property.Accessibility), property.IsStatic);
|
||||
Images.GetOverlayIcon(property.Accessibility), property.IsStatic, false);
|
||||
}
|
||||
|
||||
public override FilterResult Filter(LanguageSettings settings)
|
||||
|
||||
Reference in New Issue
Block a user