Skip to content

Commit

Permalink
Merge pull request #5 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Version 0.2.2
  • Loading branch information
ricaun authored Aug 14, 2024
2 parents 03e620f + 646ceff commit 585841f
Show file tree
Hide file tree
Showing 19 changed files with 206 additions and 190 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
dotnet-version: |
7.0.x
8.0.x
- name: "NuGet Add Source Organization"
run: if ("${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }}" -ne "") { dotnet nuget add source --username ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_USERNAME }} --password ${{ secrets.ORGANIZATION_SOURCE_PACKAGE_PASSWORD }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{github.repository_owner}}/index.json" }
- name: Run './build/build.cmd'
run: ./build/build.cmd --root ./build
Expand Down
10 changes: 10 additions & 0 deletions Build/.nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"PreReleaseFilter": {
"type": "array",
"items": {
"type": "string"
}
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
Expand Down Expand Up @@ -99,8 +105,10 @@
"Build",
"Clean",
"Compile",
"GitPreRelease",
"GitRelease",
"Pack",
"PrePack",
"Release",
"Sign"
]
Expand All @@ -119,8 +127,10 @@
"Build",
"Clean",
"Compile",
"GitPreRelease",
"GitRelease",
"Pack",
"PrePack",
"Release",
"Sign"
]
Expand Down
2 changes: 1 addition & 1 deletion Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using ricaun.Nuke;
using ricaun.Nuke.Components;

class Build : NukeBuild, IPublishPack
class Build : NukeBuild, IPublishPack, IPrePack
{
public static int Main() => Execute<Build>(x => x.From<IPublishPack>().Build);
}
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>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>.</NukeRootDirectory>
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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).

## [0.2.2] / 2023-08-14
### Features
- Add `XmlnsPrefix` and `XmlnsDefinition` to `Revit.Busy` namespace.
### Updated
- Update references to work with net code.
- Clear main project and move files to `Example`

## [0.2.1] / 2023-03-04
### Features
- Update `net8.0-windows` version for Revit 2025
Expand Down Expand Up @@ -32,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

