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 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); } } }
static Window CreateSplashScreenWindow(object parameter) { object[] parameters = (object[])parameter; bool useFadeEffect = (bool)parameters[0]; WindowArrangerContainer owner = (WindowArrangerContainer)parameters[1]; SplashScreenLock lockMode = (SplashScreenLock)parameters[2]; IList <TimeSpan> durations = SplashScreenHelper.FindParameters <TimeSpan>(parameter); FlowDirection flowDirection = SplashScreenHelper.FindParameter <FlowDirection>(parameter); Style windowStyle = SplashScreenHelper.FindParameter <Style>(parameter); var window = new LoadingDecoratorWindowFree(owner, lockMode); if (windowStyle != null) { window.Style = windowStyle; } else { window.ApplyDefaultSettings(); } window.SetCurrentValue(FlowDirectionProperty, flowDirection); if (useFadeEffect && durations.Any(x => x.TotalMilliseconds > 0)) { Interaction.GetBehaviors(window).Add(new WindowFadeAnimationBehavior() { FadeInDuration = durations[0], FadeOutDuration = durations[1] }); } return(window); }
public ContainerLocker(WindowContainer container, SplashScreenLock lockMode) { Container = container; this.lockMode = lockMode; if (!Container.IsInitialized) { Container.Initialized += OnOwnerInitialized; } else { Initialize(); } }
public LoadingDecoratorWindow(WindowArrangerContainer parentContainer, SplashScreenLock lockMode) { WindowStyle = WindowStyle.None; AllowsTransparency = true; Topmost = false; Focusable = false; ShowInTaskbar = false; Background = new SolidColorBrush(Colors.Transparent); SizeToContent = SizeToContent.WidthAndHeight; WindowStartupLocation = WindowStartupLocation.Manual; SetWindowStartupPosition(parentContainer.ControlStartupPosition.IsEmpty ? parentContainer.WindowStartupPosition : parentContainer.ControlStartupPosition); CreateLocker(parentContainer, lockMode); }
static void EnableWindow(WindowContainer container, SplashScreenLock lockMode) { if (lockMode == SplashScreenLock.Full) { SplashScreenHelper.SetWindowEnabled(container.Handle, true); } else { UIElement visual = lockMode == SplashScreenLock.InputOnly ? container.Window : container.WindowObject as UIElement; if (visual != null) { visual.SetCurrentValue(UIElement.IsHitTestVisibleProperty, true); visual.PreviewKeyDown -= OnWindowKeyDown; } } }
static Window CreateSplashScreenWindow(object parameter) { object[] parameters = (object[])parameter; bool useFadeEffect = (bool)parameters[0]; WindowArrangerContainer owner = (WindowArrangerContainer)parameters[1]; SplashScreenLock lockMode = (SplashScreenLock)parameters[2]; IList <TimeSpan> durations = SplashScreenHelper.FindParameters <TimeSpan>(parameter); var window = new LoadingDecoratorWindow(owner, lockMode); if (useFadeEffect && durations.Any(x => x.TotalMilliseconds > 0)) { Interaction.GetBehaviors(window).Add(new WindowFadeAnimationBehavior() { FadeInDuration = durations[0], FadeOutDuration = durations[1] }); } return(window); }
static SplashScreenLock GetActualLockMode(WindowContainer container, SplashScreenLock lockMode) { SplashScreenLock result = SplashScreenLock.None; if (lockMode == SplashScreenLock.Full || (lockMode == SplashScreenLock.InputOnly && container.Form != null)) { result = SplashScreenLock.Full; } else if (lockMode == SplashScreenLock.LoadingContent && container.WindowObject == container.Window) { result = SplashScreenLock.InputOnly; } else if ((lockMode == SplashScreenLock.InputOnly && container.Window != null) || lockMode == SplashScreenLock.LoadingContent) { result = lockMode; } return(result); }
static void DisableWindow(WindowContainer container, SplashScreenLock lockMode) { if (lockMode == SplashScreenLock.Full) { SplashScreenHelper.SetWindowEnabled(container.Handle, false); } else if (lockMode == SplashScreenLock.InputOnly) { container.Window.IsHitTestVisible = false; container.Window.PreviewKeyDown += OnWindowKeyDown; } else if (lockMode == SplashScreenLock.LoadingContent) { FrameworkElement content = container.WindowObject as FrameworkElement; if (content != null) { content.PreviewKeyDown -= OnWindowKeyDown; content.IsHitTestVisible = false; } } }
static void DisableWindow(WindowContainer container, SplashScreenLock lockMode) { switch (lockMode) { case SplashScreenLock.InputOnly: container.Window.IsHitTestVisible = false; container.Window.PreviewKeyDown += OnWindowKeyDown; break; case SplashScreenLock.Full: SplashScreenHelper.SetWindowEnabled(container.Handle, false); break; case SplashScreenLock.LoadingContent: FrameworkElement content = container.WindowObject as FrameworkElement; if (content != null) { content.PreviewKeyDown += OnWindowKeyDown; content.IsHitTestVisible = false; } break; } }
void CreateLocker(WindowContainer parentContainer, SplashScreenLock lockMode) { ParentLocker = new ContainerLocker(parentContainer, lockMode); }
public LoadingDecoratorWindowFree(WindowArrangerContainer parentContainer, SplashScreenLock lockMode) { WindowStartupLocation = WindowStartupLocation.Manual; SetWindowStartupPosition(parentContainer.ControlStartupPosition.IsEmpty ? parentContainer.WindowStartupPosition : parentContainer.ControlStartupPosition); CreateLocker(parentContainer, lockMode); ClearValue(ShowActivatedProperty); }
public LoadingDecoratorWindowFree(WindowArrangerContainer parentContainer, SplashScreenLock lockMode, bool useFadeEffect, TimeSpan fadeInDuration, TimeSpan fadeOutDuration) { ParentContainer = parentContainer; if (useFadeEffect) { AnimationBehavior = new WindowFadeAnimationBehavior() { FadeInDuration = fadeInDuration, FadeOutDuration = fadeOutDuration }; Interaction.GetBehaviors(this).Add(AnimationBehavior); } WindowStartupLocation = WindowStartupLocation.Manual; if (!LoadingDecorator.IsLoadedEx) { Opacity = 0d; LoadingDecorator.Loaded += OnLoadingDecoratorLoaded; if (AnimationBehavior != null) { AnimationBehavior.ManualFadeIn = true; } } var startupLocation = parentContainer.GetControlStartupRect(SplashScreenLocation.CenterContainer); if (startupLocation.IsEmpty) { startupLocation = parentContainer.GetControlStartupRect(SplashScreenLocation.CenterWindow); } SetWindowStartupPosition(startupLocation); CreateLocker(parentContainer, lockMode); ClearValue(ShowActivatedProperty); }
public ContainerLockInfo(int lockCounter, SplashScreenLock lockMode, bool isHitTestVisible) { LockCounter = lockCounter; LockMode = lockMode; IsHitTestVisible = isHitTestVisible; }
public ContainerLockInfo(int lockCounter, SplashScreenLock lockMode) { LockCounter = lockCounter; LockMode = lockMode; }