Skip to content

Commit

Permalink
Merge pull request #10 from ricaun-io/develop
Browse files Browse the repository at this point in the history
Deploy 0.0.7
  • Loading branch information
ricaun authored Feb 8, 2022
2 parents 60f4747 + d53f78a commit 0805a44
Show file tree
Hide file tree
Showing 16 changed files with 817 additions and 423 deletions.
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ 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.0.7] / 2022-02-08
- Add Availability class
- Update xml documetation
- Fix AutoSelect base64 or uri
- Add string on SetImage / SetLargeImage
- 2022-02-07
- Add QuickAccessToolBar on Autodesk.Revit.UI.RibbonItem
- Add Pack UIFrameworkRes Reference
- Remove RibbonItem from RibbonPanel - Include Split/Down/Stacked
- Test Online Icons Scale
- Test Scale
- Test IsDownloading Icon
- Icon Select Frame
- Teste PushButtonData Set Proprieties
- Change CreatePulldownButton to params
- Change CreateSplitButton to params
- Add RibbonHelpExtension
- Add RibbonItemDataExtension
- Clear Code - Remove not used stuff
- Add RibbonUtilExtension
- Add RibbonTabExtension
- TODO: Add PushButtonData, RibbonItemData SetImage / Description / Othes : DONE
- TODO: Add pack component BitmapSource : DONE
- TODO: Add Icon selector size with BitmapDecoder : DONE
- TODO: Add Remove RibbonItem From RibbonPanel : DONE
- 2022-02-03
- Add Remove RibbonItem on the Panel

## [0.0.6] / 2022-02-02
- Special Icons8 class
- Update Example Version
Expand Down Expand Up @@ -80,6 +108,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- First Release

[vNext]: ../../compare/1.0.0...HEAD
[0.0.8]: ../../compare/0.0.7...0.0.8
[0.0.7]: ../../compare/0.0.6...0.0.7
[0.0.6]: ../../compare/0.0.5...0.0.6
[0.0.5]: ../../compare/0.0.4...0.0.5
[0.0.4]: ../../compare/0.0.3...0.0.4
[0.0.3]: ../../compare/0.0.2...0.0.3
[0.0.2]: ../../compare/0.0.1...0.0.2
Expand Down
24 changes: 24 additions & 0 deletions ricaun.Revit.UI.Example/Proprieties/Pack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Runtime.CompilerServices;

namespace ricaun.Revit.UI.Example.Proprieties
{
public static class Pack
{
#region Private
private static string Assembly => "UIFrameworkRes";
private static string BaseUri => @"pack://application:,,,/{0};component/Ribbon/images/{1}.ico";
#endregion
public static string Icon([CallerMemberName] string name = null) => string.Format(BaseUri, Assembly, name.ToLower());
public static string Power => Icon("system_electrical_circuit_power_create");
public static string Communication => Icon("system_electrical_circuit_communication_create");
public static string Control => Icon("system_electrical_circuit_control_create");
public static string Data => Icon("system_electrical_circuit_data_create");
public static string Alarm => Icon("system_electrical_circuit_fire_alarm_create");
public static string Nurce => Icon("system_electrical_circuit_nurse_call_create");
public static string Security => Icon("system_electrical_circuit_security_create");
public static string Telephone => Icon("system_electrical_circuit_telephone_create");
public static string Switch => Icon("system_switch_create");

}
}
113 changes: 100 additions & 13 deletions ricaun.Revit.UI.Example/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Linq;
using ricaun.Revit.UI.Example.Proprieties;
using System.Windows.Media;

