Ejemplo n.º 1
0
        private Task CreateSplash()
        {
            return(STATaskFactory.StartNew(() =>
            {
                var splash = new Splash();
                splash.Closed += (s, e) =>
                                 Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                splash.Show();

                LoadingManager.Instance.SplashVM = splash.ViewModel;

                _isSplashCreated = true;
                Dispatcher.Run();
            }));
        }
        private static Task <IProgressDialogController> ShowExternalProgressDialogAsync(string title, string message, bool isCancellable)
        {
            IProgressDialogController controller = null;

            STATaskFactory.StartNew(() =>
            {
                var shellHandle = (IntPtr)Application.Current.Dispatcher.Invoke(new Func <IntPtr>(
                                                                                    () => new WindowInteropHelper(Application.Current.MainWindow).Handle));

                var dialog    = new ProgressDialog(shellHandle);
                var shellRect = (Rect)Application.Current.Dispatcher.Invoke(new Func <Rect>(
                                                                                () => new Rect(Application.Current.MainWindow.WindowState == WindowState.Maximized ? 0 : Application.Current.MainWindow.Left,
                                                                                               Application.Current.MainWindow.WindowState == WindowState.Maximized ? 0 : Application.Current.MainWindow.Top,
                                                                                               Application.Current.MainWindow.ActualWidth,
                                                                                               Application.Current.MainWindow.ActualHeight)));

                dialog.Left   = shellRect.Left;
                dialog.Top    = shellRect.Top;
                dialog.Width  = shellRect.Width;
                dialog.Height = shellRect.Height;

                dialog.Title         = title;
                dialog.Message       = message;
                dialog.IsCancellable = isCancellable;

                dialog.Closed += (s, e) =>
                                 Dispatcher.CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background);

                dialog.AnimateAndShow();

                controller = dialog.ProgressDialogController;

                Dispatcher.Run();
            });

            return(Task.Factory.StartNew(() =>
            {
                while (controller == null)
                {
                    Thread.Sleep(10);
                }

                return controller;
            }));
        }