diff --git a/mRemoteV1/Connection/ConnectionInfoInheritance.cs b/mRemoteV1/Connection/ConnectionInfoInheritance.cs index 53042090e..78e1e3e5e 100644 --- a/mRemoteV1/Connection/ConnectionInfoInheritance.cs +++ b/mRemoteV1/Connection/ConnectionInfoInheritance.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections; using System.Collections.Generic; using mRemoteNG.Tools; using System.ComponentModel; diff --git a/mRemoteV1/Connection/DefaultConnectionInheritance.cs b/mRemoteV1/Connection/DefaultConnectionInheritance.cs index f1b5b97b2..bba22bcd1 100644 --- a/mRemoteV1/Connection/DefaultConnectionInheritance.cs +++ b/mRemoteV1/Connection/DefaultConnectionInheritance.cs @@ -1,16 +1,13 @@ - +using System; -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; } } + public static DefaultConnectionInheritance Instance { get; } = new DefaultConnectionInheritance(); private DefaultConnectionInheritance() : base(null) { @@ -20,13 +17,14 @@ namespace mRemoteNG.Connection { } - public void LoadFromSettings() + public void LoadFrom(TSource sourceInstance, Func propertyNameMutator = null) { + if (propertyNameMutator == null) propertyNameMutator = (a) => a; var inheritanceProperties = GetProperties(); foreach (var property in inheritanceProperties) { - var propertyFromSettings = typeof(Settings).GetProperty($"{SettingNamePrefix}{property.Name}"); - var valueFromSettings = propertyFromSettings.GetValue(Settings.Default, null); + var propertyFromSettings = typeof(TSource).GetProperty(propertyNameMutator(property.Name)); + var valueFromSettings = propertyFromSettings.GetValue(sourceInstance, null); property.SetValue(Instance, valueFromSettings, null); } } @@ -40,63 +38,6 @@ namespace mRemoteNG.Connection 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; } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index f48f9d2b6..f3a2468e1 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -1621,7 +1621,7 @@ namespace mRemoteNG.UI.Window DefaultPropertiesVisible = false; DefaultInheritanceVisible = true; var defaultInheritance = DefaultConnectionInheritance.Instance; - defaultInheritance.LoadFromSettings(); + defaultInheritance.LoadFrom(Settings.Default, (a)=>"InhDefault"+a); SetPropertyGridObject(defaultInheritance); } }