Skip to content

Commit

Permalink
Create RowLargeStackedItems with large image and two itens
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Nov 18, 2023
1 parent 4733390 commit 05e0f6b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [0.5.7] / 2023-11-17
### Features
- LargeImage changes `TextBox` Image
- Create `RowLargeStackedItems` with large image and two itens
### Updated
- Update Example `Icons` to get random icon using `UIFrameworkRes`
### Tests
- Test `ComboBox` and `TextBox` Image/LargeImage
- Test `RowLargeStackedItems` with large image and two itens

## [0.5.6] / 2023-11-08
### Features
Expand Down
5 changes: 5 additions & 0 deletions ricaun.Revit.UI.Example/Revit/AppStacked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Autodesk.Revit.UI;
using ricaun.Revit.UI;
using ricaun.Revit.UI.Example.Proprieties;
using ricaun.Revit.UI.Utils;
using System.Linq;

namespace ricaun.Revit.UI.Example.Revit
Expand Down Expand Up @@ -29,6 +30,7 @@ RibbonItem[] CreateButtons(int number)
.SetToolTip($"{i}")
.SetShowText(false)
.SetItemSize()
.SetToolTip(Icons.Icon.ToString())
.SetLargeImage(Icons.Icon)
);
return itens.ToArray();
Expand All @@ -37,6 +39,9 @@ RibbonItem[] CreateButtons(int number)
ribbonPanel.AddSeparator();
ribbonPanel.RowStackedItems(CreateButtons(9));

ribbonPanel.AddSeparator();
ribbonPanel.RowLargeStackedItems(CreateButtons(4));

ribbonPanel.AddSlideOut();
ribbonPanel.RowStackedItems(CreateButtons(8));
ribbonPanel.AddSeparator();
Expand Down
27 changes: 27 additions & 0 deletions ricaun.Revit.UI.Tests/Items/RevitStackedItemsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,33 @@ public void CreateRow(int numberOfCommands)
Assert.AreEqual(expectadRowPanels, ribbonRowPanel.Length);
}

[TestCase(2)]
[TestCase(3)]
[TestCase(4)]
[TestCase(6)]
[TestCase(9)]
[TestCase(20)]
public void CreateRowLarge(int numberOfCommands)
{
var pushButtons = Enumerable.Range(0, numberOfCommands)
.Select(e => ribbonPanel.CreatePushButton<BaseCommand>())
.ToArray();

var ribbonRowPanel = ribbonPanel.RowLargeStackedItems(pushButtons);

var expectadRowPanels = Math.Ceiling(numberOfCommands / 2.0);

Assert.AreEqual(expectadRowPanels, ribbonRowPanel.Length);

foreach (var rowPanel in ribbonRowPanel)
{
foreach (var item in rowPanel.Items)
{
Assert.AreEqual(item.Size, Autodesk.Windows.RibbonItemSize.Large);
}
}
}

[TestCase(2)]
[TestCase(3)]
[TestCase(4)]
Expand Down
14 changes: 13 additions & 1 deletion ricaun.Revit.UI/RibbonStackExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@ public static class RibbonStackExtension
/// <param name="ribbonPanel"></param>
/// <param name="ribbonItems"></param>
/// <returns></returns>
/// <remarks>The <paramref name="ribbonItems"/> is divided into groups of a maximum of 3 in each RibbonRowPanel</remarks>
/// <remarks>The <paramref name="ribbonItems"/> is divided into groups of a maximum of 3 in each RibbonRowPanel with Image size.</remarks>
public static Autodesk.Windows.RibbonRowPanel[] RowStackedItems(this RibbonPanel ribbonPanel, params RibbonItem[] ribbonItems)
{
return ribbonPanel.CreateRowStackedItemsWithMax(ribbonItems);
}

/// <summary>
/// Create Row Panels and move the <paramref name="ribbonItems"/> to the new panels
/// </summary>
/// <param name="ribbonPanel"></param>
/// <param name="ribbonItems"></param>
/// <returns></returns>
/// <remarks>The <paramref name="ribbonItems"/> is divided into groups of a maximum of 2 in each RibbonRowPanel with LargeImage size.</remarks>
public static Autodesk.Windows.RibbonRowPanel[] RowLargeStackedItems(this RibbonPanel ribbonPanel, params RibbonItem[] ribbonItems)
{
return ribbonPanel.CreateRowStackedItemsWithMax(2, ribbonItems).SetRibbonItemSize();
}

/// <summary>
/// Create Flow Panels and move the <paramref name="ribbonItems"/> to the new panels
/// </summary>
Expand Down
34 changes: 34 additions & 0 deletions ricaun.Revit.UI/Utils/RibbonItemPanelExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,40 @@ public static Autodesk.Windows.RibbonRowPanel AddRibbonItem(this Autodesk.Window
ribbonRowPanel.Items.Add(UpdateForRibbonRowPanel(ribbonItem));
return ribbonRowPanel;
}
/// <summary>
/// Set each <paramref name="ribbonRowPanels"/> items to <paramref name="ribbonItemSize"/>
/// </summary>
/// <param name="ribbonRowPanels"></param>
/// <param name="ribbonItemSize"></param>
/// <returns></returns>
public static Autodesk.Windows.RibbonRowPanel[] SetRibbonItemSize(
this Autodesk.Windows.RibbonRowPanel[] ribbonRowPanels,
Autodesk.Windows.RibbonItemSize ribbonItemSize = Autodesk.Windows.RibbonItemSize.Large)
{
foreach (var ribbonRowPanel in ribbonRowPanels)
{
ribbonRowPanel.SetRibbonItemSize(ribbonItemSize);
}
return ribbonRowPanels;
}

/// <summary>
/// Set <paramref name="ribbonRowPanel"/> items to <paramref name="ribbonItemSize"/>
/// </summary>
/// <param name="ribbonRowPanel"></param>
/// <param name="ribbonItemSize"></param>
/// <returns></returns>
public static Autodesk.Windows.RibbonRowPanel SetRibbonItemSize(
this Autodesk.Windows.RibbonRowPanel ribbonRowPanel,
Autodesk.Windows.RibbonItemSize ribbonItemSize = Autodesk.Windows.RibbonItemSize.Large)
{
foreach (var ribbonItem in ribbonRowPanel.Items)
{
ribbonItem.Size = ribbonItemSize;
}
return ribbonRowPanel;
}

internal static Autodesk.Windows.RibbonItem UpdateForRibbonRowPanel(this Autodesk.Windows.RibbonItem ribbonItem)
{
ribbonItem.Size = Autodesk.Windows.RibbonItemSize.Standard;
Expand Down

0 comments on commit 05e0f6b

Please sign in to comment.