public static IDisposable Open(TopLevel root, DevToolsOptions options) { if (s_open.TryGetValue(root, out var window)) { window.Activate(); } else { window = new MainWindow { Root = root, Width = options.Size.Width, Height = options.Size.Height, }; window.Closed += DevToolsClosed; s_open.Add(root, window); if (options.ShowAsChildWindow && root is Window inspectedWindow) { window.Show(inspectedWindow); } else { window.Show(); } } return(Disposable.Create(() => window?.Close())); }
public static IDisposable Attach(TopLevel root, DevToolsOptions options) { void PreviewKeyDown(object sender, KeyEventArgs e) { if (options.Gesture.Matches(e)) { Open(root, options); } } return(root.AddDisposableHandler( InputElement.KeyDownEvent, PreviewKeyDown, RoutingStrategies.Tunnel)); }
public static IDisposable Attach(TopLevel root, DevToolsOptions options) { if (s_attachedToApplication == true) { throw new ArgumentException("DevTools already attached to application", nameof(root)); } void PreviewKeyDown(object?sender, KeyEventArgs e) { if (options.Gesture.Matches(e)) { Open(root, options); } } return(root.AddDisposableHandler( InputElement.KeyDownEvent, PreviewKeyDown, RoutingStrategies.Tunnel)); }
internal static IDisposable Attach(Application?application, DevToolsOptions options, Window?owner = null) { if (application is null) { throw new ArgumentNullException(nameof(application)); } var result = Disposable.Empty; // Skip if call on Design Mode if (!Avalonia.Controls.Design.IsDesignMode && !s_attachedToApplication) { var lifeTime = application.ApplicationLifetime as Avalonia.Controls.ApplicationLifetimes.IControlledApplicationLifetime; if (lifeTime is null) { throw new ArgumentNullException(nameof(Application.ApplicationLifetime)); } if (application.InputManager is { })
public static IDisposable Open(TopLevel root, DevToolsOptions options) => Open(Application.Current, options, root as Window);