Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.7.0 #36

Merged
merged 25 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,29 @@ 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.7.0] / 2024-07-06 - 2024-07-25
### Features
- Auto set image based on the theme of the Ribbon using `light` and `dark` image pattern.
- `RibbonThemeUtils` to change the theme of the Ribbon. (Revit 2019+)
- Set project configuration to support `net47` and `net48`.
### Updated
- Change `GetRibbonItem` to `GetRibbonItem_Alternative` to fix null when panel is removed.
- Update `SetImage` to work with `ComboBoxMember`
- Add `CreateComboBoxMember` to create `ComboBoxMember`.
- Add `RibbonThemeImageUtils` to change theme for `ImageSource`.
- Update `RibbonThemeImageUtils` with public `GetThemeImageSource`.
- Add `RibbonThemePanelUtils` to update the theme for itens in the `RibbonPanel`.
- Update `RibbonPanel` create and remove to update the theme of the itens.
- Update `TryThemeImage` to not change assembly name if is a resource component.
- Remove `ConsoleAttribute` and `SetOrderPanels` obsolete methods.
- Update `GetAutodeskOwner` to obsolete only in `net46`.
### Tests
- Add `RibbonThemeUtilsTests` to test the theme change event.
- Add `TryThemeImage` tests to replace image with theme.
- Add `ComboBoxMember` tests for `Image`, `Group` and `Current`.
### Example
- Add `AppTheme` to test theme change features for `RibbonItem`.

## [0.6.2] / 2024-01-09 - 2024-02-05
### Features
- `SetListImageSize` to change the size of the image in the `PulldownButton` and `SplitButton`.
Expand Down Expand Up @@ -337,6 +360,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- First Release

