void InstallOutOfGameDependencies() { GameSettings.AddSettingsFile(new SettingsFile { fileName = Constants.ModName }); XmlPersistenceService = new XmlPersistenceService(); Settings = XmlPersistenceService.Load(); }
private void InitializeAddIn() { Splash splash = null; try { if (_isInitialized) { // The add-in is already initialized. See: // The strange case of the add-in initialized twice // http://msmvps.com/blogs/carlosq/archive/2013/02/14/the-strange-case-of-the-add-in-initialized-twice.aspx return; } var pathProvider = PersistencePathProvider.Instance; var configLoader = new XmlPersistenceService <GeneralSettings>(pathProvider); var configProvider = new GeneralConfigProvider(configLoader); _initialSettings = configProvider.Read(); if (_initialSettings != null) { try { var cultureInfo = CultureInfo.GetCultureInfo(_initialSettings.Language.Code); Dispatcher.CurrentDispatcher.Thread.CurrentUICulture = cultureInfo; } catch (CultureNotFoundException) { } try { if (_initialSettings.SetDpiUnaware) { SHCore.SetProcessDpiAwareness(PROCESS_DPI_AWARENESS.Process_DPI_Unaware); } } catch (Exception) { Debug.Assert(false, "Could not set DPI awareness."); } } else { Debug.Assert(false, "Settings could not be initialized."); } if (_initialSettings?.CanShowSplash ?? false) { splash = new Splash { // note: IVersionCheck.CurrentVersion could return this string. Version = $"version {Assembly.GetExecutingAssembly().GetName().Version}" }; splash.Show(); splash.Refresh(); } Startup(); } catch (Win32Exception) { System.Windows.Forms.MessageBox.Show(Resources.RubberduckUI.RubberduckReloadFailure_Message, RubberduckUI.RubberduckReloadFailure_Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (Exception exception) { _logger.Fatal(exception); // TODO Use Rubberduck Interaction instead and provide exception stack trace as // an optional "more info" collapsible section to eliminate the conditional. MessageBox.Show( #if DEBUG exception.ToString(), #else exception.Message.ToString(), #endif RubberduckUI.RubberduckLoadFailure, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { splash?.Dispose(); } }
public static void SaveSettings() { XmlPersistenceService.Save(Settings); }