Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportRtfDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportRtfDialog(FdoCache cache)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            // If the current settings are for arabic digits then don't show the option
            // to export them as arabic.
            m_scr = cache.LangProject.TranslatedScriptureOA;

            // Set default export folder.
            m_rtfFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName,
                                                    cache.DatabaseName, "ExportFolderForRTF",
                                                    Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            string fileName = m_rtfFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache, FileType.RTF);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
        }
Esempio n. 2
0
        public void WhenParentAndChildNonDefault_ThenOverlayByReturnsCorrectValues()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var parent = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "black",
                    key,
                    _ => true);
                parent.Value = "red";
                Assert.IsFalse(parent.IsDefault);

                var child = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "black",
                    key,
                    _ => true);
                child.Value = "green";
                Assert.IsFalse(child.IsDefault);

                var effective = parent.OverlayBy(child);
                Assert.AreNotSame(effective, parent);
                Assert.AreNotSame(effective, child);

                Assert.AreEqual("green", effective.Value);
                Assert.AreEqual("red", effective.DefaultValue);
                Assert.IsFalse(effective.IsDefault);
            }
        }
 private void Dispose(bool fDisposing)
 {
     System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + " *******");
     if (fDisposing)
     {
         DisposeVariables();
     }
     SendSyncMessages    = null;
     ReceiveSyncMessages = null;
     ShowSpellingErrors  = null;
     ChangeAllBtWs       = null;
     BookFilterEnabled   = null;
     ShowUsfmResources   = null;
     FiltersKey          = null;
 }
Esempio n. 4
0
        public void WhenParentIsNonDefaultAndChildSetToOriginalDefault_ThenIsDefaultReturnsFalse()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var parent = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "black",
                    key,
                    _ => true);
                parent.Value = "red";
                Assert.IsFalse(parent.IsDefault);

                var intermediate = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "black",
                    key,
                    _ => true);
                Assert.IsTrue(intermediate.IsDefault);

                var child = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "black",
                    key,
                    _ => true);

                var effective = parent
                                .OverlayBy(intermediate)
                                .OverlayBy(child);
                Assert.AreNotSame(effective, parent);
                Assert.AreNotSame(effective, intermediate);
                Assert.AreNotSame(effective, child);

                effective.Value = "black";

                Assert.AreEqual("black", effective.Value);
                Assert.AreEqual("red", effective.DefaultValue);
                Assert.IsFalse(effective.IsDefault);
            }
        }
Esempio n. 5
0
        public void WhenValueIsOfWrongType_ThenSetValueRaisesInvalidCastException()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                Assert.Throws <InvalidCastException>(() => setting.Value = 1);
            }
        }
Esempio n. 6
0
			/// ------------------------------------------------------------------------------------
			/// <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);
			}
Esempio n. 7
0
        public void WhenSettingIsNonNull_ThenSaveUpdatesRegistry()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                setting.Value = "green";
                setting.Save(key);

                Assert.AreEqual("green", key.GetValue("test"));
            }
        }
Esempio n. 8
0
        public void WhenValueDiffersFromDefault_ThenSetValueSucceedsAndSettingIsDirty()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                setting.Value = "yellow";

                Assert.IsFalse(setting.IsDefault);
                Assert.IsTrue(setting.IsDirty);
            }
        }
Esempio n. 9
0
        public void WhenValueAndDefaultAreNull_ThenSetValueSucceedsAndSettingIsNotDirty()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    null,
                    key,
                    _ => true);

                setting.Value = null;

                Assert.IsTrue(setting.IsDefault);
                Assert.IsFalse(setting.IsDirty);
            }
        }
 /// ------------------------------------------------------------------------------------
 /// <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>
            /// 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);
            }
Esempio n. 12
0
        public void WhenValueIsNull_ThenSetValueResetsToDefault()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                setting.Value = "blue";
                setting.Value = null;

                Assert.AreEqual("blue", setting.Value);
                Assert.IsTrue(setting.IsDefault);
            }
        }
Esempio n. 13
0
        public void WhenSettingIsNull_ThenSaveResetsRegistry()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                key.SetValue("test", "red");

                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                setting.Value = null;
                setting.Save(key);

                Assert.IsNull(key.GetValue("test"));
            }
        }
