public static void LockWindow(WindowContainer container, SplashScreenLock lockMode) { if (container == null || container.Handle == IntPtr.Zero || lockMode == SplashScreenLock.None) { return; } IntPtr handle = container.Handle; lock (locker) { WindowLockInfo lockInfo; if (!lockedWindowsDict.TryGetValue(handle, out lockInfo)) { lockedWindowsDict.Add(handle, (lockInfo = new WindowLockInfo(1, lockMode, container.Window.IsHitTestVisible))); } else { ++lockInfo.LockCounter; } if (lockInfo.LockCounter == 1) { DisableWindow(container, lockMode); } } }
static void EnableWindow(WindowContainer container, WindowLockInfo lockInfo) { if (lockInfo.LockMode == SplashScreenLock.Full) { SplashScreenHelper.SetWindowEnabled(container.Handle, true); } else if (lockInfo.LockMode == SplashScreenLock.InputOnly) { container.Window.IsHitTestVisible = lockInfo.IsHitTestVisible; container.Window.PreviewKeyDown -= OnWindowKeyDown; } else if (lockInfo.LockMode == SplashScreenLock.LoadingContent) { FrameworkElement content = container.WindowObject as FrameworkElement; if (content != null) { content.PreviewKeyDown -= OnWindowKeyDown; content.IsHitTestVisible = lockInfo.IsHitTestVisible; } } }