private void ShowChangeLog() { var changeLogWindow = new ChangeLogWindow(this.ViewModel.Settings.ApplicationTheme) { Owner = this }; changeLogWindow.Show(); }
private async Task LoadAppAsync(SMAParameters args) { // // Installer events https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/custom-squirrel-events.md if (SMAInstaller.HandleEvent(args, out var firstRun)) { if (firstRun) { MessageBox.Show("SuperMemo Assistant has been successfully installed.", "Installation success"); } Shutdown(); return; } // // Make sure assemblies are available, and SMA is installed in "%LocalAppData%\SuperMemoAssistant" if (AssemblyCheck.CheckRequired(out var errMsg) == false || CheckSMALocation(out errMsg) == false) { LogTo.Warning(errMsg); await errMsg.ErrorMsgBox().ConfigureAwait(false); Shutdown(SMAExitCodes.ExitCodeDependencyError); return; } // // Load main configuration files var(success, nativeDataCfg, coreCfg) = await LoadConfigs().ConfigureAwait(true); if (success == false) { errMsg = $"At least one essential config file could not be loaded: nativeDataCfg ? {nativeDataCfg == null} ; startupCfg ? {coreCfg == null}"; LogTo.Warning(errMsg); await errMsg.ErrorMsgBox().ConfigureAwait(false); Shutdown(SMAExitCodes.ExitCodeConfigError); return; } SMA.Core.CoreConfig = coreCfg; // // Setup Windows Toast notifications DesktopNotificationManager.RegisterAumidAndComServer <SMANotificationActivator>(SMANotificationActivator.AppUserModelId); DesktopNotificationManager.RegisterActivator <SMANotificationActivator>(); // // Initialize the plugin manager await SMAPluginManager.Instance.InitializeAsync().ConfigureAwait(true); // // Check if SMA is setup, and run the setup wizard if it isn't if (SMASetup.Run(nativeDataCfg, coreCfg) == false) { LogTo.Warning("SMA Setup canceled. Exiting."); Shutdown(SMAExitCodes.ExitCodeSMASetupError); return; } // // Start plugins var pluginStartTask = SMAPluginManager.Instance.StartPlugins().ConfigureAwait(true); // // (Optional) Start the debugging tool Key logger (logs key strokes with modifiers, e.g. ctrl, alt, ..) if (args.KeyLogger) { SMA.Core.KeyboardHotKey.MainCallback = hk => LogTo.Debug("Key pressed: {Hk}", hk); } // // Show the change logs if necessary ChangeLogWindow.ShowIfUpdated(coreCfg); // // Determine which collection to open SMCollection smCollection = null; var selectionWdw = new CollectionSelectionWindow(coreCfg); // Try to open command line collection, if one was passed if (args.CollectionKnoPath != null && selectionWdw.ValidateSuperMemoPath()) { smCollection = new SMCollection(args.CollectionKnoPath, DateTime.Now); if (selectionWdw.ValidateCollection(smCollection) == false) { smCollection = null; } } // No valid collection passed, show selection window if (smCollection == null) { selectionWdw.ShowDialog(); smCollection = selectionWdw.Collection; } // // If a collection was selected, start SMA if (smCollection != null) { _splashScreen = new SplashScreenWindow(); _splashScreen.Show(); SMA.Core.SMA.OnSMStartingInternalEvent += OnSMStartingEventAsync; SMA.Core.SMA.OnSMStoppedInternalEvent += OnSMStoppedEvent; // Wait for plugins to start await pluginStartTask; Exception ex; if ((ex = await SMA.Core.SMA.StartAsync(nativeDataCfg, smCollection).ConfigureAwait(true)) != null) { _splashScreen?.Close(); _splashScreen = null; await $"SMA failed to start: {ex.Message}".ErrorMsgBox().ConfigureAwait(false); Shutdown(SMAExitCodes.ExitCodeSMAStartupError); return; } if (SMAExecutableInfo.Instance.IsDev == false) { await SMAInstaller.Instance.Update().ConfigureAwait(false); } } else { Shutdown(); } }