Esempio n. 14
0
        public void WhenRegistryKeyIsNull_ThenFromKeyUsesDefaults()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    null,
                    _ => true);

                Assert.AreEqual("test", setting.Key);
                Assert.AreEqual("title", setting.Title);
                Assert.AreEqual("description", setting.Description);
                Assert.AreEqual("category", setting.Category);
                Assert.AreEqual("blue", setting.Value);
                Assert.IsTrue(setting.IsDefault);
                Assert.IsFalse(setting.IsDirty);
            }
        }
Esempio n. 15
0
        public void WhenRegistryValueExists_ThenFromKeyUsesValue()
        {
            using (var key = this.hkcu.CreateSubKey(TestKeyPath))
            {
                key.SetValue("test", "red");

                var setting = RegistryStringSetting.FromKey(
                    "test",
                    "title",
                    "description",
                    "category",
                    "blue",
                    key,
                    _ => true);

                Assert.AreEqual("test", setting.Key);
                Assert.AreEqual("title", setting.Title);
                Assert.AreEqual("description", setting.Description);
                Assert.AreEqual("category", setting.Category);
                Assert.AreEqual("red", setting.Value);
                Assert.IsFalse(setting.IsDefault);
                Assert.IsFalse(setting.IsDirty);
            }
        }
Esempio n. 16
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. 17
0
			private void Dispose(bool fDisposing)
			{
				System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + " *******");
				if (fDisposing)
				{
					DisposeVariables();
				}
				SendSyncMessages = null;
				ReceiveSyncMessages = null;
				ShowSpellingErrors = null;
				ChangeAllBtWs = null;
				BookFilterEnabled = null;
				ShowUsfmResources = null;
				FiltersKey = null;
			}
 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)
     });
 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 _)),
     });
        protected void InitializeFromKey(RegistryKey key)
        {
            //
            // RDP Settings.
            //
            this.RdpUsername = RegistryStringSetting.FromKey(
                "Username",
                "Username",
                "Windows logon username",
                Categories.RdpCredentials,
                null,
                key,
                _ => true);
            this.RdpPassword = RegistrySecureStringSetting.FromKey(
                "Password",
                "Password",
                "Windows logon password",
                Categories.RdpCredentials,
                key,
                DataProtectionScope.CurrentUser);
            this.RdpDomain = RegistryStringSetting.FromKey(
                "Domain",
                "Domain",
                "Windows logon domain",
                Categories.RdpCredentials,
                null,
                key,
                _ => true);
            this.RdpConnectionBar = RegistryEnumSetting <RdpConnectionBarState> .FromKey(
                "ConnectionBar",
                "Show connection bar",
                "Show connection bar in full-screen mode",
                Categories.RdpDisplay,
                RdpConnectionBarState._Default,
                key);

            this.RdpDesktopSize = RegistryEnumSetting <RdpDesktopSize> .FromKey(
                "DesktopSize",
                "Desktop size",
                "Size of remote desktop",
                Categories.RdpDisplay,
                ConnectionSettings.RdpDesktopSize._Default,
                key);

            this.RdpAuthenticationLevel = RegistryEnumSetting <RdpAuthenticationLevel> .FromKey(
                "AuthenticationLevel",
                "Server authentication",
                "Require server authentication when connecting",
                Categories.RdpConnection,
                ConnectionSettings.RdpAuthenticationLevel._Default,
                key);

            this.RdpColorDepth = RegistryEnumSetting <RdpColorDepth> .FromKey(
                "ColorDepth",
                "Color depth",
                "Color depth of remote desktop",
                Categories.RdpDisplay,
                ConnectionSettings.RdpColorDepth._Default,
                key);

            this.RdpAudioMode = RegistryEnumSetting <RdpAudioMode> .FromKey(
                "AudioMode",
                "Audio mode",
                "Redirect audio when playing on server",
                Categories.RdpResources,
                ConnectionSettings.RdpAudioMode._Default,
                key);

            this.RdpRedirectClipboard = RegistryEnumSetting <RdpRedirectClipboard> .FromKey(
                "RedirectClipboard",
                "Redirect clipboard",
                "Allow clipboard contents to be shared with remote desktop",
                Categories.RdpResources,
                ConnectionSettings.RdpRedirectClipboard._Default,
                key);

            this.RdpUserAuthenticationBehavior = RegistryEnumSetting <RdpUserAuthenticationBehavior> .FromKey(
                "RdpUserAuthenticationBehavior",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                ConnectionSettings.RdpUserAuthenticationBehavior._Default,
                key);

            this.RdpBitmapPersistence = RegistryEnumSetting <RdpBitmapPersistence> .FromKey(
                "BitmapPersistence",
                "Bitmap caching",
                "Use persistent bitmap cache",
                Categories.RdpResources,
                ConnectionSettings.RdpBitmapPersistence._Default,
                key);

            this.RdpConnectionTimeout = RegistryDwordSetting.FromKey(
                "ConnectionTimeout",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                30,
                key,
                0, 300);
            this.RdpCredentialGenerationBehavior = RegistryEnumSetting <RdpCredentialGenerationBehavior> .FromKey(
                "CredentialGenerationBehavior",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                ConnectionSettings.RdpCredentialGenerationBehavior._Default,
                key);

            this.RdpPort = RegistryDwordSetting.FromKey(
                "RdpPort",
                "Server port",
                "Server port",
                Categories.RdpConnection,
                3389,
                key,
                1,
                ushort.MaxValue);

            //
            // SSH Settings.
            //
            this.SshPort = RegistryDwordSetting.FromKey(
                "SshPort",
                "Server port",
                "Server port",
                Categories.SshConnection,
                22,
                key,
                1,
                ushort.MaxValue);
            this.SshUsername = RegistryStringSetting.FromKey(
                "SshUsername",
                "Username",
                "Preferred Linux username (only applicable if OS Login is disabled)",
                Categories.SshCredentials,
                null,
                key,
                username => string.IsNullOrEmpty(username) ||
                AuthorizedKey.IsValidUsername(username));
            this.SshConnectionTimeout = RegistryDwordSetting.FromKey(
                "SshConnectionTimeout",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                30,
                key,
                0, 300);

            Debug.Assert(this.Settings.All(s => s != null));
        }
