diff --git a/CHANGELOG.md b/CHANGELOG.md index 406741e..269dc64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ 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). +## [1.1.0] / 2024-03-13 +- Add event feature + ## [1.0.0] / 2024-02-01 - Add Icons - Add Button Start / Stop @@ -12,4 +15,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - First Release [vNext]: ../../compare/1.0.0...HEAD +[1.1.0]: ../../compare/1.0.0...1.1.0 [1.0.0]: ../../compare/1.0.0 \ No newline at end of file diff --git a/RevitAddin.VisualStudioDebug/Revit/App.cs b/RevitAddin.VisualStudioDebug/Revit/App.cs index 37adbcb..3b3460c 100644 --- a/RevitAddin.VisualStudioDebug/Revit/App.cs +++ b/RevitAddin.VisualStudioDebug/Revit/App.cs @@ -29,23 +29,50 @@ public Result OnStartup(UIControlledApplication application) .SetLargeImage("Resources/Play-Light.ico") .SetToolTip("Start Debugging using Visual Studio process."); + var eventButton = ribbonPanel.CreatePushButton("Event") + .SetLargeImage("Resources/Pause-Light.ico") + .SetToolTip("Start Debugging using Visual Studio process when AssemblyLoad event happen."); + var stopButton = ribbonPanel.CreatePushButton("Stop") .SetLargeImage("Resources/Stop-Light.ico") .SetToolTip("Stop Debugging using Visual Studio process."); ribbonPanel.RowStackedItems( startButton, + eventButton, //ribbonPanel.CreatePushButton("Pause").SetLargeImage("Resources/Pause-Light.ico"), stopButton ); + AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad; + return Result.Succeeded; } + private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) + { + if (EventLoad) + { + EventLoad = false; + visualStudioDebugAttach?.Dispose(); + visualStudioDebugAttach = new VisualStudioDebugAttach(); + } + } + + private static bool EventLoad; + + private static void EventMonitor() + { + EventLoad = !EventLoad; + } + public Result OnShutdown(UIControlledApplication application) { ribbonPanel?.Remove(); visualStudioDebugAttach?.Dispose(); + + AppDomain.CurrentDomain.AssemblyLoad -= CurrentDomain_AssemblyLoad; + return Result.Succeeded; } @@ -62,6 +89,24 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme return Result.Succeeded; } + public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) + { + return System.Diagnostics.Debugger.IsAttached == false && EventLoad == false; + } + } + + [Transaction(TransactionMode.Manual)] + public class CommandEvent : IExternalCommand, IExternalCommandAvailability + { + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) + { + UIApplication uiapp = commandData.Application; + + EventMonitor(); + + return Result.Succeeded; + } + public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) { return System.Diagnostics.Debugger.IsAttached == false; diff --git a/RevitAddin.VisualStudioDebug/RevitAddin.VisualStudioDebug.csproj b/RevitAddin.VisualStudioDebug/RevitAddin.VisualStudioDebug.csproj index 4dd129b..a4b82d5 100644 --- a/RevitAddin.VisualStudioDebug/RevitAddin.VisualStudioDebug.csproj +++ b/RevitAddin.VisualStudioDebug/RevitAddin.VisualStudioDebug.csproj @@ -63,7 +63,7 @@ RevitAddin.VisualStudioDebug - 1.0.0 + 1.1.0 {C917B240-4C2B-431A-BB03-730BE9802F25}