diff --git a/CHANGELOG.md b/CHANGELOG.md
index d4002d0..a4d2607 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,11 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Update Remove and QuickAccess
### Updated
- Update `QuickAccessToolBarExtension` with internal methods.
+- Update `MoveToRibbonTab` to move to `Modify` tab.
### Tests
- Add Tests for `QuickAccessToolBarExtension`
- Add Tests for `RibbonHelp` and `RibbonItem`
- Add Tests for `AppLoader`
-
+- Add Tests for `MoveToRibbonTab`
## [0.5.5] / 2023-11-03
### Features
diff --git a/ricaun.Revit.UI.Example/Revit/App.cs b/ricaun.Revit.UI.Example/Revit/App.cs
index 4a7dc4e..0894aa5 100644
--- a/ricaun.Revit.UI.Example/Revit/App.cs
+++ b/ricaun.Revit.UI.Example/Revit/App.cs
@@ -278,9 +278,6 @@ private void AddNewPanelToMove(UIControlledApplication application)
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");
}
-
-
-
//Console.WriteLine($">> {split}");
//var ribbonItem = button.GetRibbonItem();
diff --git a/ricaun.Revit.UI.Example/Revit/AppExample.cs b/ricaun.Revit.UI.Example/Revit/AppExample.cs
index 67552a1..2452347 100644
--- a/ricaun.Revit.UI.Example/Revit/AppExample.cs
+++ b/ricaun.Revit.UI.Example/Revit/AppExample.cs
@@ -25,6 +25,8 @@ public Result OnStartup(UIControlledApplication application)
.SetLongDescription("Esta é uma descrição.");
}
+ //ribbonPanel.MoveToRibbonTab();
+
return Result.Succeeded;
}
diff --git a/ricaun.Revit.UI.Tests/Base/BaseCreatePanelTests.cs b/ricaun.Revit.UI.Tests/Base/BaseCreatePanelTests.cs
index 18138ed..305c98f 100644
--- a/ricaun.Revit.UI.Tests/Base/BaseCreatePanelTests.cs
+++ b/ricaun.Revit.UI.Tests/Base/BaseCreatePanelTests.cs
@@ -16,7 +16,7 @@ public void SetUp(UIControlledApplication application)
}
[TearDown]
- public void TearDown(UIControlledApplication application)
+ public void TearDown()
{
ribbonPanel?.Remove(true);
}
diff --git a/ricaun.Revit.UI.Tests/Extensions/RevitRibbonHelpTests.cs b/ricaun.Revit.UI.Tests/Extensions/RevitRibbonHelpTests.cs
index df62ba4..014deac 100644
--- a/ricaun.Revit.UI.Tests/Extensions/RevitRibbonHelpTests.cs
+++ b/ricaun.Revit.UI.Tests/Extensions/RevitRibbonHelpTests.cs
@@ -17,7 +17,7 @@ public void ContextualHelp_ShouldBe_Url(string helpPath)
[TestCase("file")]
[TestCase("help.pdf")]
- [TestCase("C:\\help.pdf")]
+ [TestCase("ricaun.com")]
public void ContextualHelp_ShouldBe_ChmFile(string helpPath)
{
var contextualHelp = RibbonHelpExtension.GetContextualHelp(helpPath);
diff --git a/ricaun.Revit.UI.Tests/Panels/RevitPanelMoveTests.cs b/ricaun.Revit.UI.Tests/Panels/RevitPanelMoveTests.cs
new file mode 100644
index 0000000..8711612
--- /dev/null
+++ b/ricaun.Revit.UI.Tests/Panels/RevitPanelMoveTests.cs
@@ -0,0 +1,57 @@
+using NUnit.Framework;
+using System.Linq;
+
+namespace ricaun.Revit.UI.Tests.Panels
+{
+ public class RevitPanelMoveTests : BaseCreatePanelTests
+ {
+ private const string TabIdAddIns = "Add-Ins";
+ private const string TabIdModify = "Modify";
+
+ [Test]
+ public void CreatePanel_ShouldBe_AddIns()
+ {
+ Assert.AreEqual(TabIdAddIns, ribbonPanel.GetRibbonTab().Id);
+ }
+
+ [Test]
+ public void MovePanelTo_Modify()
+ {
+ ribbonPanel.MoveToRibbonTab();
+ Assert.AreEqual(TabIdModify, ribbonPanel.GetRibbonTab().Id);
+ }
+
+ [Test]
+ public void MovePanelWithId_Modify()
+ {
+ ribbonPanel.MoveToRibbonTab(TabIdModify);
+ Assert.AreEqual(TabIdModify, ribbonPanel.GetRibbonTab().Id);
+ }
+
+ [Test]
+ public void MovePanelWithId_AddIns()
+ {
+ ribbonPanel.MoveToRibbonTab(TabIdModify);
+ ribbonPanel.MoveToRibbonTab(TabIdAddIns);
+ Assert.AreEqual(TabIdAddIns, ribbonPanel.GetRibbonTab().Id);
+ }
+
+ [Test]
+ public void MovePanelWithTab_First()
+ {
+ var ribbonTab = RibbonTabExtension.GetRibbonTabs().FirstOrDefault();
+ ribbonPanel.MoveToRibbonTab(ribbonTab);
+ Assert.AreEqual(ribbonTab, ribbonPanel.GetRibbonTab());
+ }
+
+ [Test]
+ public void MovePanelWithTab_ForEach()
+ {
+ foreach (var ribbonTab in RibbonTabExtension.GetRibbonTabs())
+ {
+ ribbonPanel.MoveToRibbonTab(ribbonTab);
+ Assert.AreEqual(ribbonTab, ribbonPanel.GetRibbonTab());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ricaun.Revit.UI.Tests/Panels/RevitPanelTests.cs b/ricaun.Revit.UI.Tests/Panels/RevitPanelTests.cs
index 300016d..c0f0dd7 100644
--- a/ricaun.Revit.UI.Tests/Panels/RevitPanelTests.cs
+++ b/ricaun.Revit.UI.Tests/Panels/RevitPanelTests.cs
@@ -9,45 +9,48 @@ public class RevitPanelTests
{
private const string PanelName = "Example";
+ UIControlledApplication application;
+
[SetUp]
public void SetUp(UIControlledApplication application)
{
+ this.application = application;
var panel = application.GetRibbonPanels().FirstOrDefault();
System.Console.WriteLine($"RibbonTab: {panel?.GetRibbonTab().Id}");
}
- private bool ContainPanel(UIControlledApplication application, RibbonPanel panel)
+ private bool ContainPanel(RibbonPanel panel)
{
return application.GetRibbonPanels().Contains(panel);
}
[Test]
- public void CreatePanel(UIControlledApplication application)
+ public void CreatePanel()
{
var panel = application.CreatePanel(PanelName);
foreach (var item in RibbonTabExtension.GetRibbonTabsDictionary(panel.GetRibbonTab()))
{
System.Console.WriteLine(item);
}
- Assert.IsTrue(ContainPanel(application, panel), "Contain Panel");
+ Assert.IsTrue(ContainPanel(panel), "Contain Panel");
panel?.Remove();
- Assert.IsFalse(ContainPanel(application, panel), "Not Contain Panel");
+ Assert.IsFalse(ContainPanel(panel), "Not Contain Panel");
}
[Test]
- public void CreatePanel_10Times(UIControlledApplication application)
+ public void CreatePanel_10Times()
{
for (int i = 0; i < 10; i++)
{
var panel = application.CreatePanel(PanelName);
- Assert.IsTrue(ContainPanel(application, panel), "Contain Panel");
+ Assert.IsTrue(ContainPanel(panel), "Contain Panel");
panel?.Remove();
- Assert.IsFalse(ContainPanel(application, panel), "Not Contain Panel");
+ Assert.IsFalse(ContainPanel(panel), "Not Contain Panel");
}
}
[Test]
- public void RemovePanel_DisableFloating(UIControlledApplication application)
+ public void RemovePanel_DisableFloating()
{
var panel = application.CreatePanel(PanelName);
panel.GetRibbonPanel().IsFloating = true;
@@ -56,6 +59,24 @@ public void RemovePanel_DisableFloating(UIControlledApplication application)
Assert.IsFalse(panel.GetRibbonPanel().IsFloating, "Panel Should not be Floating");
}
+ [Test]
+ public void RemovePanel_ShouldBe_NotEnable()
+ {
+ var panel = application.CreatePanel(PanelName);
+ Assert.IsTrue(panel.Enabled, "Panel Should be Enabled");
+ panel.Remove();
+ Assert.IsFalse(panel.Enabled, "Panel Should be not Enabled");
+ }
+
+ [Test]
+ public void RemovePanel_ShouldBe_NotVisible()
+ {
+ var panel = application.CreatePanel(PanelName);
+ Assert.IsTrue(panel.Visible, "Panel Should be Visible");
+ panel.Remove();
+ Assert.IsFalse(panel.Visible, "Panel Should be not Visible");
+ }
+
[Test]
public void RemovePanel_IgnoreIfNull()
{
diff --git a/ricaun.Revit.UI.Tests/Panels/RevitTabPanelTests.cs b/ricaun.Revit.UI.Tests/Panels/RevitTabPanelTests.cs
index cf4e9e8..708a1ad 100644
--- a/ricaun.Revit.UI.Tests/Panels/RevitTabPanelTests.cs
+++ b/ricaun.Revit.UI.Tests/Panels/RevitTabPanelTests.cs
@@ -8,48 +8,50 @@ public class RevitTabPanelTests
private const string TabName = "RevitTabPanelTests";
private const string PanelName = "Example";
private static RibbonPanel ribbonPanel;
+ private UIControlledApplication application;
[SetUp]
public void SetUp(UIControlledApplication application)
{
+ this.application = application;
ribbonPanel = application.CreatePanel(TabName, PanelName);
ribbonPanel.Remove();
System.Console.WriteLine($"RibbonTab: {ribbonPanel.GetRibbonTab().Id}");
}
- private bool ContainPanel(UIControlledApplication application, RibbonPanel panel)
+ private bool ContainPanel(RibbonPanel panel)
{
var tabName = panel.GetRibbonTab().Id;
return application.GetRibbonPanels(tabName).Contains(panel);
}
[Test]
- public void CreatePanel(UIControlledApplication application)
+ public void CreatePanel()
{
var panel = application.CreatePanel(TabName, PanelName);
foreach (var item in RibbonTabExtension.GetRibbonTabsDictionary(panel.GetRibbonTab()))
{
System.Console.WriteLine(item);
}
- Assert.IsTrue(ContainPanel(application, panel), "Contain Panel");
+ Assert.IsTrue(ContainPanel(panel), "Contain Panel");
panel?.Remove();
- Assert.IsFalse(ContainPanel(application, panel), "Not Contain Panel");
+ Assert.IsFalse(ContainPanel(panel), "Not Contain Panel");
}
[Test]
- public void CreatePanel_10Times(UIControlledApplication application)
+ public void CreatePanel_10Times()
{
for (int i = 0; i < 10; i++)
{
var panel = application.CreatePanel(TabName, PanelName);
- Assert.IsTrue(ContainPanel(application, panel), "Contain Panel");
+ Assert.IsTrue(ContainPanel(panel), "Contain Panel");
panel?.Remove();
- Assert.IsFalse(ContainPanel(application, panel), "Not Contain Panel");
+ Assert.IsFalse(ContainPanel(panel), "Not Contain Panel");
}
}
[TearDown]
- public void TearDown(UIControlledApplication application)
+ public void TearDown()
{
if (!string.IsNullOrEmpty(TabName))
ribbonPanel.GetRibbonTab().Remove();
diff --git a/ricaun.Revit.UI/RibbonPanelExtension.cs b/ricaun.Revit.UI/RibbonPanelExtension.cs
index 90459b9..77352a6 100644
--- a/ricaun.Revit.UI/RibbonPanelExtension.cs
+++ b/ricaun.Revit.UI/RibbonPanelExtension.cs
@@ -128,6 +128,16 @@ public static RibbonPanel Remove(this RibbonPanel ribbonPanel)
return ribbonPanel;
}
+ ///
+ /// Move RibbonPanel to RibbonTab 'Modify'/>
+ ///
+ ///
+ ///
+ public static RibbonPanel MoveToRibbonTab(this RibbonPanel ribbonPanel)
+ {
+ return ribbonPanel.MoveToRibbonTab("Modify");
+ }
+
///
/// Move RibbonPanel to RibbonTab with
/// 'Modify' | 'Add-Ins'
diff --git a/ricaun.Revit.UI/Utils/RibbonModifyUtils.cs b/ricaun.Revit.UI/Utils/RibbonModifyUtils.cs
index 4fc2377..876a74c 100644
--- a/ricaun.Revit.UI/Utils/RibbonModifyUtils.cs
+++ b/ricaun.Revit.UI/Utils/RibbonModifyUtils.cs
@@ -11,6 +11,15 @@ internal static class RibbonModifyUtils
{
private const string MODIFY_PANEL_ID = "Modify";
+ ///
+ /// Get RibbonTab of Modify
+ ///
+ ///
+ public static Autodesk.Windows.RibbonTab RibbonTab()
+ {
+ return RibbonTabExtension.GetRibbonTab(MODIFY_PANEL_ID);
+ }
+
///
/// Create Panel with to Modify Tab. And add the to the Panel.
///
@@ -46,7 +55,7 @@ public static Autodesk.Windows.RibbonPanel CreateRibbonPanel(string panelName, p
///
public static Autodesk.Windows.RibbonPanel CreateRibbonPanel(string panelName)
{
- var modifyTab = Autodesk.Windows.ComponentManager.Ribbon.FindTab(MODIFY_PANEL_ID);
+ var modifyTab = RibbonTab();
var modifyPanel = modifyTab.CreateRibbonPanel(panelName);
return modifyPanel;
}
@@ -58,7 +67,7 @@ public static Autodesk.Windows.RibbonPanel CreateRibbonPanel(string panelName)
///
public static Autodesk.Windows.RibbonPanel RemoveRibbonPanel(string panelName)
{
- var modifyTab = Autodesk.Windows.ComponentManager.Ribbon.FindTab(MODIFY_PANEL_ID);
+ var modifyTab = RibbonTab();
var modifyPanel = modifyTab.RemoveRibbonPanel(panelName);
return modifyPanel;
}