SIL.FieldWorks.Common.Framework.FwApp.LoadSettings C# (CSharp) Method

LoadSettings() public method

Called just after DoApplicationInitialization(). Allows a separate overide of loading settings. If you override this you probably also want to override SaveSettings.
public LoadSettings ( ) : void
return void
		public virtual void LoadSettings()
		{
			// Keyman has an option to change the system keyboard with a keyman keyboard change.
			// Unfortunately, this messes up changing writing systems in FieldWorks when Keyman
			// is running. The only fix seems to be to turn that option off... (TE-8686)
			try
			{
				using (RegistryKey engineKey = Registry.CurrentUser.OpenSubKey(
					@"Software\Tavultesoft\Keyman Engine", false))
				{
					if (engineKey != null)
					{
						foreach (string version in engineKey.GetSubKeyNames())
						{
							using (RegistryKey keyVersion = engineKey.OpenSubKey(version, true))
							{
								if (keyVersion != null)
								{
									object value = keyVersion.GetValue("switch language with keyboard");
									if (value == null || (int)value != 0)
										keyVersion.SetValue("switch language with keyboard", 0);
								}
							}
						}
					}
				}
			}
			catch (SecurityException)
			{
				// User doesn't have access to the registry key, so just hope the user is fine
				// with what he gets.
			}
		}

Usage Example

Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes the specified application and creates a new main window for it. Also
		/// does application-specific cache initialization.
		/// </summary>
		/// <param name="app">The application</param>
		/// <param name="progressDlg">The progress dialog.</param>
		/// <returns>True if the application was started successfully, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		private static bool InitializeApp(FwApp app, IThreadedProgress progressDlg)
		{
			using (new DataUpdateMonitor(null, "Application Initialization"))
				app.DoApplicationInitialization(progressDlg);
			using (new DataUpdateMonitor(null, "Loading Application Settings"))
				app.LoadSettings();

			using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
				s_cache.ServiceLocator.GetInstance<IActionHandler>()))
			using (new DataUpdateMonitor(null, "Application Cache Initialization"))
			{
				try
				{
					if (!app.InitCacheForApp(progressDlg))
						throw new StartupException(Properties.Resources.kstidCacheInitFailure);
				}
				catch (Exception e)
				{
					if (e is StartupException)
						throw;
					throw new StartupException(Properties.Resources.kstidCacheInitFailure, e, true);
				}
				undoHelper.RollBack = false;
			}

			if (s_cache.ServiceLocator.GetInstance<IUndoStackManager>().HasUnsavedChanges)
			{
				if (progressDlg != null)
				{
					progressDlg.Message = String.Format(Properties.Resources.kstidSaving, s_cache.ProjectId.UiName);
					progressDlg.IsIndeterminate = true;
				}
				s_cache.ServiceLocator.GetInstance<IUndoStackManager>().Save();
				if (progressDlg != null)
					progressDlg.IsIndeterminate = false;
			}

			return CreateAndInitNewMainWindow(app, true, null, false);
		}