4e85a6cccc
* add base revit 26 projects * fix up cef replacement * fix up revit 2026 events * add revit events * fixes for revit 26 * use right version of DI for Revit26 * add Revit26 to local * fmt * use visual studio to fix slns * Add revit to installer constants * move webview stuff to 2026 specific area to avoid build issues * update locks * Revit 2026 wants to invoke scripts with RevitTask. Abstract RevitTask * fmt * fix project copying * use 3.2 SDK * fix build * Revit 2025 is now CEF vulnerable * add SendProgress to not overload revit context * update Revit 26 lock files * update locks --------- Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com>
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using Autodesk.Revit.UI;
|
|
using Autodesk.Revit.UI.Events;
|
|
using Speckle.Connectors.DUI.Bridge;
|
|
using Speckle.Converters.RevitShared.Helpers;
|
|
using Speckle.Sdk.Common;
|
|
|
|
namespace Speckle.Connectors.Revit.Plugin;
|
|
|
|
public sealed class RevitIdleManager : AppIdleManager
|
|
{
|
|
private readonly UIApplication _uiApplication;
|
|
private readonly IIdleCallManager _idleCallManager;
|
|
private readonly ITopLevelExceptionHandler _topLevelExceptionHandler;
|
|
|
|
private event EventHandler<IdlingEventArgs>? OnIdle;
|
|
|
|
public RevitIdleManager(
|
|
RevitContext revitContext,
|
|
IIdleCallManager idleCallManager,
|
|
ITopLevelExceptionHandler topLevelExceptionHandler,
|
|
IRevitTask revitTask
|
|
)
|
|
: base(idleCallManager)
|
|
{
|
|
_topLevelExceptionHandler = topLevelExceptionHandler;
|
|
_uiApplication = revitContext.UIApplication.NotNull();
|
|
_idleCallManager = idleCallManager;
|
|
revitTask.Run(
|
|
() => _uiApplication.Idling += (s, e) => OnIdle?.Invoke(s, e) // will be called on the main thread always and fixing the Revit exceptions on subscribing/unsubscribing Idle events
|
|
);
|
|
}
|
|
|
|
protected override void AddEvent()
|
|
{
|
|
_topLevelExceptionHandler.CatchUnhandled(() =>
|
|
{
|
|
OnIdle += RevitAppOnIdle;
|
|
});
|
|
}
|
|
|
|
private void RevitAppOnIdle(object? sender, IdlingEventArgs e) =>
|
|
_idleCallManager.AppOnIdle(() => OnIdle -= RevitAppOnIdle);
|
|
}
|