Exemple #1
0
 void Initialize()
 {
     if (Container != null)
     {
         SplashScreenHelper.InvokeAsync(Container, () => LockContainer(Container, lockMode), DispatcherPriority.Send, AsyncInvokeMode.AllowSyncInvoke);
     }
 }
        public void Release(bool activateWindowIfNeeded)
        {
            if (Container == null)
            {
                return;
            }

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

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

            SplashScreenHelper.InvokeAsync(container.Window, () => {
                if (activateWindowIfNeeded && !SplashScreenHelper.ApplicationHasActiveWindow())
                {
                    container.ActivateWindow();
                }

                SplashScreenHelper.UnlockWindow(container);
            }, DispatcherPriority.Render);
        }
Exemple #3
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);
        }
Exemple #4
0
            void ReleaseResources(SplashScreenInfo container)
            {
                lock (instanceLocker) {
                    instances.Remove(this);
                    if (instances.Count == 0 && hasUnhandledExceptionSubscriver)
                    {
                        SplashScreenHelper.InvokeAsync(Application.Current, UnsubscribeUnhandledException, DispatcherPriority.Send, AsyncInvokeMode.AsyncOnly);
                    }
                }
                var dispatcher = Dispatcher.FromThread(container.InternalThread);

                container.RelationInfo.Do(x => x.ParentClosed -= OnSplashScreenOwnerClosed);
                container.ReleaseResources();
                if (Closed != null)
                {
                    Closed.Invoke(this, EventArgs.Empty);
                }
                lock (internalLocker) {
                    infosForRelease.Remove(container);
                }
                try {
                    if (dispatcher != null)
                    {
                        dispatcher.BeginInvokeShutdown(DispatcherPriority.Normal);
                        Dispatcher.Run();
                    }
                } catch { }
            }
        void OnLoadingChildChanged(bool loadChild = true)
        {
            if (ViewModelBase.IsInDesignMode)
            {
                LoadChildInDesignTime();
                return;
            }
            Child = null;
            if ((LoadingChild == null && LoadingChildTemplate == null) || !IsInitialized)
            {
                return;
            }
            if (CanAutoShow())
            {
                if (!IsVisible && IsLoadedEx)
                {
                    CloseSplashScreen();
                }
                else
                {
                    ShowSplashScreen();
                }
            }

            if (loadChild)
            {
                SplashScreenHelper.InvokeAsync(this, LoadChild);
            }
        }
        void CloseSplashScreenOnLoading()
        {
            if (IsSplashScreenShown != null || !IsActive)
            {
                return;
            }

            SplashScreenHelper.InvokeAsync(this, CloseSplashScreen, DispatcherPriority.Render);
        }
 protected override void CompleteInitializationOverride()
 {
     if (Child.Window.Dispatcher.CheckAccess())
     {
         nextParentPos = childLocation == SplashScreenLocation.CenterContainer ? Parent.ControlStartupPosition : Parent.WindowStartupPosition;
         UpdateChildPosition();
     }
     SplashScreenHelper.InvokeAsync(Parent.Window, () => UpdateNextParentRectAndChildPosition(true), DispatcherPriority.Normal, AsyncInvokeMode.AllowSyncInvoke);
 }
Exemple #8
0
        protected override void CompleteInitializationOverride()
        {
            base.CompleteInitializationOverride();
            if (Child.Window.Dispatcher.CheckAccess())
            {
                UpdateChildLocation();
            }

            SplashScreenHelper.InvokeAsync(Parent, () => UpdateNextParentRectAndChildPosition(true), DispatcherPriority.Normal, AsyncInvokeMode.AllowSyncInvoke);
        }
Exemple #9
0
        void CompleteInitialization()
        {
            if (IsReleased || IsInitialized || Child == null || !Child.IsInitialized || Parent.Handle == IntPtr.Zero)
            {
                return;
            }

            CompleteInitializationOverride();
            SplashScreenHelper.InvokeAsync(Child, SetChildParent);
            IsInitialized = true;
        }
        void OnLoadingChildChanged()
        {
            Child = null;
            if (LoadingChild == null || !IsLoaded)
            {
                return;
            }
            LoadingChild.Loaded += OnLoadingChildLoaded;
            if (IsSplashScreenShown == null && IsVisible)
            {
                ShowSplashScreen();
            }

            SplashScreenHelper.InvokeAsync(this, () => Child = LoadingChild);
        }
