|
| 1 | +using Autodesk.Revit.UI; |
| 2 | +using System; |
| 3 | + |
| 4 | +namespace RevitAddin.CommandLoader.Extensions |
| 5 | +{ |
| 6 | + public static class AutodeskIconGeneratorUtils |
| 7 | + { |
| 8 | + private static string[] icons = new[] { "Grey", "Red", "Yellow", "Green", "Cyan", "Blue", "Purple", "Pink", "Brown" }; |
| 9 | + private static string[] types = new[] { "Box", "Cube" }; |
| 10 | + private static string[] themes = new[] { "", "Dark" }; |
| 11 | + private static char separetor = '-'; |
| 12 | + private static string extension = ".ico"; |
| 13 | + private static string url = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.0.0/"; |
| 14 | + |
| 15 | + private static int icon = 0; |
| 16 | + public static bool IsDark => UIThemeManager.CurrentTheme == UITheme.Dark; |
| 17 | + public static string GetBox() |
| 18 | + { |
| 19 | + return url + CreateIcon(icon++, 0, IsDark ? 1 : 0); |
| 20 | + } |
| 21 | + |
| 22 | + public static string GetCube() |
| 23 | + { |
| 24 | + return url + CreateIcon(icon++, 1, IsDark ? 1 : 0); |
| 25 | + } |
| 26 | + |
| 27 | + private static string CreateIcon(int icon = 0, int type = 0, int theme = 0) |
| 28 | + { |
| 29 | + var typeStr = types[type % types.Length]; |
| 30 | + var iconStr = icons[icon % icons.Length]; |
| 31 | + var themeStr = themes[theme % themes.Length]; |
| 32 | + |
| 33 | + var name = $"{typeStr}{separetor}{iconStr}"; |
| 34 | + if (string.IsNullOrEmpty(themeStr) == false) |
| 35 | + name += $"{separetor}{themeStr}"; |
| 36 | + |
| 37 | + return $"{name}{extension}"; |
| 38 | + } |
| 39 | + } |
| 40 | +} |
0 commit comments