protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t))); var splashVM = new SplashScreenVM(); ViewManager.ShowWindow(splashVM); //in order to ensure the UI stays responsive, we need to //do the work on a different thread Task.Factory.StartNew(() => { ConfigureContainer(splashVM); Dispatcher.Invoke(() => { ViewManager.ShowWindow <MainVM>(); splashVM.Close(); }); }); Dispatcher.UnhandledException += (s, ea) => { string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}"; Trace.TraceError(message); ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK); ea.Handled = true; }; }
public App() { SetUpCrashReporting(ConfigurationManager.AppSettings["SentryDsn"]); Startup += async(sender, args) => { var baseDir = AppDomain.CurrentDomain.BaseDirectory; var dataDir = Path.Combine(baseDir, "Data"); kernel = Configure(dataDir); var window = new MainWindow(); var splashVm = new SplashScreenVM(); var splash = new SplashScreen { DataContext = splashVm }; IProgress <string> progress = new Progress <string>(s => splashVm.ProgressReport = s); splash.Show(); Encoding.RegisterProvider(new Utf8EncodingProviderHack()); kernel.Bind <ITextInsertCommand>(() => new TextInsertCommand(window.InsertTextAtCursor)); kernel.Bind(Dispatcher); await Task.Run(() => { Preload(progress); }); var vm = kernel.Get <MainWindowVM>(); window.DataContext = vm; window.Show(); splash.Close(); }; Exit += (sender, args) => { kernel.Dispose(); }; }
//--------------------------------------------------------------------- SplashScreenVM ShowSplashScreen() { _splashScreen = new Views.SplashScreen(); _splashScreen.Owner = _mainWindow; _splashScreenVM = new SplashScreenVM(); _splashScreen.DataContext = _splashScreenVM; _splashScreen.Show(); // start the timer to close the splash _timer = new System.Timers.Timer(300); _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed); _timer.Enabled = true; return(_splashScreenVM); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); commandLineArgs = new CommandLineArgs(e.Args); ViewManager.SetImplementation(new DefaultViewManager(t => kernel.Get(t))); Log.SetImplementation((DefaultLogger)LogManager.GetLogger("", typeof(DefaultLogger))); if (commandLineArgs.Contains("-debug", StringComparer.OrdinalIgnoreCase)) { Log.Level = "Debug"; } Log.Info($"Starting Astrarium {FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion}"); var splashVM = new SplashScreenVM(); ViewManager.ShowWindow(splashVM); // in order to ensure the UI stays responsive, we need to // do the work on a different thread Task.Factory.StartNew(() => { ConfigureContainer(splashVM); Dispatcher.Invoke(() => { ViewManager.ShowWindow <MainVM>(); splashVM.Close(); }); }); Dispatcher.UnhandledException += (s, ea) => { string message = $"An unhandled exception occurred:\n\n{ea.Exception.Message}\nStack trace:\n\n{ea.Exception.StackTrace}"; Log.Error(message); ViewManager.ShowMessageBox("Error", message, MessageBoxButton.OK); ea.Handled = true; }; }