예제 #1
0
        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()));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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 { })
예제 #5
0
 public static IDisposable Open(TopLevel root, DevToolsOptions options) =>
 Open(Application.Current, options, root as Window);