Skip to content

Commit

Permalink
Merge pull request #7 from ricaun-io/develop
Browse files Browse the repository at this point in the history
## [0.0.5] / 2022-01-24
  • Loading branch information
ricaun authored Jan 25, 2022
2 parents bb8f4cc + 0bd11b0 commit bb5eb52
Show file tree
Hide file tree
Showing 12 changed files with 666 additions and 41 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ 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.5] / 2022-01-24
- Add SetImage / SetLongDescription
- Add UpdateRibbonDescription
- Add RibbonDescription
-- [0.0.5] / 2022-01-20
- Add Move RibbonPanelTo
- Add Remove RibbonTab
- Add `GetRibbonPanel` using `m_RibbonPanel`
- Remove Panel
- Add OrderPanels
- Clear Code
- Change to Now.Tick
- Add ConsoleAttribute
- Add RibbonItem Set
- Add RibbonDescriptionExtension

## [0.0.4] / 2022-01-12
- Add NugetApiUrl & NugetApiKey
- Update Readme
Expand Down
4 changes: 2 additions & 2 deletions ricaun.Revit.UI.Example/Proprieties/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ricaun.Revit.UI.Example/Proprieties/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<data name="LargeImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
101 changes: 76 additions & 25 deletions ricaun.Revit.UI.Example/Revit/App.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ricaun.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Media;

