mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Refactored much of the inheritance code to use System.Reflection instead of hardcoded values.
Refactored DefaultInheritance to its own class which inherits from the ConnectionInfoInheritance class. Fixed issue with DefaultInheritance not saving to settings.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
@@ -59,10 +60,23 @@ namespace mRemoteNGTests.Connection
|
||||
Assert.That(_inheritance.Username, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPropertiesReturnsListOfSettableProperties()
|
||||
{
|
||||
var hasIconProperty = _inheritance.GetProperties().Contains(typeof(ConnectionInfoInheritance).GetProperty("Icon"));
|
||||
Assert.That(hasIconProperty, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPropertiesExludesPropertiesThatShouldNotBeSet()
|
||||
{
|
||||
var hasEverythingInheritedProperty = _inheritance.GetProperties().Contains(typeof(ConnectionInfoInheritance).GetProperty("EverythingInherited"));
|
||||
Assert.That(hasEverythingInheritedProperty, Is.False);
|
||||
}
|
||||
|
||||
private bool AllInheritancePropertiesAreTrue()
|
||||
{
|
||||
bool allPropertiesTrue = true;
|
||||
var allPropertiesTrue = true;
|
||||
foreach (var property in _inheritanceProperties)
|
||||
{
|
||||
if (PropertyIsBoolean(property) && PropertyIsChangedWhenSettingInheritAll(property) && BooleanPropertyIsSetToFalse(property))
|
||||
@@ -73,7 +87,7 @@ namespace mRemoteNGTests.Connection
|
||||
|
||||
private bool AllInheritancePropertiesAreFalse()
|
||||
{
|
||||
bool allPropertiesFalse = true;
|
||||
var allPropertiesFalse = true;
|
||||
foreach (var property in _inheritanceProperties)
|
||||
{
|
||||
if (PropertyIsBoolean(property) && PropertyIsChangedWhenSettingInheritAll(property) && BooleanPropertyIsSetToTrue(property))
|
||||
@@ -84,8 +98,7 @@ namespace mRemoteNGTests.Connection
|
||||
|
||||
private bool PropertyIsChangedWhenSettingInheritAll(PropertyInfo property)
|
||||
{
|
||||
ArrayList propertiesIgnoredByInheritAll = new ArrayList();
|
||||
propertiesIgnoredByInheritAll.Add("IsDefault");
|
||||
var propertiesIgnoredByInheritAll = new ArrayList {"IsDefault"};
|
||||
return propertiesIgnoredByInheritAll.Contains(property);
|
||||
}
|
||||
|
||||
@@ -101,7 +114,7 @@ namespace mRemoteNGTests.Connection
|
||||
|
||||
private bool BooleanPropertyIsSetToTrue(PropertyInfo property)
|
||||
{
|
||||
return (bool)property.GetValue(_inheritance) == true;
|
||||
return (bool)property.GetValue(_inheritance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
using mRemoteNG.Connection;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace mRemoteNGTests.Connection
|
||||
{
|
||||
public class DefaultConnectionInheritanceTests
|
||||
{
|
||||
private readonly DefaultConnectionInheritance _defaultConnectionInheritance;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void Teardown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void a()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,7 @@
|
||||
<Compile Include="App\LoggerTests.cs" />
|
||||
<Compile Include="BinaryFileTests.cs" />
|
||||
<Compile Include="Connection\ConnectionInfoInheritanceTests.cs" />
|
||||
<Compile Include="Connection\DefaultConnectionInheritanceTests.cs" />
|
||||
<Compile Include="ListViewTester.cs" />
|
||||
<Compile Include="Config\Connections\SqlConnectionUpdateCheckerTests.cs" />
|
||||
<Compile Include="Config\Connections\SqlUpdateQueryBuilderTest.cs" />
|
||||
|
||||
@@ -17,7 +17,6 @@ using System.IO;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Security.SymmetricEncryption;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Forms.Input;
|
||||
@@ -145,73 +144,6 @@ namespace mRemoteNG.App
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Default Inheritance
|
||||
public static ConnectionInfoInheritance DefaultInheritanceFromSettings()
|
||||
{
|
||||
DefaultInheritance = new ConnectionInfoInheritance(null);
|
||||
DefaultInheritance.IsDefault = true;
|
||||
return DefaultInheritance;
|
||||
}
|
||||
|
||||
public static void DefaultInheritanceToSettings()
|
||||
{
|
||||
Settings.Default.InhDefaultDescription = DefaultInheritance.Description;
|
||||
Settings.Default.InhDefaultIcon = DefaultInheritance.Icon;
|
||||
Settings.Default.InhDefaultPanel = DefaultInheritance.Panel;
|
||||
Settings.Default.InhDefaultUsername = DefaultInheritance.Username;
|
||||
Settings.Default.InhDefaultPassword = DefaultInheritance.Password;
|
||||
Settings.Default.InhDefaultDomain = DefaultInheritance.Domain;
|
||||
Settings.Default.InhDefaultProtocol = DefaultInheritance.Protocol;
|
||||
Settings.Default.InhDefaultPort = DefaultInheritance.Port;
|
||||
Settings.Default.InhDefaultPuttySession = DefaultInheritance.PuttySession;
|
||||
Settings.Default.InhDefaultUseConsoleSession = DefaultInheritance.UseConsoleSession;
|
||||
Settings.Default.InhDefaultUseCredSsp = DefaultInheritance.UseCredSsp;
|
||||
Settings.Default.InhDefaultRenderingEngine = DefaultInheritance.RenderingEngine;
|
||||
Settings.Default.InhDefaultICAEncryptionStrength = DefaultInheritance.ICAEncryption;
|
||||
Settings.Default.InhDefaultRDPAuthenticationLevel = DefaultInheritance.RDPAuthenticationLevel;
|
||||
Settings.Default.InhDefaultLoadBalanceInfo = DefaultInheritance.LoadBalanceInfo;
|
||||
Settings.Default.InhDefaultResolution = DefaultInheritance.Resolution;
|
||||
Settings.Default.InhDefaultAutomaticResize = DefaultInheritance.AutomaticResize;
|
||||
Settings.Default.InhDefaultColors = DefaultInheritance.Colors;
|
||||
Settings.Default.InhDefaultCacheBitmaps = DefaultInheritance.CacheBitmaps;
|
||||
Settings.Default.InhDefaultDisplayWallpaper = DefaultInheritance.DisplayWallpaper;
|
||||
Settings.Default.InhDefaultDisplayThemes = DefaultInheritance.DisplayThemes;
|
||||
Settings.Default.InhDefaultEnableFontSmoothing = DefaultInheritance.EnableFontSmoothing;
|
||||
Settings.Default.InhDefaultEnableDesktopComposition = DefaultInheritance.EnableDesktopComposition;
|
||||
Settings.Default.InhDefaultRedirectKeys = DefaultInheritance.RedirectKeys;
|
||||
Settings.Default.InhDefaultRedirectDiskDrives = DefaultInheritance.RedirectDiskDrives;
|
||||
Settings.Default.InhDefaultRedirectPrinters = DefaultInheritance.RedirectPrinters;
|
||||
Settings.Default.InhDefaultRedirectPorts = DefaultInheritance.RedirectPorts;
|
||||
Settings.Default.InhDefaultRedirectSmartCards = DefaultInheritance.RedirectSmartCards;
|
||||
Settings.Default.InhDefaultRedirectSound = DefaultInheritance.RedirectSound;
|
||||
Settings.Default.InhDefaultPreExtApp = DefaultInheritance.PreExtApp;
|
||||
Settings.Default.InhDefaultPostExtApp = DefaultInheritance.PostExtApp;
|
||||
Settings.Default.InhDefaultMacAddress = DefaultInheritance.MacAddress;
|
||||
Settings.Default.InhDefaultUserField = DefaultInheritance.UserField;
|
||||
// VNC inheritance
|
||||
Settings.Default.InhDefaultVNCAuthMode = DefaultInheritance.VNCAuthMode;
|
||||
Settings.Default.InhDefaultVNCColors = DefaultInheritance.VNCColors;
|
||||
Settings.Default.InhDefaultVNCCompression = DefaultInheritance.VNCCompression;
|
||||
Settings.Default.InhDefaultVNCEncoding = DefaultInheritance.VNCEncoding;
|
||||
Settings.Default.InhDefaultVNCProxyIP = DefaultInheritance.VNCProxyIP;
|
||||
Settings.Default.InhDefaultVNCProxyPassword = DefaultInheritance.VNCProxyPassword;
|
||||
Settings.Default.InhDefaultVNCProxyPort = DefaultInheritance.VNCProxyPort;
|
||||
Settings.Default.InhDefaultVNCProxyType = DefaultInheritance.VNCProxyType;
|
||||
Settings.Default.InhDefaultVNCProxyUsername = DefaultInheritance.VNCProxyUsername;
|
||||
Settings.Default.InhDefaultVNCSmartSizeMode = DefaultInheritance.VNCSmartSizeMode;
|
||||
Settings.Default.InhDefaultVNCViewOnly = DefaultInheritance.VNCViewOnly;
|
||||
// Ext. App inheritance
|
||||
Settings.Default.InhDefaultExtApp = DefaultInheritance.ExtApp;
|
||||
// RDP gateway inheritance
|
||||
Settings.Default.InhDefaultRDGatewayUsageMethod = DefaultInheritance.RDGatewayUsageMethod;
|
||||
Settings.Default.InhDefaultRDGatewayHostname = DefaultInheritance.RDGatewayHostname;
|
||||
Settings.Default.InhDefaultRDGatewayUsername = DefaultInheritance.RDGatewayUsername;
|
||||
Settings.Default.InhDefaultRDGatewayPassword = DefaultInheritance.RDGatewayPassword;
|
||||
Settings.Default.InhDefaultRDGatewayDomain = DefaultInheritance.RDGatewayDomain;
|
||||
Settings.Default.InhDefaultRDGatewayUseConnectionCredentials = DefaultInheritance.RDGatewayUseConnectionCredentials;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Panels
|
||||
public static Form AddPanel(string title = "", bool noTabber = false)
|
||||
{
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace mRemoteNG.Config.Connections
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.UseConsoleSession) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.RenderingEngine) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.Username) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.ICAEncryption) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.ICAEncryptionStrength) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.RDPAuthenticationLevel) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.LoadBalanceInfo) + "\',";
|
||||
_sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.PreExtApp) + "\',";
|
||||
@@ -845,7 +845,7 @@ namespace mRemoteNG.Config.Connections
|
||||
_xmlTextWriter.WriteAttributeString("InheritUseCredSsp", "", Convert.ToString(curConI.Inheritance.UseCredSsp));
|
||||
_xmlTextWriter.WriteAttributeString("InheritRenderingEngine", "", Convert.ToString(curConI.Inheritance.RenderingEngine));
|
||||
_xmlTextWriter.WriteAttributeString("InheritUsername", "", Convert.ToString(curConI.Inheritance.Username));
|
||||
_xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", Convert.ToString(curConI.Inheritance.ICAEncryption));
|
||||
_xmlTextWriter.WriteAttributeString("InheritICAEncryptionStrength", "", Convert.ToString(curConI.Inheritance.ICAEncryptionStrength));
|
||||
_xmlTextWriter.WriteAttributeString("InheritRDPAuthenticationLevel", "", Convert.ToString(curConI.Inheritance.RDPAuthenticationLevel));
|
||||
_xmlTextWriter.WriteAttributeString("InheritLoadBalanceInfo", "", Convert.ToString(curConI.Inheritance.LoadBalanceInfo));
|
||||
_xmlTextWriter.WriteAttributeString("InheritPreExtApp", "", Convert.ToString(curConI.Inheritance.PreExtApp));
|
||||
@@ -1039,7 +1039,7 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
if (SaveSecurity.Inheritance)
|
||||
{
|
||||
csvLn += con.Inheritance.CacheBitmaps + ";" + Convert.ToString(con.Inheritance.Colors) + ";" + Convert.ToString(con.Inheritance.Description) + ";" + Convert.ToString(con.Inheritance.DisplayThemes) + ";" + Convert.ToString(con.Inheritance.DisplayWallpaper) + ";" + Convert.ToString(con.Inheritance.EnableFontSmoothing) + ";" + Convert.ToString(con.Inheritance.EnableDesktopComposition) + ";" + Convert.ToString(con.Inheritance.Domain) + ";" + Convert.ToString(con.Inheritance.Icon) + ";" + Convert.ToString(con.Inheritance.Panel) + ";" + Convert.ToString(con.Inheritance.Password) + ";" + Convert.ToString(con.Inheritance.Port) + ";" + Convert.ToString(con.Inheritance.Protocol) + ";" + Convert.ToString(con.Inheritance.PuttySession) + ";" + Convert.ToString(con.Inheritance.RedirectDiskDrives) + ";" + Convert.ToString(con.Inheritance.RedirectKeys) + ";" + Convert.ToString(con.Inheritance.RedirectPorts) + ";" + Convert.ToString(con.Inheritance.RedirectPrinters) + ";" + Convert.ToString(con.Inheritance.RedirectSmartCards) + ";" + Convert.ToString(con.Inheritance.RedirectSound) + ";" + Convert.ToString(con.Inheritance.Resolution) + ";" + Convert.ToString(con.Inheritance.AutomaticResize) + ";" + Convert.ToString(con.Inheritance.UseConsoleSession) + ";" + Convert.ToString(con.Inheritance.UseCredSsp) + ";" + Convert.ToString(con.Inheritance.RenderingEngine) + ";" + Convert.ToString(con.Inheritance.Username) + ";" + Convert.ToString(con.Inheritance.ICAEncryption) + ";" + Convert.ToString(con.Inheritance.RDPAuthenticationLevel) + ";" + Convert.ToString(con.Inheritance.LoadBalanceInfo) + ";" + Convert.ToString(con.Inheritance.PreExtApp) + ";" + Convert.ToString(con.Inheritance.PostExtApp) + ";" + Convert.ToString(con.Inheritance.MacAddress) + ";" + Convert.ToString(con.Inheritance.UserField) + ";" + Convert.ToString(con.Inheritance.ExtApp) + ";" + Convert.ToString(con.Inheritance.VNCCompression) + ";"
|
||||
csvLn += con.Inheritance.CacheBitmaps + ";" + Convert.ToString(con.Inheritance.Colors) + ";" + Convert.ToString(con.Inheritance.Description) + ";" + Convert.ToString(con.Inheritance.DisplayThemes) + ";" + Convert.ToString(con.Inheritance.DisplayWallpaper) + ";" + Convert.ToString(con.Inheritance.EnableFontSmoothing) + ";" + Convert.ToString(con.Inheritance.EnableDesktopComposition) + ";" + Convert.ToString(con.Inheritance.Domain) + ";" + Convert.ToString(con.Inheritance.Icon) + ";" + Convert.ToString(con.Inheritance.Panel) + ";" + Convert.ToString(con.Inheritance.Password) + ";" + Convert.ToString(con.Inheritance.Port) + ";" + Convert.ToString(con.Inheritance.Protocol) + ";" + Convert.ToString(con.Inheritance.PuttySession) + ";" + Convert.ToString(con.Inheritance.RedirectDiskDrives) + ";" + Convert.ToString(con.Inheritance.RedirectKeys) + ";" + Convert.ToString(con.Inheritance.RedirectPorts) + ";" + Convert.ToString(con.Inheritance.RedirectPrinters) + ";" + Convert.ToString(con.Inheritance.RedirectSmartCards) + ";" + Convert.ToString(con.Inheritance.RedirectSound) + ";" + Convert.ToString(con.Inheritance.Resolution) + ";" + Convert.ToString(con.Inheritance.AutomaticResize) + ";" + Convert.ToString(con.Inheritance.UseConsoleSession) + ";" + Convert.ToString(con.Inheritance.UseCredSsp) + ";" + Convert.ToString(con.Inheritance.RenderingEngine) + ";" + Convert.ToString(con.Inheritance.Username) + ";" + Convert.ToString(con.Inheritance.ICAEncryptionStrength) + ";" + Convert.ToString(con.Inheritance.RDPAuthenticationLevel) + ";" + Convert.ToString(con.Inheritance.LoadBalanceInfo) + ";" + Convert.ToString(con.Inheritance.PreExtApp) + ";" + Convert.ToString(con.Inheritance.PostExtApp) + ";" + Convert.ToString(con.Inheritance.MacAddress) + ";" + Convert.ToString(con.Inheritance.UserField) + ";" + Convert.ToString(con.Inheritance.ExtApp) + ";" + Convert.ToString(con.Inheritance.VNCCompression) + ";"
|
||||
+ Convert.ToString(con.Inheritance.VNCEncoding) + ";" + Convert.ToString(con.Inheritance.VNCAuthMode) + ";" + Convert.ToString(con.Inheritance.VNCProxyType) + ";" + Convert.ToString(con.Inheritance.VNCProxyIP) + ";" + Convert.ToString(con.Inheritance.VNCProxyPort) + ";" + Convert.ToString(con.Inheritance.VNCProxyUsername) + ";" + Convert.ToString(con.Inheritance.VNCProxyPassword) + ";" + Convert.ToString(con.Inheritance.VNCColors) + ";" + Convert.ToString(con.Inheritance.VNCSmartSizeMode) + ";" + Convert.ToString(con.Inheritance.VNCViewOnly);
|
||||
}
|
||||
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace mRemoteNG.Config.Connections
|
||||
if (_confVersion > 1.5) //1.6
|
||||
{
|
||||
connectionInfo.ICAEncryption = (ProtocolICA.EncryptionStrength)Tools.MiscTools.StringToEnum(typeof(ProtocolICA.EncryptionStrength), Convert.ToString(_sqlDataReader["ICAEncryptionStrength"]));
|
||||
connectionInfo.Inheritance.ICAEncryption = Convert.ToBoolean(_sqlDataReader["InheritICAEncryptionStrength"]);
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength = Convert.ToBoolean(_sqlDataReader["InheritICAEncryptionStrength"]);
|
||||
connectionInfo.PreExtApp = Convert.ToString(_sqlDataReader["PreExtApp"]);
|
||||
connectionInfo.PostExtApp = Convert.ToString(_sqlDataReader["PostExtApp"]);
|
||||
connectionInfo.Inheritance.PreExtApp = Convert.ToBoolean(_sqlDataReader["InheritPreExtApp"]);
|
||||
|
||||
@@ -371,7 +371,7 @@ namespace mRemoteNG.Config.Connections
|
||||
if (_confVersion > 1.5) //1.6
|
||||
{
|
||||
connectionInfo.ICAEncryption = (ProtocolICA.EncryptionStrength)Tools.MiscTools.StringToEnum(typeof(ProtocolICA.EncryptionStrength), xmlnode.Attributes["ICAEncryptionStrength"].Value);
|
||||
connectionInfo.Inheritance.ICAEncryption = bool.Parse(xmlnode.Attributes["InheritICAEncryptionStrength"].Value);
|
||||
connectionInfo.Inheritance.ICAEncryptionStrength = bool.Parse(xmlnode.Attributes["InheritICAEncryptionStrength"].Value);
|
||||
connectionInfo.PreExtApp = xmlnode.Attributes["PreExtApp"].Value;
|
||||
connectionInfo.PostExtApp = xmlnode.Attributes["PostExtApp"].Value;
|
||||
connectionInfo.Inheritance.PreExtApp = bool.Parse(xmlnode.Attributes["InheritPreExtApp"].Value);
|
||||
|
||||
@@ -221,7 +221,7 @@ namespace mRemoteNG.Connection
|
||||
TypeConverter(typeof(Tools.MiscTools.EnumTypeConverter))]
|
||||
public ProtocolICA.EncryptionStrength ICAEncryption
|
||||
{
|
||||
get { return GetPropertyValue("ICAEncryption", _icaEncryption); }
|
||||
get { return GetPropertyValue("ICAEncryptionStrength", _icaEncryption); }
|
||||
set { _icaEncryption = value; }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using mRemoteNG.Tools;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
@@ -16,10 +21,7 @@ namespace mRemoteNG.Connection
|
||||
public bool EverythingInherited
|
||||
{
|
||||
get { return EverythingIsInherited(); }
|
||||
set
|
||||
{
|
||||
SetAllValues(value);
|
||||
}
|
||||
set { SetAllValues(value); }
|
||||
}
|
||||
#endregion
|
||||
#region Display
|
||||
@@ -78,7 +80,7 @@ namespace mRemoteNG.Connection
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 4),
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameEncryptionStrength"),
|
||||
LocalizedAttributes.LocalizedDescriptionInheritAttribute("strPropertyDescriptionEncryptionStrength"),
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool ICAEncryption {get; set;}
|
||||
TypeConverter(typeof(MiscTools.YesNoTypeConverter))]public bool ICAEncryptionStrength {get; set;}
|
||||
|
||||
[LocalizedAttributes.LocalizedCategory("strCategoryProtocol", 4),
|
||||
LocalizedAttributes.LocalizedDisplayNameInheritAttribute("strPropertyNameAuthenticationLevel"),
|
||||
@@ -294,9 +296,6 @@ namespace mRemoteNG.Connection
|
||||
|
||||
[Browsable(false)]
|
||||
public object Parent {get; set;}
|
||||
|
||||
[Browsable(false)]
|
||||
public bool IsDefault {get; set;}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -349,15 +348,23 @@ namespace mRemoteNG.Connection
|
||||
|
||||
private bool EverythingIsInherited()
|
||||
{
|
||||
var displaySettings = Description && Icon && Panel;
|
||||
var connectionSettings = Username && Password && Domain;
|
||||
var protocolSettings = Protocol && ExtApp && Port && PuttySession && ICAEncryption && RDPAuthenticationLevel && LoadBalanceInfo && RenderingEngine && UseConsoleSession && UseCredSsp;
|
||||
var appearanceSettings = Resolution && AutomaticResize && Colors && CacheBitmaps && DisplayWallpaper && DisplayThemes && EnableFontSmoothing && EnableDesktopComposition;
|
||||
var redirectSettings = RedirectDiskDrives && RedirectKeys && RedirectPorts && RedirectPrinters && RedirectSmartCards && RedirectSound;
|
||||
var miscSettings = PreExtApp && PostExtApp && MacAddress && UserField;
|
||||
var vncSettings = VNCAuthMode && VNCColors && VNCCompression && VNCEncoding && VNCProxyIP && VNCProxyPassword && VNCProxyPort && VNCProxyType && VNCProxyUsername;
|
||||
var inheritanceProperties = GetProperties();
|
||||
var everythingInherited = inheritanceProperties.All((p) => (bool)p.GetValue(this, null));
|
||||
return everythingInherited;
|
||||
}
|
||||
|
||||
return displaySettings && connectionSettings && protocolSettings && appearanceSettings && redirectSettings && miscSettings && vncSettings;
|
||||
public IEnumerable<PropertyInfo> GetProperties()
|
||||
{
|
||||
var properties = typeof(ConnectionInfoInheritance).GetProperties();
|
||||
var filteredProperties = properties.Where(FilterProperty);
|
||||
return filteredProperties;
|
||||
}
|
||||
|
||||
private bool FilterProperty(PropertyInfo propertyInfo)
|
||||
{
|
||||
var exclusions = new[] { "EverythingInherited", "Parent" };
|
||||
var valueShouldNotBeFiltered = !exclusions.Contains(propertyInfo.Name);
|
||||
return valueShouldNotBeFiltered;
|
||||
}
|
||||
|
||||
private void SetAllValues(bool value)
|
||||
@@ -370,7 +377,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAllValues(ConnectionInfoInheritance otherInheritanceObject)
|
||||
protected void SetAllValues(ConnectionInfoInheritance otherInheritanceObject)
|
||||
{
|
||||
var properties = typeof(ConnectionInfoInheritance).GetProperties();
|
||||
foreach (var property in properties)
|
||||
|
||||
102
mRemoteV1/Connection/DefaultConnectionInheritance.cs
Normal file
102
mRemoteV1/Connection/DefaultConnectionInheritance.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace mRemoteNG.Connection
|
||||
{
|
||||
public class DefaultConnectionInheritance : ConnectionInfoInheritance
|
||||
{
|
||||
private static readonly DefaultConnectionInheritance _singletonInstance = new DefaultConnectionInheritance();
|
||||
private const string SettingNamePrefix = "InhDefault";
|
||||
|
||||
|
||||
public static DefaultConnectionInheritance Instance { get { return _singletonInstance; } }
|
||||
|
||||
private DefaultConnectionInheritance() : base(null)
|
||||
{
|
||||
}
|
||||
|
||||
static DefaultConnectionInheritance()
|
||||
{ }
|
||||
|
||||
|
||||
public void LoadFromSettings()
|
||||
{
|
||||
var inheritanceProperties = GetProperties();
|
||||
foreach (var property in inheritanceProperties)
|
||||
{
|
||||
var propertyFromSettings = typeof(Settings).GetProperty($"{SettingNamePrefix}{property.Name}");
|
||||
var valueFromSettings = propertyFromSettings.GetValue(Settings.Default, null);
|
||||
property.SetValue(Instance, valueFromSettings, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveToSettings()
|
||||
{
|
||||
var inheritanceProperties = GetProperties();
|
||||
foreach (var property in inheritanceProperties)
|
||||
{
|
||||
var propertyFromSettings = typeof(Settings).GetProperty($"{SettingNamePrefix}{property.Name}");
|
||||
var localValue = property.GetValue(Instance, null);
|
||||
propertyFromSettings.SetValue(Settings.Default, localValue, null);
|
||||
}
|
||||
|
||||
//Settings.Default.InhDefaultDescription = Description;
|
||||
//Settings.Default.InhDefaultIcon = Icon;
|
||||
//Settings.Default.InhDefaultPanel = Panel;
|
||||
//Settings.Default.InhDefaultUsername = Username;
|
||||
//Settings.Default.InhDefaultPassword = Password;
|
||||
//Settings.Default.InhDefaultDomain = Domain;
|
||||
//Settings.Default.InhDefaultProtocol = Protocol;
|
||||
//Settings.Default.InhDefaultPort = Port;
|
||||
//Settings.Default.InhDefaultPuttySession = PuttySession;
|
||||
//Settings.Default.InhDefaultUseConsoleSession = UseConsoleSession;
|
||||
//Settings.Default.InhDefaultUseCredSsp = UseCredSsp;
|
||||
//Settings.Default.InhDefaultRenderingEngine = RenderingEngine;
|
||||
//Settings.Default.InhDefaultICAEncryptionStrength = ICAEncryptionStrength;
|
||||
//Settings.Default.InhDefaultRDPAuthenticationLevel = RDPAuthenticationLevel;
|
||||
//Settings.Default.InhDefaultLoadBalanceInfo = LoadBalanceInfo;
|
||||
//Settings.Default.InhDefaultResolution = Resolution;
|
||||
//Settings.Default.InhDefaultAutomaticResize = AutomaticResize;
|
||||
//Settings.Default.InhDefaultColors = Colors;
|
||||
//Settings.Default.InhDefaultCacheBitmaps = CacheBitmaps;
|
||||
//Settings.Default.InhDefaultDisplayWallpaper = DisplayWallpaper;
|
||||
//Settings.Default.InhDefaultDisplayThemes = DisplayThemes;
|
||||
//Settings.Default.InhDefaultEnableFontSmoothing = EnableFontSmoothing;
|
||||
//Settings.Default.InhDefaultEnableDesktopComposition = EnableDesktopComposition;
|
||||
////
|
||||
//Settings.Default.InhDefaultRedirectKeys = RedirectKeys;
|
||||
//Settings.Default.InhDefaultRedirectDiskDrives = RedirectDiskDrives;
|
||||
//Settings.Default.InhDefaultRedirectPrinters = RedirectPrinters;
|
||||
//Settings.Default.InhDefaultRedirectPorts = RedirectPorts;
|
||||
//Settings.Default.InhDefaultRedirectSmartCards = RedirectSmartCards;
|
||||
//Settings.Default.InhDefaultRedirectSound = RedirectSound;
|
||||
////
|
||||
//Settings.Default.InhDefaultPreExtApp = PreExtApp;
|
||||
//Settings.Default.InhDefaultPostExtApp = PostExtApp;
|
||||
//Settings.Default.InhDefaultMacAddress = MacAddress;
|
||||
//Settings.Default.InhDefaultUserField = UserField;
|
||||
//// VNC inheritance
|
||||
//Settings.Default.InhDefaultVNCAuthMode = VNCAuthMode;
|
||||
//Settings.Default.InhDefaultVNCColors = VNCColors;
|
||||
//Settings.Default.InhDefaultVNCCompression = VNCCompression;
|
||||
//Settings.Default.InhDefaultVNCEncoding = VNCEncoding;
|
||||
//Settings.Default.InhDefaultVNCProxyIP = VNCProxyIP;
|
||||
//Settings.Default.InhDefaultVNCProxyPassword = VNCProxyPassword;
|
||||
//Settings.Default.InhDefaultVNCProxyPort = VNCProxyPort;
|
||||
//Settings.Default.InhDefaultVNCProxyType = VNCProxyType;
|
||||
//Settings.Default.InhDefaultVNCProxyUsername = VNCProxyUsername;
|
||||
//Settings.Default.InhDefaultVNCSmartSizeMode = VNCSmartSizeMode;
|
||||
//Settings.Default.InhDefaultVNCViewOnly = VNCViewOnly;
|
||||
//// Ext. App inheritance
|
||||
//Settings.Default.InhDefaultExtApp = ExtApp;
|
||||
//// RDP gateway inheritance
|
||||
//Settings.Default.InhDefaultRDGatewayUsageMethod = RDGatewayUsageMethod;
|
||||
//Settings.Default.InhDefaultRDGatewayHostname = RDGatewayHostname;
|
||||
//Settings.Default.InhDefaultRDGatewayUsername = RDGatewayUsername;
|
||||
//Settings.Default.InhDefaultRDGatewayPassword = RDGatewayPassword;
|
||||
//Settings.Default.InhDefaultRDGatewayDomain = RDGatewayDomain;
|
||||
//Settings.Default.InhDefaultRDGatewayUseConnectionCredentials = RDGatewayUseConnectionCredentials;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace mRemoteNG.UI.Window
|
||||
Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, Convert.ToByte(0));
|
||||
HideOnClose = true;
|
||||
Icon = Resources.Config_Icon;
|
||||
Name = $"Config";
|
||||
Name = "Config";
|
||||
TabText = @"Config";
|
||||
Text = @"Config";
|
||||
propertyGridContextMenu.ResumeLayout(false);
|
||||
@@ -790,13 +790,8 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
private void UpdateInheritanceNode()
|
||||
{
|
||||
if (pGrid.SelectedObject is ConnectionInfoInheritance)
|
||||
{
|
||||
if (((ConnectionInfoInheritance)pGrid.SelectedObject).IsDefault)
|
||||
{
|
||||
Runtime.DefaultInheritanceToSettings();
|
||||
}
|
||||
}
|
||||
if (!(pGrid.SelectedObject is DefaultConnectionInheritance)) return;
|
||||
DefaultConnectionInheritance.Instance.SaveToSettings();
|
||||
}
|
||||
|
||||
private void pGrid_PropertySortChanged(object sender, EventArgs e)
|
||||
@@ -819,7 +814,7 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
case Connection.Protocol.ProtocolType.RDP:
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("PuttySession");
|
||||
strHide.Add("RenderingEngine");
|
||||
strHide.Add("VNCAuthMode");
|
||||
@@ -860,7 +855,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableFontSmoothing");
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("PuttySession");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -903,7 +898,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
strHide.Add("RDGatewayPassword");
|
||||
@@ -944,7 +939,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
strHide.Add("RDGatewayPassword");
|
||||
@@ -985,7 +980,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("Password");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1028,7 +1023,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("Password");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1071,7 +1066,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("Password");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1114,7 +1109,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("PuttySession");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1155,7 +1150,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ExtApp");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("PuttySession");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1232,7 +1227,7 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("EnableFontSmoothing");
|
||||
strHide.Add("EnableDesktopComposition");
|
||||
strHide.Add("Domain");
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
strHide.Add("PuttySession");
|
||||
strHide.Add("RDGatewayDomain");
|
||||
strHide.Add("RDGatewayHostname");
|
||||
@@ -1389,9 +1384,9 @@ namespace mRemoteNG.UI.Window
|
||||
strHide.Add("RenderingEngine");
|
||||
}
|
||||
|
||||
if (conI.Inheritance.ICAEncryption)
|
||||
if (conI.Inheritance.ICAEncryptionStrength)
|
||||
{
|
||||
strHide.Add("ICAEncryption");
|
||||
strHide.Add("ICAEncryptionStrength");
|
||||
}
|
||||
|
||||
if (conI.Inheritance.RDPAuthenticationLevel)
|
||||
@@ -1563,7 +1558,7 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
if (pGrid.SelectedObject is ConnectionInfoInheritance)
|
||||
{
|
||||
if (((ConnectionInfoInheritance)pGrid.SelectedObject).IsDefault)
|
||||
if (pGrid.SelectedObject is DefaultConnectionInheritance)
|
||||
{
|
||||
PropertiesVisible = true;
|
||||
InheritanceVisible = false;
|
||||
@@ -1625,7 +1620,9 @@ namespace mRemoteNG.UI.Window
|
||||
InheritanceVisible = false;
|
||||
DefaultPropertiesVisible = false;
|
||||
DefaultInheritanceVisible = true;
|
||||
SetPropertyGridObject(Runtime.DefaultInheritanceFromSettings());
|
||||
var defaultInheritance = DefaultConnectionInheritance.Instance;
|
||||
defaultInheritance.LoadFromSettings();
|
||||
SetPropertyGridObject(defaultInheritance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
<Compile Include="Connection\ConnectionInfoInheritance.cs" />
|
||||
<Compile Include="App\ProgramRoot.cs" />
|
||||
<Compile Include="Connection\Converter.cs" />
|
||||
<Compile Include="Connection\DefaultConnectionInheritance.cs" />
|
||||
<Compile Include="Connection\Inheritance.cs" />
|
||||
<Compile Include="Connection\Parent.cs" />
|
||||
<Compile Include="Connection\Protocol\ProtocolFactory.cs" />
|
||||
|
||||
Reference in New Issue
Block a user