From ae13b5f9203e79b361bc6f1e961583aa00b246b7 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 10:24:02 -0400 Subject: [PATCH 1/8] code clean up/remove unused files --- mRemoteNGTests/UI/Forms/PasswordFormTests.cs | 12 +- mRemoteV1/App/Update/AppUpdater.cs | 1 - mRemoteV1/App/Update/UpdateInfo.cs | 2 - .../Connections/SQLConnectionsProvider.cs | 5 - .../Config/Connections/SqlUpdateTimer.cs | 10 +- mRemoteV1/Config/Settings/SettingsLoader.cs | 1 - mRemoteV1/Config/SqlConnectorImp.cs | 4 +- .../Protocol/ICA/Connection.Protocol.ICA.cs | 117 ++++++++--------- .../Connection/Protocol/IntegratedProgram.cs | 1 - mRemoteV1/Connection/Protocol/ProtocolBase.cs | 15 ++- .../Connection/Protocol/ProtocolFactory.cs | 8 -- mRemoteV1/Connection/Protocol/PuttyBase.cs | 3 +- mRemoteV1/Connection/Protocol/VNC/VNCEnum.cs | 5 +- mRemoteV1/Messages/MessageClassEnum.cs | 6 +- mRemoteV1/Properties/AssemblyInfo.cs | 1 - mRemoteV1/Themes/ThemeManager.cs | 14 +- mRemoteV1/Tools/CmdArgumentsInterpreter.cs | 17 +-- mRemoteV1/Tools/ExternalToolsTypeConverter.cs | 4 +- mRemoteV1/Tools/MiscTools.cs | 2 +- mRemoteV1/Tools/ReconnectGroup.Designer.cs | 2 +- mRemoteV1/Tools/ReconnectGroup.cs | 29 ++--- mRemoteV1/Tools/Sorting/Sortable.cs | 11 -- mRemoteV1/Tools/Sorting/TreeNodeSorter.cs | 7 +- mRemoteV1/Tools/Tools.LocalizedAttributes.cs | 52 +++----- mRemoteV1/Tree/Root/PuttySessionsNodeInfo.cs | 10 +- mRemoteV1/Tree/Root/RootNodeInfo.cs | 5 +- .../UI/Forms/OptionsPages/AppearancePage.cs | 1 - .../UI/Forms/OptionsPages/SqlServerPage.cs | 2 - .../UI/Forms/OptionsPages/StartupExitPage.cs | 1 - .../UI/Forms/OptionsPages/TabsPanelsPage.cs | 1 - mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs | 5 +- .../UI/Forms/OptionsPages/UpdatesPage.cs | 2 - mRemoteV1/UI/Forms/PasswordForm.Designer.cs | 8 +- mRemoteV1/UI/Forms/PasswordForm.cs | 4 +- mRemoteV1/UI/Forms/SplashPage.Designer.cs | 61 --------- mRemoteV1/UI/Forms/SplashPage.cs | 26 ---- mRemoteV1/UI/Forms/SplashPage.resx | 120 ------------------ mRemoteV1/UI/TaskDialog/CommandButton.cs | 63 +++++---- .../UI/Window/ActiveDirectoryImportWindow.cs | 3 +- mRemoteV1/UI/Window/AnnouncementWindow.cs | 1 - mRemoteV1/UI/Window/HelpWindow.cs | 3 +- mRemoteV1/UI/Window/PortScanWindow.cs | 1 - mRemoteV1/UI/Window/UpdateWindow.cs | 20 ++- mRemoteV1/mRemoteV1.csproj | 10 -- 44 files changed, 182 insertions(+), 494 deletions(-) delete mode 100644 mRemoteV1/Tools/Sorting/Sortable.cs delete mode 100644 mRemoteV1/UI/Forms/SplashPage.Designer.cs delete mode 100644 mRemoteV1/UI/Forms/SplashPage.cs delete mode 100644 mRemoteV1/UI/Forms/SplashPage.resx diff --git a/mRemoteNGTests/UI/Forms/PasswordFormTests.cs b/mRemoteNGTests/UI/Forms/PasswordFormTests.cs index d9bd7277..928f652c 100644 --- a/mRemoteNGTests/UI/Forms/PasswordFormTests.cs +++ b/mRemoteNGTests/UI/Forms/PasswordFormTests.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using NUnit.Extensions.Forms; -using System.Threading.Tasks; -using mRemoteNG.Forms; using mRemoteNG.UI.Forms; namespace mRemoteNGTests.UI.Forms @@ -26,7 +20,9 @@ namespace mRemoteNGTests.UI.Forms public void Teardown() { _passwordForm.Dispose(); - while (_passwordForm.Disposing) ; + while (_passwordForm.Disposing) + { + } _passwordForm = null; } diff --git a/mRemoteV1/App/Update/AppUpdater.cs b/mRemoteV1/App/Update/AppUpdater.cs index 89ef2624..cf4ef2a9 100644 --- a/mRemoteV1/App/Update/AppUpdater.cs +++ b/mRemoteV1/App/Update/AppUpdater.cs @@ -6,7 +6,6 @@ using System.Threading; using mRemoteNG.Tools; using System.Reflection; using mRemoteNG.App.Info; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; diff --git a/mRemoteV1/App/Update/UpdateInfo.cs b/mRemoteV1/App/Update/UpdateInfo.cs index 44e7351c..86b40e39 100644 --- a/mRemoteV1/App/Update/UpdateInfo.cs +++ b/mRemoteV1/App/Update/UpdateInfo.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace mRemoteNG.App.Update { diff --git a/mRemoteV1/Config/Connections/SQLConnectionsProvider.cs b/mRemoteV1/Config/Connections/SQLConnectionsProvider.cs index aafaea57..182b137a 100644 --- a/mRemoteV1/Config/Connections/SQLConnectionsProvider.cs +++ b/mRemoteV1/Config/Connections/SQLConnectionsProvider.cs @@ -1,11 +1,6 @@ using mRemoteNG.App; using mRemoteNG.Messages; -using mRemoteNG.Tools; using System; -using System.Collections.Generic; -using System.Text; -using System.Timers; -using mRemoteNG.My; namespace mRemoteNG.Config.Connections { diff --git a/mRemoteV1/Config/Connections/SqlUpdateTimer.cs b/mRemoteV1/Config/Connections/SqlUpdateTimer.cs index ee46d682..2e7f079f 100644 --- a/mRemoteV1/Config/Connections/SqlUpdateTimer.cs +++ b/mRemoteV1/Config/Connections/SqlUpdateTimer.cs @@ -1,9 +1,6 @@ -using mRemoteNG.App; -using mRemoteNG.Messages; -using System; -using System.Data; -using System.Data.SqlClient; +using System; using System.Timers; +using mRemoteNG.App; namespace mRemoteNG.Config.Connections { @@ -67,8 +64,9 @@ namespace mRemoteNG.Config.Connections _sqlUpdateTimer.Stop(); _sqlUpdateTimer.Close(); } - catch (Exception) + catch (Exception ex) { + Runtime.MessageCollector.AddExceptionStackTrace("SqlUpdateTimer StopTimer Exception", ex); } } diff --git a/mRemoteV1/Config/Settings/SettingsLoader.cs b/mRemoteV1/Config/Settings/SettingsLoader.cs index 91bd4af8..5d390337 100644 --- a/mRemoteV1/Config/Settings/SettingsLoader.cs +++ b/mRemoteV1/Config/Settings/SettingsLoader.cs @@ -8,7 +8,6 @@ using System.Globalization; using mRemoteNG.Themes; using mRemoteNG.Connection.Protocol; using mRemoteNG.App.Info; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; using mRemoteNG.UI.Forms; diff --git a/mRemoteV1/Config/SqlConnectorImp.cs b/mRemoteV1/Config/SqlConnectorImp.cs index 012a4c8e..387e5bc2 100644 --- a/mRemoteV1/Config/SqlConnectorImp.cs +++ b/mRemoteV1/Config/SqlConnectorImp.cs @@ -1,12 +1,10 @@ using mRemoteNG.App.Info; -using System; using System.Data.SqlClient; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; namespace mRemoteNG.Config { - public class SqlConnectorImp : IDisposable, mRemoteNG.Config.SqlConnector + public class SqlConnectorImp : SqlConnector { private SqlConnection _sqlConnection = default(SqlConnection); private string _sqlConnectionString = ""; diff --git a/mRemoteV1/Connection/Protocol/ICA/Connection.Protocol.ICA.cs b/mRemoteV1/Connection/Protocol/ICA/Connection.Protocol.ICA.cs index e3d36521..db93ef90 100644 --- a/mRemoteV1/Connection/Protocol/ICA/Connection.Protocol.ICA.cs +++ b/mRemoteV1/Connection/Protocol/ICA/Connection.Protocol.ICA.cs @@ -7,7 +7,6 @@ using System.Threading; using mRemoteNG.App.Info; using mRemoteNG.Tools; using mRemoteNG.Connection.Protocol.RDP; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; using mRemoteNG.UI.Forms; @@ -39,24 +38,26 @@ namespace mRemoteNG.Connection.Protocol.ICA defaultInstance = value; } } - - static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e) + +#if false + private static void defaultInstance_FormClosed(object sender, FormClosedEventArgs e) { defaultInstance = null; } - #endregion +#endif +#endregion - #region Private Properties +#region Private Properties private AxICAClient _ICAClient; private ConnectionInfo _Info; - #endregion +#endregion - #region Public Methods +#region Public Methods public ProtocolICA() { try { - this.Control = new AxICAClient(); + Control = new AxICAClient(); } catch (Exception ex) { @@ -70,21 +71,21 @@ namespace mRemoteNG.Connection.Protocol.ICA try { - _ICAClient = (AxICAClient)this.Control; - _Info = this.InterfaceControl.Info; + _ICAClient = (AxICAClient)Control; + _Info = InterfaceControl.Info; _ICAClient.CreateControl(); - while (!this._ICAClient.Created) + while (!_ICAClient.Created) { Thread.Sleep(10); - System.Windows.Forms.Application.DoEvents(); + Application.DoEvents(); } _ICAClient.Address = _Info.Hostname; - this.SetCredentials(); - this.SetResolution(); - this.SetColors(); - this.SetSecurity(); + SetCredentials(); + SetResolution(); + SetColors(); + SetSecurity(); //Disable hotkeys for international users _ICAClient.Hotkey1Shift = null; @@ -123,7 +124,7 @@ namespace mRemoteNG.Connection.Protocol.ICA public override bool Connect() { - this.SetEventHandlers(); + SetEventHandlers(); try { @@ -137,31 +138,31 @@ namespace mRemoteNG.Connection.Protocol.ICA return false; } } - #endregion +#endregion - #region Private Methods +#region Private Methods private void SetCredentials() { try { - if (((int)Force & (int)Connection.ConnectionInfo.Force.NoCredentials) == (int)Connection.ConnectionInfo.Force.NoCredentials) + if (((int)Force & (int)ConnectionInfo.Force.NoCredentials) == (int)ConnectionInfo.Force.NoCredentials) { return ; } - string _user = this._Info.Username; - string _pass = this._Info.Password; - string _dom = this._Info.Domain; + string _user = _Info.Username; + string _pass = _Info.Password; + string _dom = _Info.Domain; if (string.IsNullOrEmpty(_user)) { - if ((string) mRemoteNG.Settings.Default.EmptyCredentials == "windows") + if (Settings.Default.EmptyCredentials == "windows") { _ICAClient.Username = Environment.UserName; } - else if ((string) mRemoteNG.Settings.Default.EmptyCredentials == "custom") + else if (Settings.Default.EmptyCredentials == "custom") { - _ICAClient.Username = mRemoteNG.Settings.Default.DefaultUsername; + _ICAClient.Username = Settings.Default.DefaultUsername; } } else @@ -171,9 +172,9 @@ namespace mRemoteNG.Connection.Protocol.ICA if (string.IsNullOrEmpty(_pass)) { - if ((string) mRemoteNG.Settings.Default.EmptyCredentials == "custom") + if (Settings.Default.EmptyCredentials == "custom") { - if (mRemoteNG.Settings.Default.DefaultPassword != "") + if (Settings.Default.DefaultPassword != "") { var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); _ICAClient.SetProp("ClearPassword", cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, GeneralAppInfo.EncryptionKey)); @@ -187,13 +188,13 @@ namespace mRemoteNG.Connection.Protocol.ICA if (string.IsNullOrEmpty(_dom)) { - if ((string) mRemoteNG.Settings.Default.EmptyCredentials == "windows") + if (Settings.Default.EmptyCredentials == "windows") { _ICAClient.Domain = Environment.UserDomainName; } - else if ((string) mRemoteNG.Settings.Default.EmptyCredentials == "custom") + else if (Settings.Default.EmptyCredentials == "custom") { - _ICAClient.Domain = mRemoteNG.Settings.Default.DefaultDomain; + _ICAClient.Domain = Settings.Default.DefaultDomain; } } else @@ -211,7 +212,7 @@ namespace mRemoteNG.Connection.Protocol.ICA { try { - if ((this.Force & Connection.ConnectionInfo.Force.Fullscreen) == Connection.ConnectionInfo.Force.Fullscreen) + if ((Force & ConnectionInfo.Force.Fullscreen) == ConnectionInfo.Force.Fullscreen) { _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, Screen.FromControl(frmMain.Default).Bounds.Width, Screen.FromControl(frmMain.Default).Bounds.Height, 0); _ICAClient.FullScreenWindow(); @@ -219,15 +220,15 @@ namespace mRemoteNG.Connection.Protocol.ICA return; } - if (this.InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.FitToWindow) + if (InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.FitToWindow) { - _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, this.InterfaceControl.Size.Width, this.InterfaceControl.Size.Height, 0); + _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0); } - else if (this.InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.SmartSize) + else if (InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.SmartSize) { - _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, this.InterfaceControl.Size.Width, this.InterfaceControl.Size.Height, 0); + _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, InterfaceControl.Size.Width, InterfaceControl.Size.Height, 0); } - else if (this.InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.Fullscreen) + else if (InterfaceControl.Info.Resolution == ProtocolRDP.RDPResolutions.Fullscreen) { _ICAClient.SetWindowSize(WFICALib.ICAWindowType.WindowTypeClient, Screen.FromControl(frmMain.Default).Bounds.Width, Screen.FromControl(frmMain.Default).Bounds.Height, 0); _ICAClient.FullScreenWindow(); @@ -290,39 +291,39 @@ namespace mRemoteNG.Connection.Protocol.ICA { try { - _ICAClient.OnConnecting += new System.EventHandler(ICAEvent_OnConnecting); - _ICAClient.OnConnect += new System.EventHandler(ICAEvent_OnConnected); - _ICAClient.OnConnectFailed += new System.EventHandler(ICAEvent_OnConnectFailed); - _ICAClient.OnDisconnect += new System.EventHandler(ICAEvent_OnDisconnect); + _ICAClient.OnConnecting += new EventHandler(ICAEvent_OnConnecting); + _ICAClient.OnConnect += new EventHandler(ICAEvent_OnConnected); + _ICAClient.OnConnectFailed += new EventHandler(ICAEvent_OnConnectFailed); + _ICAClient.OnDisconnect += new EventHandler(ICAEvent_OnDisconnect); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strIcaSetEventHandlersFailed + Environment.NewLine + ex.Message, true); } } - #endregion +#endregion - #region Private Events & Handlers - private void ICAEvent_OnConnecting(object sender, System.EventArgs e) +#region Private Events & Handlers + private void ICAEvent_OnConnecting(object sender, EventArgs e) { - base.Event_Connecting(this); + Event_Connecting(this); } - private void ICAEvent_OnConnected(object sender, System.EventArgs e) + private void ICAEvent_OnConnected(object sender, EventArgs e) { - base.Event_Connected(this); + Event_Connected(this); } - private void ICAEvent_OnConnectFailed(object sender, System.EventArgs e) + private void ICAEvent_OnConnectFailed(object sender, EventArgs e) { - base.Event_ErrorOccured(this, e.ToString()); + Event_ErrorOccured(this, e.ToString()); } - private void ICAEvent_OnDisconnect(object sender, System.EventArgs e) + private void ICAEvent_OnDisconnect(object sender, EventArgs e) { - base.Event_Disconnected(this, e.ToString()); + Event_Disconnected(this, e.ToString()); - if (mRemoteNG.Settings.Default.ReconnectOnDisconnect) + if (Settings.Default.ReconnectOnDisconnect) { ReconnectGroup = new ReconnectGroup(); //this.Load += ReconnectGroup_Load; @@ -334,12 +335,12 @@ namespace mRemoteNG.Connection.Protocol.ICA } else { - base.Close(); + Close(); } } - #endregion +#endregion - #region Reconnect Stuff +#region Reconnect Stuff public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { bool srvReady = Scanner.IsPortOpen(_Info.Hostname, Convert.ToString(_Info.Port)); @@ -353,9 +354,9 @@ namespace mRemoteNG.Connection.Protocol.ICA _ICAClient.Connect(); } } - #endregion +#endregion - #region Enums +#region Enums public enum Defaults { Port = 1494, @@ -375,6 +376,6 @@ namespace mRemoteNG.Connection.Protocol.ICA [LocalizedAttributes.LocalizedDescription("strEnc128Bit")] Encr128Bit = 128 } - #endregion +#endregion } } \ No newline at end of file diff --git a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs index 767155e0..3bd9593a 100644 --- a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs +++ b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Drawing; using System.Threading; using System.Windows.Forms; -using mRemoteNG.My; namespace mRemoteNG.Connection.Protocol diff --git a/mRemoteV1/Connection/Protocol/ProtocolBase.cs b/mRemoteV1/Connection/Protocol/ProtocolBase.cs index 8d0039b6..dfb80df6 100644 --- a/mRemoteV1/Connection/Protocol/ProtocolBase.cs +++ b/mRemoteV1/Connection/Protocol/ProtocolBase.cs @@ -2,6 +2,7 @@ using System; using System.Windows.Forms; using System.Threading; using mRemoteNG.App; +using mRemoteNG.Tools; namespace mRemoteNG.Connection.Protocol @@ -54,12 +55,22 @@ namespace mRemoteNG.Connection.Protocol public readonly System.Timers.Timer tmrReconnect = new System.Timers.Timer(2000); protected ReconnectGroup ReconnectGroup; + + protected ProtocolBase(string name) + { + Name = name; + } + + public ProtocolBase() + { + } + #endregion - + #region Methods //public abstract int GetDefaultPort(); - public virtual void Focus() + public virtual void Focus() { try { diff --git a/mRemoteV1/Connection/Protocol/ProtocolFactory.cs b/mRemoteV1/Connection/Protocol/ProtocolFactory.cs index 4fa367be..df91c2d3 100644 --- a/mRemoteV1/Connection/Protocol/ProtocolFactory.cs +++ b/mRemoteV1/Connection/Protocol/ProtocolFactory.cs @@ -7,19 +7,11 @@ using mRemoteNG.Connection.Protocol.SSH; using mRemoteNG.Connection.Protocol.Telnet; using mRemoteNG.Connection.Protocol.VNC; using System; -using System.Collections.Generic; -using System.Text; -using mRemoteNG.My; namespace mRemoteNG.Connection.Protocol { public class ProtocolFactory { - public ProtocolFactory() - { - - } - public ProtocolBase CreateProtocol(ConnectionInfo connectionInfo) { ProtocolBase newProtocol = default(ProtocolBase); diff --git a/mRemoteV1/Connection/Protocol/PuttyBase.cs b/mRemoteV1/Connection/Protocol/PuttyBase.cs index d7db43d0..73e2582a 100644 --- a/mRemoteV1/Connection/Protocol/PuttyBase.cs +++ b/mRemoteV1/Connection/Protocol/PuttyBase.cs @@ -7,7 +7,6 @@ using System.Drawing; using System.Threading; using System.Windows.Forms; using mRemoteNG.App.Info; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; @@ -40,7 +39,7 @@ namespace mRemoteNG.Connection.Protocol } #endregion - public PuttyBase() + public PuttyBase() : base() { } diff --git a/mRemoteV1/Connection/Protocol/VNC/VNCEnum.cs b/mRemoteV1/Connection/Protocol/VNC/VNCEnum.cs index 4dd4cc6b..c7267613 100644 --- a/mRemoteV1/Connection/Protocol/VNC/VNCEnum.cs +++ b/mRemoteV1/Connection/Protocol/VNC/VNCEnum.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; +using System.ComponentModel; using mRemoteNG.Tools; namespace mRemoteNG.Connection.Protocol.VNC diff --git a/mRemoteV1/Messages/MessageClassEnum.cs b/mRemoteV1/Messages/MessageClassEnum.cs index 38d1069c..53a49531 100644 --- a/mRemoteV1/Messages/MessageClassEnum.cs +++ b/mRemoteV1/Messages/MessageClassEnum.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace mRemoteNG.Messages +namespace mRemoteNG.Messages { public enum MessageClass { diff --git a/mRemoteV1/Properties/AssemblyInfo.cs b/mRemoteV1/Properties/AssemblyInfo.cs index 1b4a5946..f28dff03 100644 --- a/mRemoteV1/Properties/AssemblyInfo.cs +++ b/mRemoteV1/Properties/AssemblyInfo.cs @@ -1,4 +1,3 @@ -using System; using System.Reflection; using System.Resources; using System.Runtime.InteropServices; diff --git a/mRemoteV1/Themes/ThemeManager.cs b/mRemoteV1/Themes/ThemeManager.cs index ebd6cd92..e8bf7c68 100644 --- a/mRemoteV1/Themes/ThemeManager.cs +++ b/mRemoteV1/Themes/ThemeManager.cs @@ -1,4 +1,3 @@ -using mRemoteNG.My; using System.Collections.Generic; using System.ComponentModel; using System.IO; @@ -9,9 +8,9 @@ namespace mRemoteNG.Themes public class ThemeManager { #region Private Variables - private static readonly ThemeInfo _defaultTheme = new ThemeInfo(Language.strDefaultTheme); + private static ThemeInfo _activeTheme; - private static bool _activeThemeHandlerSet = false; + private static bool _activeThemeHandlerSet; #endregion #region Public Methods @@ -93,11 +92,8 @@ namespace mRemoteNG.Themes #endregion #region Properties - public static ThemeInfo DefaultTheme - { - get { return _defaultTheme; } - } - + public static ThemeInfo DefaultTheme { get; } = new ThemeInfo(Language.strDefaultTheme); + public static ThemeInfo ActiveTheme { get @@ -123,7 +119,7 @@ namespace mRemoteNG.Themes if (_activeThemeHandlerSet) { - _activeTheme.PropertyChanged -= NotifyThemeChanged; + if (_activeTheme != null) _activeTheme.PropertyChanged -= NotifyThemeChanged; } _activeTheme = value; diff --git a/mRemoteV1/Tools/CmdArgumentsInterpreter.cs b/mRemoteV1/Tools/CmdArgumentsInterpreter.cs index b1b5acb2..1de952ef 100644 --- a/mRemoteV1/Tools/CmdArgumentsInterpreter.cs +++ b/mRemoteV1/Tools/CmdArgumentsInterpreter.cs @@ -1,8 +1,6 @@ using mRemoteNG.App; using System; -using System.Collections.Generic; using System.Collections.Specialized; -using System.Text; using System.Text.RegularExpressions; namespace mRemoteNG.Tools @@ -22,21 +20,14 @@ namespace mRemoteNG.Tools private StringDictionary Parameters; // Retrieve a parameter value if it exists - public string this[string Param] - { - get - { - return (Parameters[Param]); - } - } + public string this[string Param] => (Parameters[Param]); public CmdArgumentsInterpreter(string[] Args) { Parameters = new StringDictionary(); - Regex Spliter = new Regex("^-{1,2}|^/|=|:", (RegexOptions)(RegexOptions.IgnoreCase | RegexOptions.Compiled)); - Regex Remover = new Regex("^[\'\"]?(.*?)[\'\"]?$", (RegexOptions)(RegexOptions.IgnoreCase | RegexOptions.Compiled)); + Regex Spliter = new Regex("^-{1,2}|^/|=|:", RegexOptions.IgnoreCase | RegexOptions.Compiled); + Regex Remover = new Regex("^[\'\"]?(.*?)[\'\"]?$", RegexOptions.IgnoreCase | RegexOptions.Compiled); string Parameter = null; - string[] Parts = null; // Valid parameters forms: // {-,/,--}param{ ,=,:}((",')value(",')) @@ -47,7 +38,7 @@ namespace mRemoteNG.Tools foreach (string Txt in Args) { // Look for new parameters (-,/ or --) and a possible enclosed value (=,:) - Parts = Spliter.Split(Txt, 3); + var Parts = Spliter.Split(Txt, 3); switch (Parts.Length) { case 1: diff --git a/mRemoteV1/Tools/ExternalToolsTypeConverter.cs b/mRemoteV1/Tools/ExternalToolsTypeConverter.cs index 5fb5cb0b..af7379c8 100644 --- a/mRemoteV1/Tools/ExternalToolsTypeConverter.cs +++ b/mRemoteV1/Tools/ExternalToolsTypeConverter.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; -using System.Text; namespace mRemoteNG.Tools { diff --git a/mRemoteV1/Tools/MiscTools.cs b/mRemoteV1/Tools/MiscTools.cs index e22338d0..9e9d9799 100644 --- a/mRemoteV1/Tools/MiscTools.cs +++ b/mRemoteV1/Tools/MiscTools.cs @@ -7,9 +7,9 @@ using System.Reflection; using System.Security; using System.Windows.Forms; using mRemoteNG.App; -using mRemoteNG.Forms; using mRemoteNG.Messages; using mRemoteNG.Security; +using mRemoteNG.UI.Forms; using mRemoteNG.UI.Window; using static System.String; diff --git a/mRemoteV1/Tools/ReconnectGroup.Designer.cs b/mRemoteV1/Tools/ReconnectGroup.Designer.cs index 5b23e0c7..309e469a 100644 --- a/mRemoteV1/Tools/ReconnectGroup.Designer.cs +++ b/mRemoteV1/Tools/ReconnectGroup.Designer.cs @@ -1,4 +1,4 @@ -namespace mRemoteNG +namespace mRemoteNG.Tools { public partial class ReconnectGroup : System.Windows.Forms.UserControl { diff --git a/mRemoteV1/Tools/ReconnectGroup.cs b/mRemoteV1/Tools/ReconnectGroup.cs index b8e7384a..43f557eb 100644 --- a/mRemoteV1/Tools/ReconnectGroup.cs +++ b/mRemoteV1/Tools/ReconnectGroup.cs @@ -1,8 +1,6 @@ using System.Drawing; -using mRemoteNG.My; - -namespace mRemoteNG +namespace mRemoteNG.Tools { public partial class ReconnectGroup { @@ -19,16 +17,9 @@ namespace mRemoteNG } set { - if (value == true) - { - SetStatusImage(Resources.HostStatus_On); - } - else - { - SetStatusImage(Resources.HostStatus_Off); - } - - _ServerReady = value; + SetStatusImage(value ? Resources.HostStatus_On : Resources.HostStatus_Off); + + _ServerReady = value; } } @@ -37,8 +28,8 @@ namespace mRemoteNG { if (pbServerStatus.InvokeRequired) { - SetStatusImageCB d = new SetStatusImageCB(SetStatusImage); - ParentForm.Invoke(d, new object[] {Img}); + SetStatusImageCB d = new SetStatusImageCB(SetStatusImage); + ParentForm?.Invoke(d, new object[] {Img}); } else { @@ -70,8 +61,8 @@ namespace mRemoteNG { if (chkReconnectWhenReady.InvokeRequired) { - SetCheckboxCB d = new SetCheckboxCB(SetCheckbox); - ParentForm.Invoke(d, new object[] {Val}); + SetCheckboxCB d = new SetCheckboxCB(SetCheckbox); + ParentForm?.Invoke(d, new object[] {Val}); } else { @@ -125,8 +116,8 @@ namespace mRemoteNG { if (this.InvokeRequired) { - DisposeReconnectGroupCB d = new DisposeReconnectGroupCB(DisposeReconnectGroup); - ParentForm.Invoke(d); + DisposeReconnectGroupCB d = new DisposeReconnectGroupCB(DisposeReconnectGroup); + ParentForm?.Invoke(d); } else { diff --git a/mRemoteV1/Tools/Sorting/Sortable.cs b/mRemoteV1/Tools/Sorting/Sortable.cs deleted file mode 100644 index 517a7abb..00000000 --- a/mRemoteV1/Tools/Sorting/Sortable.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace mRemoteNG.Tools.Sorting -{ - public interface Sortable - { - void Sort(); - } -} \ No newline at end of file diff --git a/mRemoteV1/Tools/Sorting/TreeNodeSorter.cs b/mRemoteV1/Tools/Sorting/TreeNodeSorter.cs index ad1100d1..946bdec4 100644 --- a/mRemoteV1/Tools/Sorting/TreeNodeSorter.cs +++ b/mRemoteV1/Tools/Sorting/TreeNodeSorter.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Windows.Forms; namespace mRemoteNG.Tools.Sorting @@ -20,9 +21,9 @@ namespace mRemoteNG.Tools.Sorting switch (Sorting) { case SortOrder.Ascending: - return string.Compare(tx.Text, ty.Text); + return String.CompareOrdinal(tx.Text, ty.Text); case SortOrder.Descending: - return string.Compare(ty.Text, tx.Text); + return String.CompareOrdinal(ty.Text, tx.Text); default: return 0; } diff --git a/mRemoteV1/Tools/Tools.LocalizedAttributes.cs b/mRemoteV1/Tools/Tools.LocalizedAttributes.cs index 4931b1eb..539a14e6 100644 --- a/mRemoteV1/Tools/Tools.LocalizedAttributes.cs +++ b/mRemoteV1/Tools/Tools.LocalizedAttributes.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using mRemoteNG.My; namespace mRemoteNG.Tools @@ -15,20 +14,13 @@ namespace mRemoteNG.Tools public LocalizedCategoryAttribute(string value, int Order = 1) : base(value) { - if (Order > LocalizedCategoryAttribute.MaxOrder) - { - this.Order = LocalizedCategoryAttribute.MaxOrder; - } - else - { - this.Order = Order; - } + this.Order = Order > MaxOrder ? MaxOrder : Order; } protected override string GetLocalizedString(string value) { string OrderPrefix = ""; - for (int x = 0; x <= LocalizedCategoryAttribute.MaxOrder - this.Order; x++) + for (int x = 0; x <= MaxOrder - Order; x++) { OrderPrefix += Convert.ToString("\t"); } @@ -45,17 +37,17 @@ namespace mRemoteNG.Tools public LocalizedDisplayNameAttribute(string value) : base(value) { - this.Localized = false; + Localized = false; } public override string DisplayName { get { - if (!this.Localized) + if (!Localized) { - this.Localized = true; - this.DisplayNameValue = Language.ResourceManager.GetString(this.DisplayNameValue); + Localized = true; + DisplayNameValue = Language.ResourceManager.GetString(DisplayNameValue); } return base.DisplayName; @@ -69,17 +61,17 @@ namespace mRemoteNG.Tools private bool Localized; public LocalizedDescriptionAttribute(string value) : base(value) { - this.Localized = false; + Localized = false; } public override string Description { get { - if (!this.Localized) + if (!Localized) { - this.Localized = true; - this.DescriptionValue = Language.ResourceManager.GetString(this.DescriptionValue); + Localized = true; + DescriptionValue = Language.ResourceManager.GetString(DescriptionValue); } return base.Description; @@ -96,13 +88,7 @@ namespace mRemoteNG.Tools // This allows localized attributes in a derived class to override a matching // non-localized attribute inherited from its base class - public override object TypeId - { - get - { - return typeof(DefaultValueAttribute); - } - } + public override object TypeId => typeof(DefaultValueAttribute); } #region Special localization - with String.Format @@ -113,17 +99,17 @@ namespace mRemoteNG.Tools public LocalizedDisplayNameInheritAttribute(string value) : base(value) { - this.Localized = false; + Localized = false; } public override string DisplayName { get { - if (!this.Localized) + if (!Localized) { - this.Localized = true; - this.DisplayNameValue = string.Format(Language.strFormatInherit, Language.ResourceManager.GetString(this.DisplayNameValue)); + Localized = true; + DisplayNameValue = string.Format(Language.strFormatInherit, Language.ResourceManager.GetString(DisplayNameValue)); } return base.DisplayName; @@ -138,17 +124,17 @@ namespace mRemoteNG.Tools public LocalizedDescriptionInheritAttribute(string value) : base(value) { - this.Localized = false; + Localized = false; } public override string Description { get { - if (!this.Localized) + if (!Localized) { - this.Localized = true; - this.DescriptionValue = string.Format(Language.strFormatInheritDescription, Language.ResourceManager.GetString(this.DescriptionValue)); + Localized = true; + DescriptionValue = string.Format(Language.strFormatInheritDescription, Language.ResourceManager.GetString(DescriptionValue)); } return base.Description; diff --git a/mRemoteV1/Tree/Root/PuttySessionsNodeInfo.cs b/mRemoteV1/Tree/Root/PuttySessionsNodeInfo.cs index 656c365f..18725164 100644 --- a/mRemoteV1/Tree/Root/PuttySessionsNodeInfo.cs +++ b/mRemoteV1/Tree/Root/PuttySessionsNodeInfo.cs @@ -1,7 +1,5 @@ -using mRemoteNG.My; using mRemoteNG.Tools; using mRemoteNG.Tree.Root; -using System.Windows.Forms; namespace mRemoteNG.Root.PuttySessions @@ -34,14 +32,14 @@ namespace mRemoteNG.Root.PuttySessions { TreeNode.Text = value; } - mRemoteNG.Settings.Default.PuttySavedSessionsName = value; + Settings.Default.PuttySavedSessionsName = value; } } - [LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1), + [LocalizedAttributes.LocalizedCategory("strCategoryDisplay"), LocalizedAttributes.LocalizedDisplayName("strPropertyNamePanel"), LocalizedAttributes.LocalizedDescription("strPropertyDescriptionPanel")] - public string Panel + public override string Panel { get { return _panel; } set @@ -51,7 +49,7 @@ namespace mRemoteNG.Root.PuttySessions return ; } _panel = value; - mRemoteNG.Settings.Default.PuttySavedSessionsPanel = value; + Settings.Default.PuttySavedSessionsPanel = value; } } #endregion diff --git a/mRemoteV1/Tree/Root/RootNodeInfo.cs b/mRemoteV1/Tree/Root/RootNodeInfo.cs index fff20358..31119418 100644 --- a/mRemoteV1/Tree/Root/RootNodeInfo.cs +++ b/mRemoteV1/Tree/Root/RootNodeInfo.cs @@ -1,6 +1,5 @@ using mRemoteNG.Tools; using System.ComponentModel; -using System.Windows.Forms; using mRemoteNG.Container; @@ -19,7 +18,7 @@ namespace mRemoteNG.Tree.Root } #region Public Properties - [LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1), + [LocalizedAttributes.LocalizedCategory("strCategoryDisplay"), Browsable(true), LocalizedAttributes.LocalizedDefaultValue("strConnections"), LocalizedAttributes.LocalizedDisplayName("strPropertyNameName"), @@ -42,7 +41,7 @@ namespace mRemoteNG.Tree.Root } } - [LocalizedAttributes.LocalizedCategory("strCategoryDisplay", 1), + [LocalizedAttributes.LocalizedCategory("strCategoryDisplay"), Browsable(true), LocalizedAttributes.LocalizedDisplayName("strPasswordProtect"), TypeConverter(typeof(Tools.MiscTools.YesNoTypeConverter))] diff --git a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs index 5071fe81..9e70680c 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs @@ -1,7 +1,6 @@ using System; using System.Windows.Forms; using mRemoteNG.App; -using mRemoteNG.My; namespace mRemoteNG.UI.Forms.OptionsPages { diff --git a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs index c1714616..a028f4e5 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs @@ -2,8 +2,6 @@ using System; using mRemoteNG.App; using mRemoteNG.App.Info; using mRemoteNG.Config.Connections; -using mRemoteNG.My; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; namespace mRemoteNG.UI.Forms.OptionsPages diff --git a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs index 6cce36ab..5b1d9984 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs @@ -1,5 +1,4 @@ using System; -using mRemoteNG.My; namespace mRemoteNG.UI.Forms.OptionsPages { diff --git a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs index 15e614c4..29961939 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs @@ -1,5 +1,4 @@ using System; -using mRemoteNG.My; namespace mRemoteNG.UI.Forms.OptionsPages { diff --git a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs index eaeb7fa3..b1123855 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs @@ -1,7 +1,6 @@ using System; using System.ComponentModel; using System.Windows.Forms; -using mRemoteNG.My; using mRemoteNG.Themes; namespace mRemoteNG.UI.Forms.OptionsPages @@ -67,7 +66,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages public void cboTheme_DropDown(object sender, EventArgs e) { - if (ThemeManager.ActiveTheme == ThemeManager.DefaultTheme) + if (Equals(ThemeManager.ActiveTheme, ThemeManager.DefaultTheme)) { return; } @@ -81,7 +80,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages cboTheme.SelectedItem = ThemeManager.DefaultTheme; } - if (cboTheme.SelectedItem == ThemeManager.DefaultTheme) + if (Equals(cboTheme.SelectedItem, ThemeManager.DefaultTheme)) { cboTheme.DropDownStyle = ComboBoxStyle.DropDownList; btnThemeDelete.Enabled = false; diff --git a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs index 38aa72fb..aa2e6fa7 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs @@ -4,8 +4,6 @@ using System.Windows.Forms; using mRemoteNG.App; using mRemoteNG.App.Info; using mRemoteNG.App.Update; -using mRemoteNG.My; -using mRemoteNG.Security; using mRemoteNG.Security.SymmetricEncryption; using mRemoteNG.Tools; using mRemoteNG.UI.TaskDialog; diff --git a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs index e7bf9ab8..424384e1 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs @@ -1,8 +1,6 @@ -using mRemoteNG.My; - -namespace mRemoteNG.Forms +namespace mRemoteNG.UI.Forms { public partial class PasswordForm : System.Windows.Forms.Form @@ -163,8 +161,8 @@ namespace mRemoteNG.Forms this.PerformLayout(); } - private Controls.TextBox txtPassword; - private Controls.TextBox txtVerify; + private mRemoteNG.Controls.TextBox txtPassword; + private mRemoteNG.Controls.TextBox txtVerify; private System.Windows.Forms.Label lblPassword; private System.Windows.Forms.Label lblVerify; private System.Windows.Forms.Button btnOK; diff --git a/mRemoteV1/UI/Forms/PasswordForm.cs b/mRemoteV1/UI/Forms/PasswordForm.cs index 585fe23e..c96445aa 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.cs @@ -1,9 +1,7 @@ using System; using System.Windows.Forms; -using mRemoteNG.My; - -namespace mRemoteNG.Forms +namespace mRemoteNG.UI.Forms { public partial class PasswordForm { diff --git a/mRemoteV1/UI/Forms/SplashPage.Designer.cs b/mRemoteV1/UI/Forms/SplashPage.Designer.cs deleted file mode 100644 index c7cf44c7..00000000 --- a/mRemoteV1/UI/Forms/SplashPage.Designer.cs +++ /dev/null @@ -1,61 +0,0 @@ -using mRemoteNG.My; - -namespace mRemoteNG.UI.Forms -{ - partial class SplashPage - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // SplashPage - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackgroundImage = Resources.Logo; - this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.ClientSize = new System.Drawing.Size(492, 128); - this.ControlBox = false; - this.DoubleBuffered = true; - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(492, 128); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(492, 128); - this.Name = "SplashPage"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "SplashPage"; - this.TopMost = true; - this.ResumeLayout(false); - - } - - #endregion - - } -} \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/SplashPage.cs b/mRemoteV1/UI/Forms/SplashPage.cs deleted file mode 100644 index 5d0540f0..00000000 --- a/mRemoteV1/UI/Forms/SplashPage.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace mRemoteNG.UI.Forms -{ - public partial class SplashPage : Form - { - BackgroundWorker splashPageWorker; - - public SplashPage() - { - InitializeComponent(); - InitializeBackgroundWorker(); - } - - public void InitializeBackgroundWorker() - { - splashPageWorker = new BackgroundWorker(); - } - } -} diff --git a/mRemoteV1/UI/Forms/SplashPage.resx b/mRemoteV1/UI/Forms/SplashPage.resx deleted file mode 100644 index 7080a7d1..00000000 --- a/mRemoteV1/UI/Forms/SplashPage.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/mRemoteV1/UI/TaskDialog/CommandButton.cs b/mRemoteV1/UI/TaskDialog/CommandButton.cs index 1817e433..babdedeb 100644 --- a/mRemoteV1/UI/TaskDialog/CommandButton.cs +++ b/mRemoteV1/UI/TaskDialog/CommandButton.cs @@ -1,10 +1,7 @@ using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Drawing; using System.Drawing.Drawing2D; -using System.Text; using System.Windows.Forms; namespace mRemoteNG.UI.TaskDialog @@ -14,8 +11,8 @@ namespace mRemoteNG.UI.TaskDialog //-------------------------------------------------------------------------------- #region PRIVATE MEMBERS //-------------------------------------------------------------------------------- - Image imgArrow1 = null; - Image imgArrow2 = null; + Image imgArrow1; + Image imgArrow2; const int LEFT_MARGIN = 10; const int TOP_MARGIN = 10; @@ -37,8 +34,8 @@ namespace mRemoteNG.UI.TaskDialog { base.Text = value; if (m_autoHeight) - this.Height = GetBestHeight(); - this.Invalidate(); + Height = GetBestHeight(); + Invalidate(); } } @@ -51,7 +48,7 @@ namespace mRemoteNG.UI.TaskDialog [Browsable(true)] [Category("Behavior")] [DefaultValue(true)] - public bool AutoHeight { get { return m_autoHeight; } set { m_autoHeight = value; if (m_autoHeight) this.Invalidate(); } } + public bool AutoHeight { get { return m_autoHeight; } set { m_autoHeight = value; if (m_autoHeight) Invalidate(); } } #endregion @@ -61,8 +58,8 @@ namespace mRemoteNG.UI.TaskDialog public CommandButton() { InitializeComponent(); - base.Font = new Font("Segoe UI", 11.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)0); - m_smallFont = new Font("Segoe UI", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)0); + Font = new Font("Segoe UI", 11.75F, FontStyle.Regular, GraphicsUnit.Point, 0); + m_smallFont = new Font("Segoe UI", 8F, FontStyle.Regular, GraphicsUnit.Point, 0); } #endregion @@ -81,16 +78,16 @@ namespace mRemoteNG.UI.TaskDialog //-------------------------------------------------------------------------------- string GetLargeText() { - string[] lines = this.Text.Split(new char[] { '\n' }); + string[] lines = Text.Split(new char[] { '\n' }); return lines[0]; } string GetSmallText() { - if (this.Text.IndexOf('\n') < 0) + if (Text.IndexOf('\n') < 0) return ""; - string s = this.Text; + string s = Text; string[] lines = s.Split(new char[] { '\n' }); s = ""; for (int i = 1; i < lines.Length; i++) @@ -101,9 +98,9 @@ namespace mRemoteNG.UI.TaskDialog SizeF GetLargeTextSizeF() { int x = LEFT_MARGIN + ARROW_WIDTH + 5; - SizeF mzSize = new SizeF(this.Width - x - LEFT_MARGIN, 5000.0F); // presume RIGHT_MARGIN = LEFT_MARGIN - Graphics g = Graphics.FromHwnd(this.Handle); - SizeF textSize = g.MeasureString(GetLargeText(), base.Font, mzSize); + SizeF mzSize = new SizeF(Width - x - LEFT_MARGIN, 5000.0F); // presume RIGHT_MARGIN = LEFT_MARGIN + Graphics g = Graphics.FromHwnd(Handle); + SizeF textSize = g.MeasureString(GetLargeText(), Font, mzSize); return textSize; } @@ -112,8 +109,8 @@ namespace mRemoteNG.UI.TaskDialog string s = GetSmallText(); if (s == "") return new SizeF(0, 0); int x = LEFT_MARGIN + ARROW_WIDTH + 8; // <- indent small text slightly more - SizeF mzSize = new SizeF(this.Width - x - LEFT_MARGIN, 5000.0F); // presume RIGHT_MARGIN = LEFT_MARGIN - Graphics g = Graphics.FromHwnd(this.Handle); + SizeF mzSize = new SizeF(Width - x - LEFT_MARGIN, 5000.0F); // presume RIGHT_MARGIN = LEFT_MARGIN + Graphics g = Graphics.FromHwnd(Handle); SizeF textSize = g.MeasureString(s, m_smallFont, mzSize); return textSize; } @@ -149,7 +146,7 @@ namespace mRemoteNG.UI.TaskDialog { case eButtonState.Normal: e.Graphics.FillRectangle(Brushes.White, newRect); - if (base.Focused) + if (Focused) e.Graphics.DrawRectangle(new Pen(Color.SkyBlue, 1), newRect); else e.Graphics.DrawRectangle(new Pen(Color.White, 1), newRect); @@ -180,12 +177,12 @@ namespace mRemoteNG.UI.TaskDialog text_color = Color.DarkBlue; } - string largetext = this.GetLargeText(); - string smalltext = this.GetSmallText(); + string largetext = GetLargeText(); + string smalltext = GetSmallText(); SizeF szL = GetLargeTextSizeF(); //e.Graphics.DrawString(largetext, base.Font, new SolidBrush(text_color), new RectangleF(new PointF(LEFT_MARGIN + imgArrow1.Width + 5, TOP_MARGIN), szL)); - TextRenderer.DrawText(e.Graphics, largetext, base.Font, new Rectangle(LEFT_MARGIN + imgArrow1.Width + 5, TOP_MARGIN, (int)szL.Width, (int)szL.Height), text_color, TextFormatFlags.Default); + TextRenderer.DrawText(e.Graphics, largetext, Font, new Rectangle(LEFT_MARGIN + imgArrow1.Width + 5, TOP_MARGIN, (int)szL.Width, (int)szL.Height), text_color, TextFormatFlags.Default); if (smalltext != "") { @@ -193,38 +190,38 @@ namespace mRemoteNG.UI.TaskDialog e.Graphics.DrawString(smalltext, m_smallFont, new SolidBrush(text_color), new RectangleF(new PointF(LEFT_MARGIN + imgArrow1.Width + 8, TOP_MARGIN + (int)szL.Height), szS)); } - e.Graphics.DrawImage(img, new Point(LEFT_MARGIN, TOP_MARGIN + (int)(szL.Height / 2) - (int)(img.Height / 2))); + e.Graphics.DrawImage(img, new Point(LEFT_MARGIN, TOP_MARGIN + (int)(szL.Height / 2) - img.Height / 2)); } //-------------------------------------------------------------------------------- - protected override void OnMouseLeave(System.EventArgs e) + protected override void OnMouseLeave(EventArgs e) { m_State = eButtonState.Normal; - this.Invalidate(); + Invalidate(); base.OnMouseLeave(e); } //-------------------------------------------------------------------------------- - protected override void OnMouseEnter(System.EventArgs e) + protected override void OnMouseEnter(EventArgs e) { m_State = eButtonState.MouseOver; - this.Invalidate(); + Invalidate(); base.OnMouseEnter(e); } //-------------------------------------------------------------------------------- - protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) + protected override void OnMouseUp(MouseEventArgs e) { m_State = eButtonState.MouseOver; - this.Invalidate(); + Invalidate(); base.OnMouseUp(e); } //-------------------------------------------------------------------------------- - protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) + protected override void OnMouseDown(MouseEventArgs e) { m_State = eButtonState.Down; - this.Invalidate(); + Invalidate(); base.OnMouseDown(e); } @@ -234,9 +231,9 @@ namespace mRemoteNG.UI.TaskDialog if (m_autoHeight) { int h = GetBestHeight(); - if (this.Height != h) + if (Height != h) { - this.Height = h; + Height = h; return; } } diff --git a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs index b4091750..4ddc5b20 100644 --- a/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs +++ b/mRemoteV1/UI/Window/ActiveDirectoryImportWindow.cs @@ -2,12 +2,11 @@ using System; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using mRemoteNG.App; -using mRemoteNG.My; namespace mRemoteNG.UI.Window { - public partial class ActiveDirectoryImportWindow : BaseWindow + public partial class ActiveDirectoryImportWindow { #region Constructors public ActiveDirectoryImportWindow(DockContent panel) diff --git a/mRemoteV1/UI/Window/AnnouncementWindow.cs b/mRemoteV1/UI/Window/AnnouncementWindow.cs index 73d00185..d3dcce73 100644 --- a/mRemoteV1/UI/Window/AnnouncementWindow.cs +++ b/mRemoteV1/UI/Window/AnnouncementWindow.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; using mRemoteNG.App; using mRemoteNG.App.Update; diff --git a/mRemoteV1/UI/Window/HelpWindow.cs b/mRemoteV1/UI/Window/HelpWindow.cs index b586374b..72ad8fda 100644 --- a/mRemoteV1/UI/Window/HelpWindow.cs +++ b/mRemoteV1/UI/Window/HelpWindow.cs @@ -1,7 +1,6 @@ using System; using System.Windows.Forms; using mRemoteNG.App.Info; -using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; @@ -13,7 +12,7 @@ namespace mRemoteNG.UI.Window #region Form Init internal TreeView tvIndex; internal ImageList imgListHelp; - private System.ComponentModel.Container components = null; + private System.ComponentModel.Container components; internal SplitContainer pnlSplitter; internal Label lblDocName; internal WebBrowser wbHelp; diff --git a/mRemoteV1/UI/Window/PortScanWindow.cs b/mRemoteV1/UI/Window/PortScanWindow.cs index 449924c3..e3b64039 100644 --- a/mRemoteV1/UI/Window/PortScanWindow.cs +++ b/mRemoteV1/UI/Window/PortScanWindow.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System; -using System.Drawing; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; using mRemoteNG.App; diff --git a/mRemoteV1/UI/Window/UpdateWindow.cs b/mRemoteV1/UI/Window/UpdateWindow.cs index cc1d0ffe..e41c40ad 100644 --- a/mRemoteV1/UI/Window/UpdateWindow.cs +++ b/mRemoteV1/UI/Window/UpdateWindow.cs @@ -3,7 +3,6 @@ using System.Drawing; using System.Diagnostics; using System.Windows.Forms; using System.ComponentModel; -using mRemoteNG.My; using WeifenLuo.WinFormsUI.Docking; using System.IO; using mRemoteNG.App; @@ -39,22 +38,22 @@ namespace mRemoteNG.UI.Window btnDownload.Text = Language.strDownloadAndInstall; lblChangeLogLabel.Text = Language.strLabelChangeLog; lblInstalledVersion.Text = Language.strVersion; - lblInstalledVersionLabel.Text = string.Format("{0}:", Language.strCurrentVersion); + lblInstalledVersionLabel.Text = $"{Language.strCurrentVersion}:"; lblLatestVersion.Text = Language.strVersion; - lblLatestVersionLabel.Text = string.Format("{0}:", Language.strAvailableVersion); + lblLatestVersionLabel.Text = $"{Language.strAvailableVersion}:"; } - public void btnCheckForUpdate_Click(System.Object sender, EventArgs e) + public void btnCheckForUpdate_Click(Object sender, EventArgs e) { CheckForUpdate(); } - public void btnDownload_Click(System.Object sender, EventArgs e) + public void btnDownload_Click(Object sender, EventArgs e) { DownloadUpdate(); } - public void pbUpdateImage_Click(System.Object sender, EventArgs e) + public void pbUpdateImage_Click(Object sender, EventArgs e) { Uri linkUri = pbUpdateImage.Tag as Uri; if (linkUri == null || linkUri.IsFile || linkUri.IsUnc || linkUri.IsLoopback) @@ -67,7 +66,7 @@ namespace mRemoteNG.UI.Window #region Private Fields private AppUpdater _appUpdate; - private bool _isUpdateDownloadHandlerDeclared = false; + private bool _isUpdateDownloadHandlerDeclared; #endregion #region Private Methods @@ -177,7 +176,7 @@ namespace mRemoteNG.UI.Window } } - private void GetChangeLogCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + private void GetChangeLogCompleted(object sender, AsyncCompletedEventArgs e) { if (InvokeRequired) { @@ -237,7 +236,7 @@ namespace mRemoteNG.UI.Window prgbDownload.Value = e.ProgressPercentage; } - private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + private void DownloadUpdateCompleted(object sender, AsyncCompletedEventArgs e) { try { @@ -253,10 +252,9 @@ namespace mRemoteNG.UI.Window throw (e.Error); } - if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) + if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath); - return ; } else { diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 8948fbbe..966a5c9f 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -174,7 +174,6 @@ - @@ -363,12 +362,6 @@ - - Form - - - SplashPage.cs - Component @@ -566,9 +559,6 @@ ReconnectGroup.cs Designer - - SplashPage.cs - frmTaskDialog.cs From 5afb9c572ec85ea6cf2f04367928272b8d859f9b Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 11:31:43 -0400 Subject: [PATCH 2/8] code clean up --- .../UI/Forms/OptionsPages/OptionsPage.cs | 2 +- .../UI/Forms/OptionsPages/TabsPanelsPage.cs | 46 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/mRemoteV1/UI/Forms/OptionsPages/OptionsPage.cs b/mRemoteV1/UI/Forms/OptionsPages/OptionsPage.cs index 4583d167..528a9a15 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/OptionsPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/OptionsPage.cs @@ -6,7 +6,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { public class OptionsPage : UserControl { - public OptionsPage() + protected OptionsPage() { //InitializeComponent(); } diff --git a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs index 29961939..e469fa24 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs @@ -38,41 +38,41 @@ namespace mRemoteNG.UI.Forms.OptionsPages { base.SaveSettings(); - chkAlwaysShowPanelTabs.Checked = mRemoteNG.Settings.Default.AlwaysShowPanelTabs; - chkOpenNewTabRightOfSelected.Checked = mRemoteNG.Settings.Default.OpenTabsRightOfSelected; - chkShowLogonInfoOnTabs.Checked = mRemoteNG.Settings.Default.ShowLogonInfoOnTabs; - chkShowProtocolOnTabs.Checked = mRemoteNG.Settings.Default.ShowProtocolOnTabs; - chkIdentifyQuickConnectTabs.Checked = mRemoteNG.Settings.Default.IdentifyQuickConnectTabs; - chkDoubleClickClosesTab.Checked = mRemoteNG.Settings.Default.DoubleClickOnTabClosesIt; - chkAlwaysShowPanelSelectionDlg.Checked = mRemoteNG.Settings.Default.AlwaysShowPanelSelectionDlg; + chkAlwaysShowPanelTabs.Checked = Settings.Default.AlwaysShowPanelTabs; + chkOpenNewTabRightOfSelected.Checked = Settings.Default.OpenTabsRightOfSelected; + chkShowLogonInfoOnTabs.Checked = Settings.Default.ShowLogonInfoOnTabs; + chkShowProtocolOnTabs.Checked = Settings.Default.ShowProtocolOnTabs; + chkIdentifyQuickConnectTabs.Checked = Settings.Default.IdentifyQuickConnectTabs; + chkDoubleClickClosesTab.Checked = Settings.Default.DoubleClickOnTabClosesIt; + chkAlwaysShowPanelSelectionDlg.Checked = Settings.Default.AlwaysShowPanelSelectionDlg; - chkUseOnlyErrorsAndInfosPanel.Checked = mRemoteNG.Settings.Default.ShowNoMessageBoxes; - chkMCInformation.Checked = mRemoteNG.Settings.Default.SwitchToMCOnInformation; - chkMCWarnings.Checked = mRemoteNG.Settings.Default.SwitchToMCOnWarning; - chkMCErrors.Checked = mRemoteNG.Settings.Default.SwitchToMCOnError; + chkUseOnlyErrorsAndInfosPanel.Checked = Settings.Default.ShowNoMessageBoxes; + chkMCInformation.Checked = Settings.Default.SwitchToMCOnInformation; + chkMCWarnings.Checked = Settings.Default.SwitchToMCOnWarning; + chkMCErrors.Checked = Settings.Default.SwitchToMCOnError; } public override void SaveSettings() { base.SaveSettings(); - mRemoteNG.Settings.Default.AlwaysShowPanelTabs = chkAlwaysShowPanelTabs.Checked; + Settings.Default.AlwaysShowPanelTabs = chkAlwaysShowPanelTabs.Checked; frmMain.Default.ShowHidePanelTabs(); - mRemoteNG.Settings.Default.OpenTabsRightOfSelected = chkOpenNewTabRightOfSelected.Checked; - mRemoteNG.Settings.Default.ShowLogonInfoOnTabs = chkShowLogonInfoOnTabs.Checked; - mRemoteNG.Settings.Default.ShowProtocolOnTabs = chkShowProtocolOnTabs.Checked; - mRemoteNG.Settings.Default.IdentifyQuickConnectTabs = chkIdentifyQuickConnectTabs.Checked; - mRemoteNG.Settings.Default.DoubleClickOnTabClosesIt = chkDoubleClickClosesTab.Checked; - mRemoteNG.Settings.Default.AlwaysShowPanelSelectionDlg = chkAlwaysShowPanelSelectionDlg.Checked; + Settings.Default.OpenTabsRightOfSelected = chkOpenNewTabRightOfSelected.Checked; + Settings.Default.ShowLogonInfoOnTabs = chkShowLogonInfoOnTabs.Checked; + Settings.Default.ShowProtocolOnTabs = chkShowProtocolOnTabs.Checked; + Settings.Default.IdentifyQuickConnectTabs = chkIdentifyQuickConnectTabs.Checked; + Settings.Default.DoubleClickOnTabClosesIt = chkDoubleClickClosesTab.Checked; + Settings.Default.AlwaysShowPanelSelectionDlg = chkAlwaysShowPanelSelectionDlg.Checked; - mRemoteNG.Settings.Default.ShowNoMessageBoxes = chkUseOnlyErrorsAndInfosPanel.Checked; - mRemoteNG.Settings.Default.SwitchToMCOnInformation = chkMCInformation.Checked; - mRemoteNG.Settings.Default.SwitchToMCOnWarning = chkMCWarnings.Checked; - mRemoteNG.Settings.Default.SwitchToMCOnError = chkMCErrors.Checked; + Settings.Default.ShowNoMessageBoxes = chkUseOnlyErrorsAndInfosPanel.Checked; + Settings.Default.SwitchToMCOnInformation = chkMCInformation.Checked; + Settings.Default.SwitchToMCOnWarning = chkMCWarnings.Checked; + Settings.Default.SwitchToMCOnError = chkMCErrors.Checked; } - public void chkUseOnlyErrorsAndInfosPanel_CheckedChanged(object sender, EventArgs e) + private void chkUseOnlyErrorsAndInfosPanel_CheckedChanged(object sender, EventArgs e) { chkMCInformation.Enabled = chkUseOnlyErrorsAndInfosPanel.Checked; chkMCWarnings.Enabled = chkUseOnlyErrorsAndInfosPanel.Checked; From 6666552b8a9c33dc10696482336b5e168bf8313e Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 11:54:06 -0400 Subject: [PATCH 3/8] code clean up and ensure settings save --- .../UI/Forms/OptionsPages/AdvancedPage.cs | 8 +-- .../UI/Forms/OptionsPages/AppearancePage.cs | 30 ++++---- .../UI/Forms/OptionsPages/ConnectionsPage.cs | 68 ++++++++++--------- .../UI/Forms/OptionsPages/SqlServerPage.cs | 26 +++---- .../UI/Forms/OptionsPages/StartupExitPage.cs | 20 +++--- .../UI/Forms/OptionsPages/TabsPanelsPage.cs | 2 + mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs | 12 ++-- .../UI/Forms/OptionsPages/UpdatesPage.cs | 12 ++-- 8 files changed, 96 insertions(+), 82 deletions(-) diff --git a/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs b/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs index 00d1ed0d..cc4b4623 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AdvancedPage.cs @@ -95,19 +95,19 @@ namespace mRemoteNG.UI.Forms.OptionsPages #region Event Handlers - public void chkUseCustomPuttyPath_CheckedChanged(object sender, EventArgs e) + private void chkUseCustomPuttyPath_CheckedChanged(object sender, EventArgs e) { txtCustomPuttyPath.Enabled = chkUseCustomPuttyPath.Checked; btnBrowseCustomPuttyPath.Enabled = chkUseCustomPuttyPath.Checked; SetPuttyLaunchButtonEnabled(); } - public void txtCustomPuttyPath_TextChanged(object sender, EventArgs e) + private void txtCustomPuttyPath_TextChanged(object sender, EventArgs e) { SetPuttyLaunchButtonEnabled(); } - public void btnBrowseCustomPuttyPath_Click(object sender, EventArgs e) + private void btnBrowseCustomPuttyPath_Click(object sender, EventArgs e) { using (var openFileDialog = new OpenFileDialog()) { @@ -124,7 +124,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages } } - public void btnLaunchPutty_Click(object sender, EventArgs e) + private void btnLaunchPutty_Click(object sender, EventArgs e) { try { diff --git a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs index 9e70680c..3a9a229f 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.cs @@ -40,20 +40,20 @@ namespace mRemoteNG.UI.Forms.OptionsPages { cboLanguage.Items.Add(nativeName); } - if (!string.IsNullOrEmpty(mRemoteNG.Settings.Default.OverrideUICulture) && - SupportedCultures.IsNameSupported(mRemoteNG.Settings.Default.OverrideUICulture)) + if (!string.IsNullOrEmpty(Settings.Default.OverrideUICulture) && + SupportedCultures.IsNameSupported(Settings.Default.OverrideUICulture)) { - cboLanguage.SelectedItem = SupportedCultures.get_CultureNativeName(mRemoteNG.Settings.Default.OverrideUICulture); + cboLanguage.SelectedItem = SupportedCultures.get_CultureNativeName(Settings.Default.OverrideUICulture); } if (cboLanguage.SelectedIndex == -1) { cboLanguage.SelectedIndex = 0; } - chkShowDescriptionTooltipsInTree.Checked = mRemoteNG.Settings.Default.ShowDescriptionTooltipsInTree; - chkShowFullConnectionsFilePathInTitle.Checked = mRemoteNG.Settings.Default.ShowCompleteConsPathInTitle; - chkShowSystemTrayIcon.Checked = mRemoteNG.Settings.Default.ShowSystemTrayIcon; - chkMinimizeToSystemTray.Checked = mRemoteNG.Settings.Default.MinimizeToTray; + chkShowDescriptionTooltipsInTree.Checked = Settings.Default.ShowDescriptionTooltipsInTree; + chkShowFullConnectionsFilePathInTitle.Checked = Settings.Default.ShowCompleteConsPathInTitle; + chkShowSystemTrayIcon.Checked = Settings.Default.ShowSystemTrayIcon; + chkMinimizeToSystemTray.Checked = Settings.Default.MinimizeToTray; } public override void SaveSettings() @@ -62,20 +62,20 @@ namespace mRemoteNG.UI.Forms.OptionsPages if (cboLanguage.SelectedIndex > 0 && SupportedCultures.IsNativeNameSupported(Convert.ToString(cboLanguage.SelectedItem))) { - mRemoteNG.Settings.Default.OverrideUICulture = + Settings.Default.OverrideUICulture = SupportedCultures.get_CultureName(Convert.ToString(cboLanguage.SelectedItem)); } else { - mRemoteNG.Settings.Default.OverrideUICulture = string.Empty; + Settings.Default.OverrideUICulture = string.Empty; } - mRemoteNG.Settings.Default.ShowDescriptionTooltipsInTree = chkShowDescriptionTooltipsInTree.Checked; - mRemoteNG.Settings.Default.ShowCompleteConsPathInTitle = chkShowFullConnectionsFilePathInTitle.Checked; + Settings.Default.ShowDescriptionTooltipsInTree = chkShowDescriptionTooltipsInTree.Checked; + Settings.Default.ShowCompleteConsPathInTitle = chkShowFullConnectionsFilePathInTitle.Checked; frmMain.Default.ShowFullPathInTitle = chkShowFullConnectionsFilePathInTitle.Checked; - mRemoteNG.Settings.Default.ShowSystemTrayIcon = chkShowSystemTrayIcon.Checked; - if (mRemoteNG.Settings.Default.ShowSystemTrayIcon) + Settings.Default.ShowSystemTrayIcon = chkShowSystemTrayIcon.Checked; + if (Settings.Default.ShowSystemTrayIcon) { if (Runtime.NotificationAreaIcon == null) { @@ -91,7 +91,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages } } - mRemoteNG.Settings.Default.MinimizeToTray = chkMinimizeToSystemTray.Checked; + Settings.Default.MinimizeToTray = chkMinimizeToSystemTray.Checked; + + Settings.Default.Save(); } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.cs b/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.cs index 24105f37..d2abb1e5 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.cs @@ -53,45 +53,45 @@ namespace mRemoteNG.UI.Forms.OptionsPages base.SaveSettings(); chkSingleClickOnConnectionOpensIt.Checked = - Convert.ToBoolean(mRemoteNG.Settings.Default.SingleClickOnConnectionOpensIt); + Convert.ToBoolean(Settings.Default.SingleClickOnConnectionOpensIt); chkSingleClickOnOpenedConnectionSwitchesToIt.Checked = - Convert.ToBoolean(mRemoteNG.Settings.Default.SingleClickSwitchesToOpenConnection); - chkHostnameLikeDisplayName.Checked = Convert.ToBoolean(mRemoteNG.Settings.Default.SetHostnameLikeDisplayName); + Convert.ToBoolean(Settings.Default.SingleClickSwitchesToOpenConnection); + chkHostnameLikeDisplayName.Checked = Convert.ToBoolean(Settings.Default.SetHostnameLikeDisplayName); - numRdpReconnectionCount.Value = Convert.ToDecimal(mRemoteNG.Settings.Default.RdpReconnectionCount); + numRdpReconnectionCount.Value = Convert.ToDecimal(Settings.Default.RdpReconnectionCount); - numRDPConTimeout.Value = Convert.ToDecimal(mRemoteNG.Settings.Default.ConRDPOverallConnectionTimeout); + numRDPConTimeout.Value = Convert.ToDecimal(Settings.Default.ConRDPOverallConnectionTimeout); - numAutoSave.Value = Convert.ToDecimal(mRemoteNG.Settings.Default.AutoSaveEveryMinutes); + numAutoSave.Value = Convert.ToDecimal(Settings.Default.AutoSaveEveryMinutes); // ReSharper disable once StringLiteralTypo - if (mRemoteNG.Settings.Default.EmptyCredentials == "noinfo") + if (Settings.Default.EmptyCredentials == "noinfo") { radCredentialsNoInfo.Checked = true; } - else if (mRemoteNG.Settings.Default.EmptyCredentials == "windows") + else if (Settings.Default.EmptyCredentials == "windows") { radCredentialsWindows.Checked = true; } - else if (mRemoteNG.Settings.Default.EmptyCredentials == "custom") + else if (Settings.Default.EmptyCredentials == "custom") { radCredentialsCustom.Checked = true; } - txtCredentialsUsername.Text = Convert.ToString(mRemoteNG.Settings.Default.DefaultUsername); + txtCredentialsUsername.Text = Convert.ToString(Settings.Default.DefaultUsername); var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); txtCredentialsPassword.Text = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.DefaultPassword), GeneralAppInfo.EncryptionKey); - txtCredentialsDomain.Text = Convert.ToString(mRemoteNG.Settings.Default.DefaultDomain); + txtCredentialsDomain.Text = Convert.ToString(Settings.Default.DefaultDomain); - if (mRemoteNG.Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Never) + if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Never) { radCloseWarnNever.Checked = true; } - else if (mRemoteNG.Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Exit) + else if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Exit) { radCloseWarnExit.Checked = true; } - else if (mRemoteNG.Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Multiple) + else if (Settings.Default.ConfirmCloseConnection == (int) ConfirmCloseEnum.Multiple) { radCloseWarnMultiple.Checked = true; } @@ -103,18 +103,18 @@ namespace mRemoteNG.UI.Forms.OptionsPages public override void SaveSettings() { - mRemoteNG.Settings.Default.SingleClickOnConnectionOpensIt = chkSingleClickOnConnectionOpensIt.Checked; - mRemoteNG.Settings.Default.SingleClickSwitchesToOpenConnection = chkSingleClickOnOpenedConnectionSwitchesToIt.Checked; - mRemoteNG.Settings.Default.SetHostnameLikeDisplayName = chkHostnameLikeDisplayName.Checked; + Settings.Default.SingleClickOnConnectionOpensIt = chkSingleClickOnConnectionOpensIt.Checked; + Settings.Default.SingleClickSwitchesToOpenConnection = chkSingleClickOnOpenedConnectionSwitchesToIt.Checked; + Settings.Default.SetHostnameLikeDisplayName = chkHostnameLikeDisplayName.Checked; - mRemoteNG.Settings.Default.RdpReconnectionCount = (int) numRdpReconnectionCount.Value; + Settings.Default.RdpReconnectionCount = (int) numRdpReconnectionCount.Value; - mRemoteNG.Settings.Default.ConRDPOverallConnectionTimeout = (int) numRDPConTimeout.Value; + Settings.Default.ConRDPOverallConnectionTimeout = (int) numRDPConTimeout.Value; - mRemoteNG.Settings.Default.AutoSaveEveryMinutes = (int) numAutoSave.Value; - if (mRemoteNG.Settings.Default.AutoSaveEveryMinutes > 0) + Settings.Default.AutoSaveEveryMinutes = (int) numAutoSave.Value; + if (Settings.Default.AutoSaveEveryMinutes > 0) { - frmMain.Default.tmrAutoSave.Interval = Convert.ToInt32(mRemoteNG.Settings.Default.AutoSaveEveryMinutes*60000); + frmMain.Default.tmrAutoSave.Interval = Convert.ToInt32(Settings.Default.AutoSaveEveryMinutes*60000); frmMain.Default.tmrAutoSave.Enabled = true; } else @@ -125,41 +125,43 @@ namespace mRemoteNG.UI.Forms.OptionsPages if (radCredentialsNoInfo.Checked) { // ReSharper disable once StringLiteralTypo - mRemoteNG.Settings.Default.EmptyCredentials = "noinfo"; + Settings.Default.EmptyCredentials = "noinfo"; } else if (radCredentialsWindows.Checked) { - mRemoteNG.Settings.Default.EmptyCredentials = "windows"; + Settings.Default.EmptyCredentials = "windows"; } else if (radCredentialsCustom.Checked) { - mRemoteNG.Settings.Default.EmptyCredentials = "custom"; + Settings.Default.EmptyCredentials = "custom"; } - mRemoteNG.Settings.Default.DefaultUsername = txtCredentialsUsername.Text; + Settings.Default.DefaultUsername = txtCredentialsUsername.Text; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); - mRemoteNG.Settings.Default.DefaultPassword = cryptographyProvider.Encrypt(txtCredentialsPassword.Text, GeneralAppInfo.EncryptionKey); - mRemoteNG.Settings.Default.DefaultDomain = txtCredentialsDomain.Text; + Settings.Default.DefaultPassword = cryptographyProvider.Encrypt(txtCredentialsPassword.Text, GeneralAppInfo.EncryptionKey); + Settings.Default.DefaultDomain = txtCredentialsDomain.Text; if (radCloseWarnAll.Checked) { - mRemoteNG.Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.All; + Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.All; } if (radCloseWarnMultiple.Checked) { - mRemoteNG.Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Multiple; + Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Multiple; } if (radCloseWarnExit.Checked) { - mRemoteNG.Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Exit; + Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Exit; } if (radCloseWarnNever.Checked) { - mRemoteNG.Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Never; + Settings.Default.ConfirmCloseConnection = (int) ConfirmCloseEnum.Never; } + + Settings.Default.Save(); } - public void radCredentialsCustom_CheckedChanged(object sender, EventArgs e) + private void radCredentialsCustom_CheckedChanged(object sender, EventArgs e) { lblCredentialsUsername.Enabled = radCredentialsCustom.Checked; lblCredentialsPassword.Enabled = radCredentialsCustom.Checked; diff --git a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs index a028f4e5..82cce92a 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.cs @@ -37,10 +37,10 @@ namespace mRemoteNG.UI.Forms.OptionsPages { base.SaveSettings(); - chkUseSQLServer.Checked = mRemoteNG.Settings.Default.UseSQLServer; - txtSQLServer.Text = mRemoteNG.Settings.Default.SQLHost; - txtSQLDatabaseName.Text = mRemoteNG.Settings.Default.SQLDatabaseName; - txtSQLUsername.Text = mRemoteNG.Settings.Default.SQLUser; + chkUseSQLServer.Checked = Settings.Default.UseSQLServer; + txtSQLServer.Text = Settings.Default.SQLHost; + txtSQLDatabaseName.Text = Settings.Default.SQLDatabaseName; + txtSQLUsername.Text = Settings.Default.SQLUser; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); txtSQLPassword.Text = cryptographyProvider.Decrypt(Settings.Default.SQLPass, GeneralAppInfo.EncryptionKey); } @@ -49,13 +49,15 @@ namespace mRemoteNG.UI.Forms.OptionsPages { base.SaveSettings(); - mRemoteNG.Settings.Default.UseSQLServer = chkUseSQLServer.Checked; - mRemoteNG.Settings.Default.SQLHost = txtSQLServer.Text; - mRemoteNG.Settings.Default.SQLDatabaseName = txtSQLDatabaseName.Text; - mRemoteNG.Settings.Default.SQLUser = txtSQLUsername.Text; + Settings.Default.UseSQLServer = chkUseSQLServer.Checked; + Settings.Default.SQLHost = txtSQLServer.Text; + Settings.Default.SQLDatabaseName = txtSQLDatabaseName.Text; + Settings.Default.SQLUser = txtSQLUsername.Text; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); - mRemoteNG.Settings.Default.SQLPass = cryptographyProvider.Encrypt(txtSQLPassword.Text, GeneralAppInfo.EncryptionKey); + Settings.Default.SQLPass = cryptographyProvider.Encrypt(txtSQLPassword.Text, GeneralAppInfo.EncryptionKey); ReinitializeSqlUpdater(); + + Settings.Default.Save(); } private static void ReinitializeSqlUpdater() @@ -63,8 +65,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages if (Runtime.SQLConnProvider != null) { Runtime.SQLConnProvider.Dispose(); - frmMain.Default.AreWeUsingSqlServerForSavingConnections = mRemoteNG.Settings.Default.UseSQLServer; - if (mRemoteNG.Settings.Default.UseSQLServer) + frmMain.Default.AreWeUsingSqlServerForSavingConnections = Settings.Default.UseSQLServer; + if (Settings.Default.UseSQLServer) { Runtime.SQLConnProvider = new SqlConnectionsProvider(); Runtime.SQLConnProvider.Enable(); @@ -72,7 +74,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages } } - public void chkUseSQLServer_CheckedChanged(object sender, EventArgs e) + private void chkUseSQLServer_CheckedChanged(object sender, EventArgs e) { lblSQLServer.Enabled = chkUseSQLServer.Checked; lblSQLDatabaseName.Enabled = chkUseSQLServer.Checked; diff --git a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs index 5b1d9984..2fabbc76 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.cs @@ -29,18 +29,20 @@ namespace mRemoteNG.UI.Forms.OptionsPages { base.SaveSettings(); - mRemoteNG.Settings.Default.SaveConsOnExit = chkSaveConsOnExit.Checked; - mRemoteNG.Settings.Default.OpenConsFromLastSession = chkReconnectOnStart.Checked; - mRemoteNG.Settings.Default.SingleInstance = chkSingleInstance.Checked; - mRemoteNG.Settings.Default.StartupComponentsCheck = chkProperInstallationOfComponentsAtStartup.Checked; + Settings.Default.SaveConsOnExit = chkSaveConsOnExit.Checked; + Settings.Default.OpenConsFromLastSession = chkReconnectOnStart.Checked; + Settings.Default.SingleInstance = chkSingleInstance.Checked; + Settings.Default.StartupComponentsCheck = chkProperInstallationOfComponentsAtStartup.Checked; + + Settings.Default.Save(); } - public void StartupExitPage_Load(object sender, EventArgs e) + private void StartupExitPage_Load(object sender, EventArgs e) { - chkSaveConsOnExit.Checked = mRemoteNG.Settings.Default.SaveConsOnExit; - chkReconnectOnStart.Checked = mRemoteNG.Settings.Default.OpenConsFromLastSession; - chkSingleInstance.Checked = mRemoteNG.Settings.Default.SingleInstance; - chkProperInstallationOfComponentsAtStartup.Checked = mRemoteNG.Settings.Default.StartupComponentsCheck; + chkSaveConsOnExit.Checked = Settings.Default.SaveConsOnExit; + chkReconnectOnStart.Checked = Settings.Default.OpenConsFromLastSession; + chkSingleInstance.Checked = Settings.Default.SingleInstance; + chkProperInstallationOfComponentsAtStartup.Checked = Settings.Default.StartupComponentsCheck; } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs index e469fa24..496244bd 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.cs @@ -70,6 +70,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages Settings.Default.SwitchToMCOnInformation = chkMCInformation.Checked; Settings.Default.SwitchToMCOnWarning = chkMCWarnings.Checked; Settings.Default.SwitchToMCOnError = chkMCErrors.Checked; + + Settings.Default.Save(); } private void chkUseOnlyErrorsAndInfosPanel_CheckedChanged(object sender, EventArgs e) diff --git a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs index b1123855..29167382 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs @@ -45,7 +45,9 @@ namespace mRemoteNG.UI.Forms.OptionsPages base.SaveSettings(); ThemeManager.SaveThemes(_themeList); - mRemoteNG.Settings.Default.ThemeName = ThemeManager.ActiveTheme.Name; + Settings.Default.ThemeName = ThemeManager.ActiveTheme.Name; + + Settings.Default.Save(); } public override void RevertSettings() @@ -64,7 +66,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages #region Event Handlers - public void cboTheme_DropDown(object sender, EventArgs e) + private void cboTheme_DropDown(object sender, EventArgs e) { if (Equals(ThemeManager.ActiveTheme, ThemeManager.DefaultTheme)) { @@ -73,7 +75,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages ThemeManager.ActiveTheme.Name = cboTheme.Text; } - public void cboTheme_SelectionChangeCommitted(object sender, EventArgs e) + private void cboTheme_SelectionChangeCommitted(object sender, EventArgs e) { if (cboTheme.SelectedItem == null) { @@ -98,7 +100,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages ThemePropertyGrid.Refresh(); } - public void btnThemeNew_Click(object sender, EventArgs e) + private void btnThemeNew_Click(object sender, EventArgs e) { var newTheme = (ThemeInfo) ThemeManager.ActiveTheme.Clone(); newTheme.Name = Language.strUnnamedTheme; @@ -111,7 +113,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages cboTheme.Focus(); } - public void btnThemeDelete_Click(object sender, EventArgs e) + private void btnThemeDelete_Click(object sender, EventArgs e) { var theme = (ThemeInfo) cboTheme.SelectedItem; if (theme == null) diff --git a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs index aa2e6fa7..d1538f68 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.cs @@ -141,6 +141,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages Settings.Default.UpdateProxyAuthUser = txtProxyUsername.Text; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); Settings.Default.UpdateProxyAuthPass = cryptographyProvider.Encrypt(txtProxyPassword.Text, GeneralAppInfo.EncryptionKey); + + Settings.Default.Save(); } #endregion @@ -149,17 +151,17 @@ namespace mRemoteNG.UI.Forms.OptionsPages #region Event Handlers - public void chkCheckForUpdatesOnStartup_CheckedChanged(object sender, EventArgs e) + private void chkCheckForUpdatesOnStartup_CheckedChanged(object sender, EventArgs e) { cboUpdateCheckFrequency.Enabled = chkCheckForUpdatesOnStartup.Checked; } - public void btnUpdateCheckNow_Click(object sender, EventArgs e) + private void btnUpdateCheckNow_Click(object sender, EventArgs e) { Windows.Show(WindowType.Update); } - public void chkUseProxyForAutomaticUpdates_CheckedChanged(object sender, EventArgs e) + private void chkUseProxyForAutomaticUpdates_CheckedChanged(object sender, EventArgs e) { pnlProxyBasic.Enabled = chkUseProxyForAutomaticUpdates.Checked; btnTestProxy.Enabled = chkUseProxyForAutomaticUpdates.Checked; @@ -180,7 +182,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages } } - public void btnTestProxy_Click(object sender, EventArgs e) + private void btnTestProxy_Click(object sender, EventArgs e) { if (_appUpdate != null) { @@ -204,7 +206,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages _appUpdate.GetUpdateInfoAsync(); } - public void chkUseProxyAuthentication_CheckedChanged(object sender, EventArgs e) + private void chkUseProxyAuthentication_CheckedChanged(object sender, EventArgs e) { if (chkUseProxyForAutomaticUpdates.Checked) { From b757ab742416301125d591a8c90e7ca18c6751ad Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 15:46:21 -0400 Subject: [PATCH 4/8] MR-979 - switched to notifications pnl incorrectly --- mRemoteV1/Messages/MessageCollector.cs | 55 +++++++++++++++++++------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/mRemoteV1/Messages/MessageCollector.cs b/mRemoteV1/Messages/MessageCollector.cs index 28844ada..7c10db55 100644 --- a/mRemoteV1/Messages/MessageCollector.cs +++ b/mRemoteV1/Messages/MessageCollector.cs @@ -36,25 +36,50 @@ namespace mRemoteNG.Messages return; } - if (Settings.Default.SwitchToMCOnInformation && nMsg.MsgClass == MessageClass.InformationMsg) + var EnableTimer = true; // used to control if we SWITCH to the notifiation panel. Message will still be added regardless. + + if (nMsg.MsgClass == MessageClass.InformationMsg) + { AddInfoMessage(nMsg); - - if (Settings.Default.SwitchToMCOnWarning && nMsg.MsgClass == MessageClass.WarningMsg) + + if (!Settings.Default.SwitchToMCOnInformation) + EnableTimer = false; + } + + if (nMsg.MsgClass == MessageClass.WarningMsg) + { AddWarningMessage(nMsg); - if (Settings.Default.SwitchToMCOnError && nMsg.MsgClass == MessageClass.ErrorMsg) + if (!Settings.Default.SwitchToMCOnWarning) + EnableTimer = false; + } + + if (nMsg.MsgClass == MessageClass.ErrorMsg) + { AddErrorMessage(nMsg); - if (!OnlyLog) - { - if (Settings.Default.ShowNoMessageBoxes) - _ECTimer.Enabled = true; - else - ShowMessageBox(nMsg); - - ListViewItem lvItem = BuildListViewItem(nMsg); - AddToList(lvItem); + if (!Settings.Default.SwitchToMCOnError) + EnableTimer = false; } + + if (OnlyLog) + return; + + if (Settings.Default.ShowNoMessageBoxes) + { + /* These if statements need to be split so we can: + * control that no messages boxes will be dispalyed + * add items to the notifications panel + * NOT switch to the notification panel if configured that way + */ + if(EnableTimer) + _ECTimer.Enabled = true; + } + else + ShowMessageBox(nMsg); + + ListViewItem lvItem = BuildListViewItem(nMsg); + AddToList(lvItem); } private void AddInfoMessage(Message nMsg) @@ -100,9 +125,9 @@ namespace mRemoteNG.Messages AddMessage(msgClass, message + Environment.NewLine + Tools.MiscTools.GetExceptionMessageRecursive(ex), logOnly); } - public void AddExceptionStackTrace(string message, Exception ex, MessageClass msgClass = MessageClass.ErrorMsg, bool logOnly = false) + public void AddExceptionStackTrace(string message, Exception ex, MessageClass msgClass = MessageClass.ErrorMsg) { - AddMessage(msgClass, message + Environment.NewLine + ex.StackTrace, logOnly); + AddMessage(msgClass, message + Environment.NewLine + ex.StackTrace, true); } #endregion From 95c818d92e4dcd7efd155d5fe0e0417b49aad25a Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 16:23:03 -0400 Subject: [PATCH 5/8] code clean up Octet1.Text.Remove didn't actually do anything. Text is already removed properly when backspace is pressed without this code in the event handlers. --- mRemoteV1/UI/Controls/IPTextBox.cs | 50 +++++++++--------------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/mRemoteV1/UI/Controls/IPTextBox.cs b/mRemoteV1/UI/Controls/IPTextBox.cs index 438e1820..b9e63b4a 100644 --- a/mRemoteV1/UI/Controls/IPTextBox.cs +++ b/mRemoteV1/UI/Controls/IPTextBox.cs @@ -49,13 +49,13 @@ namespace mRemoteNG.UI.Controls { get { - return Octet1.Text + "." + Octet2.Text + "." + Octet3.Text + "." + Octet4.Text; + return Octet1.Text + @"." + Octet2.Text + @"." + Octet3.Text + @"." + Octet4.Text; } set { if (!string.IsNullOrEmpty(value)) { - var pieces = value.Split(".".ToCharArray(),4); + var pieces = value.Split(@".".ToCharArray(),4); Octet1.Text = pieces[0]; Octet2.Text = pieces[1]; Octet3.Text = pieces[2]; @@ -225,7 +225,7 @@ namespace mRemoteNG.UI.Controls * \return True if the string is between 0 and 255 inclusively, false otherwise * \endif * */ - private bool IsValid(string inString) + private static bool IsValid(string inString) { try { @@ -249,7 +249,7 @@ namespace mRemoteNG.UI.Controls private void Box1_KeyPress(object sender, KeyPressEventArgs e) { //Only Accept a '.', a numeral, or backspace - if(e.KeyChar.ToString() == "." || Char.IsDigit(e.KeyChar) || e.KeyChar == 8) + if(e.KeyChar.ToString() == "." || char.IsDigit(e.KeyChar) || e.KeyChar == 8) { //If the key pressed is a '.' if(e.KeyChar.ToString() == ".") @@ -272,9 +272,7 @@ namespace mRemoteNG.UI.Controls // ip octet then move on to next box if(Octet1.Text.Length == 2) { - if(e.KeyChar == 8) - Octet1.Text.Remove(Octet1.Text.Length-1,1); - else if(!IsValid(Octet1.Text + e.KeyChar.ToString())) + if(!IsValid(Octet1.Text + e.KeyChar)) { Octet1.SelectAll(); e.Handled = true; @@ -299,7 +297,7 @@ namespace mRemoteNG.UI.Controls { //Similar to Box1_KeyPress but in special case for backspace moves cursor //to the previouse box (Box1) - if(e.KeyChar.ToString() == "." || Char.IsDigit(e.KeyChar) || e.KeyChar == 8) + if(e.KeyChar.ToString() == "." || char.IsDigit(e.KeyChar) || e.KeyChar == 8) { if(e.KeyChar.ToString() == ".") { @@ -316,11 +314,7 @@ namespace mRemoteNG.UI.Controls { if(Octet2.Text.Length == 2) { - if(e.KeyChar == 8) - { - Octet2.Text.Remove(Octet2.Text.Length-1,1); - } - else if(!IsValid(Octet2.Text + e.KeyChar.ToString())) + if(!IsValid(Octet2.Text + e.KeyChar)) { Octet2.SelectAll(); e.Handled = true; @@ -350,7 +344,7 @@ namespace mRemoteNG.UI.Controls { //Identical to Box2_KeyPress except that previous box is Box2 and //next box is Box3 - if(e.KeyChar.ToString() == "." || Char.IsDigit(e.KeyChar) || e.KeyChar == 8) + if(e.KeyChar.ToString() == "." || char.IsDigit(e.KeyChar) || e.KeyChar == 8) { if(e.KeyChar.ToString() == ".") { @@ -367,11 +361,7 @@ namespace mRemoteNG.UI.Controls { if(Octet3.Text.Length == 2) { - if(e.KeyChar == 8) - { - Octet3.Text.Remove(Octet3.Text.Length-1,1); - } - else if(!IsValid(Octet3.Text + e.KeyChar.ToString())) + if(!IsValid(Octet3.Text + e.KeyChar)) { Octet3.SelectAll(); e.Handled = true; @@ -400,17 +390,13 @@ namespace mRemoteNG.UI.Controls { //Similar to Box3 but ignores the '.' character and does not advance //to the next box. Also Box3 is previous box for backspace case. - if(Char.IsDigit(e.KeyChar) || e.KeyChar == 8) + if(char.IsDigit(e.KeyChar) || e.KeyChar == 8) { if(Octet4.SelectionLength != Octet4.Text.Length) { if(Octet4.Text.Length == 2) { - if(e.KeyChar == 8) - { - Octet4.Text.Remove(Octet4.Text.Length-1,1); - } - else if(!IsValid(Octet4.Text + e.KeyChar.ToString())) + if(!IsValid(Octet4.Text + e.KeyChar)) { Octet4.SelectAll(); e.Handled = true; @@ -441,11 +427,8 @@ namespace mRemoteNG.UI.Controls /// \endif private void label_EnabledChanged(object sender, EventArgs e) { - var lbl = (Label) sender; - if(lbl.Enabled) - lbl.BackColor = SystemColors.Window; - else - lbl.BackColor = SystemColors.Control; + var lbl = (Label) sender; + lbl.BackColor = lbl.Enabled ? SystemColors.Window : SystemColors.Control; } /// \ifnot hide_events @@ -453,11 +436,8 @@ namespace mRemoteNG.UI.Controls /// \endif private void panel1_EnabledChanged(object sender, EventArgs e) { - var pan = (Panel) sender; - if(pan.Enabled) - pan.BackColor = SystemColors.Window; - else - pan.BackColor = SystemColors.Control; + var pan = (Panel) sender; + pan.BackColor = pan.Enabled ? SystemColors.Window : SystemColors.Control; } } } From 2f10e60dbfb3bf52d6a0f9c835425a988eafffb6 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 16:39:24 -0400 Subject: [PATCH 6/8] code clean up --- .../UI/Controls/CustomListViewTests.cs | 25 +++++++-------- mRemoteV1/UI/Controls/ListView.cs | 32 ++++++++----------- 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/mRemoteNGTests/UI/Controls/CustomListViewTests.cs b/mRemoteNGTests/UI/Controls/CustomListViewTests.cs index 1edf9eb9..7527da8e 100644 --- a/mRemoteNGTests/UI/Controls/CustomListViewTests.cs +++ b/mRemoteNGTests/UI/Controls/CustomListViewTests.cs @@ -1,32 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using mRemoteNG.Controls; -using NUnit.Framework; -using NUnit.Extensions.Forms; -using System.Windows.Forms; +using NUnit.Framework; +using ListView = mRemoteNG.UI.Controls.ListView; namespace mRemoteNGTests.UI.Controls { public class CustomListViewTests { - mRemoteNG.Controls.ListView _listView; + ListView _listView; [SetUp] public void Setup() { - _listView = new mRemoteNG.Controls.ListView(); - _listView.Name = "myTestListView"; - _listView.View = System.Windows.Forms.View.Tile; + _listView = new ListView + { + Name = "myTestListView", + View = System.Windows.Forms.View.Tile + }; } [TearDown] public void Teardown() { _listView.Dispose(); - while (_listView.Disposing) ; + while (_listView.Disposing) + { + } _listView = null; } } diff --git a/mRemoteV1/UI/Controls/ListView.cs b/mRemoteV1/UI/Controls/ListView.cs index 564fd556..aa3fcddb 100644 --- a/mRemoteV1/UI/Controls/ListView.cs +++ b/mRemoteV1/UI/Controls/ListView.cs @@ -1,15 +1,14 @@ +using System.ComponentModel; using System.Drawing; using System.Windows.Forms; -using System.ComponentModel; - -namespace mRemoteNG.Controls +namespace mRemoteNG.UI.Controls { public class ListView : System.Windows.Forms.ListView { - Brush foreColorBrush = null; - Brush backColorBrush = null; - Pen borderPen = null; + Brush foreColorBrush; + Brush backColorBrush; + Pen borderPen; #region Public Properties [Category("Appearance"), DefaultValue(typeof(Color), "HighlightText")] @@ -172,12 +171,9 @@ namespace mRemoteNG.Controls private void DisposeBrushesAndPens() { - if (foreColorBrush != null) - foreColorBrush.Dispose(); - if (backColorBrush != null) - backColorBrush.Dispose(); - if (borderPen != null) - borderPen.Dispose(); + foreColorBrush?.Dispose(); + backColorBrush?.Dispose(); + borderPen?.Dispose(); } #endregion @@ -210,14 +206,14 @@ namespace mRemoteNG.Controls format.Alignment = StringAlignment.Far; break; } - - if (RightToLeft.ToString() != null) - format.FormatFlags = (StringFormatFlags) (format.FormatFlags | StringFormatFlags.DirectionRightToLeft); + + if (RightToLeftLayout) + format.FormatFlags = format.FormatFlags | StringFormatFlags.DirectionRightToLeft; if (LabelWrap) - format.FormatFlags = (StringFormatFlags) (format.FormatFlags & ~StringFormatFlags.NoWrap); + format.FormatFlags = format.FormatFlags & ~StringFormatFlags.NoWrap; else - format.FormatFlags = (StringFormatFlags) (format.FormatFlags | StringFormatFlags.NoWrap); + format.FormatFlags = format.FormatFlags | StringFormatFlags.NoWrap; return format; } @@ -258,7 +254,7 @@ namespace mRemoteNG.Controls public override string ToString() { - return string.Format("{0}, {1}", Vertical, Horizontal); + return $"{Vertical}, {Horizontal}"; } } From 6799ac2b304c699ddb5c0506d37fb96b855a6b5b Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 17:08:15 -0400 Subject: [PATCH 7/8] code clean up --- mRemoteV1/UI/Controls/IPTextBox.cs | 12 ++++++------ mRemoteV1/UI/Controls/ToolStripSplitButton.cs | 7 +++---- mRemoteV1/UI/Forms/Input/input.cs | 2 +- mRemoteV1/UI/Forms/PasswordForm.cs | 18 ++++++++++-------- mRemoteV1/UI/{Controls => Forms}/TextBox.cs | 9 ++++----- mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs | 4 +--- mRemoteV1/UI/Forms/frmChoosePanel.cs | 18 +++++++++--------- mRemoteV1/UI/Forms/frmMain.Designer.cs | 3 +-- mRemoteV1/UI/Window/SSHTransferWindow.cs | 1 + mRemoteV1/mRemoteV1.csproj | 6 +++--- 10 files changed, 39 insertions(+), 41 deletions(-) rename mRemoteV1/UI/{Controls => Forms}/TextBox.cs (88%) diff --git a/mRemoteV1/UI/Controls/IPTextBox.cs b/mRemoteV1/UI/Controls/IPTextBox.cs index b9e63b4a..fbb9d6e3 100644 --- a/mRemoteV1/UI/Controls/IPTextBox.cs +++ b/mRemoteV1/UI/Controls/IPTextBox.cs @@ -17,12 +17,12 @@ namespace mRemoteNG.UI.Controls public class IPTextBox: UserControl { private Panel panel1; - public TextBox Octet1; - private Label label1; - public TextBox Octet2; - public TextBox Octet3; - public TextBox Octet4; - private Label label2; + public System.Windows.Forms.TextBox Octet1; + public System.Windows.Forms.TextBox Octet2; + public System.Windows.Forms.TextBox Octet3; + public System.Windows.Forms.TextBox Octet4; + private Label label1; + private Label label2; private Label label3; private ToolTip toolTip1; private System.ComponentModel.IContainer components; diff --git a/mRemoteV1/UI/Controls/ToolStripSplitButton.cs b/mRemoteV1/UI/Controls/ToolStripSplitButton.cs index 9f565b10..033b448f 100644 --- a/mRemoteV1/UI/Controls/ToolStripSplitButton.cs +++ b/mRemoteV1/UI/Controls/ToolStripSplitButton.cs @@ -1,8 +1,7 @@ using System.Drawing; using System.Windows.Forms; - -namespace mRemoteNG.Controls +namespace mRemoteNG.UI.Controls { public class ToolStripSplitButton : System.Windows.Forms.ToolStripSplitButton { @@ -21,7 +20,7 @@ namespace mRemoteNG.Controls private void DropDown_Closing(object sender, ToolStripDropDownClosingEventArgs e) { - if (!(e.CloseReason == ToolStripDropDownCloseReason.AppClicked)) + if (e.CloseReason != ToolStripDropDownCloseReason.AppClicked) { return ; } @@ -54,6 +53,6 @@ namespace mRemoteNG.Controls } } - private bool _dropDownVisibleOnMouseDown = false; + private bool _dropDownVisibleOnMouseDown; } } diff --git a/mRemoteV1/UI/Forms/Input/input.cs b/mRemoteV1/UI/Forms/Input/input.cs index 0cb65ebd..a8bb2695 100644 --- a/mRemoteV1/UI/Forms/Input/input.cs +++ b/mRemoteV1/UI/Forms/Input/input.cs @@ -8,7 +8,7 @@ using System.Drawing; namespace mRemoteNG.UI.Forms.Input { - internal class input + internal static class input { public static DialogResult InputBox(string title, string promptText, ref string value) { diff --git a/mRemoteV1/UI/Forms/PasswordForm.cs b/mRemoteV1/UI/Forms/PasswordForm.cs index c96445aa..b48c9910 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.cs @@ -1,5 +1,6 @@ using System; using System.Windows.Forms; +using mRemoteNG.UI.Controls; namespace mRemoteNG.UI.Forms { @@ -35,12 +36,13 @@ namespace mRemoteNG.UI.Forms // Add any initialization after the InitializeComponent() call. _passwordName = passwordName; - this.Verify = verify; + Verify = verify; } #endregion #region Event Handlers - public void frmPassword_Load(object sender, EventArgs e) + + private void frmPassword_Load(object sender, EventArgs e) { ApplyLanguage(); @@ -51,14 +53,14 @@ namespace mRemoteNG.UI.Forms txtVerify.Visible = false; } } - - public void btnCancel_Click(System.Object sender, EventArgs e) + + private void btnCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } - - public void btnOK_Click(System.Object sender, EventArgs e) + + private void btnOK_Click(object sender, EventArgs e) { if (Verify) { @@ -70,8 +72,8 @@ namespace mRemoteNG.UI.Forms DialogResult = DialogResult.OK; } } - - public void txtPassword_TextChanged(System.Object sender, EventArgs e) + + private void txtPassword_TextChanged(object sender, EventArgs e) { HideStatus(); } diff --git a/mRemoteV1/UI/Controls/TextBox.cs b/mRemoteV1/UI/Forms/TextBox.cs similarity index 88% rename from mRemoteV1/UI/Controls/TextBox.cs rename to mRemoteV1/UI/Forms/TextBox.cs index 04a0b9a5..2123081b 100644 --- a/mRemoteV1/UI/Controls/TextBox.cs +++ b/mRemoteV1/UI/Forms/TextBox.cs @@ -1,17 +1,16 @@ using System; -using System.Windows.Forms; using System.ComponentModel; - +using System.Windows.Forms; // Adapted from http://stackoverflow.com/a/3678888/2101395 -namespace mRemoteNG.Controls +namespace mRemoteNG.UI.Forms { public class TextBox : System.Windows.Forms.TextBox { #region Public Properties [Category("Behavior"), - DefaultValue(false)]private bool _SelectAllOnFocus = false; + DefaultValue(false)]private bool _SelectAllOnFocus; public bool SelectAllOnFocus { get @@ -60,7 +59,7 @@ namespace mRemoteNG.Controls #endregion #region Private Fields - private bool _focusHandled = false; + private bool _focusHandled; #endregion } } \ No newline at end of file diff --git a/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs b/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs index bda982d7..f410edba 100644 --- a/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs +++ b/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs @@ -1,8 +1,6 @@ -using mRemoteNG.My; - -namespace mRemoteNG +namespace mRemoteNG.UI.Forms { public partial class frmChoosePanel : System.Windows.Forms.Form diff --git a/mRemoteV1/UI/Forms/frmChoosePanel.cs b/mRemoteV1/UI/Forms/frmChoosePanel.cs index de142629..6d5ad13b 100644 --- a/mRemoteV1/UI/Forms/frmChoosePanel.cs +++ b/mRemoteV1/UI/Forms/frmChoosePanel.cs @@ -2,7 +2,7 @@ using System.Windows.Forms; using mRemoteNG.App; using mRemoteNG.UI.Forms.Input; -namespace mRemoteNG +namespace mRemoteNG.UI.Forms { public partial class frmChoosePanel { @@ -21,8 +21,8 @@ namespace mRemoteNG cbPanels.SelectedItem = value; } } - - public void frmChoosePanel_Load(object sender, System.EventArgs e) + + private void frmChoosePanel_Load(object sender, System.EventArgs e) { ApplyLanguage(); @@ -59,8 +59,8 @@ namespace mRemoteNG btnOK.Enabled = false; } } - - public void btnNew_Click(object sender, System.EventArgs e) + + private void btnNew_Click(object sender, System.EventArgs e) { string pnlName = Language.strNewPanel; @@ -72,13 +72,13 @@ namespace mRemoteNG cbPanels.Focus(); } } - - public void btnOK_Click(object sender, System.EventArgs e) + + private void btnOK_Click(object sender, System.EventArgs e) { DialogResult = DialogResult.OK; } - - public void btnCancel_Click(object sender, System.EventArgs e) + + private void btnCancel_Click(object sender, System.EventArgs e) { DialogResult = DialogResult.Cancel; } diff --git a/mRemoteV1/UI/Forms/frmMain.Designer.cs b/mRemoteV1/UI/Forms/frmMain.Designer.cs index 6b1c864b..95c7733e 100644 --- a/mRemoteV1/UI/Forms/frmMain.Designer.cs +++ b/mRemoteV1/UI/Forms/frmMain.Designer.cs @@ -1,4 +1,3 @@ -using mRemoteNG.Controls; using mRemoteNG.UI.Controls; namespace mRemoteNG.UI.Forms @@ -98,7 +97,7 @@ namespace mRemoteNG.UI.Forms this.cmbQuickConnect = new mRemoteNG.UI.Controls.QuickConnectComboBox(); this.tsContainer = new System.Windows.Forms.ToolStripContainer(); this.tsQuickConnect = new System.Windows.Forms.ToolStrip(); - this.btnQuickConnect = new mRemoteNG.Controls.ToolStripSplitButton(); + this.btnQuickConnect = new ToolStripSplitButton(); this.mnuQuickConnectProtocol = new System.Windows.Forms.ContextMenuStrip(this.components); this.btnConnections = new System.Windows.Forms.ToolStripDropDownButton(); this.mnuConnections = new System.Windows.Forms.ContextMenuStrip(this.components); diff --git a/mRemoteV1/UI/Window/SSHTransferWindow.cs b/mRemoteV1/UI/Window/SSHTransferWindow.cs index c5815292..a8af6c90 100644 --- a/mRemoteV1/UI/Window/SSHTransferWindow.cs +++ b/mRemoteV1/UI/Window/SSHTransferWindow.cs @@ -6,6 +6,7 @@ using System.Windows.Forms; using mRemoteNG.Tools; using mRemoteNG.UI.Forms; using WeifenLuo.WinFormsUI.Docking; +using TextBox = System.Windows.Forms.TextBox; namespace mRemoteNG.UI.Window { diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 966a5c9f..8e64843c 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -194,9 +194,6 @@ Component - - Component - Component @@ -362,6 +359,9 @@ + + Component + Component From d5a54dd63d2673fc08c37deaf4930afb1be8fc2c Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 9 Sep 2016 17:08:27 -0400 Subject: [PATCH 8/8] code clean up --- mRemoteV1/UI/Forms/PasswordForm.Designer.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs index 424384e1..27fede77 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs @@ -1,4 +1,4 @@ - +using TextBox = mRemoteNG.UI.Forms.TextBox; namespace mRemoteNG.UI.Forms { @@ -38,8 +38,8 @@ namespace mRemoteNG.UI.Forms this.btnCancel = new System.Windows.Forms.Button(); this.lblStatus = new System.Windows.Forms.Label(); this.pbLock = new System.Windows.Forms.PictureBox(); - this.txtVerify = new mRemoteNG.Controls.TextBox(); - this.txtPassword = new mRemoteNG.Controls.TextBox(); + this.txtVerify = new TextBox(); + this.txtPassword = new TextBox(); ((System.ComponentModel.ISupportInitialize)(this.pbLock)).BeginInit(); this.SuspendLayout(); // @@ -161,8 +161,8 @@ namespace mRemoteNG.UI.Forms this.PerformLayout(); } - private mRemoteNG.Controls.TextBox txtPassword; - private mRemoteNG.Controls.TextBox txtVerify; + private TextBox txtPassword; + private TextBox txtVerify; private System.Windows.Forms.Label lblPassword; private System.Windows.Forms.Label lblVerify; private System.Windows.Forms.Button btnOK;