Esempio n. 1
0
        static void LockContainer(WindowContainer container, SplashScreenLock lockMode)
        {
            if (container == null || container.Handle == IntPtr.Zero)
            {
                return;
            }

            lockMode = GetActualLockMode(container, lockMode);
            if (lockMode == SplashScreenLock.None)
            {
                return;
            }

            lock (locker) {
                ContainerLockInfo lockInfo;
                if (lockMode == SplashScreenLock.LoadingContent)
                {
                    if (!lockedContainerDict.TryGetValue(container.WindowObject, out lockInfo))
                    {
                        lockedContainerDict.Add(container.WindowObject, (lockInfo = new ContainerLockInfo(0, lockMode)));
                    }
                }
                else if (!lockedWindowsDict.TryGetValue(container.Handle, out lockInfo))
                {
                    lockedWindowsDict.Add(container.Handle, (lockInfo = new ContainerLockInfo(0, lockMode)));
                }

                ++lockInfo.LockCounter;
                infosFromContainer.Add(container, lockInfo);
                if (lockInfo.LockCounter == 1)
                {
                    DisableWindow(container, lockMode);
                }
            }
        }
Esempio n. 2
0
        static void EnableWindow(WindowContainer container, ContainerLockInfo lockInfo)
        {
            switch (lockInfo.LockMode)
            {
            case SplashScreenLock.InputOnly:
                container.Window.IsHitTestVisible = lockInfo.IsHitTestVisible;
                container.Window.PreviewKeyDown  -= OnWindowKeyDown;
                break;

            case SplashScreenLock.Full:
                SplashScreenHelper.SetWindowEnabled(container.Handle, true);
                break;

            case SplashScreenLock.LoadingContent:
                FrameworkElement content = container.WindowObject as FrameworkElement;
                if (content != null)
                {
                    content.PreviewKeyDown  -= OnWindowKeyDown;
                    content.IsHitTestVisible = lockInfo.IsHitTestVisible;
                }
                break;
            }
        }