mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
use a single instance of IConnectionInitiator everywhere
This commit is contained in:
@@ -12,7 +12,7 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
{
|
||||
public class IntegratedProgramTests
|
||||
{
|
||||
private readonly ExternalTool _extTool = new ExternalTool
|
||||
private readonly ExternalTool _extTool = new ExternalTool(new ConnectionInitiator())
|
||||
{
|
||||
DisplayName = "notepad",
|
||||
FileName = @"%windir%\system32\notepad.exe",
|
||||
@@ -50,7 +50,7 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
|
||||
private InterfaceControl BuildInterfaceControl(string extAppName, ProtocolBase sut)
|
||||
{
|
||||
var connectionWindow = new ConnectionWindow(new DockContent());
|
||||
var connectionWindow = new ConnectionWindow(new DockContent(), new ConnectionInitiator());
|
||||
var connectionInfo = new ConnectionInfo {ExtApp = extAppName, Protocol = ProtocolType.IntApp};
|
||||
return new InterfaceControl(connectionWindow, sut, connectionInfo);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using NUnit.Framework;
|
||||
using mRemoteNG.Connection;
|
||||
using NUnit.Framework;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNGTests.UI.Forms
|
||||
@@ -15,7 +16,7 @@ namespace mRemoteNGTests.UI.Forms
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_optionsForm = new FrmOptions();
|
||||
_optionsForm = new FrmOptions(new ConnectionInitiator());
|
||||
_optionsForm.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NUnit.Framework;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
@@ -13,7 +14,7 @@ namespace mRemoteNGTests.UI.Window
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent());
|
||||
_connectionTreeWindow = new ConnectionTreeWindow(new DockContent(), new ConnectionInitiator());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
@@ -20,7 +21,7 @@ namespace mRemoteNG.App
|
||||
|
||||
internal static ConnectionTreeWindow TreeForm
|
||||
{
|
||||
get => _treeForm ?? (_treeForm = new ConnectionTreeWindow());
|
||||
get => _treeForm ?? (_treeForm = new ConnectionTreeWindow(ConnectionInitiator));
|
||||
set => _treeForm = value;
|
||||
}
|
||||
|
||||
@@ -29,6 +30,7 @@ namespace mRemoteNG.App
|
||||
internal static ScreenshotManagerWindow ScreenshotForm { get; set; } = new ScreenshotManagerWindow();
|
||||
private static UpdateWindow UpdateForm { get; set; } = new UpdateWindow();
|
||||
internal static SSHTransferWindow SshtransferForm { get; private set; } = new SSHTransferWindow();
|
||||
internal static IConnectionInitiator ConnectionInitiator { get; set; }
|
||||
|
||||
|
||||
public static void Show(WindowType windowType)
|
||||
@@ -50,7 +52,7 @@ namespace mRemoteNG.App
|
||||
_adimportForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.Options:
|
||||
using (var optionsForm = new FrmOptions())
|
||||
using (var optionsForm = new FrmOptions(ConnectionInitiator))
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
}
|
||||
@@ -73,7 +75,7 @@ namespace mRemoteNG.App
|
||||
break;
|
||||
case WindowType.ExternalApps:
|
||||
if (_externalappsForm == null || _externalappsForm.IsDisposed)
|
||||
_externalappsForm = new ExternalToolsWindow();
|
||||
_externalappsForm = new ExternalToolsWindow(ConnectionInitiator);
|
||||
_externalappsForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.PortScan:
|
||||
|
||||
@@ -4,6 +4,7 @@ using mRemoteNG.App.Info;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
@@ -13,12 +14,14 @@ namespace mRemoteNG.Config.Settings
|
||||
public class ExternalAppsLoader
|
||||
{
|
||||
private readonly FrmMain _mainForm;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
public ExternalAppsLoader(FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
ExternalToolsToolStrip externalToolsToolStrip)
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
@@ -30,6 +33,7 @@ namespace mRemoteNG.Config.Settings
|
||||
_mainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_connectionInitiator = connectionInitiator;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +75,7 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
foreach (XmlElement xEl in xDom.DocumentElement.ChildNodes)
|
||||
{
|
||||
var extA = new ExternalTool
|
||||
var extA = new ExternalTool(_connectionInitiator)
|
||||
{
|
||||
DisplayName = xEl.Attributes["DisplayName"].Value,
|
||||
FileName = xEl.Attributes["FileName"].Value,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
@@ -7,6 +7,7 @@ using System.Threading;
|
||||
using System.Globalization;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
@@ -23,16 +24,19 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly MultiSshToolStrip _multiSshToolStrip;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
|
||||
private FrmMain MainForm { get; }
|
||||
|
||||
|
||||
public SettingsLoader(FrmMain mainForm,
|
||||
MessageCollector messageCollector,
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
MenuStrip mainMenu)
|
||||
public SettingsLoader(
|
||||
FrmMain mainForm,
|
||||
IConnectionInitiator connectionInitiator,
|
||||
MessageCollector messageCollector,
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
MenuStrip mainMenu)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
@@ -53,7 +57,8 @@ namespace mRemoteNG.Config.Settings
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_multiSshToolStrip = multiSshToolStrip;
|
||||
_mainMenu = mainMenu;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip);
|
||||
_connectionInitiator = connectionInitiator;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip, _connectionInitiator);
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
@@ -156,10 +161,10 @@ namespace mRemoteNG.Config.Settings
|
||||
MainForm.Fullscreen.Value = true;
|
||||
}
|
||||
|
||||
private static void SetShowSystemTrayIcon()
|
||||
private void SetShowSystemTrayIcon()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.ShowSystemTrayIcon)
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon();
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(_connectionInitiator);
|
||||
}
|
||||
|
||||
private static void SetPuttyPath()
|
||||
|
||||
@@ -5,7 +5,6 @@ using mRemoteNG.App;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Panels;
|
||||
using mRemoteNG.UI.Tabs;
|
||||
@@ -17,10 +16,13 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
public class ConnectionInitiator : IConnectionInitiator
|
||||
{
|
||||
private readonly PanelAdder _panelAdder = new PanelAdder();
|
||||
private readonly List<string> _activeConnections = new List<string>();
|
||||
private readonly List<ProtocolBase> _activeConnections = new List<ProtocolBase>();
|
||||
|
||||
public IEnumerable<string> ActiveConnections => _activeConnections;
|
||||
public IEnumerable<ProtocolBase> ActiveConnections => _activeConnections;
|
||||
|
||||
public ConnectionInitiator()
|
||||
{
|
||||
}
|
||||
|
||||
public bool SwitchToOpenConnection(ConnectionInfo connectionInfo)
|
||||
{
|
||||
@@ -101,7 +103,7 @@ namespace mRemoteNG.Connection
|
||||
}
|
||||
|
||||
connectionInfo.OpenConnections.Add(newProtocol);
|
||||
_activeConnections.Add(connectionInfo.ConstantID);
|
||||
_activeConnections.Add(newProtocol);
|
||||
FrmMain.Default.SelectedConnection = connectionInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -141,14 +143,14 @@ namespace mRemoteNG.Connection
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string SetConnectionPanel(ConnectionInfo connectionInfo, ConnectionInfo.Force force)
|
||||
private string SetConnectionPanel(ConnectionInfo connectionInfo, ConnectionInfo.Force force)
|
||||
{
|
||||
if (connectionInfo.Panel != "" &&
|
||||
!force.HasFlag(ConnectionInfo.Force.OverridePanel) &&
|
||||
!Settings.Default.AlwaysShowPanelSelectionDlg)
|
||||
return connectionInfo.Panel;
|
||||
|
||||
var frmPnl = new FrmChoosePanel();
|
||||
var frmPnl = new FrmChoosePanel(this);
|
||||
return frmPnl.ShowDialog() == DialogResult.OK
|
||||
? frmPnl.Panel
|
||||
: null;
|
||||
@@ -159,7 +161,7 @@ namespace mRemoteNG.Connection
|
||||
var connectionForm = conForm ?? Runtime.WindowList.FromString(connectionPanel) as ConnectionWindow;
|
||||
|
||||
if (connectionForm == null)
|
||||
connectionForm = _panelAdder.AddPanel(connectionPanel);
|
||||
connectionForm = new PanelAdder(this).AddPanel(connectionPanel);
|
||||
else
|
||||
connectionForm.Show(FrmMain.Default.pnlDock);
|
||||
|
||||
@@ -256,8 +258,8 @@ namespace mRemoteNG.Connection
|
||||
prot.InterfaceControl.Info.Protocol,
|
||||
Environment.UserName));
|
||||
prot.InterfaceControl.Info.OpenConnections.Remove(prot);
|
||||
if (_activeConnections.Contains(prot.InterfaceControl.Info.ConstantID))
|
||||
_activeConnections.Remove(prot.InterfaceControl.Info.ConstantID);
|
||||
if (_activeConnections.Contains(prot))
|
||||
_activeConnections.Remove(prot);
|
||||
|
||||
if (prot.InterfaceControl.Info.PostExtApp == "") return;
|
||||
var extA = Runtime.ExternalToolsService.GetExtAppByName(prot.InterfaceControl.Info.PostExtApp);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Container;
|
||||
using mRemoteNG.UI.Window;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace mRemoteNG.Connection
|
||||
{
|
||||
public interface IConnectionInitiator
|
||||
{
|
||||
IEnumerable<string> ActiveConnections { get; }
|
||||
IEnumerable<ProtocolBase> ActiveConnections { get; }
|
||||
|
||||
void OpenConnection(
|
||||
ContainerInfo containerInfo,
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace mRemoteNG.Tools
|
||||
{
|
||||
public class ExternalTool : INotifyPropertyChanged
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private string _displayName;
|
||||
private string _fileName;
|
||||
private bool _waitForExit;
|
||||
@@ -102,12 +102,15 @@ namespace mRemoteNG.Tools
|
||||
|
||||
#endregion
|
||||
|
||||
public ExternalTool(string displayName = "",
|
||||
string fileName = "",
|
||||
string arguments = "",
|
||||
string workingDir = "",
|
||||
bool runElevated = false)
|
||||
public ExternalTool(
|
||||
IConnectionInitiator connectionInitiator,
|
||||
string displayName = "",
|
||||
string fileName = "",
|
||||
string arguments = "",
|
||||
string workingDir = "",
|
||||
bool runElevated = false)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
DisplayName = displayName;
|
||||
FileName = fileName;
|
||||
Arguments = arguments;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
@@ -14,13 +14,14 @@ namespace mRemoteNG.Tools
|
||||
private readonly NotifyIcon _nI;
|
||||
private readonly ContextMenuStrip _cMen;
|
||||
private readonly ToolStripMenuItem _cMenCons;
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private static readonly FrmMain FrmMain = FrmMain.Default;
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
public NotificationAreaIcon()
|
||||
public NotificationAreaIcon(IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
try
|
||||
{
|
||||
_cMenCons = new ToolStripMenuItem
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace mRemoteNG.Tree
|
||||
.Where(item =>
|
||||
item.PleaseConnect &&
|
||||
//ignore items that have already connected
|
||||
!_connectionInitiator.ActiveConnections.Contains(item.ConstantID));
|
||||
_connectionInitiator.ActiveConnections.All(protocol => protocol.InterfaceControl.Info.ConstantID != item.ConstantID));
|
||||
|
||||
foreach (var connectionInfo in previouslyOpenedConnections)
|
||||
{
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace mRemoteNG.UI.Controls
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
|
||||
|
||||
public ConnectionContextMenu(ConnectionTree connectionTree)
|
||||
public ConnectionContextMenu(ConnectionTree connectionTree, IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionTree = connectionTree;
|
||||
_connectionInitiator = new ConnectionInitiator();
|
||||
_connectionInitiator = connectionInitiator;
|
||||
InitializeComponent();
|
||||
ApplyLanguage();
|
||||
EnableShortcutKeys();
|
||||
|
||||
@@ -23,7 +23,8 @@ namespace mRemoteNG.UI.Controls
|
||||
private readonly ConnectionTreeDragAndDropHandler _dragAndDropHandler = new ConnectionTreeDragAndDropHandler();
|
||||
private readonly PuttySessionsManager _puttySessionsManager = PuttySessionsManager.Instance;
|
||||
private readonly StatusImageList _statusImageList = new StatusImageList();
|
||||
private ThemeManager _themeManager;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly ThemeManager _themeManager;
|
||||
|
||||
private readonly ConnectionTreeSearchTextFilter _connectionTreeSearchTextFilter =
|
||||
new ConnectionTreeSearchTextFilter();
|
||||
@@ -63,6 +64,7 @@ namespace mRemoteNG.UI.Controls
|
||||
|
||||
public ConnectionTree()
|
||||
{
|
||||
_connectionInitiator = Windows.ConnectionInitiator;
|
||||
InitializeComponent();
|
||||
SetupConnectionTreeView();
|
||||
UseOverlays = false;
|
||||
@@ -114,7 +116,7 @@ namespace mRemoteNG.UI.Controls
|
||||
SmallImageList = _statusImageList.ImageList;
|
||||
AddColumns(_statusImageList.ImageGetter);
|
||||
LinkModelToView();
|
||||
_contextMenu = new ConnectionContextMenu(this);
|
||||
_contextMenu = new ConnectionContextMenu(this, _connectionInitiator);
|
||||
ContextMenuStrip = _contextMenu;
|
||||
SetupDropSink();
|
||||
SetEventHandlers();
|
||||
|
||||
@@ -22,21 +22,11 @@ namespace mRemoteNG.UI.Controls
|
||||
private ContextMenuStrip _mnuQuickConnectProtocol;
|
||||
private QuickConnectComboBox _cmbQuickConnect;
|
||||
private ContextMenuStrip _mnuConnections;
|
||||
private IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly ThemeManager _themeManager;
|
||||
private WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender vsToolStripExtender;
|
||||
private readonly DisplayProperties _display;
|
||||
|
||||
public IConnectionInitiator ConnectionInitiator
|
||||
{
|
||||
get => _connectionInitiator;
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
_connectionInitiator = value;
|
||||
}
|
||||
}
|
||||
public IConnectionInitiator ConnectionInitiator { get; set; }
|
||||
|
||||
public QuickConnectToolStrip()
|
||||
{
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
public sealed partial class AppearancePage
|
||||
{
|
||||
public AppearancePage()
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
|
||||
public AppearancePage(IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
InitializeComponent();
|
||||
ApplyTheme();
|
||||
PageIcon = Resources.Panels_Icon;
|
||||
@@ -82,7 +86,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
if (Runtime.NotificationAreaIcon == null)
|
||||
{
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon();
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(_connectionInitiator);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Themes;
|
||||
using mRemoteNG.UI.Forms.Input;
|
||||
using mRemoteNG.UI.Panels;
|
||||
@@ -10,10 +11,10 @@ namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
private readonly PanelAdder _panelAdder;
|
||||
|
||||
public FrmChoosePanel()
|
||||
public FrmChoosePanel(IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
InitializeComponent();
|
||||
_panelAdder = new PanelAdder();
|
||||
_panelAdder = new PanelAdder(connectionInitiator);
|
||||
}
|
||||
|
||||
public string Panel
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace mRemoteNG.UI.Forms
|
||||
private readonly IList<IMessageWriter> _messageWriters = new List<IMessageWriter>();
|
||||
private readonly ThemeManager _themeManager;
|
||||
private readonly FileBackupPruner _backupPruner = new FileBackupPruner();
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
|
||||
internal FullscreenHandler Fullscreen { get; set; }
|
||||
|
||||
@@ -145,10 +146,11 @@ namespace mRemoteNG.UI.Forms
|
||||
MessageCollectorSetup.SetupMessageCollector(messageCollector, _messageWriters);
|
||||
MessageCollectorSetup.BuildMessageWritersFromSettings(_messageWriters);
|
||||
|
||||
Windows.ConnectionInitiator = _connectionInitiator;
|
||||
Startup.Instance.InitializeProgram(messageCollector);
|
||||
|
||||
msMain.Location = Point.Empty;
|
||||
var settingsLoader = new SettingsLoader(this, messageCollector, _quickConnectToolStrip,
|
||||
var settingsLoader = new SettingsLoader(this, _connectionInitiator, messageCollector, _quickConnectToolStrip,
|
||||
_externalToolsToolStrip, _multiSshToolStrip, msMain);
|
||||
settingsLoader.LoadSettings();
|
||||
|
||||
@@ -193,14 +195,17 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
FrmSplashScreen.getInstance().Close();
|
||||
|
||||
if (!Settings.Default.CreateEmptyPanelOnStartUp) return;
|
||||
var panelName = !string.IsNullOrEmpty(Settings.Default.StartUpPanelName)
|
||||
? Settings.Default.StartUpPanelName
|
||||
: Language.strNewPanel;
|
||||
if (Settings.Default.CreateEmptyPanelOnStartUp)
|
||||
{
|
||||
var panelName = !string.IsNullOrEmpty(Settings.Default.StartUpPanelName)
|
||||
? Settings.Default.StartUpPanelName
|
||||
: Language.strNewPanel;
|
||||
|
||||
var panelAdder = new PanelAdder(_connectionInitiator);
|
||||
if (!panelAdder.DoesPanelExist(panelName))
|
||||
panelAdder.AddPanel(panelName);
|
||||
}
|
||||
|
||||
var panelAdder = new PanelAdder();
|
||||
if (!panelAdder.DoesPanelExist(panelName))
|
||||
panelAdder.AddPanel(panelName);
|
||||
}
|
||||
|
||||
private void ApplyLanguage()
|
||||
@@ -249,20 +254,20 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
private void SetMenuDependencies()
|
||||
{
|
||||
var connectionInitiator = new ConnectionInitiator();
|
||||
fileMenu.TreeWindow = Windows.TreeForm;
|
||||
fileMenu.ConnectionInitiator = connectionInitiator;
|
||||
fileMenu.ConnectionInitiator = _connectionInitiator;
|
||||
|
||||
viewMenu.TsExternalTools = _externalToolsToolStrip;
|
||||
viewMenu.TsQuickConnect = _quickConnectToolStrip;
|
||||
viewMenu.TsMultiSsh = _multiSshToolStrip;
|
||||
viewMenu.FullscreenHandler = Fullscreen;
|
||||
viewMenu.MainForm = this;
|
||||
viewMenu.ConnectionInitiator = _connectionInitiator;
|
||||
|
||||
toolsMenu.MainForm = this;
|
||||
toolsMenu.CredentialProviderCatalog = Runtime.CredentialProviderCatalog;
|
||||
|
||||
_quickConnectToolStrip.ConnectionInitiator = connectionInitiator;
|
||||
_quickConnectToolStrip.ConnectionInitiator = _connectionInitiator;
|
||||
}
|
||||
|
||||
//Theming support
|
||||
@@ -338,7 +343,7 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
if (CTaskDialog.CommandButtonResult != 1) return;
|
||||
|
||||
using (var optionsForm = new FrmOptions(Language.strTabUpdates))
|
||||
using (var optionsForm = new FrmOptions(Language.strTabUpdates, _connectionInitiator))
|
||||
{
|
||||
optionsForm.ShowDialog(this);
|
||||
}
|
||||
@@ -348,13 +353,8 @@ namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
if (!Settings.Default.CheckForUpdatesOnStartup) return;
|
||||
|
||||
var nextUpdateCheck = Convert.ToDateTime(
|
||||
Settings.Default.CheckForUpdatesLastCheck.Add(
|
||||
TimeSpan
|
||||
.FromDays(Convert
|
||||
.ToDouble(Settings
|
||||
.Default
|
||||
.CheckForUpdatesFrequencyDays))));
|
||||
var updateFrequencyInDays = Convert.ToDouble(Settings.Default.CheckForUpdatesFrequencyDays);
|
||||
var nextUpdateCheck = Settings.Default.CheckForUpdatesLastCheck.AddDays(updateFrequencyInDays);
|
||||
|
||||
if (!Settings.Default.UpdatePending && DateTime.UtcNow <= nextUpdateCheck) return;
|
||||
if (!IsHandleCreated)
|
||||
@@ -446,7 +446,7 @@ namespace mRemoteNG.UI.Forms
|
||||
if (!Settings.Default.MinimizeToTray) return;
|
||||
if (Runtime.NotificationAreaIcon == null)
|
||||
{
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon();
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(_connectionInitiator);
|
||||
}
|
||||
|
||||
Hide();
|
||||
|
||||
@@ -4,26 +4,30 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Themes;
|
||||
|
||||
namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
public partial class FrmOptions : Form
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private Dictionary<string, OptionsPage> _pages;
|
||||
private readonly string _pageName;
|
||||
private readonly DisplayProperties _display = new DisplayProperties();
|
||||
|
||||
public FrmOptions() : this(Language.strStartupExit)
|
||||
public FrmOptions(IConnectionInitiator connectionInitiator)
|
||||
: this(Language.strStartupExit, connectionInitiator)
|
||||
{
|
||||
}
|
||||
|
||||
public FrmOptions(string pn)
|
||||
public FrmOptions(string pn, IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
Application.DoEvents();
|
||||
InitializeComponent();
|
||||
_pageName = pn;
|
||||
_connectionInitiator = connectionInitiator;
|
||||
Cursor.Current = Cursors.Default;
|
||||
}
|
||||
|
||||
@@ -68,7 +72,7 @@ namespace mRemoteNG.UI.Forms
|
||||
_pages = new Dictionary<string, OptionsPage>
|
||||
{
|
||||
{typeof(StartupExitPage).Name, new StartupExitPage {Dock = DockStyle.Fill}},
|
||||
{typeof(AppearancePage).Name, new AppearancePage {Dock = DockStyle.Fill}},
|
||||
{typeof(AppearancePage).Name, new AppearancePage(_connectionInitiator) {Dock = DockStyle.Fill}},
|
||||
{typeof(TabsPanelsPage).Name, new TabsPanelsPage {Dock = DockStyle.Fill}},
|
||||
{typeof(NotificationsPage).Name, new NotificationsPage {Dock = DockStyle.Fill}},
|
||||
{typeof(ConnectionsPage).Name, new ConnectionsPage {Dock = DockStyle.Fill}},
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Panels;
|
||||
using mRemoteNG.UI.Window;
|
||||
@@ -27,7 +28,6 @@ namespace mRemoteNG.UI.Menu
|
||||
private ToolStripMenuItem _mMenViewResetLayout;
|
||||
private ToolStripMenuItem _mMenViewLockToolbars;
|
||||
private ToolStripSeparator _toolStripSeparator1;
|
||||
private readonly PanelAdder _panelAdder;
|
||||
|
||||
|
||||
public ToolStrip TsExternalTools { get; set; }
|
||||
@@ -35,12 +35,12 @@ namespace mRemoteNG.UI.Menu
|
||||
public ToolStrip TsMultiSsh { get; set; }
|
||||
public FullscreenHandler FullscreenHandler { get; set; }
|
||||
public FrmMain MainForm { get; set; }
|
||||
public IConnectionInitiator ConnectionInitiator { get; set; }
|
||||
|
||||
|
||||
public ViewMenu()
|
||||
{
|
||||
Initialize();
|
||||
_panelAdder = new PanelAdder();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
@@ -374,7 +374,7 @@ namespace mRemoteNG.UI.Menu
|
||||
|
||||
private void mMenViewAddConnectionPanel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_panelAdder.AddPanel();
|
||||
new PanelAdder(ConnectionInitiator).AddPanel();
|
||||
}
|
||||
|
||||
private void mMenViewExtAppsToolbar_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -7,17 +7,25 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Connection;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.UI.Panels
|
||||
{
|
||||
public class PanelAdder
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
|
||||
public PanelAdder(IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
}
|
||||
|
||||
public ConnectionWindow AddPanel(string title = "")
|
||||
{
|
||||
try
|
||||
{
|
||||
var connectionForm = new ConnectionWindow(new DockContent());
|
||||
var connectionForm = new ConnectionWindow(new DockContent(), _connectionInitiator);
|
||||
BuildConnectionWindowContextMenu(connectionForm);
|
||||
SetConnectionWindowTitle(title, connectionForm);
|
||||
ShowConnectionWindow(connectionForm);
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
public partial class ConnectionTreeWindow
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private ThemeManager _themeManager;
|
||||
|
||||
public ConnectionInfo SelectedNode => olvConnections.SelectedNode;
|
||||
@@ -32,12 +32,14 @@ namespace mRemoteNG.UI.Window
|
||||
set { olvConnections = value; }
|
||||
}
|
||||
|
||||
public ConnectionTreeWindow() : this(new DockContent())
|
||||
public ConnectionTreeWindow(IConnectionInitiator connectionInitiator)
|
||||
: this(new DockContent(), connectionInitiator)
|
||||
{
|
||||
}
|
||||
|
||||
public ConnectionTreeWindow(DockContent panel)
|
||||
public ConnectionTreeWindow(DockContent panel, IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
WindowType = WindowType.Tree;
|
||||
DockPnl = panel;
|
||||
InitializeComponent();
|
||||
|
||||
@@ -23,14 +23,15 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
public partial class ConnectionWindow : BaseWindow
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private VisualStudioToolStripExtender vsToolStripExtender;
|
||||
private readonly ToolStripRenderer _toolStripProfessionalRenderer = new ToolStripProfessionalRenderer();
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public ConnectionWindow(DockContent panel, string formText = "")
|
||||
public ConnectionWindow(DockContent panel, IConnectionInitiator connectionInitiator, string formText = "")
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
if (formText == "")
|
||||
{
|
||||
formText = Language.strNewPanel;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using BrightIdeasSoftware;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.UI.Forms;
|
||||
@@ -14,12 +15,15 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
public partial class ExternalToolsWindow
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly ExternalAppsSaver _externalAppsSaver;
|
||||
private readonly ThemeManager _themeManager;
|
||||
private readonly FullyObservableCollection<ExternalTool> _currentlySelectedExternalTools;
|
||||
|
||||
public ExternalToolsWindow()
|
||||
|
||||
public ExternalToolsWindow(IConnectionInitiator connectionInitiator)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator;
|
||||
InitializeComponent();
|
||||
WindowType = WindowType.ExternalApps;
|
||||
DockPnl = new DockContent();
|
||||
@@ -177,7 +181,10 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
try
|
||||
{
|
||||
var externalTool = new ExternalTool(Language.strExternalToolDefaultName);
|
||||
var externalTool = new ExternalTool(_connectionInitiator)
|
||||
{
|
||||
DisplayName = Language.strExternalToolDefaultName
|
||||
};
|
||||
Runtime.ExternalToolsService.ExternalTools.Add(externalTool);
|
||||
UpdateToolsListObjView();
|
||||
ToolsListObjView.SelectedObject = externalTool;
|
||||
|
||||
Reference in New Issue
Block a user