namespace ricaun.Revit.UI.Example.Revit
{
Expand All @@ -20,19 +21,46 @@ public Result OnStartup(UIControlledApplication application)

ribbonPanel.AddPushButton<Commands.Command>();

ribbonPanel.CreatePulldownButton("PulldownButton", new[] {
var down = ribbonPanel.CreatePulldownButton("T",
ribbonPanel.NewPushButtonData<Commands.Command<Edge>>()
.SetText("1")
.SetToolTip("One")
.SetLongDescription("The One")
.SetLargeImage(Icons8.Document.Scale(0.5))
.SetToolTipImage(Icons8.Document),
ribbonPanel.NewPushButtonData<Commands.Command<EdgeArray>>()
.SetText("2")
.SetLargeImage(Icons8.Document.Scale(0.5)),
ribbonPanel.NewPushButtonData<Commands.Command<EdgeArrayArray>>()
.SetText("3")
.SetLargeImage(Icons8.Document.Scale(0.5)),
ribbonPanel.NewPushButtonData<Commands.Command<EdgeArrayArrayIterator>>()
.SetText("4")
.SetLargeImage(Icons8.Document.Scale(0.5))
)
.SetToolTip("T");

ribbonPanel.Remove(down);

ribbonPanel.AddPushButton<Commands.Command<Construction>>("-")
.SetLargeImage(GetBase64LargeImage());

ribbonPanel.AddPushButton<Commands.Command<Construction>>("-")
.SetLargeImage(GetResourcesLargeImage());

ribbonPanel.CreatePulldownButton("PulldownButton",
ribbonPanel.NewPushButtonData<Commands.Command<int>>(),
ribbonPanel.NewPushButtonData<Commands.Command<double>>(),
ribbonPanel.NewPushButtonData<Commands.Command<bool>>(),
ribbonPanel.NewPushButtonData<Commands.Command<string>>()
);

ribbonPanel.CreateSplitButton("SplitButton",
ribbonPanel.NewPushButtonData<Commands.Command<int>>(),
ribbonPanel.NewPushButtonData<Commands.Command<double>>(),
ribbonPanel.NewPushButtonData<Commands.Command<bool>>(),
ribbonPanel.NewPushButtonData<Commands.Command<string>>()
});

ribbonPanel.CreateSplitButton("SplitButton", new[] {
ribbonPanel.NewPushButtonData<Commands.Command<int>>(),
ribbonPanel.NewPushButtonData<Commands.Command<double>>(),
ribbonPanel.NewPushButtonData<Commands.Command<bool>>(),
ribbonPanel.NewPushButtonData<Commands.Command<string>>()
});
);

ribbonPanel.AddPushButton<Commands.Command<Commands.Command>>();

Expand All @@ -55,11 +83,53 @@ public Result OnStartup(UIControlledApplication application)
ribbonPanel.NewPushButtonData<Commands.Command<ElementType>>(),
ribbonPanel.NewPushButtonData<Commands.Command<ElementArray>>());

ribbonPanel.AddSlideOut();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Power)
.SetText("Power")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Data)
.SetText("Data")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Communication)
.SetText("Communication")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Alarm)
.SetText("Alarm")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Nurce)
.SetText("Nurce")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Security)
.SetText("Security")
.AddQuickAccessToolBar();

ribbonPanel.AddPushButton<Commands.Command<Point>>()
.SetLargeImage(Pack.Telephone)
.SetText("Telephone")
.AddQuickAccessToolBar();

var sw = ribbonPanel.AddPushButton<Commands.Command<Point>, Commands.Availability.AvailableOnAnyDocument>()
.SetLargeImage(Pack.Switch)
.SetText("Switch")
.AddQuickAccessToolBar();

OrderPanelAndMove(ribbonPanel);

foreach (var item in ribbonPanel.GetRibbonItems())
{
//Console.WriteLine($"{item} {item.Name}");
//Console.WriteLine($"{item} {item.Name} {item.GetRibbonItem()}");
}

UpdateRibbonDescription(ribbonPanel);
Expand All @@ -82,7 +152,7 @@ private void UpdateRibbonDescription(RibbonPanel ribbonPanel)
new RibbonDescription()
{
LargeImage = Resource.LargeImage.GetBitmapSource(),
Text = "Hello",
Text = "ricaun",
ToolTip = "This is a Tool Tip",
LongDescription = "This is a Long Description",
},
Expand All @@ -98,7 +168,13 @@ private void UpdateRibbonDescription(RibbonPanel ribbonPanel)
new RibbonDescription()
{
Text = "Ok",
LargeImage = Icons8.Ok
ToolTip = "This Button gonna be Removed",
LargeImage = Icons8.Ok,
Action = (ribbonItem) =>
{
var ri = ribbonItem.GetRibbonItem() as Autodesk.Windows.RibbonButton;
ri.MouseLeft += (s, e) => { ribbonPanel.Remove(ribbonItem); };
}
}
);

Expand Down Expand Up @@ -253,7 +329,7 @@ private void UpdateRibbonDescription(RibbonPanel ribbonPanel)

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

Expand All @@ -263,5 +339,16 @@ private void OrderPanelAndMove(RibbonPanel ribbonPanel)
var ric = ribbonPanel.GetRibbonPanel().Tab.Panels.ToList().FirstOrDefault(e => e.Source.Title == "ricaun");
ric?.MoveRibbonPanel();
}

