mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
made Shutdown and SettingsSaver non-static
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Connection.Protocol;
|
||||
using mRemoteNG.Credential.Repositories;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tools.CustomCollections;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
@@ -70,7 +73,10 @@ namespace mRemoteNGTests.Connection.Protocol
|
||||
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 shutdown = new Shutdown(new SettingsSaver(new ExternalToolsService()));
|
||||
Func<UpdateWindow> updateWindowBuilder = () => new UpdateWindow(new DockContent(), shutdown);
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder = () => new NotificationAreaIcon(FrmMain.Default, _connectionInitiator, shutdown);
|
||||
var windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow, sshTransferWindow, updateWindowBuilder, notificationAreaIconBuilder);
|
||||
var connectionWindow = new ConnectionWindow(new DockContent(), _connectionInitiator, windows);
|
||||
var connectionInfo = new ConnectionInfo {ExtApp = extAppName};
|
||||
return new InterfaceControl(connectionWindow, sut, connectionInfo);
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
@@ -18,7 +21,8 @@ namespace mRemoteNGTests.UI.Forms
|
||||
public void Setup()
|
||||
{
|
||||
var connectionInitiator = Substitute.For<IConnectionInitiator>();
|
||||
_optionsForm = new frmOptions(connectionInitiator, type => {});
|
||||
var shutdown = new Shutdown(new SettingsSaver(new ExternalToolsService()));
|
||||
_optionsForm = new frmOptions(connectionInitiator, type => {}, () => new NotificationAreaIcon(FrmMain.Default, connectionInitiator, shutdown));
|
||||
_optionsForm.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Config.DataProviders;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Connection;
|
||||
using mRemoteNG.Credential;
|
||||
using mRemoteNG.Credential.Repositories;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Security;
|
||||
using mRemoteNG.Tools;
|
||||
|
||||
@@ -3,29 +3,36 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.Config.Settings;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
// ReSharper disable ArrangeAccessorOwnerBody
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
public static class Shutdown
|
||||
public class Shutdown
|
||||
{
|
||||
private readonly SettingsSaver _settingsSaver;
|
||||
private static string _updateFilePath;
|
||||
|
||||
public Shutdown(SettingsSaver settingsSaver)
|
||||
{
|
||||
_settingsSaver = settingsSaver.ThrowIfNull(nameof(settingsSaver));
|
||||
}
|
||||
|
||||
private static bool UpdatePending
|
||||
{
|
||||
get { return !string.IsNullOrEmpty(_updateFilePath); }
|
||||
}
|
||||
|
||||
public static void Quit(string updateFilePath = null)
|
||||
public void Quit(string updateFilePath = null)
|
||||
{
|
||||
_updateFilePath = updateFilePath;
|
||||
FrmMain.Default.Close();
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
public void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,34 +48,34 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static void StopPuttySessionWatcher()
|
||||
private void StopPuttySessionWatcher()
|
||||
{
|
||||
PuttySessionsManager.Instance.StopWatcher();
|
||||
}
|
||||
|
||||
private static void DisposeNotificationAreaIcon()
|
||||
private void DisposeNotificationAreaIcon()
|
||||
{
|
||||
if (Runtime.NotificationAreaIcon != null && Runtime.NotificationAreaIcon.Disposed == false)
|
||||
Runtime.NotificationAreaIcon.Dispose();
|
||||
}
|
||||
|
||||
private static void SaveConnections()
|
||||
private void SaveConnections()
|
||||
{
|
||||
if (Settings.Default.SaveConsOnExit)
|
||||
Runtime.ConnectionsService.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
private void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip, MultiSshToolStrip multiSshToolStrip, FrmMain frmMain)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
_settingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip, multiSshToolStrip, frmMain);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
private void UnregisterBrowsers()
|
||||
{
|
||||
IeBrowserEmulation.Unregister();
|
||||
}
|
||||
|
||||
public static void StartUpdate()
|
||||
public void StartUpdate()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -80,7 +87,7 @@ namespace mRemoteNG.App
|
||||
}
|
||||
}
|
||||
|
||||
private static void RunUpdateFile()
|
||||
private void RunUpdateFile()
|
||||
{
|
||||
if (UpdatePending)
|
||||
Process.Start(_updateFilePath);
|
||||
|
||||
@@ -5,6 +5,7 @@ using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using mRemoteNG.UI.Window;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
{
|
||||
@@ -19,6 +20,8 @@ namespace mRemoteNG.App
|
||||
private UltraVNCWindow _ultravncscForm;
|
||||
private ComponentsCheckWindow _componentscheckForm;
|
||||
private UpdateWindow _updateForm;
|
||||
private readonly Func<UpdateWindow> _updateWindowBuilder;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
|
||||
internal ConnectionTreeWindow TreeForm { get; }
|
||||
internal ConfigWindow ConfigForm { get; }
|
||||
@@ -32,7 +35,9 @@ namespace mRemoteNG.App
|
||||
ConfigWindow configForm,
|
||||
ErrorAndInfoWindow errorAndInfoWindow,
|
||||
ScreenshotManagerWindow screenshotForm,
|
||||
SSHTransferWindow sshtransferForm)
|
||||
SSHTransferWindow sshtransferForm,
|
||||
Func<UpdateWindow> updateWindowBuilder,
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
TreeForm = treeForm.ThrowIfNull(nameof(treeForm));
|
||||
@@ -40,7 +45,8 @@ namespace mRemoteNG.App
|
||||
ErrorsForm = errorAndInfoWindow.ThrowIfNull(nameof(errorAndInfoWindow));
|
||||
ScreenshotForm = screenshotForm.ThrowIfNull(nameof(screenshotForm));
|
||||
SshtransferForm = sshtransferForm.ThrowIfNull(nameof(sshtransferForm));
|
||||
_updateForm = new UpdateWindow();
|
||||
_updateWindowBuilder = updateWindowBuilder;
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder;
|
||||
}
|
||||
|
||||
public void Show(WindowType windowType)
|
||||
@@ -62,7 +68,7 @@ namespace mRemoteNG.App
|
||||
_adimportForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.Options:
|
||||
using (var optionsForm = new frmOptions(_connectionInitiator, Show))
|
||||
using (var optionsForm = new frmOptions(_connectionInitiator, Show, _notificationAreaIconBuilder))
|
||||
{
|
||||
optionsForm.ShowDialog(dockPanel);
|
||||
}
|
||||
@@ -74,7 +80,7 @@ namespace mRemoteNG.App
|
||||
break;
|
||||
case WindowType.Update:
|
||||
if (_updateForm == null || _updateForm.IsDisposed)
|
||||
_updateForm = new UpdateWindow();
|
||||
_updateForm = _updateWindowBuilder();
|
||||
_updateForm.Show(dockPanel);
|
||||
break;
|
||||
case WindowType.Help:
|
||||
|
||||
@@ -16,12 +16,15 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly ExternalToolsService _externalToolsService;
|
||||
|
||||
public ExternalAppsLoader(MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip, IConnectionInitiator connectionInitiator)
|
||||
public ExternalAppsLoader(MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip,
|
||||
IConnectionInitiator connectionInitiator, ExternalToolsService externalToolsService)
|
||||
{
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_externalToolsToolStrip = externalToolsToolStrip.ThrowIfNull(nameof(externalToolsToolStrip));
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_externalToolsService = externalToolsService.ThrowIfNull(nameof(externalToolsService));
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +90,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
|
||||
_messageCollector.AddMessage(MessageClass.InformationMsg, $"Adding External App: {extA.DisplayName} {extA.FileName} {extA.Arguments}", true);
|
||||
Runtime.ExternalToolsService.ExternalTools.Add(extA);
|
||||
_externalToolsService.ExternalTools.Add(extA);
|
||||
}
|
||||
|
||||
_externalToolsToolStrip.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly MultiSshToolStrip _multiSshToolStrip;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
|
||||
private FrmMain MainForm { get; }
|
||||
|
||||
@@ -34,15 +34,16 @@ namespace mRemoteNG.Config.Settings
|
||||
QuickConnectToolStrip quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
IConnectionInitiator connectionInitiator)
|
||||
ExternalAppsLoader externalAppsLoader,
|
||||
Func<NotificationAreaIcon> notificationAreaIconBuilder)
|
||||
{
|
||||
MainForm = mainForm.ThrowIfNull(nameof(mainForm));
|
||||
MainForm = mainForm.ThrowIfNull(nameof(mainForm));
|
||||
_messageCollector = messageCollector.ThrowIfNull(nameof(messageCollector));
|
||||
_quickConnectToolStrip = quickConnectToolStrip.ThrowIfNull(nameof(quickConnectToolStrip));
|
||||
_externalToolsToolStrip = externalToolsToolStrip.ThrowIfNull(nameof(externalToolsToolStrip));
|
||||
_multiSshToolStrip = multiSshToolStrip.ThrowIfNull(nameof(multiSshToolStrip));
|
||||
_externalAppsLoader = new ExternalAppsLoader(messageCollector, _externalToolsToolStrip, connectionInitiator.ThrowIfNull(nameof(connectionInitiator)));
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_externalAppsLoader = externalAppsLoader.ThrowIfNull(nameof(externalAppsLoader));
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder;
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
@@ -146,7 +147,7 @@ namespace mRemoteNG.Config.Settings
|
||||
private void SetShowSystemTrayIcon()
|
||||
{
|
||||
if (mRemoteNG.Settings.Default.ShowSystemTrayIcon)
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(MainForm, _connectionInitiator);
|
||||
Runtime.NotificationAreaIcon = _notificationAreaIconBuilder();
|
||||
}
|
||||
|
||||
private void SetPuttyPath()
|
||||
|
||||
@@ -9,9 +9,16 @@ using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
public static class SettingsSaver
|
||||
public class SettingsSaver
|
||||
{
|
||||
public static void SaveSettings(
|
||||
private readonly ExternalToolsService _externalToolsService;
|
||||
|
||||
public SettingsSaver(ExternalToolsService externalToolsService)
|
||||
{
|
||||
_externalToolsService = externalToolsService.ThrowIfNull(nameof(externalToolsService));
|
||||
}
|
||||
|
||||
public void SaveSettings(
|
||||
Control quickConnectToolStrip,
|
||||
ExternalToolsToolStrip externalToolsToolStrip,
|
||||
MultiSshToolStrip multiSshToolStrip,
|
||||
@@ -62,7 +69,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveExternalAppsToolbarLocation(ExternalToolsToolStrip externalToolsToolStrip)
|
||||
private void SaveExternalAppsToolbarLocation(ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.ExtAppsTBLocation = externalToolsToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.ExtAppsTBVisible = externalToolsToolStrip.Visible;
|
||||
@@ -74,7 +81,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveQuickConnectToolbarLocation(Control quickConnectToolStrip)
|
||||
private void SaveQuickConnectToolbarLocation(Control quickConnectToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.QuickyTBLocation = quickConnectToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.QuickyTBVisible = quickConnectToolStrip.Visible;
|
||||
@@ -85,7 +92,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveMultiSshToolbarLocation(MultiSshToolStrip multiSshToolStrip)
|
||||
private void SaveMultiSshToolbarLocation(MultiSshToolStrip multiSshToolStrip)
|
||||
{
|
||||
mRemoteNG.Settings.Default.MultiSshToolbarLocation = multiSshToolStrip.Location;
|
||||
mRemoteNG.Settings.Default.MultiSshToolbarVisible = multiSshToolStrip.Visible;
|
||||
@@ -96,7 +103,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static void SaveDockPanelLayout()
|
||||
private void SaveDockPanelLayout()
|
||||
{
|
||||
var panelLayoutXmlFilePath = SettingsFileInfo.SettingsPath + "\\" + SettingsFileInfo.LayoutFileName;
|
||||
var panelLayoutSaver = new DockPanelLayoutSaver(
|
||||
@@ -106,10 +113,10 @@ namespace mRemoteNG.Config.Settings
|
||||
panelLayoutSaver.Save();
|
||||
}
|
||||
|
||||
private static void SaveExternalApps()
|
||||
private void SaveExternalApps()
|
||||
{
|
||||
var externalAppsSaver = new ExternalAppsSaver();
|
||||
externalAppsSaver.Save(Runtime.ExternalToolsService.ExternalTools);
|
||||
externalAppsSaver.Save(_externalToolsService.ExternalTools);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,13 +16,16 @@ namespace mRemoteNG.Tools
|
||||
private readonly ToolStripMenuItem _cMenCons;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly FrmMain _frmMain;
|
||||
private readonly Shutdown _shutdown;
|
||||
|
||||
public bool Disposed { get; private set; }
|
||||
|
||||
public NotificationAreaIcon(FrmMain frmMain, IConnectionInitiator connectionInitiator)
|
||||
public NotificationAreaIcon(FrmMain frmMain, IConnectionInitiator connectionInitiator, Shutdown shutdown)
|
||||
{
|
||||
_frmMain = frmMain.ThrowIfNull(nameof(frmMain));
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_shutdown = shutdown.ThrowIfNull(nameof(shutdown));
|
||||
|
||||
try
|
||||
{
|
||||
_cMenCons = new ToolStripMenuItem
|
||||
@@ -124,9 +127,9 @@ namespace mRemoteNG.Tools
|
||||
_connectionInitiator.OpenConnection((ConnectionInfo) ((ToolStripMenuItem) sender).Tag);
|
||||
}
|
||||
|
||||
private static void cMenExit_Click(object sender, EventArgs e)
|
||||
private void cMenExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Shutdown.Quit();
|
||||
_shutdown.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,12 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
public partial class AppearancePage
|
||||
{
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
|
||||
public AppearancePage(IConnectionInitiator connectionInitiator)
|
||||
public AppearancePage(IConnectionInitiator connectionInitiator, Func<NotificationAreaIcon> notificationAreaIconBuilder)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder;
|
||||
InitializeComponent();
|
||||
base.ApplyTheme();
|
||||
}
|
||||
@@ -85,7 +87,7 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
{
|
||||
if (Runtime.NotificationAreaIcon == null)
|
||||
{
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(FrmMain.Default, _connectionInitiator);
|
||||
Runtime.NotificationAreaIcon = _notificationAreaIconBuilder();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -58,7 +58,11 @@ namespace mRemoteNG.UI.Forms
|
||||
private readonly Windows _windows;
|
||||
private readonly Startup _startup;
|
||||
private readonly Export _export;
|
||||
private readonly SettingsLoader _settingsLoader;
|
||||
private readonly SettingsSaver _settingsSaver;
|
||||
private readonly Shutdown _shutdown;
|
||||
private readonly ICredentialRepositoryList _credentialRepositoryList;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
|
||||
internal FullscreenHandler Fullscreen { get; set; }
|
||||
|
||||
@@ -83,15 +87,22 @@ namespace mRemoteNG.UI.Forms
|
||||
connectionTreeWindow.ConnectionTreeContextMenu = connectionTreeContextMenu;
|
||||
var errorAndInfoWindow = new ErrorAndInfoWindow(new DockContent(), connectionTreeWindow);
|
||||
var screenshotManagerWindow = new ScreenshotManagerWindow();
|
||||
_windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow, sshTransferWindow);
|
||||
var externalToolsService = new ExternalToolsService();
|
||||
_settingsSaver = new SettingsSaver(externalToolsService);
|
||||
_shutdown = new Shutdown(_settingsSaver);
|
||||
Func<UpdateWindow> updateWindowBuilder = () => new UpdateWindow(new DockContent(), _shutdown);
|
||||
_notificationAreaIconBuilder = () => new NotificationAreaIcon(this, _connectionInitiator, _shutdown);
|
||||
_windows = new Windows(_connectionInitiator, connectionTreeWindow, configWindow, errorAndInfoWindow, screenshotManagerWindow, sshTransferWindow, updateWindowBuilder, _notificationAreaIconBuilder);
|
||||
_panelAdder = new PanelAdder(_windowList, _connectionInitiator, _windows);
|
||||
_showFullPathInTitle = Settings.Default.ShowCompleteConsPathInTitle;
|
||||
_connectionInitiator.Adder = _panelAdder;
|
||||
_startup = new Startup(this, _windows);
|
||||
connectionTreeContextMenu.ShowWindowAction = _windows.Show;
|
||||
connectionTreeContextMenu.ShowWindowAction = _windows.Show;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var externalAppsLoader = new ExternalAppsLoader(Runtime.MessageCollector, _externalToolsToolStrip, _connectionInitiator, externalToolsService);
|
||||
_settingsLoader = new SettingsLoader(this, Runtime.MessageCollector, _quickConnectToolStrip, _externalToolsToolStrip, _multiSshToolStrip, externalAppsLoader, _notificationAreaIconBuilder);
|
||||
_externalToolsToolStrip.GetSelectedConnectionFunc = () => SelectedConnection;
|
||||
_quickConnectToolStrip.ConnectionInitiator = _connectionInitiator;
|
||||
CredentialRecordTypeConverter.CredentialRepositoryList = _credentialRepositoryList;
|
||||
@@ -185,8 +196,7 @@ namespace mRemoteNG.UI.Forms
|
||||
SetMenuDependencies();
|
||||
|
||||
msMain.Location = Point.Empty;
|
||||
var settingsLoader = new SettingsLoader(this, messageCollector, _quickConnectToolStrip, _externalToolsToolStrip, _multiSshToolStrip, _connectionInitiator);
|
||||
settingsLoader.LoadSettings();
|
||||
_settingsLoader.LoadSettings();
|
||||
|
||||
var uiLoader = new DockPanelLayoutLoader(this, messageCollector, _windows);
|
||||
uiLoader.LoadPanelsFromXml();
|
||||
@@ -252,6 +262,7 @@ namespace mRemoteNG.UI.Forms
|
||||
mainFileMenu1.WindowList = _windowList;
|
||||
mainFileMenu1.Windows = _windows;
|
||||
mainFileMenu1.Export = _export;
|
||||
mainFileMenu1.Shutdown = _shutdown;
|
||||
|
||||
viewMenu1.TsExternalTools = _externalToolsToolStrip;
|
||||
viewMenu1.TsQuickConnect = _quickConnectToolStrip;
|
||||
@@ -319,7 +330,7 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
if (CTaskDialog.CommandButtonResult != 1) return;
|
||||
|
||||
using (var optionsForm = new frmOptions(_connectionInitiator, _windows.Show, Language.strTabUpdates))
|
||||
using (var optionsForm = new frmOptions(_connectionInitiator, _windows.Show, _notificationAreaIconBuilder, Language.strTabUpdates))
|
||||
{
|
||||
optionsForm.ShowDialog(this);
|
||||
}
|
||||
@@ -366,7 +377,7 @@ namespace mRemoteNG.UI.Forms
|
||||
}
|
||||
}
|
||||
|
||||
Shutdown.Cleanup(_quickConnectToolStrip, _externalToolsToolStrip, _multiSshToolStrip, this);
|
||||
_shutdown.Cleanup(_quickConnectToolStrip, _externalToolsToolStrip, _multiSshToolStrip, this);
|
||||
|
||||
IsClosing = true;
|
||||
|
||||
@@ -378,7 +389,7 @@ namespace mRemoteNG.UI.Forms
|
||||
}
|
||||
}
|
||||
|
||||
Shutdown.StartUpdate();
|
||||
_shutdown.StartUpdate();
|
||||
|
||||
Debug.Print("[END] - " + Convert.ToString(DateTime.Now, CultureInfo.InvariantCulture));
|
||||
}
|
||||
@@ -405,7 +416,7 @@ namespace mRemoteNG.UI.Forms
|
||||
if (!Settings.Default.MinimizeToTray) return;
|
||||
if (Runtime.NotificationAreaIcon == null)
|
||||
{
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(this, _connectionInitiator);
|
||||
Runtime.NotificationAreaIcon = new NotificationAreaIcon(this, _connectionInitiator, _shutdown);
|
||||
}
|
||||
Hide();
|
||||
}
|
||||
|
||||
@@ -16,18 +16,19 @@ namespace mRemoteNG.UI.Forms
|
||||
private readonly string _pageName;
|
||||
private readonly IConnectionInitiator _connectionInitiator;
|
||||
private readonly Action<WindowType> _showWindowAction;
|
||||
private readonly Func<NotificationAreaIcon> _notificationAreaIconBuilder;
|
||||
|
||||
|
||||
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction)
|
||||
: this(connectionInitiator, showWindowAction, Language.strStartupExit)
|
||||
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction, Func<NotificationAreaIcon> notificationAreaIconBuilder)
|
||||
: this(connectionInitiator, showWindowAction, notificationAreaIconBuilder, Language.strStartupExit)
|
||||
{
|
||||
}
|
||||
|
||||
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction, string pageName)
|
||||
public frmOptions(IConnectionInitiator connectionInitiator, Action<WindowType> showWindowAction, Func<NotificationAreaIcon> notificationAreaIconBuilder, string pageName)
|
||||
{
|
||||
_connectionInitiator = connectionInitiator.ThrowIfNull(nameof(connectionInitiator));
|
||||
_pageName = pageName.ThrowIfNull(nameof(pageName));
|
||||
_showWindowAction = showWindowAction.ThrowIfNull(nameof(showWindowAction));
|
||||
_notificationAreaIconBuilder = notificationAreaIconBuilder;
|
||||
_pageName = pageName.ThrowIfNull(nameof(pageName));
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ namespace mRemoteNG.UI.Forms
|
||||
_pages = new Dictionary<string, OptionsPage>
|
||||
{
|
||||
{typeof(StartupExitPage).Name, new StartupExitPage()},
|
||||
{typeof(AppearancePage).Name, new AppearancePage(_connectionInitiator)},
|
||||
{typeof(AppearancePage).Name, new AppearancePage(_connectionInitiator, _notificationAreaIconBuilder)},
|
||||
{typeof(TabsPanelsPage).Name, new TabsPanelsPage()},
|
||||
{typeof(NotificationsPage).Name, new NotificationsPage()},
|
||||
{typeof(ConnectionsPage).Name, new ConnectionsPage()},
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace mRemoteNG.UI.Menu
|
||||
public ConnectionTreeWindow TreeWindow { get; set; }
|
||||
public IConnectionInitiator ConnectionInitiator { get; set; }
|
||||
public Export Export { get; set; }
|
||||
public Shutdown Shutdown { get; set; }
|
||||
|
||||
public MainFileMenu()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.App.Update;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace mRemoteNG.UI.Window
|
||||
@@ -15,21 +16,17 @@ namespace mRemoteNG.UI.Window
|
||||
public partial class UpdateWindow : BaseWindow
|
||||
{
|
||||
private AppUpdater _appUpdate;
|
||||
private Shutdown _shutdown;
|
||||
private bool _isUpdateDownloadHandlerDeclared;
|
||||
|
||||
#region Public Methods
|
||||
public UpdateWindow() : this(new DockContent())
|
||||
{
|
||||
}
|
||||
|
||||
public UpdateWindow(DockContent panel)
|
||||
public UpdateWindow(DockContent panel, Shutdown shutdown)
|
||||
{
|
||||
WindowType = WindowType.Update;
|
||||
WindowType = WindowType.Update;
|
||||
DockPnl = panel;
|
||||
_shutdown = shutdown.ThrowIfNull(nameof(shutdown));
|
||||
InitializeComponent();
|
||||
FontOverrider.FontOverride(this);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Form Stuff
|
||||
|
||||
@@ -262,7 +259,7 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
if (MessageBox.Show(Language.strUpdateDownloadComplete, Language.strMenuCheckForUpdates, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
|
||||
{
|
||||
Shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath);
|
||||
_shutdown.Quit(_appUpdate.CurrentUpdateInfo.UpdateFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user