1- using System . IO ;
2- using System . Reflection ;
3- using Autodesk . Revit . UI ;
4- using Autodesk . Revit . UI . Events ;
1+ using Autodesk . Revit . UI ;
2+ using Nice3point . Revit . Toolkit . External ;
53using RevitDevTool . Commands ;
6- using RevitDevTool . Extensions ;
7- using RevitDevTool . Handlers ;
84
95namespace RevitDevTool ;
106
11- [ PublicAPI ]
12- public class Application : IExternalApplication
7+ [ UsedImplicitly ]
8+ public class Application : ExternalApplication
139{
14- public static UIControlledApplication RevitUiControlledApplication { get ; private set ; } = null ! ;
15- public static UIApplication RevitUiApplication => new RibbonItemEventArgs ( ) . Application ;
16- public static Autodesk . Revit . ApplicationServices . Application RevitApplication => RevitUiApplication . Application ;
17- public static UIDocument ? RevitActiveUiDocument => RevitUiApplication . ActiveUIDocument ;
18- public static Document ? RevitActiveDocument => RevitActiveUiDocument ? . Document ;
19- public static bool IsInRevitApiMode => RevitUiApplication . ActiveAddInId is not null ;
20-
21- public Result OnStartup ( UIControlledApplication application )
10+ public override void OnStartup ( )
2211 {
23- ResolveAssemblies ( ) ;
24- RevitUiControlledApplication = application ;
2512 ExternalEventController . Register ( ) ;
26- AddButton ( application ) ;
27- AddDockable ( application ) ;
28- return Result . Succeeded ;
13+ AddButton ( Application ) ;
14+ AddDockable ( Application ) ;
2915 }
3016
31- public Result OnShutdown ( UIControlledApplication application )
32- {
33- return Result . Succeeded ;
34- }
35-
3617 private static void AddDockable ( UIControlledApplication application )
3718 {
3819 TraceCommand . RegisterDockablePane ( application ) ;
3920 }
4021
4122 private static void AddButton ( UIControlledApplication application )
4223 {
43- var panel = application . CreateRibbonPanel ( "DevTool ") ;
24+ var panel = application . CreatePanel ( "External Tools ") ;
4425
45- panel . AddPushButton < TraceCommand > ( "Trace\n Panel" )
46- . SetLargeImage ( "/RevitDevTool;component/Images/log.png" )
47- . SetLongDescription ( "Display trace data" ) ;
48- }
49-
50- private static void ResolveAssemblies ( )
51- {
52- var currentAssemblyPath = Assembly . GetExecutingAssembly ( ) . Location ;
53- var currentAssemblyDirectory = Path . GetDirectoryName ( currentAssemblyPath ) ;
54- if ( currentAssemblyDirectory is null ) return ;
55- var assemblyFiles = Directory . GetFiles ( currentAssemblyDirectory , "*.dll" ) ;
56- foreach ( var assemblyFile in assemblyFiles )
57- {
58- Assembly . LoadFrom ( assemblyFile ) ;
59- }
26+ panel . AddPushButton < TraceCommand > ( "Trace Panel" )
27+ . SetLargeImage ( "/RevitDevTool;component/Resources/Icons/TraceCommand32_light.tiff" )
28+ . SetLongDescription ( "Show/Hide Trace Panel" ) ;
6029 }
6130}
0 commit comments