Merge branch 'develop' into MR-225_Can_not_import_RDCMan_v2.7

This commit is contained in:
David Sparer
2017-11-08 11:58:34 -06:00
committed by GitHub
18 changed files with 252 additions and 112 deletions

View File

@@ -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:

View File

@@ -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> {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);
}
}
}

View File

@@ -141,6 +141,7 @@
<Compile Include="Config\Settings\DockPanelSerializerTests.cs" />
<Compile Include="Connection\AbstractConnectionInfoDataTests.cs" />
<Compile Include="Connection\ConnectionInfoComparerTests.cs" />
<Compile Include="Connection\Protocol\IntegratedProgramTests.cs" />
<Compile Include="Connection\Protocol\ProtocolListTests.cs" />
<Compile Include="Credential\CompositeRepositoryUnlockerTests.cs" />
<Compile Include="Credential\CredentialChangedEventArgsTests.cs" />
@@ -317,4 +318,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -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()

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -61,6 +61,15 @@ namespace mRemoteNG
}
/// <summary>
/// Looks up a localized string similar to Could not find external tool with name &quot;{0}&quot;.
/// </summary>
internal static string CouldNotFindExternalTool {
get {
return ResourceManager.GetString("CouldNotFindExternalTool", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Credentials.
/// </summary>
internal static string Credentials {

View File

@@ -2592,4 +2592,7 @@ This page will walk you through the process of upgrading your connections file o
<data name="strOptionsThemeErrorNoThemes" xml:space="preserve">
<value>No themes are loaded, check that the default mremoteNG themes exist in the slash themes folder</value>
</data>
<data name="CouldNotFindExternalTool" xml:space="preserve">
<value>Could not find external tool with name "{0}"</value>
</data>
</root>

View File

@@ -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
{

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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();
}
/// <summary>
/// Resizes the given column to ensure that all content is shown
/// </summary>
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
}
}

View File

@@ -11,6 +11,7 @@ namespace mRemoteNG.UI.Controls
FillsFreeSpace = false;
AspectGetter = item => ((ConnectionInfo) item).Name;
ImageGetter = imageGetterDelegate;
AutoCompleteEditor = false;
}
}
}

View File

@@ -153,6 +153,9 @@ namespace mRemoteNG.UI.Forms
Runtime.WindowList = new WindowList();
if (Settings.Default.ResetPanels)
SetDefaultLayout();
var credsAndConsSetup = new CredsAndConsSetup();
credsAndConsSetup.LoadCredsAndCons();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)