diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4046d..29cfb22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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). +## [0.7.1] / 2024-11-11 +### Features +- Support `tiff` files for icon. +### Updated +- Update `GetBitmapFrame` to round `width` that is changed by `dpi`. +### Example +- Add `Cube-Grey-Light.tiff` and `Cube-Grey-Dark.tiff` in `AppTheme`. + ## [0.7.0] / 2024-07-06 - 2024-07-25 ### Features - Auto set image based on the theme of the Ribbon using `light` and `dark` image pattern. @@ -360,6 +368,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - First Release [vNext]: ../../compare/1.0.0...HEAD +[0.7.1]: ../../compare/0.7.0...0.7.1 [0.7.0]: ../../compare/0.6.2...0.7.0 [0.6.2]: ../../compare/0.6.1...0.6.2 [0.6.1]: ../../compare/0.6.0...0.6.1 diff --git a/Directory.Build.props b/Directory.Build.props index 5596472..b243076 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 0.7.0 + 0.7.1-alpha \ No newline at end of file diff --git a/ricaun.Revit.UI.Example/Resources/Cube-Grey-Dark.tiff b/ricaun.Revit.UI.Example/Resources/Cube-Grey-Dark.tiff new file mode 100644 index 0000000..12bc09f Binary files /dev/null and b/ricaun.Revit.UI.Example/Resources/Cube-Grey-Dark.tiff differ diff --git a/ricaun.Revit.UI.Example/Resources/Cube-Grey-Light.tiff b/ricaun.Revit.UI.Example/Resources/Cube-Grey-Light.tiff new file mode 100644 index 0000000..c99ad07 Binary files /dev/null and b/ricaun.Revit.UI.Example/Resources/Cube-Grey-Light.tiff differ diff --git a/ricaun.Revit.UI.Example/Revit/AppTheme.cs b/ricaun.Revit.UI.Example/Revit/AppTheme.cs index e1aeb80..d8aa158 100644 --- a/ricaun.Revit.UI.Example/Revit/AppTheme.cs +++ b/ricaun.Revit.UI.Example/Revit/AppTheme.cs @@ -61,6 +61,37 @@ public Result OnStartup(UIControlledApplication application) ribbonPanel.AddSeparator(); + + { + var buttonTiff = ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff"); + //if (buttonTiff.LargeImage is System.Windows.Media.Imaging.BitmapSource largeImage) + //{ + // System.Console.WriteLine($"{largeImage.GetType().Name} | {largeImage.Width:0}x{largeImage.Height:0} ({largeImage.PixelWidth}x{largeImage.PixelHeight}) {largeImage.DpiX:0}:{largeImage.DpiY:0}"); + //} + //if (buttonTiff.Image is System.Windows.Media.Imaging.BitmapSource smallImage) + //{ + // System.Console.WriteLine($"{smallImage.GetType().Name} | {smallImage.Width:0}x{smallImage.Height:0} ({smallImage.PixelWidth}x{smallImage.PixelHeight}) {smallImage.DpiX:0}:{smallImage.DpiY:0}"); + //} + } + + ribbonPanel.RowStackedItems( + ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff"), + ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff"), + ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff") + ); + ribbonPanel.RowLargeStackedItems( + ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff"), + ribbonPanel.CreatePushButton("Grey") + .SetLargeImage("Resources/Cube-Grey-Light.tiff") + ); + + ribbonPanel.AddSeparator(); + ribbonPanel.FlowStackedItems( ribbonPanel.CreatePushButton("1").SetLargeImage(LIGHT_RED), ribbonPanel.CreatePushButton("2").SetLargeImage(DARK_RED), diff --git a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj index 17d6cdb..855d528 100644 --- a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj +++ b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj @@ -96,6 +96,8 @@ + + @@ -126,6 +128,8 @@ + + diff --git a/ricaun.Revit.UI/BitmapExtension.cs b/ricaun.Revit.UI/BitmapExtension.cs index 78f1f69..59c7515 100644 --- a/ricaun.Revit.UI/BitmapExtension.cs +++ b/ricaun.Revit.UI/BitmapExtension.cs @@ -97,8 +97,9 @@ TImageSource ScaleDownIfWidthIsGreater(TImageSource imageSource, int width) if (width <= 0) return imageSource; - if (imageSource.Width > width) - imageSource = imageSource.Scale(width / imageSource.Width) as TImageSource; + var imageRoundWidth = Math.Round(imageSource.Width); + if (imageRoundWidth > width) + imageSource = imageSource.Scale(width / imageRoundWidth) as TImageSource; return imageSource; } @@ -110,7 +111,7 @@ BitmapFrame GetBitmapFrameByWidth(BitmapFrame bitmapFrame, int width) var frames = bitmapFrame.Decoder.Frames; var frame = frames .OrderBy(e => e.Width) - .FirstOrDefault(e => e.Width >= width); + .FirstOrDefault(e => Math.Round(e.Width) >= width); return frame; }