Skip to content

Commit

Permalink
Merge pull request #1166 from mcneel/1.23
Browse files Browse the repository at this point in the history
`EditScope` does not need any wrapper.
  • Loading branch information
kike-garbo authored Aug 16, 2024
2 parents 3bc38d7 + b2bbf8f commit 6fd1413
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
14 changes: 4 additions & 10 deletions src/RhinoInside.Revit.External/ActivationGate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -440,18 +440,12 @@ protected override int DispatchHook(int nCode, IntPtr wParam, IntPtr lParam)
if (IsOpen)
{
var window = (WindowHandle) wParam;
if (HostMainWindow != window)
if (window == HostMainWindow && !window.Enabled)
{
if (!HostMainWindow.Enabled && !IsExternalWindow(window, out var _))
foreach (var gate in gates)
{
//foreach (var gate in gates)
//{
// try { gate.Value.Window.BringToFront(); }
// catch { }
//}

windowToActivate = window; // Will be activated when our message loop is Idle.
return 1; // Prevents activation now.
try { gate.Value.Window.BringToFront(); }
catch { }
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/RhinoInside.Revit.External/UI/EditScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace RhinoInside.Revit.External.UI
{
internal sealed class EditScope : IDisposable
{
readonly UIHostApplication uiApplication;
readonly UIApplication uiApplication;
readonly WindowHandle activeWindow = WindowHandle.ActiveWindow;
readonly bool WasExposed = HostedApplication.Active.MainWindow.Visible;
readonly bool WasEnabled = ExternalApplication.HostMainWindow.Enabled;

public EditScope(UIHostApplication app)
public EditScope(UIApplication app)
{
uiApplication = app;
HostedApplication.Active.MainWindow.HideOwnedPopups();
Expand All @@ -27,13 +27,13 @@ public EditScope(UIHostApplication app)
WindowHandle.ActiveWindow = ExternalApplication.HostMainWindow;
}

internal static async void PostCommand(UIHostApplication app, RevitCommandId commandId)
internal static async void PostCommand(UIApplication app, RevitCommandId commandId)
{
using (var scope = new EditScope(app))
await scope.ExecuteCommandAsync(commandId);
}

internal static async void PostCommand(UIHostApplication app, RevitCommandId commandId, Action continuation)
internal static async void PostCommand(UIApplication app, RevitCommandId commandId, Action continuation)
{
using (var scope = new EditScope(app))
await scope.ExecuteCommandAsync(commandId);
Expand All @@ -42,7 +42,7 @@ internal static async void PostCommand(UIHostApplication app, RevitCommandId com
}

internal CommandAwaitable ExecuteCommandAsync(RevitCommandId commandId) =>
new CommandAwaitable(uiApplication.Value as UIApplication, commandId);
new CommandAwaitable(uiApplication, commandId);

void IDisposable.Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ namespace RhinoInside.Revit.External.UI
sealed class UIHostApplicationUnconstrained : UIHostApplication
{
UIApplication _app;
public UIHostApplicationUnconstrained(UIApplication app, bool disposable) : base(disposable)
internal UIHostApplicationUnconstrained(UIApplication app, bool disposable) : base(disposable)
{
_app = app;
_app.ViewActivated += UpdateOpenViewsList;
if (!disposable)
{
_app.ViewActivated += UpdateOpenViewsList;

#if REVIT_2023
_app.SelectionChanged += SelectionChangedHandler;
_app.SelectionChanged += SelectionChangedHandler;
#endif
}
}

protected override void Dispose(bool disposing)
Expand Down

0 comments on commit 6fd1413

Please sign in to comment.