diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a7149d..7ec7d6f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.4.0] / 2024-09-05
### Features
- Support `NUnit.Timeout` option to abort application. (default '10' minutes) (Fix: #51)
+- Autoclose `VIEWER MODE` warning dialog box when Revit starts. (Fix: #52)
+### Application
+- Add `DialogBoxResolver` to cancel dialog box before revit initialization.
### Console
- Change `TimeoutMinutesDefault` to 10 minutes in the `RevitTestUtils`.
- Remove deprecated `wait` option and `RevitDebugUtils`.
diff --git a/Directory.Build.props b/Directory.Build.props
index 35c490e..f8afd83 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,5 +1,5 @@
- 1.4.0-alpha.1
+ 1.4.0-beta
\ No newline at end of file
diff --git a/ricaun.RevitTest.Application/Revit/App.cs b/ricaun.RevitTest.Application/Revit/App.cs
index 91752e6..c0ce3af 100644
--- a/ricaun.RevitTest.Application/Revit/App.cs
+++ b/ricaun.RevitTest.Application/Revit/App.cs
@@ -23,6 +23,7 @@ public class App : IExternalApplication
private static PipeTestServer PipeTestServer;
private static RevitTaskService RevitTask;
private static RevitBusyService RevitBusyService;
+ private static DialogBoxResolver DialogBoxResolver;
private static bool IsTestRunning = false;
private const int TestThreadSleepMin = 50;
@@ -38,6 +39,9 @@ public Result OnStartup(UIControlledApplication application)
RevitTask = new RevitTaskService(application);
RevitTask.Initialize();
+ DialogBoxResolver = new DialogBoxResolver(application);
+ DialogBoxResolver.Initialize();
+
Log.WriteLine();
Log.WriteLine($"{AppUtils.GetInfo()}");
@@ -219,9 +223,10 @@ public Result OnShutdown(UIControlledApplication application)
});
ribbonPanel?.Remove();
+
PipeTestServer?.Dispose();
RevitBusyService?.Dispose();
-
+ DialogBoxResolver?.Dispose();
RevitTask?.Dispose();
Log.Finish();
diff --git a/ricaun.RevitTest.Application/Revit/Utils/DialogBoxResolver.cs b/ricaun.RevitTest.Application/Revit/Utils/DialogBoxResolver.cs
new file mode 100644
index 0000000..f69a430
--- /dev/null
+++ b/ricaun.RevitTest.Application/Revit/Utils/DialogBoxResolver.cs
@@ -0,0 +1,64 @@
+using Autodesk.Revit.UI;
+using System;
+
+namespace ricaun.RevitTest.Application.Revit.Utils
+{
+ ///
+ /// DialogBoxResolver resolve the dialog box by DialogId and override the result to cancel.
+ ///
+ /// The resolver only works before Revit initialize.
+ public class DialogBoxResolver : IDisposable
+ {
+ private readonly UIControlledApplication application;
+ private readonly string[] TaskDialogIds;
+ public DialogBoxResolver(UIControlledApplication application)
+ {
+ this.application = application;
+ this.TaskDialogIds = new string[]
+ {
+ "TaskDialog_License_Current_Status_Demo_Mode", // Viewer Mode
+ "TaskDialog_DNSMTemplate" // Revit Warning
+ };
+ }
+
+ ///
+ /// Initialize the events to resolve the dialog box.
+ ///
+ /// The Initialize is ignored if the .
+ public virtual void Initialize()
+ {
+ if (this.application.IsLateAddinLoading) return;
+ Dispose();
+ this.application.DialogBoxShowing += OnDialogBoxShowing;
+ this.application.ControlledApplication.ApplicationInitialized += OnApplicationInitialized;
+ }
+
+ ///
+ /// Dispose the events.
+ ///
+ public virtual void Dispose()
+ {
+ this.application.DialogBoxShowing -= OnDialogBoxShowing;
+ this.application.ControlledApplication.ApplicationInitialized -= OnApplicationInitialized;
+ }
+
+ private void OnDialogBoxShowing(object sender, Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs e)
+ {
+ if (TaskDialogIds is null) return;
+ foreach (var dialogId in TaskDialogIds)
+ {
+ if (dialogId == e.DialogId)
+ {
+ Console.WriteLine($"{nameof(DialogBoxResolver)}: [{e.DialogId}]");
+ e.OverrideResult((int)TaskDialogResult.Cancel);
+ return;
+ }
+ }
+ }
+ private void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
+ {
+ Dispose();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/ricaun.RevitTest.Console/Resources/ricaun.RevitTest.Application.bundle.zip b/ricaun.RevitTest.Console/Resources/ricaun.RevitTest.Application.bundle.zip
index d124e89..ffa4ea0 100644
Binary files a/ricaun.RevitTest.Console/Resources/ricaun.RevitTest.Application.bundle.zip and b/ricaun.RevitTest.Console/Resources/ricaun.RevitTest.Application.bundle.zip differ
diff --git a/ricaun.RevitTest.TestAdapter/Resources/net48/ricaun.RevitTest.Console.zip b/ricaun.RevitTest.TestAdapter/Resources/net48/ricaun.RevitTest.Console.zip
index 2092961..a479562 100644
Binary files a/ricaun.RevitTest.TestAdapter/Resources/net48/ricaun.RevitTest.Console.zip and b/ricaun.RevitTest.TestAdapter/Resources/net48/ricaun.RevitTest.Console.zip differ
diff --git a/ricaun.RevitTest.TestAdapter/Resources/net8.0-windows/ricaun.RevitTest.Console.zip b/ricaun.RevitTest.TestAdapter/Resources/net8.0-windows/ricaun.RevitTest.Console.zip
index cb188d6..1a94b22 100644
Binary files a/ricaun.RevitTest.TestAdapter/Resources/net8.0-windows/ricaun.RevitTest.Console.zip and b/ricaun.RevitTest.TestAdapter/Resources/net8.0-windows/ricaun.RevitTest.Console.zip differ