Esempio n. 22
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportXmlDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, ScrReference refBook,
                               IVwStylesheet stylesheet, FileType exportType)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_scr         = cache.LangProject.TranslatedScriptureOA;
            m_eExportType = exportType;
            string key;

            switch (m_eExportType)
            {
            case FileType.OXES:
                key = "ExportFolderForXML";
                break;

            case FileType.XHTML:
                Text = TeResourceHelper.GetResourceString("kstidExportXHTML");                         // "Export XHTML"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.ODT:
                Text = TeResourceHelper.GetResourceString("kstidExportODT");                         // "Export Open Office file"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.PDF:
                Text = TeResourceHelper.GetResourceString("kstidExportPDF");                         // "Export Adobe Portable Document"
                key  = "ExportFolderForXhtml";
                break;

            default:
                key = "ExportFolderForXML";
                break;
            }
            m_xmlFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName,
                                                    cache.DatabaseName, key, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
            string fileName = m_xmlFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache, m_eExportType);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
            // Ensure that the end of the filename is visible.
            m_txtOutputFile.Select(fileName.Length, 0);

            FillFilterListLabel(filter);

            // Set the single book from the current one in use if possible, otherwise set
            // it from the first available book, if any are available.
            if (refBook == null)
            {
                refBook          = new ScrReference();
                refBook.BBCCCVVV = 1001001;
                if (m_scr.ScriptureBooksOS.Count > 0)
                {
                    refBook.Book = m_scr.ScriptureBooksOS[0].CanonicalNum;
                }
            }

            m_scrBook.Initialize(refBook, m_scr as Scripture, true);
            m_scrBook.PassageChanged += m_scrBook_PassageChanged;

            // Initialize the combo boxes, and then adjust their heights (and the locations
            // of following controls) as needed.
            m_oldComboHeight = cboFrom.Height;
            m_gap            = cboTo.Top - cboFrom.Bottom;
            FwStyleSheet ss = stylesheet as FwStyleSheet;

            m_fntVern    = new Font(ss.GetNormalFontFaceName(cache, cache.DefaultVernWs), 10);
            cboFrom.Font = cboTo.Font = m_fntVern;

            // Now that the sizes are fixed, load the combo box lists.
            LoadSectionsForBook(refBook.Book);

            m_nBookForSections = refBook.Book;
            m_sRangeBookFmt    = m_grpSectionRange.Text;
            UpdateBookSectionGroupLabel();

            //m_scrBook.Enabled = false;
            //m_grpSectionRange.Enabled = false;
            m_grpSectionRange.Visible = true;

            // Initialize the description.
            DateTime now = DateTime.Now;

            // "{0} exported by {1} on {2} {3}, {4} at {5}"
            m_txtDescription.Text = String.Format(DlgResources.ResourceString("kstidOxesExportDescription"),
                                                  cache.LangProject.Name.BestAnalysisVernacularAlternative.Text,
                                                  System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
                                                  now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

            // TODO: Set export type from the stored registry setting.
        }
