mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-25 19:38:37 +08:00
moved external tools tool strip to a new class
This commit is contained in:
@@ -10,6 +10,7 @@ using mRemoteNG.UI.Window;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Security;
|
||||
@@ -41,7 +42,7 @@ namespace mRemoteNG.App
|
||||
public static RemoteConnectionsSyncronizer RemoteConnectionsSyncronizer { get; set; }
|
||||
// ReSharper disable once UnusedAutoPropertyAccessor.Local
|
||||
private static DateTime LastSqlUpdate { get; set; }
|
||||
public static ArrayList ExternalTools { get; set; } = new ArrayList();
|
||||
public static ObservableCollection<ExternalTool> ExternalTools { get; set; } = new ObservableCollection<ExternalTool>();
|
||||
public static SecureString EncryptionKey { get; set; } = new RootNodeInfo(RootNodeType.Connection).PasswordString.ConvertToSecureString();
|
||||
public static ConnectionTreeModel ConnectionTreeModel
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.Config.Putty;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
namespace mRemoteNG.App
|
||||
@@ -20,14 +21,14 @@ namespace mRemoteNG.App
|
||||
ProgramRoot.CloseSingletonInstanceMutex();
|
||||
}
|
||||
|
||||
public static void Cleanup(Control quickConnectToolStrip)
|
||||
public static void Cleanup(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
try
|
||||
{
|
||||
StopPuttySessionWatcher();
|
||||
DisposeNotificationAreaIcon();
|
||||
SaveConnections();
|
||||
SaveSettings(quickConnectToolStrip);
|
||||
SaveSettings(quickConnectToolStrip, externalToolsToolStrip);
|
||||
UnregisterBrowsers();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -53,9 +54,9 @@ namespace mRemoteNG.App
|
||||
Runtime.SaveConnections();
|
||||
}
|
||||
|
||||
private static void SaveSettings(Control quickConnectToolStrip)
|
||||
private static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip);
|
||||
Config.Settings.SettingsSaver.SaveSettings(quickConnectToolStrip, externalToolsToolStrip);
|
||||
}
|
||||
|
||||
private static void UnregisterBrowsers()
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.IO;
|
||||
using System.Xml;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
|
||||
namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
@@ -13,16 +14,20 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
private readonly FrmMain _mainForm;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector)
|
||||
public ExternalAppsLoader(FrmMain mainForm, MessageCollector messageCollector, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
if (messageCollector == null)
|
||||
throw new ArgumentNullException(nameof(messageCollector));
|
||||
if (externalToolsToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(externalToolsToolStrip));
|
||||
|
||||
_mainForm = mainForm;
|
||||
_messageCollector = messageCollector;
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,9 +86,8 @@ namespace mRemoteNG.Config.Settings
|
||||
Runtime.ExternalTools.Add(extA);
|
||||
}
|
||||
|
||||
_mainForm.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
|
||||
|
||||
FrmMain.Default.AddExternalToolsToToolBar();
|
||||
_externalToolsToolStrip.SwitchToolBarText(mRemoteNG.Settings.Default.ExtAppsTBShowText);
|
||||
_externalToolsToolStrip.AddExternalToolsToToolBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace mRemoteNG.Config.Settings
|
||||
}
|
||||
else
|
||||
{
|
||||
FrmMain.Default.SetDefaultLayout();
|
||||
_mainForm.SetDefaultLayout();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -21,11 +21,12 @@ namespace mRemoteNG.Config.Settings
|
||||
private readonly ExternalAppsLoader _externalAppsLoader;
|
||||
private readonly MessageCollector _messageCollector;
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
|
||||
private FrmMain MainForm { get; }
|
||||
|
||||
|
||||
public SettingsLoader(FrmMain mainForm, MessageCollector messageCollector, QuickConnectToolStrip quickConnectToolStrip)
|
||||
public SettingsLoader(FrmMain mainForm, MessageCollector messageCollector, QuickConnectToolStrip quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
if (mainForm == null)
|
||||
throw new ArgumentNullException(nameof(mainForm));
|
||||
@@ -33,12 +34,15 @@ namespace mRemoteNG.Config.Settings
|
||||
throw new ArgumentNullException(nameof(messageCollector));
|
||||
if (quickConnectToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(quickConnectToolStrip));
|
||||
if (externalToolsToolStrip == null)
|
||||
throw new ArgumentNullException(nameof(externalToolsToolStrip));
|
||||
|
||||
MainForm = mainForm;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector);
|
||||
_messageCollector = messageCollector;
|
||||
_quickConnectToolStrip = quickConnectToolStrip;
|
||||
}
|
||||
_externalToolsToolStrip = externalToolsToolStrip;
|
||||
_externalAppsLoader = new ExternalAppsLoader(MainForm, messageCollector, _externalToolsToolStrip);
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
public void LoadSettings()
|
||||
@@ -183,8 +187,8 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
ToolStripPanelFromString("top").Join(_quickConnectToolStrip, new Point(300, 0));
|
||||
_quickConnectToolStrip.Visible = true;
|
||||
ToolStripPanelFromString("bottom").Join(MainForm.tsExternalTools, new Point(3, 0));
|
||||
MainForm.tsExternalTools.Visible = false;
|
||||
ToolStripPanelFromString("bottom").Join(_externalToolsToolStrip, new Point(3, 0));
|
||||
_externalToolsToolStrip.Visible = false;
|
||||
}
|
||||
|
||||
private void LoadToolbarsFromSettings()
|
||||
@@ -209,8 +213,8 @@ namespace mRemoteNG.Config.Settings
|
||||
|
||||
private void AddDynamicPanels()
|
||||
{
|
||||
ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock).Join(MainForm.tsExternalTools, mRemoteNG.Settings.Default.ExtAppsTBLocation);
|
||||
MainForm.tsExternalTools.Visible = mRemoteNG.Settings.Default.ExtAppsTBVisible;
|
||||
ToolStripPanelFromString(mRemoteNG.Settings.Default.ExtAppsTBParentDock).Join(_externalToolsToolStrip, mRemoteNG.Settings.Default.ExtAppsTBLocation);
|
||||
_externalToolsToolStrip.Visible = mRemoteNG.Settings.Default.ExtAppsTBVisible;
|
||||
}
|
||||
|
||||
private ToolStripPanel ToolStripPanelFromString(string panel)
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using mRemoteNG.App.Info;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Forms;
|
||||
using static mRemoteNG.App.Runtime;
|
||||
|
||||
@@ -12,32 +13,32 @@ namespace mRemoteNG.Config.Settings
|
||||
{
|
||||
public static class SettingsSaver
|
||||
{
|
||||
public static void SaveSettings(Control quickConnectToolStrip)
|
||||
public static void SaveSettings(Control quickConnectToolStrip, ExternalToolsToolStrip externalToolsToolStrip)
|
||||
{
|
||||
try
|
||||
{
|
||||
var with1 = FrmMain.Default;
|
||||
var frmMain = FrmMain.Default;
|
||||
var windowPlacement = new WindowPlacement(FrmMain.Default);
|
||||
if (with1.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized)
|
||||
if (frmMain.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized)
|
||||
{
|
||||
with1.Opacity = 0;
|
||||
with1.WindowState = FormWindowState.Maximized;
|
||||
frmMain.Opacity = 0;
|
||||
frmMain.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
|
||||
mRemoteNG.Settings.Default.MainFormLocation = with1.Location;
|
||||
mRemoteNG.Settings.Default.MainFormSize = with1.Size;
|
||||
mRemoteNG.Settings.Default.MainFormLocation = frmMain.Location;
|
||||
mRemoteNG.Settings.Default.MainFormSize = frmMain.Size;
|
||||
|
||||
if (with1.WindowState != FormWindowState.Normal)
|
||||
if (frmMain.WindowState != FormWindowState.Normal)
|
||||
{
|
||||
mRemoteNG.Settings.Default.MainFormRestoreLocation = with1.RestoreBounds.Location;
|
||||
mRemoteNG.Settings.Default.MainFormRestoreSize = with1.RestoreBounds.Size;
|
||||
mRemoteNG.Settings.Default.MainFormRestoreLocation = frmMain.RestoreBounds.Location;
|
||||
mRemoteNG.Settings.Default.MainFormRestoreSize = frmMain.RestoreBounds.Size;
|
||||
}
|
||||
|
||||
mRemoteNG.Settings.Default.MainFormState = with1.WindowState;
|
||||
mRemoteNG.Settings.Default.MainFormState = frmMain.WindowState;
|
||||
|
||||
if (with1._fullscreen != null)
|
||||
if (frmMain._fullscreen != null)
|
||||
{
|
||||
mRemoteNG.Settings.Default.MainFormKiosk = with1._fullscreen.Value;
|
||||
mRemoteNG.Settings.Default.MainFormKiosk = frmMain._fullscreen.Value;
|
||||
}
|
||||
|
||||
mRemoteNG.Settings.Default.FirstStart = false;
|
||||
@@ -45,13 +46,13 @@ namespace mRemoteNG.Config.Settings
|
||||
mRemoteNG.Settings.Default.ResetToolbars = false;
|
||||
mRemoteNG.Settings.Default.NoReconnect = false;
|
||||
|
||||
mRemoteNG.Settings.Default.ExtAppsTBLocation = with1.tsExternalTools.Location;
|
||||
if (with1.tsExternalTools.Parent != null)
|
||||
mRemoteNG.Settings.Default.ExtAppsTBLocation = externalToolsToolStrip.Location;
|
||||
if (externalToolsToolStrip.Parent != null)
|
||||
{
|
||||
mRemoteNG.Settings.Default.ExtAppsTBParentDock = with1.tsExternalTools.Parent.Dock.ToString();
|
||||
mRemoteNG.Settings.Default.ExtAppsTBParentDock = externalToolsToolStrip.Parent.Dock.ToString();
|
||||
}
|
||||
mRemoteNG.Settings.Default.ExtAppsTBVisible = with1.tsExternalTools.Visible;
|
||||
mRemoteNG.Settings.Default.ExtAppsTBShowText = with1.cMenToolbarShowText.Checked;
|
||||
mRemoteNG.Settings.Default.ExtAppsTBVisible = externalToolsToolStrip.Visible;
|
||||
mRemoteNG.Settings.Default.ExtAppsTBShowText = externalToolsToolStrip.CMenToolbarShowText.Checked;
|
||||
|
||||
mRemoteNG.Settings.Default.QuickyTBLocation = quickConnectToolStrip.Location;
|
||||
if (quickConnectToolStrip.Parent != null)
|
||||
|
||||
133
mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs
Normal file
133
mRemoteV1/UI/Controls/ExternalToolsToolStrip.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Themes;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
|
||||
namespace mRemoteNG.UI.Controls
|
||||
{
|
||||
public class ExternalToolsToolStrip : ToolStrip
|
||||
{
|
||||
private IContainer components;
|
||||
private ContextMenuStrip _cMenExtAppsToolbar;
|
||||
internal ToolStripMenuItem CMenToolbarShowText;
|
||||
|
||||
public ExternalToolsToolStrip()
|
||||
{
|
||||
Initialize();
|
||||
ApplyThemes();
|
||||
Runtime.ExternalTools.CollectionChanged += (sender, args) => AddExternalToolsToToolBar();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
_cMenExtAppsToolbar = new ContextMenuStrip(components);
|
||||
CMenToolbarShowText = new ToolStripMenuItem();
|
||||
|
||||
//
|
||||
// tsExternalTools
|
||||
//
|
||||
ContextMenuStrip = _cMenExtAppsToolbar;
|
||||
Dock = DockStyle.None;
|
||||
Location = new System.Drawing.Point(39, 49);
|
||||
MaximumSize = new System.Drawing.Size(0, 25);
|
||||
Name = "tsExternalTools";
|
||||
Size = new System.Drawing.Size(111, 25);
|
||||
TabIndex = 17;
|
||||
//
|
||||
// cMenExtAppsToolbar
|
||||
//
|
||||
_cMenExtAppsToolbar.Items.Add(CMenToolbarShowText);
|
||||
_cMenExtAppsToolbar.Name = "cMenToolbar";
|
||||
_cMenExtAppsToolbar.Size = new System.Drawing.Size(129, 26);
|
||||
//
|
||||
// cMenToolbarShowText
|
||||
//
|
||||
CMenToolbarShowText.Checked = true;
|
||||
CMenToolbarShowText.CheckState = CheckState.Checked;
|
||||
CMenToolbarShowText.Name = "cMenToolbarShowText";
|
||||
CMenToolbarShowText.Size = new System.Drawing.Size(128, 22);
|
||||
CMenToolbarShowText.Text = Language.strMenuShowText;
|
||||
CMenToolbarShowText.Click += cMenToolbarShowText_Click;
|
||||
}
|
||||
|
||||
private void ApplyThemes()
|
||||
{
|
||||
BackColor = ThemeManager.ActiveTheme.ToolbarBackgroundColor;
|
||||
ForeColor = ThemeManager.ActiveTheme.ToolbarTextColor;
|
||||
}
|
||||
|
||||
#region Ext Apps Toolbar
|
||||
private void cMenToolbarShowText_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchToolBarText(!CMenToolbarShowText.Checked);
|
||||
}
|
||||
|
||||
public void AddExternalToolsToToolBar()
|
||||
{
|
||||
try
|
||||
{
|
||||
for (var index = Items.Count - 1; index >= 0; index--)
|
||||
Items[index].Dispose();
|
||||
Items.Clear();
|
||||
|
||||
foreach (var tool in Runtime.ExternalTools)
|
||||
{
|
||||
var button = (ToolStripButton)Items.Add(tool.DisplayName, tool.Image, tsExtAppEntry_Click);
|
||||
if (CMenToolbarShowText.Checked)
|
||||
button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
|
||||
else
|
||||
button.DisplayStyle = button.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.ImageAndText;
|
||||
|
||||
button.Tag = tool;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(Language.strErrorAddExternalToolsToToolBarFailed, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void tsExtAppEntry_Click(object sender, EventArgs e)
|
||||
{
|
||||
var extA = (ExternalTool)((ToolStripButton)sender).Tag;
|
||||
|
||||
var selectedTreeNode = Windows.TreeForm.SelectedNode;
|
||||
if (selectedTreeNode != null && (selectedTreeNode.GetTreeNodeType() == TreeNodeType.Connection | selectedTreeNode.GetTreeNodeType() == TreeNodeType.PuttySession))
|
||||
extA.Start(selectedTreeNode);
|
||||
else
|
||||
extA.Start();
|
||||
}
|
||||
|
||||
public void SwitchToolBarText(bool show)
|
||||
{
|
||||
foreach (ToolStripButton tItem in Items)
|
||||
{
|
||||
if (show)
|
||||
tItem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
|
||||
else
|
||||
tItem.DisplayStyle = tItem.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.ImageAndText;
|
||||
}
|
||||
|
||||
CMenToolbarShowText.Checked = show;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
components?.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
mRemoteV1/UI/Forms/frmMain.Designer.cs
generated
35
mRemoteV1/UI/Forms/frmMain.Designer.cs
generated
@@ -35,15 +35,11 @@ namespace mRemoteNG.UI.Forms
|
||||
this.mMenInfo = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mMenSep3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.tsContainer = new System.Windows.Forms.ToolStripContainer();
|
||||
this.tsExternalTools = new System.Windows.Forms.ToolStrip();
|
||||
this.cMenExtAppsToolbar = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.cMenToolbarShowText = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tmrAutoSave = new System.Windows.Forms.Timer(this.components);
|
||||
this.msMain.SuspendLayout();
|
||||
this.tsContainer.ContentPanel.SuspendLayout();
|
||||
this.tsContainer.TopToolStripPanel.SuspendLayout();
|
||||
this.tsContainer.SuspendLayout();
|
||||
this.cMenExtAppsToolbar.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pnlDock
|
||||
@@ -71,15 +67,6 @@ namespace mRemoteNG.UI.Forms
|
||||
this.msMain.TabIndex = 16;
|
||||
this.msMain.Text = "Main Toolbar";
|
||||
//
|
||||
// cMenToolbarShowText
|
||||
//
|
||||
this.cMenToolbarShowText.Checked = true;
|
||||
this.cMenToolbarShowText.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cMenToolbarShowText.Name = "cMenToolbarShowText";
|
||||
this.cMenToolbarShowText.Size = new System.Drawing.Size(128, 22);
|
||||
this.cMenToolbarShowText.Text = "Show Text";
|
||||
this.cMenToolbarShowText.Click += new System.EventHandler(this.cMenToolbarShowText_Click);
|
||||
//
|
||||
// mMenSep3
|
||||
//
|
||||
this.mMenSep3.Name = "mMenSep3";
|
||||
@@ -102,24 +89,6 @@ namespace mRemoteNG.UI.Forms
|
||||
// tsContainer.TopToolStripPanel
|
||||
//
|
||||
this.tsContainer.TopToolStripPanel.Controls.Add(this.msMain);
|
||||
this.tsContainer.TopToolStripPanel.Controls.Add(this.tsExternalTools);
|
||||
//
|
||||
// tsExternalTools
|
||||
//
|
||||
this.tsExternalTools.ContextMenuStrip = this.cMenExtAppsToolbar;
|
||||
this.tsExternalTools.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.tsExternalTools.Location = new System.Drawing.Point(39, 49);
|
||||
this.tsExternalTools.MaximumSize = new System.Drawing.Size(0, 25);
|
||||
this.tsExternalTools.Name = "tsExternalTools";
|
||||
this.tsExternalTools.Size = new System.Drawing.Size(111, 25);
|
||||
this.tsExternalTools.TabIndex = 17;
|
||||
//
|
||||
// cMenExtAppsToolbar
|
||||
//
|
||||
//this.cMenExtAppsToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
//this.cMenToolbarShowText});
|
||||
this.cMenExtAppsToolbar.Name = "cMenToolbar";
|
||||
this.cMenExtAppsToolbar.Size = new System.Drawing.Size(129, 26);
|
||||
//
|
||||
// tmrAutoSave
|
||||
//
|
||||
@@ -150,7 +119,6 @@ namespace mRemoteNG.UI.Forms
|
||||
this.tsContainer.TopToolStripPanel.PerformLayout();
|
||||
this.tsContainer.ResumeLayout(false);
|
||||
this.tsContainer.PerformLayout();
|
||||
this.cMenExtAppsToolbar.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -160,11 +128,8 @@ namespace mRemoteNG.UI.Forms
|
||||
internal System.Windows.Forms.ToolStripMenuItem mMenView;
|
||||
internal System.Windows.Forms.ToolStripMenuItem mMenTools;
|
||||
internal System.Windows.Forms.ToolStripMenuItem mMenInfo;
|
||||
internal System.Windows.Forms.ToolStripMenuItem cMenToolbarShowText;
|
||||
internal System.Windows.Forms.ToolStripContainer tsContainer;
|
||||
internal System.Windows.Forms.Timer tmrAutoSave;
|
||||
internal System.Windows.Forms.ToolStrip tsExternalTools;
|
||||
internal System.Windows.Forms.ContextMenuStrip cMenExtAppsToolbar;
|
||||
internal System.Windows.Forms.ToolStripSeparator mMenSep3;
|
||||
private System.ComponentModel.IContainer components;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ using mRemoteNG.Credential;
|
||||
using mRemoteNG.Messages;
|
||||
using mRemoteNG.Themes;
|
||||
using mRemoteNG.Tools;
|
||||
using mRemoteNG.Tree;
|
||||
using mRemoteNG.UI.Controls;
|
||||
using mRemoteNG.UI.Menu;
|
||||
using mRemoteNG.UI.TaskDialog;
|
||||
@@ -43,7 +42,8 @@ namespace mRemoteNG.UI.Forms
|
||||
private readonly ScreenSelectionSystemMenu _screenSystemMenu;
|
||||
private ConnectionInfo _selectedConnection;
|
||||
internal FullscreenHandler _fullscreen { get; set; }
|
||||
private QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly QuickConnectToolStrip _quickConnectToolStrip;
|
||||
private readonly ExternalToolsToolStrip _externalToolsToolStrip;
|
||||
private readonly IConnectionInitiator _connectionInitiator = new ConnectionInitiator();
|
||||
private readonly string _credentialFilePath = Path.Combine(CredentialsFileInfo.CredentialsPath, CredentialsFileInfo.CredentialsFile);
|
||||
private readonly CredentialManager _credentialManager = Runtime.CredentialManager;
|
||||
@@ -57,7 +57,9 @@ namespace mRemoteNG.UI.Forms
|
||||
_fullscreen = new FullscreenHandler(this);
|
||||
pnlDock.Theme = new VS2012LightTheme();
|
||||
_screenSystemMenu = new ScreenSelectionSystemMenu(this);
|
||||
}
|
||||
_quickConnectToolStrip = new QuickConnectToolStrip(_connectionInitiator);
|
||||
_externalToolsToolStrip = new ExternalToolsToolStrip();
|
||||
}
|
||||
|
||||
static FrmMain()
|
||||
{
|
||||
@@ -134,16 +136,12 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
Startup.Instance.InitializeProgram(messageCollector);
|
||||
|
||||
_quickConnectToolStrip = new QuickConnectToolStrip(_connectionInitiator);
|
||||
tsContainer.TopToolStripPanel.Controls.Add(_quickConnectToolStrip);
|
||||
|
||||
var settingsLoader = new SettingsLoader(this, messageCollector, _quickConnectToolStrip);
|
||||
var settingsLoader = new SettingsLoader(this, messageCollector, _quickConnectToolStrip, _externalToolsToolStrip);
|
||||
settingsLoader.LoadSettings();
|
||||
|
||||
var uiLoader = new LayoutSettingsLoader(this, messageCollector);
|
||||
uiLoader.LoadPanelsFromXml();
|
||||
|
||||
ApplyLanguage();
|
||||
ThemeManager.ThemeChanged += ApplyThemes;
|
||||
ApplyThemes();
|
||||
|
||||
@@ -163,11 +161,13 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
_screenSystemMenu.BuildScreenList();
|
||||
SystemEvents.DisplaySettingsChanged += _screenSystemMenu.OnDisplayChanged;
|
||||
|
||||
|
||||
tsContainer.TopToolStripPanel.Controls.Add(_quickConnectToolStrip);
|
||||
tsContainer.TopToolStripPanel.Controls.Add(_externalToolsToolStrip);
|
||||
msMain.Items.AddRange(new ToolStripItem[]
|
||||
{
|
||||
new MainFileMenu(Windows.TreeForm, _connectionInitiator),
|
||||
new ViewMenu(tsExternalTools, _quickConnectToolStrip, _fullscreen, this),
|
||||
new ViewMenu(_externalToolsToolStrip, _quickConnectToolStrip, _fullscreen, this),
|
||||
new ToolsMenu(this, _credentialManager),
|
||||
new HelpMenu()
|
||||
});
|
||||
@@ -175,11 +175,6 @@ namespace mRemoteNG.UI.Forms
|
||||
Opacity = 1;
|
||||
}
|
||||
|
||||
private void ApplyLanguage()
|
||||
{
|
||||
cMenToolbarShowText.Text = Language.strMenuShowText;
|
||||
}
|
||||
|
||||
private void ApplyThemes()
|
||||
{
|
||||
pnlDock.DockBackColor = ThemeManager.ActiveTheme.WindowBackgroundColor;
|
||||
@@ -198,8 +193,6 @@ namespace mRemoteNG.UI.Forms
|
||||
msMain.BackColor = ThemeManager.ActiveTheme.ToolbarBackgroundColor;
|
||||
msMain.ForeColor = ThemeManager.ActiveTheme.ToolbarTextColor;
|
||||
ApplyMenuColors(msMain.Items);
|
||||
tsExternalTools.BackColor = ThemeManager.ActiveTheme.ToolbarBackgroundColor;
|
||||
tsExternalTools.ForeColor = ThemeManager.ActiveTheme.ToolbarTextColor;
|
||||
}
|
||||
|
||||
private static void ApplyMenuColors(IEnumerable itemCollection)
|
||||
@@ -284,7 +277,7 @@ namespace mRemoteNG.UI.Forms
|
||||
}
|
||||
}
|
||||
|
||||
Shutdown.Cleanup(_quickConnectToolStrip);
|
||||
Shutdown.Cleanup(_quickConnectToolStrip, _externalToolsToolStrip);
|
||||
|
||||
IsClosing = true;
|
||||
|
||||
@@ -310,77 +303,6 @@ namespace mRemoteNG.UI.Forms
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Ext Apps Toolbar
|
||||
private void cMenToolbarShowText_Click(object sender, EventArgs e)
|
||||
{
|
||||
SwitchToolBarText(!cMenToolbarShowText.Checked);
|
||||
}
|
||||
|
||||
public void AddExternalToolsToToolBar()
|
||||
{
|
||||
try
|
||||
{
|
||||
for (var index = tsExternalTools.Items.Count - 1; index >= 0; index--)
|
||||
{
|
||||
tsExternalTools.Items[index].Dispose();
|
||||
}
|
||||
tsExternalTools.Items.Clear();
|
||||
|
||||
foreach (ExternalTool tool in Runtime.ExternalTools)
|
||||
{
|
||||
var button = (ToolStripButton)tsExternalTools.Items.Add(tool.DisplayName, tool.Image, tsExtAppEntry_Click);
|
||||
|
||||
if (cMenToolbarShowText.Checked)
|
||||
{
|
||||
button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
|
||||
}
|
||||
else
|
||||
{
|
||||
button.DisplayStyle = button.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.ImageAndText;
|
||||
}
|
||||
|
||||
button.Tag = tool;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionStackTrace(Language.strErrorAddExternalToolsToToolBarFailed, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static void tsExtAppEntry_Click(object sender, EventArgs e)
|
||||
{
|
||||
var extA = (ExternalTool)((ToolStripButton)sender).Tag;
|
||||
|
||||
var selectedTreeNode = Windows.TreeForm.SelectedNode;
|
||||
if (selectedTreeNode.GetTreeNodeType() == TreeNodeType.Connection | selectedTreeNode.GetTreeNodeType() == TreeNodeType.PuttySession)
|
||||
{
|
||||
extA.Start(selectedTreeNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
extA.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void SwitchToolBarText(bool show)
|
||||
{
|
||||
foreach (ToolStripButton tItem in tsExternalTools.Items)
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
tItem.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
|
||||
}
|
||||
else
|
||||
{
|
||||
tItem.DisplayStyle = tItem.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.ImageAndText;
|
||||
}
|
||||
}
|
||||
|
||||
cMenToolbarShowText.Checked = show;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Window Overrides and DockPanel Stuff
|
||||
private void frmMain_ResizeBegin(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using mRemoteNG.App;
|
||||
using mRemoteNG.Tools;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
using mRemoteNG.UI.Forms;
|
||||
|
||||
@@ -21,7 +22,7 @@ namespace mRemoteNG.UI.Window
|
||||
#endregion
|
||||
|
||||
#region Private Fields
|
||||
private Tools.ExternalTool _selectedTool;
|
||||
private ExternalTool _selectedTool;
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
@@ -41,14 +42,14 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
try
|
||||
{
|
||||
var externalTool = new Tools.ExternalTool(Language.strExternalToolDefaultName);
|
||||
var externalTool = new ExternalTool(Language.strExternalToolDefaultName);
|
||||
Runtime.ExternalTools.Add(externalTool);
|
||||
UpdateToolsListView(externalTool);
|
||||
DisplayNameTextBox.Focus();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.NewTool_Click() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.NewTool_Click() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,19 +78,15 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
foreach (ListViewItem listViewItem in ToolsListView.SelectedItems)
|
||||
{
|
||||
var externalTool = listViewItem.Tag as Tools.ExternalTool;
|
||||
if (externalTool == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Runtime.ExternalTools.Remove(listViewItem.Tag);
|
||||
var externalTool = listViewItem.Tag as ExternalTool;
|
||||
if (externalTool == null) continue;
|
||||
Runtime.ExternalTools.Remove(externalTool);
|
||||
listViewItem.Remove();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.DeleteTool_Click() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.DeleteTool_Click() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +102,7 @@ namespace mRemoteNG.UI.Window
|
||||
if (ToolsListView.SelectedItems.Count == 1)
|
||||
{
|
||||
PropertiesGroupBox.Enabled = true;
|
||||
_selectedTool = ToolsListView.SelectedItems[0].Tag as Tools.ExternalTool;
|
||||
_selectedTool = ToolsListView.SelectedItems[0].Tag as ExternalTool;
|
||||
if (_selectedTool == null)
|
||||
{
|
||||
return;
|
||||
@@ -124,7 +121,7 @@ namespace mRemoteNG.UI.Window
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.ToolsListView_SelectedIndexChanged() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.ToolsListView_SelectedIndexChanged() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +152,7 @@ namespace mRemoteNG.UI.Window
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PropertyControl_ChangedOrLostFocus() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.PropertyControl_ChangedOrLostFocus() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +172,7 @@ namespace mRemoteNG.UI.Window
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.BrowseButton_Click() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.BrowseButton_Click() failed.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,16 +219,16 @@ namespace mRemoteNG.UI.Window
|
||||
LaunchToolMenuItem.Text = Language.strMenuLaunchExternalTool;
|
||||
}
|
||||
|
||||
private void UpdateToolsListView(Tools.ExternalTool selectTool = null)
|
||||
private void UpdateToolsListView(ExternalTool selectTool = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var selectedTools = new List<Tools.ExternalTool>();
|
||||
var selectedTools = new List<ExternalTool>();
|
||||
if (selectTool == null)
|
||||
{
|
||||
foreach (ListViewItem listViewItem in ToolsListView.SelectedItems)
|
||||
{
|
||||
var externalTool = listViewItem.Tag as Tools.ExternalTool;
|
||||
var externalTool = listViewItem.Tag as ExternalTool;
|
||||
if (externalTool != null)
|
||||
{
|
||||
selectedTools.Add(externalTool);
|
||||
@@ -246,7 +243,7 @@ namespace mRemoteNG.UI.Window
|
||||
ToolsListView.BeginUpdate();
|
||||
ToolsListView.Items.Clear();
|
||||
|
||||
foreach (Tools.ExternalTool externalTool in Runtime.ExternalTools)
|
||||
foreach (var externalTool in Runtime.ExternalTools)
|
||||
{
|
||||
var listViewItem = new ListViewItem {Text = externalTool.DisplayName};
|
||||
listViewItem.SubItems.Add(externalTool.FileName);
|
||||
@@ -264,12 +261,10 @@ namespace mRemoteNG.UI.Window
|
||||
}
|
||||
|
||||
ToolsListView.EndUpdate();
|
||||
|
||||
FrmMain.Default.AddExternalToolsToToolBar();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.PopulateToolsListView()", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.PopulateToolsListView()", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,16 +274,16 @@ namespace mRemoteNG.UI.Window
|
||||
{
|
||||
foreach (ListViewItem listViewItem in ToolsListView.SelectedItems)
|
||||
{
|
||||
var externalTool = listViewItem.Tag as Tools.ExternalTool;
|
||||
var externalTool = listViewItem.Tag as ExternalTool;
|
||||
|
||||
externalTool?.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Runtime.MessageCollector.AddExceptionMessage(message: "UI.Window.ExternalTools.LaunchTool() failed.", ex: ex, logOnly: true);
|
||||
Runtime.MessageCollector.AddExceptionMessage("UI.Window.ExternalTools.LaunchTool() failed.", ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,6 +297,9 @@
|
||||
<Compile Include="UI\Controls\CredentialRecordListBox.Designer.cs">
|
||||
<DependentUpon>CredentialRecordListBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\ExternalToolsToolStrip.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\Controls\FilteredPropertyGrid\FilteredPropertyGrid.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user