private void EnableShortcuts()

in src/dotnet/JetBrains.PresentationAssistant/PresentationAssistantWindowOwner.cs [47:84]


        private void EnableShortcuts(Lifetime enabledLifetime)
        {
            var popupWindowLifetimeDefinition = Lifetime.Define(enabledLifetime, "PresentationAssistant::PopupWindow");

            var window = new PresentationAssistantWindow();
            window.Owner = mainWindow.MainWpfWindow.Value;


            theming.PopulateResourceDictionary(popupWindowLifetimeDefinition.Lifetime, window.Resources);

            var popupWindow = new FadingWpfPopupWindow(popupWindowLifetimeDefinition, context, context.Mutex,
                popupWindowManager, window, opacity: 0.8);

            var visibilityLifetimes = new SequentialLifetimes(popupWindowLifetimeDefinition.Lifetime);

            showAction = shortcut =>
            {
                window.SetShortcut(shortcut);
                popupWindow.ShowWindow();

                visibilityLifetimes.DefineNext(visibleLifetime =>
                {
                    // Hide the window after a timespan, and queue it on the visible sequential lifetime so
                    // that the timer is cancelled when we want to show a new shortcut. Don't hide the window
                    // by attaching it to the sequential lifetime, as that will cause the window to hide when
                    // we need to show a new shortcut. But, make sure we do terminate the lifetime so that
                    // the topmost timer hack is stopped when this window is not visible
                    threading.TimedActions.Queue(visibleLifetime.Lifetime, "PresentationAssistantWindow::HideWindow",
                        () => popupWindow.HideWindow(), VisibleTimeSpan,
                        TimedActionsHost.Recurrence.OneTime, Rgc.Invariant);
                });
            };

            enabledLifetime.OnTermination(() =>
            {
                showAction = _ => { };
            });
        }