diff --git a/CHANGELOG.md b/CHANGELOG.md index 69fd0c2..60e014f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ricaun.Revit.UI.Example/Revit/AppStacked.cs b/ricaun.Revit.UI.Example/Revit/AppStacked.cs index b04719b..fb00b36 100644 --- a/ricaun.Revit.UI.Example/Revit/AppStacked.cs +++ b/ricaun.Revit.UI.Example/Revit/AppStacked.cs @@ -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 @@ -29,6 +30,7 @@ RibbonItem[] CreateButtons(int number) .SetToolTip($"{i}") .SetShowText(false) .SetItemSize() + .SetToolTip(Icons.Icon.ToString()) .SetLargeImage(Icons.Icon) ); return itens.ToArray(); @@ -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(); diff --git a/ricaun.Revit.UI.Tests/Items/RevitStackedItemsTests.cs b/ricaun.Revit.UI.Tests/Items/RevitStackedItemsTests.cs index 5646f0e..e4c6df3 100644 --- a/ricaun.Revit.UI.Tests/Items/RevitStackedItemsTests.cs +++ b/ricaun.Revit.UI.Tests/Items/RevitStackedItemsTests.cs @@ -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()) + .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)] diff --git a/ricaun.Revit.UI/RibbonStackExtension.cs b/ricaun.Revit.UI/RibbonStackExtension.cs index cc62340..b60c8d5 100644 --- a/ricaun.Revit.UI/RibbonStackExtension.cs +++ b/ricaun.Revit.UI/RibbonStackExtension.cs @@ -14,12 +14,24 @@ public static class RibbonStackExtension /// /// /// - /// The is divided into groups of a maximum of 3 in each RibbonRowPanel + /// The is divided into groups of a maximum of 3 in each RibbonRowPanel with Image size. public static Autodesk.Windows.RibbonRowPanel[] RowStackedItems(this RibbonPanel ribbonPanel, params RibbonItem[] ribbonItems) { return ribbonPanel.CreateRowStackedItemsWithMax(ribbonItems); } + /// + /// Create Row Panels and move the to the new panels + /// + /// + /// + /// + /// The is divided into groups of a maximum of 2 in each RibbonRowPanel with LargeImage size. + public static Autodesk.Windows.RibbonRowPanel[] RowLargeStackedItems(this RibbonPanel ribbonPanel, params RibbonItem[] ribbonItems) + { + return ribbonPanel.CreateRowStackedItemsWithMax(2, ribbonItems).SetRibbonItemSize(); + } + /// /// Create Flow Panels and move the to the new panels /// diff --git a/ricaun.Revit.UI/Utils/RibbonItemPanelExtension.cs b/ricaun.Revit.UI/Utils/RibbonItemPanelExtension.cs index 51cffcd..a3b4b59 100644 --- a/ricaun.Revit.UI/Utils/RibbonItemPanelExtension.cs +++ b/ricaun.Revit.UI/Utils/RibbonItemPanelExtension.cs @@ -69,6 +69,40 @@ public static Autodesk.Windows.RibbonRowPanel AddRibbonItem(this Autodesk.Window ribbonRowPanel.Items.Add(UpdateForRibbonRowPanel(ribbonItem)); return ribbonRowPanel; } + /// + /// Set each items to + /// + /// + /// + /// + 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; + } + + /// + /// Set items to + /// + /// + /// + /// + 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;