Skip to content

Commit

Permalink
Add ability to force large icons with just the small image's existenc…
Browse files Browse the repository at this point in the history
…e. This fixes #13. How: If the small image does not exist, the button must be a large button.
  • Loading branch information
johnpierson committed Apr 23, 2024
1 parent 7711f35 commit 8139e84
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
Binary file modified _Release/Revit2025/Relay/Relay.dll
Binary file not shown.
37 changes: 35 additions & 2 deletions src/Utilities/RibbonUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Relay.Classes;
using System.Reflection;
using Autodesk.Revit.DB.Electrical;
using Autodesk.Windows;
using RibbonItem = Autodesk.Revit.UI.RibbonItem;

namespace Relay.Utilities
{
Expand Down Expand Up @@ -86,14 +88,45 @@ public static void AddItems(Autodesk.Revit.UI.RibbonPanel panelToUse, string[] d
{
foreach (var pushButton in pushButtonDatas)
{
panelToUse.AddItem(pushButton);
var newButton = panelToUse.AddItem(pushButton);
//add to our global list
Globals.RelayButtons.Add(newButton.ToolTip.GetStringBetweenCharacters('[', ']'), newButton);
}
return;
}

//check if the DYN only has a large image available, if so, make it large only
List<PushButtonData> remainingToCreate = new List<PushButtonData>();
foreach (var pushButton in pushButtonDatas)
{
try
{
string dynPath = pushButton.ToolTip.GetStringBetweenCharacters('[', ']');
string smolImage = dynPath.Replace(".dyn", "_16.png");

if (!File.Exists(smolImage))
{
var newButton = panelToUse.AddItem(pushButton);

//add to our global list
Globals.RelayButtons.Add(newButton.ToolTip.GetStringBetweenCharacters('[', ']'), newButton);
}
else
{
remainingToCreate.Add(pushButton);
}
}
catch (Exception)
{
//weird error, ignore.
}

}


List<RibbonItem> createdButtons = new List<RibbonItem>();

var splitButtons = SplitList(pushButtonDatas, 2);
var splitButtons = SplitList(remainingToCreate, 2);

foreach (var buttonGroup in splitButtons)
{
Expand Down

0 comments on commit 8139e84

Please sign in to comment.