namespace ricaun.Revit.UI.Example.Revit
{
[Console]
public class App : IExternalApplication
{
private const string TabName = "ricaun";
private const string PanelName = "Example";
private static RibbonPanel ribbonPanel;

public Result OnStartup(UIControlledApplication application)
{
ribbonPanel = application.CreatePanel("Example");
ribbonPanel.AddPushButton<Commands.Command>();
ribbonPanel = application.CreatePanel(TabName, PanelName);
var button = ribbonPanel.AddPushButton<Commands.Command>();

ribbonPanel.CreatePulldownButton(new[] {
ribbonPanel.CreatePulldownButton("PulldownButton", new[] {
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>(),
Expand All @@ -23,7 +30,7 @@ public Result OnStartup(UIControlledApplication application)
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>() });

ribbonPanel.CreateSplitButton(new[] {
ribbonPanel.CreateSplitButton("SplitButton", new[] {
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>(),
Expand All @@ -33,17 +40,16 @@ public Result OnStartup(UIControlledApplication application)
ribbonPanel.NewPushButtonData<Commands.Command>(),
ribbonPanel.NewPushButtonData<Commands.Command>() });

ribbonPanel.AddPushButton<Commands.Command>("");
var button2 = ribbonPanel.AddPushButton<Commands.Command>("");

var items = ribbonPanel.AddStackedItems(
ribbonPanel.NewPushButtonData<Commands.Command>("Item1"),
ribbonPanel.NewPushButtonData<Commands.Command>("Item2"));

foreach (var item in items)
{
var ri = item.GetRibbonItem();
ri.ShowText = false;
ri.Size = Autodesk.Windows.RibbonItemSize.Large;
item.SetItemSize();
item.SetText();
}

var item3s = ribbonPanel.AddStackedItems(
Expand All @@ -53,37 +59,86 @@ public Result OnStartup(UIControlledApplication application)

foreach (var item in item3s)
{
var ri = item.GetRibbonItem();
ri.ShowText = false;
item.SetText();
}

/*
foreach (var item in ribbonPanel.GetItems())
{
if (item is PushButton pushButton)
{
pushButton.LargeImage = Proprieties.Resource.icon.GetBitmapSource();
pushButton.Image = Proprieties.Resource.icon.GetBitmapSource().Scale(0.5);
pushButton.ToolTipImage = Proprieties.Resource.icon.GetBitmapSource().Scale(2);
pushButton.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
pushButton.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
pushButton.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
}
if (item is PulldownButton pulldownButton)
{
pulldownButton.LargeImage = Proprieties.Resource.icon.GetBitmapSource();
pulldownButton.Image = Proprieties.Resource.icon.GetBitmapSource().Scale(0.5);
pulldownButton.ToolTipImage = Proprieties.Resource.icon.GetBitmapSource().Scale(2);
pulldownButton.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
pulldownButton.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
pulldownButton.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
}
if (item is SplitButton splitButton)
{
foreach (var i in splitButton.GetItems())
{
if (i is PushButton pb)
{
pb.LargeImage = Proprieties.Resource.icon.GetBitmapSource();
pb.Image = Proprieties.Resource.icon.GetBitmapSource().Scale(0.5);
pb.ToolTipImage = Proprieties.Resource.icon.GetBitmapSource().Scale(2);
pb.LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource();
pb.Image = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(0.5);
pb.ToolTipImage = Proprieties.Resource.LargeImage.GetBitmapSource().Scale(2);
}
}
}
}
*/

ribbonPanel.GetRibbonPanel().Tab.SetOrderPanels();
var ric = ribbonPanel.GetRibbonPanel().Tab.Panels.ToList().FirstOrDefault(e => e.Source.Title == "ricaun");
ric?.MoveRibbonPanel();

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

ribbonPanel.UpdateRibbonDescription(setting =>
{
setting.Add("",
new RibbonDescription()
{
LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource(),
Help = "https://ricaun.com"
}
);

setting.Add<Commands.Command>(
new RibbonDescription()
{
Text = "Hello",
ToolTip = "This is a Tool Tip",
LongDescription = "This is a Long Description",
LargeImage = Proprieties.Resource.LargeImage.GetBitmapSource(),
Help = "https://ricaun.com"
},
new RibbonDescription(LanguageType.Brazilian_Portuguese)
{
Text = "Ola",
ToolTip = "Este é um Tool Tip",
LongDescription = "Este é um Long Description",
}
);

setting.Add("PulldownButton", new RibbonDescription()
{
Text = "PulldownButton",
Help = "https://ricaun.com"
});

setting.Add("SplitButton", new RibbonDescription()
{
Text = "SplitButton",
Help = "https://ricaun.com"
});
});

return Result.Succeeded;
}
Expand All @@ -94,8 +149,4 @@ public Result OnShutdown(UIControlledApplication application)
return Result.Succeeded;
}
}

internal class ConsoleAttribute : Attribute
{
}
}
6 changes: 4 additions & 2 deletions ricaun.Revit.UI.Example/Revit/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
{
UIApplication uiapp = commandData.Application;

Console.WriteLine(typeof(Command).Assembly);
//new Services.ReflectionService().GetFields<RibbonPanel>();
//new Services.ReflectionService().GetMethods<RibbonPanel>();

//System.Windows.MessageBox.Show(AutodeskExtension.GetAutodeskOwner(), $"Hello Revit\n{DateTime.Now}");
//Console.WriteLine(typeof(Command).Assembly);
System.Windows.MessageBox.Show(AutodeskExtension.GetAutodeskOwner(), $"Hello Revit\n{DateTime.Now}");

return Result.Succeeded;
}
Expand Down
37 changes: 37 additions & 0 deletions ricaun.Revit.UI.Example/Services/ReflectionService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ricaun.Revit.UI.Example.Services
{
public class ReflectionService
{
public void GetFields<T>()
{
var type = typeof(T);
var fieldInfos = type.GetFields(BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
foreach (var fieldInfo in fieldInfos)
{
Console.WriteLine($"{fieldInfo.Name} {fieldInfo.FieldType}");
}
}

public void GetMethods<T>()
{
var type = typeof(T);
var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
foreach (var method in methods)
{
Console.WriteLine($"{method.Name} {method.DeclaringType}");
foreach (var parameterInfo in method.GetParameters())
{
Console.WriteLine($" {parameterInfo.Name} {parameterInfo.ParameterType}");
}
}
}

}
}
1 change: 0 additions & 1 deletion ricaun.Revit.UI.Example/ricaun.Revit.UI.Example.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.1.0.0" IncludeAssets="build; compile" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ricaun.Revit.UI\ricaun.Revit.UI.csproj" />
</ItemGroup>
Expand Down
11 changes: 11 additions & 0 deletions ricaun.Revit.UI/ConsoleAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace ricaun.Revit.UI
{
/// <summary>
/// Console Attribute for ricaun.Console
/// </summary>
public class ConsoleAttribute : Attribute
{
}
}
Loading

0 comments on commit bb5eb52

Please sign in to comment.