Skip to content

Commit

Permalink
Merge pull request #1 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
ricaun authored Apr 8, 2024
2 parents 5ef8194 + 3e29104 commit 8d9f671
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Build/Build.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>.</NukeRootDirectory>
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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
- Update Event images.

## [1.0.0] / 2024-02-01
- Add Icons
- Add Button Start / Stop
Expand All @@ -12,4 +16,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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Build](../../actions/workflows/Build.yml/badge.svg)](../../actions)

The `RevitAddin.VisualStudioDebug` plugin allow to enable debug in the current section of Revit and Visual Studio.

This project was generated by the [ricaun.AppLoader](https://ricaun.com/AppLoader/) Revit plugin.

## Usage

In the `Add-Ins` tab the panel `Debug` is created with three buttons `Start`, `Event`, and `Stop`.

![Debug](assets/Debug.PNG)![Debug-Event](assets/Debug-Event.PNG)![Debug-Stop](assets/Debug-Stop.PNG)

* `Start`: Start Debugging using Visual Studio process.
* `Event`: Start Debugging using Visual Studio process when an assembly is loaded in the `AppDomain`.
* `Stop`: Stop Debugging using Visual Studio process.

## Installation

* Download and install [RevitAddin.VisualStudioDebug.exe](../../releases/latest/download/RevitAddin.VisualStudioDebug.zip)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
71 changes: 68 additions & 3 deletions RevitAddin.VisualStudioDebug/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ namespace RevitAddin.VisualStudioDebug.Revit
[AppLoader]
public class App : IExternalApplication
{
const string ContextualHelpUrl = "https://github.com/ricaun-io/RevitAddin.VisualStudioDebug";
private static RibbonPanel ribbonPanel;
private static VisualStudioDebugAttach visualStudioDebugAttach;
private static RibbonButton ribbonEventButton;
public Result OnStartup(UIControlledApplication application)
{
//Console.WriteLine(application);
Expand All @@ -27,25 +29,70 @@ public Result OnStartup(UIControlledApplication application)

var startButton = ribbonPanel.CreatePushButton<CommandPlay>("Start")
.SetLargeImage("Resources/Play-Light.ico")
.SetToolTip("Start Debugging using Visual Studio process.");
.SetToolTip("Start Debugging using Visual Studio process.")
.SetContextualHelp(ContextualHelpUrl);

var eventButton = ribbonPanel.CreatePushButton<CommandEvent>("Event")
.SetLargeImage("Resources/Event-Light.ico")
.SetToolTip("Start Debugging using Visual Studio process when an assembly is loaded in the AppDomain.")
.SetContextualHelp(ContextualHelpUrl);

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

ribbonPanel.RowStackedItems(
startButton,
//ribbonPanel.CreatePushButton<CommandPause>("Pause").SetLargeImage("Resources/Pause-Light.ico"),
eventButton,
stopButton
);

ribbonEventButton = eventButton;

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();
UpdateButtonEventImage();
}
}

private static bool EventLoad;

private static void EventMonitor()
{
EventLoad = !EventLoad;
UpdateButtonEventImage();
}

private static void UpdateButtonEventImage()
{
if (EventLoad)
{
ribbonEventButton?.SetLargeImage("Resources/Event-Stop-Light.ico");
}
else
{
ribbonEventButton?.SetLargeImage("Resources/Event-Light.ico");
}
}

public Result OnShutdown(UIControlledApplication application)
{
ribbonPanel?.Remove();
visualStudioDebugAttach?.Dispose();

AppDomain.CurrentDomain.AssemblyLoad -= CurrentDomain_AssemblyLoad;

return Result.Succeeded;
}

Expand All @@ -62,6 +109,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 Expand Up @@ -92,6 +92,10 @@
<ItemGroup>
<None Remove="Resources\About-Dark.ico" />
<None Remove="Resources\About-Light.ico" />
<None Remove="Resources\Event-Dark.ico" />
<None Remove="Resources\Event-Light.ico" />
<None Remove="Resources\Event-Stop-Dark.ico" />
<None Remove="Resources\Event-Stop-Light.ico" />
<None Remove="Resources\Pause-Dark.ico" />
<None Remove="Resources\Pause-Light.ico" />
<None Remove="Resources\Play-Dark.ico" />
Expand All @@ -114,6 +118,10 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\Event-Dark.ico" />
<Resource Include="Resources\Event-Light.ico" />
<Resource Include="Resources\Event-Stop-Dark.ico" />
<Resource Include="Resources\Event-Stop-Light.ico" />
<Resource Include="Resources\Revit.ico" />
</ItemGroup>

Expand Down
Binary file added assets/Debug-Event.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Debug-Stop.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Debug.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8d9f671

Please sign in to comment.