[vNext]: ../../compare/1.0.0...HEAD
[1.0.0]: ../../compare/1.0.0
[0.2.2]: ../../compare/0.2.1...0.2.2
[0.2.1]: ../../compare/0.2.0...0.2.1
[0.2.0]: ../../compare/0.1.2...0.2.0
[0.1.2]: ../../compare/0.1.1...0.1.2
Expand Down
5 changes: 5 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<Version>0.2.2</Version>
</PropertyGroup>
</Project>
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@
[![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
[![Build](../../actions/workflows/Build.yml/badge.svg)](../../actions)

`Revit.Busy` package provides a static control to manage the busy state of Revit using the `Idling` event.

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

## Exemple
### Initialize
Static initialization of the `Revit.Busy` control.
```c#
RevitBusyControl.Initialize(application);
```

### Binding

Binding to the `IsRevitBusy` property.
```xml
xmlns:busy="clr-namespace:Revit.Busy"
xmlns:busy="http://schemas.revit.busy.com/2024/xaml/presentation"
```
```xml
{Binding IsRevitBusy, Source={x:Static busy:RevitBusyControl.Control}}
```

## License

This project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License).
This project is [licensed](LICENSE) under the [MIT License](https://en.wikipedia.org/wiki/MIT_License).

---

Expand Down
84 changes: 22 additions & 62 deletions Revit.Busy.Example/Revit.Busy.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,38 @@
</PropertyGroup>

<!-- RevitVersion -->
<PropertyGroup>
<TargetFrameworks>net46;net47;net48;net8.0-windows</TargetFrameworks>
</PropertyGroup>
<Choose>
<When Condition="$(Configuration.Contains('2017'))">
<When Condition="$(TargetFramework.StartsWith('net46'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2018'))">
<PropertyGroup>
<RevitVersion>2018</RevitVersion>
<TargetFramework>net46</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2019'))">
<When Condition="$(TargetFramework.StartsWith('net47'))">
<PropertyGroup>
<RevitVersion>2019</RevitVersion>
<TargetFramework>net47</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2020'))">
<PropertyGroup>
<RevitVersion>2020</RevitVersion>
<TargetFramework>net47</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2021'))">
<When Condition="$(TargetFramework.StartsWith('net48'))">
<PropertyGroup>
<RevitVersion>2021</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2022'))">
<PropertyGroup>
<RevitVersion>2022</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2023'))">
<PropertyGroup>
<RevitVersion>2023</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<When Condition="$(Configuration.Contains('2024'))">
<PropertyGroup>
<RevitVersion>2024</RevitVersion>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
<TargetFramework>net46</TargetFramework>
<RevitVersion>2025</RevitVersion>
</PropertyGroup>
</Otherwise>
</Choose>

<!-- RevitVersion -->
<PropertyGroup>
<TargetFrameworks>net46;net8.0-windows</TargetFrameworks>
<!-- Net Core -->
<PropertyGroup Condition="!$(TargetFramework.StartsWith('net4'))">
<EnableDynamicLoading>true</EnableDynamicLoading>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<GenerateDependencyFile>false</GenerateDependencyFile>
</PropertyGroup>
<Choose>
<When Condition="$(TargetFramework.StartsWith('net4'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<RevitVersion>2025</RevitVersion>
</PropertyGroup>
</Otherwise>
</Choose>

<!-- Release -->
<PropertyGroup Condition="!$(Configuration.Contains('Debug'))">
Expand Down Expand Up @@ -112,8 +71,6 @@

<PropertyGroup>
<PackageId>Revit.Busy.Example</PackageId>
<Version>1.0.0</Version>
<ProjectGuid>{ce1d2870-abe0-4096-95db-6d6db724a2e9}</ProjectGuid>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -126,8 +83,8 @@
</PropertyGroup>

<PropertyGroup>
<Company>Company</Company>
<Authors>Authors</Authors>
<Company>ricaun</Company>
<Authors>Luiz Henrique Cassettari</Authors>
<Description>Revit Add-In Description for $(PackageId).</Description>
<CopyrightYears>$([System.DateTime]::Now.ToString('yyyy'))</CopyrightYears>
</PropertyGroup>
Expand All @@ -138,15 +95,12 @@
<Copyright>Copyright © $(CopyrightYears) $(Company)</Copyright>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
<ItemGroup>
<PackageReference Include="ricaun.Revit.UI" Version="*" />
<PackageReference Include="ricaun.Revit.UI.Tasks" Version="*" />
<PackageReference Include="ricaun.Revit.Mvvm" Version="*" />
</ItemGroup>

<ItemGroup>
<Folder Include="Revit\Commands" />
</ItemGroup>

<ItemGroup>
<None Include="Revit\App.cs" />
<None Include="Revit\Commands\Command.cs" />
Expand All @@ -172,4 +126,10 @@
<ProjectReference Include="..\Revit.Busy\Revit.Busy.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Update="Revit\Views\BusyView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>

</Project>
47 changes: 27 additions & 20 deletions Revit.Busy.Example/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,62 @@
#if NETFRAMEWORK
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Revit.Busy;
using ricaun.Revit.UI;
using ricaun.Revit.UI.Tasks;
using System;
namespace Revit.Busy.Example.Revit
{
[AppLoader]
public class App : IExternalApplication
{
private static RevitTaskService revitTaskService;
public static IRevitTask RevitTask => revitTaskService;

private static RibbonPanel ribbonPanel;
private static RibbonItem ribbonItem;
public static RevitBusyService RevitBusyService;
public Result OnStartup(UIControlledApplication application)
{
revitTaskService = new RevitTaskService(application);
revitTaskService.Initialize();

ribbonPanel = application.CreatePanel("Example");
ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>("RevitBusy")
var ribbonItem = ribbonPanel.CreatePushButton<Commands.Command>("RevitBusy")
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");

RevitBusyControl.Initialize(application);
RevitBusyControl.Control.PropertyChanged += RevitBusyControlPropertyChanged;

UpdateLargeImageBusy(ribbonItem, RevitBusyControl.Control);
var viewButton = ribbonPanel.CreatePushButton<Commands.CommandView>("View")
.SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico");

return Result.Succeeded;
}
RevitBusyService = new RevitBusyService(application);
RevitBusyService.SetInterval(100);
RevitBusyService.PropertyChanged += (s, e) =>
{
UpdateLargeImageBusy(ribbonItem, RevitBusyService.IsRevitBusy);
UpdateLargeImageBusy(viewButton, RevitBusyService.IsRevitBusy);
};

private void RevitBusyControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
Console.WriteLine($"RevitBusyControl PropertyChanged {e.PropertyName} {RevitBusyControl.Control.IsRevitBusy}");
RevitBusyControl.Initialize(application);

var control = sender as RevitBusyService;
UpdateLargeImageBusy(ribbonItem, control);
return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication application)
{
ribbonPanel?.Remove();
if (RevitBusyControl.Control is not null)
RevitBusyControl.Control.PropertyChanged -= RevitBusyControlPropertyChanged;

RevitBusyService?.Dispose();
revitTaskService?.Dispose();

return Result.Succeeded;
}

private static void UpdateLargeImageBusy(RibbonItem ribbonItem, RevitBusyService control)
private static void UpdateLargeImageBusy(RibbonItem ribbonItem, bool revitBusy)
{
const string LargeImageIsBusy = "/UIFrameworkRes;component/ribbon/images/close.ico";
const string LargeImageNoBusy = "/UIFrameworkRes;component/ribbon/images/add.ico";
if (control.IsRevitBusy)
if (revitBusy)
ribbonItem.SetLargeImage(LargeImageIsBusy);
else
ribbonItem.SetLargeImage(LargeImageNoBusy);
}
}
}
#endif
}
17 changes: 16 additions & 1 deletion Revit.Busy.Example/Revit/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Revit.Busy.Example.Revit.Commands
{
[Transaction(TransactionMode.Manual)]
public class Command : IExternalCommand
public class Command : IExternalCommand, IExternalCommandAvailability
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
{
Expand All @@ -16,5 +16,20 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme

return Result.Succeeded;
}

public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) { return true; }
}

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

new Views.BusyView().Show();

return Result.Succeeded;
}
}
}
Loading

0 comments on commit 585841f

Please sign in to comment.