private string GetResourcesLargeImage()
{
return string.Format("pack://application:,,,/{0};component/Resources/icon.png", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
}

private string GetBase64LargeImage()
{
const string LargeImage = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAACQAAAAkABgV+WigAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAPaSURBVFiFvZddbBRVGIaf+dnd2bp/dQu0paStho2kQVpNL0RDQ/WiCVZEozHGLImpvS0iBIxKkTRGEU29gVTlRgJBuRQ1xliLEGmDSa1EbWJtKy3VdmmVsmt3Z3/Gi+ngst2fmSHxTc7Fzvm+931nvzPnfEfAPHzANqAV2ATUAYHlub+BSeAHoB/4DLhhgbsoQsBxIAZoJkcM+BBYfzvCbuCI4FCSFoRzhwocBhSr4uuBy4BW0dGnBcPvaWKZ364JDbgIVJkVbwLmjOSKzuNa/SlNq33/muZr69IQJbsmpoB7c8XEPG/+JbBqRaAnSDDcy9qeSyj3bDH7MtmoQV+clYUMKMCZfOLZcNY1UXXgHGv2foq8qt6OibPo6wsAKWvyTWBHbkbZ/dtx1TWtYHJUhfA93Ino9pIYG0JLqWZNVANpYAD++wdCQJdZBgOC042/fR8174zibe0EIbeiBbGb5VIYGfsA2aoBA1J5NRUdfVQfGkQJbTaT4gEOGAZ8wDN2xbPhuruZqu4LrO76BDm4rlR4GPBKwBPFDDjXbcTd0GrehSDgrGnA29oBmQzqxPeQSeelBkYk9NrfV4gvPnqe+M8DuOoakQKVhcJW+pBduDc+gmfLTjLRedQrI/nCFiTgNWBtMbLUtd+50f8BqblxlNBmRMVj2ohY5ueO5h24N7SgTg6Tvj6bPZ0UgAhQYZpQ8eDftgf/Y/sRHC7TRgDQMkQvnGTh5B7Si3MAcxLQw637QXGOlEr8lwFigx8jBSpx1jSYNyAIOGs34d3aAYA6fkk2/eHm5XO6SweVgAwsYqUEZQEC2/fja9t1GyV4ifRiBOC6DEyYMiCIeB56jjufPYzkX2NNGFj6qZ+FEy+iXvkx+/G4jN5GNRdLVja0EAz34qxttCycnP2Nv06/TGzoTL7pERm9h3uhEEHg8Vcof7rHsjDA0uWvmD3SjpZMFAr5WkQ/HmOFIuTVd9kSB0jNTxUTjwFfiEAUOG1bxT5OAVHjM3wLSP6P4ip6/3HzOP4V6LXKoqlLaOqSHQPvAuPZBkA/nwfNMvwzfJbpvQ1M7w4RPX8CNM1s6kXgoPEj20AcvSWbKpatTg7zx6EWZt9uJxWZILUwTeRYmJnuB0iMlfQ/AzwF3FyZuVvxn8CjwHRuZiY6z/xHu7j6ajPx0W9XMCfGhpjpfpDIsZ25J56BKaANuFrKJeid8TlsXkxExaOVP3lQCz5/1Hj2HTntuBm4gNcFhxI1K5w7BIeSAN5Y5rKNSuAo+n5hVjwK9AEldzHBghEP+vV8K9AI1HPr9XwCGAa+AT5fNlES/wLKWXKx84783QAAAABJRU5ErkJggg==";
return LargeImage;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace ricaun.Revit.UI.Example.Revit.Commands.Availability
{
/// <summary>
/// The Command will be available on Project and Family environment
/// </summary>
public class AvailableOnAnyDocument : IExternalCommandAvailability
{
public bool IsCommandAvailable(UIApplication uiapp, CategorySet categorySet)
{
if (uiapp.ActiveUIDocument == null) return false;
if (uiapp.ActiveUIDocument.Document == null) return false;

return true;
}
}
}
9 changes: 9 additions & 0 deletions ricaun.Revit.UI.Example/Services/ReflectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@ public void GetMethods<T>()
}
}

public TResult GetResult<T, TResult>(T obj, string methodName)
{
var type = typeof(T);
var method = type.GetMethod(methodName,
BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

return (TResult)method?.Invoke(obj, null);
}

}
}
7 changes: 7 additions & 0 deletions ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
<Page Remove="InstallationFiles\**" />
</ItemGroup>

<ItemGroup>
<None Remove="Resources\icon.png" />
</ItemGroup>

<ItemGroup>
<None Include="FodyWeavers.xml" />
</ItemGroup>
Expand All @@ -130,6 +134,9 @@
<ItemGroup>
<ProjectReference Include="..\ricaun.Revit.UI\ricaun.Revit.UI.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\icon.png" />
</ItemGroup>

<ItemGroup>
<Compile Update="Proprieties\Resource.Designer.cs">
Expand Down
Loading

0 comments on commit 0805a44

Please sign in to comment.