Browse Source

Add tree node icon for Static Class.

pull/170/head
Ed Harvey 14 years ago
parent
commit
637a91236c
  1. 2
      ILSpy/ILSpy.csproj
  2. 5
      ILSpy/Images/Images.cs
  3. BIN
      ILSpy/Images/StaticClass.png
  4. 3
      ILSpy/Images/TypeIcon.cs
  5. 18
      ILSpy/TreeNodes/TypeTreeNode.cs

2
ILSpy/ILSpy.csproj

@ -236,6 +236,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Images\Class.png" /> <Resource Include="Images\Class.png" />
<Resource Include="Images\StaticClass.png" />
<Resource Include="Images\Delegate.png" /> <Resource Include="Images\Delegate.png" />
<Resource Include="Images\Enum.png" /> <Resource Include="Images\Enum.png" />
<Resource Include="Images\Field.png" /> <Resource Include="Images\Field.png" />
@ -303,6 +304,5 @@
<Name>ICSharpCode.TreeView</Name> <Name>ICSharpCode.TreeView</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>

5
ILSpy/Images/Images.cs

@ -65,6 +65,7 @@ namespace ICSharpCode.ILSpy
public static readonly BitmapImage Interface = LoadBitmap("Interface"); public static readonly BitmapImage Interface = LoadBitmap("Interface");
public static readonly BitmapImage Delegate = LoadBitmap("Delegate"); public static readonly BitmapImage Delegate = LoadBitmap("Delegate");
public static readonly BitmapImage Enum = LoadBitmap("Enum"); public static readonly BitmapImage Enum = LoadBitmap("Enum");
public static readonly BitmapImage StaticClass = LoadBitmap("StaticClass");
public static readonly BitmapImage Field = LoadBitmap("Field"); public static readonly BitmapImage Field = LoadBitmap("Field");
@ -133,6 +134,7 @@ namespace ICSharpCode.ILSpy
PreloadPublicIconToCache(TypeIcon.Struct, Images.Struct); PreloadPublicIconToCache(TypeIcon.Struct, Images.Struct);
PreloadPublicIconToCache(TypeIcon.Interface, Images.Interface); PreloadPublicIconToCache(TypeIcon.Interface, Images.Interface);
PreloadPublicIconToCache(TypeIcon.Delegate, Images.Delegate); PreloadPublicIconToCache(TypeIcon.Delegate, Images.Delegate);
PreloadPublicIconToCache(TypeIcon.StaticClass, Images.StaticClass);
} }
protected override ImageSource GetBaseImage(TypeIcon icon) protected override ImageSource GetBaseImage(TypeIcon icon)
@ -154,6 +156,9 @@ namespace ICSharpCode.ILSpy
case TypeIcon.Delegate: case TypeIcon.Delegate:
baseImage = Images.Delegate; baseImage = Images.Delegate;
break; break;
case TypeIcon.StaticClass:
baseImage = Images.StaticClass;
break;
default: default:
throw new NotSupportedException(); throw new NotSupportedException();
} }

BIN
ILSpy/Images/StaticClass.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

3
ILSpy/Images/TypeIcon.cs

@ -26,6 +26,7 @@ namespace ICSharpCode.ILSpy
Enum, Enum,
Struct, Struct,
Interface, Interface,
Delegate Delegate,
StaticClass
} }
} }

18
ILSpy/TreeNodes/TypeTreeNode.cs

@ -146,8 +146,10 @@ namespace ICSharpCode.ILSpy.TreeNodes
} else { } else {
if (type.IsInterface) if (type.IsInterface)
return TypeIcon.Interface; return TypeIcon.Interface;
else if (type.BaseType != null && type.BaseType.FullName == typeof(MulticastDelegate).FullName) else if (IsDelegate(type))
return TypeIcon.Delegate; return TypeIcon.Delegate;
else if (IsStaticClass(type))
return TypeIcon.StaticClass;
else else
return TypeIcon.Class; return TypeIcon.Class;
} }
@ -178,6 +180,20 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
return overlay; return overlay;
} }
private static bool IsDelegate(TypeDefinition type)
{
return type.BaseType != null && type.BaseType.FullName == typeof(MulticastDelegate).FullName;
}
private static bool IsStaticClass(TypeDefinition type)
{
if(type.IsSealed)
return !type.Methods.Where(m => m.Name == ".ctor").Any(m => !m.IsPrivate);
return false;
}
#endregion #endregion
MemberReference IMemberTreeNode.Member { MemberReference IMemberTreeNode.Member {

Loading…
Cancel
Save