completed first round of fixes

This commit is contained in:
David Sparer
2018-03-02 13:40:24 -06:00
parent 8dc3303e0f
commit 13f51629af
25 changed files with 283 additions and 248 deletions

View File

@@ -1,8 +1,10 @@
using mRemoteNG.App;
using System.Threading;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.Tools;
using mRemoteNG.Tools.CustomCollections;
using mRemoteNG.UI.Controls;
using mRemoteNG.UI.Window;
using NSubstitute;
using NUnit.Framework;
@@ -10,7 +12,7 @@ using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNGTests.Connection.Protocol
{
public class IntegratedProgramTests
public class IntegratedProgramTests
{
private ExternalTool _extTool;
private IConnectionInitiator _connectionInitiator;
@@ -29,6 +31,7 @@ namespace mRemoteNGTests.Connection.Protocol
}
[Test]
[Apartment(ApartmentState.STA)]
public void CanStartExternalApp()
{
SetExternalToolList(_extTool);
@@ -41,6 +44,7 @@ namespace mRemoteNGTests.Connection.Protocol
}
[Test]
[Apartment(ApartmentState.STA)]
public void ConnectingToExternalAppThatDoesntExistDoesNothing()
{
SetExternalToolList(_extTool);
@@ -57,7 +61,16 @@ namespace mRemoteNGTests.Connection.Protocol
private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut)
{
var connectionWindow = new ConnectionWindow(new DockContent(), _connectionInitiator);
var configWindow = new ConfigWindow(new DockContent());
var sshTransferWindow = new SSHTransferWindow();
var connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), _connectionInitiator);
var connectionTree = connectionTreeWindow.ConnectionTree;
var connectionTreeContextMenu = new ConnectionContextMenu(connectionTree, _connectionInitiator, sshTransferWindow);
connectionTreeWindow.ConnectionTreeContextMenu = connectionTreeContextMenu;
var errorAndInfoWindow = new ErrorAndInfoWindow(new DockContent(), connectionTreeWindow);
var screenshotManagerWindow = new ScreenshotManagerWindow(new DockContent());
var windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow, sshTransferWindow);
var connectionWindow = new ConnectionWindow(new DockContent(), _connectionInitiator, windows);
var connectionInfo = new ConnectionInfo {ExtApp = extAppName};
return new InterfaceControl(connectionWindow, sut, connectionInfo);
}

View File

