private void quitChronojump(bool deleteRunningFileName) { if (deleteRunningFileName) { try { File.Delete(runningFileName); } catch { //done because if database dir is moved in a chronojump conversion //(eg from before installer to installjammer) maybe it will not find this runningFileName } } if (splashWin != null) { splashWin.Destroy(); } else { SplashWindow.Hide(); } if (!quitNowCjTwoTimes) { Log.End(); } Application.Quit(); }
/// <summary> /// Loads the kernel. /// </summary> protected async void LoadKernel() { try { CompositionRoot = new ApplicationHost(); Logger = CompositionRoot.LogManager.GetLogger("App"); var splash = new SplashWindow(CompositionRoot.ApplicationVersion); splash.Show(); await CompositionRoot.Init(); splash.Hide(); var task = CompositionRoot.RunStartupTasks(); new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager, CompositionRoot.UserManager, CompositionRoot.LibraryManager, CompositionRoot.JsonSerializer, CompositionRoot.DisplayPreferencesRepository).Show(); await task.ConfigureAwait(false); } catch (Exception ex) { Logger.ErrorException("Error launching application", ex); MessageBox.Show("There was an error launching Media Browser: " + ex.Message); // Shutdown the app with an error code Shutdown(1); } }
private void HideSplashWindow() { if (_splashWindow != null) { _splashWindow.Hide(); _splashWindow = null; } }
private void on_splash_ended(object o, EventArgs args) { LogB.Information("splash screen going to END"); fakeSplashButton.Clicked -= new EventHandler(on_splash_ended); if (splashWin != null) { splashWin.Destroy(); } else { SplashWindow.Hide(); } LogB.Information("splash screen ENDED!"); readMessageToStart(); }
protected override void OnStartup(StartupEventArgs e) { BootLog.Log("App.OnStartup start"); RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; try { appMutex = new Mutex(true, _appPipName, out createdNew); } catch (Exception) { createdNew = false; } if (createdNew) { if (!NTMiner.Windows.Role.IsAdministrator) { AppHelper.RunAsAdministrator(); return; } BootLog.Log("new SplashWindow"); SplashWindow splashWindow = new SplashWindow(); splashWindow.Show(); NTMinerRoot.Inited = () => { NTMinerRoot.KernelDownloader = new KernelDownloader(); Execute.OnUIThread(() => { bool?result = true; if (string.IsNullOrEmpty(Server.LoginName) || string.IsNullOrEmpty(Server.Password)) { LoginWindow loginWindow = new LoginWindow(); splashWindow.Hide(); result = loginWindow.ShowDialog(); } if (result.HasValue && result.Value) { BootLog.Log("new MainWindow"); ControlCenterWindow window = new ControlCenterWindow(); IMainWindow mainWindow = window; this.MainWindow = window; this.MainWindow.Show(); this.MainWindow.Activate(); BootLog.Log("MainWindow showed"); notifyIcon = new ExtendedNotifyIcon("pack://application:,,,/ControlCenterApp;component/logo.ico"); notifyIcon.Init(); #region 处理显示主界面命令 Global.Access <ShowMainWindowCommand>( Guid.Parse("01f3c467-f494-42b8-bcb5-848050df59f3"), "处理显示主界面命令", LogEnum.None, action: message => { Execute.OnUIThread(() => { Dispatcher.Invoke((ThreadStart)mainWindow.ShowThisWindow); AppHelper.MainWindowShowed(); }); }); #endregion Task.Factory.StartNew(() => { AppHelper.RunPipeServer(this, _appPipName); }); } splashWindow?.Close(); BootLog.SyncToDisk(); }); }; } else { try { AppHelper.ShowMainWindow(this, _appPipName); } catch (Exception) { DialogWindow.ShowDialog(message: "另一个NTMiner正在运行,请手动结束正在运行的NTMiner进程后再次尝试。", title: "alert", icon: "Icon_Error"); Process currentProcess = Process.GetCurrentProcess(); Process[] processes = Process.GetProcessesByName(currentProcess.ProcessName); foreach (var process in processes) { if (process.Id != currentProcess.Id) { NTMiner.Windows.TaskKill.Kill(process.Id); } } } } base.OnStartup(e); BootLog.Log("App.OnStartup end"); BootLog.SyncToDisk(); }
protected override async void OnStartup(StartupEventArgs e) { _applicationInstance = new WhisperApplication(); // Initialise the application instance. using (var splash = new SplashWindow(_applicationInstance.InitialisationProgress)) { splash.Show(); var timer = System.Diagnostics.Stopwatch.StartNew(); await _applicationInstance.InitialiseApplication(); timer.Stop(); var delayDelta = (int)(1000 - timer.ElapsedMilliseconds); if (delayDelta > 0) { await Task.Delay(delayDelta); } Locator.CurrentMutable.Register(() => new CreateItemView(), typeof(IViewFor <CreateItemViewModel>)); Locator.CurrentMutable.Register(() => new HistoryListItemView(), typeof(IViewFor <HistoryListItemViewModel>)); Locator.CurrentMutable.Register(() => new HistoryListView(), typeof(IViewFor <HistoryListViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageAboutView(), typeof(IViewFor <SettingsPageAboutViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageApplicationView(), typeof(IViewFor <SettingsPageApplicationViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGeneralView(), typeof(IViewFor <SettingsPageGeneralViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGenerationView(), typeof(IViewFor <SettingsPageGenerationViewModel>)); Locator.CurrentMutable.Register(() => new SettingsPageGenerationItemView(), typeof(IViewFor <SettingsPageGenerationItemViewModel>)); Func <SettingsWindow> settingsWindowFactory = () => { var settingsWindow = new SettingsWindow(); var settingsVm = new SettingsWindowViewModel(new List <SettingsPageViewModelBase> { new SettingsPageAboutViewModel(_applicationInstance.AppInfoService), new SettingsPageGeneralViewModel(_applicationInstance.ConfigService), //new SettingsPageApplicationViewModel(), new SettingsPageGenerationViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService) }); settingsWindow.ViewModel = settingsVm; return(settingsWindow); }; var settingsManager = new SettingsWindowManager(settingsWindowFactory); var shellWindowViewModel = new ShellWindowViewModel(_applicationInstance.ConfigService, new CreateItemViewModel(_applicationInstance.ConfigService, _applicationInstance.GeneratorService, _applicationInstance.ClipboardService), new HistoryListViewModel(_applicationInstance.GeneratorService, _applicationInstance.ClipboardService), settingsManager); // Fix this bat-shit nonsense. Locator.CurrentMutable.UnregisterAll <IPropertyBindingHook>(); Locator.CurrentMutable.Register <IPropertyBindingHook>(() => new BindingHookFixerer()); var shell = new ShellWindow { ViewModel = shellWindowViewModel }; var trayIcon = new WhisperTrayAgent(shell, settingsManager); _applicationDisposables.Add(trayIcon); splash.Hide(); splash.Close(); shell.Show(); } base.OnStartup(e); }