Example #1
0
        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;
            };
        }
Example #2
0
        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;
            };
        }