From 64bd5a93ade701bf807164ed5fc581d4cfa04bce Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 31 Oct 2017 08:11:57 -0500 Subject: [PATCH 01/20] resolves #761 --- mRemoteV1/Connection/Protocol/IntegratedProgram.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs index 9cf67ee1..fe93ae40 100644 --- a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs +++ b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs @@ -1,11 +1,11 @@ -using mRemoteNG.App; -using mRemoteNG.Tools; using System; using System.Diagnostics; using System.Drawing; using System.Threading; using System.Windows.Forms; +using mRemoteNG.App; using mRemoteNG.Messages; +using mRemoteNG.Tools; namespace mRemoteNG.Connection.Protocol @@ -23,7 +23,7 @@ namespace mRemoteNG.Connection.Protocol { if (InterfaceControl.Info == null) return base.Initialize(); - _externalTool = Runtime.GetExtAppByName(InterfaceControl.Info.Name); + _externalTool = Runtime.GetExtAppByName(InterfaceControl.Info.ExtApp); _externalTool.ConnectionInfo = InterfaceControl.Info; return base.Initialize(); From 65782285a386058c7ea1b598233b012f01c28332 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 31 Oct 2017 09:56:48 -0500 Subject: [PATCH 02/20] added a few unit tests for integrated programs --- .../Protocol/IntegratedProgramTests.cs | 57 +++++++++++++++++++ mRemoteNGTests/mRemoteNGTests.csproj | 1 + .../Connection/Protocol/IntegratedProgram.cs | 22 ++++--- mRemoteV1/Connection/Protocol/ProtocolBase.cs | 8 +-- .../Resources/Language/Language.Designer.cs | 9 +++ mRemoteV1/Resources/Language/Language.resx | 3 + 6 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs diff --git a/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs b/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs new file mode 100644 index 00000000..dbb613cf --- /dev/null +++ b/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs @@ -0,0 +1,57 @@ +using System.Collections; +using mRemoteNG.App; +using mRemoteNG.Connection; +using mRemoteNG.Connection.Protocol; +using mRemoteNG.Tools; +using mRemoteNG.UI.Window; +using NUnit.Framework; +using WeifenLuo.WinFormsUI.Docking; + +namespace mRemoteNGTests.Connection.Protocol +{ + public class IntegratedProgramTests + { + private readonly ExternalTool _extTool = new ExternalTool + { + DisplayName = "notepad", + FileName = @"%windir%\system32\notepad.exe", + Arguments = "", + TryIntegrate = true + }; + + + [Test] + public void CanStartExternalApp() + { + SetExternalToolList(_extTool); + var sut = new IntegratedProgram(); + sut.InterfaceControl = BuildInterfaceControl("notepad", sut); + sut.Initialize(); + var appStarted = sut.Connect(); + sut.Disconnect(); + Assert.That(appStarted); + } + + [Test] + public void ConnectingToExternalAppThatDoesntExistDoesNothing() + { + SetExternalToolList(_extTool); + var sut = new IntegratedProgram(); + sut.InterfaceControl = BuildInterfaceControl("doesntExist", sut); + var appInitialized = sut.Initialize(); + Assert.That(appInitialized, Is.False); + } + + private void SetExternalToolList(ExternalTool externalTool) + { + Runtime.ExternalTools = new ArrayList {externalTool}; + } + + private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut) + { + var connectionWindow = new ConnectionWindow(new DockContent()); + var connectionInfo = new ConnectionInfo {ExtApp = extAppName}; + return new InterfaceControl(connectionWindow, sut, connectionInfo); + } + } +} \ No newline at end of file diff --git a/mRemoteNGTests/mRemoteNGTests.csproj b/mRemoteNGTests/mRemoteNGTests.csproj index 4f3b92ff..20bcff34 100644 --- a/mRemoteNGTests/mRemoteNGTests.csproj +++ b/mRemoteNGTests/mRemoteNGTests.csproj @@ -123,6 +123,7 @@ + diff --git a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs index fe93ae40..03f535e3 100644 --- a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs +++ b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs @@ -21,9 +21,15 @@ namespace mRemoteNG.Connection.Protocol #region Public Methods public override bool Initialize() { - if (InterfaceControl.Info == null) return base.Initialize(); + if (InterfaceControl.Info == null) + return base.Initialize(); _externalTool = Runtime.GetExtAppByName(InterfaceControl.Info.ExtApp); + if (_externalTool == null) + { + Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, InterfaceControl.Info.ExtApp)); + return false; + } _externalTool.ConnectionInfo = InterfaceControl.Info; return base.Initialize(); @@ -33,7 +39,7 @@ namespace mRemoteNG.Connection.Protocol { try { - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, $"Attempting to start: {_externalTool.DisplayName}", true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, $"Attempting to start: {_externalTool.DisplayName}", true); if (_externalTool.TryIntegrate == false) { @@ -43,7 +49,7 @@ namespace mRemoteNG.Connection.Protocol * will be called - which is just going to call IntegratedProgram.Close() again anyway... * Close(); */ - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, $"Assuming no other errors/exceptions occurred immediately before this message regarding {_externalTool.DisplayName}, the next \"closed by user\" message can be ignored", true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, $"Assuming no other errors/exceptions occurred immediately before this message regarding {_externalTool.DisplayName}, the next \"closed by user\" message can be ignored", true); return false; } @@ -80,10 +86,10 @@ namespace mRemoteNG.Connection.Protocol } NativeMethods.SetParent(_handle, InterfaceControl.Handle); - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strIntAppStuff, true); - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppHandle, _handle), true); - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppTitle, _process.MainWindowTitle), true); - Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppParentHandle, InterfaceControl.Parent.Handle), true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, Language.strIntAppStuff, true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppHandle, _handle), true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppTitle, _process.MainWindowTitle), true); + Runtime.MessageCollector?.AddMessage(MessageClass.InformationMsg, string.Format(Language.strIntAppParentHandle, InterfaceControl.Parent.Handle), true); Resize(this, new EventArgs()); base.Connect(); @@ -91,7 +97,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - Runtime.MessageCollector.AddExceptionMessage(Language.strIntAppConnectionFailed, ex); + Runtime.MessageCollector?.AddExceptionMessage(Language.strIntAppConnectionFailed, ex); return false; } } diff --git a/mRemoteV1/Connection/Protocol/ProtocolBase.cs b/mRemoteV1/Connection/Protocol/ProtocolBase.cs index 76a6cf32..b9008b03 100644 --- a/mRemoteV1/Connection/Protocol/ProtocolBase.cs +++ b/mRemoteV1/Connection/Protocol/ProtocolBase.cs @@ -1,6 +1,6 @@ using System; -using System.Windows.Forms; using System.Threading; +using System.Windows.Forms; using mRemoteNG.App; using mRemoteNG.Tools; @@ -153,7 +153,7 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - Runtime.MessageCollector.AddExceptionStackTrace("Couldn't dispose control, probably form is already closed (Connection.Protocol.Base)", ex); + Runtime.MessageCollector?.AddExceptionStackTrace("Couldn't dispose control, probably form is already closed (Connection.Protocol.Base)", ex); } } @@ -172,12 +172,12 @@ namespace mRemoteNG.Connection.Protocol } catch (Exception ex) { - Runtime.MessageCollector.AddExceptionStackTrace("Couldn't set InterfaceControl.Parent.Tag or Dispose Interface, probably form is already closed (Connection.Protocol.Base)", ex); + Runtime.MessageCollector?.AddExceptionStackTrace("Couldn't set InterfaceControl.Parent.Tag or Dispose Interface, probably form is already closed (Connection.Protocol.Base)", ex); } } catch (Exception ex) { - Runtime.MessageCollector.AddExceptionStackTrace("Couldn't Close InterfaceControl BG (Connection.Protocol.Base)", ex); + Runtime.MessageCollector?.AddExceptionStackTrace("Couldn't Close InterfaceControl BG (Connection.Protocol.Base)", ex); } } diff --git a/mRemoteV1/Resources/Language/Language.Designer.cs b/mRemoteV1/Resources/Language/Language.Designer.cs index 8eb0d595..852aaf68 100644 --- a/mRemoteV1/Resources/Language/Language.Designer.cs +++ b/mRemoteV1/Resources/Language/Language.Designer.cs @@ -60,6 +60,15 @@ namespace mRemoteNG { } } + /// + /// Looks up a localized string similar to Could not find external tool with name "{0}". + /// + internal static string CouldNotFindExternalTool { + get { + return ResourceManager.GetString("CouldNotFindExternalTool", resourceCulture); + } + } + /// /// Looks up a localized string similar to About. /// diff --git a/mRemoteV1/Resources/Language/Language.resx b/mRemoteV1/Resources/Language/Language.resx index 8cffa995..8a90eeec 100644 --- a/mRemoteV1/Resources/Language/Language.resx +++ b/mRemoteV1/Resources/Language/Language.resx @@ -2433,4 +2433,7 @@ mRemoteNG will now quit and begin with the installation. Alert on Idle Disconnect + + Could not find external tool with name "{0}" + \ No newline at end of file From 6db7adf9004a99ae573dc33b9ddb53884563b947 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 31 Oct 2017 13:10:49 -0500 Subject: [PATCH 03/20] re-implemented autoresizecolumn in the connection tree I did this in order to get around a weird bug where the connection tree would sometimes be set to a very small width (making it not visible) --- .../Controls/ConnectionTree/ConnectionTree.cs | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index a2296b39..98117470 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -15,13 +15,12 @@ using mRemoteNG.Tree.Root; namespace mRemoteNG.UI.Controls { - public partial class ConnectionTree : TreeListView, IConnectionTree + public partial class ConnectionTree : TreeListView, IConnectionTree { private ConnectionTreeModel _connectionTreeModel; private readonly ConnectionTreeDragAndDropHandler _dragAndDropHandler = new ConnectionTreeDragAndDropHandler(); private readonly PuttySessionsManager _puttySessionsManager = PuttySessionsManager.Instance; private bool _allowEdit; - private bool _isUpdatingColumnWidth; public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject; @@ -94,16 +93,15 @@ namespace mRemoteNG.UI.Controls var container = args.Model as ContainerInfo; if (container == null) return; container.IsExpanded = false; - UpdateColumnWidth(); - }; + AutoResizeColumn(Columns[0]); + }; Expanded += (sender, args) => { var container = args.Model as ContainerInfo; if (container == null) return; container.IsExpanded = true; - UpdateColumnWidth(); - }; - SizeChanged += OnSizeChanged; + AutoResizeColumn(Columns[0]); + }; SelectionChanged += tvConnections_AfterSelect; MouseDoubleClick += OnMouse_DoubleClick; MouseClick += OnMouse_SingleClick; @@ -113,20 +111,28 @@ namespace mRemoteNG.UI.Controls BeforeLabelEdit += HandleCheckForValidEdit; } - private void OnSizeChanged(object o, EventArgs eventArgs) - { - if (_isUpdatingColumnWidth) - return; - UpdateColumnWidth(); - } + /// + /// Resizes the given column to ensure that all content is shown + /// + private void AutoResizeColumn(ColumnHeader column) + { + var longestIndentationAndTextWidth = int.MinValue; + var horizontalScrollOffset = LowLevelScrollPosition.X; + const int padding = 10; - private void UpdateColumnWidth() - { - _isUpdatingColumnWidth = true; - AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); - Columns[0].Width += SmallImageSize.Width; - _isUpdatingColumnWidth = false; - } + for (var i = 0; i < Items.Count; i++) + { + var rowIndentation = Items[i].Position.X; + var rowTextWidth = TextRenderer.MeasureText(Items[i].Text, Font).Width; + + longestIndentationAndTextWidth = Math.Max(rowIndentation + rowTextWidth, longestIndentationAndTextWidth); + } + + column.Width = longestIndentationAndTextWidth + + SmallImageSize.Width + + horizontalScrollOffset + + padding; + } private void PopulateTreeView() { @@ -134,9 +140,9 @@ namespace mRemoteNG.UI.Controls SetObjects(ConnectionTreeModel.RootNodes); RegisterModelUpdateHandlers(); NodeSearcher = new NodeSearcher(ConnectionTreeModel); - UpdateColumnWidth(); ExecutePostSetupActions(); - } + AutoResizeColumn(Columns[0]); + } private void RegisterModelUpdateHandlers() { @@ -168,8 +174,8 @@ namespace mRemoteNG.UI.Controls return; RefreshObject(senderAsConnectionInfo); - UpdateColumnWidth(); - } + AutoResizeColumn(Columns[0]); + } private void ExecutePostSetupActions() { @@ -278,8 +284,8 @@ namespace mRemoteNG.UI.Controls private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { RefreshObject(sender); - UpdateColumnWidth(); - } + AutoResizeColumn(Columns[0]); + } private void tvConnections_AfterSelect(object sender, EventArgs e) { @@ -298,7 +304,7 @@ namespace mRemoteNG.UI.Controls if (mouseEventArgs.Clicks < 2) return; OLVColumn column; var listItem = GetItemAt(mouseEventArgs.X, mouseEventArgs.Y, out column); - var clickedNode = listItem.RowObject as ConnectionInfo; + var clickedNode = listItem?.RowObject as ConnectionInfo; if (clickedNode == null) return; DoubleClickHandler.Execute(clickedNode); } From 2b672dc4fc21f5ba798b6b724575de07688ffbc2 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 31 Oct 2017 14:07:18 -0500 Subject: [PATCH 04/20] Fixed another minor issue with external tools --- mRemoteV1/Tools/ExternalTool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/Tools/ExternalTool.cs b/mRemoteV1/Tools/ExternalTool.cs index 7f89a1bc..279e31de 100644 --- a/mRemoteV1/Tools/ExternalTool.cs +++ b/mRemoteV1/Tools/ExternalTool.cs @@ -105,7 +105,7 @@ namespace mRemoteNG.Tools private void SetConnectionInfoFields(ConnectionInfo newConnectionInfo) { newConnectionInfo.Protocol = ProtocolType.IntApp; - newConnectionInfo.ExtApp = FileName; + newConnectionInfo.ExtApp = DisplayName; newConnectionInfo.Name = DisplayName; newConnectionInfo.Panel = Language.strMenuExternalTools; } From 99e52ab0b5cadd8412886b74e13b1c2e019c7232 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 31 Oct 2017 15:08:06 -0500 Subject: [PATCH 05/20] updated changelog --- CHANGELOG.TXT | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 658b4874..b76fbf04 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,10 @@ +1.75.7011 (2017-xx-xx): + +Fixes: +------ +#761: Connections using external tools do not start (introduced in v1.75.7009) + + 1.75.7010 (2017-10-29): Fixes: From e3121cb0439c44f9103bbc95f464eccde41482c4 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Wed, 1 Nov 2017 15:14:55 -0500 Subject: [PATCH 06/20] bumped assembly version --- mRemoteV1/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/Properties/AssemblyInfo.cs b/mRemoteV1/Properties/AssemblyInfo.cs index df10ceba..5dfee719 100644 --- a/mRemoteV1/Properties/AssemblyInfo.cs +++ b/mRemoteV1/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // -[assembly: AssemblyVersion("1.75.7010.*")] +[assembly: AssemblyVersion("1.75.7011.*")] [assembly:NeutralResourcesLanguageAttribute("en")] From 5ce8171f12b7385f571fa634457015dd9bc05991 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Wed, 1 Nov 2017 15:29:54 -0500 Subject: [PATCH 07/20] updated changelog --- CHANGELOG.TXT | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index b76fbf04..59dedf80 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -3,6 +3,7 @@ Fixes: ------ #761: Connections using external tools do not start (introduced in v1.75.7009) +Minor changes to how the connection tree column widths are calculated 1.75.7010 (2017-10-29): From 4defa5fa9caf5245b28e5a6d464a92b69beffe34 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 3 Nov 2017 15:09:18 -0500 Subject: [PATCH 08/20] Resolves #758 introduced in commit 8a3e3704 --- mRemoteV1/App/Runtime.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs index 28a24e51..ffa6d05e 100644 --- a/mRemoteV1/App/Runtime.cs +++ b/mRemoteV1/App/Runtime.cs @@ -469,7 +469,7 @@ namespace mRemoteNG.App connectionsSaver.SQLDatabaseName = Settings.Default.SQLDatabaseName; connectionsSaver.SQLUsername = Settings.Default.SQLUser; var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); - connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Settings.Default.SQLUser, EncryptionKey); + connectionsSaver.SQLPassword = cryptographyProvider.Decrypt(Settings.Default.SQLPass, EncryptionKey); } connectionsSaver.SaveConnections(); From 01ad0b48754ca7240866db24eca4dbfe4f15d7b0 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Fri, 3 Nov 2017 15:10:35 -0500 Subject: [PATCH 09/20] safer connection tree gui updating --- mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index 98117470..53ca1a5f 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -116,6 +116,12 @@ namespace mRemoteNG.UI.Controls /// private void AutoResizeColumn(ColumnHeader column) { + if (InvokeRequired) + { + Invoke((MethodInvoker) (() => AutoResizeColumn(column))); + return; + } + var longestIndentationAndTextWidth = int.MinValue; var horizontalScrollOffset = LowLevelScrollPosition.X; const int padding = 10; From 7a002e4b89e2c71f9fdef95b953e49354ab7f1c7 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sat, 4 Nov 2017 11:45:14 -0500 Subject: [PATCH 10/20] updated changelog --- CHANGELOG.TXT | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 59dedf80..7e709120 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,9 +1,10 @@ -1.75.7011 (2017-xx-xx): +1.75.7011 (2017-11-04): Fixes: ------ +#763: Sometimes minimizing folder causes connection tree to disappear #761: Connections using external tools do not start (introduced in v1.75.7009) -Minor changes to how the connection tree column widths are calculated +#758: "Decryption failed" message when loading from SQL server 1.75.7010 (2017-10-29): From 88d735ed56d326ac009a6ad77f6b456020066516 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sat, 4 Nov 2017 22:04:08 -0500 Subject: [PATCH 11/20] resolved bug that would sometimes disable connection tree hot keys bug was introduced in #652. I made sure that the original issue is still resolved --- .../Controls/ConnectionTree/ConnectionTree.cs | 56 ++++++++++++++----- .../UI/Controls/ConnectionTree/NameColumn.cs | 1 + mRemoteV1/UI/Window/ConnectionTreeWindow.cs | 27 +-------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index 53ca1a5f..5c253006 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -20,7 +20,9 @@ namespace mRemoteNG.UI.Controls private ConnectionTreeModel _connectionTreeModel; private readonly ConnectionTreeDragAndDropHandler _dragAndDropHandler = new ConnectionTreeDragAndDropHandler(); private readonly PuttySessionsManager _puttySessionsManager = PuttySessionsManager.Instance; + private bool _nodeInEditMode; private bool _allowEdit; + private ConnectionContextMenu _contextMenu; public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject; @@ -59,6 +61,8 @@ namespace mRemoteNG.UI.Controls SmallImageList = imageList.GetImageList(); AddColumns(imageList.ImageGetter); LinkModelToView(); + _contextMenu = new ConnectionContextMenu(this); + ContextMenuStrip = _contextMenu; SetupDropSink(); SetEventHandlers(); } @@ -108,7 +112,8 @@ namespace mRemoteNG.UI.Controls CellToolTipShowing += tvConnections_CellToolTipShowing; ModelCanDrop += _dragAndDropHandler.HandleEvent_ModelCanDrop; ModelDropped += _dragAndDropHandler.HandleEvent_ModelDropped; - BeforeLabelEdit += HandleCheckForValidEdit; + BeforeLabelEdit += OnBeforeLabelEdit; + AfterLabelEdit += OnAfterLabelEdit; } /// @@ -263,20 +268,6 @@ namespace mRemoteNG.UI.Controls { _allowEdit = true; SelectedItem.BeginEdit(); - Runtime.SaveConnectionsAsync(); - } - - public void HandleCheckForValidEdit(object sender, LabelEditEventArgs e) - { - if (!(sender is ConnectionTree)) return; - if (_allowEdit) - { - _allowEdit = false; - } - else - { - e.CancelEdit = true; - } } public void DeleteSelectedNode() @@ -337,6 +328,41 @@ namespace mRemoteNG.UI.Controls Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_MouseMove (UI.Window.ConnectionTreeWindow) failed", ex); } } + + private void OnBeforeLabelEdit(object sender, LabelEditEventArgs e) + { + if (_nodeInEditMode || !(sender is ConnectionTree)) + return; + + if (!_allowEdit || SelectedNode is PuttySessionInfo || SelectedNode is RootPuttySessionsNodeInfo) + { + e.CancelEdit = true; + return; + } + + _nodeInEditMode = true; + _contextMenu.DisableShortcutKeys(); + } + + private void OnAfterLabelEdit(object sender, LabelEditEventArgs e) + { + if (!_nodeInEditMode) + return; + + try + { + _contextMenu.EnableShortcutKeys(); + ConnectionTreeModel.RenameNode(SelectedNode, e.Label); + _nodeInEditMode = false; + _allowEdit = false; + Windows.ConfigForm.SelectedTreeNode = SelectedNode; + Runtime.SaveConnectionsAsync(); + } + catch (Exception ex) + { + Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterLabelEdit (UI.Window.ConnectionTreeWindow) failed", ex); + } + } #endregion } } \ No newline at end of file diff --git a/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs b/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs index 1097912e..ba056188 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs @@ -12,6 +12,7 @@ namespace mRemoteNG.UI.Controls FillsFreeSpace = false; AspectGetter = item => ((ConnectionInfo) item).Name; ImageGetter = imageGetterDelegate; + AutoCompleteEditor = false; } } } \ No newline at end of file diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index 3ce13648..8435c654 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; +using mRemoteNG.Tree.Root; using mRemoteNG.UI.Controls; using WeifenLuo.WinFormsUI.Docking; @@ -15,10 +16,8 @@ namespace mRemoteNG.UI.Window { public partial class ConnectionTreeWindow { - private readonly ConnectionContextMenu _contextMenu; private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator(); - public ConnectionInfo SelectedNode => olvConnections.SelectedNode; public ConnectionTree ConnectionTree @@ -32,8 +31,6 @@ namespace mRemoteNG.UI.Window WindowType = WindowType.Tree; DockPnl = panel; InitializeComponent(); - _contextMenu = new ConnectionContextMenu(olvConnections); - olvConnections.ContextMenuStrip = _contextMenu; SetMenuEventHandlers(); SetConnectionTreeEventHandlers(); Settings.Default.PropertyChanged += (sender, args) => SetConnectionTreeEventHandlers(); @@ -84,8 +81,6 @@ namespace mRemoteNG.UI.Window private void SetConnectionTreeEventHandlers() { olvConnections.NodeDeletionConfirmer = new SelectedConnectionDeletionConfirmer(olvConnections, MessageBox.Show); - olvConnections.BeforeLabelEdit += tvConnections_BeforeLabelEdit; - olvConnections.AfterLabelEdit += tvConnections_AfterLabelEdit; olvConnections.KeyDown += tvConnections_KeyDown; olvConnections.KeyPress += tvConnections_KeyPress; SetTreePostSetupActions(); @@ -171,26 +166,6 @@ namespace mRemoteNG.UI.Window Runtime.SaveConnectionsAsync(); } - - private void tvConnections_BeforeLabelEdit(object sender, LabelEditEventArgs e) - { - _contextMenu.DisableShortcutKeys(); - } - - private void tvConnections_AfterLabelEdit(object sender, LabelEditEventArgs e) - { - try - { - _contextMenu.EnableShortcutKeys(); - ConnectionTree.ConnectionTreeModel.RenameNode(SelectedNode, e.Label); - Windows.ConfigForm.SelectedTreeNode = SelectedNode; - Runtime.SaveConnectionsAsync(); - } - catch (Exception ex) - { - Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterLabelEdit (UI.Window.ConnectionTreeWindow) failed", ex); - } - } #endregion #region Search From 7451383c24257e4c0fd375f82912ce7f1cd60782 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sun, 5 Nov 2017 07:09:17 -0600 Subject: [PATCH 12/20] putty nodes and root putty node should not have context menu items "import" or "export" --- mRemoteV1/UI/Controls/ConnectionContextMenu.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs index fd51d65c..49bec5db 100644 --- a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs +++ b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs @@ -443,7 +443,9 @@ namespace mRemoteNG.UI.Controls _cMenTreeToolsSort.Enabled = false; _cMenTreeToolsExternalApps.Enabled = false; _cMenTreeDuplicate.Enabled = false; - _cMenTreeRename.Enabled = true; + _cMenTreeImport.Enabled = false; + _cMenTreeExportFile.Enabled = false; + _cMenTreeRename.Enabled = false; _cMenTreeDelete.Enabled = false; _cMenTreeMoveUp.Enabled = false; _cMenTreeMoveDown.Enabled = false; @@ -498,6 +500,8 @@ namespace mRemoteNG.UI.Controls _cMenTreeDelete.Enabled = false; _cMenTreeMoveUp.Enabled = false; _cMenTreeMoveDown.Enabled = false; + _cMenTreeImport.Enabled = false; + _cMenTreeExportFile.Enabled = false; } internal void ShowHideMenuItemsForConnectionNode(ConnectionInfo connectionInfo) From 85b67ecd0b061fc16bf7e34b2a70dacb8762aeff Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sun, 5 Nov 2017 07:24:28 -0600 Subject: [PATCH 13/20] fixed bug in connection tree context menu right clicking in white space (no connection tree item selected) made the context menu appear with all options enabled. No context menu should appear in that case --- mRemoteV1/UI/Controls/ConnectionContextMenu.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs index 49bec5db..3ae6148c 100644 --- a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs +++ b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs @@ -60,9 +60,13 @@ namespace mRemoteNG.UI.Controls Opening += (sender, args) => { AddExternalApps(); + if (_connectionTree.SelectedNode == null) + { + args.Cancel = true; + return; + } ShowHideMenuItems(); }; - Closing += (sender, args) => EnableMenuItemsRecursive(Items); } private void InitializeComponent() @@ -397,9 +401,6 @@ namespace mRemoteNG.UI.Controls internal void ShowHideMenuItems() { - if (_connectionTree.SelectedNode == null) - return; - try { Enabled = true; From 0120762dbeadb6048594c7333e56b5a3a9adbc59 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sun, 5 Nov 2017 08:41:13 -0600 Subject: [PATCH 14/20] putty sessions should not have the inheritance button --- mRemoteV1/UI/Window/ConfigWindow.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index f529aab8..4a551f09 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -492,7 +492,9 @@ namespace mRemoteNG.UI.Window _pGrid.SelectedObject = propertyGridObject; _btnShowProperties.Enabled = true; - _btnShowInheritance.Enabled = gridObjectAsConnectionInfo.Parent != null; + _btnShowInheritance.Enabled = + !(gridObjectAsConnectionInfo is PuttySessionInfo) && + gridObjectAsConnectionInfo.Parent != null; _btnShowDefaultProperties.Enabled = false; _btnShowDefaultInheritance.Enabled = false; _btnIcon.Enabled = true; From aed509155b34f1d4e092d9d809ec1d13289df0a7 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Sun, 5 Nov 2017 09:04:10 -0600 Subject: [PATCH 15/20] inheritance button should be disabled when parent is root connection node --- mRemoteV1/UI/Window/ConfigWindow.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index 4a551f09..475741e2 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -476,7 +476,9 @@ namespace mRemoteNG.UI.Window _pGrid.SelectedObject = propertyGridObject; _btnShowProperties.Enabled = true; - _btnShowInheritance.Enabled = gridObjectAsContainerInfo.Parent != null; + _btnShowInheritance.Enabled = + gridObjectAsContainerInfo.Parent != null && + !(gridObjectAsContainerInfo.Parent is RootNodeInfo); _btnShowDefaultProperties.Enabled = false; _btnShowDefaultInheritance.Enabled = false; _btnIcon.Enabled = true; @@ -494,7 +496,8 @@ namespace mRemoteNG.UI.Window _btnShowProperties.Enabled = true; _btnShowInheritance.Enabled = !(gridObjectAsConnectionInfo is PuttySessionInfo) && - gridObjectAsConnectionInfo.Parent != null; + gridObjectAsConnectionInfo.Parent != null && + !(gridObjectAsConnectionInfo.Parent is RootNodeInfo); _btnShowDefaultProperties.Enabled = false; _btnShowDefaultInheritance.Enabled = false; _btnIcon.Enabled = true; From afc410cfe6d84f4509d6c40a9fcbe0a9121ff677 Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 7 Nov 2017 08:21:32 -0600 Subject: [PATCH 16/20] fixed #778 custom cons param bug introduced in commit f73c9c9d --- mRemoteV1/App/Startup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/App/Startup.cs b/mRemoteV1/App/Startup.cs index 8cdc0a75..8e2de4c8 100644 --- a/mRemoteV1/App/Startup.cs +++ b/mRemoteV1/App/Startup.cs @@ -253,11 +253,11 @@ namespace mRemoteNG.App var ConsParam = ""; if (cmd["cons"] != null) { - ConsParam = "cons"; + ConsParam = cmd["cons"]; } if (cmd["c"] != null) { - ConsParam = "c"; + ConsParam = cmd["c"]; } var ResetPosParam = ""; From 469b4224dcbd71d4fde3994305b9a028bfae1c2b Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 7 Nov 2017 10:05:18 -0600 Subject: [PATCH 17/20] fixed bug with resetting window position resetting window position now places app in center of main monitor like it should --- mRemoteV1/App/Startup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mRemoteV1/App/Startup.cs b/mRemoteV1/App/Startup.cs index 8e2de4c8..f1af845a 100644 --- a/mRemoteV1/App/Startup.cs +++ b/mRemoteV1/App/Startup.cs @@ -318,8 +318,12 @@ namespace mRemoteNG.App if (!string.IsNullOrEmpty(ResetPosParam)) { Settings.Default.MainFormKiosk = false; - Settings.Default.MainFormLocation = new Point(999, 999); - Settings.Default.MainFormSize = new Size(900, 600); + var newWidth = 900; + var newHeight = 600; + var newX = Screen.PrimaryScreen.WorkingArea.Width/2 - newWidth/2; + var newY = Screen.PrimaryScreen.WorkingArea.Height/2 - newHeight/2; + Settings.Default.MainFormLocation = new Point(newX, newY); + Settings.Default.MainFormSize = new Size(newWidth, newHeight); Settings.Default.MainFormState = FormWindowState.Normal; } From ef5b09b6facf2017cbccbd5eaa475eec348b2f6e Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 7 Nov 2017 16:35:25 -0600 Subject: [PATCH 18/20] fix issue where /resetpanels did nothing --- mRemoteV1/UI/Forms/frmMain.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mRemoteV1/UI/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index d6ec6c0f..9a8a6ce7 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -204,6 +204,9 @@ namespace mRemoteNG.UI.Forms Runtime.NewConnections(Runtime.GetStartupConnectionFileName()); } + if (Settings.Default.ResetPanels) + SetDefaultLayout(); + Runtime.LoadConnections(); Windows.TreePanel.Focus(); From 9c57976906bd34468ea6e0b7aa766ff37d8a23ba Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 7 Nov 2017 20:20:24 -0600 Subject: [PATCH 19/20] singleton instance should be given focus --- mRemoteV1/App/ProgramRoot.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/mRemoteV1/App/ProgramRoot.cs b/mRemoteV1/App/ProgramRoot.cs index 445366ad..fbc71571 100644 --- a/mRemoteV1/App/ProgramRoot.cs +++ b/mRemoteV1/App/ProgramRoot.cs @@ -56,6 +56,7 @@ namespace mRemoteNG.App if (singletonInstanceWindowHandle == IntPtr.Zero) return; if (NativeMethods.IsIconic(singletonInstanceWindowHandle) != 0) NativeMethods.ShowWindow(singletonInstanceWindowHandle, (int)NativeMethods.SW_RESTORE); + NativeMethods.SetForegroundWindow(singletonInstanceWindowHandle); } private static IntPtr GetRunningSingletonInstanceWindowHandle() From 9cee827f6b16f16e1b1e78492e9078f488dc9abf Mon Sep 17 00:00:00 2001 From: David Sparer Date: Tue, 7 Nov 2017 20:21:13 -0600 Subject: [PATCH 20/20] updated changelog --- CHANGELOG.TXT | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 7e709120..afb1545d 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,10 +1,13 @@ -1.75.7011 (2017-11-04): +1.75.7011 (2017-11-07): Fixes: ------ +#778: Custom connection file path command line argument (/c) not working #763: Sometimes minimizing folder causes connection tree to disappear #761: Connections using external tools do not start (introduced in v1.75.7009) #758: "Decryption failed" message when loading from SQL server +Fixed issues with /resetpanels and /resetpos command line arguments +Resolved bug where connection tree hotkeys would sometimes be disabled 1.75.7010 (2017-10-29):