1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- using Autodesk.Windows;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace LRH.Tool.RevitUI
- {
-
-
-
- public class RevitUIUtils
- {
-
-
-
-
- public static StringBuilder CollectCommandIds()
- {
- RibbonControl control = ComponentManager.Ribbon;
- StringBuilder builder = new StringBuilder();
- foreach (var currentTab in control.Tabs)
- {
-
-
- foreach (var currentPanel in currentTab.Panels)
- {
-
- foreach (var item in currentPanel.Source.Items)
- {
-
-
-
-
- if(item is RibbonListButton listButton)
- {
- foreach (var currentItem in listButton.Items)
- {
- if (currentItem.Id == "ID_TOGGLE_PROPERTIES_PALETTE")
- {
- }
- builder.Append(string.Format("【{0}】", currentTab.Title));
- builder.Append("→");
- builder.Append(string.Format("【{0}】", currentPanel.Source.Title));
- builder.Append("→");
- builder.Append(string.Format("【{0}】", currentItem.Text));
- builder.Append(string.Format(":{0}", currentItem.Id));
- builder.AppendLine();
- }
- }
- else
- {
- builder.Append(string.Format("【{0}】", currentTab.Title));
- builder.Append("→");
- builder.Append(string.Format("【{0}】", currentPanel.Source.Title));
- builder.Append("→");
- builder.Append(string.Format("【{0}】", item.Text));
- builder.Append(string.Format(":{0}", item.Id));
- builder.AppendLine();
- }
-
- }
- }
- }
- return builder;
- }
- #region 命令UI信息
-
-
-
-
-
-
-
- #endregion
- public static void SetIsChecked(RibbonItem item, bool flag)
- {
- var useType = typeof(RibbonItem).Assembly.GetType("Autodesk.Internal.Windows.RibbonCommandItemBindings");
- MethodInfo mi = useType.GetMethod("TrySetIsChecked");
- if (mi != null)
- {
- mi?.Invoke(null, new object[] { item,flag });
- }
- }
- }
- }
|