Esempio n. 1
0
		/// <summary>
		/// Initialize static registry settings.
		/// NOTE: This should be called only by unit tests.
		/// </summary>
		public static void Init()
		{
			if (s_measurementUnitSetting != null)
				return;

			// Data Notebook has the MeasurementUnits setting in the Data Notebook registry
			//  folder rather than in the folder for general FieldWorks settings.
			//  The MeasurementUnits setting should be set for all FieldWorks applications,
			//  not just in the individual applications.
			s_measurementUnitSetting = new RegistryIntSetting((int)MsrSysType.Cm, "MeasurementSystem");

			// This affects all FieldWorks apps.
			s_disableSplashScreen = new RegistryBoolSetting(false, "DisableSplashScreen");
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="FwRegistrySettings"/> class.
		/// </summary>
		/// <param name="app">The application.</param>
		/// ------------------------------------------------------------------------------------
		public FwRegistrySettings(FwApp app)
		{
			if (app == null)
				throw new ArgumentNullException("app");
			m_firstTimeAppHasBeenRun = new RegistryBoolSetting(app.SettingsKey, "FirstTime", true);
			m_showSideBar = new RegistryBoolSetting(app.SettingsKey, "ShowSideBar", true);
			m_showStatusBar = new RegistryBoolSetting(app.SettingsKey, "ShowStatusBar", true);
			m_openLastEditedProject = new RegistryBoolSetting(app.SettingsKey, "OpenLastEditedProject", false);
			m_loadingProcessId = new RegistryIntSetting(app.SettingsKey, "LoadingProcessId", 0);
			m_numberOfLaunches = new RegistryIntSetting(app.SettingsKey, "launches", 0);
			m_numberOfSeriousCrashes = new RegistryIntSetting(app.SettingsKey, "NumberOfSeriousCrashes", 0);
			m_numberOfAnnoyingCrashes = new RegistryIntSetting(app.SettingsKey, "NumberOfAnnoyingCrashes", 0);
			m_totalAppRuntime = new RegistryIntSetting(app.SettingsKey, "TotalAppRuntime", 0);
			m_appStartupTime = new RegistryStringSetting(app.SettingsKey, "LatestAppStartupTime", string.Empty);
			m_latestProject = new RegistryStringSetting(app.SettingsKey, "LatestProject", string.Empty);
			m_latestServer = new RegistryStringSetting(app.SettingsKey, "LatestServer", string.Empty);
		}
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="BackTransLanguageDialog"/> class.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public BackTransLanguageDialog(FdoCache cache, int defaultWs,
			IHelpTopicProvider helpProvider) : this()
		{
			m_cache = cache;
			m_helpProvider = helpProvider;

			m_changeAllBtWs = new RegistryBoolSetting(FwSubKey.TE, m_cache.ServerName,
				m_cache.DatabaseName, "ChangeAllBtViews", true);

			m_chkBxApplyToAllBtWs.Checked = m_changeAllBtWs.Value;

			foreach (LgWritingSystem ws in cache.LangProject.AnalysisWssRC)
			{
				m_olbWritingSystems.Items.Add(ws);
				if (ws.Hvo == defaultWs)
					m_olbWritingSystems.SelectedItem = ws;
			}
		}
Esempio n. 4
0
			/// <summary>
			/// Initializes the variables.
			/// </summary>
			public void Init()
			{
				if (TeRegistryKey != null)
					return;

				TeRegistryKey = FwRegistryHelper.FieldWorksRegistryKey.CreateSubKey(FwSubKey.TE);
				ShowMarkerlessIconsSetting = new RegistryBoolSetting(TeRegistryKey, "FootnoteShowMarkerlessIcons", true);
				ShowEmptyParagraphPromptsSetting = new RegistryBoolSetting(TeRegistryKey, "ShowEmptyParagraphPrompts", true);
				ShowFormatMarksSetting = new RegistryBoolSetting(TeRegistryKey, "ShowFormatMarks", false);
				UserInterfaceLanguage = new RegistryStringSetting(FwRegistryHelper.FieldWorksRegistryKey,
						FwRegistryHelper.UserLocaleValueName, MiscUtils.CurrentUICulture);
				UseVerticalDraftView = new RegistryBoolSetting(TeRegistryKey, "UseVerticalDraftView", false);
				UseInterlinearBackTranslation = new RegistryBoolSetting(TeRegistryKey, "UseInterlinearBackTranslation", false);
				UseXhtmlExport = new RegistryBoolSetting(TeRegistryKey, "UseXhtmlExport", false);
				ShowTranslateUnsQuestions = new RegistryBoolSetting(TeRegistryKey, "ShowTranslateUnsQuestions", false);
				FootnoteSynchronousScrollingSetting = new RegistryBoolSetting(TeRegistryKey, "FootnoteSynchronousScrolling", true);
				ShowTheseStylesSetting = new RegistryStringSetting(TeRegistryKey, "ShowTheseStyles", "all");
				ShowStyleLevelSetting = new RegistryStringSetting(TeRegistryKey, "ShowStyleLevel", DlgResources.ResourceString("kstidStyleLevelBasic"));
				ShowUserDefinedStylesSetting = new RegistryBoolSetting(TeRegistryKey, "ShowUserDefinedStyles", true);
				AutoStartLibronix = new RegistryBoolSetting(TeRegistryKey, "AutoStartLibronix", false);
				//UseEnableSendReceiveSyncMsgs = new RegistryBoolSetting(FwSubKey.TE, "UseSendReceiveSyncMsgs", false);
			}
Esempio n. 5
0
		public void TestSetup()
		{
			Debug.Assert(m_testTeApp == null, "Why does it have something in m_testTeApp here?");
			Unpacker.UnPackParatextTestProjects();
			m_regData = Unpacker.PrepareRegistryForPTData();
			m_teSubKey = Registry.CurrentUser.CreateSubKey(@"Software\SIL\FieldWorks\Translation Editor");

			// save the width of the style pane, only if it already has a value
			// Tests will fail if the style pane is showing, so we turn it off.
			object keyValue = m_teSubKey.GetValue("DraftStyleAreaWidth");
			if (keyValue != null)
			{
				m_draftAreaStyleWidth = (int)keyValue;
				m_teSubKey.SetValue("DraftStyleAreaWidth", 0);
			}

			// TeApp derives from FwApp
			// Make sure the registry thinks the last time an attempt was made to open TE
			// was successful. Otherwise, the welcome dialog shows up in the middle of tests.
			RegistryBoolSetting successfulStartup = new RegistryBoolSetting(FwSubKey.TE, "OpenSuccessful", true);
			successfulStartup.Value = true;

			// TODO: Figure out what we need to pass into the app
			m_testTeApp = new TestTeApp(new string[0]);

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
			Assert.AreEqual(1, m_testTeApp.MainWindows.Count);

			// Sidebar buttons get pressed as part of main window initialization;
			// wait for that initialization to finish before we proceed.
			while (DataUpdateMonitor.IsUpdateInProgress(
				((TestTeMainWnd)m_testTeApp.MainWindows[0]).Cache.MainCacheAccessor))
			{
				Application.DoEvents();
			}

			if (m_fMainWindowOpened)
			{
				m_firstMainWnd = (TestTeMainWnd)m_testTeApp.MainWindows[0];
				m_firstMainWnd.CreateDraftView();
				// Set the view to the DraftView
				m_firstMainWnd.SwitchActiveView(m_firstMainWnd.TheDraftViewWrapper);
				Application.DoEvents();

				m_firstDraftView = (TestTeDraftView)m_firstMainWnd.TheDraftView;
				m_firstDraftView.ActivateView();

				SelectionHelper helper = m_firstDraftView.SetInsertionPoint(0, 0, 0, 0, true);
				// helper.IhvoEndPara = -1;
				helper.SetSelection(m_firstDraftView, true, true);
				Application.DoEvents();
			}
		}
Esempio n. 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Start up the test application
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void StartTestApp()
		{
			// Make sure the registry thinks the last time an attempt was made to open TE
			// was successful. Otherwise, the welcome dialog shows up in the middle of tests.

			RegistryBoolSetting successfulStartup = new RegistryBoolSetting(FwSubKey.TE, "OpenSuccessful", true);
			successfulStartup.Value = true;

			// TODO-Linux: calling added close method on RegistryBoolSetting
			successfulStartup.Close();

			// TODO: Figure out what to pass into the app
			m_testTeApp = new TestTeApp(new string[0]);

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
			Assert.AreEqual(1, m_testTeApp.MainWindows.Count);

			m_DefParaCharsStyle = ResourceHelper.DefaultParaCharsStyleName;

			// Sidebar buttons get pressed as part of main window initialization;
			// wait for that initialization to finish before we proceed.
			while (DataUpdateMonitor.IsUpdateInProgress(
				((TestTeMainWnd)m_testTeApp.MainWindows[0]).Cache.MainCacheAccessor))
			{
				Application.DoEvents();
			}
			((TestTeMainWnd)m_testTeApp.MainWindows[0]).CreateDraftView();
		}
Esempio n. 7
0
			private void Dispose(bool fDisposing)
			{
				System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + " *******");
				if (fDisposing)
				{
					var disposable = TeRegistryKey as IDisposable;
					if (disposable != null)
						disposable.Dispose();
					if (ShowMarkerlessIconsSetting != null)
						ShowMarkerlessIconsSetting.Dispose();
					if (ShowEmptyParagraphPromptsSetting != null)
						ShowEmptyParagraphPromptsSetting.Dispose();
					if (ShowFormatMarksSetting != null)
						ShowFormatMarksSetting.Dispose();
					if (UserInterfaceLanguage != null)
						UserInterfaceLanguage.Dispose();
					if (UseVerticalDraftView != null)
						UseVerticalDraftView.Dispose();
					if (UseInterlinearBackTranslation != null)
						UseInterlinearBackTranslation.Dispose();
					if (UseXhtmlExport != null)
						UseXhtmlExport.Dispose();
					if (FootnoteSynchronousScrollingSetting != null)
						FootnoteSynchronousScrollingSetting.Dispose();
					if (ShowTheseStylesSetting != null)
						ShowTheseStylesSetting.Dispose();
					if (ShowStyleLevelSetting != null)
						ShowStyleLevelSetting.Dispose();
					if (ShowUserDefinedStylesSetting != null)
						ShowUserDefinedStylesSetting.Dispose();
					if (AutoStartLibronix != null)
						AutoStartLibronix.Dispose();
					if (ShowTranslateUnsQuestions != null)
						ShowTranslateUnsQuestions.Dispose();
					//if (UseEnableSendReceiveSyncMsgs != null)
					//    UseEnableSendReceiveSyncMsgs.Dispose();
					//UseEnableSendReceiveSyncMsgs = null;
				}
				TeRegistryKey = null;
				ShowMarkerlessIconsSetting = null;
				ShowEmptyParagraphPromptsSetting = null;
				ShowFormatMarksSetting = null;
				UserInterfaceLanguage = null;
				UseVerticalDraftView = null;
				UseInterlinearBackTranslation = null;
				UseXhtmlExport = null;
				FootnoteSynchronousScrollingSetting = null;
				ShowTheseStylesSetting = null;
				ShowStyleLevelSetting = null;
				ShowUserDefinedStylesSetting = null;
				AutoStartLibronix = null;
				ShowTranslateUnsQuestions = null;
			}