[vNext]: ../../compare/1.0.0...HEAD
[0.7.0]: ../../compare/0.6.2...0.7.0
[0.6.2]: ../../compare/0.6.1...0.6.2
[0.6.1]: ../../compare/0.6.0...0.6.1
[0.6.0]: ../../compare/0.5.7...0.6.0
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>0.6.2</Version>
<Version>0.7.0</Version>
</PropertyGroup>
</Project>
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This project was generated by the [ricaun.AppLoader](https://ricaun.com/AppLoade
[AppLoader]
public class App : IExternalApplication
{
private static RibbonPanel ribbonPanel;
private RibbonPanel ribbonPanel;
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("PanelName");
Expand Down Expand Up @@ -165,6 +165,11 @@ comboBox.AddDropDownClosed(OnDropDownClosed);
comboBox.RemoveDropDownClosed(OnDropDownClosed);
```
```C#
ComboBoxMember comboBoxMember = comboBox.CreateComboBoxMember();
// comboBox.CreateComboBoxMember("Name");
// comboBox.CreateComboBoxMember("Name", "GroupName");
```
```C#
ComboBoxData comboBoxData = ribbonPanel.NewComboBoxData();
// ribbonPanel.NewComboBoxData("ComboBoxDataName");
```
Expand Down Expand Up @@ -393,7 +398,7 @@ awRibbonPanel.SetDialogLauncher(ribbonCommandItem);

## 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
Binary file added ricaun.Revit.UI.Example/Resources/Box-Grey-Dark.ico
Binary file not shown.
Binary file added ricaun.Revit.UI.Example/Resources/Box-Grey-Light.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion ricaun.Revit.UI.Example/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ricaun.Revit.UI.Example.Revit
{
[AppLoader]
//[AppLoader]
//[Obsolete]
public class App : IExternalApplication
{
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Revit.UI.Example/Revit/AppList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ricaun.Revit.UI.Example.Revit
{
[AppLoader]
//[AppLoader]
public class AppList : IExternalApplication
{
private static RibbonPanel ribbonPanel;
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Revit.UI.Example/Revit/AppResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ricaun.Revit.UI.Example.Revit
{
[AppLoader]
//[AppLoader]
public class AppResource : IExternalApplication
{
private static RibbonPanel ribbonPanel;
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Revit.UI.Example/Revit/AppStacked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace ricaun.Revit.UI.Example.Revit
{
[AppLoader]
//[AppLoader]
public class AppStacked : IExternalApplication
{
private static RibbonPanel ribbonPanel;
Expand Down
121 changes: 121 additions & 0 deletions ricaun.Revit.UI.Example/Revit/AppTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ricaun.Revit.UI.Utils;

namespace ricaun.Revit.UI.Example.Revit
{
[AppLoader]
public class AppTheme : IExternalApplication
{
static string LIGHT = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Grey-Dark.ico";
static string DARK = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Grey-Dark.ico";
static string LIGHT_RED = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Red-Light.ico";
static string DARK_RED = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Red-Dark.ico";
static string LIGHT_GREEN = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Green-Light.ico";
static string DARK_GREEN = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Green-Dark.ico";
static string LIGHT_BLUE = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Blue-Light.ico";
static string DARK_BLUE = "https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/1.1.0/Box-Blue-Dark.ico";
const string REVIT = "/UIFrameworkRes;component/ribbon/images/revit.ico";
const string Base64Image = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAHYcAAB2HAY/l8WUAAABOSURBVEhLtccxDQAwDMCw8odRdIWxP7cn+fHM3l8913M913M913M913M913M913M913M913M913M913M913M913M913M913M913O9tfcAG98oW3bd33wAAAAASUVORK5CYII=";

private RibbonPanel ribbonPanel;
public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("Theme");

//ribbonPanel.CreatePushButton<CommandTheme>("Revit")
// .SetLargeImage(REVIT);

//ribbonPanel.CreatePushButton<CommandTheme>("Base64")
// .SetLargeImage(Base64Image);

ribbonPanel.CreatePushButton<CommandTheme>("Light")
.SetLargeImage(LIGHT);
ribbonPanel.CreatePushButton<CommandTheme>("Dark")
.SetLargeImage(DARK);

ribbonPanel.CreatePushButton<CommandTheme>(".")
.SetLargeImage(LIGHT_GREEN)
.SetImage(LIGHT_RED);

ribbonPanel.CreatePushButton<CommandTheme>(".")
.SetLargeImage(LIGHT_GREEN)
.SetImage(LIGHT_RED)
.SetItemSize(Autodesk.Windows.RibbonItemSize.Standard);

ribbonPanel.RowStackedItems(
ribbonPanel.CreatePushButton<CommandTheme>("Grey")
.SetLargeImage("Resources/Box-Grey-Light.ico"),
ribbonPanel.CreatePushButton<CommandTheme>("Grey")
.SetLargeImage("Resources/Box-Grey-Light.ico"),
ribbonPanel.CreatePushButton<CommandTheme>("Grey")
.SetLargeImage("Resources/Box-Grey-Light.ico")
);
ribbonPanel.RowLargeStackedItems(
ribbonPanel.CreatePushButton<CommandTheme>("Grey")
.SetLargeImage("Resources/Box-Grey-Light.ico"),
ribbonPanel.CreatePushButton<CommandTheme>("Grey")
.SetLargeImage("Resources/Box-Grey-Light.ico")
);

ribbonPanel.AddSeparator();

ribbonPanel.FlowStackedItems(
ribbonPanel.CreatePushButton<CommandTheme>("1").SetLargeImage(LIGHT_RED),
ribbonPanel.CreatePushButton<CommandTheme>("2").SetLargeImage(DARK_RED),
ribbonPanel.CreatePushButton<CommandTheme>("3").SetLargeImage(LIGHT_BLUE),
ribbonPanel.CreatePushButton<CommandTheme>("4").SetLargeImage(DARK_GREEN),
ribbonPanel.CreatePushButton<CommandTheme>("5").SetLargeImage(LIGHT_GREEN),
ribbonPanel.CreatePushButton<CommandTheme>("6").SetLargeImage(DARK_BLUE)
);

ribbonPanel.AddSeparator();

var pushButton = ribbonPanel.CreatePushButton<CommandTheme>("Theme")
.SetLargeImage(LIGHT);

var textBox = ribbonPanel.CreateTextBox()
.SetPromptText("TextBox")
.SetLargeImage(LIGHT);

var comboBox = ribbonPanel.CreateComboBox()
.SetLargeImage(LIGHT);
comboBox.CreateComboBoxMember("ComboBox")
.SetLargeImage(LIGHT);
comboBox.CreateComboBoxMember("Red")
.SetLargeImage(LIGHT_RED);
comboBox.CreateComboBoxMember("Green")
.SetLargeImage(LIGHT_GREEN);
comboBox.CreateComboBoxMember("Blue")
.SetLargeImage(LIGHT_BLUE);

ribbonPanel.RowStackedItems(pushButton, textBox, comboBox);

return Result.Succeeded;
}

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

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

UIThemeManager.CurrentTheme = UIThemeManager.CurrentTheme == UITheme.Light ? UITheme.Dark : UITheme.Light;
return Result.Succeeded;
}

public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
{
return true;
}
}
}
}
11 changes: 7 additions & 4 deletions ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

<!-- RevitVersion -->
<PropertyGroup>
<TargetFrameworks>net46;net8.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>
</PropertyGroup>
<Choose>
<When Condition="$(TargetFramework.StartsWith('net4'))">
<PropertyGroup>
<RevitVersion>2017</RevitVersion>
<RevitVersion>2021</RevitVersion>
</PropertyGroup>
</When>
<Otherwise>
Expand Down Expand Up @@ -67,8 +67,7 @@
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<Revision>$([MSBuild]::Divide($([System.DateTime]::get_Now().get_TimeOfDay().get_TotalSeconds()), 4).ToString('F0'))</Revision>
<Version>$(Version).$(Revision)</Version>
<PackageAssemblyVersion>.Dev.$(Version)</PackageAssemblyVersion>
<PackageAssemblyVersion>.Dev.$(Version).$(Revision)</PackageAssemblyVersion>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -85,6 +84,8 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\Box-Grey-Dark.ico" />
<None Remove="Resources\Box-Grey-Light.ico" />
<None Remove="Resources\icon.png" />
<None Remove="Resources\Revit.ico" />
</ItemGroup>
Expand Down Expand Up @@ -113,6 +114,8 @@
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\Box-Grey-Dark.ico" />
<Resource Include="Resources\Box-Grey-Light.ico" />
<Resource Include="Resources\icon.png" />
<Resource Include="Resources\Revit.ico" />
</ItemGroup>
Expand Down
42 changes: 40 additions & 2 deletions ricaun.Revit.UI.Tests/Extensions/RevitRibbonItemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,52 @@ public void GetRibbonItem_Alternative_NotNull()
}

[Test]
public void GetRibbonItem_EqualTo_Alternative()
public void GetRibbonItem_RibbonControl_NotNull()
{
var pushButton = ribbonPanel.CreatePushButton<BaseCommand>();
var ribbonItemRibbonControl = pushButton.GetRibbonItem_RibbonControl();
Assert.IsNotNull(ribbonItemRibbonControl);
}

[Test]
public void GetRibbonItem_RemovePanel()
{
var pushButton = ribbonPanel.CreatePushButton<BaseCommand>();
ribbonPanel.Remove();
var ribbonItem = pushButton.GetRibbonItem();
Assert.IsNotNull(ribbonItem);
}

[Test]
public void GetRibbonItem_Alternative_RemovePanel()
{
var pushButton = ribbonPanel.CreatePushButton<BaseCommand>();
ribbonPanel.Remove();
var ribbonItemAlternative = pushButton.GetRibbonItem_Alternative();
Assert.AreEqual(ribbonItem, ribbonItemAlternative);
Assert.IsNotNull(ribbonItemAlternative);
}

[Test]
public void GetRibbonItem_RibbonControl_RemovePanel()
{
var pushButton = ribbonPanel.CreatePushButton<BaseCommand>();
ribbonPanel.Remove();
var ribbonItemRibbonControl = pushButton.GetRibbonItem_RibbonControl();
// if the panel is removed, the ribbonItem will be null
Assert.IsNull(ribbonItemRibbonControl);
}


[Test]
public void GetRibbonItem_EqualTo_Alternative_And_RibbonControl()
{
var pushButton = ribbonPanel.CreatePushButton<BaseCommand>();
var ribbonItem = pushButton.GetRibbonItem();
var ribbonItemAlternative = pushButton.GetRibbonItem_Alternative();
var ribbonItemRibbonControl = pushButton.GetRibbonItem_RibbonControl();
Assert.AreEqual(ribbonItem, ribbonItemAlternative);
Assert.AreEqual(ribbonItemRibbonControl, ribbonItemAlternative);
}
}

}
Loading
Loading