diff --git a/CHANGELOG.md b/CHANGELOG.md
index 342b649..6a3dd55 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,27 @@ 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.0.6] / 2022-02-02
+- Special Icons8 class
+- Update Example Version
+- Add Icon / InstallationFiles
+- Add More Icons
+- Update Readme
+- Update `GetBitmapSource` base64orUri
+- Add Icons8 on Example
+- Change SetImage and SetLargeImage to RibbonItem
+- Fix RemoveQuickAccessToolBar on `Remove` RibbonPanel
+- Add GetName `Type`
+- Add SetShowImage
+- Add Action on `RibbonDescription`
+- Add TRibbonButton on `RibbonDescriptionExtension`
+- Add TRibbonItem on `RibbonDescriptionExtension`
+- 2022-01-31
+- Remove QuickAccessToolBar when Remove RibbonPanel
+- Add QuickAccessToolBarExtension
+- 2022-01-25
+- Add GetRibbonTabs
+
## [0.0.5] / 2022-01-24
- Add SetImage / SetLongDescription
- Add UpdateRibbonDescription
diff --git a/README.md b/README.md
index 55f8425..6a669b0 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,23 @@
# ricaun.Revit.UI
-[![Revit API](https://img.shields.io/badge/Revit%20API-2017+-blue.svg)](../..)
+[![Revit 2017](https://img.shields.io/badge/Revit-2017+-blue.svg)](../..)
[![Visual Studio 2019](https://img.shields.io/badge/Visual%20Studio%202019-16.11.7+-blue)](../..)
+[![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/)
[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
-
[![Publish](../../actions/workflows/Publish.yml/badge.svg)](../../actions)
[![Develop](../../actions/workflows/Develop.yml/badge.svg)](../../actions)
[![Release](https://img.shields.io/nuget/v/ricaun.Revit.UI?logo=nuget&label=release&color=blue)](https://www.nuget.org/packages/ricaun.Revit.UI)
----
+## Release
+
+* [Latest release](../../releases/latest)
+
+## License
-Copyright © 2021 ricaun
+This Project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License).
+
+Credit to [icons8.com](https://icons8.com/) for the icons on the Example.
+
+---
+Do you like this package? Please [star this project on GitHub](../../stargazers)!
\ No newline at end of file
diff --git a/ricaun.Revit.UI.Example/InstallationFiles/License.txt b/ricaun.Revit.UI.Example/InstallationFiles/License.txt
new file mode 100644
index 0000000..97fc841
--- /dev/null
+++ b/ricaun.Revit.UI.Example/InstallationFiles/License.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2022 ricaun
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/ricaun.Revit.UI.Example/InstallationFiles/icon.ico b/ricaun.Revit.UI.Example/InstallationFiles/icon.ico
new file mode 100644
index 0000000..bb81856
Binary files /dev/null and b/ricaun.Revit.UI.Example/InstallationFiles/icon.ico differ
diff --git a/ricaun.Revit.UI.Example/Proprieties/Icons8.cs b/ricaun.Revit.UI.Example/Proprieties/Icons8.cs
new file mode 100644
index 0000000..18c91d0
--- /dev/null
+++ b/ricaun.Revit.UI.Example/Proprieties/Icons8.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Windows.Media.Imaging;
+using ricaun.Revit.UI;
+
+namespace ricaun.Revit.UI.Example.Proprieties
+{
+ ///
+ /// https://icons8.com/
+ /// https://img.icons8.com/small/32/000000/circled.png
+ /// https://img.icons8.com/{0}/{1}/{2}/{3}.png
+ ///
+ public class Icons8
+ {
+ #region Private
+ private static string Color => "000000";
+ private static string Type => "color";
+ private static string Size => "32";
+ private static string BaseUri => @"https://img.icons8.com/{0}/{1}/{2}/{3}.png";
+ #endregion
+
+ #region Icons
+ public static BitmapSource Icon([CallerMemberName] string name = null) => string.Format(BaseUri, Type, Size, Color, name.ToLower()).GetBitmapSource();
+ public static BitmapSource Ok => Icon();
+ public static BitmapSource Document => Icon();
+ public static BitmapSource File => Icon();
+ public static BitmapSource Support => Icon();
+ public static BitmapSource Settings => Icon();
+ public static BitmapSource About => Icon();
+ public static BitmapSource Restart => Icon();
+ public static BitmapSource Filter => Icon();
+ public static BitmapSource Search => Icon();
+ public static BitmapSource Trash => Icon();
+ public static BitmapSource Home => Icon();
+ public static BitmapSource Menu => Icon();
+ public static BitmapSource Info => Icon();
+ public static BitmapSource Circled => Icon();
+ public static BitmapSource Checked => Icon();
+ public static BitmapSource Cancel => Icon();
+ #endregion
+ }
+}
diff --git a/ricaun.Revit.UI.Example/Revit/App.cs b/ricaun.Revit.UI.Example/Revit/App.cs
index c1bf631..1722675 100644
--- a/ricaun.Revit.UI.Example/Revit/App.cs
+++ b/ricaun.Revit.UI.Example/Revit/App.cs
@@ -2,10 +2,8 @@
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
-using System.Windows.Media;
+using ricaun.Revit.UI.Example.Proprieties;
namespace ricaun.Revit.UI.Example.Revit
{
@@ -19,93 +17,63 @@ public class App : IExternalApplication
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel(TabName, PanelName);
- var button = ribbonPanel.AddPushButton();
+
+ ribbonPanel.AddPushButton();
ribbonPanel.CreatePulldownButton("PulldownButton", new[] {
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData() });
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>()
+ });
ribbonPanel.CreateSplitButton("SplitButton", new[] {
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData(),
- ribbonPanel.NewPushButtonData() });
-
- var button2 = ribbonPanel.AddPushButton("");
-
- var items = ribbonPanel.AddStackedItems(
- ribbonPanel.NewPushButtonData("Item1"),
- ribbonPanel.NewPushButtonData("Item2"));
-
- foreach (var item in items)
- {
- item.SetItemSize();
- item.SetText();
- }
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>()
+ });
- var item3s = ribbonPanel.AddStackedItems(
- ribbonPanel.NewPushButtonData("1"),
- ribbonPanel.NewPushButtonData("2"),
- ribbonPanel.NewPushButtonData("3"));
+ ribbonPanel.AddPushButton>();
- foreach (var item in item3s)
- {
- item.SetText();
- }
- /*
- foreach (var item in ribbonPanel.GetItems())
- {
- if (item is PushButton pushButton)
- {
- pushButton.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
- pushButton.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
- pushButton.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
- }
- if (item is PulldownButton pulldownButton)
- {
- pulldownButton.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
- pulldownButton.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
- pulldownButton.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
- }
- if (item is SplitButton splitButton)
- {
- foreach (var i in splitButton.GetItems())
- {
- if (i is PushButton pb)
- {
- pb.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
- pb.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
- pb.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
- }
- }
- }
- }
- */
+ ribbonPanel.AddStackedItems(
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>());
- ribbonPanel.GetRibbonPanel().Tab.SetOrderPanels();
- var ric = ribbonPanel.GetRibbonPanel().Tab.Panels.ToList().FirstOrDefault(e => e.Source.Title == "ricaun");
- ric?.MoveRibbonPanel();
+ ribbonPanel.AddStackedItems(
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>());
+
+
+ ribbonPanel.AddStackedItems(
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>());
+
+ ribbonPanel.AddStackedItems(
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>(),
+ ribbonPanel.NewPushButtonData>());
+
+ OrderPanelAndMove(ribbonPanel);
foreach (var item in ribbonPanel.GetRibbonItems())
{
//Console.WriteLine($"{item} {item.Name}");
}
+ UpdateRibbonDescription(ribbonPanel);
+
+ return Result.Succeeded;
+ }
+
+ private void UpdateRibbonDescription(RibbonPanel ribbonPanel)
+ {
ribbonPanel.UpdateRibbonDescription(setting =>
{
- setting.Add("",
+ setting.AddDefault(
new RibbonDescription()
{
- LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource(),
Help = "https://ricaun.com"
}
);
@@ -113,11 +81,10 @@ public Result OnStartup(UIControlledApplication application)
setting.Add(
new RibbonDescription()
{
+ LargeImage = Resource.LargeImage.GetBitmapSource(),
Text = "Hello",
ToolTip = "This is a Tool Tip",
LongDescription = "This is a Long Description",
- LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource(),
- Help = "https://ricaun.com"
},
new RibbonDescription(LanguageType.Brazilian_Portuguese)
{
@@ -127,20 +94,161 @@ public Result OnStartup(UIControlledApplication application)
}
);
+ setting.Add>(
+ new RibbonDescription()
+ {
+ Text = "Ok",
+ LargeImage = Icons8.Ok
+ }
+ );
+
+ setting.Add>(
+ new RibbonDescription()
+ {
+ Text = "int",
+ LargeImage = Icons8.Document
+ }
+ );
+
+ setting.Add>(
+ new RibbonDescription()
+ {
+ Text = "double",
+ LargeImage = Icons8.File
+ }
+ );
+
+ setting.Add>(
+ new RibbonDescription()
+ {
+ Text = "bool",
+ LargeImage = Icons8.Support
+ }
+ );
+
+ setting.Add>(
+ new RibbonDescription()
+ {
+ Text = "text",
+ LargeImage = Icons8.Settings
+ }
+ );
+
setting.Add("PulldownButton", new RibbonDescription()
{
- Text = "PulldownButton",
- Help = "https://ricaun.com"
+ Text = "Menu",
+ LargeImage = Icons8.About
});
- setting.Add("SplitButton", new RibbonDescription()
+
+ setting.Add>(new RibbonDescription()
{
- Text = "SplitButton",
- Help = "https://ricaun.com"
+ Text = "UIApplication",
+ LargeImage = Icons8.Restart,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetItemSize();
+ ribbonItem.SetShowText();
+ }
});
- });
- return Result.Succeeded;
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "UIDocument",
+ LargeImage = Icons8.Filter,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetItemSize();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "Application",
+ LargeImage = Icons8.Search,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetItemSize();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "Document",
+ LargeImage = Icons8.Trash,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetItemSize();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "RibbonItem",
+ LargeImage = Icons8.Home,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.GetRibbonItem().AddQuickAccessToolBar();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "RibbonButton",
+ LargeImage = Icons8.Menu,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.GetRibbonItem().AddQuickAccessToolBar();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "RibbonPanel",
+ LargeImage = Icons8.Info,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.GetRibbonItem().AddQuickAccessToolBar();
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "Element",
+ LargeImage = Icons8.Circled,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "ElementType",
+ LargeImage = Icons8.Checked,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetShowText();
+ }
+ });
+
+ setting.Add>(new RibbonDescription()
+ {
+ Text = "ElementArray",
+ LargeImage = Icons8.Cancel,
+ Action = (ribbonItem) =>
+ {
+ ribbonItem.SetShowText();
+ }
+ });
+
+ });
}
public Result OnShutdown(UIControlledApplication application)
@@ -148,5 +256,12 @@ public Result OnShutdown(UIControlledApplication application)
ribbonPanel.Close();
return Result.Succeeded;
}
+
+ private void OrderPanelAndMove(RibbonPanel ribbonPanel)
+ {
+ ribbonPanel.GetRibbonPanel().Tab.SetOrderPanels();
+ var ric = ribbonPanel.GetRibbonPanel().Tab.Panels.ToList().FirstOrDefault(e => e.Source.Title == "ricaun");
+ ric?.MoveRibbonPanel();
+ }
}
}
\ No newline at end of file
diff --git a/ricaun.Revit.UI.Example/Revit/Commands/Command.cs b/ricaun.Revit.UI.Example/Revit/Commands/Command.cs
index 8552eec..d513085 100644
--- a/ricaun.Revit.UI.Example/Revit/Commands/Command.cs
+++ b/ricaun.Revit.UI.Example/Revit/Commands/Command.cs
@@ -12,11 +12,20 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
UIApplication uiapp = commandData.Application;
- //new Services.ReflectionService().GetFields();
- //new Services.ReflectionService().GetMethods();
+ return Result.Succeeded;
+ }
+ }
+
+ [Transaction(TransactionMode.Manual)]
+ public class Command : IExternalCommand
+ {
+ public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
+ {
+ UIApplication uiapp = commandData.Application;
+
+ var t = typeof(T);
- //Console.WriteLine(typeof(Command).Assembly);
- System.Windows.MessageBox.Show(AutodeskExtension.GetAutodeskOwner(), $"Hello Revit\n{DateTime.Now}");
+ System.Windows.MessageBox.Show(AutodeskExtension.GetAutodeskOwner(), $"Hello Revit\n{DateTime.Now}\n{t}");
return Result.Succeeded;
}
diff --git a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
index 55eb1b1..cab9898 100644
--- a/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
+++ b/ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
@@ -77,12 +77,12 @@
ricaun.Revit.UI.Example
- 1.0.0
+ 1.0.6
{f736f68f-7101-4640-9093-8715f88ccb95}
- .$(Version)
+
$([MSBuild]::Divide($([System.DateTime]::get_Now().get_TimeOfDay().get_TotalSeconds()), 4).ToString('F0'))
@@ -103,6 +103,13 @@
Copyright © $(CopyrightYears) $(Company)
+
+
+
+
+
+
+
diff --git a/ricaun.Revit.UI/BitmapExtension.cs b/ricaun.Revit.UI/BitmapExtension.cs
index 618df36..b15db8f 100644
--- a/ricaun.Revit.UI/BitmapExtension.cs
+++ b/ricaun.Revit.UI/BitmapExtension.cs
@@ -55,13 +55,16 @@ public static BitmapSource GetBitmapSource(this System.Drawing.Image image)
}
///
- /// Transform string base64 to BitmapSource
+ /// Transform string base64 or Uri to BitmapSource
///
- ///
+ ///
///
- public static BitmapSource GetBitmapSource(this string base64)
+ public static BitmapSource GetBitmapSource(this string base64orUri)
{
- var image = System.Drawing.Bitmap.FromStream(new MemoryStream(Convert.FromBase64String(base64)));
+ if (base64orUri.StartsWith("http"))
+ return new BitmapImage(new Uri(base64orUri));
+
+ var image = System.Drawing.Bitmap.FromStream(new MemoryStream(Convert.FromBase64String(base64orUri)));
return image.GetBitmapSource();
}
@@ -86,6 +89,5 @@ public static BitmapSource Scale(this ImageSource imageSource, double scale)
{
return new TransformedBitmap(imageSource as BitmapSource, new ScaleTransform(scale, scale));
}
-
}
}
diff --git a/ricaun.Revit.UI/QuickAccessToolBarExtension.cs b/ricaun.Revit.UI/QuickAccessToolBarExtension.cs
new file mode 100644
index 0000000..4370dc0
--- /dev/null
+++ b/ricaun.Revit.UI/QuickAccessToolBarExtension.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Autodesk.Windows;
+
+namespace ricaun.Revit.UI
+{
+ ///
+ /// QuickAccessToolBarExtension
+ ///
+ public static class QuickAccessToolBarExtension
+ {
+ ///
+ /// Remove RibbonItem from QuickAccessToolBar
+ ///
+ ///
+ ///
+ ///
+ public static TRibbonItem RemoveQuickAccessToolBar(this TRibbonItem ribbonItem) where TRibbonItem : RibbonItem
+ {
+ if (ribbonItem == null)
+ return ribbonItem;
+
+ var ri = ComponentManager.QuickAccessToolBar.Items
+ .FirstOrDefault(e => e.Id == ribbonItem.Id);
+
+ if (ri != null)
+ ComponentManager.QuickAccessToolBar.Items.Remove(ri);
+
+ return ribbonItem;
+ }
+
+ ///
+ /// Add RibbonItem to QuickAccessToolBar
+ ///
+ ///
+ ///
+ ///
+ public static TRibbonItem AddQuickAccessToolBar(this TRibbonItem ribbonItem) where TRibbonItem : RibbonItem
+ {
+ if (ribbonItem == null)
+ return ribbonItem;
+
+ var ri = ComponentManager.QuickAccessToolBar.Items
+ .FirstOrDefault(e => e.Id == ribbonItem.Id);
+
+ if (ri == null)
+ ComponentManager.QuickAccessToolBar.Items.Add(ribbonItem);
+
+ return ribbonItem;
+ }
+ }
+}
diff --git a/ricaun.Revit.UI/RibbonDescriptionExtension.cs b/ricaun.Revit.UI/RibbonDescriptionExtension.cs
index 529e468..e639d1a 100644
--- a/ricaun.Revit.UI/RibbonDescriptionExtension.cs
+++ b/ricaun.Revit.UI/RibbonDescriptionExtension.cs
@@ -33,17 +33,6 @@ public bool TryGetValue(string name, out List ribbonDescripti
return nameRibbonDescriptions.TryGetValue(name, out ribbonDescriptions);
}
- ///
- /// Add
- ///
- ///
- ///
- public void Add(params RibbonDescription[] ribbonDescriptions)
- {
- var name = typeof(T).Name;
- Add(name, ribbonDescriptions);
- }
-
///
/// Add
///
@@ -71,6 +60,27 @@ public void Add(string name, params RibbonDescription[] ribbonDescriptions)
Add(name, ribbonDescription);
}
+ ///
+ /// Add
+ ///
+ ///
+ ///
+ public void Add(params RibbonDescription[] ribbonDescriptions)
+ {
+ var name = typeof(T).GetName();
+ Add(name, ribbonDescriptions);
+ }
+
+ ///
+ /// Add Default
+ ///
+ ///
+ public void AddDefault(params RibbonDescription[] ribbonDescriptions)
+ {
+ foreach (var ribbonDescription in ribbonDescriptions)
+ Add("", ribbonDescription);
+ }
+
///
/// Get Count
///
@@ -123,6 +133,10 @@ public RibbonDescription(LanguageType LanguageType = LanguageType.Unknown)
/// ToolTipImage
///
public ImageSource ToolTipImage { get; set; }
+ ///
+ /// Action
+ ///
+ public Action Action { get; set; }
}
///
@@ -195,10 +209,11 @@ public static IList GetRibbonItems(this RibbonPanel ribbonPanel)
///
/// Update RibbonDescription
///
+ /// RibbonItem
///
///
///
- public static RibbonItem UpdateRibbonDescription(this RibbonItem ribbonItem, RibbonDescription description)
+ public static TRibbonItem UpdateRibbonDescription(this TRibbonItem ribbonItem, RibbonDescription description) where TRibbonItem : RibbonItem
{
if (description == null)
return ribbonItem;
@@ -209,24 +224,23 @@ public static RibbonItem UpdateRibbonDescription(this RibbonItem ribbonItem, Rib
ribbonItem.SetToolTipImage(description.ToolTipImage);
ribbonItem.SetContextualHelp(description.Help);
- if (ribbonItem is RibbonButton ribbonButton)
- {
- ribbonButton.SetImage(description.Image);
- ribbonButton.SetLargeImage(description.LargeImage);
- }
+ ribbonItem.SetImage(description.Image);
+ ribbonItem.SetLargeImage(description.LargeImage);
+
+ description.Action?.Invoke(ribbonItem);
+
return ribbonItem;
}
#region Set RibbonItem
-
-
///
/// Sets the contextual help bound with this RibbonItem.
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetContextualHelp(this RibbonItem ribbonItem, string helpPath)
+ public static TRibbonItem SetContextualHelp(this TRibbonItem ribbonItem, string helpPath) where TRibbonItem : RibbonItem
{
if (helpPath != null)
ribbonItem.SetContextualHelp(GetContextualHelp(helpPath));
@@ -237,22 +251,37 @@ public static RibbonItem SetContextualHelp(this RibbonItem ribbonItem, string he
///
/// Enable / Disable Show Text
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetShowText(this RibbonItem ribbonItem, bool showText = false)
+ public static TRibbonItem SetShowText(this TRibbonItem ribbonItem, bool showText = false) where TRibbonItem : RibbonItem
{
ribbonItem.GetRibbonItem().ShowText = showText;
return ribbonItem;
}
+ ///
+ /// Enable / Disable Show Image
+ ///
+ /// RibbonItem
+ ///
+ ///
+ ///
+ public static TRibbonItem SetShowImage(this TRibbonItem ribbonItem, bool showImage = false) where TRibbonItem : RibbonItem
+ {
+ ribbonItem.GetRibbonItem().ShowImage = showImage;
+ return ribbonItem;
+ }
+
///
/// Set RibbonItemSize
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetItemSize(this RibbonItem ribbonItem, Autodesk.Windows.RibbonItemSize itemSize = Autodesk.Windows.RibbonItemSize.Large)
+ public static TRibbonItem SetItemSize(this TRibbonItem ribbonItem, Autodesk.Windows.RibbonItemSize itemSize = Autodesk.Windows.RibbonItemSize.Large) where TRibbonItem : RibbonItem
{
ribbonItem.GetRibbonItem().Size = itemSize;
return ribbonItem;
@@ -261,10 +290,11 @@ public static RibbonItem SetItemSize(this RibbonItem ribbonItem, Autodesk.Window
///
/// Set RibbonItem Text
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetText(this RibbonItem ribbonItem, string text = "")
+ public static TRibbonItem SetText(this TRibbonItem ribbonItem, string text = "") where TRibbonItem : RibbonItem
{
if (text == null)
return ribbonItem;
@@ -279,10 +309,11 @@ public static RibbonItem SetText(this RibbonItem ribbonItem, string text = "")
///
/// Set RibbonItem ToolTip
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetToolTip(this RibbonItem ribbonItem, string toolTip)
+ public static TRibbonItem SetToolTip(this TRibbonItem ribbonItem, string toolTip) where TRibbonItem : RibbonItem
{
if (toolTip != null)
ribbonItem.ToolTip = toolTip;
@@ -293,10 +324,11 @@ public static RibbonItem SetToolTip(this RibbonItem ribbonItem, string toolTip)
///
/// Set RibbonItem LongDescription
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetLongDescription(this RibbonItem ribbonItem, string longDescription)
+ public static TRibbonItem SetLongDescription(this TRibbonItem ribbonItem, string longDescription) where TRibbonItem : RibbonItem
{
if (longDescription != null)
ribbonItem.LongDescription = longDescription;
@@ -307,50 +339,56 @@ public static RibbonItem SetLongDescription(this RibbonItem ribbonItem, string l
///
/// Set RibbonItem ToolTipImage
///
+ /// RibbonItem
///
///
///
- public static RibbonItem SetToolTipImage(this RibbonItem ribbonItem, ImageSource toolTipImage)
+ public static TRibbonItem SetToolTipImage(this TRibbonItem ribbonItem, ImageSource toolTipImage) where TRibbonItem : RibbonItem
{
if (toolTipImage != null)
ribbonItem.ToolTipImage = toolTipImage;
return ribbonItem;
}
-
#endregion
#region Set RibbonButton
///
/// Set RibbonButton Image
///
- ///
+ /// RibbonButton
+ ///
///
///
- public static RibbonButton SetImage(this RibbonButton ribbonButton, ImageSource image)
+ public static TRibbonItem SetImage(this TRibbonItem ribbonItem, ImageSource image) where TRibbonItem : RibbonItem
{
if (image != null)
- ribbonButton.Image = image;
+ if (ribbonItem is RibbonButton ribbonButton)
+ ribbonButton.Image = image;
- return ribbonButton;
+ return ribbonItem;
}
///
/// Set RibbonButton LargeImage
///
- ///
+ /// RibbonButton
+ ///
///
///
- public static RibbonButton SetLargeImage(this RibbonButton ribbonButton, ImageSource largeImage)
+ public static TRibbonItem SetLargeImage(this TRibbonItem ribbonItem, ImageSource largeImage) where TRibbonItem : RibbonItem
{
if (largeImage != null)
{
- ribbonButton.LargeImage = largeImage;
- if (ribbonButton.Image == null)
- ribbonButton.Image = largeImage.Scale(0.5);
+ if (ribbonItem is RibbonButton ribbonButton)
+ {
+ ribbonButton.LargeImage = largeImage;
+ if (ribbonButton.Image == null)
+ ribbonButton.Image = largeImage.Scale(0.5);
+ }
}
- return ribbonButton;
+ return ribbonItem;
}
#endregion
diff --git a/ricaun.Revit.UI/RibbonItemExtension.cs b/ricaun.Revit.UI/RibbonItemExtension.cs
index 7b5a988..1cb270c 100644
--- a/ricaun.Revit.UI/RibbonItemExtension.cs
+++ b/ricaun.Revit.UI/RibbonItemExtension.cs
@@ -85,6 +85,16 @@ public static Autodesk.Windows.RibbonTab GetRibbonTab(string tabId)
return null;
}
+ ///
+ /// Get GetRibbonTabs
+ ///
+ ///
+ public static IList GetRibbonTabs()
+ {
+ var ribbon = Autodesk.Windows.ComponentManager.Ribbon;
+ return ribbon.Tabs;
+ }
+
///
/// GetRibbonPanel
///
diff --git a/ricaun.Revit.UI/RibbonPanelExtension.cs b/ricaun.Revit.UI/RibbonPanelExtension.cs
index 3ef15c4..0c6be0a 100644
--- a/ricaun.Revit.UI/RibbonPanelExtension.cs
+++ b/ricaun.Revit.UI/RibbonPanelExtension.cs
@@ -1,4 +1,5 @@
using Autodesk.Revit.UI;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -49,7 +50,6 @@ public static RibbonPanel CreatePanel(this UIControlledApplication application,
}
catch
{
- //ribbonManager = application.GetRibbonPanels(tabName).FirstOrDefault(r => r.Name.StartsWith(panelName) && r.Visible);
if (ribbonManager == null)
{
ribbonManager = application.CreateRibbonPanel(tabName, SafeRibbonPanelName(panelName));
@@ -66,8 +66,12 @@ public static RibbonPanel CreatePanel(this UIControlledApplication application,
///
public static RibbonPanel Remove(this RibbonPanel ribbonPanel)
{
+ foreach (var ribbonItem in ribbonPanel.GetRibbonItems())
+ ribbonItem.GetRibbonItem().RemoveQuickAccessToolBar();
+
ribbonPanel.Visible = false;
ribbonPanel.Enabled = false;
+
var panel = ribbonPanel.GetRibbonPanel();
panel.Tab.Panels.Remove(panel);
return ribbonPanel;
@@ -88,15 +92,14 @@ public static RibbonPanel Close(this RibbonPanel ribbonPanel)
///
/// NewPushButtonData
///
- ///
///
+ ///
///
///
- public static PushButtonData NewPushButtonData(this RibbonPanel ribbonPanel, string text = null) where TExternalCommand : class, IExternalCommand, new()
+ public static PushButtonData NewPushButtonData(this RibbonPanel ribbonPanel, Type commandType, string text = null)
{
- var commandType = typeof(TExternalCommand);
- var targetName = commandType.Name;
- var targetText = commandType.Name;
+ var targetName = commandType.GetName();
+ var targetText = targetName;
var assemblyName = commandType.Assembly.Location;
var className = commandType.FullName;
@@ -113,6 +116,19 @@ public static RibbonPanel Close(this RibbonPanel ribbonPanel)
return currentBtn;
}
+
+ ///
+ /// NewPushButtonData
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static PushButtonData NewPushButtonData(this RibbonPanel ribbonPanel, string text = null) where TExternalCommand : class, IExternalCommand, new()
+ {
+ var commandType = typeof(TExternalCommand);
+ return ribbonPanel.NewPushButtonData(commandType, text);
+ }
///
/// NewPushButtonData
///
diff --git a/ricaun.Revit.UI/TypeExtension.cs b/ricaun.Revit.UI/TypeExtension.cs
new file mode 100644
index 0000000..3a7ae93
--- /dev/null
+++ b/ricaun.Revit.UI/TypeExtension.cs
@@ -0,0 +1,27 @@
+using System;
+
+namespace ricaun.Revit.UI
+{
+ ///
+ /// TypeExtension
+ ///
+ public static class TypeExtension
+ {
+ ///
+ /// Get Name of the with GenericArguments
+ ///
+ ///
+ ///
+ public static string GetName(this Type type)
+ {
+ var name = type.Name;
+ if (type.IsGenericType)
+ {
+ foreach (var generic in type.GetGenericArguments())
+ name += $"[{generic}]";
+ }
+ return name;
+ }
+
+ }
+}
diff --git a/ricaun.Revit.UI/ricaun.Revit.UI.csproj b/ricaun.Revit.UI/ricaun.Revit.UI.csproj
index eaf3271..0605121 100644
--- a/ricaun.Revit.UI/ricaun.Revit.UI.csproj
+++ b/ricaun.Revit.UI/ricaun.Revit.UI.csproj
@@ -77,7 +77,7 @@
ricaun.Revit.UI
- 0.0.5
+ 0.0.6
{2064ba4d-5527-41e9-8b76-0cbfefa35900}