Esempio n. 23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ExportXmlDialog"/> class.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, int defaultBookNum,
                               IVwStylesheet stylesheet, FileType exportType, IHelpTopicProvider helpTopicProvider)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            m_helpTopicProvider = helpTopicProvider;
            m_scr         = cache.LangProject.TranslatedScriptureOA;
            m_eExportType = exportType;

            string key;
            string descriptionFmt = "kstidOxesExportDescription";

            switch (m_eExportType)
            {
            case FileType.XHTML:
                Text = TeResourceHelper.GetResourceString("kstidExportXHTML");                         // "Export XHTML"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.ODT:
                Text = TeResourceHelper.GetResourceString("kstidExportODT");                         // "Export Open Office file"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.PDF:
                Text = TeResourceHelper.GetResourceString("kstidExportPDF");                         // "Export Adobe Portable Document"
                key  = "ExportFolderForXhtml";
                break;

            case FileType.OXEKT:
                Text = TeResourceHelper.GetResourceString("kstidExportOXEKT");                         // "Export Open XML for Exchanging Key Terms"
                m_lblExportWhat.Text = TeResourceHelper.GetResourceString("kstidExportWhatOXEKT");
                key            = "ExportFolderForXml";
                descriptionFmt = "kstidOxektExportDescription";
                break;

            case FileType.OXES:
            default:
                key = "ExportFolderForXml";
                break;
            }

            m_xmlFolder = new RegistryStringSetting(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                                                    key, FwSubKey.TE);
            string fileName = m_xmlFolder.Value;

            m_fileDialog = new TeImportExportFileDialog(cache.ProjectId.Name, m_eExportType);

            // Append a filename if it was set to just a directory
            if (Directory.Exists(fileName))
            {
                fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
            }
            m_txtOutputFile.Text = fileName;
            // Ensure that the end of the filename is visible.
            m_txtOutputFile.Select(fileName.Length, 0);

            FillFilterListLabel(filter);

            // Set the single book from the current one in use if possible, otherwise set
            // it from the first available book, if any are available.
            if (defaultBookNum < 1 || defaultBookNum > BCVRef.LastBook)
            {
                defaultBookNum = 1;
                if (m_scr.ScriptureBooksOS.Count > 0)
                {
                    defaultBookNum = m_scr.ScriptureBooksOS[0].CanonicalNum;
                }
            }

            m_scrBook.Initialize(defaultBookNum, m_scr.ScriptureBooksOS.Select(b => b.CanonicalNum).ToArray());
            m_scrBook.PassageChanged += m_scrBook_PassageChanged;

            // Initialize the combo boxes, and then adjust their heights (and the locations
            // of following controls) as needed.
            m_oldComboHeight = cboFrom.Height;
            m_gap            = cboTo.Top - cboFrom.Bottom;
            m_fntVern        = ((FwStyleSheet)stylesheet).GetUiFontForWritingSystem(
                cache.DefaultVernWs, FontInfo.kDefaultFontSize);
            cboFrom.Font = cboTo.Font = m_fntVern;

            // Now that the sizes are fixed, load the combo box lists.
            LoadSectionsForBook(defaultBookNum);

            m_nBookForSections = defaultBookNum;
            m_sRangeBookFmt    = m_grpSectionRange.Text;
            UpdateBookSectionGroupLabel();

            //m_scrBook.Enabled = false;
            //m_grpSectionRange.Enabled = false;
            m_grpSectionRange.Visible = true;

            // Initialize the description.
            DateTime now = DateTime.Now;

            // "{0} exported by {1} on {2} {3}, {4} at {5}"
            m_txtDescription.Text = String.Format(DlgResources.ResourceString(descriptionFmt),
                                                  cache.ProjectId.Name,
                                                  System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
                                                  now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

            // TODO: Set export type from the stored registry setting.
        }
