mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Add capability to set Update Settings via Registry
This commit enhances the functionality of the WindowsRegistryAdvanced class to provide the capability to set up Update Settings through the Windows Registry. The changes include the addition of methods or modifications that allow users to configure update-related settings using the Registry.
This commit is contained in:
21
mRemoteNG/App/Info/WindowsRegistryInfo.cs
Normal file
21
mRemoteNG/App/Info/WindowsRegistryInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace mRemoteNG.App.Info
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
public static class WindowsRegistryInfo
|
||||
{
|
||||
#region general parameters
|
||||
public const RegistryHive Hive = RegistryHive.LocalMachine;
|
||||
public const string RootKey = "SOFTWARE\\mRemoteNG";
|
||||
#endregion
|
||||
|
||||
#region subkey location parameters
|
||||
|
||||
// Updates
|
||||
public const string UpdateSubkey = RootKey + "\\Updates"; // Registry subkey for general update settings
|
||||
public const string UpdateOptionsSubkey = RootKey + "\\Updates\\Options"; // Registry subkey for update options within the update settings
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
62
mRemoteNG/Config/Settings/Registry/CommonRegistrySettings.cs
Normal file
62
mRemoteNG/Config/Settings/Registry/CommonRegistrySettings.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Tools.WindowsRegistry;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Registry
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
/// Static utility class that provides access to and management of registry settings on the local machine.
|
||||
/// It abstracts complex registry operations and centralizes the handling of various registry keys.
|
||||
/// Benefits: Simplified code, enhances maintainability, and ensures consistency. #ReadOnly
|
||||
public static class CommonRegistrySettings
|
||||
{
|
||||
private static readonly IRegistryAdvancedRead _WindowsRegistry = new WindowsRegistryAdvanced();
|
||||
private static readonly RegistryHive _Hive = WindowsRegistryInfo.Hive;
|
||||
|
||||
private const string __Update = WindowsRegistryInfo.UpdateSubkey;
|
||||
private const string __Credential = WindowsRegistryInfo.CredentialSubkey;
|
||||
|
||||
#region general update registry settings
|
||||
/// <summary>
|
||||
/// Indicates whether searching for updates is allowed. If false, there is no way to update directly from mRemoteNG.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is true, which allows check for updates.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdates { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdates), true);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether automatic search for updates is allowed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Default value is true, which allows check for updates automaticaly.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// Important: If AllowCheckForUpdates is false, the default for this value (AllowCheckForUpdatesAutomatical) is also false, manual update checks are disabled.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdatesAutomatical { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdatesAutomatical), AllowCheckForUpdates);
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether a manual search for updates is allowed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The default value is true, enabling the manual check for updates.
|
||||
/// If the registry key is set to true, no action will be taken because the key is not needed.
|
||||
/// Important: If AllowCheckForUpdates is false, the default for this value (AllowCheckForUpdatesManual) is also false, manual update checks are disabled.
|
||||
/// </remarks>
|
||||
public static bool AllowCheckForUpdatesManual { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(AllowCheckForUpdatesManual), AllowCheckForUpdates);
|
||||
|
||||
/// <summary>
|
||||
/// Specifies whether a question about checking for updates is displayed at startup.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Important: If the registry entry is set to true, a popup will appear every time you start
|
||||
/// </remarks>
|
||||
public static bool CheckForUpdatesAsked { get; } = _WindowsRegistry.GetBoolValue(_Hive, __Update, nameof(CheckForUpdatesAsked));
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
86
mRemoteNG/Config/Settings/Registry/OptRegistryUpdatesPage.cs
Normal file
86
mRemoteNG/Config/Settings/Registry/OptRegistryUpdatesPage.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Runtime.Versioning;
|
||||
using Microsoft.Win32;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Tools.WindowsRegistry;
|
||||
|
||||
namespace mRemoteNG.Config.Settings.Registry
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
/// Static utility class that provides access to and management of registry settings on the local machine.
|
||||
/// It abstracts complex registry operations and centralizes the handling of various registry keys.
|
||||
/// Benefits: Simplified code, enhances maintainability, and ensures consistency. #ReadOnly
|
||||
public sealed partial class OptRegistryUpdatesPage : WindowsRegistryAdvanced
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies the number of days between update checks.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyInteger CheckForUpdatesFrequencyDays { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the update channel for updates.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The update channel should be one of the predefined values: Stable, Preview, Nightly.
|
||||
/// </remarks>
|
||||
public WindowsRegistryKeyString UpdateChannel { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether proxy usage for updates is enabled.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyBoolean UseProxyForUpdates { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the proxy address for updates.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyString ProxyAddress { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the proxy port for updates.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyInteger ProxyPort { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether proxy authentication is enabled.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyBoolean UseProxyAuthentication { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the authentication username for the proxy.
|
||||
/// </summary>
|
||||
public WindowsRegistryKeyString ProxyAuthUser { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the authentication password for the proxy.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Please only store encrypted passwords in the registry by using the password generator on the 'Credentials' options page.
|
||||
/// </remarks>
|
||||
public string ProxyAuthPass { get; }
|
||||
|
||||
public OptRegistryUpdatesPage()
|
||||
{
|
||||
RegistryHive hive = WindowsRegistryInfo.Hive;
|
||||
string subKey = WindowsRegistryInfo.UpdateOptionsSubkey;
|
||||
|
||||
CheckForUpdatesFrequencyDays = GetInteger(hive, subKey, nameof(CheckForUpdatesFrequencyDays));
|
||||
|
||||
UpdateChannel = GetStringValidated(hive, subKey, nameof(UpdateChannel),
|
||||
new string[] {
|
||||
UpdateChannelInfo.STABLE,
|
||||
UpdateChannelInfo.PREVIEW,
|
||||
UpdateChannelInfo.NIGHTLY
|
||||
}
|
||||
,true
|
||||
);
|
||||
|
||||
UseProxyForUpdates = GetBoolean(hive, subKey, nameof(UseProxyForUpdates));
|
||||
ProxyAddress = GetString(hive, subKey, nameof(ProxyAddress), null);
|
||||
ProxyPort = GetInteger(hive, subKey, nameof(ProxyPort));
|
||||
|
||||
UseProxyAuthentication = GetBoolean(hive, subKey, nameof(UseProxyAuthentication));
|
||||
ProxyAuthUser = GetString(hive, subKey, nameof(ProxyAuthUser), null);
|
||||
//Currently not supported:
|
||||
//ProxyAuthPass = GetPassword(Hive, _SubKey, nameof(ProxyAuthPass));
|
||||
}
|
||||
}
|
||||
}
|
||||
9
mRemoteNG/Language/Language.Designer.cs
generated
9
mRemoteNG/Language/Language.Designer.cs
generated
@@ -3387,6 +3387,15 @@ namespace mRemoteNG.Resources.Language {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to *Some settings are determined by your company. For further information, please contact your administrator.
|
||||
/// </summary>
|
||||
internal static string OptionsAdminInfo {
|
||||
get {
|
||||
return ResourceManager.GetString("OptionsAdminInfo", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to mRemoteNG Options.
|
||||
/// </summary>
|
||||
|
||||
@@ -2047,4 +2047,7 @@ Nightly umfasst Alphas, Betas und Release Candidates.</value>
|
||||
<value>Maximale Anmeldeversuche erreicht. Verbindung erneut initiieren.</value>
|
||||
<comment>C# to Powershell transfer issue with encoding possible</comment>
|
||||
</data>
|
||||
<data name="OptionsAdminInfo" xml:space="preserve">
|
||||
<value>*Einige Einstellungen werden von Ihrem Unternehmen festgelegt. Für weitere Informationen wenden Sie sich an Ihren Systemadministrator.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -2362,4 +2362,7 @@ Nightly Channel includes Alphas, Betas & Release Candidates.</value>
|
||||
<data name="FilterSecureCRT" xml:space="preserve">
|
||||
<value>SecureCRT (*.xml)</value>
|
||||
</data>
|
||||
<data name="OptionsAdminInfo" xml:space="preserve">
|
||||
<value>*Some settings are determined by your company. For further information, please contact your administrator</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -42,6 +42,16 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
public virtual void RevertSettings()
|
||||
{
|
||||
}
|
||||
public virtual void LoadRegistrySettings()
|
||||
{
|
||||
}
|
||||
public virtual bool ShowAdministratorInfo()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual void DisablePage()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -65,6 +75,27 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
Name = "OptionsPage";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disables the specified control by setting its Enabled property to false.
|
||||
/// For TextBox controls, additionally sets the ReadOnly property based on the Enabled state.
|
||||
/// Does nothing if the control is null.
|
||||
/// </summary>
|
||||
/// <param name="control">The control to be disabled.</param>
|
||||
protected static void DisableControl(Control control)
|
||||
{
|
||||
if (control == null) return;
|
||||
|
||||
control.Enabled = false;
|
||||
|
||||
if (control is TextBox)
|
||||
{
|
||||
// If it's a TextBox, set the ReadOnly property
|
||||
((TextBox)control).ReadOnly = control.Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
internal class DropdownList
|
||||
{
|
||||
|
||||
@@ -35,9 +35,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
lblUpdatesExplanation = new MrngLabel();
|
||||
pnlUpdateCheck = new System.Windows.Forms.Panel();
|
||||
cboUpdateCheckFrequency = new MrngComboBox();
|
||||
btnUpdateCheckNow = new MrngButton();
|
||||
chkCheckForUpdatesOnStartup = new MrngCheckBox();
|
||||
cboUpdateCheckFrequency = new MrngComboBox();
|
||||
lblReleaseChannelExplanation = new MrngTextBox();
|
||||
cboReleaseChannel = new MrngComboBox();
|
||||
pnlProxy = new System.Windows.Forms.Panel();
|
||||
@@ -55,36 +55,53 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
chkUseProxyAuthentication = new MrngCheckBox();
|
||||
btnTestProxy = new MrngButton();
|
||||
groupBoxReleaseChannel = new MrngGroupBox();
|
||||
pnlDefaultUpdate = new System.Windows.Forms.Panel();
|
||||
lblUpdateAdminInfo = new System.Windows.Forms.Label();
|
||||
pnlUpdateCheck.SuspendLayout();
|
||||
pnlProxy.SuspendLayout();
|
||||
tblProxyBasic.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numProxyPort).BeginInit();
|
||||
tblProxyAuthentication.SuspendLayout();
|
||||
groupBoxReleaseChannel.SuspendLayout();
|
||||
pnlDefaultUpdate.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// lblUpdatesExplanation
|
||||
//
|
||||
lblUpdatesExplanation.Location = new System.Drawing.Point(3, 3);
|
||||
lblUpdatesExplanation.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
lblUpdatesExplanation.Location = new System.Drawing.Point(0, 0);
|
||||
lblUpdatesExplanation.Name = "lblUpdatesExplanation";
|
||||
lblUpdatesExplanation.Size = new System.Drawing.Size(595, 32);
|
||||
lblUpdatesExplanation.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
lblUpdatesExplanation.Size = new System.Drawing.Size(610, 38);
|
||||
lblUpdatesExplanation.TabIndex = 0;
|
||||
lblUpdatesExplanation.Text = "mRemoteNG can periodically connect to the mRemoteNG website to check for updates.";
|
||||
//
|
||||
// pnlUpdateCheck
|
||||
//
|
||||
pnlUpdateCheck.Controls.Add(cboUpdateCheckFrequency);
|
||||
pnlUpdateCheck.Controls.Add(btnUpdateCheckNow);
|
||||
pnlUpdateCheck.Controls.Add(chkCheckForUpdatesOnStartup);
|
||||
pnlUpdateCheck.Controls.Add(cboUpdateCheckFrequency);
|
||||
pnlUpdateCheck.Location = new System.Drawing.Point(3, 25);
|
||||
pnlUpdateCheck.Controls.Add(lblUpdatesExplanation);
|
||||
pnlUpdateCheck.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
pnlUpdateCheck.Location = new System.Drawing.Point(0, 30);
|
||||
pnlUpdateCheck.Name = "pnlUpdateCheck";
|
||||
pnlUpdateCheck.Size = new System.Drawing.Size(604, 99);
|
||||
pnlUpdateCheck.TabIndex = 1;
|
||||
pnlUpdateCheck.Size = new System.Drawing.Size(610, 114);
|
||||
pnlUpdateCheck.TabIndex = 0;
|
||||
//
|
||||
// cboUpdateCheckFrequency
|
||||
//
|
||||
cboUpdateCheckFrequency._mice = MrngComboBox.MouseState.HOVER;
|
||||
cboUpdateCheckFrequency.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
cboUpdateCheckFrequency.FormattingEnabled = true;
|
||||
cboUpdateCheckFrequency.Location = new System.Drawing.Point(27, 44);
|
||||
cboUpdateCheckFrequency.Name = "cboUpdateCheckFrequency";
|
||||
cboUpdateCheckFrequency.Size = new System.Drawing.Size(120, 21);
|
||||
cboUpdateCheckFrequency.TabIndex = 1;
|
||||
//
|
||||
// btnUpdateCheckNow
|
||||
//
|
||||
btnUpdateCheckNow._mice = MrngButton.MouseState.OUT;
|
||||
btnUpdateCheckNow.Location = new System.Drawing.Point(5, 63);
|
||||
btnUpdateCheckNow.Location = new System.Drawing.Point(5, 79);
|
||||
btnUpdateCheckNow.Name = "btnUpdateCheckNow";
|
||||
btnUpdateCheckNow.Size = new System.Drawing.Size(122, 25);
|
||||
btnUpdateCheckNow.TabIndex = 2;
|
||||
@@ -97,7 +114,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
chkCheckForUpdatesOnStartup._mice = MrngCheckBox.MouseState.OUT;
|
||||
chkCheckForUpdatesOnStartup.AutoSize = true;
|
||||
chkCheckForUpdatesOnStartup.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
chkCheckForUpdatesOnStartup.Location = new System.Drawing.Point(6, 11);
|
||||
chkCheckForUpdatesOnStartup.Location = new System.Drawing.Point(9, 21);
|
||||
chkCheckForUpdatesOnStartup.Name = "chkCheckForUpdatesOnStartup";
|
||||
chkCheckForUpdatesOnStartup.Size = new System.Drawing.Size(120, 17);
|
||||
chkCheckForUpdatesOnStartup.TabIndex = 0;
|
||||
@@ -105,16 +122,6 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
chkCheckForUpdatesOnStartup.UseVisualStyleBackColor = true;
|
||||
chkCheckForUpdatesOnStartup.CheckedChanged += chkCheckForUpdatesOnStartup_CheckedChanged;
|
||||
//
|
||||
// cboUpdateCheckFrequency
|
||||
//
|
||||
cboUpdateCheckFrequency._mice = MrngComboBox.MouseState.HOVER;
|
||||
cboUpdateCheckFrequency.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
cboUpdateCheckFrequency.FormattingEnabled = true;
|
||||
cboUpdateCheckFrequency.Location = new System.Drawing.Point(6, 34);
|
||||
cboUpdateCheckFrequency.Name = "cboUpdateCheckFrequency";
|
||||
cboUpdateCheckFrequency.Size = new System.Drawing.Size(120, 21);
|
||||
cboUpdateCheckFrequency.TabIndex = 1;
|
||||
//
|
||||
// lblReleaseChannelExplanation
|
||||
//
|
||||
lblReleaseChannelExplanation.BackColor = System.Drawing.SystemColors.Control;
|
||||
@@ -145,9 +152,10 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
pnlProxy.Controls.Add(chkUseProxyForAutomaticUpdates);
|
||||
pnlProxy.Controls.Add(chkUseProxyAuthentication);
|
||||
pnlProxy.Controls.Add(btnTestProxy);
|
||||
pnlProxy.Location = new System.Drawing.Point(3, 240);
|
||||
pnlProxy.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
pnlProxy.Location = new System.Drawing.Point(0, 248);
|
||||
pnlProxy.Name = "pnlProxy";
|
||||
pnlProxy.Size = new System.Drawing.Size(604, 223);
|
||||
pnlProxy.Size = new System.Drawing.Size(610, 232);
|
||||
pnlProxy.TabIndex = 3;
|
||||
//
|
||||
// tblProxyBasic
|
||||
@@ -311,24 +319,47 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
//
|
||||
groupBoxReleaseChannel.Controls.Add(lblReleaseChannelExplanation);
|
||||
groupBoxReleaseChannel.Controls.Add(cboReleaseChannel);
|
||||
groupBoxReleaseChannel.Location = new System.Drawing.Point(3, 130);
|
||||
groupBoxReleaseChannel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
groupBoxReleaseChannel.Location = new System.Drawing.Point(0, 144);
|
||||
groupBoxReleaseChannel.Name = "groupBoxReleaseChannel";
|
||||
groupBoxReleaseChannel.Size = new System.Drawing.Size(604, 104);
|
||||
groupBoxReleaseChannel.Size = new System.Drawing.Size(610, 104);
|
||||
groupBoxReleaseChannel.TabIndex = 3;
|
||||
groupBoxReleaseChannel.TabStop = false;
|
||||
groupBoxReleaseChannel.Text = "Release Channel";
|
||||
//
|
||||
// pnlDefaultUpdate
|
||||
//
|
||||
pnlDefaultUpdate.Controls.Add(pnlProxy);
|
||||
pnlDefaultUpdate.Controls.Add(groupBoxReleaseChannel);
|
||||
pnlDefaultUpdate.Controls.Add(pnlUpdateCheck);
|
||||
pnlDefaultUpdate.Controls.Add(lblUpdateAdminInfo);
|
||||
pnlDefaultUpdate.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
pnlDefaultUpdate.Location = new System.Drawing.Point(0, 0);
|
||||
pnlDefaultUpdate.Name = "pnlDefaultUpdate";
|
||||
pnlDefaultUpdate.Size = new System.Drawing.Size(610, 483);
|
||||
pnlDefaultUpdate.TabIndex = 4;
|
||||
//
|
||||
// lblUpdateAdminInfo
|
||||
//
|
||||
lblUpdateAdminInfo.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
lblUpdateAdminInfo.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
lblUpdateAdminInfo.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
lblUpdateAdminInfo.Location = new System.Drawing.Point(0, 0);
|
||||
lblUpdateAdminInfo.Name = "lblUpdateAdminInfo";
|
||||
lblUpdateAdminInfo.Padding = new System.Windows.Forms.Padding(0, 2, 0, 0);
|
||||
lblUpdateAdminInfo.Size = new System.Drawing.Size(610, 30);
|
||||
lblUpdateAdminInfo.TabIndex = 0;
|
||||
lblUpdateAdminInfo.Text = "Some settings are configured by your Administrator. Please contact your administrator for more information.";
|
||||
lblUpdateAdminInfo.Visible = false;
|
||||
//
|
||||
// UpdatesPage
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
Controls.Add(groupBoxReleaseChannel);
|
||||
Controls.Add(lblUpdatesExplanation);
|
||||
Controls.Add(pnlUpdateCheck);
|
||||
Controls.Add(pnlProxy);
|
||||
Controls.Add(pnlDefaultUpdate);
|
||||
Margin = new System.Windows.Forms.Padding(4);
|
||||
Name = "UpdatesPage";
|
||||
Size = new System.Drawing.Size(610, 490);
|
||||
Size = new System.Drawing.Size(610, 496);
|
||||
pnlUpdateCheck.ResumeLayout(false);
|
||||
pnlUpdateCheck.PerformLayout();
|
||||
pnlProxy.ResumeLayout(false);
|
||||
@@ -340,6 +371,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
tblProxyAuthentication.PerformLayout();
|
||||
groupBoxReleaseChannel.ResumeLayout(false);
|
||||
groupBoxReleaseChannel.PerformLayout();
|
||||
pnlDefaultUpdate.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@@ -347,7 +379,6 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
internal System.Windows.Forms.Panel pnlUpdateCheck;
|
||||
internal MrngButton btnUpdateCheckNow;
|
||||
internal MrngCheckBox chkCheckForUpdatesOnStartup;
|
||||
internal MrngComboBox cboUpdateCheckFrequency;
|
||||
internal System.Windows.Forms.Panel pnlProxy;
|
||||
internal Controls.MrngLabel lblProxyAddress;
|
||||
internal Controls.MrngTextBox txtProxyAddress;
|
||||
@@ -365,5 +396,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
private MrngGroupBox groupBoxReleaseChannel;
|
||||
private System.Windows.Forms.TableLayoutPanel tblProxyBasic;
|
||||
private System.Windows.Forms.TableLayoutPanel tblProxyAuthentication;
|
||||
private System.Windows.Forms.Panel pnlDefaultUpdate;
|
||||
internal System.Windows.Forms.Label lblUpdateAdminInfo;
|
||||
internal MrngComboBox cboUpdateCheckFrequency;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
|
||||
namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
@@ -19,6 +20,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
#region Private Fields
|
||||
|
||||
private AppUpdater _appUpdate;
|
||||
private readonly OptRegistryUpdatesPage _RegistrySettings = new();
|
||||
private bool _pageEnabled = true;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -58,39 +61,51 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
lblProxyPassword.Text = Language.Password;
|
||||
|
||||
btnTestProxy.Text = Language.TestProxy;
|
||||
|
||||
lblUpdateAdminInfo.Text = Language.OptionsAdminInfo;
|
||||
}
|
||||
|
||||
public override void LoadSettings()
|
||||
{
|
||||
if (UpdatesForbidden())
|
||||
return;
|
||||
|
||||
chkCheckForUpdatesOnStartup.Checked = Properties.OptionsUpdatesPage.Default.CheckForUpdatesOnStartup;
|
||||
cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked;
|
||||
cboUpdateCheckFrequency.Items.Clear();
|
||||
var nDaily = cboUpdateCheckFrequency.Items.Add(Language.Daily);
|
||||
var nWeekly = cboUpdateCheckFrequency.Items.Add(Language.Weekly);
|
||||
var nMonthly = cboUpdateCheckFrequency.Items.Add(Language.Monthly);
|
||||
if (Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays < 1)
|
||||
if (!_RegistrySettings.CheckForUpdatesFrequencyDays.IsKeyPresent)
|
||||
cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked;
|
||||
|
||||
if (CommonRegistrySettings.AllowCheckForUpdatesAutomatical)
|
||||
{
|
||||
chkCheckForUpdatesOnStartup.Checked = false;
|
||||
cboUpdateCheckFrequency.SelectedIndex = nDaily;
|
||||
} // Daily
|
||||
else
|
||||
switch (Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays)
|
||||
cboUpdateCheckFrequency.Items.Clear();
|
||||
var nDaily = cboUpdateCheckFrequency.Items.Add(Language.Daily);
|
||||
var nWeekly = cboUpdateCheckFrequency.Items.Add(Language.Weekly);
|
||||
var nMonthly = cboUpdateCheckFrequency.Items.Add(Language.Monthly);
|
||||
if (Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays < 1)
|
||||
{
|
||||
case 1:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nDaily;
|
||||
break;
|
||||
case 7:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nWeekly;
|
||||
break;
|
||||
case 31:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nMonthly;
|
||||
break;
|
||||
default:
|
||||
var nCustom =
|
||||
cboUpdateCheckFrequency.Items.Add(string.Format(Language.UpdateFrequencyCustom, Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays));
|
||||
cboUpdateCheckFrequency.SelectedIndex = nCustom;
|
||||
break;
|
||||
chkCheckForUpdatesOnStartup.Checked = false;
|
||||
cboUpdateCheckFrequency.SelectedIndex = nDaily;
|
||||
} // Daily
|
||||
else
|
||||
{
|
||||
switch (Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays)
|
||||
{
|
||||
case 1:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nDaily;
|
||||
break;
|
||||
case 7:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nWeekly;
|
||||
break;
|
||||
case 31:
|
||||
cboUpdateCheckFrequency.SelectedIndex = nMonthly;
|
||||
break;
|
||||
default:
|
||||
var nCustom =
|
||||
cboUpdateCheckFrequency.Items.Add(string.Format(Language.UpdateFrequencyCustom, Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays));
|
||||
cboUpdateCheckFrequency.SelectedIndex = nCustom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var stable = cboReleaseChannel.Items.Add(UpdateChannelInfo.STABLE);
|
||||
var beta = cboReleaseChannel.Items.Add(UpdateChannelInfo.PREVIEW);
|
||||
@@ -130,6 +145,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
base.SaveSettings();
|
||||
|
||||
if (UpdatesForbidden())
|
||||
return;
|
||||
|
||||
Properties.OptionsUpdatesPage.Default.CheckForUpdatesOnStartup = chkCheckForUpdatesOnStartup.Checked;
|
||||
if (cboUpdateCheckFrequency.SelectedItem.ToString() == Language.Daily)
|
||||
{
|
||||
@@ -156,13 +174,109 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAuthPass = cryptographyProvider.Encrypt(txtProxyPassword.Text, Runtime.EncryptionKey);
|
||||
}
|
||||
|
||||
public override void LoadRegistrySettings()
|
||||
{
|
||||
if (UpdatesForbidden())
|
||||
return;
|
||||
|
||||
if (!CommonRegistrySettings.AllowCheckForUpdatesAutomatical)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.CheckForUpdatesOnStartup = false;
|
||||
DisableControl(chkCheckForUpdatesOnStartup);
|
||||
DisableControl(cboUpdateCheckFrequency);
|
||||
}
|
||||
|
||||
if (_RegistrySettings.CheckForUpdatesFrequencyDays.IsKeyPresent && _RegistrySettings.CheckForUpdatesFrequencyDays.Value >= 1)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.CheckForUpdatesFrequencyDays = _RegistrySettings.CheckForUpdatesFrequencyDays.Value;
|
||||
DisableControl(cboUpdateCheckFrequency);
|
||||
}
|
||||
|
||||
btnUpdateCheckNow.Enabled = CommonRegistrySettings.AllowCheckForUpdatesManual;
|
||||
|
||||
if (_RegistrySettings.UpdateChannel.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateChannel = _RegistrySettings.UpdateChannel.Value;
|
||||
DisableControl(cboReleaseChannel);
|
||||
}
|
||||
|
||||
if (_RegistrySettings.UseProxyForUpdates.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateUseProxy = _RegistrySettings.UseProxyForUpdates.Value;
|
||||
DisableControl(chkUseProxyForAutomaticUpdates);
|
||||
|
||||
if (_RegistrySettings.UseProxyForUpdates.Value == false)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAddress = "";
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyPort = 80;
|
||||
}
|
||||
|
||||
if (_RegistrySettings.ProxyAddress.IsKeyPresent && _RegistrySettings.UseProxyForUpdates.Value == true)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAddress = _RegistrySettings.ProxyAddress.Value;
|
||||
DisableControl(txtProxyAddress);
|
||||
}
|
||||
|
||||
if (_RegistrySettings.ProxyPort.IsKeyPresent && _RegistrySettings.UseProxyForUpdates.Value == true)
|
||||
{
|
||||
// only set value if not is 0 to prevent errors..
|
||||
if (_RegistrySettings.ProxyPort.Value >= 1)
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyPort = _RegistrySettings.ProxyPort.Value;
|
||||
|
||||
DisableControl(numProxyPort);
|
||||
}
|
||||
}
|
||||
|
||||
if (_RegistrySettings.UseProxyAuthentication.IsKeyPresent)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyUseAuthentication = _RegistrySettings.UseProxyAuthentication.Value;
|
||||
DisableControl(chkUseProxyAuthentication);
|
||||
|
||||
if (_RegistrySettings.UseProxyAuthentication.Value == false)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAuthUser = "";
|
||||
//Properties.OptionsUpdatesPage.Default.UpdateProxyAuthPass = "";
|
||||
}
|
||||
|
||||
if (_RegistrySettings.ProxyAuthUser.IsKeyPresent && _RegistrySettings.UseProxyAuthentication.Value == true)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAuthUser = _RegistrySettings.ProxyAuthUser.Value;
|
||||
DisableControl(txtProxyUsername);
|
||||
}
|
||||
|
||||
/*if (_RegistrySettings.ProxyAuthPass.IsProvided && _RegistrySettings.UseProxyAuthentication.Value == true)
|
||||
{
|
||||
Properties.OptionsUpdatesPage.Default.UpdateProxyAuthPass = _RegistrySettings.ProxyAuthPass;
|
||||
DisableControl(txtProxyPassword);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
lblUpdateAdminInfo.Visible = ShowAdministratorInfo();
|
||||
}
|
||||
|
||||
public override bool ShowAdministratorInfo()
|
||||
{
|
||||
return !CommonRegistrySettings.AllowCheckForUpdatesAutomatical
|
||||
|| !CommonRegistrySettings.AllowCheckForUpdatesManual
|
||||
|| _RegistrySettings.CheckForUpdatesFrequencyDays.IsKeyPresent
|
||||
|| _RegistrySettings.UpdateChannel.IsKeyPresent
|
||||
|| _RegistrySettings.UseProxyForUpdates.IsKeyPresent
|
||||
|| _RegistrySettings.ProxyAddress.IsKeyPresent
|
||||
|| _RegistrySettings.ProxyPort.IsKeyPresent
|
||||
|| _RegistrySettings.UseProxyAuthentication.IsKeyPresent
|
||||
|| _RegistrySettings.ProxyAuthUser.IsKeyPresent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void chkCheckForUpdatesOnStartup_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked;
|
||||
if (!_RegistrySettings.CheckForUpdatesFrequencyDays.IsKeyPresent)
|
||||
cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked;
|
||||
}
|
||||
|
||||
private void btnUpdateCheckNow_Click(object sender, EventArgs e)
|
||||
@@ -177,9 +291,10 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
|
||||
if (chkUseProxyForAutomaticUpdates.Checked)
|
||||
{
|
||||
chkUseProxyAuthentication.Enabled = true;
|
||||
if (!_RegistrySettings.UseProxyForUpdates.IsKeyPresent)
|
||||
chkUseProxyAuthentication.Enabled = true;
|
||||
|
||||
if (chkUseProxyAuthentication.Checked)
|
||||
if (chkUseProxyAuthentication.Checked && !_RegistrySettings.UseProxyAuthentication.IsKeyPresent)
|
||||
{
|
||||
tblProxyAuthentication.Enabled = true;
|
||||
}
|
||||
@@ -238,6 +353,49 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
}
|
||||
}
|
||||
|
||||
private bool UpdatesForbidden()
|
||||
{
|
||||
bool forbidden = !CommonRegistrySettings.AllowCheckForUpdates
|
||||
|| (!CommonRegistrySettings.AllowCheckForUpdatesAutomatical
|
||||
&& !CommonRegistrySettings.AllowCheckForUpdatesManual);
|
||||
|
||||
if (forbidden && _pageEnabled)
|
||||
DisablePage();
|
||||
|
||||
return forbidden;
|
||||
}
|
||||
|
||||
public override void DisablePage()
|
||||
{
|
||||
chkCheckForUpdatesOnStartup.Checked = false;
|
||||
chkCheckForUpdatesOnStartup.Enabled = false;
|
||||
cboUpdateCheckFrequency.Enabled = false;
|
||||
btnUpdateCheckNow.Enabled = false;
|
||||
cboReleaseChannel.Enabled = false;
|
||||
|
||||
chkUseProxyForAutomaticUpdates.Checked = false;
|
||||
chkUseProxyForAutomaticUpdates.Enabled = false;
|
||||
|
||||
tblProxyBasic.Enabled = false;
|
||||
txtProxyAddress.Enabled = false;
|
||||
txtProxyAddress.ReadOnly = true;
|
||||
numProxyPort.Enabled = false;
|
||||
|
||||
chkUseProxyAuthentication.Checked = false;
|
||||
chkUseProxyAuthentication.Enabled = false;
|
||||
|
||||
tblProxyAuthentication.Enabled = false;
|
||||
txtProxyUsername.Enabled = false;
|
||||
txtProxyUsername.ReadOnly = true;
|
||||
txtProxyPassword.Enabled = false;
|
||||
txtProxyPassword.ReadOnly = true;
|
||||
btnTestProxy.Enabled = false;
|
||||
|
||||
lblUpdateAdminInfo.Visible = true;
|
||||
|
||||
_pageEnabled = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
@@ -57,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="lblUpdateAdminInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -33,6 +33,7 @@ using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
#endregion
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
@@ -345,6 +346,10 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
private void PromptForUpdatesPreference()
|
||||
{
|
||||
if (!CommonRegistrySettings.AllowCheckForUpdates) return;
|
||||
if (!CommonRegistrySettings.AllowCheckForUpdatesAutomatical) return;
|
||||
if (CommonRegistrySettings.CheckForUpdatesAsked) return;
|
||||
|
||||
if (Properties.OptionsUpdatesPage.Default.CheckForUpdatesAsked) return;
|
||||
string[] commandButtons =
|
||||
{
|
||||
@@ -368,6 +373,9 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
private async Task CheckForUpdates()
|
||||
{
|
||||
if (!CommonRegistrySettings.AllowCheckForUpdates) return;
|
||||
if (!CommonRegistrySettings.AllowCheckForUpdatesAutomatical) return;
|
||||
|
||||
if (!Properties.OptionsUpdatesPage.Default.CheckForUpdatesOnStartup) return;
|
||||
|
||||
var nextUpdateCheck =
|
||||
|
||||
@@ -206,6 +206,7 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
if (page == null) return;
|
||||
page.ApplyLanguage();
|
||||
page.LoadRegistrySettings();
|
||||
page.LoadSettings();
|
||||
_optionPages.Add(page);
|
||||
lstOptionPages.AddObject(page);
|
||||
|
||||
@@ -6,6 +6,7 @@ using mRemoteNG.App.Info;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.Resources.Language;
|
||||
using System.Runtime.Versioning;
|
||||
using mRemoteNG.Config.Settings.Registry;
|
||||
|
||||
namespace mRemoteNG.UI.Menu
|
||||
{
|
||||
@@ -78,6 +79,8 @@ namespace mRemoteNG.UI.Menu
|
||||
_mMenToolsUpdate.Size = new System.Drawing.Size(190, 22);
|
||||
_mMenToolsUpdate.Text = Language.CheckForUpdates;
|
||||
_mMenToolsUpdate.Click += mMenToolsUpdate_Click;
|
||||
_mMenToolsUpdate.Enabled = CommonRegistrySettings.AllowCheckForUpdates
|
||||
&& CommonRegistrySettings.AllowCheckForUpdatesManual;
|
||||
//
|
||||
// mMenInfoSep1
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user