From acff6a7cc9ea30bfb7c19038e71eb1a6282fb4f8 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 27 Feb 2024 15:34:15 -0300 Subject: [PATCH 1/3] Add `AutodeskIconGeneratorUtils` --- CHANGELOG.md | 7 ++++ README.md | 1 + .../Extensions/AutodeskIconGeneratorUtils.cs | 40 +++++++++++++++++++ .../Extensions/ImageGeneratorUtils.cs | 21 ---------- RevitAddin.CommandLoader/Revit/App.cs | 2 +- RevitAddin.CommandLoader/Revit/CodeSamples.cs | 1 + .../RevitAddin.CommandLoader.csproj | 2 +- .../ViewModels/CompileViewModel.cs | 2 +- .../Views/CompileView.xaml.cs | 1 + 9 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 RevitAddin.CommandLoader/Extensions/AutodeskIconGeneratorUtils.cs delete mode 100644 RevitAddin.CommandLoader/Extensions/ImageGeneratorUtils.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index d2275ab..f38c2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.1.1] / 2024-02-27 +### Features +- Support icons in dark theme. +### Updated +- Add `AutodeskIconGeneratorUtils`. + ## [1.1.0] / 2024-02-17 ### Features - Support net core plugin. @@ -59,6 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - [x] AutoUpdater [vNext]: ../../compare/1.0.0...HEAD +[1.1.1]: ../../compare/1.1.0...1.1.1 [1.1.0]: ../../compare/1.0.6...1.1.0 [1.0.6]: ../../compare/1.0.5...1.0.6 [1.0.5]: ../../compare/1.0.4...1.0.5 diff --git a/README.md b/README.md index 50f8019..9bb0b3f 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ Just copy the `gist` link in the `RevitAddin.CommandLoader` compiler and execute * [CommandVersion](https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e) - File with Revit defines. * [CommandCreate](https://gist.github.com/ricaun/4f62b8650d29f1ff837e7e77f9e8b552) - Multiple file each with a `IExternalCommand`. +* [CommandTheme](https://gist.github.com/ricaun/86334ff6560e3e8c4671148c5c995b39) - Commands to change `UITheme`. ## Resources diff --git a/RevitAddin.CommandLoader/Extensions/AutodeskIconGeneratorUtils.cs b/RevitAddin.CommandLoader/Extensions/AutodeskIconGeneratorUtils.cs new file mode 100644 index 0000000..e3cfe99 --- /dev/null +++ b/RevitAddin.CommandLoader/Extensions/AutodeskIconGeneratorUtils.cs @@ -0,0 +1,40 @@ +using Autodesk.Revit.UI; +using System; + +namespace RevitAddin.CommandLoader.Extensions +{ + public static class AutodeskIconGeneratorUtils + { + private static string[] icons = new[] { "Grey", "Red", "Yellow", "Green", "Cyan", "Blue", "Purple", "Pink", "Brown" }; + private static string[] types = new[] { "Box", "Cube" }; + private static string[] themes = new[] { "", "Dark" }; + private static char separetor = '-'; + private static string extension = ".ico"; + private static string url = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.0.0/"; + + private static int icon = 0; + public static bool IsDark => UIThemeManager.CurrentTheme == UITheme.Dark; + public static string GetBox() + { + return url + CreateIcon(icon++, 0, IsDark ? 1 : 0); + } + + public static string GetCube() + { + return url + CreateIcon(icon++, 1, IsDark ? 1 : 0); + } + + private static string CreateIcon(int icon = 0, int type = 0, int theme = 0) + { + var typeStr = types[type % types.Length]; + var iconStr = icons[icon % icons.Length]; + var themeStr = themes[theme % themes.Length]; + + var name = $"{typeStr}{separetor}{iconStr}"; + if (string.IsNullOrEmpty(themeStr) == false) + name += $"{separetor}{themeStr}"; + + return $"{name}{extension}"; + } + } +} diff --git a/RevitAddin.CommandLoader/Extensions/ImageGeneratorUtils.cs b/RevitAddin.CommandLoader/Extensions/ImageGeneratorUtils.cs deleted file mode 100644 index 5a0c7bf..0000000 --- a/RevitAddin.CommandLoader/Extensions/ImageGeneratorUtils.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; - -namespace RevitAddin.CommandLoader.Extensions -{ - public static class ImageGeneratorUtils - { - private static int imageNumber = 0; - public static string GetLargeImageUri() - { - char GetLetter() - { - var num = imageNumber++ % 26; - char let = (char)('a' + num); - return let; - } - var baseImage = @"https://img.icons8.com/small/32/111111/circled-{0}.png"; - var imageLarge = string.Format(baseImage, GetLetter()); - return imageLarge; - } - } -} diff --git a/RevitAddin.CommandLoader/Revit/App.cs b/RevitAddin.CommandLoader/Revit/App.cs index c807e3c..1c178ed 100644 --- a/RevitAddin.CommandLoader/Revit/App.cs +++ b/RevitAddin.CommandLoader/Revit/App.cs @@ -109,7 +109,7 @@ public static void CreateCommands(Assembly assembly) if (needImage) { - button.SetLargeImage(ImageGeneratorUtils.GetLargeImageUri()); + button.SetLargeImage(AutodeskIconGeneratorUtils.GetCube()); } } } diff --git a/RevitAddin.CommandLoader/Revit/CodeSamples.cs b/RevitAddin.CommandLoader/Revit/CodeSamples.cs index 7d33e2f..fcd1037 100644 --- a/RevitAddin.CommandLoader/Revit/CodeSamples.cs +++ b/RevitAddin.CommandLoader/Revit/CodeSamples.cs @@ -6,6 +6,7 @@ namespace RevitAddin.CommandLoader.Revit { public class CodeSamples { + public static string CommandThemeGist => "https://gist.github.com/ricaun/86334ff6560e3e8c4671148c5c995b39"; public static string CommandVersionGist => "https://gist.github.com/ricaun/200a576c3baa45cba034ceedac1e708e"; public static string Command => @"using System; diff --git a/RevitAddin.CommandLoader/RevitAddin.CommandLoader.csproj b/RevitAddin.CommandLoader/RevitAddin.CommandLoader.csproj index 9d94817..338b378 100644 --- a/RevitAddin.CommandLoader/RevitAddin.CommandLoader.csproj +++ b/RevitAddin.CommandLoader/RevitAddin.CommandLoader.csproj @@ -108,7 +108,7 @@ RevitAddin.CommandLoader - 1.1.0 + 1.1.1 {82070359-36DA-4441-A59D-9018B6A8B348} diff --git a/RevitAddin.CommandLoader/ViewModels/CompileViewModel.cs b/RevitAddin.CommandLoader/ViewModels/CompileViewModel.cs index c0d31cb..85feea3 100644 --- a/RevitAddin.CommandLoader/ViewModels/CompileViewModel.cs +++ b/RevitAddin.CommandLoader/ViewModels/CompileViewModel.cs @@ -21,7 +21,7 @@ public class CompileViewModel : ObservableObject #region Public Properties public string Text { get; set; } = #if DEBUG - CodeSamples.CommandVersionGist; + CodeSamples.CommandThemeGist; #else CodeSamples.Command; #endif diff --git a/RevitAddin.CommandLoader/Views/CompileView.xaml.cs b/RevitAddin.CommandLoader/Views/CompileView.xaml.cs index ca1c8da..ae66a82 100644 --- a/RevitAddin.CommandLoader/Views/CompileView.xaml.cs +++ b/RevitAddin.CommandLoader/Views/CompileView.xaml.cs @@ -9,6 +9,7 @@ public CompileView() { InitializeComponent(); InitializeWindow(); + this.KeyDown += (s, e) => { if (e.Key == System.Windows.Input.Key.Escape) { this.Close(); } }; } #region InitializeWindow From 299725b57dc265f98f9066453b26271f84407616 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 27 Feb 2024 15:42:42 -0300 Subject: [PATCH 2/3] Window close with `Esc` key. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f38c2a7..73238a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Support icons in dark theme. ### Updated - Add `AutodeskIconGeneratorUtils`. +- Window close with `Esc` key. ## [1.1.0] / 2024-02-17 ### Features From d785cb36426d82c76f7ae5c5766ceb87995bd9c1 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 27 Feb 2024 15:47:07 -0300 Subject: [PATCH 3/3] Update Readme --- CHANGELOG.md | 2 +- README.md | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73238a0..6615e3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.1.1] / 2024-02-27 ### Features -- Support icons in dark theme. +- Support [Autodesk.Icon](https://github.com/ricaun-io/Autodesk.Icon.Example) in dark theme. ### Updated - Add `AutodeskIconGeneratorUtils`. - Window close with `Esc` key. diff --git a/README.md b/README.md index 9bb0b3f..68a84f0 100644 --- a/README.md +++ b/README.md @@ -101,9 +101,9 @@ Videos in Portuguese with the creation of this project. [![VideoIma1]][Video1] -Live videos in English about this project. +Videos in English about this project. -[![VideoIma2]][Video2] [![VideoIma3]][Video3] +[![VideoIma2]][Video2] [![VideoIma3]][Video3] [![VideoIma4]][Video4] ## License @@ -120,4 +120,5 @@ Do you like this project? Please [star this project on GitHub](../../stargazers) [VideoIma2]: https://img.youtube.com/vi/hI21lxm4EVU/mqdefault.jpg [Video3]: https://youtu.be/cOu7vjZnyXc [VideoIma3]: https://img.youtube.com/vi/cOu7vjZnyXc/mqdefault.jpg - +[Video4]: https://youtu.be/y2GkFXoFwow +[VideoIma4]: https://img.youtube.com/vi/y2GkFXoFwow/mqdefault.jpg