From fe9aa596902aaba1b6ab50a7563ed0d8cb59860f Mon Sep 17 00:00:00 2001 From: "Sparer, David" Date: Thu, 26 May 2016 15:37:12 -0600 Subject: [PATCH 01/27] Finished basic implementation of uninstalling legacy versions. --- .../CustomActions/CustomActions.cs | 29 +++++++ .../CustomActions/CustomActions.csproj | 4 +- .../CustomActions/UninstallNSISVersions.cs | 75 +++++++++++++++++++ .../CustomActions/UninstallLegacyVersions.wxs | 10 +++ .../Installer/Installer.wixproj | 1 + Installer Projects/Installer/mRemoteNGV1.wxs | 6 +- 6 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 Installer Projects/CustomActions/UninstallNSISVersions.cs create mode 100644 Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs diff --git a/Installer Projects/CustomActions/CustomActions.cs b/Installer Projects/CustomActions/CustomActions.cs index 2ecdf6a3..8d8c5f71 100644 --- a/Installer Projects/CustomActions/CustomActions.cs +++ b/Installer Projects/CustomActions/CustomActions.cs @@ -27,5 +27,34 @@ namespace CustomActions session.Log("End IsKBInstalled"); return ActionResult.Success; } + + [CustomAction] + public static ActionResult UninstallLegacyVersion(Session session) + { + session.Log("Begin UninstallLegacyVersion"); + UninstallNSISVersions uninstaller = new UninstallNSISVersions(); + string uninstallString = uninstaller.GetLegacyUninstallString(); + uninstaller.UninstallLegacyVersion(); + session.Log("End UninstallLegacyVersion"); + return ActionResult.Success; + } + + [CustomAction] + public static ActionResult IsLegacyVersionInstalled(Session session) + { + session.Log("Begin IsLegacyVersionInstalled"); + UninstallNSISVersions uninstaller = new UninstallNSISVersions(); + if (uninstaller.IsLegacymRemoteNGInstalled()) + { + session["LEGACYVERSIONINSTALLED"] = "1"; + } + else + { + session["LEGACYVERSIONINSTALLED"] = "0"; + } + + session.Log("End IsLegacyVersionInstalled"); + return ActionResult.Success; + } } } \ No newline at end of file diff --git a/Installer Projects/CustomActions/CustomActions.csproj b/Installer Projects/CustomActions/CustomActions.csproj index c24e2fce..ce227710 100644 --- a/Installer Projects/CustomActions/CustomActions.csproj +++ b/Installer Projects/CustomActions/CustomActions.csproj @@ -33,7 +33,8 @@ 4 - + + @@ -46,6 +47,7 @@ + diff --git a/Installer Projects/CustomActions/UninstallNSISVersions.cs b/Installer Projects/CustomActions/UninstallNSISVersions.cs new file mode 100644 index 00000000..17866ade --- /dev/null +++ b/Installer Projects/CustomActions/UninstallNSISVersions.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Win32; +using System.Diagnostics; +using System.IO; + +namespace CustomActions +{ + public class UninstallNSISVersions + { + private const string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\mRemoteNG"; + private const string REGISTRY_PATH_Wow6432 = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\mRemoteNG"; + private RegistryKey _activeRegistryPath; + + + public UninstallNSISVersions() + { + GetLegacymRemoteNGRegistryKeyPath(); + } + + public void UninstallLegacyVersion() + { + if (!IsLegacymRemoteNGInstalled()) + return; + string uninstallString = GetLegacyUninstallString(); + ProcessStartInfo processStartInfo = new ProcessStartInfo(uninstallString); + processStartInfo.UseShellExecute = true; + processStartInfo.Arguments = string.Format("_?={0}", uninstallString.Replace("Uninstall.exe", "").Replace(@"""", "")); + Process uninstallProcess = Process.Start(processStartInfo); + while (uninstallProcess.HasExited == false) + { + Debug.WriteLine("Waiting for uninstaller to exit"); + } + } + + public bool IsLegacymRemoteNGInstalled() + { + return (_activeRegistryPath != null); + } + + public string GetLegacyUninstallString() + { + if (IsLegacymRemoteNGInstalled()) + return _activeRegistryPath.GetValue("UninstallString").ToString(); + return ""; + } + + private void GetLegacymRemoteNGRegistryKeyPath() + { + GetUninstallKeyPath(); + GetUninstallKeyPath6432(); + } + + private void GetUninstallKeyPath() + { + try + { + _activeRegistryPath = Registry.LocalMachine.OpenSubKey(REGISTRY_PATH); + } + catch (Exception ex) + { } + } + + private void GetUninstallKeyPath6432() + { + try + { + _activeRegistryPath = Registry.LocalMachine.OpenSubKey(REGISTRY_PATH_Wow6432); + } + catch (Exception ex) + { } + } + } +} \ No newline at end of file diff --git a/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs b/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs new file mode 100644 index 00000000..65dc0d17 --- /dev/null +++ b/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Installer Projects/Installer/Installer.wixproj b/Installer Projects/Installer/Installer.wixproj index 8f3a1f9f..e5c926bd 100644 --- a/Installer Projects/Installer/Installer.wixproj +++ b/Installer Projects/Installer/Installer.wixproj @@ -27,6 +27,7 @@ + diff --git a/Installer Projects/Installer/mRemoteNGV1.wxs b/Installer Projects/Installer/mRemoteNGV1.wxs index 991c1c1e..7889f333 100644 --- a/Installer Projects/Installer/mRemoteNGV1.wxs +++ b/Installer Projects/Installer/mRemoteNGV1.wxs @@ -17,13 +17,17 @@ + - NOT Installed AND (VersionNT = 601 OR VersionNT64 = 601) + (NOT Installed) AND (VersionNT = 601 OR VersionNT64 = 601) + + + (NOT Installed) AND (LEGACYVERSIONINSTALLED = 1) From 93d54a915dbe4b3bee694e1e994f02f205886c85 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Thu, 26 May 2016 16:47:39 -0600 Subject: [PATCH 02/27] Made the legacy uninstall a silent uninstall. Not sure if this is how we will want to release it, but it's reasonably user friendly --- .../CustomActions/CustomActions.cs | 22 +++++++++---------- .../CustomActions/UninstallNSISVersions.cs | 10 +++++++-- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Installer Projects/CustomActions/CustomActions.cs b/Installer Projects/CustomActions/CustomActions.cs index 8d8c5f71..a68ff2e7 100644 --- a/Installer Projects/CustomActions/CustomActions.cs +++ b/Installer Projects/CustomActions/CustomActions.cs @@ -28,17 +28,6 @@ namespace CustomActions return ActionResult.Success; } - [CustomAction] - public static ActionResult UninstallLegacyVersion(Session session) - { - session.Log("Begin UninstallLegacyVersion"); - UninstallNSISVersions uninstaller = new UninstallNSISVersions(); - string uninstallString = uninstaller.GetLegacyUninstallString(); - uninstaller.UninstallLegacyVersion(); - session.Log("End UninstallLegacyVersion"); - return ActionResult.Success; - } - [CustomAction] public static ActionResult IsLegacyVersionInstalled(Session session) { @@ -56,5 +45,16 @@ namespace CustomActions session.Log("End IsLegacyVersionInstalled"); return ActionResult.Success; } + + [CustomAction] + public static ActionResult UninstallLegacyVersion(Session session) + { + session.Log("Begin UninstallLegacyVersion"); + UninstallNSISVersions uninstaller = new UninstallNSISVersions(); + string uninstallString = uninstaller.GetLegacyUninstallString(); + uninstaller.UninstallLegacyVersion(true); + session.Log("End UninstallLegacyVersion"); + return ActionResult.Success; + } } } \ No newline at end of file diff --git a/Installer Projects/CustomActions/UninstallNSISVersions.cs b/Installer Projects/CustomActions/UninstallNSISVersions.cs index 17866ade..8d4df4ec 100644 --- a/Installer Projects/CustomActions/UninstallNSISVersions.cs +++ b/Installer Projects/CustomActions/UninstallNSISVersions.cs @@ -19,14 +19,20 @@ namespace CustomActions GetLegacymRemoteNGRegistryKeyPath(); } - public void UninstallLegacyVersion() + public void UninstallLegacyVersion(bool Silent = false) { if (!IsLegacymRemoteNGInstalled()) return; string uninstallString = GetLegacyUninstallString(); + string forceNonTempUninstaller = string.Format("_?={0}", uninstallString.Replace("Uninstall.exe", "").Replace(@"""", "")); + string silentUninstall = ""; + if (Silent) + { + silentUninstall = "/S"; + } ProcessStartInfo processStartInfo = new ProcessStartInfo(uninstallString); processStartInfo.UseShellExecute = true; - processStartInfo.Arguments = string.Format("_?={0}", uninstallString.Replace("Uninstall.exe", "").Replace(@"""", "")); + processStartInfo.Arguments = string.Format("{0} {1}", forceNonTempUninstaller, silentUninstall); Process uninstallProcess = Process.Start(processStartInfo); while (uninstallProcess.HasExited == false) { From cde7f114f9b21c18a5e90dde76fed89ebc6fde69 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 09:40:34 -0600 Subject: [PATCH 03/27] Cleaned up some code noise in ConnectionTree --- mRemoteV1/Tree/ConnectionTree.cs | 44 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 5e0f024c..646cca1e 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -1,11 +1,11 @@ using Microsoft.VisualBasic; using mRemoteNG.App; using mRemoteNG.Connection; +using mRemoteNG.Messages; using mRemoteNG.Tools.Sorting; using System; using System.Collections.Generic; using System.Windows.Forms; -using mRemoteNG.My; namespace mRemoteNG.Tree { @@ -39,26 +39,24 @@ namespace mRemoteNG.Tree try { if (SelectedNode == null) - { return; - } - if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) + if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "The root item cannot be deleted!"); + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "The root item cannot be deleted!"); } - else if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) + else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) { - if (Tree.ConnectionTreeNode.IsEmpty(SelectedNode) == false) + if (ConnectionTreeNode.IsEmpty(SelectedNode) == false) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) { SelectedNode.Remove(); } } else { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) { foreach (TreeNode tNode in SelectedNode.Nodes) { @@ -68,21 +66,21 @@ namespace mRemoteNG.Tree } } } - else if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) + else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) { SelectedNode.Remove(); } } else { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); } } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Deleting selected node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Deleting selected node failed" + Environment.NewLine + ex.Message, true); } } @@ -98,14 +96,14 @@ namespace mRemoteNG.Tree { ConnectionInfo connectionInfo = SelectedNode.Tag as ConnectionInfo; if (connectionInfo != null) - Tree.ConnectionTreeNode.RenameNode(connectionInfo, newName); + ConnectionTreeNode.RenameNode(connectionInfo, newName); } public static void SetNodeToolTip(MouseEventArgs e, ToolTip tTip) { try { - if (mRemoteNG.Settings.Default.ShowDescriptionTooltipsInTree) + if (Settings.Default.ShowDescriptionTooltipsInTree) { //Find the node under the mouse. TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); @@ -123,7 +121,7 @@ namespace mRemoteNG.Tree else { //Get this node's object data. - if (Tree.ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) { tTip.SetToolTip(_TreeView, (SetNodeToolTip_old_node.Tag as ConnectionInfo).Description); } @@ -132,7 +130,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SetNodeToolTip failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SetNodeToolTip failed" + Environment.NewLine + ex.Message, true); } } @@ -175,7 +173,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeDown failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "MoveNodeDown failed" + Environment.NewLine + ex.Message, true); } } @@ -201,7 +199,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeUp failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "MoveNodeUp failed" + Environment.NewLine + ex.Message, true); } } @@ -219,7 +217,7 @@ namespace mRemoteNG.Tree else return; } - else if (Tree.ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection) + else if (ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection) { treeNode = treeNode.Parent; if (treeNode == null) @@ -263,7 +261,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Sort nodes failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Sort nodes failed" + Environment.NewLine + ex.Message, true); } } @@ -287,7 +285,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); } return null; @@ -315,7 +313,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); } return null; From d7d78d8053b87cc5b9e5c2af7ff3561c561c55b3 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 10:21:28 -0600 Subject: [PATCH 04/27] Inverted conditional statement. This resolved the primary issue in MR-836 where deleting a non-empty folder would not delete all connections within it --- mRemoteV1/Tree/ConnectionTree.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 646cca1e..9af19558 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -47,7 +47,7 @@ namespace mRemoteNG.Tree } else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) { - if (ConnectionTreeNode.IsEmpty(SelectedNode) == false) + if (ConnectionTreeNode.IsEmpty(SelectedNode)) { if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) { From 5c7f120a7ebd1885a052f3cfafb27776b9c15719 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 11:12:32 -0600 Subject: [PATCH 05/27] Fixed bug with ConnectionTreeNode.IsEmpty(). Logic was inverted --- mRemoteV1/Tree/ConnectionTreeNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/Tree/ConnectionTreeNode.cs b/mRemoteV1/Tree/ConnectionTreeNode.cs index bcc68d24..08452f7e 100644 --- a/mRemoteV1/Tree/ConnectionTreeNode.cs +++ b/mRemoteV1/Tree/ConnectionTreeNode.cs @@ -108,7 +108,7 @@ namespace mRemoteNG.Tree { try { - if (treeNode.Nodes.Count <= 0) + if (treeNode.Nodes.Count > 0) return false; } catch (Exception ex) From eab5a42d9332fe09eee5480554f5a3e71423c317 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 11:18:05 -0600 Subject: [PATCH 06/27] Refactored ConnectionTree.DeleteSelectedNode() - extracted some methods to make it more readable --- mRemoteV1/Tree/ConnectionTree.cs | 55 ++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 9af19558..576159d7 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -38,25 +38,19 @@ namespace mRemoteNG.Tree { try { - if (SelectedNode == null) + if (!SelectedNodeIsAValidDeletionTarget()) return; - if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) - { - Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "The root item cannot be deleted!"); - } - else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) + if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) { if (ConnectionTreeNode.IsEmpty(SelectedNode)) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) - { + if (UserConfirmsEmptyFolderDeletion()) SelectedNode.Remove(); - } } else { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) + if (UserConfirmsNonEmptyFolderDeletion()) { foreach (TreeNode tNode in SelectedNode.Nodes) { @@ -68,10 +62,8 @@ namespace mRemoteNG.Tree } else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text), MsgBoxStyle.YesNo | MsgBoxStyle.Question, null) == MsgBoxResult.Yes) - { + if (UserConfirmsConnectionDeletion()) SelectedNode.Remove(); - } } else { @@ -84,6 +76,43 @@ namespace mRemoteNG.Tree } } + private static bool SelectedNodeIsAValidDeletionTarget() + { + bool validDeletionTarget = true; + if (SelectedNode == null) + validDeletionTarget = false; + else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) + { + validDeletionTarget = false; + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "The root item cannot be deleted!"); + } + return validDeletionTarget; + } + + private static bool UserConfirmsEmptyFolderDeletion() + { + string messagePrompt = string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text); + return PromptUser(messagePrompt); + } + + private static bool UserConfirmsNonEmptyFolderDeletion() + { + string messagePrompt = string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text); + return PromptUser(messagePrompt); + } + + private static bool UserConfirmsConnectionDeletion() + { + string messagePrompt = string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text); + return PromptUser(messagePrompt); + } + + private static bool PromptUser(string PromptMessage) + { + MsgBoxResult msgBoxResponse = Interaction.MsgBox(PromptMessage, MsgBoxStyle.YesNo | MsgBoxStyle.Question, null); + return (msgBoxResponse == MsgBoxResult.Yes); + } + public static void StartRenameSelectedNode() { if (SelectedNode != null) From d7f64fec4ffe69056d70951004b528128a97ceca Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 11:22:40 -0600 Subject: [PATCH 07/27] Added check for null nodes in ConnectionTree.DeleteSelectedNode(). This now fully resolves the issues noted in MR-836 --- mRemoteV1/Tree/ConnectionTree.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 576159d7..e4631705 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -54,7 +54,8 @@ namespace mRemoteNG.Tree { foreach (TreeNode tNode in SelectedNode.Nodes) { - tNode.Remove(); + if (tNode != null) + tNode.Remove(); } SelectedNode.Remove(); } From 33c9774b21e55a15ee3207f553beb614c28023e0 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 11:39:18 -0600 Subject: [PATCH 08/27] There was still a bug with deleting folders that had contents. Using a builtin function to do this instead of trying to re-implement. I am hoping this really does fix MR-836 this time. --- mRemoteV1/Tree/ConnectionTree.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index e4631705..94215878 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -52,11 +52,7 @@ namespace mRemoteNG.Tree { if (UserConfirmsNonEmptyFolderDeletion()) { - foreach (TreeNode tNode in SelectedNode.Nodes) - { - if (tNode != null) - tNode.Remove(); - } + SelectedNode.Nodes.Clear(); SelectedNode.Remove(); } } From 09102325eb02b90f0dfb2af548c1a94a36753923 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 27 May 2016 13:56:04 -0400 Subject: [PATCH 09/27] Fix MR-828 NullReferenceException SetNodeToolTip Also, remove Microsoft.VisualBasic references --- mRemoteV1/Tree/ConnectionTree.cs | 83 ++++++++++++++++---------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 5e0f024c..afa091d3 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -1,17 +1,16 @@ -using Microsoft.VisualBasic; -using mRemoteNG.App; -using mRemoteNG.Connection; -using mRemoteNG.Tools.Sorting; -using System; +using System; using System.Collections.Generic; using System.Windows.Forms; -using mRemoteNG.My; +using mRemoteNG.App; +using mRemoteNG.Connection; +using mRemoteNG.Messages; +using mRemoteNG.Tools.Sorting; namespace mRemoteNG.Tree { public class ConnectionTree { - private static TreeNode SetNodeToolTip_old_node = null; + private static TreeNode SetNodeToolTip_old_node; private static TreeNode treeNodeToBeSelected; private static TreeView _TreeView; @@ -43,22 +42,23 @@ namespace mRemoteNG.Tree return; } - if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) + if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Root) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "The root item cannot be deleted!"); + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "The root item cannot be deleted!"); } - else if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) + else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Container) { - if (Tree.ConnectionTreeNode.IsEmpty(SelectedNode) == false) + if (ConnectionTreeNode.IsEmpty(SelectedNode) == false) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + + if (MessageBox.Show(string.Format(Language.strConfirmDeleteNodeFolder, SelectedNode.Text), "Confirm Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes) { SelectedNode.Remove(); } } else { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + if (MessageBox.Show(string.Format(Language.strConfirmDeleteNodeFolderNotEmpty, SelectedNode.Text), "Confirm Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (TreeNode tNode in SelectedNode.Nodes) { @@ -68,21 +68,21 @@ namespace mRemoteNG.Tree } } } - else if (Tree.ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) + else if (ConnectionTreeNode.GetNodeType(SelectedNode) == TreeNodeType.Connection) { - if (Interaction.MsgBox(string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text), (Microsoft.VisualBasic.MsgBoxStyle)(MsgBoxStyle.YesNo | MsgBoxStyle.Question), null) == MsgBoxResult.Yes) + if (MessageBox.Show(string.Format(Language.strConfirmDeleteNodeConnection, SelectedNode.Text), "Confirm Delete?", MessageBoxButtons.YesNo) == DialogResult.Yes) { SelectedNode.Remove(); } } else { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, "Tree item type is unknown so it cannot be deleted!"); } } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Deleting selected node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Deleting selected node failed" + Environment.NewLine + ex.Message, true); } } @@ -98,18 +98,18 @@ namespace mRemoteNG.Tree { ConnectionInfo connectionInfo = SelectedNode.Tag as ConnectionInfo; if (connectionInfo != null) - Tree.ConnectionTreeNode.RenameNode(connectionInfo, newName); + ConnectionTreeNode.RenameNode(connectionInfo, newName); } public static void SetNodeToolTip(MouseEventArgs e, ToolTip tTip) { try { - if (mRemoteNG.Settings.Default.ShowDescriptionTooltipsInTree) + if (Settings.Default.ShowDescriptionTooltipsInTree) { //Find the node under the mouse. TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); - if (new_node.Equals(SetNodeToolTip_old_node)) + if (new_node == null || new_node.Equals(SetNodeToolTip_old_node)) { return; } @@ -123,16 +123,16 @@ namespace mRemoteNG.Tree else { //Get this node's object data. - if (Tree.ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) { - tTip.SetToolTip(_TreeView, (SetNodeToolTip_old_node.Tag as ConnectionInfo).Description); + tTip.SetToolTip(_TreeView, ((ConnectionInfo) SetNodeToolTip_old_node.Tag).Description); } } } } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SetNodeToolTip failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SetNodeToolTip failed" + Environment.NewLine + ex.Message, true); } } @@ -175,7 +175,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeDown failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "MoveNodeDown failed" + Environment.NewLine + ex.Message, true); } } @@ -201,7 +201,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "MoveNodeUp failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "MoveNodeUp failed" + Environment.NewLine + ex.Message, true); } } @@ -219,7 +219,7 @@ namespace mRemoteNG.Tree else return; } - else if (Tree.ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection) + else if (ConnectionTreeNode.GetNodeType(treeNode) == TreeNodeType.Connection) { treeNode = treeNode.Parent; if (treeNode == null) @@ -251,8 +251,11 @@ namespace mRemoteNG.Tree currentNode = childNode; } } - treeNode.Nodes.Remove(currentNode); - sortedNodes.Add(currentNode); + if (currentNode != null) + { + treeNode.Nodes.Remove(currentNode); + sortedNodes.Add(currentNode); + } currentNode = null; } @@ -263,14 +266,13 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Sort nodes failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Sort nodes failed" + Environment.NewLine + ex.Message, true); } } public static TreeNode Find(TreeNode treeNode, string searchFor) { - TreeNode tmpNode = default(TreeNode); - + try { if (IsThisTheNodeWeAreSearchingFor(treeNode, searchFor)) @@ -278,8 +280,8 @@ namespace mRemoteNG.Tree foreach (TreeNode childNode in treeNode.Nodes) { - tmpNode = Find(childNode, searchFor); - if (!(tmpNode == null)) + TreeNode tmpNode = Find(childNode, searchFor); + if (tmpNode != null) { return tmpNode; } @@ -287,7 +289,7 @@ namespace mRemoteNG.Tree } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); } return null; @@ -300,7 +302,6 @@ namespace mRemoteNG.Tree public static TreeNode Find(TreeNode treeNode, ConnectionInfo conInfo) { - TreeNode tmpNode = default(TreeNode); try { if (treeNode.Tag == conInfo) @@ -308,14 +309,14 @@ namespace mRemoteNG.Tree foreach (TreeNode childNode in treeNode.Nodes) { - tmpNode = Find(childNode, conInfo); - if (!(tmpNode == null)) + TreeNode tmpNode = Find(childNode, conInfo); + if (tmpNode != null) return tmpNode; } } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "Find node failed" + Environment.NewLine + ex.Message, true); } return null; @@ -326,7 +327,7 @@ namespace mRemoteNG.Tree { if (TreeView.InvokeRequired) { - ResetTreeDelegate resetTreeDelegate = new ResetTreeDelegate(ResetTree); + ResetTreeDelegate resetTreeDelegate = ResetTree; Windows.treeForm.Invoke(resetTreeDelegate); } else @@ -341,9 +342,9 @@ namespace mRemoteNG.Tree private delegate void SelectNodeCB(); private static void SelectNode() { - if (_TreeView.InvokeRequired == true) + if (_TreeView.InvokeRequired) { - SelectNodeCB d = new SelectNodeCB(SelectNode); + SelectNodeCB d = SelectNode; _TreeView.Invoke(d); } else From a055d7f4a8c9414bd7a2bc3eab8fb022c8c076ae Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 11:56:48 -0600 Subject: [PATCH 10/27] Slight optimization to prevent window flicker when deleting a folder with many connections. --- mRemoteV1/Tree/ConnectionTree.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index 94215878..ebd854e3 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -52,8 +52,10 @@ namespace mRemoteNG.Tree { if (UserConfirmsNonEmptyFolderDeletion()) { + TreeView.BeginUpdate(); SelectedNode.Nodes.Clear(); SelectedNode.Remove(); + TreeView.EndUpdate(); } } } From 6d8f375ae144777659893328bc7e8ab3086214bb Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 27 May 2016 14:21:34 -0400 Subject: [PATCH 11/27] Remove Microsoft.VisualBasic references --- mRemoteV1/App/Runtime.cs | 5 +- mRemoteV1/UI/Window/ExternalToolsWindow.cs | 26 +- mRemoteV1/UI/Window/SSHTransferWindow.cs | 675 ++++++++++----------- mRemoteV1/UI/Window/SSHTransferWindow.resx | 6 +- 4 files changed, 355 insertions(+), 357 deletions(-) diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs index f85a5d44..81c0526c 100644 --- a/mRemoteV1/App/Runtime.cs +++ b/mRemoteV1/App/Runtime.cs @@ -1,4 +1,3 @@ -using log4net; using Microsoft.VisualBasic; using mRemoteNG.App.Info; using mRemoteNG.Config.Connections; @@ -555,7 +554,9 @@ namespace mRemoteNG.App } else { - Interaction.MsgBox(string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)), (int)MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, null); + MessageBox.Show(frmMain.Default, + string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)), + "Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } diff --git a/mRemoteV1/UI/Window/ExternalToolsWindow.cs b/mRemoteV1/UI/Window/ExternalToolsWindow.cs index a83045db..a6d8cf77 100644 --- a/mRemoteV1/UI/Window/ExternalToolsWindow.cs +++ b/mRemoteV1/UI/Window/ExternalToolsWindow.cs @@ -1,10 +1,8 @@ using System.Collections.Generic; using System; -using Microsoft.VisualBasic; using System.Windows.Forms; using mRemoteNG.App; using WeifenLuo.WinFormsUI.Docking; -using mRemoteNG.My; using mRemoteNG.UI.Forms; @@ -23,7 +21,7 @@ namespace mRemoteNG.UI.Window #endregion #region Private Fields - private Tools.ExternalTool _selectedTool = null; + private Tools.ExternalTool _selectedTool; #endregion #region Private Methods @@ -34,12 +32,12 @@ namespace mRemoteNG.UI.Window UpdateToolsListView(); } - static public void ExternalTools_FormClosed(System.Object sender, FormClosedEventArgs e) + static public void ExternalTools_FormClosed(object sender, FormClosedEventArgs e) { - mRemoteNG.Config.Settings.SettingsSaver.SaveExternalAppsToXML(); + Config.Settings.SettingsSaver.SaveExternalAppsToXML(); } - public void NewTool_Click(System.Object sender, EventArgs e) + public void NewTool_Click(object sender, EventArgs e) { try { @@ -54,11 +52,11 @@ namespace mRemoteNG.UI.Window } } - public void DeleteTool_Click(System.Object sender, EventArgs e) + public void DeleteTool_Click(object sender, EventArgs e) { try { - string message = ""; + string message; if (ToolsListView.SelectedItems.Count == 1) { message = string.Format(Language.strConfirmDeleteExternalTool, ToolsListView.SelectedItems[0].Text); @@ -71,8 +69,8 @@ namespace mRemoteNG.UI.Window { return ; } - - if (!(Interaction.MsgBox(message, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.Yes)) + + if (MessageBox.Show(frmMain.Default, message, "Question?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return ; } @@ -95,12 +93,12 @@ namespace mRemoteNG.UI.Window } } - public void LaunchTool_Click(System.Object sender, EventArgs e) + public void LaunchTool_Click(object sender, EventArgs e) { LaunchTool(); } - public void ToolsListView_SelectedIndexChanged(System.Object sender, EventArgs e) + public void ToolsListView_SelectedIndexChanged(object sender, EventArgs e) { try { @@ -161,7 +159,7 @@ namespace mRemoteNG.UI.Window } } - public void BrowseButton_Click(System.Object sender, EventArgs e) + public void BrowseButton_Click(object sender, EventArgs e) { try { @@ -181,7 +179,7 @@ namespace mRemoteNG.UI.Window } } - public void TryToIntegrateCheckBox_CheckedChanged(System.Object sender, EventArgs e) + public void TryToIntegrateCheckBox_CheckedChanged(object sender, EventArgs e) { if (TryToIntegrateCheckBox.Checked) { diff --git a/mRemoteV1/UI/Window/SSHTransferWindow.cs b/mRemoteV1/UI/Window/SSHTransferWindow.cs index f5a564d4..aa120796 100644 --- a/mRemoteV1/UI/Window/SSHTransferWindow.cs +++ b/mRemoteV1/UI/Window/SSHTransferWindow.cs @@ -1,10 +1,9 @@ -using Microsoft.VisualBasic; using mRemoteNG.App; using System; using System.IO; using System.Threading; using System.Windows.Forms; -using mRemoteNG.My; +using mRemoteNG.UI.Forms; using Tamir.SharpSsh; using WeifenLuo.WinFormsUI.Docking; @@ -14,298 +13,298 @@ namespace mRemoteNG.UI.Window public class SSHTransferWindow : BaseWindow { #region Form Init - internal System.Windows.Forms.ProgressBar pbStatus; - internal System.Windows.Forms.Button btnTransfer; - internal System.Windows.Forms.TextBox txtUser; - internal System.Windows.Forms.TextBox txtPassword; - internal System.Windows.Forms.TextBox txtHost; - internal System.Windows.Forms.TextBox txtPort; - internal System.Windows.Forms.Label lblHost; - internal System.Windows.Forms.Label lblPort; - internal System.Windows.Forms.Label lblUser; - internal System.Windows.Forms.Label lblPassword; - internal System.Windows.Forms.Label lblProtocol; - internal System.Windows.Forms.RadioButton radProtSCP; - internal System.Windows.Forms.RadioButton radProtSFTP; - internal System.Windows.Forms.GroupBox grpConnection; - internal System.Windows.Forms.Button btnBrowse; - internal System.Windows.Forms.Label lblRemoteFile; - internal System.Windows.Forms.TextBox txtRemoteFile; - internal System.Windows.Forms.TextBox txtLocalFile; - internal System.Windows.Forms.Label lblLocalFile; - internal System.Windows.Forms.GroupBox grpFiles; + internal ProgressBar pbStatus; + internal Button btnTransfer; + internal TextBox txtUser; + internal TextBox txtPassword; + internal TextBox txtHost; + internal TextBox txtPort; + internal Label lblHost; + internal Label lblPort; + internal Label lblUser; + internal Label lblPassword; + internal Label lblProtocol; + internal RadioButton radProtSCP; + internal RadioButton radProtSFTP; + internal GroupBox grpConnection; + internal Button btnBrowse; + internal Label lblRemoteFile; + internal TextBox txtRemoteFile; + internal TextBox txtLocalFile; + internal Label lblLocalFile; + internal GroupBox grpFiles; private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SSHTransferWindow)); - this.grpFiles = new System.Windows.Forms.GroupBox(); - this.Load += new System.EventHandler(SSHTransfer_Load); - this.lblLocalFile = new System.Windows.Forms.Label(); - this.txtLocalFile = new System.Windows.Forms.TextBox(); - this.txtRemoteFile = new System.Windows.Forms.TextBox(); - this.lblRemoteFile = new System.Windows.Forms.Label(); - this.btnBrowse = new System.Windows.Forms.Button(); - this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click); - this.grpConnection = new System.Windows.Forms.GroupBox(); - this.radProtSFTP = new System.Windows.Forms.RadioButton(); - this.radProtSCP = new System.Windows.Forms.RadioButton(); - this.lblProtocol = new System.Windows.Forms.Label(); - this.lblPassword = new System.Windows.Forms.Label(); - this.lblUser = new System.Windows.Forms.Label(); - this.lblPort = new System.Windows.Forms.Label(); - this.lblHost = new System.Windows.Forms.Label(); - this.txtPort = new System.Windows.Forms.TextBox(); - this.txtHost = new System.Windows.Forms.TextBox(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtUser = new System.Windows.Forms.TextBox(); - this.btnTransfer = new System.Windows.Forms.Button(); - this.btnTransfer.Click += new System.EventHandler(this.btnTransfer_Click); - this.pbStatus = new System.Windows.Forms.ProgressBar(); - this.grpFiles.SuspendLayout(); - this.grpConnection.SuspendLayout(); - this.SuspendLayout(); - // - //grpFiles - // - this.grpFiles.Anchor = (System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.grpFiles.Controls.Add(this.lblLocalFile); - this.grpFiles.Controls.Add(this.txtLocalFile); - this.grpFiles.Controls.Add(this.txtRemoteFile); - this.grpFiles.Controls.Add(this.lblRemoteFile); - this.grpFiles.Controls.Add(this.btnBrowse); - this.grpFiles.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.grpFiles.Location = new System.Drawing.Point(12, 153); - this.grpFiles.Name = "grpFiles"; - this.grpFiles.Size = new System.Drawing.Size(668, 194); - this.grpFiles.TabIndex = 2000; - this.grpFiles.TabStop = false; - this.grpFiles.Text = "Files"; - // - //lblLocalFile - // - this.lblLocalFile.AutoSize = true; - this.lblLocalFile.Location = new System.Drawing.Point(20, 25); - this.lblLocalFile.Name = "lblLocalFile"; - this.lblLocalFile.Size = new System.Drawing.Size(52, 13); - this.lblLocalFile.TabIndex = 10; - this.lblLocalFile.Text = "Local file:"; - // - //txtLocalFile - // - this.txtLocalFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtLocalFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtLocalFile.Location = new System.Drawing.Point(105, 23); - this.txtLocalFile.Name = "txtLocalFile"; - this.txtLocalFile.Size = new System.Drawing.Size(455, 20); - this.txtLocalFile.TabIndex = 20; - // - //txtRemoteFile - // - this.txtRemoteFile.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtRemoteFile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtRemoteFile.Location = new System.Drawing.Point(105, 49); - this.txtRemoteFile.Name = "txtRemoteFile"; - this.txtRemoteFile.Size = new System.Drawing.Size(542, 20); - this.txtRemoteFile.TabIndex = 50; - // - //lblRemoteFile - // - this.lblRemoteFile.AutoSize = true; - this.lblRemoteFile.Location = new System.Drawing.Point(20, 51); - this.lblRemoteFile.Name = "lblRemoteFile"; - this.lblRemoteFile.Size = new System.Drawing.Size(63, 13); - this.lblRemoteFile.TabIndex = 40; - this.lblRemoteFile.Text = "Remote file:"; - // - //btnBrowse - // - this.btnBrowse.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.btnBrowse.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnBrowse.Location = new System.Drawing.Point(566, 21); - this.btnBrowse.Name = "btnBrowse"; - this.btnBrowse.Size = new System.Drawing.Size(81, 23); - this.btnBrowse.TabIndex = 30; - this.btnBrowse.Text = "Browse"; - this.btnBrowse.UseVisualStyleBackColor = true; - // - //grpConnection - // - this.grpConnection.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.grpConnection.Controls.Add(this.radProtSFTP); - this.grpConnection.Controls.Add(this.radProtSCP); - this.grpConnection.Controls.Add(this.lblProtocol); - this.grpConnection.Controls.Add(this.lblPassword); - this.grpConnection.Controls.Add(this.lblUser); - this.grpConnection.Controls.Add(this.lblPort); - this.grpConnection.Controls.Add(this.lblHost); - this.grpConnection.Controls.Add(this.txtPort); - this.grpConnection.Controls.Add(this.txtHost); - this.grpConnection.Controls.Add(this.txtPassword); - this.grpConnection.Controls.Add(this.txtUser); - this.grpConnection.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.grpConnection.Location = new System.Drawing.Point(12, 12); - this.grpConnection.Name = "grpConnection"; - this.grpConnection.Size = new System.Drawing.Size(668, 135); - this.grpConnection.TabIndex = 1000; - this.grpConnection.TabStop = false; - this.grpConnection.Text = "Connection"; - // - //radProtSFTP - // - this.radProtSFTP.AutoSize = true; - this.radProtSFTP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radProtSFTP.Location = new System.Drawing.Point(153, 103); - this.radProtSFTP.Name = "radProtSFTP"; - this.radProtSFTP.Size = new System.Drawing.Size(51, 17); - this.radProtSFTP.TabIndex = 110; - this.radProtSFTP.Text = "SFTP"; - this.radProtSFTP.UseVisualStyleBackColor = true; - // - //radProtSCP - // - this.radProtSCP.AutoSize = true; - this.radProtSCP.Checked = true; - this.radProtSCP.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.radProtSCP.Location = new System.Drawing.Point(92, 103); - this.radProtSCP.Name = "radProtSCP"; - this.radProtSCP.Size = new System.Drawing.Size(45, 17); - this.radProtSCP.TabIndex = 100; - this.radProtSCP.TabStop = true; - this.radProtSCP.Text = "SCP"; - this.radProtSCP.UseVisualStyleBackColor = true; - // - //lblProtocol - // - this.lblProtocol.AutoSize = true; - this.lblProtocol.Location = new System.Drawing.Point(20, 105); - this.lblProtocol.Name = "lblProtocol"; - this.lblProtocol.Size = new System.Drawing.Size(49, 13); - this.lblProtocol.TabIndex = 90; - this.lblProtocol.Text = "Protocol:"; - // - //lblPassword - // - this.lblPassword.AutoSize = true; - this.lblPassword.Location = new System.Drawing.Point(20, 79); - this.lblPassword.Name = "lblPassword"; - this.lblPassword.Size = new System.Drawing.Size(56, 13); - this.lblPassword.TabIndex = 70; - this.lblPassword.Text = "Password:"; - // - //lblUser - // - this.lblUser.AutoSize = true; - this.lblUser.Location = new System.Drawing.Point(20, 53); - this.lblUser.Name = "lblUser"; - this.lblUser.Size = new System.Drawing.Size(32, 13); - this.lblUser.TabIndex = 50; - this.lblUser.Text = "User:"; - // - //lblPort - // - this.lblPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.lblPort.AutoSize = true; - this.lblPort.Location = new System.Drawing.Point(582, 27); - this.lblPort.Name = "lblPort"; - this.lblPort.Size = new System.Drawing.Size(29, 13); - this.lblPort.TabIndex = 30; - this.lblPort.Text = "Port:"; - // - //lblHost - // - this.lblHost.AutoSize = true; - this.lblHost.Location = new System.Drawing.Point(20, 27); - this.lblHost.Name = "lblHost"; - this.lblHost.Size = new System.Drawing.Size(32, 13); - this.lblHost.TabIndex = 10; - this.lblHost.Text = "Host:"; - // - //txtPort - // - this.txtPort.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right); - this.txtPort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtPort.Location = new System.Drawing.Point(617, 25); - this.txtPort.Name = "txtPort"; - this.txtPort.Size = new System.Drawing.Size(30, 20); - this.txtPort.TabIndex = 40; - // - //txtHost - // - this.txtHost.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtHost.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtHost.Location = new System.Drawing.Point(105, 25); - this.txtHost.Name = "txtHost"; - this.txtHost.Size = new System.Drawing.Size(471, 20); - this.txtHost.TabIndex = 20; - // - //txtPassword - // - this.txtPassword.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtPassword.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtPassword.Location = new System.Drawing.Point(105, 77); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = global::Microsoft.VisualBasic.Strings.ChrW(42); - this.txtPassword.Size = new System.Drawing.Size(471, 20); - this.txtPassword.TabIndex = 80; - // - //txtUser - // - this.txtUser.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.txtUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtUser.Location = new System.Drawing.Point(105, 51); - this.txtUser.Name = "txtUser"; - this.txtUser.Size = new System.Drawing.Size(471, 20); - this.txtUser.TabIndex = 60; - // - //btnTransfer - // - this.btnTransfer.Anchor = (System.Windows.Forms.AnchorStyles) (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right); - this.btnTransfer.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnTransfer.Image = Resources.SSHTransfer; - this.btnTransfer.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; - this.btnTransfer.Location = new System.Drawing.Point(597, 382); - this.btnTransfer.Name = "btnTransfer"; - this.btnTransfer.Size = new System.Drawing.Size(83, 29); - this.btnTransfer.TabIndex = 10000; - this.btnTransfer.Text = "Transfer"; - this.btnTransfer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - this.btnTransfer.UseVisualStyleBackColor = true; - // - //pbStatus - // - this.pbStatus.Anchor = (System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right); - this.pbStatus.Location = new System.Drawing.Point(12, 353); - this.pbStatus.Name = "pbStatus"; - this.pbStatus.Size = new System.Drawing.Size(668, 23); - this.pbStatus.TabIndex = 3000; - // - //SSHTransfer - // - this.ClientSize = new System.Drawing.Size(692, 423); - this.Controls.Add(this.grpFiles); - this.Controls.Add(this.grpConnection); - this.Controls.Add(this.btnTransfer); - this.Controls.Add(this.pbStatus); - this.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, Convert.ToByte(0)); - this.Icon = (System.Drawing.Icon) (resources.GetObject("$this.Icon")); - this.Name = "SSHTransfer"; - this.TabText = "SSH File Transfer"; - this.Text = "SSH File Transfer"; - this.grpFiles.ResumeLayout(false); - this.grpFiles.PerformLayout(); - this.grpConnection.ResumeLayout(false); - this.grpConnection.PerformLayout(); - this.ResumeLayout(false); - + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SSHTransferWindow)); + grpFiles = new GroupBox(); + lblLocalFile = new Label(); + txtLocalFile = new TextBox(); + txtRemoteFile = new TextBox(); + lblRemoteFile = new Label(); + btnBrowse = new Button(); + grpConnection = new GroupBox(); + radProtSFTP = new RadioButton(); + radProtSCP = new RadioButton(); + lblProtocol = new Label(); + lblPassword = new Label(); + lblUser = new Label(); + lblPort = new Label(); + lblHost = new Label(); + txtPort = new TextBox(); + txtHost = new TextBox(); + txtPassword = new TextBox(); + txtUser = new TextBox(); + btnTransfer = new Button(); + pbStatus = new ProgressBar(); + grpFiles.SuspendLayout(); + grpConnection.SuspendLayout(); + SuspendLayout(); + // + // grpFiles + // + grpFiles.Anchor = (((AnchorStyles.Top | AnchorStyles.Bottom) + | AnchorStyles.Left) + | AnchorStyles.Right); + grpFiles.Controls.Add(lblLocalFile); + grpFiles.Controls.Add(txtLocalFile); + grpFiles.Controls.Add(txtRemoteFile); + grpFiles.Controls.Add(lblRemoteFile); + grpFiles.Controls.Add(btnBrowse); + grpFiles.FlatStyle = FlatStyle.Flat; + grpFiles.Location = new System.Drawing.Point(12, 153); + grpFiles.Name = "grpFiles"; + grpFiles.Size = new System.Drawing.Size(668, 194); + grpFiles.TabIndex = 2000; + grpFiles.TabStop = false; + grpFiles.Text = "Files"; + // + // lblLocalFile + // + lblLocalFile.AutoSize = true; + lblLocalFile.Location = new System.Drawing.Point(20, 25); + lblLocalFile.Name = "lblLocalFile"; + lblLocalFile.Size = new System.Drawing.Size(55, 13); + lblLocalFile.TabIndex = 10; + lblLocalFile.Text = "Local file:"; + // + // txtLocalFile + // + txtLocalFile.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + txtLocalFile.BorderStyle = BorderStyle.FixedSingle; + txtLocalFile.Location = new System.Drawing.Point(105, 23); + txtLocalFile.Name = "txtLocalFile"; + txtLocalFile.Size = new System.Drawing.Size(455, 22); + txtLocalFile.TabIndex = 20; + // + // txtRemoteFile + // + txtRemoteFile.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + txtRemoteFile.BorderStyle = BorderStyle.FixedSingle; + txtRemoteFile.Location = new System.Drawing.Point(105, 49); + txtRemoteFile.Name = "txtRemoteFile"; + txtRemoteFile.Size = new System.Drawing.Size(542, 22); + txtRemoteFile.TabIndex = 50; + // + // lblRemoteFile + // + lblRemoteFile.AutoSize = true; + lblRemoteFile.Location = new System.Drawing.Point(20, 51); + lblRemoteFile.Name = "lblRemoteFile"; + lblRemoteFile.Size = new System.Drawing.Size(68, 13); + lblRemoteFile.TabIndex = 40; + lblRemoteFile.Text = "Remote file:"; + // + // btnBrowse + // + btnBrowse.Anchor = (AnchorStyles.Top | AnchorStyles.Right); + btnBrowse.FlatStyle = FlatStyle.Flat; + btnBrowse.Location = new System.Drawing.Point(566, 21); + btnBrowse.Name = "btnBrowse"; + btnBrowse.Size = new System.Drawing.Size(81, 23); + btnBrowse.TabIndex = 30; + btnBrowse.Text = "Browse"; + btnBrowse.UseVisualStyleBackColor = true; + btnBrowse.Click += new EventHandler(btnBrowse_Click); + // + // grpConnection + // + grpConnection.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + grpConnection.Controls.Add(radProtSFTP); + grpConnection.Controls.Add(radProtSCP); + grpConnection.Controls.Add(lblProtocol); + grpConnection.Controls.Add(lblPassword); + grpConnection.Controls.Add(lblUser); + grpConnection.Controls.Add(lblPort); + grpConnection.Controls.Add(lblHost); + grpConnection.Controls.Add(txtPort); + grpConnection.Controls.Add(txtHost); + grpConnection.Controls.Add(txtPassword); + grpConnection.Controls.Add(txtUser); + grpConnection.FlatStyle = FlatStyle.Flat; + grpConnection.Location = new System.Drawing.Point(12, 12); + grpConnection.Name = "grpConnection"; + grpConnection.Size = new System.Drawing.Size(668, 135); + grpConnection.TabIndex = 1000; + grpConnection.TabStop = false; + grpConnection.Text = "Connection"; + // + // radProtSFTP + // + radProtSFTP.AutoSize = true; + radProtSFTP.FlatStyle = FlatStyle.Flat; + radProtSFTP.Location = new System.Drawing.Point(153, 103); + radProtSFTP.Name = "radProtSFTP"; + radProtSFTP.Size = new System.Drawing.Size(47, 17); + radProtSFTP.TabIndex = 110; + radProtSFTP.Text = "SFTP"; + radProtSFTP.UseVisualStyleBackColor = true; + // + // radProtSCP + // + radProtSCP.AutoSize = true; + radProtSCP.Checked = true; + radProtSCP.FlatStyle = FlatStyle.Flat; + radProtSCP.Location = new System.Drawing.Point(92, 103); + radProtSCP.Name = "radProtSCP"; + radProtSCP.Size = new System.Drawing.Size(43, 17); + radProtSCP.TabIndex = 100; + radProtSCP.TabStop = true; + radProtSCP.Text = "SCP"; + radProtSCP.UseVisualStyleBackColor = true; + // + // lblProtocol + // + lblProtocol.AutoSize = true; + lblProtocol.Location = new System.Drawing.Point(20, 105); + lblProtocol.Name = "lblProtocol"; + lblProtocol.Size = new System.Drawing.Size(53, 13); + lblProtocol.TabIndex = 90; + lblProtocol.Text = "Protocol:"; + // + // lblPassword + // + lblPassword.AutoSize = true; + lblPassword.Location = new System.Drawing.Point(20, 79); + lblPassword.Name = "lblPassword"; + lblPassword.Size = new System.Drawing.Size(59, 13); + lblPassword.TabIndex = 70; + lblPassword.Text = "Password:"; + // + // lblUser + // + lblUser.AutoSize = true; + lblUser.Location = new System.Drawing.Point(20, 53); + lblUser.Name = "lblUser"; + lblUser.Size = new System.Drawing.Size(33, 13); + lblUser.TabIndex = 50; + lblUser.Text = "User:"; + // + // lblPort + // + lblPort.Anchor = (AnchorStyles.Top | AnchorStyles.Right); + lblPort.AutoSize = true; + lblPort.Location = new System.Drawing.Point(582, 27); + lblPort.Name = "lblPort"; + lblPort.Size = new System.Drawing.Size(31, 13); + lblPort.TabIndex = 30; + lblPort.Text = "Port:"; + // + // lblHost + // + lblHost.AutoSize = true; + lblHost.Location = new System.Drawing.Point(20, 27); + lblHost.Name = "lblHost"; + lblHost.Size = new System.Drawing.Size(34, 13); + lblHost.TabIndex = 10; + lblHost.Text = "Host:"; + // + // txtPort + // + txtPort.Anchor = (AnchorStyles.Top | AnchorStyles.Right); + txtPort.BorderStyle = BorderStyle.FixedSingle; + txtPort.Location = new System.Drawing.Point(617, 25); + txtPort.Name = "txtPort"; + txtPort.Size = new System.Drawing.Size(30, 22); + txtPort.TabIndex = 40; + // + // txtHost + // + txtHost.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + txtHost.BorderStyle = BorderStyle.FixedSingle; + txtHost.Location = new System.Drawing.Point(105, 25); + txtHost.Name = "txtHost"; + txtHost.Size = new System.Drawing.Size(471, 22); + txtHost.TabIndex = 20; + // + // txtPassword + // + txtPassword.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + txtPassword.BorderStyle = BorderStyle.FixedSingle; + txtPassword.Location = new System.Drawing.Point(105, 77); + txtPassword.Name = "txtPassword"; + txtPassword.Size = new System.Drawing.Size(471, 22); + txtPassword.TabIndex = 80; + txtPassword.UseSystemPasswordChar = true; + // + // txtUser + // + txtUser.Anchor = ((AnchorStyles.Top | AnchorStyles.Left) + | AnchorStyles.Right); + txtUser.BorderStyle = BorderStyle.FixedSingle; + txtUser.Location = new System.Drawing.Point(105, 51); + txtUser.Name = "txtUser"; + txtUser.Size = new System.Drawing.Size(471, 22); + txtUser.TabIndex = 60; + // + // btnTransfer + // + btnTransfer.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right); + btnTransfer.FlatStyle = FlatStyle.Flat; + btnTransfer.Image = Resources.SSHTransfer; + btnTransfer.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + btnTransfer.Location = new System.Drawing.Point(597, 382); + btnTransfer.Name = "btnTransfer"; + btnTransfer.Size = new System.Drawing.Size(83, 29); + btnTransfer.TabIndex = 10000; + btnTransfer.Text = "Transfer"; + btnTransfer.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + btnTransfer.UseVisualStyleBackColor = true; + btnTransfer.Click += new EventHandler(btnTransfer_Click); + // + // pbStatus + // + pbStatus.Anchor = ((AnchorStyles.Bottom | AnchorStyles.Left) + | AnchorStyles.Right); + pbStatus.Location = new System.Drawing.Point(12, 353); + pbStatus.Name = "pbStatus"; + pbStatus.Size = new System.Drawing.Size(668, 23); + pbStatus.TabIndex = 3000; + // + // SSHTransferWindow + // + ClientSize = new System.Drawing.Size(692, 423); + Controls.Add(grpFiles); + Controls.Add(grpConnection); + Controls.Add(btnTransfer); + Controls.Add(pbStatus); + Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); + Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + Name = "SSHTransferWindow"; + TabText = "SSH File Transfer"; + Text = "SSH File Transfer"; + Load += new EventHandler(SSHTransfer_Load); + grpFiles.ResumeLayout(false); + grpFiles.PerformLayout(); + grpConnection.ResumeLayout(false); + grpConnection.PerformLayout(); + ResumeLayout(false); + } #endregion @@ -319,11 +318,11 @@ namespace mRemoteNG.UI.Window { get { - return this.txtHost.Text; + return txtHost.Text; } set { - this.txtHost.Text = value; + txtHost.Text = value; } } @@ -331,11 +330,11 @@ namespace mRemoteNG.UI.Window { get { - return this.txtPort.Text; + return txtPort.Text; } set { - this.txtPort.Text = value; + txtPort.Text = value; } } @@ -343,11 +342,11 @@ namespace mRemoteNG.UI.Window { get { - return this.txtUser.Text; + return txtUser.Text; } set { - this.txtUser.Text = value; + txtUser.Text = value; } } @@ -355,17 +354,17 @@ namespace mRemoteNG.UI.Window { get { - return this.txtPassword.Text; + return txtPassword.Text; } set { - this.txtPassword.Text = value; + txtPassword.Text = value; } } #endregion #region Form Stuff - private void SSHTransfer_Load(object sender, System.EventArgs e) + private void SSHTransfer_Load(object sender, EventArgs e) { ApplyLanguage(); } @@ -397,7 +396,7 @@ namespace mRemoteNG.UI.Window return; } - if (File.Exists(this.txtLocalFile.Text) == false) + if (File.Exists(txtLocalFile.Text) == false) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, Language.strLocalFileDoesNotExist); return; @@ -407,23 +406,23 @@ namespace mRemoteNG.UI.Window { if (Protocol == SSHTransferProtocol.SCP) { - this.sshT = new Scp(txtHost.Text, txtUser.Text, txtPassword.Text); + sshT = new Scp(txtHost.Text, txtUser.Text, txtPassword.Text); } else if (Protocol == SSHTransferProtocol.SFTP) { - this.sshT = new Sftp(txtHost.Text, txtUser.Text, txtPassword.Text); + sshT = new Sftp(txtHost.Text, txtUser.Text, txtPassword.Text); } sshT.OnTransferStart += SshTransfer_Start; sshT.OnTransferProgress += SshTransfer_Progress; sshT.OnTransferEnd += SshTransfer_End; + + sshT.Connect(Convert.ToInt32(txtPort.Text)); - this.sshT.Connect(Convert.ToInt32(this.txtPort.Text)); + LocalFile = txtLocalFile.Text; + RemoteFile = txtRemoteFile.Text; - LocalFile = this.txtLocalFile.Text; - RemoteFile = this.txtRemoteFile.Text; - - Thread t = new Thread(new System.Threading.ThreadStart(StartTransferBG)); + Thread t = new Thread(new ThreadStart(StartTransferBG)); t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Start(); @@ -431,7 +430,7 @@ namespace mRemoteNG.UI.Window catch (Exception ex) { Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strSSHTransferFailed + Environment.NewLine + ex.Message); - this.sshT.Close(); + sshT.Close(); } } @@ -443,7 +442,7 @@ namespace mRemoteNG.UI.Window try { DisableButtons(); - this.sshT.Put(LocalFile, RemoteFile); + sshT.Put(LocalFile, RemoteFile); } catch (Exception ex) { @@ -453,19 +452,19 @@ namespace mRemoteNG.UI.Window private bool AllFieldsSet() { - if (this.txtHost.Text != "" && this.txtPort.Text != "" && this.txtUser.Text != "" && this.txtLocalFile.Text != "" && this.txtRemoteFile.Text != "") + if (txtHost.Text != "" && txtPort.Text != "" && txtUser.Text != "" && txtLocalFile.Text != "" && txtRemoteFile.Text != "") { - if (this.txtPassword.Text == "") + if (txtPassword.Text == "") { - if (Interaction.MsgBox(Language.strEmptyPasswordContinue, (Microsoft.VisualBasic.MsgBoxStyle) (MsgBoxStyle.Question | MsgBoxStyle.YesNo), null) == MsgBoxResult.No) + if (MessageBox.Show(frmMain.Default, Language.strEmptyPasswordContinue, "Question?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return false; } } - if (this.txtRemoteFile.Text.EndsWith("/") || this.txtRemoteFile.Text.EndsWith("\\")) + if (txtRemoteFile.Text.EndsWith("/") || txtRemoteFile.Text.EndsWith("\\")) { - this.txtRemoteFile.Text += this.txtLocalFile.Text.Substring(this.txtLocalFile.Text.LastIndexOf("\\") + 1); + txtRemoteFile.Text += txtLocalFile.Text.Substring(txtLocalFile.Text.LastIndexOf("\\") + 1); } return true; @@ -486,7 +485,7 @@ namespace mRemoteNG.UI.Window if (pbStatus.InvokeRequired) { SetStatusCB d = new SetStatusCB(SetStatus); - this.pbStatus.Invoke(d); + pbStatus.Invoke(d); } else { @@ -501,7 +500,7 @@ namespace mRemoteNG.UI.Window if (btnTransfer.InvokeRequired) { EnableButtonsCB d = new EnableButtonsCB(EnableButtons); - this.btnTransfer.Invoke(d); + btnTransfer.Invoke(d); } else { @@ -515,7 +514,7 @@ namespace mRemoteNG.UI.Window if (btnTransfer.InvokeRequired) { DisableButtonsCB d = new DisableButtonsCB(DisableButtons); - this.btnTransfer.Invoke(d); + btnTransfer.Invoke(d); } else { @@ -551,13 +550,13 @@ namespace mRemoteNG.UI.Window Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strSSHTransferFailed); - if (this.sshT != null) + if (sshT != null) { - this.sshT.Close(); + sshT.Close(); } - else if (this.sshT != null) + else if (sshT != null) { - this.sshT.Close(); + sshT.Close(); } } catch (Exception ex) @@ -570,37 +569,37 @@ namespace mRemoteNG.UI.Window #region Public Methods public SSHTransferWindow(DockContent Panel) { - this.WindowType = WindowType.SSHTransfer; - this.DockPnl = Panel; - this.InitializeComponent(); - - this.oDlg = new OpenFileDialog(); - this.oDlg.Filter = "All Files (*.*)|*.*"; - this.oDlg.CheckFileExists = true; + WindowType = WindowType.SSHTransfer; + DockPnl = Panel; + InitializeComponent(); + + oDlg = new OpenFileDialog(); + oDlg.Filter = "All Files (*.*)|*.*"; + oDlg.CheckFileExists = true; } #endregion #region Form Stuff - private void btnBrowse_Click(System.Object sender, System.EventArgs e) + private void btnBrowse_Click(object sender, EventArgs e) { - if (this.oDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) + if (oDlg.ShowDialog() == DialogResult.OK) { - if (this.oDlg.FileName != "") + if (oDlg.FileName != "") { - this.txtLocalFile.Text = this.oDlg.FileName; + txtLocalFile.Text = oDlg.FileName; } } } - private void btnTransfer_Click(System.Object sender, System.EventArgs e) + private void btnTransfer_Click(object sender, EventArgs e) { - if (this.radProtSCP.Checked) + if (radProtSCP.Checked) { - this.StartTransfer(SSHTransferProtocol.SCP); + StartTransfer(SSHTransferProtocol.SCP); } - else if (this.radProtSFTP.Checked) + else if (radProtSFTP.Checked) { - this.StartTransfer(SSHTransferProtocol.SFTP); + StartTransfer(SSHTransferProtocol.SFTP); } } #endregion diff --git a/mRemoteV1/UI/Window/SSHTransferWindow.resx b/mRemoteV1/UI/Window/SSHTransferWindow.resx index 4069c499..c94db595 100644 --- a/mRemoteV1/UI/Window/SSHTransferWindow.resx +++ b/mRemoteV1/UI/Window/SSHTransferWindow.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA From e2d66235b59e30dee5b15897ae5f74152d7d8f88 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 27 May 2016 15:49:03 -0400 Subject: [PATCH 12/27] Remove Microsoft.VisualBasic references & cleanup --- mRemoteV1/App/Info/GeneralAppInfo.cs | 15 +- mRemoteV1/App/Startup.cs | 2 +- mRemoteV1/App/Update/AppUpdater.cs | 54 ++-- .../Config/Connections/ConnectionsSaver.cs | 232 +++++++++--------- .../Config/Settings/ExternalAppsLoader.cs | 2 +- .../Config/Settings/LayoutSettingsLoader.cs | 2 +- .../Protocol/RDP/Connection.Protocol.RDP.cs | 13 +- mRemoteV1/Security/Security.Impersonator.cs | 12 +- mRemoteV1/Tools/ReconnectGroup.Designer.cs | 5 - .../OptionsPages/AppearancePage.Designer.cs | 2 +- .../OptionsPages/ConnectionsPage.Designer.cs | 2 +- .../OptionsPages/SqlServerPage.Designer.cs | 2 +- .../OptionsPages/StartupExitPage.Designer.cs | 2 +- .../OptionsPages/TabsPanelsPage.Designer.cs | 2 +- .../Forms/OptionsPages/ThemePage.Designer.cs | 2 +- .../OptionsPages/UpdatesPage.Designer.cs | 2 +- mRemoteV1/UI/Forms/PasswordForm.Designer.cs | 2 +- mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs | 2 +- mRemoteV1/UI/Forms/frmMain.cs | 2 +- mRemoteV1/UI/Window/AboutWindow.cs | 27 +- mRemoteV1/UI/Window/ConnectionWindow.cs | 5 +- 21 files changed, 200 insertions(+), 189 deletions(-) diff --git a/mRemoteV1/App/Info/GeneralAppInfo.cs b/mRemoteV1/App/Info/GeneralAppInfo.cs index 32a7b3d6..e4aa01a0 100644 --- a/mRemoteV1/App/Info/GeneralAppInfo.cs +++ b/mRemoteV1/App/Info/GeneralAppInfo.cs @@ -3,6 +3,7 @@ using System; using System.IO; using System.Reflection; using System.Threading; +using System.Windows.Forms; using static System.Environment; @@ -14,7 +15,10 @@ namespace mRemoteNG.App.Info public static readonly string UrlDonate = "http://donate.mremoteng.org/"; public static readonly string UrlForum = "http://forum.mremoteng.org/"; public static readonly string UrlBugs = "http://bugs.mremoteng.org/"; - public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); + public static readonly string version = Application.ProductVersion; + public static readonly string ProdName = Application.ProductName; + public static readonly string copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute), false)).Copyright; + public static readonly string HomePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); public static readonly string EncryptionKey = "mR3m"; public static string ReportingFilePath = ""; public static readonly string PuttyPath = HomePath + "\\PuTTYNG.exe"; @@ -33,8 +37,15 @@ namespace mRemoteNG.App.Info details.Add($".NET CLR {Environment.Version}"); string detailsString = string.Join("; ", details.ToArray()); - return $"Mozilla/5.0 ({detailsString}) {System.Windows.Forms.Application.ProductName}/{System.Windows.Forms.Application.ProductVersion}"; + return $"Mozilla/5.0 ({detailsString}) {ProdName}/{version}"; } } + + public static Version getVer() + { + System.Version v = new Version(); + System.Version.TryParse(version, out v); + return v; + } } } \ No newline at end of file diff --git a/mRemoteV1/App/Startup.cs b/mRemoteV1/App/Startup.cs index 8aae2c36..4ad9b8d8 100644 --- a/mRemoteV1/App/Startup.cs +++ b/mRemoteV1/App/Startup.cs @@ -78,7 +78,7 @@ namespace mRemoteNG.App if (isFipsPolicyEnabled) { - MessageBox.Show(frmMain.Default, string.Format(Language.strErrorFipsPolicyIncompatible, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName), (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(frmMain.Default, string.Format(Language.strErrorFipsPolicyIncompatible, GeneralAppInfo.ProdName, GeneralAppInfo.ProdName, MessageBoxButtons.OK, MessageBoxIcon.Error)); Environment.Exit(1); } } diff --git a/mRemoteV1/App/Update/AppUpdater.cs b/mRemoteV1/App/Update/AppUpdater.cs index 0fa1f6a7..23d17282 100644 --- a/mRemoteV1/App/Update/AppUpdater.cs +++ b/mRemoteV1/App/Update/AppUpdater.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System; using System.IO; using System.Net; @@ -6,6 +5,7 @@ using System.ComponentModel; using System.Threading; using mRemoteNG.Tools; using System.Reflection; +using mRemoteNG.App.Info; namespace mRemoteNG.App.Update @@ -107,7 +107,7 @@ namespace mRemoteNG.App.Update public void SetProxySettings() { - SetProxySettings(Convert.ToBoolean(mRemoteNG.Settings.Default.UpdateUseProxy), Convert.ToString(mRemoteNG.Settings.Default.UpdateProxyAddress), Convert.ToInt32(mRemoteNG.Settings.Default.UpdateProxyPort), Convert.ToBoolean(mRemoteNG.Settings.Default.UpdateProxyUseAuthentication), Convert.ToString(mRemoteNG.Settings.Default.UpdateProxyAuthUser), Security.Crypt.Decrypt(Convert.ToString(mRemoteNG.Settings.Default.UpdateProxyAuthPass), Info.GeneralAppInfo.EncryptionKey)); + SetProxySettings(Convert.ToBoolean(Settings.Default.UpdateUseProxy), Convert.ToString(Settings.Default.UpdateProxyAddress), Convert.ToInt32(Settings.Default.UpdateProxyPort), Convert.ToBoolean(Settings.Default.UpdateProxyUseAuthentication), Convert.ToString(Settings.Default.UpdateProxyAuthUser), Security.Crypt.Decrypt(Convert.ToString(Settings.Default.UpdateProxyAuthPass), GeneralAppInfo.EncryptionKey)); } public void SetProxySettings(bool useProxy, string address, int port, bool useAuthentication, string username, string password) @@ -145,7 +145,7 @@ namespace mRemoteNG.App.Update return false; } - return _currentUpdateInfo.Version > (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version; + return _currentUpdateInfo.Version > GeneralAppInfo.getVer(); } public bool IsAnnouncementAvailable() @@ -155,7 +155,7 @@ namespace mRemoteNG.App.Update return false; } - return !(_currentAnnouncementInfo.Name == mRemoteNG.Settings.Default.LastAnnouncement); + return (_currentAnnouncementInfo.Name != Settings.Default.LastAnnouncement); } public void GetUpdateInfoAsync() @@ -165,7 +165,7 @@ namespace mRemoteNG.App.Update _getUpdateInfoThread.Abort(); } - _getUpdateInfoThread = new Thread(new System.Threading.ThreadStart(GetUpdateInfo)); + _getUpdateInfoThread = new Thread(new ThreadStart(GetUpdateInfo)); _getUpdateInfoThread.SetApartmentState(ApartmentState.STA); _getUpdateInfoThread.IsBackground = true; _getUpdateInfoThread.Start(); @@ -183,7 +183,7 @@ namespace mRemoteNG.App.Update _getChangeLogThread.Abort(); } - _getChangeLogThread = new Thread(new System.Threading.ThreadStart(GetChangeLog)); + _getChangeLogThread = new Thread(new ThreadStart(GetChangeLog)); _getChangeLogThread.SetApartmentState(ApartmentState.STA); _getChangeLogThread.IsBackground = true; _getChangeLogThread.Start(); @@ -196,7 +196,7 @@ namespace mRemoteNG.App.Update _getAnnouncementInfoThread.Abort(); } - _getAnnouncementInfoThread = new Thread(new System.Threading.ThreadStart(GetAnnouncementInfo)); + _getAnnouncementInfoThread = new Thread(new ThreadStart(GetAnnouncementInfo)); _getAnnouncementInfoThread.SetApartmentState(ApartmentState.STA); _getAnnouncementInfoThread.IsBackground = true; _getAnnouncementInfoThread.Start(); @@ -244,7 +244,7 @@ namespace mRemoteNG.App.Update private WebClient CreateWebClient() { WebClient webClient = new WebClient(); - webClient.Headers.Add("user-agent", Info.GeneralAppInfo.UserAgent); + webClient.Headers.Add("user-agent", GeneralAppInfo.UserAgent); webClient.Proxy = _webProxy; return webClient; } @@ -285,17 +285,17 @@ namespace mRemoteNG.App.Update private void GetUpdateInfo() { - Uri updateFileUri = new Uri(new Uri(Convert.ToString(mRemoteNG.Settings.Default.UpdateAddress)), new Uri(Info.UpdateChannelInfo.FileName, UriKind.Relative)); + Uri updateFileUri = new Uri(new Uri(Convert.ToString(Settings.Default.UpdateAddress)), new Uri(UpdateChannelInfo.FileName, UriKind.Relative)); DownloadStringCompletedEventArgs e = DownloadString(updateFileUri); if (!e.Cancelled && e.Error == null) { _currentUpdateInfo = UpdateInfo.FromString(e.Result); - - mRemoteNG.Settings.Default.CheckForUpdatesLastCheck = DateTime.UtcNow; - if (!mRemoteNG.Settings.Default.UpdatePending) + + Settings.Default.CheckForUpdatesLastCheck = DateTime.UtcNow; + if (!Settings.Default.UpdatePending) { - mRemoteNG.Settings.Default.UpdatePending = IsUpdateAvailable(); + Settings.Default.UpdatePending = IsUpdateAvailable(); } } @@ -318,7 +318,7 @@ namespace mRemoteNG.App.Update private void GetAnnouncementInfo() { - Uri announcementFileUri = new Uri(Convert.ToString(mRemoteNG.Settings.Default.AnnouncementAddress)); + Uri announcementFileUri = new Uri(Convert.ToString(Settings.Default.AnnouncementAddress)); DownloadStringCompletedEventArgs e = DownloadString(announcementFileUri); if (!e.Cancelled && e.Error == null) @@ -327,7 +327,7 @@ namespace mRemoteNG.App.Update if (!string.IsNullOrEmpty(_currentAnnouncementInfo.Name)) { - mRemoteNG.Settings.Default.LastAnnouncement = _currentAnnouncementInfo.Name; + Settings.Default.LastAnnouncement = _currentAnnouncementInfo.Name; } } @@ -341,7 +341,7 @@ namespace mRemoteNG.App.Update DownloadUpdateProgressChangedEventEvent(sender, e); } - private void DownloadUpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) + private void DownloadUpdateCompleted(object sender, AsyncCompletedEventArgs e) { AsyncCompletedEventArgs raiseEventArgs = e; @@ -353,7 +353,7 @@ namespace mRemoteNG.App.Update updateAuthenticode.RequireThumbprintMatch = true; updateAuthenticode.ThumbprintToMatch = _currentUpdateInfo.CertificateThumbprint; - if (!(updateAuthenticode.Verify() == Authenticode.StatusValue.Verified)) + if (updateAuthenticode.Verify() != Authenticode.StatusValue.Verified) { if (updateAuthenticode.Status == Authenticode.StatusValue.UnhandledException) { @@ -390,11 +390,11 @@ namespace mRemoteNG.App.Update { add { - GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Combine(GetUpdateInfoCompletedEventEvent, value); + GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetUpdateInfoCompletedEventEvent, value); } remove { - GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Remove(GetUpdateInfoCompletedEventEvent, value); + GetUpdateInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetUpdateInfoCompletedEventEvent, value); } } @@ -403,11 +403,11 @@ namespace mRemoteNG.App.Update { add { - GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Combine(GetChangeLogCompletedEventEvent, value); + GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetChangeLogCompletedEventEvent, value); } remove { - GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Remove(GetChangeLogCompletedEventEvent, value); + GetChangeLogCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetChangeLogCompletedEventEvent, value); } } @@ -416,11 +416,11 @@ namespace mRemoteNG.App.Update { add { - GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Combine(GetAnnouncementInfoCompletedEventEvent, value); + GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(GetAnnouncementInfoCompletedEventEvent, value); } remove { - GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Remove(GetAnnouncementInfoCompletedEventEvent, value); + GetAnnouncementInfoCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(GetAnnouncementInfoCompletedEventEvent, value); } } @@ -429,11 +429,11 @@ namespace mRemoteNG.App.Update { add { - DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)System.Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value); + DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Combine(DownloadUpdateProgressChangedEventEvent, value); } remove { - DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)System.Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value); + DownloadUpdateProgressChangedEventEvent = (DownloadProgressChangedEventHandler)Delegate.Remove(DownloadUpdateProgressChangedEventEvent, value); } } @@ -442,11 +442,11 @@ namespace mRemoteNG.App.Update { add { - DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Combine(DownloadUpdateCompletedEventEvent, value); + DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Combine(DownloadUpdateCompletedEventEvent, value); } remove { - DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)System.Delegate.Remove(DownloadUpdateCompletedEventEvent, value); + DownloadUpdateCompletedEventEvent = (AsyncCompletedEventHandler)Delegate.Remove(DownloadUpdateCompletedEventEvent, value); } } #endregion diff --git a/mRemoteV1/Config/Connections/ConnectionsSaver.cs b/mRemoteV1/Config/Connections/ConnectionsSaver.cs index a9d7e4e3..7842a219 100644 --- a/mRemoteV1/Config/Connections/ConnectionsSaver.cs +++ b/mRemoteV1/Config/Connections/ConnectionsSaver.cs @@ -1,19 +1,23 @@ -using mRemoteNG.App; -using mRemoteNG.Connection; -using mRemoteNG.Connection.Protocol.RDP; -using mRemoteNG.Container; -using mRemoteNG.Tools; -using mRemoteNG.Tree; using System; using System.Data.SqlClient; using System.Drawing; using System.Globalization; using System.IO; +using System.Text; using System.Windows.Forms; using System.Xml; -using mRemoteNG.My; -using mRemoteNG.UI.Forms; +using mRemoteNG.App; +using mRemoteNG.App.Info; +using mRemoteNG.Connection; +using mRemoteNG.Connection.Protocol; +using mRemoteNG.Connection.Protocol.RDP; +using mRemoteNG.Container; +using mRemoteNG.Messages; +using mRemoteNG.Security; +using mRemoteNG.Tools; +using mRemoteNG.Tree; using mRemoteNG.Tree.Root; +using mRemoteNG.UI.Forms; namespace mRemoteNG.Config.Connections { @@ -38,7 +42,7 @@ namespace mRemoteNG.Config.Connections private SqlConnection _sqlConnection; private SqlCommand _sqlQuery; - private int _currentNodeIndex = 0; + private int _currentNodeIndex; private string _parentConstantId = Convert.ToString(0); #endregion @@ -52,7 +56,7 @@ namespace mRemoteNG.Config.Connections public TreeNode RootTreeNode {get; set;} public bool Export {get; set;} public Format SaveFormat {get; set;} - public Security.Save SaveSecurity {get; set;} + public Save SaveSecurity {get; set;} public ConnectionList ConnectionList {get; set;} public ContainerList ContainerList {get; set;} #endregion @@ -95,7 +99,7 @@ namespace mRemoteNG.Config.Connections { bool isVerified = false; SqlDataReader sqlDataReader = null; - System.Version databaseVersion = null; + Version databaseVersion = null; try { SqlCommand sqlCommand = new SqlCommand("SELECT * FROM tblRoot", sqlConnection); @@ -110,17 +114,17 @@ namespace mRemoteNG.Config.Connections sqlDataReader.Close(); - if (databaseVersion.CompareTo(new System.Version(2, 2)) == 0) // 2.2 + if (databaseVersion.CompareTo(new Version(2, 2)) == 0) // 2.2 { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.3")); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion, "2.3")); sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD EnableFontSmoothing bit NOT NULL DEFAULT 0, EnableDesktopComposition bit NOT NULL DEFAULT 0, InheritEnableFontSmoothing bit NOT NULL DEFAULT 0, InheritEnableDesktopComposition bit NOT NULL DEFAULT 0;", sqlConnection); sqlCommand.ExecuteNonQuery(); - databaseVersion = new System.Version(2, 3); + databaseVersion = new Version(2, 3); } - if (databaseVersion.CompareTo(new System.Version(2, 3)) == 0) // 2.3 + if (databaseVersion.CompareTo(new Version(2, 3)) == 0) // 2.3 { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.4")); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion, "2.4")); sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD UseCredSsp bit NOT NULL DEFAULT 1, InheritUseCredSsp bit NOT NULL DEFAULT 0;", sqlConnection); sqlCommand.ExecuteNonQuery(); databaseVersion = new Version(2, 4); @@ -128,7 +132,7 @@ namespace mRemoteNG.Config.Connections if (databaseVersion.CompareTo(new Version(2, 4)) == 0) // 2.4 { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion.ToString(), "2.5")); + Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format("Upgrading database from version {0} to version {1}.", databaseVersion, "2.5")); sqlCommand = new SqlCommand("ALTER TABLE tblCons ADD LoadBalanceInfo varchar (1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, AutomaticResize bit NOT NULL DEFAULT 1, InheritLoadBalanceInfo bit NOT NULL DEFAULT 0, InheritAutomaticResize bit NOT NULL DEFAULT 0;", sqlConnection); sqlCommand.ExecuteNonQuery(); databaseVersion = new Version(2, 5); @@ -141,12 +145,12 @@ namespace mRemoteNG.Config.Connections if (isVerified == false) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.WarningMsg, string.Format(Language.strErrorBadDatabaseVersion, databaseVersion.ToString(), (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName)); + Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strErrorBadDatabaseVersion, databaseVersion, GeneralAppInfo.ProdName)); } } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, string.Format(Language.strErrorVerifyDatabaseVersionFailed, ex.Message)); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.strErrorVerifyDatabaseVersionFailed, ex.Message)); } finally { @@ -176,48 +180,46 @@ namespace mRemoteNG.Config.Connections if (!VerifyDatabaseVersion(_sqlConnection)) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, Language.strErrorConnectionListSaveFailed); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strErrorConnectionListSaveFailed); return ; } + + var tN = (TreeNode)RootTreeNode.Clone(); - TreeNode tN = default(TreeNode); - tN = (TreeNode)RootTreeNode.Clone(); - - string strProtected = ""; + string strProtected; if (tN.Tag != null) { - if ((tN.Tag as RootNodeInfo).Password == true) + if (((RootNodeInfo) tN.Tag).Password) { - _password = Convert.ToString((tN.Tag as RootNodeInfo).PasswordString); - strProtected = Security.Crypt.Encrypt("ThisIsProtected", _password); + _password = Convert.ToString(((RootNodeInfo) tN.Tag).PasswordString); + strProtected = Crypt.Encrypt("ThisIsProtected", _password); } else { - strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); + strProtected = Crypt.Encrypt("ThisIsNotProtected", _password); } } else { - strProtected = Security.Crypt.Encrypt("ThisIsNotProtected", _password); + strProtected = Crypt.Encrypt("ThisIsNotProtected", _password); } _sqlQuery = new SqlCommand("DELETE FROM tblRoot", _sqlConnection); _sqlQuery.ExecuteNonQuery(); - _sqlQuery = new SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" + MiscTools.PrepareValueForDB(tN.Text) + "\', 0, \'" + strProtected + "\'," + App.Info.ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")", _sqlConnection); + _sqlQuery = new SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES(\'" + MiscTools.PrepareValueForDB(tN.Text) + "\', 0, \'" + strProtected + "\'," + ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture) + ")", _sqlConnection); _sqlQuery.ExecuteNonQuery(); _sqlQuery = new SqlCommand("DELETE FROM tblCons", _sqlConnection); _sqlQuery.ExecuteNonQuery(); - TreeNodeCollection tNC = default(TreeNodeCollection); - tNC = tN.Nodes; - + TreeNodeCollection tNC = tN.Nodes; + SaveNodesSQL(tNC); _sqlQuery = new SqlCommand("DELETE FROM tblUpdate", _sqlConnection); _sqlQuery.ExecuteNonQuery(); - _sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + Tools.MiscTools.DBDate(DateTime.Now) + "\')", _sqlConnection); + _sqlQuery = new SqlCommand("INSERT INTO tblUpdate (LastUpdate) VALUES(\'" + MiscTools.DBDate(DateTime.Now) + "\')", _sqlConnection); _sqlQuery.ExecuteNonQuery(); _sqlConnection.Close(); @@ -234,33 +236,33 @@ namespace mRemoteNG.Config.Connections + "InheritUseCredSsp, " + "PositionID, ParentID, ConstantID, LastChange)" + "VALUES (", _sqlConnection ); - if (Tree.ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection | Tree.ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) { //_xmlTextWriter.WriteStartElement("Node") _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(node.Text) + "\',"; //Name - _sqlQuery.CommandText += "\'" + Tree.ConnectionTreeNode.GetNodeType(node).ToString() + "\',"; //Type + _sqlQuery.CommandText += "\'" + ConnectionTreeNode.GetNodeType(node) + "\',"; //Type } - if (Tree.ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) //container + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) //container { - _sqlQuery.CommandText += "\'" + this.ContainerList[node.Tag].IsExpanded + "\',"; //Expanded - curConI = this.ContainerList[node.Tag].ConnectionInfo; + _sqlQuery.CommandText += "\'" + ContainerList[node.Tag].IsExpanded + "\',"; //Expanded + curConI = ContainerList[node.Tag].ConnectionInfo; SaveConnectionFieldsSQL(curConI); - _sqlQuery.CommandText = Tools.MiscTools.PrepareForDB(_sqlQuery.CommandText); + _sqlQuery.CommandText = MiscTools.PrepareForDB(_sqlQuery.CommandText); _sqlQuery.ExecuteNonQuery(); //_parentConstantId = _currentNodeIndex SaveNodesSQL(node.Nodes); //_xmlTextWriter.WriteEndElement() } - if (Tree.ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) { _sqlQuery.CommandText += "\'" + Convert.ToString(false) + "\',"; - curConI = this.ConnectionList[node.Tag]; + curConI = ConnectionList[node.Tag]; SaveConnectionFieldsSQL(curConI); //_xmlTextWriter.WriteEndElement() - _sqlQuery.CommandText = Tools.MiscTools.PrepareForDB(_sqlQuery.CommandText); + _sqlQuery.CommandText = MiscTools.PrepareForDB(_sqlQuery.CommandText); _sqlQuery.ExecuteNonQuery(); } @@ -275,7 +277,7 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.Icon) + "\',"; _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.Panel) + "\',"; - if (this.SaveSecurity.Username == true) + if (SaveSecurity.Username) { _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.Username) + "\',"; } @@ -284,7 +286,7 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + "" + "\',"; } - if (this.SaveSecurity.Domain == true) + if (SaveSecurity.Domain) { _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.Domain) + "\',"; } @@ -293,9 +295,9 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + "" + "\',"; } - if (this.SaveSecurity.Password == true) + if (SaveSecurity.Password) { - _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(Security.Crypt.Encrypt(with_1.Password, _password)) + "\',"; + _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(Crypt.Encrypt(with_1.Password, _password)) + "\',"; } else { @@ -303,16 +305,16 @@ namespace mRemoteNG.Config.Connections } _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.Hostname) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Protocol.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Protocol + "\',"; _sqlQuery.CommandText += "\'" + MiscTools.PrepareValueForDB(with_1.PuttySession) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Port) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.UseConsoleSession) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RenderingEngine.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.ICAEncryption.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDPAuthenticationLevel.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RenderingEngine + "\',"; + _sqlQuery.CommandText += "\'" + with_1.ICAEncryption + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDPAuthenticationLevel + "\',"; _sqlQuery.CommandText += "\'" + with_1.LoadBalanceInfo + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Colors.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.Resolution.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Colors + "\',"; + _sqlQuery.CommandText += "\'" + with_1.Resolution + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.AutomaticResize) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.DisplayWallpaper) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.DisplayThemes) + "\',"; @@ -323,7 +325,7 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.RedirectPorts) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.RedirectPrinters) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.RedirectSmartCards) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RedirectSound.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RedirectSound + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.RedirectKeys) + "\',"; if (curConI.OpenConnections.Count > 0) @@ -341,23 +343,23 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + with_1.UserField + "\',"; _sqlQuery.CommandText += "\'" + with_1.ExtApp + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCCompression.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCEncoding.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCAuthMode.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCProxyType.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCCompression + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCEncoding + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCAuthMode + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCProxyType + "\',"; _sqlQuery.CommandText += "\'" + with_1.VNCProxyIP + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.VNCProxyPort) + "\',"; _sqlQuery.CommandText += "\'" + with_1.VNCProxyUsername + "\',"; - _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.VNCProxyPassword, _password) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCColors.ToString() + "\',"; - _sqlQuery.CommandText += "\'" + with_1.VNCSmartSizeMode.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + Crypt.Encrypt(with_1.VNCProxyPassword, _password) + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCColors + "\',"; + _sqlQuery.CommandText += "\'" + with_1.VNCSmartSizeMode + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.VNCViewOnly) + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsageMethod.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsageMethod + "\',"; _sqlQuery.CommandText += "\'" + with_1.RDGatewayHostname + "\',"; - _sqlQuery.CommandText += "\'" + with_1.RDGatewayUseConnectionCredentials.ToString() + "\',"; + _sqlQuery.CommandText += "\'" + with_1.RDGatewayUseConnectionCredentials + "\',"; - if (this.SaveSecurity.Username == true) + if (SaveSecurity.Username) { _sqlQuery.CommandText += "\'" + with_1.RDGatewayUsername + "\',"; } @@ -366,16 +368,16 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + "" + "\',"; } - if (this.SaveSecurity.Password == true) + if (SaveSecurity.Password) { - _sqlQuery.CommandText += "\'" + Security.Crypt.Encrypt(with_1.RDGatewayPassword, _password) + "\',"; + _sqlQuery.CommandText += "\'" + Crypt.Encrypt(with_1.RDGatewayPassword, _password) + "\',"; } else { _sqlQuery.CommandText += "\'" + "" + "\',"; } - if (this.SaveSecurity.Domain == true) + if (SaveSecurity.Domain) { _sqlQuery.CommandText += "\'" + with_1.RDGatewayDomain + "\',"; } @@ -386,7 +388,7 @@ namespace mRemoteNG.Config.Connections _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.UseCredSsp) + "\',"; - if (this.SaveSecurity.Inheritance == true) + if (SaveSecurity.Inheritance) { _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.CacheBitmaps) + "\',"; _sqlQuery.CommandText += "\'" + Convert.ToString(with_1.Inheritance.Colors) + "\',"; @@ -507,7 +509,7 @@ namespace mRemoteNG.Config.Connections { if (with_1.Parent != null) { - _parentConstantId = Convert.ToString((with_1.Parent as ContainerInfo).ConnectionInfo.ConstantID); + _parentConstantId = Convert.ToString(with_1.Parent.ConnectionInfo.ConstantID); } else { @@ -516,9 +518,9 @@ namespace mRemoteNG.Config.Connections } else { - if ((with_1.Parent as ContainerInfo).Parent != null) + if (with_1.Parent.Parent != null) { - _parentConstantId = Convert.ToString(((with_1.Parent as ContainerInfo).Parent as ContainerInfo).ConnectionInfo.ConstantID); + _parentConstantId = Convert.ToString(with_1.Parent.Parent.ConnectionInfo.ConstantID); } else { @@ -526,7 +528,7 @@ namespace mRemoteNG.Config.Connections } } - _sqlQuery.CommandText += _currentNodeIndex + ",\'" + _parentConstantId + "\',\'" + with_1.ConstantID + "\',\'" + Tools.MiscTools.DBDate(DateTime.Now) + "\')"; + _sqlQuery.CommandText += _currentNodeIndex + ",\'" + _parentConstantId + "\',\'" + with_1.ConstantID + "\',\'" + MiscTools.DBDate(DateTime.Now) + "\')"; } #endregion @@ -535,14 +537,14 @@ namespace mRemoteNG.Config.Connections { StreamReader streamReader = new StreamReader(ConnectionFileName); - string fileContents = ""; + string fileContents; fileContents = streamReader.ReadToEnd(); streamReader.Close(); if (!string.IsNullOrEmpty(fileContents)) { StreamWriter streamWriter = new StreamWriter(ConnectionFileName); - streamWriter.Write(Security.Crypt.Encrypt(fileContents, _password)); + streamWriter.Write(Crypt.Encrypt(fileContents, _password)); streamWriter.Close(); } } @@ -558,18 +560,18 @@ namespace mRemoteNG.Config.Connections TreeNode treeNode = default(TreeNode); - if (Tree.ConnectionTreeNode.GetNodeType(RootTreeNode) == Tree.TreeNodeType.Root) + if (ConnectionTreeNode.GetNodeType(RootTreeNode) == TreeNodeType.Root) { treeNode = (TreeNode)RootTreeNode.Clone(); } else { - treeNode = new TreeNode("mR|Export (" + Tools.MiscTools.DBDate(DateTime.Now) + ")"); + treeNode = new TreeNode("mR|Export (" + MiscTools.DBDate(DateTime.Now) + ")"); treeNode.Nodes.Add(Convert.ToString(RootTreeNode.Clone())); } string tempFileName = Path.GetTempFileName(); - _xmlTextWriter = new XmlTextWriter(tempFileName, System.Text.Encoding.UTF8); + _xmlTextWriter = new XmlTextWriter(tempFileName, Encoding.UTF8); _xmlTextWriter.Formatting = Formatting.Indented; _xmlTextWriter.Indentation = 4; @@ -582,22 +584,22 @@ namespace mRemoteNG.Config.Connections if (Export) { - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); + _xmlTextWriter.WriteAttributeString("Protected", "", Crypt.Encrypt("ThisIsNotProtected", _password)); } else { - if ((treeNode.Tag as RootNodeInfo).Password == true) + if (((RootNodeInfo) treeNode.Tag).Password) { - _password = Convert.ToString((treeNode.Tag as RootNodeInfo).PasswordString); - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsProtected", _password)); + _password = Convert.ToString(((RootNodeInfo) treeNode.Tag).PasswordString); + _xmlTextWriter.WriteAttributeString("Protected", "", Crypt.Encrypt("ThisIsProtected", _password)); } else { - _xmlTextWriter.WriteAttributeString("Protected", "", Security.Crypt.Encrypt("ThisIsNotProtected", _password)); + _xmlTextWriter.WriteAttributeString("Protected", "", Crypt.Encrypt("ThisIsNotProtected", _password)); } } - _xmlTextWriter.WriteAttributeString("ConfVersion", "", App.Info.ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture)); + _xmlTextWriter.WriteAttributeString("ConfVersion", "", ConnectionsFileInfo.ConnectionFileVersion.ToString(CultureInfo.InvariantCulture)); TreeNodeCollection treeNodeCollection = default(TreeNodeCollection); treeNodeCollection = treeNode.Nodes; @@ -624,7 +626,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveToXml failed" + Environment.NewLine + ex.Message, false); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SaveToXml failed" + Environment.NewLine + ex.Message, false); } } @@ -636,25 +638,25 @@ namespace mRemoteNG.Config.Connections { ConnectionInfo curConI = default(ConnectionInfo); - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Connection | Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Container) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection | ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) { _xmlTextWriter.WriteStartElement("Node"); _xmlTextWriter.WriteAttributeString("Name", "", node.Text); - _xmlTextWriter.WriteAttributeString("Type", "", Tree.ConnectionTreeNode.GetNodeType(node).ToString()); + _xmlTextWriter.WriteAttributeString("Type", "", ConnectionTreeNode.GetNodeType(node).ToString()); } - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Container) //container + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) //container { - _xmlTextWriter.WriteAttributeString("Expanded", "", Convert.ToString(this.ContainerList[node.Tag].TreeNode.IsExpanded)); - curConI = this.ContainerList[node.Tag].ConnectionInfo; + _xmlTextWriter.WriteAttributeString("Expanded", "", Convert.ToString(ContainerList[node.Tag].TreeNode.IsExpanded)); + curConI = ContainerList[node.Tag].ConnectionInfo; SaveConnectionFields(curConI); SaveNode(node.Nodes); _xmlTextWriter.WriteEndElement(); } - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) { - curConI = this.ConnectionList[node.Tag]; + curConI = ConnectionList[node.Tag]; SaveConnectionFields(curConI); _xmlTextWriter.WriteEndElement(); } @@ -662,7 +664,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveNode failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SaveNode failed" + Environment.NewLine + ex.Message, true); } } @@ -676,7 +678,7 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("Panel", "", curConI.Panel); - if (this.SaveSecurity.Username == true) + if (SaveSecurity.Username) { _xmlTextWriter.WriteAttributeString("Username", "", curConI.Username); } @@ -685,7 +687,7 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("Username", "", ""); } - if (this.SaveSecurity.Domain == true) + if (SaveSecurity.Domain) { _xmlTextWriter.WriteAttributeString("Domain", "", curConI.Domain); } @@ -694,9 +696,9 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("Domain", "", ""); } - if (this.SaveSecurity.Password == true) + if (SaveSecurity.Password) { - _xmlTextWriter.WriteAttributeString("Password", "", Security.Crypt.Encrypt(curConI.Password, _password)); + _xmlTextWriter.WriteAttributeString("Password", "", Crypt.Encrypt(curConI.Password, _password)); } else { @@ -773,7 +775,7 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("VNCProxyIP", "", curConI.VNCProxyIP); _xmlTextWriter.WriteAttributeString("VNCProxyPort", "", Convert.ToString(curConI.VNCProxyPort)); _xmlTextWriter.WriteAttributeString("VNCProxyUsername", "", curConI.VNCProxyUsername); - _xmlTextWriter.WriteAttributeString("VNCProxyPassword", "", Security.Crypt.Encrypt(curConI.VNCProxyPassword, _password)); + _xmlTextWriter.WriteAttributeString("VNCProxyPassword", "", Crypt.Encrypt(curConI.VNCProxyPassword, _password)); _xmlTextWriter.WriteAttributeString("VNCColors", "", curConI.VNCColors.ToString()); _xmlTextWriter.WriteAttributeString("VNCSmartSizeMode", "", curConI.VNCSmartSizeMode.ToString()); _xmlTextWriter.WriteAttributeString("VNCViewOnly", "", Convert.ToString(curConI.VNCViewOnly)); @@ -783,7 +785,7 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("RDGatewayUseConnectionCredentials", "", curConI.RDGatewayUseConnectionCredentials.ToString()); - if (this.SaveSecurity.Username == true) + if (SaveSecurity.Username) { _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", curConI.RDGatewayUsername); } @@ -792,16 +794,16 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("RDGatewayUsername", "", ""); } - if (this.SaveSecurity.Password == true) + if (SaveSecurity.Password) { - _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", Security.Crypt.Encrypt(curConI.RDGatewayPassword, _password)); + _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", Crypt.Encrypt(curConI.RDGatewayPassword, _password)); } else { _xmlTextWriter.WriteAttributeString("RDGatewayPassword", "", ""); } - if (this.SaveSecurity.Domain == true) + if (SaveSecurity.Domain) { _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", curConI.RDGatewayDomain); } @@ -810,7 +812,7 @@ namespace mRemoteNG.Config.Connections _xmlTextWriter.WriteAttributeString("RDGatewayDomain", "", ""); } - if (this.SaveSecurity.Inheritance == true) + if (SaveSecurity.Inheritance) { _xmlTextWriter.WriteAttributeString("InheritCacheBitmaps", "", Convert.ToString(curConI.Inheritance.CacheBitmaps)); _xmlTextWriter.WriteAttributeString("InheritColors", "", Convert.ToString(curConI.Inheritance.Colors)); @@ -920,7 +922,7 @@ namespace mRemoteNG.Config.Connections } catch (Exception ex) { - Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "SaveConnectionFields failed" + Environment.NewLine + ex.Message, true); + Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, "SaveConnectionFields failed" + Environment.NewLine + ex.Message, true); } } #endregion @@ -930,7 +932,7 @@ namespace mRemoteNG.Config.Connections private void SaveTomRCSV() { - if (App.Runtime.IsConnectionsFileLoaded == false) + if (Runtime.IsConnectionsFileLoaded == false) { return; } @@ -981,13 +983,13 @@ namespace mRemoteNG.Config.Connections { foreach (TreeNode node in tNC) { - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) { ConnectionInfo curConI = (ConnectionInfo)node.Tag; WritemRCSVLine(curConI); } - else if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Container) + else if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) { SaveNodemRCSV(node.Nodes); } @@ -1030,7 +1032,7 @@ namespace mRemoteNG.Config.Connections csvLn += con.Domain + ";"; } - csvLn += con.Hostname + ";" + con.Protocol.ToString() + ";" + con.PuttySession + ";" + Convert.ToString(con.Port) + ";" + Convert.ToString(con.UseConsoleSession) + ";" + Convert.ToString(con.UseCredSsp) + ";" + con.RenderingEngine.ToString() + ";" + con.ICAEncryption.ToString() + ";" + con.RDPAuthenticationLevel.ToString() + ";" + con.LoadBalanceInfo + ";" + con.Colors.ToString() + ";" + con.Resolution.ToString() + ";" + Convert.ToString(con.AutomaticResize) + ";" + Convert.ToString(con.DisplayWallpaper) + ";" + Convert.ToString(con.DisplayThemes) + ";" + Convert.ToString(con.EnableFontSmoothing) + ";" + Convert.ToString(con.EnableDesktopComposition) + ";" + Convert.ToString(con.CacheBitmaps) + ";" + Convert.ToString(con.RedirectDiskDrives) + ";" + Convert.ToString(con.RedirectPorts) + ";" + Convert.ToString(con.RedirectPrinters) + ";" + Convert.ToString(con.RedirectSmartCards) + ";" + con.RedirectSound.ToString() + ";" + Convert.ToString(con.RedirectKeys) + ";" + con.PreExtApp + ";" + con.PostExtApp + ";" + con.MacAddress + ";" + con.UserField + ";" + con.ExtApp + ";" + con.VNCCompression.ToString() + ";" + con.VNCEncoding.ToString() + ";" + con.VNCAuthMode.ToString() + ";" + con.VNCProxyType.ToString() + ";" + con.VNCProxyIP + ";" + Convert.ToString(con.VNCProxyPort) + ";" + con.VNCProxyUsername + ";" + con.VNCProxyPassword + ";" + con.VNCColors.ToString() + ";" + con.VNCSmartSizeMode.ToString() + ";" + Convert.ToString(con.VNCViewOnly) + ";"; + csvLn += con.Hostname + ";" + con.Protocol + ";" + con.PuttySession + ";" + Convert.ToString(con.Port) + ";" + Convert.ToString(con.UseConsoleSession) + ";" + Convert.ToString(con.UseCredSsp) + ";" + con.RenderingEngine + ";" + con.ICAEncryption + ";" + con.RDPAuthenticationLevel + ";" + con.LoadBalanceInfo + ";" + con.Colors + ";" + con.Resolution + ";" + Convert.ToString(con.AutomaticResize) + ";" + Convert.ToString(con.DisplayWallpaper) + ";" + Convert.ToString(con.DisplayThemes) + ";" + Convert.ToString(con.EnableFontSmoothing) + ";" + Convert.ToString(con.EnableDesktopComposition) + ";" + Convert.ToString(con.CacheBitmaps) + ";" + Convert.ToString(con.RedirectDiskDrives) + ";" + Convert.ToString(con.RedirectPorts) + ";" + Convert.ToString(con.RedirectPrinters) + ";" + Convert.ToString(con.RedirectSmartCards) + ";" + con.RedirectSound + ";" + Convert.ToString(con.RedirectKeys) + ";" + con.PreExtApp + ";" + con.PostExtApp + ";" + con.MacAddress + ";" + con.UserField + ";" + con.ExtApp + ";" + con.VNCCompression + ";" + con.VNCEncoding + ";" + con.VNCAuthMode + ";" + con.VNCProxyType + ";" + con.VNCProxyIP + ";" + Convert.ToString(con.VNCProxyPort) + ";" + con.VNCProxyUsername + ";" + con.VNCProxyPassword + ";" + con.VNCColors + ";" + con.VNCSmartSizeMode + ";" + Convert.ToString(con.VNCViewOnly) + ";"; if (SaveSecurity.Inheritance) { @@ -1045,7 +1047,7 @@ namespace mRemoteNG.Config.Connections #region vRD CSV private void SaveTovRDCSV() { - if (App.Runtime.IsConnectionsFileLoaded == false) + if (Runtime.IsConnectionsFileLoaded == false) { return; } @@ -1067,16 +1069,16 @@ namespace mRemoteNG.Config.Connections { foreach (TreeNode node in tNC) { - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) { ConnectionInfo curConI = (ConnectionInfo)node.Tag; - if (curConI.Protocol == Connection.Protocol.ProtocolType.RDP) + if (curConI.Protocol == ProtocolType.RDP) { WritevRDCSVLine(curConI); } } - else if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Container) + else if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Container) { SaveNodevRDCSV(node.Nodes); } @@ -1107,7 +1109,7 @@ namespace mRemoteNG.Config.Connections #region vRD VRE private void SaveToVRE() { - if (App.Runtime.IsConnectionsFileLoaded == false) + if (Runtime.IsConnectionsFileLoaded == false) { return; } @@ -1118,7 +1120,7 @@ namespace mRemoteNG.Config.Connections TreeNodeCollection tNC = default(TreeNodeCollection); tNC = tN.Nodes; - _xmlTextWriter = new XmlTextWriter(ConnectionFileName, System.Text.Encoding.UTF8); + _xmlTextWriter = new XmlTextWriter(ConnectionFileName, Encoding.UTF8); _xmlTextWriter.Formatting = Formatting.Indented; _xmlTextWriter.Indentation = 4; @@ -1140,11 +1142,11 @@ namespace mRemoteNG.Config.Connections { foreach (TreeNode node in tNC) { - if (Tree.ConnectionTreeNode.GetNodeType(node) == Tree.TreeNodeType.Connection) + if (ConnectionTreeNode.GetNodeType(node) == TreeNodeType.Connection) { ConnectionInfo curConI = (ConnectionInfo)node.Tag; - if (curConI.Protocol == Connection.Protocol.ProtocolType.RDP) + if (curConI.Protocol == ProtocolType.RDP) { _xmlTextWriter.WriteStartElement("Connection"); _xmlTextWriter.WriteAttributeString("Id", "", ""); diff --git a/mRemoteV1/Config/Settings/ExternalAppsLoader.cs b/mRemoteV1/Config/Settings/ExternalAppsLoader.cs index ee6ae88e..8dd317df 100644 --- a/mRemoteV1/Config/Settings/ExternalAppsLoader.cs +++ b/mRemoteV1/Config/Settings/ExternalAppsLoader.cs @@ -19,7 +19,7 @@ namespace mRemoteNG.Config.Settings public void LoadExternalAppsFromXML() { - string oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName + "\\" + SettingsFileInfo.ExtAppsFilesName; + string oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProdName + "\\" + SettingsFileInfo.ExtAppsFilesName; string newPath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.ExtAppsFilesName; XmlDocument xDom = new XmlDocument(); if (File.Exists(newPath)) diff --git a/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs b/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs index 6586f4e3..7eb8c6e5 100644 --- a/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs +++ b/mRemoteV1/Config/Settings/LayoutSettingsLoader.cs @@ -34,7 +34,7 @@ namespace mRemoteNG.Config.Settings CreatePanels(); #if !PORTABLE - string oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName + "\\" + SettingsFileInfo.LayoutFileName; + string oldPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + GeneralAppInfo.ProdName + "\\" + SettingsFileInfo.LayoutFileName; #endif string newPath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.LayoutFileName; if (File.Exists(newPath)) diff --git a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs index 251cd9d6..58bdf3e9 100644 --- a/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs +++ b/mRemoteV1/Connection/Protocol/RDP/Connection.Protocol.RDP.cs @@ -2,7 +2,6 @@ using System; using System.Drawing; using System.Diagnostics; using AxMSTSCLib; -using Microsoft.VisualBasic; using System.Collections; using System.Windows.Forms; using System.Threading; @@ -153,7 +152,7 @@ namespace mRemoteNG.Connection.Protocol.RDP SetLoadBalanceInfo(); SetRdGateway(); - _rdpClient.ColorDepth = Convert.ToInt32(Conversion.Int(_connectionInfo.Colors)); + _rdpClient.ColorDepth = (int)_connectionInfo.Colors; SetPerformanceFlags(); @@ -537,7 +536,7 @@ namespace mRemoteNG.Connection.Protocol.RDP _rdpClient.AdvancedSettings2.RedirectPorts = _connectionInfo.RedirectPorts; _rdpClient.AdvancedSettings2.RedirectPrinters = _connectionInfo.RedirectPrinters; _rdpClient.AdvancedSettings2.RedirectSmartCards = _connectionInfo.RedirectSmartCards; - _rdpClient.SecuredSettings2.AudioRedirectionMode = Convert.ToInt32(Conversion.Int(_connectionInfo.RedirectSound)); + _rdpClient.SecuredSettings2.AudioRedirectionMode = (int)_connectionInfo.RedirectSound; } catch (Exception ex) { @@ -552,22 +551,22 @@ namespace mRemoteNG.Connection.Protocol.RDP int pFlags = 0; if (_connectionInfo.DisplayThemes == false) { - pFlags += Convert.ToInt32(Conversion.Int(RDPPerformanceFlags.DisableThemes)); + pFlags += Convert.ToInt32(RDPPerformanceFlags.DisableThemes); } if (_connectionInfo.DisplayWallpaper == false) { - pFlags += Convert.ToInt32(Conversion.Int(RDPPerformanceFlags.DisableWallpaper)); + pFlags += Convert.ToInt32(RDPPerformanceFlags.DisableWallpaper); } if (_connectionInfo.EnableFontSmoothing) { - pFlags += Convert.ToInt32(Conversion.Int(RDPPerformanceFlags.EnableFontSmoothing)); + pFlags += Convert.ToInt32(RDPPerformanceFlags.EnableFontSmoothing); } if (_connectionInfo.EnableDesktopComposition) { - pFlags += Convert.ToInt32(Conversion.Int(RDPPerformanceFlags.EnableDesktopComposition)); + pFlags += Convert.ToInt32(RDPPerformanceFlags.EnableDesktopComposition); } _rdpClient.AdvancedSettings2.PerformanceFlags = pFlags; diff --git a/mRemoteV1/Security/Security.Impersonator.cs b/mRemoteV1/Security/Security.Impersonator.cs index 6be278f3..6f27992a 100644 --- a/mRemoteV1/Security/Security.Impersonator.cs +++ b/mRemoteV1/Security/Security.Impersonator.cs @@ -1,8 +1,8 @@ using System; -using Microsoft.VisualBasic; using System.Runtime.InteropServices; using System.Security.Principal; using System.Security.Permissions; +using System.Text.RegularExpressions; using mRemoteNG.App; @@ -39,21 +39,23 @@ namespace mRemoteNG.Security private string GetErrorMessage(int errorCode) { int messageSize = 255; - string lpMsgBuf = ""; - int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + string lpMsgBuf = ""; + + int dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; IntPtr ptrlpSource = IntPtr.Zero; IntPtr prtArguments = IntPtr.Zero; int retVal = FormatMessage(dwFlags, ref ptrlpSource, errorCode, 0, ref lpMsgBuf, messageSize, ref prtArguments); - return lpMsgBuf.Trim(new char[] {char.Parse(Constants.vbCr), char.Parse(Constants.vbLf)}); + lpMsgBuf = Regex.Replace(lpMsgBuf, @"\r\n|\n|\r", " "); + return lpMsgBuf; } [PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]public void StartImpersonation(string DomainName, string UserName, string Password) { try { - if (!(impersonatedUser == null)) + if (impersonatedUser != null) { throw (new Exception("Already impersonating a user.")); } diff --git a/mRemoteV1/Tools/ReconnectGroup.Designer.cs b/mRemoteV1/Tools/ReconnectGroup.Designer.cs index 8e910b9c..60d7cd94 100644 --- a/mRemoteV1/Tools/ReconnectGroup.Designer.cs +++ b/mRemoteV1/Tools/ReconnectGroup.Designer.cs @@ -1,10 +1,5 @@ - - -using mRemoteNG.My; - namespace mRemoteNG { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] public partial class ReconnectGroup : System.Windows.Forms.UserControl { //UserControl overrides dispose to clean up the component list. diff --git a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs index b6266905..8b92816a 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/AppearancePage.Designer.cs @@ -2,7 +2,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class AppearancePage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs index 00a37265..b98a022e 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ConnectionsPage.Designer.cs @@ -2,7 +2,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class ConnectionsPage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.Designer.cs index b56d6bca..2db5a516 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/SqlServerPage.Designer.cs @@ -2,7 +2,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class SqlServerPage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.Designer.cs index de434d3e..eca63c5d 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/StartupExitPage.Designer.cs @@ -2,7 +2,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class StartupExitPage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs index 72aa66e9..11b21d7c 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/TabsPanelsPage.Designer.cs @@ -4,7 +4,7 @@ using mRemoteNG.My; namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class TabsPanelsPage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.Designer.cs index e757a5e1..03d711b2 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.Designer.cs @@ -2,7 +2,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class ThemePage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.Designer.cs b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.Designer.cs index 339243f9..38af68d6 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.Designer.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/UpdatesPage.Designer.cs @@ -1,7 +1,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class UpdatesPage : OptionsPage { diff --git a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs index 3d156eb7..55377e7c 100644 --- a/mRemoteV1/UI/Forms/PasswordForm.Designer.cs +++ b/mRemoteV1/UI/Forms/PasswordForm.Designer.cs @@ -4,7 +4,7 @@ using mRemoteNG.My; namespace mRemoteNG.Forms { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]public + public partial class PasswordForm : System.Windows.Forms.Form { diff --git a/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs b/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs index e09cac30..783f1e13 100644 --- a/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs +++ b/mRemoteV1/UI/Forms/frmChoosePanel.Designer.cs @@ -4,7 +4,7 @@ using mRemoteNG.My; namespace mRemoteNG { - [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()] + public partial class frmChoosePanel : System.Windows.Forms.Form { //Form overrides dispose to clean up the component list. diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index a9b7d5a5..87b1b10d 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -286,7 +286,7 @@ namespace mRemoteNG.UI.Forms // if (!mRemoteNG.Settings.Default.CheckForUpdatesAsked) // { // string[] commandButtons = new string[] {Language.strAskUpdatesCommandRecommended, Language.strAskUpdatesCommandCustom, Language.strAskUpdatesCommandAskLater}; -// cTaskDialog.ShowTaskDialogBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, Language.strAskUpdatesMainInstruction, string.Format(Language.strAskUpdatesContent, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName), "", "", "", "", string.Join("|", commandButtons), eTaskDialogButtons.None, eSysIcons.Question, eSysIcons.Question); +// cTaskDialog.ShowTaskDialogBox(this, GeneralAppInfo.ProdName, Language.strAskUpdatesMainInstruction, string.Format(Language.strAskUpdatesContent, GeneralAppInfo.ProdName, "", "", "", "", string.Join("|", commandButtons), eTaskDialogButtons.None, eSysIcons.Question, eSysIcons.Question); // if (cTaskDialog.CommandButtonResult == 0 | cTaskDialog.CommandButtonResult == 1) // { // mRemoteNG.Settings.Default.CheckForUpdatesAsked = true; diff --git a/mRemoteV1/UI/Window/AboutWindow.cs b/mRemoteV1/UI/Window/AboutWindow.cs index d74147a0..2e42926a 100644 --- a/mRemoteV1/UI/Window/AboutWindow.cs +++ b/mRemoteV1/UI/Window/AboutWindow.cs @@ -256,26 +256,25 @@ namespace mRemoteNG.UI.Window #endif } - private void FillLinkLabel(LinkLabel llbl, string Text, string URL) + private void FillLinkLabel(LinkLabel llbl, string txt, string URL) { llbl.Links.Clear(); - int Open = Text.IndexOf("["); - int Close = 0; + int Open = txt.IndexOf("["); while (Open != -1) { - Text = Text.Remove(Open, 1); - Close = Text.IndexOf("]", Open); + txt = txt.Remove(Open, 1); + int Close = txt.IndexOf("]", Open); if (Close == -1) { break; } - Text = Text.Remove(Close, 1); + txt = txt.Remove(Close, 1); llbl.Links.Add(Open, Close - Open, URL); - Open = Text.IndexOf("[", Open); + Open = txt.IndexOf("[", Open); } - llbl.Text = Text; + llbl.Text = txt; } #endregion @@ -287,9 +286,9 @@ namespace mRemoteNG.UI.Window try { - lblCopyright.Text = (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Copyright; + lblCopyright.Text = GeneralAppInfo.copyright; - lblVersion.Text = "Version " + (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.Version.ToString(); + lblVersion.Text = @"Version " + GeneralAppInfo.version; if (File.Exists(GeneralAppInfo.HomePath + "\\CHANGELOG.TXT")) { @@ -310,8 +309,9 @@ namespace mRemoteNG.UI.Window Runtime.MessageCollector.AddMessage(Messages.MessageClass.ErrorMsg, "Loading About failed" + Environment.NewLine + ex.Message, true); } } - - private void llblFAMFAMFAM_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) + +#if false + private void llblFAMFAMFAM_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) { Runtime.GoToURL(Language.strFAMFAMFAMAttributionURL); } @@ -325,6 +325,7 @@ namespace mRemoteNG.UI.Window { Runtime.GoToURL(Language.strWeifenLuoAttributionURL); } - #endregion +#endif +#endregion } } diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index 62744aaa..7611199b 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -11,6 +11,7 @@ using mRemoteNG.Connection.Protocol.RDP; using mRemoteNG.Connection.Protocol; using mRemoteNG.UI.Forms; using mRemoteNG.UI.TaskDialog; +using mRemoteNG.App.Info; namespace mRemoteNG.UI.Window { @@ -421,7 +422,7 @@ namespace mRemoteNG.UI.Window ((Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All & TabController.TabPages.Count > 0) || (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.Multiple & TabController.TabPages.Count > 1))) { - DialogResult result = CTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, Text), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question); + DialogResult result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProdName, string.Format(Language.strConfirmCloseConnectionPanelMainInstruction, Text), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question); if (CTaskDialog.VerificationChecked) { Settings.Default.ConfirmCloseConnection--; @@ -504,7 +505,7 @@ namespace mRemoteNG.UI.Window Crownwood.Magic.Controls.TabPage selectedTab = TabController.SelectedTab; if (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All) { - DialogResult result = CTaskDialog.MessageBox(this, (new Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase()).Info.ProductName, string.Format(Language.strConfirmCloseConnectionMainInstruction, selectedTab.Title), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question); + DialogResult result = CTaskDialog.MessageBox(this, GeneralAppInfo.ProdName, string.Format(Language.strConfirmCloseConnectionMainInstruction, selectedTab.Title), "", "", "", Language.strCheckboxDoNotShowThisMessageAgain, ETaskDialogButtons.YesNo, ESysIcons.Question, ESysIcons.Question); if (CTaskDialog.VerificationChecked) { Settings.Default.ConfirmCloseConnection--; From 9dc5442743482de8a6585cdd5d3655a88b006a36 Mon Sep 17 00:00:00 2001 From: Sean Kaim Date: Fri, 27 May 2016 15:56:03 -0400 Subject: [PATCH 13/27] minor clean up --- mRemoteV1/Tree/ConnectionTree.cs | 83 +++++++++++++------------------- 1 file changed, 34 insertions(+), 49 deletions(-) diff --git a/mRemoteV1/Tree/ConnectionTree.cs b/mRemoteV1/Tree/ConnectionTree.cs index fdd0d62a..dae1ae7f 100644 --- a/mRemoteV1/Tree/ConnectionTree.cs +++ b/mRemoteV1/Tree/ConnectionTree.cs @@ -113,10 +113,7 @@ namespace mRemoteNG.Tree public static void StartRenameSelectedNode() { - if (SelectedNode != null) - { - SelectedNode.BeginEdit(); - } + SelectedNode?.BeginEdit(); } public static void FinishRenameSelectedNode(string newName) @@ -130,28 +127,26 @@ namespace mRemoteNG.Tree { try { - if (Settings.Default.ShowDescriptionTooltipsInTree) + if (!Settings.Default.ShowDescriptionTooltipsInTree) return; + //Find the node under the mouse. + TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); + if (new_node == null || new_node.Equals(SetNodeToolTip_old_node)) { - //Find the node under the mouse. - TreeNode new_node = _TreeView.GetNodeAt(e.X, e.Y); - if (new_node == null || new_node.Equals(SetNodeToolTip_old_node)) - { - return; - } - SetNodeToolTip_old_node = new_node; + return; + } + SetNodeToolTip_old_node = new_node; - //See if we have a node. - if (SetNodeToolTip_old_node == null) + //See if we have a node. + if (SetNodeToolTip_old_node == null) + { + tTip.SetToolTip(_TreeView, ""); + } + else + { + //Get this node's object data. + if (ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) { - tTip.SetToolTip(_TreeView, ""); - } - else - { - //Get this node's object data. - if (ConnectionTreeNode.GetNodeType(SetNodeToolTip_old_node) == TreeNodeType.Connection) - { - tTip.SetToolTip(_TreeView, ((ConnectionInfo) SetNodeToolTip_old_node.Tag).Description); - } + tTip.SetToolTip(_TreeView, ((ConnectionInfo) SetNodeToolTip_old_node.Tag).Description); } } } @@ -182,21 +177,16 @@ namespace mRemoteNG.Tree { try { - if (SelectedNode != null) - { - if (!(SelectedNode.NextNode == null)) - { - TreeView.BeginUpdate(); - TreeView.Sorted = false; + if (SelectedNode?.NextNode == null) return; + TreeView.BeginUpdate(); + TreeView.Sorted = false; - TreeNode newNode = (TreeNode)SelectedNode.Clone(); - SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 2, newNode); - SelectedNode.Remove(); - SelectedNode = newNode; + TreeNode newNode = (TreeNode)SelectedNode.Clone(); + SelectedNode.Parent.Nodes.Insert(SelectedNode.Index + 2, newNode); + SelectedNode.Remove(); + SelectedNode = newNode; - TreeView.EndUpdate(); - } - } + TreeView.EndUpdate(); } catch (Exception ex) { @@ -208,21 +198,16 @@ namespace mRemoteNG.Tree { try { - if (SelectedNode != null) - { - if (!(SelectedNode.PrevNode == null)) - { - TreeView.BeginUpdate(); - TreeView.Sorted = false; + if (SelectedNode?.PrevNode == null) return; + TreeView.BeginUpdate(); + TreeView.Sorted = false; - TreeNode newNode = (TreeNode)SelectedNode.Clone(); - SelectedNode.Parent.Nodes.Insert(SelectedNode.Index - 1, newNode); - SelectedNode.Remove(); - SelectedNode = newNode; + TreeNode newNode = (TreeNode)SelectedNode.Clone(); + SelectedNode.Parent.Nodes.Insert(SelectedNode.Index - 1, newNode); + SelectedNode.Remove(); + SelectedNode = newNode; - TreeView.EndUpdate(); - } - } + TreeView.EndUpdate(); } catch (Exception ex) { From 9f860a3f3e46e53f860e6b40a152162a9b2fc70b Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 27 May 2016 14:33:06 -0600 Subject: [PATCH 14/27] Resolved MR-683 - Validated then updated the German localization with provided file. --- mRemoteV1/Resources/Language/Language.de.resx | 386 +++++++++--------- 1 file changed, 193 insertions(+), 193 deletions(-) diff --git a/mRemoteV1/Resources/Language/Language.de.resx b/mRemoteV1/Resources/Language/Language.de.resx index 5437a9be..cd12fbca 100644 --- a/mRemoteV1/Resources/Language/Language.de.resx +++ b/mRemoteV1/Resources/Language/Language.de.resx @@ -1,4 +1,4 @@ - +