private static ImageInfo FindBestMatch( Type type, Assembly assembly, string[] resourceNames, Size desiredSize, MatchNameDelegate matchName) { Fx.Assert(type != null, "FindBestMatch - type parameter should not be null"); Fx.Assert(resourceNames != null && resourceNames.Length > 0, "resourceNames parameter should not be null"); Fx.Assert(matchName != null, "matchName parameter should not be null"); ImageInfo bestMatch = null; for (int i = 0; i < resourceNames.Length; i++) { string extension = Path.GetExtension(resourceNames[i]); if (!IsExtensionSupported(extension)) { continue; } if (!matchName(StripIconExtension(resourceNames[i]))) { continue; } ImageInfo info = ProcessResource(assembly, resourceNames[i]); if (info == null) { continue; } // Try to match the found resource to the requested size float sizeMatch = info.Match(desiredSize); // Check for exact size match if (sizeMatch < float.Epsilon) { return info; } // Keep the best image found so far if (bestMatch == null || bestMatch.LastMatch > sizeMatch) { bestMatch = info; } } return bestMatch; }
private static ImageInfo FindBestMatch( Type type, Assembly assembly, string[] resourceNames, Size desiredSize, MatchNameDelegate matchName) { Fx.Assert(type != null, "FindBestMatch - type parameter should not be null"); Fx.Assert(resourceNames != null && resourceNames.Length > 0, "resourceNames parameter should not be null"); Fx.Assert(matchName != null, "matchName parameter should not be null"); ImageInfo bestMatch = null; for (int i = 0; i < resourceNames.Length; i++) { string extension = Path.GetExtension(resourceNames[i]); if (!IsExtensionSupported(extension)) { continue; } if (!matchName(StripIconExtension(resourceNames[i]))) { continue; } ImageInfo info = ProcessResource(assembly, resourceNames[i]); if (info == null) { continue; } // Try to match the found resource to the requested size float sizeMatch = info.Match(desiredSize); // Check for exact size match if (sizeMatch < float.Epsilon) { return(info); } // Keep the best image found so far if (bestMatch == null || bestMatch.LastMatch > sizeMatch) { bestMatch = info; } } return(bestMatch); }