Get an icon from key icon key null if not found
(string name)
| 80 | /// <param name="name">icon key</param> |
| 81 | /// <returns>null if not found</returns> |
| 82 | public static StreamGeometry? GetIcon(string name) |
| 83 | { |
| 84 | // May not exist |
| 85 | if (!Application.Current!.Styles.TryGetResource(name, null, out object? resource)) |
| 86 | { |
| 87 | #if DEBUG |
| 88 | Debug.WriteLine($"ResourceLocator - Failed to find icon '{name}'"); |
| 89 | #endif // DEBUG |
| 90 | return null; |
| 91 | } |
| 92 | |
| 93 | #if DEBUG |
| 94 | if (resource is not StreamGeometry) |
| 95 | { |
| 96 | Debug.WriteLine($"ResourceLocator - Failed to convert resource '{name}' from {resource?.GetType()} to StreamGeometry"); |
| 97 | } |
| 98 | #endif // DEBUG |
| 99 | |
| 100 | return resource as StreamGeometry; |
| 101 | } |
| 102 | } |
| 103 | } |
no outgoing calls
no test coverage detected