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
This commit is contained in:
xRushG
2024-10-01 12:35:34 +02:00
parent 489602ffb3
commit d018fdbace
11 changed files with 1009 additions and 83 deletions

View File

@@ -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
{
/// <summary>
/// Specifies whether to single click to connection opens/establishes connection
/// </summary>
public WinRegistryEntry<bool> SingleClickOnConnectionOpensIt { get; private set; }
/// <summary>
/// Specifies whether a single click on an open connection switches the focused tab to that connection.
/// </summary>
public WinRegistryEntry<bool> SingleClickSwitchesToOpenConnection { get; private set; }
/// <summary>
/// Specifies whether to track open connections in the connection tree.
/// </summary>
public WinRegistryEntry<bool> TrackActiveConnectionInConnectionTree { get; private set; }
/// <summary>
/// Specifies whether to set the hostname like the display name when creating or renaming a connection.
/// </summary>
public WinRegistryEntry<bool> SetHostnameLikeDisplayName { get; private set; }
/// <summary>
/// Specifies whether filter matches in the search are applied in the connection tree.
/// </summary>
public WinRegistryEntry<bool> UseFilterSearch { get; private set; }
/// <summary>
/// Specifies whether the search bar is placed above the connection tree.
/// </summary>
public WinRegistryEntry<bool> PlaceSearchBarAboveConnectionTree { get; private set; }
/// <summary>
/// Specifies whether the username trimming is disabled.
/// </summary>
public WinRegistryEntry<bool> DoNotTrimUsername { get; private set; }
/// <summary>
/// Specifies the number of RDP reconnections.
/// </summary>
public WinRegistryEntry<int> RdpReconnectionCount { get; private set; }
/// <summary>
/// Specifies the overall connection timeout for RDP connections.
/// </summary>
public WinRegistryEntry<int> ConRDPOverallConnectionTimeout { get; private set; }
/// <summary>
/// Specifies the autosave interval in minutes.
/// </summary>
public WinRegistryEntry<int> AutoSaveEveryMinutes { get; private set; }
public OptRegistryConnectionsPage()
{
RegistryHive hive = WindowsRegistryInfo.Hive;
string subKey = WindowsRegistryInfo.ConnectionOptions;
SingleClickOnConnectionOpensIt = new WinRegistryEntry<bool>(hive, subKey, nameof(SingleClickOnConnectionOpensIt)).Read();
SingleClickSwitchesToOpenConnection = new WinRegistryEntry<bool>(hive, subKey, nameof(SingleClickSwitchesToOpenConnection)).Read();
TrackActiveConnectionInConnectionTree = new WinRegistryEntry<bool>(hive, subKey, nameof(TrackActiveConnectionInConnectionTree)).Read();
SetHostnameLikeDisplayName = new WinRegistryEntry<bool>(hive, subKey, nameof(SetHostnameLikeDisplayName)).Read();
UseFilterSearch = new WinRegistryEntry<bool>(hive, subKey, nameof(UseFilterSearch)).Read();
PlaceSearchBarAboveConnectionTree = new WinRegistryEntry<bool>(hive, subKey, nameof(PlaceSearchBarAboveConnectionTree)).Read();
DoNotTrimUsername = new WinRegistryEntry<bool>(hive, subKey, nameof(DoNotTrimUsername)).Read();
RdpReconnectionCount = new WinRegistryEntry<int>(hive, subKey, nameof(RdpReconnectionCount)).Read();
ConRDPOverallConnectionTimeout = new WinRegistryEntry<int>(hive, subKey, nameof(ConRDPOverallConnectionTimeout)).Read();
AutoSaveEveryMinutes = new WinRegistryEntry<int>(hive, subKey, nameof(AutoSaveEveryMinutes)).Read();
SetupValidation();
Apply();
}
/// <summary>
/// Configures validation settings for various parameters
/// </summary>
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);
}
/// <summary>
/// Applies registry settings and overrides various properties.
/// </summary>
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;
}
}
}

View File

@@ -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
{
/// <summary>
/// Specifies whether SQL Server is being used.
/// </summary>
public WinRegistryEntry<bool> UseSQLServer { get; private set; }
/// <summary>
/// Specifies the type of SQL Server being used.
/// </summary>
public WinRegistryEntry<string> SQLServerType { get; private set; }
/// <summary>
/// Specifies the host of the SQL Server.
/// </summary>
public WinRegistryEntry<string> SQLHost { get; private set; }
/// <summary>
/// Specifies the name/instance of the SQL database.
/// </summary>
public WinRegistryEntry<string> SQLDatabaseName { get; private set; }
/// <summary>
/// Specifies the username for accessing the SQL Server.
/// </summary>
public WinRegistryEntry<string> SQLUser { get; private set; }
/// <summary>
/// Specifies the password for accessing the SQL Server.
/// </summary>
public WinRegistryEntry<string> SQLPassword { get; private set; }
/// <summary>
/// Specifies whether the SQL connection is read-only.
/// </summary>
public WinRegistryEntry<bool> SQLReadOnly { get; private set; }
public OptRegistrySqlServerPage()
{
RegistryHive hive = WindowsRegistryInfo.Hive;
string subKey = WindowsRegistryInfo.SQLServerOptions;
UseSQLServer = new WinRegistryEntry<bool>(hive, subKey, nameof(UseSQLServer)).Read();
SQLServerType = new WinRegistryEntry<string>(hive, subKey, nameof(SQLServerType)).Read();
SQLHost = new WinRegistryEntry<string>(hive, subKey, nameof(SQLHost)).Read();
SQLDatabaseName = new WinRegistryEntry<string>(hive, subKey, nameof(SQLDatabaseName)).Read();
SQLUser = new WinRegistryEntry<string>(hive, subKey, nameof(SQLUser)).Read();
SQLPassword = new WinRegistryEntry<string>(hive, subKey, nameof(SQLPassword)).Read();
SQLReadOnly = new WinRegistryEntry<bool>(hive, subKey, nameof(SQLReadOnly)).Read();
SetupValidation();
Apply();
}
/// <summary>
/// Configures validation settings for various parameters
/// </summary>
private void SetupValidation()
{
SQLServerType.SetValidation(
new string[] {
"mssql",
"mysql"
});
}
/// <summary>
/// Applies registry settings and overrides various properties.
/// </summary>
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;
}
}
}

View File

@@ -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;
}
}

View File

@@ -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<DropdownList> _connectionWarning;
// never used, added: Jun 15, 2024
//private List<DropdownList> _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<DropdownList>
/*
* Comments added: Jun 15, 2024
*
* Seems to be unfinished or old
*/
/*_connectionWarning = new List<DropdownList>
{
{ 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();
}
/// <summary>
/// Checks if specific registry settings related to appearence page are used.
/// </summary>
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;
}
}
}

View File

@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@@ -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;
}
}

View File

@@ -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);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="useSQLServer">Flag indicating whether SQL server functionality is enabled.</param>
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)
{

View File

@@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

View File

@@ -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 <registry_settings_information>`.
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

View File

@@ -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 <registry_settings_information>`.
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_"=""

View File

@@ -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