Skip to content

Commit

Permalink
Button Start / Stop
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Feb 2, 2024
1 parent f4acf74 commit 41c4007
Show file tree
Hide file tree
Showing 16 changed files with 141 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ 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.0.0] / YYYY-MM-DD
## [1.0.0] / 2024-02-01
- Add Icons
- Add Button Start / Stop

## [1.0.0] / 2023-07-01
- First Release

[vNext]: ../../compare/1.0.0...HEAD
Expand Down
7 changes: 7 additions & 0 deletions RevitAddin.VisualStudioDebug/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"profiles": {
"RevitAddin.VisualStudioDebug": {
"commandName": "Project"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added RevitAddin.VisualStudioDebug/Resources/Play-Dark.ico
Binary file not shown.
Binary file not shown.
Binary file added RevitAddin.VisualStudioDebug/Resources/Stop-Dark.ico
Binary file not shown.
Binary file not shown.
Binary file added RevitAddin.VisualStudioDebug/Resources/User-Dark.ico
Binary file not shown.
Binary file not shown.
83 changes: 80 additions & 3 deletions RevitAddin.VisualStudioDebug/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using RevitAddin.VisualStudioDebug.Services;
using ricaun.Revit.UI;
using ricaun.Revit.UI.Drawing;
using System;

namespace RevitAddin.VisualStudioDebug.Revit
Expand All @@ -9,19 +12,93 @@ namespace RevitAddin.VisualStudioDebug.Revit
public class App : IExternalApplication
{
private static RibbonPanel ribbonPanel;
private static VisualStudioDebugAttach visualStudioDebugAttach;
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("VisualStudioDebug");
ribbonPanel.CreatePushButton<Commands.Command>()
.SetLargeImage(Properties.Resources.Revit.GetBitmapSource());
//Console.WriteLine(application);
//visualStudioDebugAttach = new VisualStudioDebugAttach();

ribbonPanel = application.CreatePanel("Debug");

//var button = ribbonPanel.CreatePushButton<Commands.Command>()
// .SetLargeImage(Properties.Resources.Revit.GetBitmapSource());

//ribbonPanel.SetDialogLauncher(button);

ribbonPanel.RowStackedItems(
ribbonPanel.CreatePushButton<CommandPlay>("Start").SetLargeImage("Resources/Play-Light.ico"),
//ribbonPanel.CreatePushButton<CommandPause>("Pause").SetLargeImage("Resources/Pause-Light.ico"),
ribbonPanel.CreatePushButton<CommandStop>("Stop").SetLargeImage("Resources/Stop-Light.ico")
);

return Result.Succeeded;
}

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


[Transaction(TransactionMode.Manual)]
public class CommandPlay : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;
visualStudioDebugAttach?.Dispose();
visualStudioDebugAttach = new VisualStudioDebugAttach();

return Result.Succeeded;
}

public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return System.Diagnostics.Debugger.IsAttached == false;
}
}

[Transaction(TransactionMode.Manual)]
public class CommandPause : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;

VisualStudioDebugUtils.DTE.Debugger.Break();

return Result.Succeeded;
}

public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return visualStudioDebugAttach is not null;
}
}

[Transaction(TransactionMode.Manual)]
public class CommandStop : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;

VisualStudioDebugUtils.DTE.Debugger.Stop();

visualStudioDebugAttach?.Dispose();
visualStudioDebugAttach = null;

return Result.Succeeded;
}

public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return System.Diagnostics.Debugger.IsAttached;
}
}

}

}
1 change: 1 addition & 0 deletions RevitAddin.VisualStudioDebug/Revit/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
return Result.Succeeded;
}
}

}
22 changes: 22 additions & 0 deletions RevitAddin.VisualStudioDebug/Revit/Commands/CommandError.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace RevitAddin.VisualStudioDebug.Revit.Commands
{
[Transaction(TransactionMode.Manual)]
public class CommandError : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
UIApplication uiapp = commandData.Application;

int i = 1;
int j = 0;
int k = i / j;

return Result.Succeeded;
}
}

}
26 changes: 26 additions & 0 deletions RevitAddin.VisualStudioDebug/RevitAddin.VisualStudioDebug.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@
<Copyright>Copyright © $(CopyrightYears) $(Company)</Copyright>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\About-Dark.ico" />
<None Remove="Resources\About-Light.ico" />
<None Remove="Resources\Pause-Dark.ico" />
<None Remove="Resources\Pause-Light.ico" />
<None Remove="Resources\Play-Dark.ico" />
<None Remove="Resources\Play-Light.ico" />
<None Remove="Resources\Stop-Dark.ico" />
<None Remove="Resources\Stop-Light.ico" />
<None Remove="Resources\User-Dark.ico" />
<None Remove="Resources\User-Light.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ricaun.Revit.UI" Version="*" />
<PackageReference Include="ricaun.Revit.Mvvm" Version="*" />
Expand Down Expand Up @@ -154,6 +167,19 @@
<PackageReference Include="Revit_All_Main_Versions_API_x64" Version="$(RevitVersion).*" IncludeAssets="build; compile" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\About-Dark.ico" />
<Resource Include="Resources\About-Light.ico" />
<Resource Include="Resources\Pause-Dark.ico" />
<Resource Include="Resources\Pause-Light.ico" />
<Resource Include="Resources\Play-Dark.ico" />
<Resource Include="Resources\Play-Light.ico" />
<Resource Include="Resources\Stop-Dark.ico" />
<Resource Include="Resources\Stop-Light.ico" />
<Resource Include="Resources\User-Dark.ico" />
<Resource Include="Resources\User-Light.ico" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand Down

0 comments on commit 41c4007

Please sign in to comment.