Skip to content

Commit 180594d

Browse files
authored
Merge pull request #2 from ricaun-io/develop
Version 0.2.0
2 parents bca6d07 + 1f8e1c0 commit 180594d

23 files changed

+553
-47
lines changed

Build/.nuke/build.schema.json

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,100 @@
2121
"VSCode"
2222
]
2323
},
24+
"IssConfiguration": {
25+
"type": "object",
26+
"properties": {
27+
"Title": {
28+
"type": [
29+
"null",
30+
"string"
31+
]
32+
},
33+
"Image": {
34+
"type": [
35+
"null",
36+
"string"
37+
]
38+
},
39+
"ImageSmall": {
40+
"type": [
41+
"null",
42+
"string"
43+
]
44+
},
45+
"Icon": {
46+
"type": [
47+
"null",
48+
"string"
49+
]
50+
},
51+
"Licence": {
52+
"type": [
53+
"null",
54+
"string"
55+
]
56+
},
57+
"Language": {
58+
"oneOf": [
59+
{
60+
"type": "null"
61+
},
62+
{
63+
"$ref": "#/definitions/IssLanguage"
64+
}
65+
]
66+
},
67+
"IssLanguageLicences": {
68+
"type": [
69+
"array",
70+
"null"
71+
],
72+
"items": {
73+
"$ref": "#/definitions/IssLanguageLicence"
74+
}
75+
}
76+
}
77+
},
78+
"IssLanguage": {
79+
"type": "object",
80+
"properties": {
81+
"Name": {
82+
"type": [
83+
"null",
84+
"string"
85+
]
86+
},
87+
"MessagesFile": {
88+
"type": [
89+
"null",
90+
"string"
91+
]
92+
}
93+
}
94+
},
95+
"IssLanguageLicence": {
96+
"type": "object",
97+
"properties": {
98+
"Name": {
99+
"type": [
100+
"null",
101+
"string"
102+
]
103+
},
104+
"MessagesFile": {
105+
"type": [
106+
"null",
107+
"string"
108+
]
109+
},
110+
"Licence": {
111+
"type": [
112+
"null",
113+
"string"
114+
]
115+
}
116+
}
117+
},
24118
"ExecutableTarget": {
25119
"type": "string",
26120
"enum": [
@@ -30,6 +124,7 @@
30124
"GitPreRelease",
31125
"GitRelease",
32126
"Pack",
127+
"PackageBuilder",
33128
"PrePack",
34129
"Release",
35130
"Sign"
@@ -116,9 +211,21 @@
116211
"type": "string",
117212
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
118213
},
214+
"InstallationFiles": {
215+
"type": "string"
216+
},
217+
"IssConfiguration": {
218+
"$ref": "#/definitions/IssConfiguration"
219+
},
119220
"MainName": {
120221
"type": "string"
121222
},
223+
"MiddleVersions": {
224+
"type": "boolean"
225+
},
226+
"NewVersions": {
227+
"type": "boolean"
228+
},
122229
"NuGetApiKey": {
123230
"type": "string",
124231
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
@@ -133,12 +240,27 @@
133240
"type": "string"
134241
}
135242
},
243+
"ProjectNameFolder": {
244+
"type": "boolean"
245+
},
246+
"ProjectRemoveTargetFrameworkFolder": {
247+
"type": "boolean"
248+
},
249+
"ProjectVersionFolder": {
250+
"type": "boolean"
251+
},
252+
"ReleaseBundle": {
253+
"type": "boolean"
254+
},
136255
"ReleaseFolder": {
137256
"type": "string"
138257
},
139258
"ReleaseNameVersion": {
140259
"type": "boolean"
141260
},
261+
"ReleasePackageBuilder": {
262+
"type": "boolean"
263+
},
142264
"SignFile": {
143265
"type": "string",
144266
"default": "Secrets must be entered via 'nuke :secrets [profile]'"

Build/Build.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
using ricaun.Nuke;
44
using ricaun.Nuke.Components;
55

6-
class Build : NukeBuild, IPublishPack, IPrePack
6+
class Build : NukeBuild, IPublishPack, IAutoCADPackageBuilder, IPrePack
77
{
8+
string IHazPackageBuilderProject.Name => "Example";
89
public static int Main() => Execute<Build>(x => x.From<IPublishPack>().Build);
910
}

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.0] / 2025-07-04
8+
### Features
9+
- Add `ricaun.AutoCAD.UI.Example` sample project.
10+
### UI
11+
- Add `AddSeparator` extension to create a separator in the ribbon panel.
12+
- Add `InfoCenter` to display balloon information in the AutoCAD InfoCenter.
13+
- Add `RibbonListButton` in the `RibbonThemePanelUtils`.
14+
### Example
15+
- Add `CircleCreate` command to the example project.
16+
- Add `MessageBox` and `ShowBalloon` buttons to the example ribbon panel.
17+
- Update resource image to `Cube-Grey-Light.tiff` and `Cube-Grey-Dark.tiff`.
18+
- Add `AutoCADBusyService` to update the button state in the example project.
19+
- Add `AutoCADTaskService` to create multiple circles in the example project.
20+
- Add `PaletteSetUtils` to show a palette set in the example project.
21+
### Updates
22+
- Fix `CheckURLValid` to support `http` and `https`.
23+
- Fix `SetImage` to update `Image` property.
24+
- Update `LockDocumentRelayCommand` to use `LockDocumentManager` to support document locking.
25+
- Update `AutoCADTaskService` update `Application_Idle` to run single event handler.
26+
727
## [0.1.0] / 2025-07-02
828
### Features
929
- `ExtensionApplication` and `RibbonControl` extension for AutoCAD ribbon UI.
@@ -13,4 +33,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1333
- Add `Busy`, `Runtime`, `Tasks`, and `Windows` utilities.
1434