@@ -1,9 +1,11 @@
using NUnit.Framework;
using mRemoteNG.Connection;
using mRemoteNG.UI.Forms;
using NSubstitute;
using NUnit.Framework;
namespace mRemoteNGTests.UI.Forms
{
public class OptionsFormSetupAndTeardown
public class OptionsFormSetupAndTeardown
{
protected frmOptions _optionsForm;
@@ -15,7 +17,8 @@ namespace mRemoteNGTests.UI.Forms
[SetUp]
public void Setup()
{
_optionsForm = new frmOptions();
var connectionInitiator = Substitute.For<IConnectionInitiator>();
_optionsForm = new frmOptions(connectionInitiator, type => {});
_optionsForm.Show();
}

View File

@@ -1,19 +1,25 @@
using System.Threading;
using mRemoteNG.Connection;
using mRemoteNG.UI.Controls;
using mRemoteNG.UI.Window;
using NSubstitute;
using NUnit.Framework;
using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNGTests.UI.Window
{
public class ConnectionTreeWindowTests
public class ConnectionTreeWindowTests
{
private ConnectionTreeWindow _connectionTreeWindow;
[SetUp]
public void Setup()
{
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent());
var connectionInitiator = Substitute.For<IConnectionInitiator>();
var connectionTree = new ConnectionTree();
var sshTransferWindow = new SSHTransferWindow();
var connectionContextMenu = new ConnectionContextMenu(connectionTree, connectionInitiator, sshTransferWindow);
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), connectionInitiator) {ConnectionTreeContextMenu = connectionContextMenu};
}
[TearDown]

View File

@@ -3,10 +3,12 @@ using System.Linq;
using mRemoteNG.Messages;
using mRemoteNG.Messages.MessageWriters;
using mRemoteNG.Messages.WriterDecorators;
using mRemoteNG.Tools;
using mRemoteNG.UI.Window;
namespace mRemoteNG.App.Initialization
{
public class MessageCollectorSetup
public class MessageCollectorSetup
{
public static void SetupMessageCollector(MessageCollector messageCollector, IList<IMessageWriter> messageWriterList)
{
@@ -19,13 +21,13 @@ namespace mRemoteNG.App.Initialization
};
}
public static void BuildMessageWritersFromSettings(IList<IMessageWriter> messageWriterList)
public static void BuildMessageWritersFromSettings(IList<IMessageWriter> messageWriterList, ErrorAndInfoWindow errorAndInfoWindow)
{
#if DEBUG
messageWriterList.Add(BuildDebugConsoleWriter());
#endif
messageWriterList.Add(BuildTextLogMessageWriter());
messageWriterList.Add(BuildNotificationPanelMessageWriter());
messageWriterList.Add(BuildNotificationPanelMessageWriter(errorAndInfoWindow));
messageWriterList.Add(BuildPopupMessageWriter());
}
@@ -42,16 +44,16 @@ namespace mRemoteNG.App.Initialization
);
}
private static IMessageWriter BuildNotificationPanelMessageWriter()
private static IMessageWriter BuildNotificationPanelMessageWriter(ErrorAndInfoWindow errorAndInfoWindow)
{
return new OnlyLogMessageFilter(
errorAndInfoWindow.ThrowIfNull(nameof(errorAndInfoWindow));
return new OnlyLogMessageFilter(
new MessageTypeFilterDecorator(
new NotificationPanelMessageFilteringOptions(),
new MessageFocusDecorator(
Windows.ErrorsForm,
errorAndInfoWindow,
new NotificationPanelSwitchOnMessageFilteringOptions(),
new NotificationPanelMessageWriter(Windows.ErrorsForm)
new NotificationPanelMessageWriter(errorAndInfoWindow)
)
)
);

View File

@@ -17,24 +17,21 @@ using mRemoteNG.UI.Forms;
namespace mRemoteNG.App
{
public class Startup
public class Startup
{
private AppUpdater _appUpdate;
private readonly ConnectionIconLoader _connectionIconLoader;
private readonly FrmMain _frmMain = FrmMain.Default;
private readonly FrmMain _frmMain;
private readonly Windows _windows;
public static Startup Instance { get; } = new Startup();
private Startup()
public Startup(FrmMain frmMain, Windows windows)
{
_appUpdate = new AppUpdater();
_frmMain = frmMain.ThrowIfNull(nameof(frmMain));
_windows = windows.ThrowIfNull(nameof(windows));
_appUpdate = new AppUpdater();
_connectionIconLoader = new ConnectionIconLoader(GeneralAppInfo.HomePath + "\\Icons\\");
}
static Startup()
{
}
public void InitializeProgram(MessageCollector messageCollector)
{
Debug.Print("---------------------------" + Environment.NewLine + "[START] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
@@ -107,7 +104,7 @@ namespace mRemoteNG.App
if (_appUpdate.IsUpdateAvailable())
{
Windows.Show(WindowType.Update);
_windows.Show(WindowType.Update);
}
}
catch (Exception ex)

View File

@@ -1,14 +1,14 @@
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Window;
using System;
using System;
using mRemoteNG.Connection;
using mRemoteNG.Messages;
using mRemoteNG.Tools;
using mRemoteNG.UI;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Window;
namespace mRemoteNG.App
{
public class Windows
public class Windows
{
private readonly IConnectionInitiator _connectionInitiator;
private AboutWindow _aboutForm;
@@ -62,7 +62,7 @@ namespace mRemoteNG.App
_adimportForm.Show(dockPanel);
break;
case WindowType.Options:
using (var optionsForm = new frmOptions(_connectionInitiator))
using (var optionsForm = new frmOptions(_connectionInitiator, Show))
{
optionsForm.ShowDialog(dockPanel);
}
@@ -93,7 +93,7 @@ namespace mRemoteNG.App
break;
case WindowType.UltraVNCSC:
if (_ultravncscForm == null || _ultravncscForm.IsDisposed)
_ultravncscForm = new UltraVNCWindow();
_ultravncscForm = new UltraVNCWindow(Show);
_ultravncscForm.Show(dockPanel);
break;
case WindowType.ComponentsCheck:

View File

@@ -9,12 +9,14 @@ using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Window;
// ReSharper disable UnusedParameter.Local
namespace mRemoteNG.UI.Controls
{
public sealed class ConnectionContextMenu : ContextMenuStrip
public sealed class ConnectionContextMenu : ContextMenuStrip
{
private ToolStripMenuItem _cMenTreeAddConnection;
private ToolStripMenuItem _cMenTreeAddFolder;
@@ -48,15 +50,19 @@ namespace mRemoteNG.UI.Controls
private ToolStripMenuItem _cMenTreeImportPortScan;
private readonly ConnectionTree _connectionTree;
private readonly IConnectionInitiator _connectionInitiator;
private readonly Windows _windows;
private readonly SSHTransferWindow _sshTransferWindow;
public ConnectionContextMenu(ConnectionTree connectionTree, IConnectionInitiator connectionInitiator, Windows windows)
// TODO - this is only a property to break up a circular dependency
public Action<WindowType> ShowWindowAction { get; set; } = type => { };
public ConnectionContextMenu(ConnectionTree connectionTree, IConnectionInitiator connectionInitiator, SSHTransferWindow sshTransferWindow)
{
_connectionTree = connectionTree;
_windows = windows.ThrowIfNull(nameof(windows));
_connectionTree = connectionTree.ThrowIfNull(nameof(connectionTree));
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
_sshTransferWindow = sshTransferWindow.ThrowIfNull(nameof(sshTransferWindow));
InitializeComponent();
ApplyLanguage();
ApplyLanguage();
EnableShortcutKeys();
Opening += (sender, args) =>
{
@@ -694,11 +700,11 @@ namespace mRemoteNG.UI.Controls
{
try
{
_windows.Show(WindowType.SSHTransfer);
_windows.SshtransferForm.Hostname = _connectionTree.SelectedNode.Hostname;
_windows.SshtransferForm.Username = _connectionTree.SelectedNode.Username;
_windows.SshtransferForm.Password = _connectionTree.SelectedNode.Password;
_windows.SshtransferForm.Port = Convert.ToString(_connectionTree.SelectedNode.Port);
ShowWindowAction(WindowType.SSHTransfer);
_sshTransferWindow.Hostname = _connectionTree.SelectedNode.Hostname;
_sshTransferWindow.Username = _connectionTree.SelectedNode.Username;
_sshTransferWindow.Password = _connectionTree.SelectedNode.Password;
_sshTransferWindow.Port = Convert.ToString(_connectionTree.SelectedNode.Port);
}
catch (Exception ex)
{
@@ -733,12 +739,12 @@ namespace mRemoteNG.UI.Controls
private void OnImportActiveDirectoryClicked(object sender, EventArgs e)
{
_windows.Show(WindowType.ActiveDirectoryImport);
ShowWindowAction(WindowType.ActiveDirectoryImport);
}
private void OnImportPortScanClicked(object sender, EventArgs e)
{
_windows.Show(WindowType.PortScan);
ShowWindowAction(WindowType.PortScan);
}
private void OnExportFileClicked(object sender, EventArgs e)

View File

@@ -9,10 +9,8 @@ using mRemoteNG.App;
using mRemoteNG.Config.Putty;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.Tree.Root;
using mRemoteNG.UI.Window;
// ReSharper disable ArrangeAccessorOwnerBody
@@ -26,10 +24,8 @@ namespace mRemoteNG.UI.Controls
private bool _nodeInEditMode;
private bool _allowEdit;
private ConnectionTreeModel _connectionTreeModel;
private ConfigWindow _configWindow;
private readonly IConnectionInitiator _connectionInitiator;
public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject;
public ConnectionInfo SelectedNode => (ConnectionInfo) SelectedObject;
public NodeSearcher NodeSearcher { get; private set; }
@@ -52,15 +48,8 @@ namespace mRemoteNG.UI.Controls
}
}
[Obsolete("This constructor is here to make the designer work. Dont use this constructor.")]
public ConnectionTree() : this(new ConnectionInitiator(new WindowList(), new Runtime()), new ConfigWindow())
public ConnectionTree()
{
}
public ConnectionTree(IConnectionInitiator connectionInitiator, ConfigWindow configWindow)
{
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
_configWindow = configWindow.ThrowIfNull(nameof(configWindow));
InitializeComponent();
SetupConnectionTreeView();
UseOverlays = false;
@@ -128,8 +117,9 @@ namespace mRemoteNG.UI.Controls
container.IsExpanded = true;
AutoResizeColumn(Columns[0]);
};
SelectionChanged += tvConnections_AfterSelect;
MouseDoubleClick += OnMouse_DoubleClick;
SelectionChanged += OnSelectionChanged;
MouseDoubleClick += OnMouse_DoubleClick;
MouseClick += OnMouse_SingleClick;
CellToolTipShowing += tvConnections_CellToolTipShowing;
ModelCanDrop += _dragAndDropHandler.HandleEvent_ModelCanDrop;
@@ -138,7 +128,7 @@ namespace mRemoteNG.UI.Controls
AfterLabelEdit += OnAfterLabelEdit;
}
/// <summary>
/// <summary>
/// Resizes the given column to ensure that all content is shown
/// </summary>
private void AutoResizeColumn(ColumnHeader column)
@@ -324,18 +314,6 @@ namespace mRemoteNG.UI.Controls
AutoResizeColumn(Columns[0]);
}
private void tvConnections_AfterSelect(object sender, EventArgs e)
{
try
{
_configWindow.SelectedTreeNode = SelectedNode;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterSelect (UI.Window.ConnectionTreeWindow) failed", ex);
}
}
private void OnMouse_DoubleClick(object sender, MouseEventArgs mouseEventArgs)
{
if (mouseEventArgs.Clicks < 2) return;
@@ -395,13 +373,25 @@ namespace mRemoteNG.UI.Controls
ConnectionTreeModel.RenameNode(SelectedNode, e.Label);
_nodeInEditMode = false;
_allowEdit = false;
_configWindow.SelectedTreeNode = SelectedNode;
RaiseSelectedNodeChangedEvent(SelectedNode);
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterLabelEdit (UI.Window.ConnectionTreeWindow) failed", ex);
}
}
#endregion
private void OnSelectionChanged(object o, EventArgs eventArgs)
{
RaiseSelectedNodeChangedEvent(SelectedNode);
}
#endregion
public event EventHandler<ConnectionInfo> SelectedNodeChanged;
private void RaiseSelectedNodeChangedEvent(ConnectionInfo selectedNode)
{
SelectedNodeChanged?.Invoke(this, selectedNode);
}
}
}

View File

@@ -9,16 +9,15 @@ using mRemoteNG.Tree;
namespace mRemoteNG.UI.Controls
{
public class ExternalToolsToolStrip : ToolStrip
public class ExternalToolsToolStrip : ToolStrip
{
private IContainer components;
private ContextMenuStrip _cMenExtAppsToolbar;
private readonly Func<ConnectionInfo> _getSelectedConnectionFunc;
internal ToolStripMenuItem CMenToolbarShowText;
public Func<ConnectionInfo> GetSelectedConnectionFunc { get; set; }
internal ToolStripMenuItem CMenToolbarShowText;
public ExternalToolsToolStrip(Func<ConnectionInfo> getSelectedConnectionFunc)
public ExternalToolsToolStrip()
{
_getSelectedConnectionFunc = getSelectedConnectionFunc;
Initialize();
Runtime.ExternalToolsService.ExternalTools.CollectionUpdated += (sender, args) => AddExternalToolsToToolBar();
}
@@ -100,7 +99,7 @@ namespace mRemoteNG.UI.Controls
{
var extA = (ExternalTool)((ToolStripButton)sender).Tag;
var selectedTreeNode = _getSelectedConnectionFunc();
var selectedTreeNode = GetSelectedConnectionFunc();
if (selectedTreeNode != null && selectedTreeNode.GetTreeNodeType() == TreeNodeType.Connection |
selectedTreeNode.GetTreeNodeType() == TreeNodeType.PuttySession)
extA.Start(selectedTreeNode);

View File

@@ -10,7 +10,7 @@ using mRemoteNG.Tools;
namespace mRemoteNG.UI.Controls
{
public class QuickConnectToolStrip : ToolStrip
public class QuickConnectToolStrip : ToolStrip
{
private IContainer components;
private ToolStripLabel _lblQuickConnect;
@@ -19,13 +19,13 @@ namespace mRemoteNG.UI.Controls
private ContextMenuStrip _mnuQuickConnectProtocol;
private QuickConnectComboBox _cmbQuickConnect;
private ContextMenuStrip _mnuConnections;
private IConnectionInitiator _connectionInitiator;
private readonly ThemeManager _themeManager;
private readonly ThemeManager _themeManager;
private WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender vsToolStripExtender;
public QuickConnectToolStrip(IConnectionInitiator connectionInitiator)
public IConnectionInitiator ConnectionInitiator { get; set; }
public QuickConnectToolStrip()
{
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
Initialize();
_themeManager = ThemeManager.getInstance();
_themeManager.ThemeChanged += ApplyTheme;
@@ -174,7 +174,7 @@ namespace mRemoteNG.UI.Controls
return;
}
_cmbQuickConnect.Add(connectionInfo);
_connectionInitiator.OpenConnection(connectionInfo, ConnectionInfo.Force.DoNotJump);
ConnectionInitiator.OpenConnection(connectionInfo, ConnectionInfo.Force.DoNotJump);
}
catch (Exception ex)
{
@@ -225,7 +225,7 @@ namespace mRemoteNG.UI.Controls
var tag = ((ToolStripMenuItem)sender).Tag as ConnectionInfo;
if (tag != null)
{
_connectionInitiator.OpenConnection(tag);
ConnectionInitiator.OpenConnection(tag);
}
}
#endregion

View File

@@ -10,17 +10,15 @@ using mRemoteNG.UI.TaskDialog;
namespace mRemoteNG.UI.Forms.OptionsPages
{
public partial class UpdatesPage
public partial class UpdatesPage
{
#region Private Fields
private AppUpdater _appUpdate;
private readonly Action<WindowType> _showWindowAction;
#endregion
public UpdatesPage()
public UpdatesPage(Action<WindowType> showWindowAction)
{
InitializeComponent();
_showWindowAction = showWindowAction.ThrowIfNull(nameof(showWindowAction));
InitializeComponent();
base.ApplyTheme();
}
@@ -164,7 +162,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
private void btnUpdateCheckNow_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.Update);
_showWindowAction(WindowType.Update);
}
private void chkUseProxyForAutomaticUpdates_CheckedChanged(object sender, EventArgs e)

View File

@@ -38,12 +38,12 @@ namespace mRemoteNG.UI.Forms
this.tmrAutoSave = new System.Windows.Forms.Timer(this.components);
this.vsToolStripExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this._multiSshToolStrip = new mRemoteNG.UI.Controls.MultiSshToolStrip();
this._externalToolsToolStrip = new mRemoteNG.UI.Controls.ExternalToolsToolStrip(() => SelectedConnection);
this._quickConnectToolStrip = new mRemoteNG.UI.Controls.QuickConnectToolStrip(_connectionInitiator);
this.mainFileMenu1 = new mRemoteNG.UI.Menu.MainFileMenu(_windowList, _windows);
this.viewMenu1 = new mRemoteNG.UI.Menu.ViewMenu(_panelAdder, _windowList, _windows);
this._externalToolsToolStrip = new mRemoteNG.UI.Controls.ExternalToolsToolStrip();
this._quickConnectToolStrip = new mRemoteNG.UI.Controls.QuickConnectToolStrip();
this.mainFileMenu1 = new mRemoteNG.UI.Menu.MainFileMenu();
this.viewMenu1 = new mRemoteNG.UI.Menu.ViewMenu();
this.toolsMenu1 = new mRemoteNG.UI.Menu.ToolsMenu();
this.helpMenu1 = new mRemoteNG.UI.Menu.HelpMenu(_webHelper, _windows);
this.helpMenu1 = new mRemoteNG.UI.Menu.HelpMenu();
this.msMain.SuspendLayout();
this.tsContainer.ContentPanel.SuspendLayout();
this.tsContainer.TopToolStripPanel.SuspendLayout();

View File

@@ -21,6 +21,7 @@ using mRemoteNG.Messages;
using mRemoteNG.Messages.MessageWriters;
using mRemoteNG.Themes;
using mRemoteNG.Tools;
using mRemoteNG.UI.Controls;
using mRemoteNG.UI.Menu;
using mRemoteNG.UI.Panels;
using mRemoteNG.UI.TaskDialog;
@@ -52,6 +53,7 @@ namespace mRemoteNG.UI.Forms
private readonly WebHelper _webHelper;
private readonly WindowList _windowList;
private readonly Windows _windows;
private readonly Startup _startup;
internal FullscreenHandler Fullscreen { get; set; }
@@ -61,21 +63,32 @@ namespace mRemoteNG.UI.Forms
private FrmMain()
{
_runtime = new Runtime();
_connectionInitiator = new ConnectionInitiator(_runtime.WindowList, _runtime);
_windowList = new WindowList();
_connectionInitiator = new ConnectionInitiator(_windowList, _runtime);
_webHelper = new WebHelper(_connectionInitiator);
var connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), _connectionInitiator);
var configWindow = new ConfigWindow(new DockContent());
var errorAndInfoWindow = new ErrorAndInfoWindow(new DockContent(), connectionTreeWindow);
var screenshotManagerWindow = new ScreenshotManagerWindow(new DockContent());
var sshTransferWindow = new SSHTransferWindow();
var connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), _connectionInitiator);
var connectionTree = connectionTreeWindow.ConnectionTree;
connectionTree.SelectedNodeChanged += configWindow.HandleConnectionTreeSelectionChanged;
var connectionTreeContextMenu = new ConnectionContextMenu(connectionTree, _connectionInitiator, sshTransferWindow);
connectionTree.ConnectionContextMenu = connectionTreeContextMenu;
connectionTreeWindow.ConnectionTreeContextMenu = connectionTreeContextMenu;
var errorAndInfoWindow = new ErrorAndInfoWindow(new DockContent(), connectionTreeWindow);
var screenshotManagerWindow = new ScreenshotManagerWindow();
_windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow, sshTransferWindow);
_panelAdder = new PanelAdder(_windowList, _connectionInitiator);
_panelAdder = new PanelAdder(_windowList, _connectionInitiator, _windows);
_showFullPathInTitle = Settings.Default.ShowCompleteConsPathInTitle;
_connectionInitiator.Adder = _panelAdder;
_startup = new Startup(this, _windows);
connectionTreeContextMenu.ShowWindowAction = _windows.Show;
InitializeComponent();
Fullscreen = new FullscreenHandler(this);
InitializeComponent();
_externalToolsToolStrip.GetSelectedConnectionFunc = () => SelectedConnection;
_quickConnectToolStrip.ConnectionInitiator = _connectionInitiator;
Fullscreen = new FullscreenHandler(this);
//Theming support
_themeManager = ThemeManager.getInstance();
@@ -156,9 +169,9 @@ namespace mRemoteNG.UI.Forms
{
var messageCollector = Runtime.MessageCollector;
MessageCollectorSetup.SetupMessageCollector(messageCollector, _messageWriters);
MessageCollectorSetup.BuildMessageWritersFromSettings(_messageWriters);
MessageCollectorSetup.BuildMessageWritersFromSettings(_messageWriters, _windows.ErrorsForm);
Startup.Instance.InitializeProgram(messageCollector);
_startup.InitializeProgram(messageCollector);
SetMenuDependencies();
@@ -191,7 +204,7 @@ namespace mRemoteNG.UI.Forms
if (Settings.Default.StartupComponentsCheck)
_windows.Show(WindowType.ComponentsCheck);
Startup.Instance.CreateConnectionsProvider(messageCollector);
_startup.CreateConnectionsProvider(messageCollector);
_screenSystemMenu.BuildScreenList();
SystemEvents.DisplaySettingsChanged += _screenSystemMenu.OnDisplayChanged;
@@ -229,15 +242,24 @@ namespace mRemoteNG.UI.Forms
{
mainFileMenu1.TreeWindow = _windows.TreeForm;
mainFileMenu1.ConnectionInitiator = _connectionInitiator;
mainFileMenu1.WindowList = _windowList;
mainFileMenu1.Windows = _windows;
viewMenu1.TsExternalTools = _externalToolsToolStrip;
viewMenu1.TsQuickConnect = _quickConnectToolStrip;
viewMenu1.TsMultiSsh = _multiSshToolStrip;
viewMenu1.FullscreenHandler = Fullscreen;
viewMenu1.MainForm = this;
viewMenu1.Adder = _panelAdder;
viewMenu1.WindowList = _windowList;
viewMenu1.Windows = _windows;
viewMenu1.MainForm = this;
toolsMenu1.MainForm = this;
toolsMenu1.CredentialProviderCatalog = Runtime.CredentialProviderCatalog;
toolsMenu1.Windows = _windows;
helpMenu1.WebHelper = _webHelper;
helpMenu1.Windows = _windows;
}
//Theming support
@@ -246,10 +268,11 @@ namespace mRemoteNG.UI.Forms
if (_themeManager.ThemingActive)
{
// Persist settings when rebuilding UI
this.pnlDock.Theme = _themeManager.ActiveTheme.Theme;
pnlDock.Theme = _themeManager.ActiveTheme.Theme;
ApplyTheme();
}
}
private void ApplyTheme()
{
if(_themeManager.ThemingActive)
@@ -288,7 +311,7 @@ namespace mRemoteNG.UI.Forms
if (CTaskDialog.CommandButtonResult != 1) return;
using (var optionsForm = new frmOptions(_connectionInitiator, Language.strTabUpdates))
using (var optionsForm = new frmOptions(_connectionInitiator, _windows.Show, Language.strTabUpdates))
{
optionsForm.ShowDialog(this);
}
@@ -305,7 +328,7 @@ namespace mRemoteNG.UI.Forms
if (!Settings.Default.UpdatePending && DateTime.UtcNow <= nextUpdateCheck) return;
if (!IsHandleCreated) CreateHandle(); // Make sure the handle is created so that InvokeRequired returns the correct result
Startup.Instance.CheckForUpdate();
_startup.CheckForUpdate();
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)

View File

@@ -1,31 +1,34 @@
using mRemoteNG.UI.Forms.OptionsPages;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using mRemoteNG.Connection;
using mRemoteNG.Tools;
using mRemoteNG.UI.Forms.OptionsPages;
namespace mRemoteNG.UI.Forms
{
public partial class frmOptions : Form
public partial class frmOptions : Form
{
private Dictionary<string, OptionsPage> _pages;
private ImageList _pageIconImageList;
private readonly string _pageName;
private readonly IConnectionInitiator _connectionInitiator;
private readonly Action<WindowType> _showWindowAction;
public frmOptions(IConnectionInitiator connectionInitiator)
: this(connectionInitiator, Language.strStartupExit)
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction)
: this(connectionInitiator, showWindowAction, Language.strStartupExit)
{
}
public frmOptions(IConnectionInitiator connectionInitiator, string pn)
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction, string pageName)
{
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
_pageName = pn;
InitializeComponent();
_pageName = pageName.ThrowIfNull(nameof(pageName));
_showWindowAction = showWindowAction.ThrowIfNull(nameof(showWindowAction));
InitializeComponent();
}
private void frmOptions_Load(object sender, EventArgs e)
@@ -41,6 +44,7 @@ namespace mRemoteNG.UI.Forms
lstOptionPages.SelectedIndexChanged += LstOptionPages_SelectedIndexChanged;
lstOptionPages.SelectedIndex = 0;
}
private void ApplyTheme()
{
if(Themes.ThemeManager.getInstance().ThemingActive)
@@ -69,7 +73,7 @@ namespace mRemoteNG.UI.Forms
{typeof(ConnectionsPage).Name, new ConnectionsPage()},
{typeof(CredentialsPage).Name, new CredentialsPage()},
{typeof(SqlServerPage).Name, new SqlServerPage()},
{typeof(UpdatesPage).Name, new UpdatesPage()},
{typeof(UpdatesPage).Name, new UpdatesPage(_showWindowAction)},
{typeof(ThemePage).Name, new ThemePage()},
{typeof(SecurityPage).Name, new SecurityPage()},
{typeof(AdvancedPage).Name, new AdvancedPage()}

View File

@@ -3,11 +3,10 @@ using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.App.Info;
using mRemoteNG.Connection;
using mRemoteNG.Tools;
namespace mRemoteNG.UI.Menu
{
public class HelpMenu : ToolStripMenuItem
public class HelpMenu : ToolStripMenuItem
{
private ToolStripMenuItem _mMenInfoHelp;
private ToolStripMenuItem _mMenInfoWebsite;
@@ -19,13 +18,12 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenInfoBugReport;
private ToolStripSeparator _toolStripSeparator2;
private ToolStripMenuItem _mMenInfoForum;
private readonly Windows _windows;
private readonly WebHelper _webHelper;
public HelpMenu(WebHelper webHelper, Windows windows)
public Windows Windows { get; set; }
public WebHelper WebHelper { get; set; }
public HelpMenu()
{
_windows = windows.ThrowIfNull(nameof(windows));
_webHelper = webHelper.ThrowIfNull(nameof(webHelper));
Initialize();
}
@@ -137,36 +135,36 @@ namespace mRemoteNG.UI.Menu
#region Info
private void mMenToolsUpdate_Click(object sender, EventArgs e)
{
_windows.Show(WindowType.Update);
Windows.Show(WindowType.Update);
}
private void mMenInfoHelp_Click(object sender, EventArgs e)
{
_windows.Show(WindowType.Help);
Windows.Show(WindowType.Help);
}
private void mMenInfoForum_Click(object sender, EventArgs e)
{
_webHelper.GoToUrl(GeneralAppInfo.UrlForum);
WebHelper.GoToUrl(GeneralAppInfo.UrlForum);
}
private void mMenInfoBugReport_Click(object sender, EventArgs e)
{
_webHelper.GoToUrl(GeneralAppInfo.UrlBugs);
WebHelper.GoToUrl(GeneralAppInfo.UrlBugs);
}
private void mMenInfoWebsite_Click(object sender, EventArgs e)
{
_webHelper.GoToUrl(GeneralAppInfo.UrlHome);
WebHelper.GoToUrl(GeneralAppInfo.UrlHome);
}
private void mMenInfoDonate_Click(object sender, EventArgs e)
{
_webHelper.GoToUrl(GeneralAppInfo.UrlDonate);
WebHelper.GoToUrl(GeneralAppInfo.UrlDonate);
}
private void mMenInfoAbout_Click(object sender, EventArgs e)
{
_windows.Show(WindowType.About);
Windows.Show(WindowType.About);
}
#endregion
}

View File

@@ -7,14 +7,13 @@ using mRemoteNG.App.Info;
using mRemoteNG.Connection;
using mRemoteNG.Container;
using mRemoteNG.Security;
using mRemoteNG.Tools;
using mRemoteNG.Tree;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Window;
namespace mRemoteNG.UI.Menu
{
public class MainFileMenu : ToolStripMenuItem
public class MainFileMenu : ToolStripMenuItem
{
private ToolStripMenuItem _mMenFileNew;
private ToolStripMenuItem _mMenFileLoad;
@@ -37,16 +36,14 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenFileImportFromPortScan;
private ToolStripMenuItem _mMenFileImport;
private ToolStripMenuItem _mMenReconnectAll;
private readonly WindowList _windowList;
private readonly Windows _windows;
public ConnectionTreeWindow TreeWindow { get; set; }
public WindowList WindowList { get; set; }
public Windows Windows { get; set; }
public ConnectionTreeWindow TreeWindow { get; set; }
public IConnectionInitiator ConnectionInitiator { get; set; }
public MainFileMenu(WindowList windowList, Windows windows)
public MainFileMenu()
{
_windows = windows.ThrowIfNull(nameof(windows));
_windowList = windowList.ThrowIfNull(nameof(windowList));
Initialize();
}
@@ -422,9 +419,9 @@ namespace mRemoteNG.UI.Menu
private void mMenReconnectAll_Click(object sender, EventArgs e)
{
if (_windowList.Count == 0)
if (WindowList.Count == 0)
return;
foreach (BaseWindow window in _windowList)
foreach (BaseWindow window in WindowList)
{
var connectionWindow = window as ConnectionWindow;
if (connectionWindow == null)
@@ -465,17 +462,17 @@ namespace mRemoteNG.UI.Menu
private void mMenFileImportFromActiveDirectory_Click(object sender, EventArgs e)
{
_windows.Show(WindowType.ActiveDirectoryImport);
Windows.Show(WindowType.ActiveDirectoryImport);
}
private void mMenFileImportFromPortScan_Click(object sender, EventArgs e)
{
_windows.Show(WindowType.PortScan);
Windows.Show(WindowType.PortScan);
}
private void mMenFileExport_Click(object sender, EventArgs e)
{
Export.ExportToFile(_windows.TreeForm.SelectedNode, Runtime.ConnectionsService.ConnectionTreeModel);
Export.ExportToFile(Windows.TreeForm.SelectedNode, Runtime.ConnectionsService.ConnectionTreeModel);
}
private void mMenFileExit_Click(object sender, EventArgs e)

View File

@@ -15,12 +15,13 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenToolsUvncsc;
private ToolStripMenuItem _mMenToolsComponentsCheck;
public Form MainForm { get; set; }
public Windows Windows { get; set; }
public Form MainForm { get; set; }
public ICredentialRepositoryList CredentialProviderCatalog { get; set; }
public ToolsMenu()
{
Initialize();
Initialize();
}
private void Initialize()
@@ -106,32 +107,32 @@ namespace mRemoteNG.UI.Menu
#region Tools
private void mMenToolsSSHTransfer_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.SSHTransfer);
Windows.Show(WindowType.SSHTransfer);
}
private void mMenToolsUVNCSC_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.UltraVNCSC);
Windows.Show(WindowType.UltraVNCSC);
}
private void mMenToolsExternalApps_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.ExternalApps);
Windows.Show(WindowType.ExternalApps);
}
private void mMenToolsPortScan_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.PortScan);
Windows.Show(WindowType.PortScan);
}
private void mMenToolsComponentsCheck_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.ComponentsCheck);
Windows.Show(WindowType.ComponentsCheck);
}
private void mMenToolsOptions_Click(object sender, EventArgs e)
{
Windows.Show(WindowType.Options);
Windows.Show(WindowType.Options);
}
#endregion
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Tools;
using mRemoteNG.UI.Forms;
using mRemoteNG.UI.Panels;
using mRemoteNG.UI.Window;
@@ -29,23 +28,19 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenViewResetLayout;
private ToolStripMenuItem _mMenViewLockToolbars;
private ToolStripSeparator _toolStripSeparator1;
private readonly PanelAdder _panelAdder;
private readonly WindowList _windowList;
private readonly Windows _windows;
public ToolStrip TsExternalTools { get; set; }
public PanelAdder Adder { get; set; }
public WindowList WindowList { get; set; }
public Windows Windows { get; set; }
public ToolStrip TsExternalTools { get; set; }
public ToolStrip TsQuickConnect { get; set; }
public ToolStrip TsMultiSsh { get; set; }
public FullscreenHandler FullscreenHandler { get; set; }
public FrmMain MainForm { get; set; }
public ViewMenu(PanelAdder panelAdder, WindowList windowList, Windows windows)
public ViewMenu()
{
_windowList = windowList.ThrowIfNull(nameof(windowList));
_windows = windows.ThrowIfNull(nameof(windows));
_panelAdder = panelAdder.ThrowIfNull(nameof(panelAdder));
Initialize();
ApplyLanguage();
}
@@ -274,10 +269,10 @@ namespace mRemoteNG.UI.Menu
#region View
internal void mMenView_DropDownOpening(object sender, EventArgs e)
{
_mMenViewConnections.Checked = !_windows.TreeForm.IsHidden;
_mMenViewConfig.Checked = !_windows.ConfigForm.IsHidden;
_mMenViewErrorsAndInfos.Checked = !_windows.ErrorsForm.IsHidden;
_mMenViewScreenshotManager.Checked = !_windows.ScreenshotForm.IsHidden;
_mMenViewConnections.Checked = !Windows.TreeForm.IsHidden;
_mMenViewConfig.Checked = !Windows.ConfigForm.IsHidden;
_mMenViewErrorsAndInfos.Checked = !Windows.ErrorsForm.IsHidden;
_mMenViewScreenshotManager.Checked = !Windows.ScreenshotForm.IsHidden;
_mMenViewLockToolbars.Checked = Settings.Default.LockToolbars;
_mMenViewExtAppsToolbar.Checked = TsExternalTools.Visible;
@@ -286,11 +281,11 @@ namespace mRemoteNG.UI.Menu
_mMenViewConnectionPanels.DropDownItems.Clear();
for (var i = 0; i <= _windowList.Count - 1; i++)
for (var i = 0; i <= WindowList.Count - 1; i++)
{
var tItem = new ToolStripMenuItem(_windowList[i].Text,
_windowList[i].Icon.ToBitmap(), ConnectionPanelMenuItem_Click)
{ Tag = _windowList[i] };
var tItem = new ToolStripMenuItem(WindowList[i].Text,
WindowList[i].Icon.ToBitmap(), ConnectionPanelMenuItem_Click)
{ Tag = WindowList[i] };
_mMenViewConnectionPanels.DropDownItems.Add(tItem);
}
@@ -307,12 +302,12 @@ namespace mRemoteNG.UI.Menu
{
if (_mMenViewConnections.Checked == false)
{
_windows.TreeForm.Show(MainForm.pnlDock);
Windows.TreeForm.Show(MainForm.pnlDock);
_mMenViewConnections.Checked = true;
}
else
{
_windows.TreeForm.Hide();
Windows.TreeForm.Hide();
_mMenViewConnections.Checked = false;
}
}
@@ -321,12 +316,12 @@ namespace mRemoteNG.UI.Menu
{
if (_mMenViewConfig.Checked == false)
{
_windows.ConfigForm.Show(MainForm.pnlDock);
Windows.ConfigForm.Show(MainForm.pnlDock);
_mMenViewConfig.Checked = true;
}
else
{
_windows.ConfigForm.Hide();
Windows.ConfigForm.Hide();
_mMenViewConfig.Checked = false;
}
}
@@ -335,12 +330,12 @@ namespace mRemoteNG.UI.Menu
{
if (_mMenViewErrorsAndInfos.Checked == false)
{
_windows.ErrorsForm.Show(MainForm.pnlDock);
Windows.ErrorsForm.Show(MainForm.pnlDock);
_mMenViewErrorsAndInfos.Checked = true;
}
else
{
_windows.ErrorsForm.Hide();
Windows.ErrorsForm.Hide();
_mMenViewErrorsAndInfos.Checked = false;
}
}
@@ -349,31 +344,31 @@ namespace mRemoteNG.UI.Menu
{
if (_mMenViewScreenshotManager.Checked == false)
{
_windows.ScreenshotForm.Show(MainForm.pnlDock);
Windows.ScreenshotForm.Show(MainForm.pnlDock);
_mMenViewScreenshotManager.Checked = true;
}
else
{
_windows.ScreenshotForm.Hide();
Windows.ScreenshotForm.Hide();
_mMenViewScreenshotManager.Checked = false;
}
}
private void mMenViewJumpToConnectionsConfig_Click(object sender, EventArgs e)
{
if (MainForm.pnlDock.ActiveContent == _windows.TreeForm)
if (MainForm.pnlDock.ActiveContent == Windows.TreeForm)
{
_windows.ConfigForm.Activate();
Windows.ConfigForm.Activate();
}
else
{
_windows.TreeForm.Activate();
Windows.TreeForm.Activate();
}
}
private void mMenViewJumpToErrorsInfos_Click(object sender, EventArgs e)
{
_windows.ErrorsForm.Activate();
Windows.ErrorsForm.Activate();
}
private void mMenViewResetLayout_Click(object sender, EventArgs e)
@@ -402,7 +397,7 @@ namespace mRemoteNG.UI.Menu
private void mMenViewAddConnectionPanel_Click(object sender, EventArgs e)
{
_panelAdder.AddPanel();
Adder.AddPanel();
}
private void mMenViewExtAppsToolbar_Click(object sender, EventArgs e)

View File

@@ -12,22 +12,24 @@ using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNG.UI.Panels
{
public class PanelAdder
public class PanelAdder
{
private readonly WindowList _windowList;
private readonly IConnectionInitiator _connectionInitiator;
private readonly Windows _windows;
public PanelAdder(WindowList windowList, IConnectionInitiator connectionInitiator)
public PanelAdder(WindowList windowList, IConnectionInitiator connectionInitiator, Windows windows)
{
_windowList = windowList.ThrowIfNull(nameof(windowList));
_windowList = windowList.ThrowIfNull(nameof(windowList));
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
_windows = windows.ThrowIfNull(nameof(windows));
}
public Form AddPanel(string title = "", bool noTabber = false)
{
try
{
var connectionForm = new ConnectionWindow(new DockContent(), _connectionInitiator);
var connectionForm = new ConnectionWindow(new DockContent(), _connectionInitiator, _windows);
BuildConnectionWindowContextMenu(connectionForm);
SetConnectionWindowTitle(title, connectionForm);
ShowConnectionWindow(connectionForm);

View File

@@ -267,19 +267,12 @@ namespace mRemoteNG.UI.Window
}
#endregion
#region Constructors
public ConfigWindow() : this(new DockContent())
{
}
public ConfigWindow(DockContent panel)
{
WindowType = WindowType.Config;
DockPnl = panel;
InitializeComponent();
}
#endregion
#region Public Methods
@@ -1670,10 +1663,22 @@ namespace mRemoteNG.UI.Window
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConfigPropertyGridSetHostStatusFailed + Environment.NewLine + ex.Message, true);
}
}
#endregion
#endregion
#region Event Handlers
private void propertyGridContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
#region Event Handlers
public void HandleConnectionTreeSelectionChanged(object sender, ConnectionInfo selectedNode)
{
try
{
SelectedTreeNode = selectedNode;
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace("tvConnections_AfterSelect (UI.Window.ConnectionTreeWindow) failed", ex);
}
}
private void propertyGridContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{

View File

@@ -17,11 +17,15 @@ namespace mRemoteNG.UI.Window
{
public partial class ConnectionTreeWindow
{
private readonly ConnectionContextMenu _contextMenu;
private readonly IConnectionInitiator _connectionInitiator;
private readonly IConnectionInitiator _connectionInitiator;
private ThemeManager _themeManager;
private readonly ConnectionTreeSearchTextFilter _connectionTreeSearchTextFilter = new ConnectionTreeSearchTextFilter();
public ConnectionContextMenu ConnectionTreeContextMenu
{
get { return olvConnections.ContextMenuStrip as ConnectionContextMenu;}
set { olvConnections.ContextMenuStrip = value; }
}
public ConnectionInfo SelectedNode => olvConnections.SelectedNode;
public ConnectionTree ConnectionTree
@@ -30,22 +34,18 @@ namespace mRemoteNG.UI.Window
set { olvConnections = value; }
}
public ConnectionTreeWindow(DockContent panel, IConnectionInitiator connectionInitiator, ConnectionContextMenu contextMenu)
public ConnectionTreeWindow(DockContent panel, IConnectionInitiator connectionInitiator)
{
WindowType = WindowType.Tree;
DockPnl = panel.ThrowIfNull(nameof(panel));
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
_contextMenu = contextMenu.ThrowIfNull(nameof(contextMenu));
InitializeComponent();
olvConnections.ContextMenuStrip = _contextMenu;
SetMenuEventHandlers();
SetConnectionTreeEventHandlers();
Settings.Default.PropertyChanged += (sender, args) => SetConnectionTreeEventHandlers();
olvConnections.ModelFilter = _connectionTreeSearchTextFilter;
}
#region Form Stuff
private void Tree_Load(object sender, EventArgs e)
{
@@ -80,7 +80,7 @@ namespace mRemoteNG.UI.Window
{
if (!_themeManager.ThemingActive) return;
vsToolStripExtender.SetStyle(msMain, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
vsToolStripExtender.SetStyle(_contextMenu, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
vsToolStripExtender.SetStyle(ConnectionTreeContextMenu, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
//Treelistview need to be manually themed
olvConnections.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TreeView_Background");
olvConnections.ForeColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("TreeView_Foreground");
@@ -178,14 +178,14 @@ namespace mRemoteNG.UI.Window
private void tvConnections_BeforeLabelEdit(object sender, LabelEditEventArgs e)
{
_contextMenu.DisableShortcutKeys();
ConnectionTreeContextMenu.DisableShortcutKeys();
}
private void tvConnections_AfterLabelEdit(object sender, LabelEditEventArgs e)
{
try
{
_contextMenu.EnableShortcutKeys();
ConnectionTreeContextMenu.EnableShortcutKeys();
ConnectionTree.ConnectionTreeModel.RenameNode(SelectedNode, e.Label);
}
catch (Exception ex)

View File

@@ -30,11 +30,13 @@ namespace mRemoteNG.UI.Window
private readonly IConnectionInitiator _connectionInitiator;
private VisualStudioToolStripExtender vsToolStripExtender;
private readonly ToolStripRenderer _toolStripProfessionalRenderer = new ToolStripProfessionalRenderer();
private readonly Windows _windows;
#region Public Methods
public ConnectionWindow(DockContent panel, IConnectionInitiator connectionInitiator, string formText = "")
public ConnectionWindow(DockContent panel, IConnectionInitiator connectionInitiator, Windows windows, string formText = "")
{
if (formText == "")
_windows = windows.ThrowIfNull(nameof(windows));
if (formText == "")
{
formText = Language.strNewPanel;
}
@@ -487,13 +489,13 @@ namespace mRemoteNG.UI.Window
var interfaceControl = TabController.SelectedTab?.Tag as InterfaceControl;
if (interfaceControl == null) return;
Windows.Show(WindowType.SSHTransfer);
_windows.Show(WindowType.SSHTransfer);
var connectionInfo = interfaceControl.Info;
Windows.SshtransferForm.Hostname = connectionInfo.Hostname;
Windows.SshtransferForm.Username = connectionInfo.Username;
Windows.SshtransferForm.Password = connectionInfo.Password;
Windows.SshtransferForm.Port = Convert.ToString(connectionInfo.Port);
_windows.SshtransferForm.Hostname = connectionInfo.Hostname;
_windows.SshtransferForm.Username = connectionInfo.Username;
_windows.SshtransferForm.Password = connectionInfo.Password;
_windows.SshtransferForm.Port = Convert.ToString(connectionInfo.Port);
}
catch (Exception ex)
{
@@ -710,7 +712,7 @@ namespace mRemoteNG.UI.Window
{
cmenTab.Close();
Application.DoEvents();
Windows.ScreenshotForm.AddScreenshot(MiscTools.TakeScreenshot(this));
_windows.ScreenshotForm.AddScreenshot(MiscTools.TakeScreenshot(this));
}
#endregion

View File

@@ -1,13 +1,13 @@
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Drawing;
using System.Text;
using WeifenLuo.WinFormsUI.Docking;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Messages;
using mRemoteNG.UI.Forms;
using mRemoteNG.Themes;
using mRemoteNG.UI.Forms;
using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNG.UI.Window
{
@@ -19,10 +19,6 @@ namespace mRemoteNG.UI.Window
public DockContent PreviousActiveForm { get; set; }
public ErrorAndInfoWindow() : this(new DockContent(), new ConnectionTreeWindow())
{
}
public ErrorAndInfoWindow(DockContent panel, ConnectionTreeWindow connectionTreeWindow)
{
_connectionTreeWindow = connectionTreeWindow;

View File

@@ -1,11 +1,11 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using mRemoteNG.App;
using System.IO;
using mRemoteNG.UI.Forms;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Themes;
using mRemoteNG.UI.Forms;
using WeifenLuo.WinFormsUI.Docking;
namespace mRemoteNG.UI.Window
{
@@ -178,7 +178,7 @@ namespace mRemoteNG.UI.Window
{
}
internal ScreenshotManagerWindow(DockContent panel)
public ScreenshotManagerWindow(DockContent panel)
{
WindowType = WindowType.ScreenshotManager;
DockPnl = panel;

View File

@@ -1,5 +1,6 @@
using System;
using mRemoteNG.App;
using mRemoteNG.Tools;
using WeifenLuo.WinFormsUI.Docking;
@@ -7,6 +8,8 @@ namespace mRemoteNG.UI.Window
{
public class UltraVNCWindow : BaseWindow
{
private readonly Action<WindowType> _showWindowAction;
#region Form Init
internal System.Windows.Forms.ToolStrip tsMain;
internal System.Windows.Forms.Panel pnlContainer;
@@ -69,18 +72,13 @@ namespace mRemoteNG.UI.Window
}
#endregion
#region Declarations
//Private WithEvents vnc As AxCSC_ViewerXControl
#endregion
#region Public Methods
public UltraVNCWindow()
public UltraVNCWindow(Action<WindowType> showWindowAction)
{
this.WindowType = WindowType.UltraVNCSC;
this.DockPnl = new DockContent();
this.InitializeComponent();
_showWindowAction = showWindowAction.ThrowIfNull(nameof(showWindowAction));
WindowType = WindowType.UltraVNCSC;
DockPnl = new DockContent();
InitializeComponent();
}
#endregion
#region Private Methods
private void UltraVNCSC_Load(object sender, System.EventArgs e)
@@ -151,7 +149,7 @@ namespace mRemoteNG.UI.Window
{
//vnc.Dispose()
Dispose();
Windows.Show(WindowType.UltraVNCSC);
_showWindowAction(WindowType.UltraVNCSC);
}
#endregion
}