diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 8c8cf5e0..da6b4595 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -14,6 +14,18 @@ Improved compatability between environments when building mRemoteNG from source #493: Changed backup file name time stamp to use local system time rather than UTC +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): Fixes: diff --git a/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs b/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs new file mode 100644 index 00000000..0f88a524 --- /dev/null +++ b/mRemoteNGTests/Connection/Protocol/IntegratedProgramTests.cs @@ -0,0 +1,57 @@ +using System.Collections.ObjectModel; +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.ExternalToolsService.ExternalTools = new ObservableCollection {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 9f544709..6a7818fc 100644 --- a/mRemoteNGTests/mRemoteNGTests.csproj +++ b/mRemoteNGTests/mRemoteNGTests.csproj @@ -141,6 +141,7 @@ + diff --git a/mRemoteV1/App/ProgramRoot.cs b/mRemoteV1/App/ProgramRoot.cs index 23a7d31d..23ac6a1f 100644 --- a/mRemoteV1/App/ProgramRoot.cs +++ b/mRemoteV1/App/ProgramRoot.cs @@ -55,6 +55,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() diff --git a/mRemoteV1/Connection/ConnectionInitiator.cs b/mRemoteV1/Connection/ConnectionInitiator.cs index e880d736..4502df26 100644 --- a/mRemoteV1/Connection/ConnectionInitiator.cs +++ b/mRemoteV1/Connection/ConnectionInitiator.cs @@ -13,9 +13,8 @@ using TabPage = Crownwood.Magic.Controls.TabPage; namespace mRemoteNG.Connection { - public class ConnectionInitiator : IConnectionInitiator + public class ConnectionInitiator : IConnectionInitiator { - private readonly FrmMain _frmMain = FrmMain.Default; private readonly PanelAdder _panelAdder = new PanelAdder(); public void OpenConnection(ContainerInfo containerInfo, ConnectionInfo.Force force = ConnectionInfo.Force.None) @@ -54,7 +53,7 @@ namespace mRemoteNG.Connection var connectionWindow = (ConnectionWindow)interfaceControl.FindForm(); connectionWindow?.Focus(); var findForm = (ConnectionWindow)interfaceControl.FindForm(); - findForm?.Show(_frmMain.pnlDock); + findForm?.Show(FrmMain.Default.pnlDock); var tabPage = (TabPage)interfaceControl.Parent; tabPage.Selected = true; return true; @@ -118,7 +117,7 @@ namespace mRemoteNG.Connection } connectionInfo.OpenConnections.Add(newProtocol); - _frmMain.SelectedConnection = connectionInfo; + FrmMain.Default.SelectedConnection = connectionInfo; } catch (Exception ex) { @@ -179,7 +178,7 @@ namespace mRemoteNG.Connection if (connectionForm == null) connectionForm = _panelAdder.AddPanel(connectionPanel); else - ((ConnectionWindow)connectionForm).Show(_frmMain.pnlDock); + ((ConnectionWindow)connectionForm).Show(FrmMain.Default.pnlDock); connectionForm.Focus(); return connectionForm; diff --git a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs index e807ecd5..d3c27c0c 100644 --- a/mRemoteV1/Connection/Protocol/IntegratedProgram.cs +++ b/mRemoteV1/Connection/Protocol/IntegratedProgram.cs @@ -20,10 +20,18 @@ 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.ExternalToolsService.GetExtAppByName(InterfaceControl.Info.ExtApp); - _externalTool.ConnectionInfo = InterfaceControl.Info; + + if (_externalTool == null) + { + Runtime.MessageCollector?.AddMessage(MessageClass.ErrorMsg, string.Format(Language.CouldNotFindExternalTool, InterfaceControl.Info.ExtApp)); + return false; + } + + _externalTool.ConnectionInfo = InterfaceControl.Info; return base.Initialize(); } @@ -32,7 +40,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) { @@ -42,7 +50,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; } @@ -79,10 +87,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(); @@ -90,7 +98,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 e4699c9e..95992401 100644 --- a/mRemoteV1/Resources/Language/Language.Designer.cs +++ b/mRemoteV1/Resources/Language/Language.Designer.cs @@ -61,6 +61,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 Credentials. /// internal static string Credentials { diff --git a/mRemoteV1/Resources/Language/Language.resx b/mRemoteV1/Resources/Language/Language.resx index 2f601428..ea355473 100644 --- a/mRemoteV1/Resources/Language/Language.resx +++ b/mRemoteV1/Resources/Language/Language.resx @@ -2592,4 +2592,7 @@ This page will walk you through the process of upgrading your connections file o No themes are loaded, check that the default mremoteNG themes exist in the slash themes folder + + Could not find external tool with name "{0}" + \ No newline at end of file diff --git a/mRemoteV1/Tools/Cmdline/StartupArgumentsInterpreter.cs b/mRemoteV1/Tools/Cmdline/StartupArgumentsInterpreter.cs index 03d5cd9b..b3f37ae2 100644 --- a/mRemoteV1/Tools/Cmdline/StartupArgumentsInterpreter.cs +++ b/mRemoteV1/Tools/Cmdline/StartupArgumentsInterpreter.cs @@ -9,7 +9,7 @@ using mRemoteNG.Messages; namespace mRemoteNG.Tools.Cmdline { - public class StartupArgumentsInterpreter + public class StartupArgumentsInterpreter { private readonly MessageCollector _messageCollector; @@ -46,11 +46,15 @@ namespace mRemoteNG.Tools.Cmdline { if (args["resetpos"] == null && args["rp"] == null && args["reset"] == null) return; _messageCollector.AddMessage(MessageClass.DebugMsg, "Cmdline arg: Resetting window positions."); - Settings.Default.MainFormKiosk = false; - Settings.Default.MainFormLocation = new Point(999, 999); - Settings.Default.MainFormSize = new Size(900, 600); - Settings.Default.MainFormState = FormWindowState.Normal; - } + Settings.Default.MainFormKiosk = false; + 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; + } private void ParseResetPanelsArg(CmdArgumentsInterpreter args) { @@ -85,15 +89,15 @@ namespace mRemoteNG.Tools.Cmdline _messageCollector.AddMessage(MessageClass.DebugMsg, "Cmdline arg: loading connections from a custom path"); if (File.Exists(args[consParam]) == false) { - if (File.Exists(GeneralAppInfo.HomePath + "\\" + args[consParam])) + if (File.Exists(Path.Combine(GeneralAppInfo.HomePath, args[consParam]))) { Settings.Default.LoadConsFromCustomLocation = true; - Settings.Default.CustomConsPath = GeneralAppInfo.HomePath + "\\" + args[consParam]; + Settings.Default.CustomConsPath = Path.Combine(GeneralAppInfo.HomePath, args[consParam]); return; } - if (!File.Exists(ConnectionsFileInfo.DefaultConnectionsPath + "\\" + args[consParam])) return; + if (!File.Exists(Path.Combine(ConnectionsFileInfo.DefaultConnectionsPath, args[consParam]))) return; Settings.Default.LoadConsFromCustomLocation = true; - Settings.Default.CustomConsPath = ConnectionsFileInfo.DefaultConnectionsPath + "\\" + args[consParam]; + Settings.Default.CustomConsPath = Path.Combine(ConnectionsFileInfo.DefaultConnectionsPath, args[consParam]); } else { diff --git a/mRemoteV1/Tools/ExternalTool.cs b/mRemoteV1/Tools/ExternalTool.cs index 31c38440..d38bf809 100644 --- a/mRemoteV1/Tools/ExternalTool.cs +++ b/mRemoteV1/Tools/ExternalTool.cs @@ -112,7 +112,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; } diff --git a/mRemoteV1/UI/Controls/ConnectionContextMenu.cs b/mRemoteV1/UI/Controls/ConnectionContextMenu.cs index 54c8b811..b43a591e 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; @@ -443,7 +444,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 +501,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) diff --git a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs index 0b3146e5..f1f1acd4 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/ConnectionTree.cs @@ -15,15 +15,15 @@ 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 readonly StatusImageList _statusImageList = new StatusImageList(); - + private readonly StatusImageList _statusImageList = new StatusImageList(); + private bool _nodeInEditMode; private bool _allowEdit; - private bool _isUpdatingColumnWidth; + private ConnectionContextMenu _contextMenu; public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject; @@ -71,6 +71,8 @@ namespace mRemoteNG.UI.Controls SmallImageList = _statusImageList.ImageList; AddColumns(_statusImageList.ImageGetter); LinkModelToView(); + _contextMenu = new ConnectionContextMenu(this); + ContextMenuStrip = _contextMenu; SetupDropSink(); SetEventHandlers(); } @@ -105,39 +107,53 @@ 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; CellToolTipShowing += tvConnections_CellToolTipShowing; ModelCanDrop += _dragAndDropHandler.HandleEvent_ModelCanDrop; ModelDropped += _dragAndDropHandler.HandleEvent_ModelDropped; - BeforeLabelEdit += HandleCheckForValidEdit; + BeforeLabelEdit += OnBeforeLabelEdit; + AfterLabelEdit += OnAfterLabelEdit; } - 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) + { + if (InvokeRequired) + { + Invoke((MethodInvoker) (() => AutoResizeColumn(column))); + return; + } - private void UpdateColumnWidth() - { - _isUpdatingColumnWidth = true; - AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); - Columns[0].Width += SmallImageSize.Width; - _isUpdatingColumnWidth = false; - } + var longestIndentationAndTextWidth = int.MinValue; + var horizontalScrollOffset = LowLevelScrollPosition.X; + const int padding = 10; + + 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() { @@ -145,9 +161,9 @@ namespace mRemoteNG.UI.Controls SetObjects(ConnectionTreeModel.RootNodes); RegisterModelUpdateHandlers(); NodeSearcher = new NodeSearcher(ConnectionTreeModel); - UpdateColumnWidth(); ExecutePostSetupActions(); - } + AutoResizeColumn(Columns[0]); + } private void RegisterModelUpdateHandlers() { @@ -185,8 +201,8 @@ namespace mRemoteNG.UI.Controls return; RefreshObject(senderAsConnectionInfo); - UpdateColumnWidth(); - } + AutoResizeColumn(Columns[0]); + } private void ExecutePostSetupActions() { @@ -269,20 +285,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() @@ -310,7 +312,8 @@ namespace mRemoteNG.UI.Controls private void HandleCollectionChanged(object sender, NotifyCollectionChangedEventArgs args) { RefreshObject(sender); - } + AutoResizeColumn(Columns[0]); + } private void tvConnections_AfterSelect(object sender, EventArgs e) { @@ -329,7 +332,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); } @@ -356,6 +359,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 d6f8ec24..ca275a04 100644 --- a/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs +++ b/mRemoteV1/UI/Controls/ConnectionTree/NameColumn.cs @@ -11,6 +11,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/Forms/frmMain.cs b/mRemoteV1/UI/Forms/frmMain.cs index 439d2c64..e98274e5 100644 --- a/mRemoteV1/UI/Forms/frmMain.cs +++ b/mRemoteV1/UI/Forms/frmMain.cs @@ -153,6 +153,9 @@ namespace mRemoteNG.UI.Forms Runtime.WindowList = new WindowList(); + if (Settings.Default.ResetPanels) + SetDefaultLayout(); + var credsAndConsSetup = new CredsAndConsSetup(); credsAndConsSetup.LoadCredsAndCons(); diff --git a/mRemoteV1/UI/Window/ConfigWindow.cs b/mRemoteV1/UI/Window/ConfigWindow.cs index c043afae..f7a56fea 100644 --- a/mRemoteV1/UI/Window/ConfigWindow.cs +++ b/mRemoteV1/UI/Window/ConfigWindow.cs @@ -467,7 +467,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; @@ -483,7 +485,10 @@ namespace mRemoteNG.UI.Window _pGrid.SelectedObject = propertyGridObject; _btnShowProperties.Enabled = true; - _btnShowInheritance.Enabled = gridObjectAsConnectionInfo.Parent != null; + _btnShowInheritance.Enabled = + !(gridObjectAsConnectionInfo is PuttySessionInfo) && + gridObjectAsConnectionInfo.Parent != null && + !(gridObjectAsConnectionInfo.Parent is RootNodeInfo); _btnShowDefaultProperties.Enabled = false; _btnShowDefaultInheritance.Enabled = false; _btnIcon.Enabled = true; diff --git a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs index 78f68eb6..16bdca45 100644 --- a/mRemoteV1/UI/Window/ConnectionTreeWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionTreeWindow.cs @@ -1,14 +1,14 @@ -using mRemoteNG.App; -using mRemoteNG.Connection; -using mRemoteNG.Tree; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; +using mRemoteNG.App; +using mRemoteNG.Connection; +using mRemoteNG.Themes; +using mRemoteNG.Tree; using mRemoteNG.UI.Controls; using WeifenLuo.WinFormsUI.Docking; -using mRemoteNG.Themes; // ReSharper disable ArrangeAccessorOwnerBody namespace mRemoteNG.UI.Window @@ -17,12 +17,9 @@ namespace mRemoteNG.UI.Window { private readonly ConnectionContextMenu _contextMenu; private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator(); - private ThemeManager _themeManager; + private ThemeManager _themeManager; - public ConnectionInfo SelectedNode - { - get { return olvConnections.SelectedNode; } - } + public ConnectionInfo SelectedNode => olvConnections.SelectedNode; public ConnectionTree ConnectionTree { @@ -39,8 +36,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(); @@ -95,7 +90,7 @@ namespace mRemoteNG.UI.Window #endregion #region ConnectionTree - private void SetConnectionTreeEventHandlers() + private void SetConnectionTreeEventHandlers() { olvConnections.NodeDeletionConfirmer = new SelectedConnectionDeletionConfirmer(MessageBox.Show); olvConnections.BeforeLabelEdit += tvConnections_BeforeLabelEdit; diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index a9441809..ef2de66a 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -4,32 +4,31 @@ using System.Linq; using System.Runtime.InteropServices; using System.Windows.Forms; using BrightIdeasSoftware; -using mRemoteNG.Connection; using mRemoteNG.App; -using WeifenLuo.WinFormsUI.Docking; -using mRemoteNG.Config; -using mRemoteNG.Connection.Protocol.VNC; -using mRemoteNG.Connection.Protocol.RDP; -using mRemoteNG.Connection.Protocol; -using mRemoteNG.UI.Forms; -using mRemoteNG.UI.TaskDialog; using mRemoteNG.App.Info; +using mRemoteNG.Config; +using mRemoteNG.Connection; +using mRemoteNG.Connection.Protocol; +using mRemoteNG.Connection.Protocol.RDP; +using mRemoteNG.Connection.Protocol.VNC; using mRemoteNG.Container; +using mRemoteNG.Themes; using mRemoteNG.Tools; +using mRemoteNG.UI.Forms; using mRemoteNG.UI.Forms.Input; +using mRemoteNG.UI.TaskDialog; +using WeifenLuo.WinFormsUI.Docking; using Message = System.Windows.Forms.Message; using TabControl = Crownwood.Magic.Controls.TabControl; using TabPage = Crownwood.Magic.Controls.TabPage; -using mRemoteNG.Themes; namespace mRemoteNG.UI.Window { - public partial class ConnectionWindow : BaseWindow + public partial class ConnectionWindow : BaseWindow { public TabControl TabController; private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator(); - private readonly FrmMain _frmMain = FrmMain.Default; - private WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender vsToolStripExtender; + private VisualStudioToolStripExtender vsToolStripExtender; private readonly ToolStripRenderer _toolStripProfessionalRenderer = new ToolStripProfessionalRenderer(); #region Public Methods @@ -156,12 +155,12 @@ namespace mRemoteNG.UI.Window { if (TabController.SelectedTab == null) { - _frmMain.SelectedConnection = null; + FrmMain.Default.SelectedConnection = null; } else { var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl; - _frmMain.SelectedConnection = interfaceControl?.Info; + FrmMain.Default.SelectedConnection = interfaceControl?.Info; } } #endregion @@ -196,8 +195,8 @@ namespace mRemoteNG.UI.Window { if (_documentHandlersAdded) { - _frmMain.ResizeBegin -= Connection_ResizeBegin; - _frmMain.ResizeEnd -= Connection_ResizeEnd; + FrmMain.Default.ResizeBegin -= Connection_ResizeBegin; + FrmMain.Default.ResizeEnd -= Connection_ResizeEnd; _documentHandlersAdded = false; } DockHandler.FloatPane.FloatWindow.ResizeBegin += Connection_ResizeBegin; @@ -212,8 +211,8 @@ namespace mRemoteNG.UI.Window DockHandler.FloatPane.FloatWindow.ResizeEnd -= Connection_ResizeEnd; _floatHandlersAdded = false; } - _frmMain.ResizeBegin += Connection_ResizeBegin; - _frmMain.ResizeEnd += Connection_ResizeEnd; + FrmMain.Default.ResizeBegin += Connection_ResizeBegin; + FrmMain.Default.ResizeEnd += Connection_ResizeEnd; _documentHandlersAdded = true; } } @@ -240,7 +239,7 @@ namespace mRemoteNG.UI.Window private void Connection_FormClosing(object sender, FormClosingEventArgs e) { - if (!_frmMain.IsClosing && + if (!FrmMain.Default.IsClosing && (Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.All & TabController.TabPages.Count > 0 || Settings.Default.ConfirmCloseConnection == (int)ConfirmCloseEnum.Multiple & TabController.TabPages.Count > 1)) { @@ -783,7 +782,7 @@ namespace mRemoteNG.UI.Window { try { - if (!(NativeMethods.GetForegroundWindow() == _frmMain.Handle) && !_ignoreChangeSelectedTabClick) + if (!(NativeMethods.GetForegroundWindow() == FrmMain.Default.Handle) && !_ignoreChangeSelectedTabClick) { var clickedTab = TabController.TabPageFromPoint(e.Location); if (clickedTab != null && TabController.SelectedTab != clickedTab)