1535
[vNext]: ../../compare/1.0.0...HEAD
36+
[0.2.0]: ../../compare/0.1.0...0.2.0
1637
[0.1.0]: ../../compare/0.1.0

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.1.0</Version>
3+
<Version>0.2.0</Version>
44
</PropertyGroup>
55
</Project>

ricaun.AutoCAD.UI.Example/App.cs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using Autodesk.AutoCAD.DatabaseServices;
2+
using Autodesk.AutoCAD.Runtime;
3+
using Autodesk.AutoCAD.Windows;
4+
using Autodesk.Windows;
5+
using ricaun.AutoCAD.UI.Busy;
6+
using ricaun.AutoCAD.UI.Tasks;
7+
using ricaun.AutoCAD.UI.Windows;
8+
using System;
9+
using System.Diagnostics;
10+
using System.Threading.Tasks;
11+
12+
[assembly: ExtensionApplication(typeof(ricaun.AutoCAD.UI.Example.App))]
13+
14+
namespace ricaun.AutoCAD.UI.Example
15+
{
16+
public class App : ExtensionApplication
17+
{
18+
private const string PanelName = "Example";
19+
private const string TabName = "ricaun";
20+
21+
public override void OnStartup(RibbonControl ribbonControl)
22+
{
23+
var ribbonPanel = ribbonControl.CreateOrSelectPanel(PanelName, TabName);
24+
25+
ribbonPanel.RowLargeStackedItems(
26+
ribbonPanel.CreateButton("Theme")
27+
.SetShowText(false)
28+
.SetCommand(Commands.ThemeChange)
29+
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Grey-Light.tiff"),
30+
ribbonPanel.CreateButton("Theme")
31+
.SetShowText(false)
32+
.SetCommand(Commands.ThemeChange)
33+
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Red-Light.tiff"),
34+
ribbonPanel.CreateButton("Theme")
35+
.SetCommand(Commands.ThemeChange)
36+
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Green-Light.ico"),
37+
ribbonPanel.CreateButton("Theme")
38+
.SetCommand(Commands.ThemeChange)
39+
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Blue-32-Light.png")
40+
);
41+
42+
ribbonPanel.AddSeparator();
43+
44+
ribbonPanel.CreateButton("Circle\rCreate")
45+
.SetCommand(Commands.CircleCreate)
46+
.SetDescription("Create a circle with a random radius in the model space.")
47+
.SetToolTip("This button use the command 'CircleCreate'.")
48+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
49+
50+
ribbonPanel.CreateButton("Show\rMessage")
51+
.SetCommand((item) => { Windows.MessageBox.ShowMessage(item.Text, "This is a custom message."); })
52+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
53+
54+
ribbonPanel.CreateButton("Show\rBalloon")
55+
.SetCommand((item) => { Windows.InfoCenter.ShowBalloon(item.Text, "This is a custom message."); })
56+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
57+
58+
ribbonButtonBusy = ribbonPanel.CreateButton("None")
59+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
60+
61+
ribbonPanel.CreateButton("Task")
62+
.SetCommand((item) =>
63+
{
64+
if (autoCADTask is null) return;
65+
item.IsEnabled = false;
66+
Task.Run(async () =>
67+
{
68+
try
69+
{
70+
for (int i = 0; i < 10; i++)
71+
{
72+
await autoCADTask.Run(Commands.CircleCreate);
73+
await Task.Delay(100);
74+
}
75+
}
76+
finally
77+
{
78+
await autoCADTask.Run(() =>
79+
{
80+
item.IsEnabled = true;
81+
});
82+
}
83+
});
84+
})
85+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
86+
87+
ribbonPanel.CreateButton("Show\rPalette")
88+
.SetCommand(() => { paletteSet?.ToggleVisible(); })
89+
.SetLargeImage("Resources/Cube-Grey-Light.tiff");
90+
91+
ribbonControl.ActiveTab = ribbonPanel.Tab;
92+
}
93+
public override void OnShutdown(RibbonControl ribbonControl)
94+
{
95+
ribbonControl.RemovePanel(PanelName, TabName);
96+
}
97+
98+
private RibbonButton ribbonButtonBusy;
99+
private PaletteSet paletteSet;
100+
private AutoCADBusyService busyService;
101+
private AutoCADTaskService taskService;
102+
public IAutoCADTask autoCADTask => taskService;
103+
public override void Initialize()
104+
{
105+
base.Initialize();
106+
busyService = new AutoCADBusyService();
107+
busyService.Initialize();
108+
busyService.PropertyChanged += (sender, e) =>
109+
{
110+
ribbonButtonBusy?.SetText(busyService.IsAutoCADBusy ? "Busy" : "Idle");
111+
var color = busyService.IsAutoCADBusy ? "Red" : "Green";
112+
ribbonButtonBusy?.SetLargeImage($"Resources/Cube-{color}-Light.tiff");
113+
};
114+
taskService = new AutoCADTaskService();
115+
taskService.Initialize();
116+
117+
var visual = new System.Windows.Controls.Grid()
118+
{
119+
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray),
120+
};
121+
paletteSet = PaletteSetUtils.Create("Example Palette Set", new Guid("360B945E-1EFF-4212-9C00-3E841A9F1B28"), visual);
122+
}
123+
124+
public override void Terminate()
125+
{
126+
base.Terminate();
127+
busyService?.Dispose();
128+
taskService?.Dispose();
129+
}
130+
}
131+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using Autodesk.AutoCAD.ApplicationServices;
2+
using Autodesk.AutoCAD.DatabaseServices;
3+
using Autodesk.AutoCAD.Geometry;
4+
using Autodesk.AutoCAD.Runtime;
5+
using System;
6+
7+
namespace ricaun.AutoCAD.UI.Example
8+
{
9+
public static class Commands
10+
{
11+
[CommandMethod("ThemeChange")]
12+
public static void ThemeChange()
13+
{
14+
Application.SetSystemVariable("COLORTHEME", 1 ^ (short)Application.GetSystemVariable("COLORTHEME"));
15+
}
16+
17+
[CommandMethod("CircleCreate")]
18+
public static void CircleCreate()
19+
{
20+
Document document = Application.DocumentManager.MdiActiveDocument;
21+
22+
if (document is null) return;
23+
24+
var database = document.Database;
25+
26+
using (var transaction = database.TransactionManager.StartTransaction())
27+
{
28+
var blockTable = transaction.GetObject(database.BlockTableId, OpenMode.ForRead) as BlockTable;
29+
var blockTableRecord = transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
30+
31+
var circle = new Circle()
32+
{
33+
Radius = new Random().NextDouble() * 100.0,
34+
Center = new Point3d(0, 0, 0),
35+
};
36+
37+
blockTableRecord.AppendEntity(circle);
38+
39+
transaction.AddNewlyCreatedDBObject(circle, true);
40+
transaction.Commit();
41+
}
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)