public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { Logger.Info("Checking for updates"); bool updated; using (var mgr = await GetUpdateManager()) { SquirrelAwareApp.HandleEvents( v => { mgr.CreateShortcutForThisExe(); }, v => { mgr.CreateShortcutForThisExe(); }, onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); }); updated = await SquirrelUpdate(mgr, splashScreenWindow); } if (updated) { Logger.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } catch (Exception e) { Logger.Error("StartupUpdateCheck(SplashScreenWindow splashScreenWindow)", e); } }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { bool updated; using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/Epix37/HDT-Releases", prerelease: Config.Instance.CheckForBetaUpdates)) { SquirrelAwareApp.HandleEvents( v => mgr.CreateShortcutForThisExe(), v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe() ); updated = await SquirrelUpdate(splashScreenWindow, mgr); } if (updated) { if (splashScreenWindow.SkipWasPressed) { StatusBar.Visibility = Visibility.Visible; } else { UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
static Task ShowCore() { ShowCoreTask = new TaskCompletionSource <bool>(); SplashScreenWindow.Loaded += OnSplashScreenWindowLoaded; SplashScreenWindow.ShowSplashScreen(); return(ShowCoreTask.Task); }
/// <summary> /// Raises the <see cref="E:System.Windows.Application.Startup"/> event. /// </summary> /// <param name="e"> /// A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data. /// </param> protected override void OnStartup(StartupEventArgs e) { this.DispatcherUnhandledException += this.ApplicationDispatcherUnhandledException; var splashWindow = new SplashScreenWindow(this.applicationResources); try { // show the splash screen splashWindow.Show(); // initialize bootstarpper var bootstrapper = new CustomBootstrapper(this.applicationResources); // initialize application view model var applicationViewModel = new CustomApplicationViewModel(bootstrapper, this.applicationResources); // create and show application window this.applicationWindow = ApplicationWindowFactory.CreateApplicationWindow(applicationViewModel, this.applicationResources); this.applicationWindow.OnStartup(splashWindow); this.applicationWindow.Show(); // once applicationWindow is in place, close splash screen splashWindow.Close(); TraceUI.Log.Info("Application successfully started"); } catch (Exception ex) { splashWindow.Close(); TraceUI.Log.Exception(ex); throw; } }
public void Show() { WaitForCreation = new AutoResetEvent(false); ThreadStart showSplash = () => { Dispatcher.CurrentDispatcher.BeginInvoke( (Action)(() => { var splash = new SplashScreenWindow(); SplashCloseEvent += (s, e) => splash.Dispatcher.InvokeShutdown(); splash.Show(); WaitForCreation.Set(); })); Dispatcher.Run(); }; var thread = new Thread(showSplash) { Name = "Splash Thread", IsBackground = true }; thread.SetApartmentState(ApartmentState.STA); thread.Start(); WaitForCreation.WaitOne(); }
/// <summary> /// Shows the Splash Screen /// </summary> public void Show() { SplashThread = new Thread(new ThreadStart(() => { splashWindow = new SplashScreenWindow(); splashWindow.Show(); Dispatcher.Run(); })) { Priority = ThreadPriority.AboveNormal, IsBackground = false }; SplashThread.SetApartmentState(ApartmentState.STA); SplashThread.Start(); while (true) { Dispatcher dispatcher = Dispatcher.FromThread(SplashThread); if (dispatcher == null) { Thread.Sleep(100); } else { break; } } }
private static async Task <bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false) { try { splashScreenWindow.StartSkipTimer(); var updateInfo = await mgr.CheckForUpdate(ignoreDelta); if (!updateInfo.ReleasesToApply.Any()) { return(false); } if (updateInfo.ReleasesToApply.LastOrDefault()?.Version <= mgr.CurrentlyInstalledVersion()) { return(false); } await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating); await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing); await mgr.CreateUninstallerRegistryEntry(); return(true); } catch (Exception) { if (!ignoreDelta) { return(await SquirrelUpdate(splashScreenWindow, mgr, true)); } return(false); } }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { Log.Info("Checking for updates"); bool updated; using (var mgr = await UpdateManager.GitHubUpdateManager(await GetReleaseUrl("live"), prerelease: Config.Instance.CheckForBetaUpdates)) { SquirrelAwareApp.HandleEvents( v => mgr.CreateShortcutForThisExe(), v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe(), onFirstRun: CleanUpInstallerFile ); updated = await SquirrelUpdate(splashScreenWindow, mgr); } if (updated) { if (splashScreenWindow.SkipUpdate) { Log.Info("Update complete, showing update bar"); StatusBar.Visibility = Visibility.Visible; } else { Log.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
public static async Task StartupUpdateCheck(SplashScreenWindow splashScreenWindow) { try { Log.Info("Checking for updates"); bool updated; using (var mgr = await GetUpdateManager()) { RegistryHelper.SetExecutablePath(Path.Combine(mgr.RootAppDirectory, "Update.exe")); RegistryHelper.SetExecutableArgs("--processStart \"HearthstoneDeckTracker.exe\""); SquirrelAwareApp.HandleEvents( v => { mgr.CreateShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.SetRunKey(); } }, v => { mgr.CreateShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.SetRunKey(); } }, onAppUninstall: v => { mgr.RemoveShortcutForThisExe(); if (Config.Instance.StartWithWindows) { RegistryHelper.DeleteRunKey(); } }, onFirstRun: CleanUpInstallerFile ); updated = await SquirrelUpdate(mgr, splashScreenWindow); } if (updated) { if (splashScreenWindow.SkipUpdate) { Log.Info("Update complete, showing update bar"); StatusBar.Visibility = Visibility.Visible; } else { Log.Info("Update complete, restarting"); UpdateManager.RestartApp(); } } } catch (Exception ex) { Log.Error(ex); } }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); // base.OnClosed() invokes this class' Closed() code, so we flipped the order of exec to reduce the number of surprises for yours truly. // This NULLing stuff is really the last rites of Dispose()-like so we stick it at the end here. splashscreen_window = null; }
private void setSplashStatus(string text) { SplashScreenWindow wnd = SplashScreen as SplashScreenWindow; if (wnd != null && (updateManager == null || updateManager.UpdateFinished)) { wnd.SetStatus(text); } }
static void ReleaseResources() { isIndeterminateCore = null; SplashScreenWindow.ReleaseResources(); SplashScreenWindow.Loaded -= OnSplashScreenWindowLoaded; SplashScreenWindow = null; SplashScreen = null; ShowCoreTask = null; }
/// <summary>Called when SuperMemo's Element window is loaded</summary> private void ElementWdw_OnAvailable() { Dispatcher.Invoke(() => { _splashScreen?.Close(); _splashScreen = null; }); SMA.Core.SM.UI.ElementWdw.OnAvailable -= ElementWdw_OnAvailable; }
public static void Close() { if (!IsActive) { throw new InvalidOperationException(DXSplashScreenExceptions.Exception3); } SplashScreenWindow.Dispatcher.BeginInvoke(delegate { SplashScreenWindow.HideSplashScreen(); ReleaseResources(); }); }
protected override void OnStartup(StartupEventArgs e) { _splashScreen.Show(); Thread.Sleep(3000); this.MainWindow.Show(); _splashScreen.Close(); _splashScreen = null; }
private void ShowSplash() { // Create the window var animatedSplashScreenWindow = new SplashScreenWindow(); SplashScreen = animatedSplashScreenWindow; // Show it animatedSplashScreenWindow.Show(); // Now that the window is created, allow the rest of the startup to run _resetSplashCreated.Set(); System.Windows.Threading.Dispatcher.Run(); }
/// <summary>The application main stopping point</summary> /// <param name="e"></param> protected override void OnExit(ExitEventArgs e) { _taskbarIcon?.Dispose(); _splashScreen?.Close(); _splashScreen = null; SMA.Core.Logger?.Shutdown(); #pragma warning disable CS0436 // Type conflicts with imported type ModuleInitializer.SentryInstance?.Dispose(); #pragma warning restore CS0436 // Type conflicts with imported type base.OnExit(e); }
protected override async void OnStartup(StartupEventArgs e) { base.OnStartup(e); //Initialize the splash screen and set it as the application main window var splashScreen = new SplashScreenWindow(); this.MainWindow = splashScreen; splashScreen.Show(); splashScreen.SplashScreenInfoLabel.Content = "Loading Application..."; await InitializeIOFolders(); InitializeStyleAsync(); //In order to ensure the UI stays responsive, we need to //Do the work on a different thread await Task.Factory.StartNew(() => { try { //we need to do the work in batches so that we can report progress for (int i = 1; i <= 100; i++) { //Simulate a part of work being done Thread.Sleep(10); //Because we're not on the UI thread, we need to use the Dispatcher //Associated with the splash screen to update the progress bar splashScreen.SplashScreenProgressBar.Dispatcher.Invoke(() => splashScreen.SplashScreenProgressBar.IsIndeterminate = true); } //Once we're done we need to use the Dispatcher //to create and show the MainWindow this.Dispatcher.Invoke(() => { //Initialize the main window, set it as the application main window //and close the splash screen var mainWindow = new MainWindow(); this.MainWindow = mainWindow; mainWindow.Show(); mainWindow.Activate(); splashScreen.Close(); }); } catch (Exception ex) { GlobalVars.Loggi.Error(ex, ex.Message); } }); }
private static async Task <bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false) { try { Log.Info($"Checking for updates (ignoreDelta={ignoreDelta})"); splashScreenWindow.StartSkipTimer(); var updateInfo = await mgr.CheckForUpdate(ignoreDelta); if (!updateInfo.ReleasesToApply.Any()) { Log.Info("No new updated available"); return(false); } var latest = updateInfo.ReleasesToApply.LastOrDefault()?.Version; var current = mgr.CurrentlyInstalledVersion(); if (latest <= current) { Log.Info($"Installed version ({current}) is greater than latest release found ({latest}). Not downloading updates."); return(false); } if (IsRevisionIncrement(current?.Version, latest?.Version)) { Log.Info($"Latest update ({latest}) is revision increment. Updating in background."); splashScreenWindow.SkipUpdate = true; } Log.Info($"Downloading {updateInfo.ReleasesToApply.Count} {(ignoreDelta ? "" : "delta ")}releases, latest={latest?.Version}"); await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating); Log.Info("Applying releases"); await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing); await mgr.CreateUninstallerRegistryEntry(); Log.Info("Done"); return(true); } catch (Exception ex) { if (ignoreDelta) { return(false); } if (ex is Win32Exception) { Log.Info("Not able to apply deltas, downloading full release"); } return(await SquirrelUpdate(splashScreenWindow, mgr, true)); } }
private void App_OnStartup(object sender, StartupEventArgs e) { var splash = new SplashScreenWindow(); splash.Show(); ServiceProvider = IOCReplacer.Create(sc => { sc.AddSingleton(this); }); var window = ServiceProvider.GetRequiredService <Views.MainWindow>(); window?.Show(); splash.Init(ServiceProvider.GetRequiredService <IAppService>()); splash.Hide(); }
// Only call when creating new thread in CreateSplashScreenThread private void ThreadFunction() { lock (this) { if (openWindowAllowed) { window = new SplashScreenWindow(formType, styles); } } if (window != null) { window.EnterMessagePump(); } }
public TabWelcome() { InitializeComponent(); ObjBackgroundImage.Source = SplashScreenWindow.GetSplashImage(); ObjBackgroundImage.Stretch = Stretch.Fill; RenderOptions.SetBitmapScalingMode(ObjBackgroundImage, BitmapScalingMode.HighQuality); ObjFlowDocument.Background = new SolidColorBrush(ColorTools.MakeTransparentColor(Colors.Black, 192)); this.DataContext = ConfigurationManager.Instance.ConfigurationRecord_Bindable; ObjGetGoing.Text = "Let's get started! >>>"; ObjGetGoingBorder.MouseDown += ObjGetGoing_MouseDown; ObjGetGoingBorder.Cursor = Cursors.Hand; }
private async void Application_Startup(object sender, StartupEventArgs e) { _mainWindow = new MainWindow(); _splashWindow = new SplashScreenWindow(); _splashWindow.Show(); await Task.Run(() => { _mainWindow.LoadNetworkItems(); }); _splashWindow.Close(); _mainWindow.Show(); }
static MainEntry() { try { DoPreamble(); DoApplicationCreate(); splashscreen_window = new SplashScreenWindow(); splashscreen_window.Show(); DoUpgrades(splashscreen_window); DoPostUpgrade(splashscreen_window); } catch (Exception ex) { MessageBoxes.Error(ex, "There was an exception in the top-level static main entry!"); } }
public static void RunUpgrades(SplashScreenWindow splashscreen_window) { Logging.Info("+UpgradeManager is running upgrades"); RenewMessage(splashscreen_window); Upgrade.RunUpgrade(); RenewMessage(splashscreen_window); V012To013.Upgrade.RunUpgrade(); RenewMessage(splashscreen_window); SQLiteUpgrade.RunUpgrade(splashscreen_window); RenewMessage(splashscreen_window); MoveOCRDirs.RunUpgrade(splashscreen_window); Logging.Info("-UpgradeManager is running upgrades"); }
private static void DoPostUpgrade(SplashScreenWindow splashscreen_window) { // NB NB NB NB: You CANT USE ANYTHING IN THE USER CONFIG AT THIS POINT - it is not yet decided until LOGIN has completed... splashscreen_window.UpdateMessage("Loading themes"); Theme.Initialize(); DualTabbedLayout.GetWindowOverride = delegate() { return(new StandardWindow()); }; // Force tooltips to stay open ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(3600000)); // Make sure the data directories exist... if (!Directory.Exists(ConfigurationManager.Instance.BaseDirectoryForUser)) { Directory.CreateDirectory(ConfigurationManager.Instance.BaseDirectoryForUser); } // NB NB NB NB: You CANT USE ANYTHING IN THE USER CONFIG AT THIS POINT - it is not yet decided until LOGIN has completed... }
protected override DependencyObject CreateShell() { SplashScreenWindow splashscreenwindow = new SplashScreenWindow(); splashscreenwindow.Show(); ApplicationService.CreateFolder(); ApplicationService.LoadFiles(); MainView shell = new MainView(); this.Container.RegisterInstance <IShell>(shell); this.Container.RegisterType <IPlayFile, PlayFile>(); shell.Dispatcher.BeginInvoke((Action) delegate { shell.Show(); splashscreenwindow.Close(); }); return(shell); }
protected override DependencyObject CreateShell() { SplashScreenWindow splashscreenwindow = new SplashScreenWindow(); splashscreenwindow.Show(); IModule thememodule = Container.Resolve <ThemeModule>(); thememodule.Initialize(); base.InitializeModules(); var shell = this.Container.Resolve <IShell>() as MainView; shell.Dispatcher.BeginInvoke((Action) delegate { //shell.Show(); splashscreenwindow.Close(); }); return(shell); }
// // Переопределенный метод OnStartup выполняет здесь две задачи: // // 1. Splash Screen. // Показывает splash screen, а только затем показывает главное окно приложения. // Про реализацию splash screen: // https://wpf.programmingpedia.net/en/tutorial/3948/creating-splash-screen-in-wpf // // 2. Является Application Root нашего приложения. // Создает экземпляр модели — единственный на всё приложение. // protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Создаем окно splash screen, временно делаем его главным // окном приложения и показываем его пользователю var splashScreen = new SplashScreenWindow(); MainWindow = splashScreen; splashScreen.Show(); // Чтобы UI оставался отзывчивым, асинхронно делаем паузу // и потом переходим к показу настоящего главного окна Task.Factory.StartNew(() => { // Делаем паузу System.Threading.Thread.Sleep(5000); // Создаем настоящее главное окно типа PuzzleWindow, делаем его главным окном // приложения и показываем его пользователю. Поскольку мы сейчас вне основного // UI-потока, то обращение к тому, что имеет отношение UI-потоку, должно быть // вызвано потокобезопасно. В WPF это делается при помощи методов Invoke или // BeginInvoke объекта Dispatcher, который как раз и дает доступ к UI-потоку. Dispatcher.Invoke(() => { // Создаем модель Model = new PuzzleDomainModel(); // Создаем настоящее главное окно типа PuzzleWindow, делаем его // главным окном приложения и показываем его пользователю MainWindow = new PuzzleWindow { DataContext = new PuzzleViewModel() }; MainWindow.Show(); // Закрываем splash screen splashScreen.Close(); }); }); }
protected override void OnStartup(StartupEventArgs e) { AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; DispatcherUnhandledException += ApplicationDispatcherUnhandledException; string softwareRenderMode = ConfigurationManager.AppSettings["SoftwareRenderMode"]; if (string.Compare(softwareRenderMode, "TRUE", true) == 0) { Lib.SoftwareRenderMode = true; } base.OnStartup(e); MainWindow mainWindow; #if !DEBUG SplashScreenViewModel splashScreen = SplashScreenFactory.CreateOrGetSplashScreen(); splashScreen.SourceUri = new Uri("pack://application:,,,/Resources/Splash.jpg"); splashScreen.ShowProgress = false; splashScreen.Info = "Loading ..."; SplashScreenWindow splashScreenWindow = new SplashScreenWindow(splashScreen); try { splashScreenWindow.Show(); #endif MagicDatabaseManager.Initialise(MultiPartCardManager.Instance); mainWindow = new MainWindow(); #if !DEBUG } finally { splashScreenWindow.Close(); } #endif _started = true; mainWindow.Show(); }
internal static void RunUpgrade(SplashScreenWindow splashscreen_window) { try { string OLD = SQLiteUpgrade.BaseDirectoryForQiqqa + @"\Temp"; string NEW = SQLiteUpgrade.BaseDirectoryForQiqqa + @"\ocr"; if (!Directory.Exists(NEW)) { Logging.Info("The NEW OCR directory does not exist."); if (Directory.Exists(OLD)) { Logging.Info("The OLD OCR directory does exist. So moving it!"); Directory.Move(OLD, NEW); } } } catch (Exception ex) { Logging.Error(ex, "There was a problem upgrading OCR directory."); } }