Skip to content

Commit

Permalink
Add event feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Mar 13, 2024
1 parent 5ef8194 commit a0c3d36
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
45 changes: 45 additions & 0 deletions RevitAddin.VisualStudioDebug/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommandEvent>("Event")
.SetLargeImage("Resources/Pause-Light.ico")
.SetToolTip("Start Debugging using Visual Studio process when AssemblyLoad event happen.");

var stopButton = ribbonPanel.CreatePushButton<CommandStop>("Stop")
.SetLargeImage("Resources/Stop-Light.ico")
.SetToolTip("Stop Debugging using Visual Studio process.");

ribbonPanel.RowStackedItems(
startButton,
eventButton,
//ribbonPanel.CreatePushButton<CommandPause>("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;
}

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

<PropertyGroup>
<PackageId>RevitAddin.VisualStudioDebug</PackageId>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<ProjectGuid>{C917B240-4C2B-431A-BB03-730BE9802F25}</ProjectGuid>
</PropertyGroup>

Expand Down

0 comments on commit a0c3d36

Please sign in to comment.