From d018fdbace93f309216b60c156dd03c74f61c918 Mon Sep 17 00:00:00 2001
From: xRushG <145561288+xRushG@users.noreply.github.com>
Date: Tue, 1 Oct 2024 12:35:34 +0200
Subject: [PATCH] feat: Add registry settings for Connections and SQL Server
settings
- Added registry settings for the Connection Page.
- Added registry settings for the SQL Serverl Page.
- All settings implemented with async registry logic
- Comment unused settings for Connection Page
- Update documents
---
.../Registry/OptRegistryConnectionsPage.cs | 178 ++++++++++++++++++
.../Registry/OptRegistrySqlServerPage.cs | 154 +++++++++++++++
.../OptionsPages/ConnectionsPage.Designer.cs | 87 ++++++---
.../UI/Forms/OptionsPages/ConnectionsPage.cs | 94 ++++++++-
.../Forms/OptionsPages/ConnectionsPage.resx | 62 +++++-
.../OptionsPages/SqlServerPage.Designer.cs | 122 +++++++-----
.../UI/Forms/OptionsPages/SqlServerPage.cs | 58 +++++-
.../UI/Forms/OptionsPages/SqlServerPage.resx | 62 +++++-
.../registry/connection_settings.rst | 167 ++++++++++++++++
.../registry/sqlServer_settings.rst | 106 +++++++++++
.../registry_settings_guide.rst | 2 +
11 files changed, 1009 insertions(+), 83 deletions(-)
create mode 100644 mRemoteNG/Config/Settings/Registry/OptRegistryConnectionsPage.cs
create mode 100644 mRemoteNG/Config/Settings/Registry/OptRegistrySqlServerPage.cs
create mode 100644 mRemoteNGDocumentation/registry/connection_settings.rst
create mode 100644 mRemoteNGDocumentation/registry/sqlServer_settings.rst
diff --git a/mRemoteNG/Config/Settings/Registry/OptRegistryConnectionsPage.cs b/mRemoteNG/Config/Settings/Registry/OptRegistryConnectionsPage.cs
new file mode 100644
index 00000000..26814bbb
--- /dev/null
+++ b/mRemoteNG/Config/Settings/Registry/OptRegistryConnectionsPage.cs
@@ -0,0 +1,178 @@
+using System.Runtime.Versioning;
+using Microsoft.Win32;
+using mRemoteNG.App.Info;
+using mRemoteNG.Tools.WindowsRegistry;
+
+namespace mRemoteNG.Config.Settings.Registry
+{
+ [SupportedOSPlatform("windows")]
+ public sealed partial class OptRegistryConnectionsPage
+ {
+ ///
+ /// Specifies whether to single click to connection opens/establishes connection
+ ///
+ public WinRegistryEntry SingleClickOnConnectionOpensIt { get; private set; }
+
+ ///
+ /// Specifies whether a single click on an open connection switches the focused tab to that connection.
+ ///
+ public WinRegistryEntry SingleClickSwitchesToOpenConnection { get; private set; }
+
+ ///
+ /// Specifies whether to track open connections in the connection tree.
+ ///
+ public WinRegistryEntry TrackActiveConnectionInConnectionTree { get; private set; }
+
+ ///
+ /// Specifies whether to set the hostname like the display name when creating or renaming a connection.
+ ///
+ public WinRegistryEntry SetHostnameLikeDisplayName { get; private set; }
+
+ ///
+ /// Specifies whether filter matches in the search are applied in the connection tree.
+ ///
+ public WinRegistryEntry UseFilterSearch { get; private set; }
+
+ ///
+ /// Specifies whether the search bar is placed above the connection tree.
+ ///
+ public WinRegistryEntry PlaceSearchBarAboveConnectionTree { get; private set; }
+
+ ///
+ /// Specifies whether the username trimming is disabled.
+ ///
+ public WinRegistryEntry DoNotTrimUsername { get; private set; }
+
+ ///
+ /// Specifies the number of RDP reconnections.
+ ///
+ public WinRegistryEntry RdpReconnectionCount { get; private set; }
+
+ ///
+ /// Specifies the overall connection timeout for RDP connections.
+ ///
+ public WinRegistryEntry ConRDPOverallConnectionTimeout { get; private set; }
+
+ ///
+ /// Specifies the autosave interval in minutes.
+ ///
+ public WinRegistryEntry AutoSaveEveryMinutes { get; private set; }
+
+ public OptRegistryConnectionsPage()
+ {
+ RegistryHive hive = WindowsRegistryInfo.Hive;
+ string subKey = WindowsRegistryInfo.ConnectionOptions;
+
+ SingleClickOnConnectionOpensIt = new WinRegistryEntry(hive, subKey, nameof(SingleClickOnConnectionOpensIt)).Read();
+ SingleClickSwitchesToOpenConnection = new WinRegistryEntry(hive, subKey, nameof(SingleClickSwitchesToOpenConnection)).Read();
+ TrackActiveConnectionInConnectionTree = new WinRegistryEntry(hive, subKey, nameof(TrackActiveConnectionInConnectionTree)).Read();
+ SetHostnameLikeDisplayName = new WinRegistryEntry(hive, subKey, nameof(SetHostnameLikeDisplayName)).Read();
+ UseFilterSearch = new WinRegistryEntry(hive, subKey, nameof(UseFilterSearch)).Read();
+ PlaceSearchBarAboveConnectionTree = new WinRegistryEntry(hive, subKey, nameof(PlaceSearchBarAboveConnectionTree)).Read();
+ DoNotTrimUsername = new WinRegistryEntry(hive, subKey, nameof(DoNotTrimUsername)).Read();
+ RdpReconnectionCount = new WinRegistryEntry(hive, subKey, nameof(RdpReconnectionCount)).Read();
+ ConRDPOverallConnectionTimeout = new WinRegistryEntry(hive, subKey, nameof(ConRDPOverallConnectionTimeout)).Read();
+ AutoSaveEveryMinutes = new WinRegistryEntry(hive, subKey, nameof(AutoSaveEveryMinutes)).Read();
+
+ SetupValidation();
+ Apply();
+ }
+
+ ///
+ /// Configures validation settings for various parameters
+ ///
+ private void SetupValidation()
+ {
+ var connectionsPage = new UI.Forms.OptionsPages.ConnectionsPage();
+
+ int ConRDPOverallConnectionTimeoutMin = (int)connectionsPage.numRDPConTimeout.Minimum;
+ int ConRDPOverallConnectionTimeoutMax = (int)connectionsPage.numRDPConTimeout.Maximum;
+ ConRDPOverallConnectionTimeout.SetValidation(ConRDPOverallConnectionTimeoutMin, ConRDPOverallConnectionTimeoutMax);
+
+ int numAutoSaveMin = (int)connectionsPage.numAutoSave.Minimum;
+ int numAutoSaveMax = (int)connectionsPage.numAutoSave.Maximum;
+ AutoSaveEveryMinutes.SetValidation(numAutoSaveMin, numAutoSaveMax);
+
+ int RdpReconnectionCountMin = (int)connectionsPage.numRdpReconnectionCount.Minimum;
+ int RdpReconnectionCountMax = (int)connectionsPage.numRdpReconnectionCount.Maximum;
+ RdpReconnectionCount.SetValidation(RdpReconnectionCountMin, RdpReconnectionCountMax);
+ }
+
+ ///
+ /// Applies registry settings and overrides various properties.
+ ///
+ private void Apply()
+ {
+ ApplySingleClickOnConnectionOpensIt();
+ ApplySingleClickSwitchesToOpenConnection();
+ ApplyTrackActiveConnectionInConnectionTree();
+ ApplySetHostnameLikeDisplayName();
+ ApplyUseFilterSearch();
+ ApplyPlaceSearchBarAboveConnectionTree();
+ ApplyDoNotTrimUsername();
+ ApplyRdpReconnectionCount();
+ ApplyConRDPOverallConnectionTimeout();
+ ApplyAutoSaveEveryMinutes();
+ }
+
+ private void ApplySingleClickOnConnectionOpensIt()
+ {
+ if (SingleClickOnConnectionOpensIt.IsSet)
+ Properties.Settings.Default.SingleClickOnConnectionOpensIt = SingleClickOnConnectionOpensIt.Value;
+ }
+
+ private void ApplySingleClickSwitchesToOpenConnection()
+ {
+ if (SingleClickSwitchesToOpenConnection.IsSet)
+ Properties.Settings.Default.SingleClickSwitchesToOpenConnection = SingleClickSwitchesToOpenConnection.Value;
+ }
+
+ private void ApplyTrackActiveConnectionInConnectionTree()
+ {
+ if (TrackActiveConnectionInConnectionTree.IsSet)
+ Properties.Settings.Default.TrackActiveConnectionInConnectionTree = TrackActiveConnectionInConnectionTree.Value;
+ }
+
+ private void ApplySetHostnameLikeDisplayName()
+ {
+ if (SetHostnameLikeDisplayName.IsSet)
+ Properties.Settings.Default.SetHostnameLikeDisplayName = SetHostnameLikeDisplayName.Value;
+ }
+
+ private void ApplyUseFilterSearch()
+ {
+ if (UseFilterSearch.IsSet)
+ Properties.Settings.Default.UseFilterSearch = UseFilterSearch.Value;
+ }
+
+ private void ApplyPlaceSearchBarAboveConnectionTree()
+ {
+ if (PlaceSearchBarAboveConnectionTree.IsSet)
+ Properties.Settings.Default.PlaceSearchBarAboveConnectionTree = PlaceSearchBarAboveConnectionTree.Value;
+ }
+
+ private void ApplyDoNotTrimUsername()
+ {
+ if (DoNotTrimUsername.IsSet)
+ Properties.Settings.Default.DoNotTrimUsername = DoNotTrimUsername.Value;
+ }
+
+ private void ApplyRdpReconnectionCount()
+ {
+ if (RdpReconnectionCount.IsValid)
+ Properties.Settings.Default.RdpReconnectionCount = RdpReconnectionCount.Value;
+ }
+
+ private void ApplyConRDPOverallConnectionTimeout()
+ {
+ if (ConRDPOverallConnectionTimeout.IsValid)
+ Properties.Settings.Default.ConRDPOverallConnectionTimeout = ConRDPOverallConnectionTimeout.Value;
+ }
+
+ private void ApplyAutoSaveEveryMinutes()
+ {
+ if (AutoSaveEveryMinutes.IsValid)
+ Properties.OptionsBackupPage.Default.AutoSaveEveryMinutes = AutoSaveEveryMinutes.Value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/mRemoteNG/Config/Settings/Registry/OptRegistrySqlServerPage.cs b/mRemoteNG/Config/Settings/Registry/OptRegistrySqlServerPage.cs
new file mode 100644
index 00000000..21154e75
--- /dev/null
+++ b/mRemoteNG/Config/Settings/Registry/OptRegistrySqlServerPage.cs
@@ -0,0 +1,154 @@
+using System.Runtime.Versioning;
+using Microsoft.Win32;
+using mRemoteNG.App;
+using mRemoteNG.App.Info;
+using mRemoteNG.Security.SymmetricEncryption;
+using mRemoteNG.Tools.WindowsRegistry;
+
+namespace mRemoteNG.Config.Settings.Registry
+{
+ [SupportedOSPlatform("windows")]
+ public sealed partial class OptRegistrySqlServerPage
+ {
+ ///
+ /// Specifies whether SQL Server is being used.
+ ///
+ public WinRegistryEntry UseSQLServer { get; private set; }
+
+ ///
+ /// Specifies the type of SQL Server being used.
+ ///
+ public WinRegistryEntry SQLServerType { get; private set; }
+
+ ///
+ /// Specifies the host of the SQL Server.
+ ///
+ public WinRegistryEntry SQLHost { get; private set; }
+
+ ///
+ /// Specifies the name/instance of the SQL database.
+ ///
+ public WinRegistryEntry SQLDatabaseName { get; private set; }
+
+ ///
+ /// Specifies the username for accessing the SQL Server.
+ ///
+ public WinRegistryEntry SQLUser { get; private set; }
+
+ ///
+ /// Specifies the password for accessing the SQL Server.
+ ///
+ public WinRegistryEntry SQLPassword { get; private set; }
+
+ ///
+ /// Specifies whether the SQL connection is read-only.
+ ///
+ public WinRegistryEntry SQLReadOnly { get; private set; }
+
+ public OptRegistrySqlServerPage()
+ {
+ RegistryHive hive = WindowsRegistryInfo.Hive;
+ string subKey = WindowsRegistryInfo.SQLServerOptions;
+
+ UseSQLServer = new WinRegistryEntry(hive, subKey, nameof(UseSQLServer)).Read();
+ SQLServerType = new WinRegistryEntry(hive, subKey, nameof(SQLServerType)).Read();
+ SQLHost = new WinRegistryEntry(hive, subKey, nameof(SQLHost)).Read();
+ SQLDatabaseName = new WinRegistryEntry(hive, subKey, nameof(SQLDatabaseName)).Read();
+ SQLUser = new WinRegistryEntry(hive, subKey, nameof(SQLUser)).Read();
+ SQLPassword = new WinRegistryEntry(hive, subKey, nameof(SQLPassword)).Read();
+ SQLReadOnly = new WinRegistryEntry(hive, subKey, nameof(SQLReadOnly)).Read();
+
+ SetupValidation();
+ Apply();
+ }
+
+ ///
+ /// Configures validation settings for various parameters
+ ///
+ private void SetupValidation()
+ {
+ SQLServerType.SetValidation(
+ new string[] {
+ "mssql",
+ "mysql"
+ });
+ }
+
+ ///
+ /// Applies registry settings and overrides various properties.
+ ///
+ private void Apply()
+ {
+ if (!UseSQLServer.IsSet) { return; }
+
+ ApplyUseSQLServer();
+
+ if (!Properties.OptionsDBsPage.Default.UseSQLServer) { return; }
+
+ ApplySQLServerType();
+ ApplySQLHost();
+ ApplySQLDatabaseName();
+ ApplySQLUser();
+ ApplySQLPassword();
+ ApplySQLReadOnly();
+ }
+
+ private void ApplyUseSQLServer()
+ {
+ Properties.OptionsDBsPage.Default.UseSQLServer = UseSQLServer.Value;
+ }
+
+ private void ApplySQLServerType()
+ {
+ if (SQLServerType.IsValid)
+ Properties.OptionsDBsPage.Default.SQLServerType = SQLServerType.Value;
+
+ }
+
+ private void ApplySQLHost()
+ {
+ if (SQLHost.IsSet)
+ Properties.OptionsDBsPage.Default.SQLHost = SQLHost.Value;
+ }
+
+ private void ApplySQLDatabaseName()
+ {
+ if (SQLDatabaseName.IsSet)
+ Properties.OptionsDBsPage.Default.SQLDatabaseName = SQLDatabaseName.Value;
+
+ }
+
+ private void ApplySQLUser()
+ {
+ if (SQLUser.IsSet)
+ Properties.OptionsDBsPage.Default.SQLUser = SQLUser.Value;
+ }
+
+ private void ApplySQLPassword()
+ {
+ if (SQLPassword.IsSet)
+ {
+ // Prevents potential issues when using SQLPass later.
+ try
+ {
+ LegacyRijndaelCryptographyProvider cryptographyProvider = new();
+ string decryptedPassword;
+ string sqlPassword = SQLPassword.Value;
+ decryptedPassword = cryptographyProvider.Decrypt(sqlPassword, Runtime.EncryptionKey);
+
+ Properties.OptionsDBsPage.Default.SQLPass = sqlPassword;
+ }
+ catch
+ {
+ // Fire-and-forget: The password in the registry is not encrypted.
+ }
+ }
+ }
+
+ private void ApplySQLReadOnly()
+ {
+ if (SQLReadOnly.IsSet)
+ Properties.OptionsDBsPage.Default.SQLReadOnly = SQLReadOnly.Value;
+ }
+ }
+}
\ No newline at end of file
diff --git a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs
index f6656aae..b6b6e648 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs
@@ -54,17 +54,20 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkPlaceSearchBarAboveConnectionTree = new MrngCheckBox();
chkConnectionTreeTrackActiveConnection = new MrngCheckBox();
chkDoNotTrimUsername = new MrngCheckBox();
+ pnlOptions = new System.Windows.Forms.Panel();
+ lblRegistrySettingsUsedInfo = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)numRDPConTimeout).BeginInit();
((System.ComponentModel.ISupportInitialize)numRdpReconnectionCount).BeginInit();
((System.ComponentModel.ISupportInitialize)numAutoSave).BeginInit();
pnlConfirmCloseConnection.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
+ pnlOptions.SuspendLayout();
SuspendLayout();
//
// numRDPConTimeout
//
numRDPConTimeout.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- numRDPConTimeout.Location = new System.Drawing.Point(274, 29);
+ numRDPConTimeout.Location = new System.Drawing.Point(277, 29);
numRDPConTimeout.Maximum = new decimal(new int[] { 600, 0, 0, 0 });
numRDPConTimeout.Minimum = new decimal(new int[] { 20, 0, 0, 0 });
numRDPConTimeout.Name = "numRDPConTimeout";
@@ -77,7 +80,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblRDPConTimeout.Dock = System.Windows.Forms.DockStyle.Top;
lblRDPConTimeout.Location = new System.Drawing.Point(3, 26);
lblRDPConTimeout.Name = "lblRDPConTimeout";
- lblRDPConTimeout.Size = new System.Drawing.Size(265, 26);
+ lblRDPConTimeout.Size = new System.Drawing.Size(268, 26);
lblRDPConTimeout.TabIndex = 0;
lblRDPConTimeout.Text = "RDP Connection Timeout";
lblRDPConTimeout.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -87,7 +90,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblRdpReconnectionCount.Dock = System.Windows.Forms.DockStyle.Top;
lblRdpReconnectionCount.Location = new System.Drawing.Point(3, 0);
lblRdpReconnectionCount.Name = "lblRdpReconnectionCount";
- lblRdpReconnectionCount.Size = new System.Drawing.Size(265, 26);
+ lblRdpReconnectionCount.Size = new System.Drawing.Size(268, 26);
lblRdpReconnectionCount.TabIndex = 0;
lblRdpReconnectionCount.Text = "RDP Reconnection Count";
lblRdpReconnectionCount.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -95,7 +98,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
// numRdpReconnectionCount
//
numRdpReconnectionCount.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- numRdpReconnectionCount.Location = new System.Drawing.Point(274, 3);
+ numRdpReconnectionCount.Location = new System.Drawing.Point(277, 3);
numRdpReconnectionCount.Maximum = new decimal(new int[] { 20, 0, 0, 0 });
numRdpReconnectionCount.Name = "numRdpReconnectionCount";
numRdpReconnectionCount.Size = new System.Drawing.Size(53, 22);
@@ -107,7 +110,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkSingleClickOnConnectionOpensIt._mice = MrngCheckBox.MouseState.OUT;
chkSingleClickOnConnectionOpensIt.AutoSize = true;
chkSingleClickOnConnectionOpensIt.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkSingleClickOnConnectionOpensIt.Location = new System.Drawing.Point(3, 3);
+ chkSingleClickOnConnectionOpensIt.Location = new System.Drawing.Point(6, 3);
chkSingleClickOnConnectionOpensIt.Name = "chkSingleClickOnConnectionOpensIt";
chkSingleClickOnConnectionOpensIt.Size = new System.Drawing.Size(206, 17);
chkSingleClickOnConnectionOpensIt.TabIndex = 0;
@@ -119,7 +122,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkHostnameLikeDisplayName._mice = MrngCheckBox.MouseState.OUT;
chkHostnameLikeDisplayName.AutoSize = true;
chkHostnameLikeDisplayName.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkHostnameLikeDisplayName.Location = new System.Drawing.Point(3, 72);
+ chkHostnameLikeDisplayName.Location = new System.Drawing.Point(6, 72);
chkHostnameLikeDisplayName.Name = "chkHostnameLikeDisplayName";
chkHostnameLikeDisplayName.Size = new System.Drawing.Size(355, 17);
chkHostnameLikeDisplayName.TabIndex = 2;
@@ -131,7 +134,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkSingleClickOnOpenedConnectionSwitchesToIt._mice = MrngCheckBox.MouseState.OUT;
chkSingleClickOnOpenedConnectionSwitchesToIt.AutoSize = true;
chkSingleClickOnOpenedConnectionSwitchesToIt.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkSingleClickOnOpenedConnectionSwitchesToIt.Location = new System.Drawing.Point(3, 26);
+ chkSingleClickOnOpenedConnectionSwitchesToIt.Location = new System.Drawing.Point(6, 26);
chkSingleClickOnOpenedConnectionSwitchesToIt.Name = "chkSingleClickOnOpenedConnectionSwitchesToIt";
chkSingleClickOnOpenedConnectionSwitchesToIt.Size = new System.Drawing.Size(492, 17);
chkSingleClickOnOpenedConnectionSwitchesToIt.TabIndex = 1;
@@ -143,7 +146,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblAutoSave1.Dock = System.Windows.Forms.DockStyle.Top;
lblAutoSave1.Location = new System.Drawing.Point(3, 52);
lblAutoSave1.Name = "lblAutoSave1";
- lblAutoSave1.Size = new System.Drawing.Size(265, 26);
+ lblAutoSave1.Size = new System.Drawing.Size(268, 26);
lblAutoSave1.TabIndex = 0;
lblAutoSave1.Text = "Auto Save in Minutes (0 means disabled)";
lblAutoSave1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
@@ -151,7 +154,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
// numAutoSave
//
numAutoSave.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
- numAutoSave.Location = new System.Drawing.Point(274, 55);
+ numAutoSave.Location = new System.Drawing.Point(277, 55);
numAutoSave.Maximum = new decimal(new int[] { 9999, 0, 0, 0 });
numAutoSave.Name = "numAutoSave";
numAutoSave.Size = new System.Drawing.Size(53, 22);
@@ -164,9 +167,10 @@ namespace mRemoteNG.UI.Forms.OptionsPages
pnlConfirmCloseConnection.Controls.Add(radCloseWarnMultiple);
pnlConfirmCloseConnection.Controls.Add(radCloseWarnExit);
pnlConfirmCloseConnection.Controls.Add(radCloseWarnNever);
- pnlConfirmCloseConnection.Location = new System.Drawing.Point(3, 270);
+ pnlConfirmCloseConnection.Dock = System.Windows.Forms.DockStyle.Top;
+ pnlConfirmCloseConnection.Location = new System.Drawing.Point(0, 292);
pnlConfirmCloseConnection.Name = "pnlConfirmCloseConnection";
- pnlConfirmCloseConnection.Size = new System.Drawing.Size(604, 137);
+ pnlConfirmCloseConnection.Size = new System.Drawing.Size(610, 133);
pnlConfirmCloseConnection.TabIndex = 6;
//
// lblClosingConnections
@@ -231,7 +235,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkSaveConnectionsAfterEveryEdit._mice = MrngCheckBox.MouseState.OUT;
chkSaveConnectionsAfterEveryEdit.AutoSize = true;
chkSaveConnectionsAfterEveryEdit.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkSaveConnectionsAfterEveryEdit.Location = new System.Drawing.Point(3, 95);
+ chkSaveConnectionsAfterEveryEdit.Location = new System.Drawing.Point(6, 95);
chkSaveConnectionsAfterEveryEdit.Name = "chkSaveConnectionsAfterEveryEdit";
chkSaveConnectionsAfterEveryEdit.Size = new System.Drawing.Size(194, 17);
chkSaveConnectionsAfterEveryEdit.TabIndex = 7;
@@ -243,7 +247,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkUseFilterSearch._mice = MrngCheckBox.MouseState.OUT;
chkUseFilterSearch.AutoSize = true;
chkUseFilterSearch.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkUseFilterSearch.Location = new System.Drawing.Point(3, 118);
+ chkUseFilterSearch.Location = new System.Drawing.Point(6, 118);
chkUseFilterSearch.Name = "chkUseFilterSearch";
chkUseFilterSearch.Size = new System.Drawing.Size(230, 17);
chkUseFilterSearch.TabIndex = 8;
@@ -261,13 +265,14 @@ namespace mRemoteNG.UI.Forms.OptionsPages
tableLayoutPanel2.Controls.Add(lblAutoSave1, 0, 2);
tableLayoutPanel2.Controls.Add(lblRDPConTimeout, 0, 1);
tableLayoutPanel2.Controls.Add(numRDPConTimeout, 1, 1);
- tableLayoutPanel2.Location = new System.Drawing.Point(3, 185);
+ tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Top;
+ tableLayoutPanel2.Location = new System.Drawing.Point(0, 213);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 3;
tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel2.Size = new System.Drawing.Size(604, 79);
+ tableLayoutPanel2.Size = new System.Drawing.Size(610, 79);
tableLayoutPanel2.TabIndex = 9;
//
// chkPlaceSearchBarAboveConnectionTree
@@ -275,7 +280,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkPlaceSearchBarAboveConnectionTree._mice = MrngCheckBox.MouseState.OUT;
chkPlaceSearchBarAboveConnectionTree.AutoSize = true;
chkPlaceSearchBarAboveConnectionTree.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkPlaceSearchBarAboveConnectionTree.Location = new System.Drawing.Point(3, 141);
+ chkPlaceSearchBarAboveConnectionTree.Location = new System.Drawing.Point(6, 141);
chkPlaceSearchBarAboveConnectionTree.Name = "chkPlaceSearchBarAboveConnectionTree";
chkPlaceSearchBarAboveConnectionTree.Size = new System.Drawing.Size(226, 17);
chkPlaceSearchBarAboveConnectionTree.TabIndex = 8;
@@ -287,7 +292,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkConnectionTreeTrackActiveConnection._mice = MrngCheckBox.MouseState.OUT;
chkConnectionTreeTrackActiveConnection.AutoSize = true;
chkConnectionTreeTrackActiveConnection.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkConnectionTreeTrackActiveConnection.Location = new System.Drawing.Point(3, 49);
+ chkConnectionTreeTrackActiveConnection.Location = new System.Drawing.Point(6, 49);
chkConnectionTreeTrackActiveConnection.Name = "chkConnectionTreeTrackActiveConnection";
chkConnectionTreeTrackActiveConnection.Size = new System.Drawing.Size(262, 17);
chkConnectionTreeTrackActiveConnection.TabIndex = 10;
@@ -299,27 +304,50 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkDoNotTrimUsername._mice = MrngCheckBox.MouseState.OUT;
chkDoNotTrimUsername.AutoSize = true;
chkDoNotTrimUsername.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkDoNotTrimUsername.Location = new System.Drawing.Point(3, 165);
+ chkDoNotTrimUsername.Location = new System.Drawing.Point(6, 165);
chkDoNotTrimUsername.Name = "chkDoNotTrimUsername";
chkDoNotTrimUsername.Size = new System.Drawing.Size(143, 17);
chkDoNotTrimUsername.TabIndex = 11;
chkDoNotTrimUsername.Text = "Do not trim usernames";
chkDoNotTrimUsername.UseVisualStyleBackColor = true;
//
+ // pnlOptions
+ //
+ pnlOptions.Controls.Add(chkSingleClickOnConnectionOpensIt);
+ pnlOptions.Controls.Add(chkDoNotTrimUsername);
+ pnlOptions.Controls.Add(chkSingleClickOnOpenedConnectionSwitchesToIt);
+ pnlOptions.Controls.Add(chkConnectionTreeTrackActiveConnection);
+ pnlOptions.Controls.Add(chkHostnameLikeDisplayName);
+ pnlOptions.Controls.Add(chkSaveConnectionsAfterEveryEdit);
+ pnlOptions.Controls.Add(chkPlaceSearchBarAboveConnectionTree);
+ pnlOptions.Controls.Add(chkUseFilterSearch);
+ pnlOptions.Dock = System.Windows.Forms.DockStyle.Top;
+ pnlOptions.Location = new System.Drawing.Point(0, 30);
+ pnlOptions.Name = "pnlOptions";
+ pnlOptions.Size = new System.Drawing.Size(610, 183);
+ pnlOptions.TabIndex = 12;
+ //
+ // lblRegistrySettingsUsedInfo
+ //
+ lblRegistrySettingsUsedInfo.BackColor = System.Drawing.SystemColors.ControlLight;
+ lblRegistrySettingsUsedInfo.Dock = System.Windows.Forms.DockStyle.Top;
+ lblRegistrySettingsUsedInfo.ForeColor = System.Drawing.SystemColors.ControlText;
+ lblRegistrySettingsUsedInfo.Location = new System.Drawing.Point(0, 0);
+ lblRegistrySettingsUsedInfo.Name = "lblRegistrySettingsUsedInfo";
+ lblRegistrySettingsUsedInfo.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
+ lblRegistrySettingsUsedInfo.Size = new System.Drawing.Size(610, 30);
+ lblRegistrySettingsUsedInfo.TabIndex = 13;
+ lblRegistrySettingsUsedInfo.Text = "Some settings are configured by your Administrator. Please contact your administrator for more information.";
+ lblRegistrySettingsUsedInfo.Visible = false;
+ //
// ConnectionsPage
//
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- Controls.Add(chkDoNotTrimUsername);
- Controls.Add(chkConnectionTreeTrackActiveConnection);
- Controls.Add(tableLayoutPanel2);
- Controls.Add(chkPlaceSearchBarAboveConnectionTree);
- Controls.Add(chkUseFilterSearch);
- Controls.Add(chkSaveConnectionsAfterEveryEdit);
- Controls.Add(chkSingleClickOnConnectionOpensIt);
- Controls.Add(chkHostnameLikeDisplayName);
- Controls.Add(chkSingleClickOnOpenedConnectionSwitchesToIt);
Controls.Add(pnlConfirmCloseConnection);
+ Controls.Add(tableLayoutPanel2);
+ Controls.Add(pnlOptions);
+ Controls.Add(lblRegistrySettingsUsedInfo);
Name = "ConnectionsPage";
Size = new System.Drawing.Size(610, 490);
((System.ComponentModel.ISupportInitialize)numRDPConTimeout).EndInit();
@@ -328,8 +356,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages
pnlConfirmCloseConnection.ResumeLayout(false);
pnlConfirmCloseConnection.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
+ pnlOptions.ResumeLayout(false);
+ pnlOptions.PerformLayout();
ResumeLayout(false);
- PerformLayout();
}
internal Controls.MrngLabel lblRdpReconnectionCount;
@@ -353,5 +382,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
private MrngCheckBox chkPlaceSearchBarAboveConnectionTree;
private MrngCheckBox chkConnectionTreeTrackActiveConnection;
private MrngCheckBox chkDoNotTrimUsername;
+ internal System.Windows.Forms.Panel pnlOptions;
+ internal System.Windows.Forms.Label lblRegistrySettingsUsedInfo;
}
}
diff --git a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs
index 70c01b6d..85b54485 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.cs
@@ -1,24 +1,38 @@
-using mRemoteNG.Config;
-using System;
-using System.Collections.Generic;
+using System;
using mRemoteNG.Config.Connections;
using mRemoteNG.Properties;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
+using mRemoteNG.Config.Settings.Registry;
namespace mRemoteNG.UI.Forms.OptionsPages
{
[SupportedOSPlatform("windows")]
public sealed partial class ConnectionsPage
{
+ #region Private Fields
+ private OptRegistryConnectionsPage pageRegSettingsInstance;
private readonly FrmMain _frmMain = FrmMain.Default;
- private List _connectionWarning;
+
+ // never used, added: Jun 15, 2024
+ //private List _connectionWarning;
+
+ #endregion
public ConnectionsPage()
{
InitializeComponent();
ApplyTheme();
PageIcon = Resources.ImageConverter.GetImageAsIcon(Properties.Resources.ASPWebSite_16x);
+
+ /*
+ * Comments added: Jun 15, 2024
+ * These settings are not used on the settings page. It doesn't matter if they are set or not; nothing happens:
+ * 1) chkSaveConnectionsAfterEveryEdit: never used
+ * 2) pnlConfirmCloseConnection: seems to be unfinished. _connectionWarning or other corresponding settings are not available.
+ */
+ chkSaveConnectionsAfterEveryEdit.Visible = false; // Temporary hide control, never used, added: Jun 15, 2024
+ pnlConfirmCloseConnection.Visible = false; // Temporary hide control, never used, added: Jun 15, 2024
}
public override string PageName
@@ -31,13 +45,18 @@ namespace mRemoteNG.UI.Forms.OptionsPages
{
base.ApplyLanguage();
- _connectionWarning = new List
+ /*
+ * Comments added: Jun 15, 2024
+ *
+ * Seems to be unfinished or old
+ */
+ /*_connectionWarning = new List
{
{ new DropdownList((int)ConfirmCloseEnum.Never, Language.RadioCloseWarnMultiple)},
{ new DropdownList((int)ConfirmCloseEnum.Exit, Language.RadioCloseWarnExit)},
{ new DropdownList((int)ConfirmCloseEnum.Multiple, Language.RadioCloseWarnMultiple)},
{ new DropdownList((int)ConfirmCloseEnum.All, Language._CloseWarnAll)}
- };
+ };*/
//comboBoxConnectionWarning.DataSource = _connectionWarning;
//comboBoxConnectionWarning.DisplayMember = "DisplayString";
@@ -56,6 +75,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblAutoSave1.Text = Language.AutoSaveEvery;
//ngLabel1.Text = Language.strLabelClosingConnections;
+ lblRegistrySettingsUsedInfo.Text = Language.OptionsCompanyPolicyMessage;
}
public override void LoadSettings()
@@ -118,5 +138,67 @@ namespace mRemoteNG.UI.Forms.OptionsPages
//Settings.Default.ConfirmCloseConnection = (int)comboBoxConnectionWarning.SelectedValue;
}
+
+ public override void LoadRegistrySettings()
+ {
+ Type settingsType = typeof(OptRegistryConnectionsPage);
+ RegistryLoader.RegistrySettings.TryGetValue(settingsType, out var settings);
+ pageRegSettingsInstance = settings as OptRegistryConnectionsPage;
+
+ RegistryLoader.Cleanup(settingsType);
+
+ // ***
+ // Disable controls based on the registry settings.
+ //
+ if (pageRegSettingsInstance.SingleClickOnConnectionOpensIt.IsSet)
+ DisableControl(chkSingleClickOnConnectionOpensIt);
+
+ if (pageRegSettingsInstance.SingleClickSwitchesToOpenConnection.IsSet)
+ DisableControl(chkSingleClickOnOpenedConnectionSwitchesToIt);
+
+ if (pageRegSettingsInstance.TrackActiveConnectionInConnectionTree.IsSet)
+ DisableControl(chkConnectionTreeTrackActiveConnection);
+
+ if (pageRegSettingsInstance.SetHostnameLikeDisplayName.IsSet)
+ DisableControl(chkHostnameLikeDisplayName);
+
+ if (pageRegSettingsInstance.UseFilterSearch.IsSet)
+ DisableControl(chkUseFilterSearch);
+
+ if (pageRegSettingsInstance.PlaceSearchBarAboveConnectionTree.IsSet)
+ DisableControl(chkPlaceSearchBarAboveConnectionTree);
+
+ if (pageRegSettingsInstance.DoNotTrimUsername.IsSet)
+ DisableControl(chkDoNotTrimUsername);
+
+ if (pageRegSettingsInstance.RdpReconnectionCount.IsSet)
+ DisableControl(numRdpReconnectionCount);
+
+ if (pageRegSettingsInstance.ConRDPOverallConnectionTimeout.IsSet)
+ DisableControl(numRDPConTimeout);
+
+ if (pageRegSettingsInstance.AutoSaveEveryMinutes.IsSet)
+ DisableControl(numAutoSave);
+
+ // Updates the visibility of the information label indicating whether registry settings are used.
+ lblRegistrySettingsUsedInfo.Visible = ShowRegistrySettingsUsedInfo();
+ }
+
+ ///
+ /// Checks if specific registry settings related to appearence page are used.
+ ///
+ public bool ShowRegistrySettingsUsedInfo()
+ {
+ return pageRegSettingsInstance.SingleClickOnConnectionOpensIt.IsSet
+ || pageRegSettingsInstance.SingleClickSwitchesToOpenConnection.IsSet
+ || pageRegSettingsInstance.TrackActiveConnectionInConnectionTree.IsSet
+ || pageRegSettingsInstance.SetHostnameLikeDisplayName.IsSet
+ || pageRegSettingsInstance.UseFilterSearch.IsSet
+ || pageRegSettingsInstance.PlaceSearchBarAboveConnectionTree.IsSet
+ || pageRegSettingsInstance.DoNotTrimUsername.IsSet
+ || pageRegSettingsInstance.RdpReconnectionCount.IsSet
+ || pageRegSettingsInstance.ConRDPOverallConnectionTimeout.IsSet
+ || pageRegSettingsInstance.AutoSaveEveryMinutes.IsSet;
+ }
}
}
\ No newline at end of file
diff --git a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.resx b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.resx
index f298a7be..af32865e 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.resx
+++ b/mRemoteNG/UI/Forms/OptionsPages/ConnectionsPage.resx
@@ -1,4 +1,64 @@
-
+
+
+
diff --git a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.Designer.cs b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.Designer.cs
index d1571540..91187ff6 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.Designer.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.Designer.cs
@@ -1,6 +1,5 @@
-
-
-using mRemoteNG.UI.Controls;
+using mRemoteNG.UI.Controls;
+using System;
namespace mRemoteNG.UI.Forms.OptionsPages
{
@@ -37,9 +36,12 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblSQLReadOnly = new MrngLabel();
lblSQLType = new MrngLabel();
txtSQLType = new MrngComboBox();
- tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
+ pnlSQLCon = new System.Windows.Forms.TableLayoutPanel();
+ pnlOptions = new System.Windows.Forms.Panel();
+ lblRegistrySettingsUsedInfo = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)imgConnectionStatus).BeginInit();
- tableLayoutPanel1.SuspendLayout();
+ pnlSQLCon.SuspendLayout();
+ pnlOptions.SuspendLayout();
SuspendLayout();
//
// lblSQLDatabaseName
@@ -69,7 +71,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
chkUseSQLServer._mice = MrngCheckBox.MouseState.OUT;
chkUseSQLServer.AutoSize = true;
chkUseSQLServer.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
- chkUseSQLServer.Location = new System.Drawing.Point(9, 7);
+ chkUseSQLServer.Location = new System.Drawing.Point(3, 3);
chkUseSQLServer.Name = "chkUseSQLServer";
chkUseSQLServer.Size = new System.Drawing.Size(244, 17);
chkUseSQLServer.TabIndex = 2;
@@ -148,7 +150,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
//
btnTestConnection._mice = MrngButton.MouseState.OUT;
btnTestConnection.Enabled = false;
- btnTestConnection.Location = new System.Drawing.Point(9, 198);
+ btnTestConnection.Location = new System.Drawing.Point(3, 194);
btnTestConnection.Name = "btnTestConnection";
btnTestConnection.Size = new System.Drawing.Size(153, 25);
btnTestConnection.TabIndex = 11;
@@ -159,7 +161,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
// imgConnectionStatus
//
imgConnectionStatus.Image = Properties.Resources.F1Help_16x;
- imgConnectionStatus.Location = new System.Drawing.Point(169, 203);
+ imgConnectionStatus.Location = new System.Drawing.Point(163, 199);
imgConnectionStatus.Name = "imgConnectionStatus";
imgConnectionStatus.Size = new System.Drawing.Size(16, 16);
imgConnectionStatus.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
@@ -169,7 +171,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
// lblTestConnectionResults
//
lblTestConnectionResults.AutoSize = true;
- lblTestConnectionResults.Location = new System.Drawing.Point(9, 226);
+ lblTestConnectionResults.Location = new System.Drawing.Point(3, 222);
lblTestConnectionResults.Name = "lblTestConnectionResults";
lblTestConnectionResults.Size = new System.Drawing.Size(125, 13);
lblTestConnectionResults.TabIndex = 13;
@@ -214,6 +216,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
txtSQLType._mice = MrngComboBox.MouseState.HOVER;
txtSQLType.Dock = System.Windows.Forms.DockStyle.Fill;
txtSQLType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ txtSQLType.Enabled = false;
txtSQLType.FormattingEnabled = true;
txtSQLType.Items.AddRange(new object[] { "mssql", "mysql" });
txtSQLType.Location = new System.Drawing.Point(163, 3);
@@ -221,53 +224,78 @@ namespace mRemoteNG.UI.Forms.OptionsPages
txtSQLType.Size = new System.Drawing.Size(235, 21);
txtSQLType.TabIndex = 21;
//
- // tableLayoutPanel1
+ // pnlSQLCon
//
- tableLayoutPanel1.ColumnCount = 2;
- tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 160F));
- tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
- tableLayoutPanel1.Controls.Add(lblSQLType, 0, 0);
- tableLayoutPanel1.Controls.Add(txtSQLType, 1, 0);
- tableLayoutPanel1.Controls.Add(lblSQLServer, 0, 1);
- tableLayoutPanel1.Controls.Add(chkSQLReadOnly, 1, 5);
- tableLayoutPanel1.Controls.Add(lblSQLReadOnly, 0, 5);
- tableLayoutPanel1.Controls.Add(lblSQLDatabaseName, 0, 2);
- tableLayoutPanel1.Controls.Add(txtSQLDatabaseName, 1, 2);
- tableLayoutPanel1.Controls.Add(lblSQLUsername, 0, 3);
- tableLayoutPanel1.Controls.Add(lblSQLPassword, 0, 4);
- tableLayoutPanel1.Controls.Add(txtSQLServer, 1, 1);
- tableLayoutPanel1.Controls.Add(txtSQLPassword, 1, 4);
- tableLayoutPanel1.Controls.Add(txtSQLUsername, 1, 3);
- tableLayoutPanel1.Location = new System.Drawing.Point(9, 30);
- tableLayoutPanel1.Name = "tableLayoutPanel1";
- tableLayoutPanel1.RowCount = 7;
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
- tableLayoutPanel1.Size = new System.Drawing.Size(401, 162);
- tableLayoutPanel1.TabIndex = 22;
+ pnlSQLCon.ColumnCount = 2;
+ pnlSQLCon.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 160F));
+ pnlSQLCon.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ pnlSQLCon.Controls.Add(lblSQLType, 0, 0);
+ pnlSQLCon.Controls.Add(txtSQLType, 1, 0);
+ pnlSQLCon.Controls.Add(lblSQLServer, 0, 1);
+ pnlSQLCon.Controls.Add(chkSQLReadOnly, 1, 5);
+ pnlSQLCon.Controls.Add(lblSQLReadOnly, 0, 5);
+ pnlSQLCon.Controls.Add(lblSQLDatabaseName, 0, 2);
+ pnlSQLCon.Controls.Add(txtSQLDatabaseName, 1, 2);
+ pnlSQLCon.Controls.Add(lblSQLUsername, 0, 3);
+ pnlSQLCon.Controls.Add(lblSQLPassword, 0, 4);
+ pnlSQLCon.Controls.Add(txtSQLServer, 1, 1);
+ pnlSQLCon.Controls.Add(txtSQLPassword, 1, 4);
+ pnlSQLCon.Controls.Add(txtSQLUsername, 1, 3);
+ pnlSQLCon.Enabled = false;
+ pnlSQLCon.Location = new System.Drawing.Point(3, 26);
+ pnlSQLCon.Name = "pnlSQLCon";
+ pnlSQLCon.RowCount = 7;
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ pnlSQLCon.RowStyles.Add(new System.Windows.Forms.RowStyle());
+ pnlSQLCon.Size = new System.Drawing.Size(401, 162);
+ pnlSQLCon.TabIndex = 22;
+ //
+ // pnlOptions
+ //
+ pnlOptions.Controls.Add(chkUseSQLServer);
+ pnlOptions.Controls.Add(pnlSQLCon);
+ pnlOptions.Controls.Add(btnTestConnection);
+ pnlOptions.Controls.Add(lblTestConnectionResults);
+ pnlOptions.Controls.Add(imgConnectionStatus);
+ pnlOptions.Dock = System.Windows.Forms.DockStyle.Top;
+ pnlOptions.Location = new System.Drawing.Point(0, 30);
+ pnlOptions.Name = "pnlOptions";
+ pnlOptions.Size = new System.Drawing.Size(610, 329);
+ pnlOptions.TabIndex = 23;
+ //
+ // lblRegistrySettingsUsedInfo
+ //
+ lblRegistrySettingsUsedInfo.BackColor = System.Drawing.SystemColors.ControlLight;
+ lblRegistrySettingsUsedInfo.Dock = System.Windows.Forms.DockStyle.Top;
+ lblRegistrySettingsUsedInfo.ForeColor = System.Drawing.SystemColors.ControlText;
+ lblRegistrySettingsUsedInfo.Location = new System.Drawing.Point(0, 0);
+ lblRegistrySettingsUsedInfo.Name = "lblRegistrySettingsUsedInfo";
+ lblRegistrySettingsUsedInfo.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
+ lblRegistrySettingsUsedInfo.Size = new System.Drawing.Size(610, 30);
+ lblRegistrySettingsUsedInfo.TabIndex = 24;
+ lblRegistrySettingsUsedInfo.Text = "Some settings are configured by your Administrator. Please contact your administrator for more information.";
+ lblRegistrySettingsUsedInfo.Visible = false;
//
// SqlServerPage
//
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- Controls.Add(tableLayoutPanel1);
- Controls.Add(lblTestConnectionResults);
- Controls.Add(imgConnectionStatus);
- Controls.Add(btnTestConnection);
- Controls.Add(chkUseSQLServer);
+ Controls.Add(pnlOptions);
+ Controls.Add(lblRegistrySettingsUsedInfo);
Margin = new System.Windows.Forms.Padding(4);
Name = "SqlServerPage";
Size = new System.Drawing.Size(610, 490);
((System.ComponentModel.ISupportInitialize)imgConnectionStatus).EndInit();
- tableLayoutPanel1.ResumeLayout(false);
- tableLayoutPanel1.PerformLayout();
+ pnlSQLCon.ResumeLayout(false);
+ pnlSQLCon.PerformLayout();
+ pnlOptions.ResumeLayout(false);
+ pnlOptions.PerformLayout();
ResumeLayout(false);
- PerformLayout();
}
internal Controls.MrngLabel lblSQLDatabaseName;
@@ -286,6 +314,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
internal Controls.MrngLabel lblSQLReadOnly;
internal Controls.MrngLabel lblSQLType;
private MrngComboBox txtSQLType;
- private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
+ private System.Windows.Forms.TableLayoutPanel pnlSQLCon;
+ private System.Windows.Forms.Panel pnlOptions;
+ internal System.Windows.Forms.Label lblRegistrySettingsUsedInfo;
}
}
diff --git a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.cs b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.cs
index fa04075a..841260c9 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.cs
+++ b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.cs
@@ -6,13 +6,17 @@ using mRemoteNG.Properties;
using mRemoteNG.Security.SymmetricEncryption;
using mRemoteNG.Resources.Language;
using System.Runtime.Versioning;
+using mRemoteNG.Config.Settings.Registry;
namespace mRemoteNG.UI.Forms.OptionsPages
{
[SupportedOSPlatform("windows")]
public sealed partial class SqlServerPage
{
+ #region Private Fields
+ private OptRegistrySqlServerPage pageRegSettingsInstance;
private readonly DatabaseConnectionTester _databaseConnectionTester;
+ #endregion
public SqlServerPage()
{
@@ -42,6 +46,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
lblSQLPassword.Text = Language.Password;
lblSQLReadOnly.Text = Language.ReadOnly;
btnTestConnection.Text = Language.TestConnection;
+ lblRegistrySettingsUsedInfo.Text = Language.OptionsCompanyPolicyMessage;
}
public override void LoadSettings()
@@ -77,6 +82,48 @@ namespace mRemoteNG.UI.Forms.OptionsPages
DisableSql();
}
+ public override void LoadRegistrySettings()
+ {
+ Type settingsType = typeof(OptRegistrySqlServerPage);
+ RegistryLoader.RegistrySettings.TryGetValue(settingsType, out var settings);
+ pageRegSettingsInstance = settings as OptRegistrySqlServerPage;
+
+ RegistryLoader.Cleanup(settingsType);
+
+ // Skip validation of SQL Server registry settings if not set in the registry.
+ if (!pageRegSettingsInstance.UseSQLServer.IsSet)
+ return;
+
+ // Updates the visibility of the information label indicating whether registry settings are used.
+ lblRegistrySettingsUsedInfo.Visible = true;
+ DisableControl(chkUseSQLServer);
+
+ // End validation of SQL Server registry settings if UseSQLServer is false.
+ if (!Properties.OptionsDBsPage.Default.UseSQLServer)
+ return;
+
+ // ***
+ // Disable controls based on the registry settings.
+ //
+ if (pageRegSettingsInstance.SQLServerType.IsSet)
+ DisableControl(txtSQLType);
+
+ if (pageRegSettingsInstance.SQLHost.IsSet)
+ DisableControl(txtSQLServer);
+
+ if (pageRegSettingsInstance.SQLDatabaseName.IsSet)
+ DisableControl(txtSQLDatabaseName);
+
+ if (pageRegSettingsInstance.SQLUser.IsSet)
+ DisableControl(txtSQLUsername);
+
+ if (pageRegSettingsInstance.SQLPassword.IsSet)
+ DisableControl(txtSQLPassword);
+
+ if (pageRegSettingsInstance.SQLReadOnly.IsSet)
+ DisableControl(chkSQLReadOnly);
+ }
+
private static void ReinitializeSqlUpdater()
{
Runtime.ConnectionsService.RemoteConnectionsSyncronizer?.Dispose();
@@ -96,8 +143,17 @@ namespace mRemoteNG.UI.Forms.OptionsPages
toggleSQLPageControls(chkUseSQLServer.Checked);
}
+ ///
+ /// Enable or disable SQL connection page controls based on SQL server settings availability.
+ /// Controls are enabled if corresponding registry settings are not set, allowing user interaction
+ /// when SQL server usage is enabled.
+ ///
+ /// Flag indicating whether SQL server functionality is enabled.
private void toggleSQLPageControls(bool useSQLServer)
{
+ if (!chkUseSQLServer.Enabled) return;
+
+ pnlSQLCon.Enabled = useSQLServer;
lblSQLType.Enabled = useSQLServer;
lblSQLServer.Enabled = useSQLServer;
lblSQLDatabaseName.Enabled = useSQLServer;
@@ -111,7 +167,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
txtSQLPassword.Enabled = useSQLServer;
chkSQLReadOnly.Enabled = useSQLServer;
btnTestConnection.Enabled = useSQLServer;
- }
+ }
private async void btnTestConnection_Click(object sender, EventArgs e)
{
diff --git a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.resx b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.resx
index f298a7be..af32865e 100644
--- a/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.resx
+++ b/mRemoteNG/UI/Forms/OptionsPages/SqlServerPage.resx
@@ -1,4 +1,64 @@
-
+
+
+
diff --git a/mRemoteNGDocumentation/registry/connection_settings.rst b/mRemoteNGDocumentation/registry/connection_settings.rst
new file mode 100644
index 00000000..68be2f37
--- /dev/null
+++ b/mRemoteNGDocumentation/registry/connection_settings.rst
@@ -0,0 +1,167 @@
+*******************
+Connection Settings
+*******************
+.. versionadded:: v1.77.3
+
+.. warning::
+ Before proceeding with any changes to the Windows Registry, it is imperative that you carefully read and comprehend the
+ **Modifying the Registry**, **Restricted Registry Settings** and **Disclaimer**
+ on :doc:`Registry Settings Infromation `.
+
+
+Options
+=======
+Configure the options page to modify functionalities as described.
+
+- **Registry Hive:** ``HKEY_LOCAL_MACHINE``
+- **Registry Path:** ``SOFTWARE\mRemoteNG\Connections\Options``
+
+Single Click On Connection To Open
+----------------------------------
+Specifies whether to single click to connection opens/establishes connection
+
+- **Value Name:** ``SingleClickOnConnectionOpensIt``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Single Click Switches To Open Connection
+----------------------------------------
+Specifies whether a single click on an open connection switches the focused tab to that connection.
+
+- **Value Name:** ``SingleClickSwitchesToOpenConnection``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Track Active Connection In Connection Tree
+------------------------------------------
+This specifies whether to track open connections in the connection tree.
+When switching to an active connection, the focus in the tree view will also switch through the connection.
+
+- **Value Name:** ``TrackActiveConnectionInConnectionTree``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Set Hostname Like Display Name
+------------------------------
+Specifies whether to set the hostname like the display name when creating or renaming a connection.
+
+- **Value Name:** ``SetHostnameLikeDisplayName``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Use Filter Search
+-----------------
+Specifies whether filters applied in the search are reflected in the connection tree.
+This determines whether the filter hides connections that do not match (value true) or only highlights those that do match (value false).
+
+- **Value Name:** ``UseFilterSearch``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Place Search Bar Above Connection Tree
+--------------------------------------
+Specifies whether the search bar is placed above the connection tree.
+
+- **Value Name:** ``PlaceSearchBarAboveConnectionTree``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Do Not Trim Username
+--------------------
+Specifies whether username trimming is enabled or disabled.
+If ``true``, spaces at the beginning or end of a username will be trimmed.
+If ``false``, spaces will not be trimmed.
+
+- **Value Name:** ``DoNotTrimUsername``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Trim: ``false``
+ - Don't Trim: ``true``
+
+
+RDP Reconnection Count
+----------------------
+Specifies the number of attempts for RDP reconnections.
+
+- **Value Name:** ``RdpReconnectionCount``
+- **Value Type:** ``REG_DWORD``
+- **Values:**
+
+ - Minimum: ``0``
+ - Maximum: ``20``
+
+
+RDP Overall Connection Timeout
+------------------------------
+Specifies the overall connection timeout for RDP connections.
+
+- **Value Name:** ``ConRDPOverallConnectionTimeout``
+- **Value Type:** ``REG_DWORD``
+- **Values:**
+
+ - Minimum: ``20``
+ - Maximum: ``600``
+
+
+Auto Save Intervall
+-------------------
+Specifies the autosave interval in minutes.
+
+- **Value Name:** ``AutoSaveEveryMinutes``
+- **Value Type:** ``REG_DWORD``
+- **Values:**
+
+ - Minimum: ``0``
+ - Maximum: ``9999``
+
+
+.. note::
+ To disable autosave, set *AutoSaveEveryMinutes* to ``0``.
+
+
+Registry Template
+=================
+
+.. code::
+
+ Windows Registry Editor Version 5.00
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\mRemoteNG\Connections]
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\mRemoteNG\Connections\Options]
+ "SingleClickOnConnectionOpensIt"="true"
+ "SingleClickSwitchesToOpenConnection"="true"
+ "TrackActiveConnectionInConnectionTree"="false"
+ "SetHostnameLikeDisplayName"="true"
+ "UseFilterSearch"="false"
+ "PlaceSearchBarAboveConnectionTree"="false"
+ "DoNotTrimUsername"="true"
+ "AutoSaveEveryMinutes"=dword:00000010
+ "ConRDPOverallConnectionTimeout"=dword:0000012c
+ "RdpReconnectionCount"=dword:0000000a
+
diff --git a/mRemoteNGDocumentation/registry/sqlServer_settings.rst b/mRemoteNGDocumentation/registry/sqlServer_settings.rst
new file mode 100644
index 00000000..860f9c0a
--- /dev/null
+++ b/mRemoteNGDocumentation/registry/sqlServer_settings.rst
@@ -0,0 +1,106 @@
+*******************
+SQL Server Settings
+*******************
+
+.. warning::
+ Before proceeding with any changes to the Windows Registry, it is imperative that you carefully read and comprehend the
+ **Modifying the Registry**, **Restricted Registry Settings** and **Disclaimer**
+ on :doc:`Registry Settings Infromation `.
+
+
+Options
+=======
+Configure the options page to modify functionalities as described.
+
+- **Registry Hive:** ``HKEY_LOCAL_MACHINE``
+- **Registry Path:** ``SOFTWARE\mRemoteNG\SQLServer\Options``
+
+Use SQL Server
+--------------
+Specifies whether SQL Server is being used.
+
+- **Value Name:** ``UseSQLServer``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+SQL Server Type
+---------------
+Specifies the type of SQL Server being used.
+
+- **Value Name:** ``SQLServerType``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - ``mssql``
+ - ``mysql``
+
+
+SQL Host
+--------
+Specifies the hostname/IP/FQDN of the SQL Server.
+
+- **Value Name:** ``SQLHost``
+- **Value Type:** ``REG_SZ``
+
+
+SQL Database Name
+-----------------
+Specifies the name/instance of the SQL database.
+
+- **Value Name:** ``SQLDatabaseName``
+- **Value Type:** ``REG_SZ``
+
+
+SQL User
+--------
+Specifies the username for accessing the SQL Server.
+
+- **Value Name:** ``SQLUser``
+- **Value Type:** ``REG_SZ``
+
+
+SQL User Password
+-----------------
+Specifies the password for accessing the SQL Server.
+
+- **Value Name:** ``SQLPassword``
+- **Value Type:** ``REG_SZ``
+
+
+.. warning::
+ Plain-text passwords are not supported.
+
+
+SQL Read Only
+-------------
+Specifies whether the SQL connection is read-only.
+
+- **Value Name:** ``SQLReadOnly``
+- **Value Type:** ``REG_SZ``
+- **Values:**
+
+ - Enable: ``true``
+ - Disable: ``false``
+
+
+Registry Template
+=================
+
+.. code::
+
+ Windows Registry Editor Version 5.00
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\mRemoteNG\SQLServer]
+
+ [HKEY_LOCAL_MACHINE\SOFTWARE\mRemoteNG\SQLServer\Options]
+ "UseSQLServer"="false"
+ "SQLDatabaseName"=""
+ "SQLReadOnly"="true"
+ "SQLUser_"=""
+ "SQLServerType_"="MSSQL"
+ "SQLHost_"=""
+
diff --git a/mRemoteNGDocumentation/registry_settings_guide.rst b/mRemoteNGDocumentation/registry_settings_guide.rst
index ee23585d..dd92db66 100644
--- a/mRemoteNGDocumentation/registry_settings_guide.rst
+++ b/mRemoteNGDocumentation/registry_settings_guide.rst
@@ -24,7 +24,9 @@ Make changes with caution and ensure that you have backups before making any adj
registry/startupExit_settings.rst
registry/appearance_settings.rst
+ registry/connection_settings.rst
registry/tabsPanels_settings.rst
registry/notification_settings.rst
registry/credential_settings.rst
+ registry/sqlServer_settings.rst
registry/updates_settings.rst
\ No newline at end of file