Skip to content

Commit

Permalink
Update SetImage to work with ComboBoxMember
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Jul 6, 2024
1 parent ef20be1 commit d3d3fd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Set project configuration to support `net47` and `net48`.
### Updated
- Change `GetRibbonItem` to `GetRibbonItem_Alternative` to fix null when panel is removed.
- Update `SetImage` to work with `ComboBoxMember`
### Tests
- Add `RibbonThemeUtilsTests` to test the theme change event.

Expand Down
18 changes: 12 additions & 6 deletions ricaun.Revit.UI/RibbonItemExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static TRibbonItem SetToolTipImage<TRibbonItem>(this TRibbonItem ribbonIt

#region Set RibbonButton
/// <summary>
/// Set RibbonButton/ComboBox/TextBox Image
/// Set RibbonButton/ComboBox/ComboBoxMember/TextBox Image
/// </summary>
/// <typeparam name="TRibbonItem"></typeparam>
/// <param name="ribbonItem"></param>
Expand All @@ -166,13 +166,13 @@ public static TRibbonItem SetImage<TRibbonItem>(this TRibbonItem ribbonItem, str
}

/// <summary>
/// Set RibbonButton/ComboBox/TextBox LargeImage
/// Set RibbonButton/ComboBox/ComboBoxMember/TextBox LargeImage
/// </summary>
/// <typeparam name="TRibbonItem"></typeparam>
/// <param name="ribbonItem"></param>
/// <param name="largeImage"></param>
/// <returns></returns>
/// <remarks>When <see cref="ComboBox"/> or <see cref="TextBox"/> does not have LargeImage, the Image is changed instead.</remarks>
/// <remarks>When <see cref="ComboBox"/>, <see cref="ComboBoxMember"/> or <see cref="TextBox"/> does not have LargeImage, the Image is changed instead.</remarks>
public static TRibbonItem SetLargeImage<TRibbonItem>(this TRibbonItem ribbonItem, string largeImage) where TRibbonItem : RibbonItem
{
var bitmapSource = largeImage?.GetBitmapSource();
Expand All @@ -184,7 +184,7 @@ public static TRibbonItem SetLargeImage<TRibbonItem>(this TRibbonItem ribbonItem
}

/// <summary>
/// Set RibbonButton/ComboBox/TextBox Image
/// Set RibbonButton/ComboBox/ComboBoxMember/TextBox Image
/// </summary>
/// <typeparam name="TRibbonItem">RibbonButton</typeparam>
/// <param name="ribbonItem"></param>
Expand All @@ -198,20 +198,23 @@ public static TRibbonItem SetImage<TRibbonItem>(this TRibbonItem ribbonItem, Ima
else if (ribbonItem is ComboBox comboBox)
comboBox.Image = image?.GetBitmapFrame(16, (frame) => { comboBox.Image = frame; });

else if (ribbonItem is ComboBoxMember comboBoxMember)
comboBoxMember.Image = image?.GetBitmapFrame(16, (frame) => { comboBoxMember.Image = frame; });

else if (ribbonItem is TextBox textBox)
textBox.Image = image?.GetBitmapFrame(16, (frame) => { textBox.Image = frame; });

return ribbonItem;
}

/// <summary>
/// Set RibbonButton/ComboBox/TextBox LargeImage
/// Set RibbonButton/ComboBox/ComboBoxMember/TextBox LargeImage
/// </summary>
/// <typeparam name="TRibbonItem">RibbonButton</typeparam>
/// <param name="ribbonItem"></param>
/// <param name="largeImage"></param>
/// <returns></returns>
/// <remarks>When <see cref="ComboBox"/> or <see cref="TextBox"/> does not have LargeImage, the Image is changed instead.</remarks>
/// <remarks>When <see cref="ComboBox"/>, <see cref="ComboBoxMember"/> or <see cref="TextBox"/> does not have LargeImage, the Image is changed instead.</remarks>
public static TRibbonItem SetLargeImage<TRibbonItem>(this TRibbonItem ribbonItem, ImageSource largeImage) where TRibbonItem : RibbonItem
{
if (ribbonItem is RibbonButton ribbonButton)
Expand All @@ -224,6 +227,9 @@ public static TRibbonItem SetLargeImage<TRibbonItem>(this TRibbonItem ribbonItem
else if (ribbonItem is ComboBox comboBox)
comboBox.SetImage(largeImage);

else if (ribbonItem is ComboBoxMember comboBoxMember)
comboBoxMember.SetImage(largeImage);

else if (ribbonItem is TextBox textBox)
textBox.SetImage(largeImage);

Expand Down

0 comments on commit d3d3fd5

Please sign in to comment.