Example #1
0
        public void Release(bool activateWindowIfNeeded)
        {
            if (Container == null)
            {
                return;
            }

            Container.Initialized -= OnOwnerInitialized;
            var container = Container;

            Container = null;
            if (lockMode == SplashScreenLock.None)
            {
                return;
            }

            SplashScreenHelper.InvokeAsync(container, () => {
                bool activateWindow = activateWindowIfNeeded && !SplashScreenHelper.ApplicationHasActiveWindow();
                UnlockContainer(container);
                if (activateWindow)
                {
                    container.ActivateWindow();
                }
                else if (Keyboard.FocusedElement == null)
                {
                    SplashScreenHelper.GetApplicationActiveWindow(false).Do(x => x.Focus());
                }
            }, DispatcherPriority.Render);
        }