Exemple #11
0
        void UpdateNextParentRectAndChildPosition(bool skipSizeCheck)
        {
            if (SkipArrange || !Parent.IsInitialized)
            {
                return;
            }

            UpdateParentLocation();
            if (!skipSizeCheck && lastParentPos == nextParentPos || nextParentPos.IsEmpty)
            {
                return;
            }

            SplashScreenHelper.InvokeAsync(Child, () => UpdateChildLocation(), DispatcherPriority.Normal, AsyncInvokeMode.AllowSyncInvoke);
        }
 void ReleaseResources(SplashScreenInfo container)
 {
     lock (instanceLocker) {
         instances.Remove(this);
         if (instances.Count == 0 && hasUnhandledExceptionSubscriver)
         {
             SplashScreenHelper.InvokeAsync(Application.Current, UnsubscribeUnhandledException, DispatcherPriority.Send, AsyncInvokeMode.AsyncOnly);
         }
     }
     container.RelationInfo.Do(x => x.ParentClosed -= OnSplashScreenOwnerClosed);
     container.ReleaseResources();
     lock (internalLocker) {
         infosForRelease.Remove(container);
     }
     Dispatcher.CurrentDispatcher.InvokeShutdown();
 }
        void UpdateNextParentRectAndChildPosition(bool skipSizeCheck)
        {
            if (SkipArrange || !Parent.IsInitialized)
            {
                return;
            }

            nextParentPos = isParentClosed
                ? Rect.Empty
                : childLocation == SplashScreenLocation.CenterContainer ? Parent.GetControlRect() : Parent.GetWindowRect();
            if (!skipSizeCheck && lastParentPos == nextParentPos || nextParentPos.IsEmpty)
            {
                return;
            }

            SplashScreenHelper.InvokeAsync(Child, () => UpdateChildPosition(), DispatcherPriority.Normal, AsyncInvokeMode.AllowSyncInvoke);
        }
        void OnLoadingChildChanged()
        {
            if (ViewModelBase.IsInDesignMode)
            {
                LoadChildInDesignTime();
                return;
            }
            Child = null;
            if ((LoadingChild == null && LoadingChildTemplate == null) || !IsLoaded)
            {
                return;
            }
            if (IsSplashScreenShown == null && IsVisible)
            {
                ShowSplashScreen();
            }

            SplashScreenHelper.InvokeAsync(this, LoadChild);
        }
 void OnIsSplashScreenShownChanged()
 {
     if (IsSplashScreenShown == true)
     {
         if (IsLoaded)
         {
             ShowSplashScreen();
         }
         else
         {
             SplashScreenHelper.InvokeAsync(this, () => { if (IsSplashScreenShown == true)
                                                          {
                                                              ShowSplashScreen();
                                                          }
                                            }, DispatcherPriority.Render);
         }
     }
     if (IsSplashScreenShown == false)
     {
         CloseSplashScreen();
     }
 }
Exemple #16
0
        void ChildSizeChanged(object sender, EventArgs e)
        {
            if (SkipArrange)
            {
                return;
            }

            if (!Parent.IsInitialized || Child.Window == null ||
                (lastChildPos.Width == Child.Window.ActualWidth && lastChildPos.Height == Child.Window.ActualHeight))
            {
                return;
            }

            if (lastParentPos.IsEmpty)
            {
                SplashScreenHelper.InvokeAsync(Parent, () => UpdateNextParentRectAndChildPosition(true), DispatcherPriority.Normal, AsyncInvokeMode.AllowSyncInvoke);
            }
            else
            {
                UpdateChildLocation();
            }
        }
Exemple #17
0
 public void ActivateWindow()
 {
     SplashScreenHelper.InvokeAsync(this, ActivateWindowCore, DispatcherPriority.Send, AsyncInvokeMode.AllowSyncInvoke);
 }