Esempio n. 24
0
        protected void InitializeFromKey(RegistryKey key)
        {
            this.Username = RegistryStringSetting.FromKey(
                "Username",
                "Username",
                "Windows logon username",
                "Credentials",
                null,
                key,
                _ => true);
            this.Password = RegistrySecureStringSetting.FromKey(
                "Password",
                "Password",
                "Windows logon password",
                "Credentials",
                key,
                DataProtectionScope.CurrentUser);
            this.Domain = RegistryStringSetting.FromKey(
                "Domain",
                "Domain",
                "Windows logon domain",
                "Credentials",
                null,
                key,
                _ => true);
            this.ConnectionBar = RegistryEnumSetting <RdpConnectionBarState> .FromKey(
                "ConnectionBar",
                "Show connection bar",
                "Show connection bar in full-screen mode",
                "Display",
                RdpConnectionBarState._Default,
                key);

            this.DesktopSize = RegistryEnumSetting <RdpDesktopSize> .FromKey(
                "DesktopSize",
                "Desktop size",
                "Size of remote desktop",
                "Display",
                RdpDesktopSize._Default,
                key);

            this.AuthenticationLevel = RegistryEnumSetting <RdpAuthenticationLevel> .FromKey(
                "AuthenticationLevel",
                "Server authentication",
                "Require server authentication when connecting",
                "Connection",
                RdpAuthenticationLevel._Default,
                key);

            this.ColorDepth = RegistryEnumSetting <RdpColorDepth> .FromKey(
                "ColorDepth",
                "Color depth",
                "Color depth of remote desktop",
                "Display",
                RdpColorDepth._Default,
                key);

            this.AudioMode = RegistryEnumSetting <RdpAudioMode> .FromKey(
                "AudioMode",
                "Audio mode",
                "Redirect audio when playing on server",
                "Local resources",
                RdpAudioMode._Default,
                key);

            this.RedirectClipboard = RegistryEnumSetting <RdpRedirectClipboard> .FromKey(
                "RedirectClipboard",
                "Redirect clipboard",
                "Allow clipboard contents to be shared with remote desktop",
                "Local resources",
                RdpRedirectClipboard._Default,
                key);

            this.UserAuthenticationBehavior = RegistryEnumSetting <RdpUserAuthenticationBehavior> .FromKey(
                "RdpUserAuthenticationBehavior",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                RdpUserAuthenticationBehavior._Default,
                key);

            this.BitmapPersistence = RegistryEnumSetting <RdpBitmapPersistence> .FromKey(
                "BitmapPersistence",
                "Bitmap caching",
                "Use persistent bitmap cache",
                "Performance",
                RdpBitmapPersistence._Default,
                key);

            this.ConnectionTimeout = RegistryDwordSetting.FromKey(
                "ConnectionTimeout",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                30,
                key,
                0, 300);
            this.CredentialGenerationBehavior = RegistryEnumSetting <RdpCredentialGenerationBehavior> .FromKey(
                "CredentialGenerationBehavior",
                null, // Hidden.
                null, // Hidden.
                null, // Hidden.
                RdpCredentialGenerationBehavior._Default,
                key);

            this.RdpPort = RegistryDwordSetting.FromKey(
                "RdpPort",
                "RDP port",
                "RDP port",
                "Connection",
                3389,
                key,
                1,
                ushort.MaxValue);

            Debug.Assert(this.Settings.All(s => s != null));
        }