Exemplo n.º 1
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            DispatcherUnhandledException += AppDispatcherUnhandledException;

            Tools.Logging.Send(LogLevel.Trace, $"Version: {Assembly.GetExecutingAssembly().GetName().Version}");
            Tools.Logging.Send(LogLevel.Trace, $"OS: {Environment.OSVersion}");

            HockeyClient.Current.Configure("847a769d61234e969e7d4b321877e67c").SetExceptionDescriptionLoader(ex => "Exception HResult: " + ex.HResult);
            await HockeyClient.Current.SendCrashesAsync();

            Settings.Load(); //Подгружаем настройки
            Settings.Program.Data.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            Settings.Program.Save();
            mainVM = new MainViewModel();

            if (!Settings.Program.Configure.UseGpu || ForceSoftwareRendering)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            var splashVM = new SplashViewModel(mainVM);

            splashVM.Exited += OnSplashExited;
            splashScreen     = new View.SplashScreen()
            {
                DataContext = splashVM
            };
            splashScreen.Show();
            splashVM.Run();
        }
Exemplo n.º 2
0
        void OnSplashExited(object sender, SplashExitedEventArgs e)
        {
            if (e.AllowApplicationRun)
            {
                // need to open main window before closing splash, otherwise application
                // will lose its focus
                mainVM.IsConnectionLost = !e.HasConnection;
                mainWindow = new MainWindow {
                    DataContext = mainVM
                };
                mainWindow.Closed += (o, args) => CleanupExit();
                mainWindow.Show();
                mainVM.Run();

                toastManager.AddToastWithTimeout(new ToastViewModel("Тест", "Я toast-нотификация, покамест тестовый образец"), TimeSpan.FromSeconds(5));
            }

            splashScreen.Close();
            splashScreen = null;

            if (!e.AllowApplicationRun)
            {
                CleanupExit();
            }
        }