Skip to content

Commit

Permalink
Fix on ValueSet.GetItemIcon.
Browse files Browse the repository at this point in the history
  • Loading branch information
kike-garbo committed Oct 11, 2024
1 parent d13d386 commit cc10c97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/RhinoInside.Revit.GH/Extensions/Grasshopper/Special/ValueSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ public DataCulling Culling
public virtual DataCulling CullingMask => DataCulling.Nulls | DataCulling.Invalids | DataCulling.Duplicates | DataCulling.Empty;

static readonly Dictionary<Type, Bitmap> TypeIcons = new Dictionary<Type, Bitmap>();
protected virtual Bitmap GetItemIcon(T value, Size size)
protected virtual Bitmap GetItemIcon(IGH_Goo value, Size size)
{
var type = value.GetType();
if (TypeIcons.TryGetValue(GetType(), out var icon))
if (TypeIcons.TryGetValue(type, out var icon))
return icon;

var bitmap = default(Bitmap);
Expand All @@ -251,19 +251,19 @@ protected virtual Bitmap GetItemIcon(T value, Size size)
{
// Try with a parameter that has the same name.
var typeName = value.TypeName;
var location = value.GetType().Assembly.Location;
var proxy = Instances.ComponentServer.ObjectProxies.
var assembly = type.Assembly;
var proxies = Instances.ComponentServer.ObjectProxies.
Where
(
x => typeof(IGH_Param).IsAssignableFrom(x.Type) &&
string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) &&
string.Equals(x.Location, location, StringComparison.OrdinalIgnoreCase)
x => x.Kind == GH_ObjectType.CompiledObject &&
typeof(IGH_Param).IsAssignableFrom(x.Type) &&
Equals(x.Type?.Assembly, assembly) &&
string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase)
).
OrderBy(x => !x.SDKCompliant).
ThenBy(x => x.Obsolete).
FirstOrDefault();
ThenBy(x => x.Obsolete);

bitmap = proxy?.Icon;
bitmap = proxies.FirstOrDefault()?.Icon;
}

return TypeIcons[type] = bitmap;
Expand Down
9 changes: 5 additions & 4 deletions src/RhinoInside.Revit.GH/Types/Reference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,14 @@ Bitmap IGH_ItemDescription.GetTypeIcon(Size size)
if (typeName.StartsWith("Revit "))
typeName = typeName.Substring(6);

var location = GetType().Assembly.Location;
var assembly = GetType().Assembly;
var proxy = Instances.ComponentServer.ObjectProxies.
Where
(
x => typeof(IGH_Param).IsAssignableFrom(x.Type) &&
string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase) &&
string.Equals(x.Location, location, StringComparison.OrdinalIgnoreCase)
x => x.Kind == GH_ObjectType.CompiledObject &&
typeof(IGH_Param).IsAssignableFrom(x.Type) &&
Equals(x.Type?.Assembly, assembly) &&
string.Equals(x.Desc.Name, typeName, StringComparison.OrdinalIgnoreCase)
).
OrderBy(x => !x.SDKCompliant).
ThenBy(x => x.Obsolete).
Expand Down

0 comments on commit cc10c97

Please sign in to comment.