Esempio n. 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Hide the previously active view and activate the new one (corresponding to the
		/// button clicked in the sidebar (or the menu item chosen).
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override bool OnSwitchActiveView(object args)
		{
			SBTabItemProperties itemProps = args as SBTabItemProperties;
			if (itemProps == null || itemProps.ParentForm != this)
				return false;

			if (itemProps.Tag is TeViewType)
			{
				TeViewType viewType = (TeViewType)itemProps.Tag;
				IRootSite rootSite;
				ISelectableViewFactory viewFactory;
				if (m_rgClientViews.TryGetValue(TeEditingHelper.ViewTypeString(viewType), out rootSite))
				{
					// We already created the view, but we couldn't update the tab item (e.g.
					// view got created while printing from draft view)
					itemProps.Tag = rootSite;
					itemProps.Update = true;
				}
				else if (m_uncreatedViews.TryGetValue(viewType, out viewFactory))
					viewFactory.Create(itemProps);
				else
					return false;
			}

			RespondToSyncScrollingMsgs(false);
			bool ret = base.OnSwitchActiveView(args);
			using (RegistryBoolSetting showUSFMResources = new RegistryBoolSetting(m_app.ProjectSpecificSettingsKey,
				"USFMResourcesVisible" + m_selectedView.Name, false))
			{
				DisplayUsfmBrowser(showUSFMResources.Value);
				RespondToSyncScrollingMsgs(true);
				return ret;
			}
		}
Esempio n. 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Turn on or off the control that shows USFM resources.
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public bool OnShowUsfmResources(object args)
		{
			if (MiscUtils.IsUnix) // FWNX-386
			{
				return false;
			}

			TMItemProperties itemProps = args as TMItemProperties;
			if (itemProps == null || !(ActiveView is ITeView))
				return false;

			using (RegistryBoolSetting showUSFMResources = new RegistryBoolSetting(m_app.ProjectSpecificSettingsKey,
				"USFMResourcesVisible" + m_selectedView.Name, false))
			{
				showUSFMResources.Value = itemProps.Checked = !showUSFMResources.Value;
				itemProps.Update = true;

				DisplayUsfmBrowser(itemProps.Checked);

				return true;
			}
		}
Esempio n. 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Start up the test application
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void StartTestApp()
		{
			// Make sure the registry thinks the last time an attempt was made to open TE
			// was successful. Otherwise, the welcome dialog shows up in the middle of tests.
			RegistryBoolSetting successfulStartup = new RegistryBoolSetting(FwSubKey.TE, "OpenSuccessful", true);
			successfulStartup.Value = true;

			m_testTeApp = new TestTeApp(new string[] {
														 "-c", m_sSvrName,		// ComputerName (aka the SQL server)
														 "-db", m_sDbName});	// DatabaseName

			m_fMainWindowOpened = m_testTeApp.OpenMainWindow();
			Assert.AreEqual(1, m_testTeApp.MainWindows.Count);

			m_DefParaCharsStyle = FdoResources.DefaultParaCharsStyleName;

			// Sidebar buttons get pressed as part of main window initialization;
			// wait for that initialization to finish before we proceed.
			while (DataUpdateMonitor.IsUpdateInProgress(
				((TestTeMainWnd)m_testTeApp.MainWindows[0]).Cache.MainCacheAccessor))
			{
				Application.DoEvents();
			}
			((TestTeMainWnd)m_testTeApp.MainWindows[0]).CreateDraftView();
		}
Esempio n. 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do required initializations
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void Init()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			if (Cache != null)
			{
				m_bookFilterEnabled = new RegistryBoolSetting(FwSubKey.TE, Cache.ServerName,
					Cache.DatabaseName, "BookFilterEnabled", false);
				m_filtersKey = new RegistryStringSetting(FwSubKey.TE, Cache.ServerName,
					Cache.DatabaseName, "BookFilterBooks", string.Empty);

				m_bookFilter = new FilteredScrBooks(Cache, Handle.ToInt32());
				m_bookFilter.FilterChanged += BookFilterChanged;
				m_bookFilter.SetSavedFilterFromString(m_filtersKey.Value);

				ILgWritingSystemFactory lgwsf = Cache.LanguageWritingSystemFactoryAccessor;
				m_defaultBackTranslationWs = -1;
				RegistryStringSetting regDefBtWs = GetBtWsRegistrySetting(String.Empty);
				if (!String.IsNullOrEmpty(regDefBtWs.Value))
					m_defaultBackTranslationWs = lgwsf.GetWsFromStr(regDefBtWs.Value);
				if (m_defaultBackTranslationWs <= 0)
					m_defaultBackTranslationWs = Cache.DefaultAnalWs;
			}
			else
			{
				// Not sure if this is necessary, but just to avoid possible problems in tests...
				m_bookFilterEnabled = new RegistryBoolSetting(FwSubKey.TE, "TestBookFilterEnabled", false);
				m_filtersKey = new RegistryStringSetting(FwSubKey.TE, "TestBookFilterBooks", string.Empty);
			}

			if (TMAdapter != null)
				InitializeInsertBookMenus(); // must do after menus are created in InitializeComponent()

			if (DesignMode)
				return;

			SetupSideBarInfoBar();

			Debug.Assert(m_scr != null);
			// Initialize the scripture passage control object.
			GotoReferenceControl.Initialize(ScrReference.StartOfBible(m_scr.Versification),
				(Scripture)m_scr, true);

			UpdateCaptionBar();

			MaxStyleLevel = ToolsOptionsDialog.MaxStyleLevel;

			// We need to store this in a variable so that it can be removed for notification
			m_changeWatcher = new BookChangeWatcher(this);
		}
Esempio n. 12
0
		/// <summary>
		/// Release static registry settings.
		/// NOTE: This should be called only by unit tests.
		/// </summary>
		public static void Release()
		{
			if (s_measurementUnitSetting != null)
				s_measurementUnitSetting.Dispose();
			s_measurementUnitSetting = null;
			if (s_disableSplashScreen != null)
				s_disableSplashScreen.Dispose();
			s_disableSplashScreen = null;
		}