public void WhenParentAndChildNonDefault_ThenOverlayByReturnsCorrectValues() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var parent = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); parent.Value = true; Assert.IsFalse(parent.IsDefault); var child = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); child.Value = true; Assert.IsFalse(child.IsDefault); var effective = parent.OverlayBy(child); Assert.AreNotSame(effective, parent); Assert.AreNotSame(effective, child); Assert.IsTrue((bool)effective.Value); Assert.IsTrue((bool)effective.DefaultValue); Assert.IsTrue(effective.IsDefault); } }
/// <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; }
public void WhenValueIsUnparsable_ThenSetValueRaisesFormatException() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); Assert.Throws <FormatException>(() => setting.Value = "maybe"); } }
public void WhenValueIsOfWrongType_ThenSetValueRaisesInvalidCastException() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); Assert.Throws <InvalidCastException>(() => setting.Value = -1); } }
public static TerminalSettings FromKey(RegistryKey registryKey) { return(new TerminalSettings() { IsCopyPasteUsingCtrlCAndCtrlVEnabled = RegistryBoolSetting.FromKey( "IsCopyPasteUsingCtrlCAndCtrlVEnabled", "IsCopyPasteUsingCtrlCAndCtrlVEnabled", null, null, true, registryKey), IsSelectAllUsingCtrlAEnabled = RegistryBoolSetting.FromKey( "IsSelectAllUsingCtrlAEnabled", "IsSelectAllUsingCtrlAEnabled", null, null, false, registryKey), IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled = RegistryBoolSetting.FromKey( "IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled", "IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled", null, null, true, registryKey), IsSelectUsingShiftArrrowEnabled = RegistryBoolSetting.FromKey( "IsSelectUsingShiftArrrowEnabled", "IsSelectUsingShiftArrrowEnabled", null, null, true, registryKey), IsQuoteConvertionOnPasteEnabled = RegistryBoolSetting.FromKey( "IsQuoteConvertionOnPasteEnabled", "IsQuoteConvertionOnPasteEnabled", null, null, true, registryKey), IsNavigationUsingControlArrrowEnabled = RegistryBoolSetting.FromKey( "IsNavigationUsingControlArrrowEnabled", "IsNavigationUsingControlArrrowEnabled", null, null, true, registryKey), }); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the project settings from the specified registry key. /// </summary> /// <param name="key">The registry key.</param> /// ------------------------------------------------------------------------------------ public void InitSettings(RegistryKey key) { if (key == null) throw new ArgumentNullException("key"); if (SendSyncMessages != null) DisposeVariables(); SendSyncMessages = new RegistryBoolSetting(key, "SendSyncMessage", true); ReceiveSyncMessages = new RegistryBoolSetting(key, "ReceiveSyncMessage", false); ShowSpellingErrors = new RegistryBoolSetting(key, "ShowSpellingErrors", false); ChangeAllBtWs = new RegistryBoolSetting(key, "ChangeAllBtViews", true); BookFilterEnabled = new RegistryBoolSetting(key, "BookFilterEnabled", false); ShowUsfmResources = new RegistryBoolSetting(key, "ShowUsfmResources", false); FiltersKey = new RegistryStringSetting(key, "BookFilterBooks", string.Empty); }
/// <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"); }
public void WhenValueIsString_ThenSetValueParsesValue() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); setting.Value = "TRUE"; Assert.AreEqual(true, setting.Value); } }
public void WhenParentIsNonDefaultAndChildSetToOriginalDefault_ThenIsDefaultReturnsFalse() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var parent = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); parent.Value = true; Assert.IsFalse(parent.IsDefault); var intermediate = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); Assert.IsTrue(intermediate.IsDefault); var child = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); var effective = parent .OverlayBy(intermediate) .OverlayBy(child); Assert.AreNotSame(effective, parent); Assert.AreNotSame(effective, intermediate); Assert.AreNotSame(effective, child); effective.Value = false; Assert.IsFalse((bool)effective.Value); Assert.IsTrue((bool)effective.DefaultValue); Assert.IsFalse(effective.IsDefault); } }
public void WhenValueDiffersFromDefault_ThenSetValueSucceedsAndSettingIsDirty() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); setting.Value = true; Assert.IsFalse(setting.IsDefault); Assert.IsTrue(setting.IsDirty); } }
public void WhenSettingIsNonNull_ThenSaveUpdatesRegistry() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); setting.Value = true; setting.Save(key); Assert.AreEqual(1, key.GetValue("test")); } }
/// ------------------------------------------------------------------------------------ /// <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); }
public void WhenValueIsNull_ThenSetValueResetsToDefault() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); setting.Value = true; setting.Value = null; Assert.AreEqual(false, setting.Value); Assert.IsTrue(setting.IsDefault); } }
public void WhenSettingIsNull_ThenSaveResetsRegistry() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { key.SetValue("test", 1, RegistryValueKind.DWord); var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); setting.Value = null; setting.Save(key); Assert.IsNull(key.GetValue("test")); } }
/// ----------------------------------------------------------------------------------- /// <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; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the project settings from the specified registry key. /// </summary> /// <param name="key">The registry key.</param> /// ------------------------------------------------------------------------------------ public void InitSettings(RegistryKey key) { if (key == null) { throw new ArgumentNullException("key"); } if (SendSyncMessages != null) { DisposeVariables(); } SendSyncMessages = new RegistryBoolSetting(key, "SendSyncMessage", true); ReceiveSyncMessages = new RegistryBoolSetting(key, "ReceiveSyncMessage", false); ShowSpellingErrors = new RegistryBoolSetting(key, "ShowSpellingErrors", false); ChangeAllBtWs = new RegistryBoolSetting(key, "ChangeAllBtViews", true); BookFilterEnabled = new RegistryBoolSetting(key, "BookFilterEnabled", false); ShowUsfmResources = new RegistryBoolSetting(key, "ShowUsfmResources", false); FiltersKey = new RegistryStringSetting(key, "BookFilterBooks", string.Empty); }
public void WhenRegistryValueDoesNotExist_ThenFromKeyUsesDefaults() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", true, key); Assert.AreEqual("test", setting.Key); Assert.AreEqual("title", setting.Title); Assert.AreEqual("description", setting.Description); Assert.AreEqual("category", setting.Category); Assert.IsTrue((bool)setting.Value); Assert.IsTrue(setting.IsDefault); Assert.IsFalse(setting.IsDirty); } }
public static SshSettings FromKey(RegistryKey registryKey) { return(new SshSettings() { IsPropagateLocaleEnabled = RegistryBoolSetting.FromKey( "IsPropagateLocaleEnabled", "IsPropagateLocaleEnabled", null, null, true, registryKey), PublicKeyValidity = RegistryDwordSetting.FromKey( "PublicKeyValidity", "PublicKeyValidity", "Validity of (OS Login/Metadata) keys in seconds", null, (int)TimeSpan.FromDays(30).TotalSeconds, registryKey, (int)TimeSpan.FromMinutes(1).TotalSeconds, int.MaxValue) }); }
public void WhenRegistryValueExists_ThenFromKeyUsesValue() { using (var key = this.hkcu.CreateSubKey(TestKeyPath)) { key.SetValue("test", 1, RegistryValueKind.DWord); var setting = RegistryBoolSetting.FromKey( "test", "title", "description", "category", false, key); Assert.AreEqual("test", setting.Key); Assert.AreEqual("title", setting.Title); Assert.AreEqual("description", setting.Description); Assert.AreEqual("category", setting.Category); Assert.IsTrue((bool)setting.Value); Assert.IsFalse(setting.IsDefault); Assert.IsFalse(setting.IsDirty); } }
/// <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); }
public static ApplicationSettings FromKey(RegistryKey registryKey) { return(new ApplicationSettings() { IsMainWindowMaximized = RegistryBoolSetting.FromKey( "IsMainWindowMaximized", "IsMainWindowMaximized", null, null, false, registryKey), MainWindowHeight = RegistryDwordSetting.FromKey( "MainWindowHeight", "MainWindowHeight", null, null, 0, registryKey, 0, ushort.MaxValue), MainWindowWidth = RegistryDwordSetting.FromKey( "WindowWidth", "WindowWidth", null, null, 0, registryKey, 0, ushort.MaxValue), IsUpdateCheckEnabled = RegistryBoolSetting.FromKey( "IsUpdateCheckEnabled", "IsUpdateCheckEnabled", null, null, true, registryKey), LastUpdateCheck = RegistryQwordSetting.FromKey( "LastUpdateCheck", "LastUpdateCheck", null, null, 0, registryKey, 0, long.MaxValue), IsPreviewFeatureSetEnabled = RegistryBoolSetting.FromKey( "IsPreviewFeatureSetEnabled", "IsPreviewFeatureSetEnabled", null, null, false, registryKey), ProxyUrl = RegistryStringSetting.FromKey( "ProxyUrl", "ProxyUrl", null, null, null, registryKey, url => url == null || Uri.TryCreate(url, UriKind.Absolute, out Uri _)), });
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; }
public static TerminalSettings FromKey(RegistryKey registryKey) { return(new TerminalSettings() { IsCopyPasteUsingCtrlCAndCtrlVEnabled = RegistryBoolSetting.FromKey( "IsCopyPasteUsingCtrlCAndCtrlVEnabled", "IsCopyPasteUsingCtrlCAndCtrlVEnabled", null, null, true, registryKey), IsSelectAllUsingCtrlAEnabled = RegistryBoolSetting.FromKey( "IsSelectAllUsingCtrlAEnabled", "IsSelectAllUsingCtrlAEnabled", null, null, false, registryKey), IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled = RegistryBoolSetting.FromKey( "IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled", "IsCopyPasteUsingShiftInsertAndCtrlInsertEnabled", null, null, true, registryKey), IsSelectUsingShiftArrrowEnabled = RegistryBoolSetting.FromKey( "IsSelectUsingShiftArrrowEnabled", "IsSelectUsingShiftArrrowEnabled", null, null, true, registryKey), IsQuoteConvertionOnPasteEnabled = RegistryBoolSetting.FromKey( "IsQuoteConvertionOnPasteEnabled", "IsQuoteConvertionOnPasteEnabled", null, null, true, registryKey), IsNavigationUsingControlArrrowEnabled = RegistryBoolSetting.FromKey( "IsNavigationUsingControlArrrowEnabled", "IsNavigationUsingControlArrrowEnabled", null, null, true, registryKey), IsScrollingUsingCtrlUpDownEnabled = RegistryBoolSetting.FromKey( "IsScrollingUsingCtrlUpDownEnabled", "IsScrollingUsingCtrlUpDownEnabled", null, null, true, registryKey), IsScrollingUsingCtrlHomeEndEnabled = RegistryBoolSetting.FromKey( "IsScrollingUsingCtrlHomeEndEnabled", "IsScrollingUsingCtrlHomeEndEnabled", null, null, true, registryKey), FontFamily = RegistryStringSetting.FromKey( "FontFamily", "FontFamily", null, null, TerminalFont.DefaultFontFamily, registryKey, f => f == null || TerminalFont.IsValidFont(f)), FontSizeAsDword = RegistryDwordSetting.FromKey( "FontSize", "FontSize", null, null, DwordFromFontSize(TerminalFont.DefaultSize), registryKey, DwordFromFontSize(TerminalFont.MinimumSize), DwordFromFontSize(TerminalFont.MaximumSize)) }); }
public static ApplicationSettings FromKey(RegistryKey registryKey) { return(new ApplicationSettings() { IsMainWindowMaximized = RegistryBoolSetting.FromKey( "IsMainWindowMaximized", "IsMainWindowMaximized", null, null, false, registryKey), MainWindowHeight = RegistryDwordSetting.FromKey( "MainWindowHeight", "MainWindowHeight", null, null, 0, registryKey, 0, ushort.MaxValue), MainWindowWidth = RegistryDwordSetting.FromKey( "WindowWidth", "WindowWidth", null, null, 0, registryKey, 0, ushort.MaxValue), IsUpdateCheckEnabled = RegistryBoolSetting.FromKey( "IsUpdateCheckEnabled", "IsUpdateCheckEnabled", null, null, true, registryKey), LastUpdateCheck = RegistryQwordSetting.FromKey( "LastUpdateCheck", "LastUpdateCheck", null, null, 0, registryKey, 0, long.MaxValue), IsPreviewFeatureSetEnabled = RegistryBoolSetting.FromKey( "IsPreviewFeatureSetEnabled", "IsPreviewFeatureSetEnabled", null, null, false, registryKey), ProxyUrl = RegistryStringSetting.FromKey( "ProxyUrl", "ProxyUrl", null, null, null, registryKey, url => url == null || Uri.TryCreate(url, UriKind.Absolute, out Uri _)), ProxyPacUrl = RegistryStringSetting.FromKey( "ProxyPacUrl", "ProxyPacUrl", null, null, null, registryKey, url => url == null || Uri.TryCreate(url, UriKind.Absolute, out Uri _)), ProxyUsername = RegistryStringSetting.FromKey( "ProxyUsername", "ProxyUsername", null, null, null, registryKey, _ => true), ProxyPassword = RegistrySecureStringSetting.FromKey( "ProxyPassword", "ProxyPassword", null, null, registryKey, DataProtectionScope.CurrentUser), IsDeviceCertificateAuthenticationEnabled = RegistryBoolSetting.FromKey( "IsDeviceCertificateAuthenticationEnabled", "IsDeviceCertificateAuthenticationEnabled", null, null, false, registryKey), FullScreenDevices = RegistryStringSetting.FromKey( "FullScreenDevices", "FullScreenDevices", null, null, null, registryKey, _ => true), IncludeOperatingSystems = RegistryEnumSetting <OperatingSystems> .FromKey( "IncludeOperatingSystems", "IncludeOperatingSystems", null, null, OperatingSystems.Windows, registryKey) });