Merge branch '644_target' into develop

# Conflicts:
#	mRemoteV1/App/Windows.cs
#	mRemoteV1/UI/Forms/frmMain.Designer.cs
#	mRemoteV1/UI/Forms/frmMain.cs
#	mRemoteV1/UI/Forms/frmMain.resx
#	mRemoteV1/mRemoteV1.csproj
This commit is contained in:
David Sparer
2017-11-15 10:06:15 -06:00
9 changed files with 296 additions and 35 deletions

View File

@@ -44,6 +44,9 @@ namespace mRemoteNG.App
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, StringBuilder lParam);
@@ -379,7 +382,12 @@ namespace mRemoteNG.App
public const int WM_KEYUP = 0x101;
/// <summary>
///
/// Posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.
/// </summary>
public const int WM_CHAR = 0x102;
/// <summary>
/// Sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
/// </summary>
public const int WM_COMMAND = 0x111;

View File

@@ -23,7 +23,7 @@ namespace mRemoteNG.Connection.Protocol
protected Putty_SSHVersion PuttySSHVersion { private get; set; }
private IntPtr PuttyHandle { get; set; }
public IntPtr PuttyHandle { get; set; }
private Process PuttyProcess { get; set; }

View File

@@ -0,0 +1,152 @@
using System;
using System.Collections;
using System.Linq;
using System.Windows.Forms;
using mRemoteNG.App;
using mRemoteNG.Connection;
using mRemoteNG.Connection.Protocol;
namespace mRemoteNG.Tools
{
public class MultiSSHController
{
private ArrayList processHandlers = new ArrayList();
private ArrayList quickConnectConnections = new ArrayList();
private ArrayList previousCommands = new ArrayList();
private int previousCommandIndex = 0;
public int CommandHistoryLength { get; set; } = 100;
public MultiSSHController(TextBox txtBox)
{
DecorateTextBox(txtBox);
}
public MultiSSHController(ToolStripTextBox txtBox)
{
DecorateTextBox(txtBox.TextBox);
}
public void ProcessNewQuickConnect(ConnectionInfo connection)
{
quickConnectConnections.Add(connection);
}
private void DecorateTextBox(TextBox toBeDecorated)
{
toBeDecorated.Enter += refreshActiveConnections;
toBeDecorated.KeyDown += processKeyPress;
toBeDecorated.KeyUp += processKeyRelease;
}
private ArrayList ProcessOpenConnections(ConnectionInfo connection)
{
ArrayList handlers = new ArrayList();
foreach (ProtocolBase _base in connection.OpenConnections)
{
if (_base.GetType().IsSubclassOf(typeof(PuttyBase)))
{
handlers.Add((PuttyBase)_base);
}
}
return handlers;
}
private void SendAllKeystrokes(int keyType, int keyData)
{
if (processHandlers.Count == 0)
{
return;
}
foreach (PuttyBase proc in processHandlers)
{
NativeMethods.PostMessage(proc.PuttyHandle, keyType, new IntPtr(keyData), new IntPtr(0));
}
}
#region Event Processors
private void refreshActiveConnections(object sender, EventArgs e)
{
processHandlers.Clear();
foreach (ConnectionInfo connection in quickConnectConnections)
{
processHandlers.AddRange(ProcessOpenConnections(connection));
}
var connectionTreeConnections = Runtime.ConnectionsService.ConnectionTreeModel.GetRecursiveChildList().Where(item => item.OpenConnections.Count > 0);
foreach (ConnectionInfo connection in connectionTreeConnections)
{
processHandlers.AddRange(ProcessOpenConnections(connection));
}
}
private void processKeyPress(object sender, KeyEventArgs e)
{
TextBox txtMultiSSH = sender as TextBox;
if (txtMultiSSH == null) return;
if (processHandlers.Count == 0)
{
e.SuppressKeyPress = true;
return;
}
if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
{
e.SuppressKeyPress = true;
if (e.KeyCode == Keys.Up && previousCommandIndex - 1 >= 0)
{
previousCommandIndex -= 1;
}
if (e.KeyCode == Keys.Down && previousCommandIndex + 1 < previousCommands.Count)
{
previousCommandIndex += 1;
}
txtMultiSSH.Text = previousCommands[previousCommandIndex].ToString();
txtMultiSSH.Select(txtMultiSSH.TextLength, 0);
}
if (e.Control == true && e.KeyCode != Keys.V && e.Alt == false)
{
SendAllKeystrokes(NativeMethods.WM_KEYDOWN, e.KeyValue);
}
if (e.KeyCode == Keys.Enter)
{
string strLine = txtMultiSSH.Text;
foreach (char chr1 in strLine)
{
SendAllKeystrokes(NativeMethods.WM_CHAR, Convert.ToByte(chr1));
}
SendAllKeystrokes(NativeMethods.WM_KEYDOWN, 13); // Enter = char13
}
}
private void processKeyRelease(object sender, KeyEventArgs e)
{
TextBox txtMultiSSH = sender as TextBox;
if (txtMultiSSH == null) return;
if (e.KeyCode == Keys.Enter)
{
if (txtMultiSSH.Text.Trim() != "")
{
previousCommands.Add(txtMultiSSH.Text.Trim());
}
if (previousCommands.Count >= CommandHistoryLength)
{
previousCommands.RemoveAt(0);
}
previousCommandIndex = previousCommands.Count - 1;
txtMultiSSH.Clear();
}
}
#endregion
}
}

View File

@@ -0,0 +1,55 @@
using System.ComponentModel;
using System.Windows.Forms;
using mRemoteNG.Tools;
namespace mRemoteNG.UI.Controls
{
public class MultiSshToolStrip : ToolStrip
{
private IContainer components;
private ToolStripLabel _lblMultiSsh;
private ToolStripTextBox _txtMultiSsh;
private MultiSSHController _multiSshController;
public MultiSshToolStrip()
{
InitializeComponent();
_multiSshController = new MultiSSHController(_txtMultiSsh);
}
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
_lblMultiSsh = new ToolStripLabel();
_txtMultiSsh = new ToolStripTextBox();
SuspendLayout();
//
// lblMultiSSH
//
_lblMultiSsh.Name = "_lblMultiSsh";
_lblMultiSsh.Size = new System.Drawing.Size(77, 22);
_lblMultiSsh.Text = "Multi SSH:";
//
// txtMultiSSH
//
_txtMultiSsh.Name = "_txtMultiSsh";
_txtMultiSsh.Size = new System.Drawing.Size(300, 25);
_txtMultiSsh.ToolTipText = "Press ENTER to send. Ctrl+C is sent immediately.";
Items.AddRange(new ToolStripItem[] {
_lblMultiSsh,
_txtMultiSsh});
ResumeLayout(true);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
components?.Dispose();
}
base.Dispose(disposing);
}
}
}

View File

@@ -42,6 +42,7 @@ namespace mRemoteNG.UI.Forms
this.tsContainer = new System.Windows.Forms.ToolStripContainer();
this._externalToolsToolStrip = new mRemoteNG.UI.Controls.ExternalToolsToolStrip();
this._quickConnectToolStrip = new mRemoteNG.UI.Controls.QuickConnectToolStrip();
this._multiSshToolStrip = new mRemoteNG.UI.Controls.MultiSshToolStrip();
this.tmrAutoSave = new System.Windows.Forms.Timer(this.components);
this.vsToolStripExtender = new WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender(this.components);
this.msMain.SuspendLayout();
@@ -159,6 +160,7 @@ namespace mRemoteNG.UI.Forms
this.tsContainer.TopToolStripPanel.Controls.Add(this.msMain);
this.tsContainer.TopToolStripPanel.Controls.Add(this._externalToolsToolStrip);
this.tsContainer.TopToolStripPanel.Controls.Add(this._quickConnectToolStrip);
this.tsContainer.TopToolStripPanel.Controls.Add(this._multiSshToolStrip);
//
// _externalToolsToolStrip
//
@@ -183,6 +185,16 @@ namespace mRemoteNG.UI.Forms
this._quickConnectToolStrip.Size = new System.Drawing.Size(364, 25);
this._quickConnectToolStrip.TabIndex = 18;
//
// tsMultiSSH
//
this._multiSshToolStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this._multiSshToolStrip.Location = new System.Drawing.Point(_quickConnectToolStrip.Location.X + _quickConnectToolStrip.Width + 1, 0);
this._multiSshToolStrip.MinimumSize = new System.Drawing.Size(300, 0);
this._multiSshToolStrip.Name = "_multiSshToolStrip";
this._multiSshToolStrip.Size = new System.Drawing.Size(430, 25);
this._multiSshToolStrip.TabIndex = 0;
this._multiSshToolStrip.Dock = System.Windows.Forms.DockStyle.Right;
//
// tmrAutoSave
//
this.tmrAutoSave.Interval = 10000;
@@ -217,7 +229,6 @@ namespace mRemoteNG.UI.Forms
this.tsContainer.ResumeLayout(false);
this.tsContainer.PerformLayout();
this.ResumeLayout(false);
}
internal WeifenLuo.WinFormsUI.Docking.DockPanel pnlDock;
internal System.Windows.Forms.MenuStrip msMain;
@@ -235,6 +246,7 @@ namespace mRemoteNG.UI.Forms
private Menu.HelpMenu helpMenu1;
internal mRemoteNG.UI.Controls.QuickConnectToolStrip _quickConnectToolStrip;
internal mRemoteNG.UI.Controls.ExternalToolsToolStrip _externalToolsToolStrip;
internal mRemoteNG.UI.Controls.MultiSshToolStrip _multiSshToolStrip;
//theming support
private WeifenLuo.WinFormsUI.Docking.VisualStudioToolStripExtender vsToolStripExtender;
}

View File

@@ -181,6 +181,7 @@ namespace mRemoteNG.UI.Forms
viewMenu1.TsExternalTools = _externalToolsToolStrip;
viewMenu1.TsQuickConnect = _quickConnectToolStrip;
viewMenu1.TsMultiSsh = _multiSshToolStrip;
viewMenu1.FullscreenHandler = Fullscreen;
viewMenu1.MainForm = this;
@@ -190,7 +191,6 @@ namespace mRemoteNG.UI.Forms
_quickConnectToolStrip.ConnectionInitiator = connectionInitiator;
}
//Theming support
private void SetSchema()
{
@@ -208,11 +208,10 @@ namespace mRemoteNG.UI.Forms
vsToolStripExtender.SetStyle(msMain, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
vsToolStripExtender.SetStyle(_quickConnectToolStrip, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
vsToolStripExtender.SetStyle(_externalToolsToolStrip, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
vsToolStripExtender.SetStyle(_multiSshToolStrip, _themeManager.ActiveTheme.Version, _themeManager.ActiveTheme.Theme);
tsContainer.TopToolStripPanel.BackColor = _themeManager.ActiveTheme.ExtendedPalette.getColor("CommandBarMenuDefault_Background");
}
}
private void frmMain_Shown(object sender, EventArgs e)
{

View File

@@ -126,6 +126,9 @@
<metadata name="_quickConnectToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>177, 17</value>
</metadata>
<metadata name="_multiSshToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="tmrAutoSave.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>630, 17</value>
</metadata>

View File

@@ -7,7 +7,7 @@ using mRemoteNG.UI.Window;
namespace mRemoteNG.UI.Menu
{
public class ViewMenu : ToolStripMenuItem
public class ViewMenu : ToolStripMenuItem
{
private ToolStripMenuItem _mMenViewConnectionPanels;
private ToolStripSeparator _mMenViewSep1;
@@ -20,6 +20,7 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenViewFullscreen;
private ToolStripMenuItem _mMenViewExtAppsToolbar;
private ToolStripMenuItem _mMenViewQuickConnectToolbar;
private ToolStripMenuItem _mMenViewMultiSshToolbar;
private ToolStripSeparator _mMenViewSep3;
private ToolStripMenuItem _mMenViewJumpTo;
private ToolStripMenuItem _mMenViewJumpToConnectionsConfig;
@@ -27,9 +28,11 @@ namespace mRemoteNG.UI.Menu
private ToolStripMenuItem _mMenViewResetLayout;
private ToolStripSeparator _toolStripSeparator1;
private readonly PanelAdder _panelAdder;
public ToolStrip TsExternalTools { 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; }
@@ -39,7 +42,7 @@ namespace mRemoteNG.UI.Menu
Initialize();
ApplyLanguage();
_panelAdder = new PanelAdder();
}
}
private void Initialize()
{
@@ -57,7 +60,8 @@ namespace mRemoteNG.UI.Menu
_mMenViewSep2 = new ToolStripSeparator();
_mMenViewQuickConnectToolbar = new ToolStripMenuItem();
_mMenViewExtAppsToolbar = new ToolStripMenuItem();
_mMenViewSep3 = new ToolStripSeparator();
_mMenViewMultiSshToolbar = new ToolStripMenuItem();
_mMenViewSep3 = new ToolStripSeparator();
_mMenViewFullscreen = new ToolStripMenuItem();
_toolStripSeparator1 = new ToolStripSeparator();
@@ -78,6 +82,7 @@ namespace mRemoteNG.UI.Menu
_mMenViewSep2,
_mMenViewQuickConnectToolbar,
_mMenViewExtAppsToolbar,
_mMenViewMultiSshToolbar,
_mMenViewSep3,
_mMenViewFullscreen});
Name = "mMenView";
@@ -206,10 +211,18 @@ namespace mRemoteNG.UI.Menu
_mMenViewExtAppsToolbar.Size = new System.Drawing.Size(228, 22);
_mMenViewExtAppsToolbar.Text = "External Applications Toolbar";
_mMenViewExtAppsToolbar.Click += mMenViewExtAppsToolbar_Click;
//
// mMenViewSep3
//
_mMenViewSep3.Name = "mMenViewSep3";
//
// mMenViewMultiSSHToolbar
//
_mMenViewMultiSshToolbar.Image = Resources.Panels;
_mMenViewMultiSshToolbar.Name = "mMenViewMultiSSHToolbar";
_mMenViewMultiSshToolbar.Size = new System.Drawing.Size(279, 26);
_mMenViewMultiSshToolbar.Text = "Multi SSH Toolbar";
_mMenViewMultiSshToolbar.Click += mMenViewMultiSSHToolbar_Click;
//
// mMenViewSep3
//
_mMenViewSep3.Name = "mMenViewSep3";
_mMenViewSep3.Size = new System.Drawing.Size(225, 6);
//
// mMenViewFullscreen
@@ -250,8 +263,9 @@ namespace mRemoteNG.UI.Menu
_mMenViewExtAppsToolbar.Checked = TsExternalTools.Visible;
_mMenViewQuickConnectToolbar.Checked = TsQuickConnect.Visible;
_mMenViewMultiSshToolbar.Checked = TsMultiSsh.Visible;
_mMenViewConnectionPanels.DropDownItems.Clear();
_mMenViewConnectionPanels.DropDownItems.Clear();
for (var i = 0; i <= Runtime.WindowList.Count - 1; i++)
{
@@ -386,7 +400,21 @@ namespace mRemoteNG.UI.Menu
}
}
private void mMenViewFullscreen_Click(object sender, EventArgs e)
private void mMenViewMultiSSHToolbar_Click(object sender, EventArgs e)
{
if (_mMenViewMultiSshToolbar.Checked == false)
{
TsMultiSsh.Visible = true;
_mMenViewMultiSshToolbar.Checked = true;
}
else
{
TsMultiSsh.Visible = false;
_mMenViewMultiSshToolbar.Checked = false;
}
}
private void mMenViewFullscreen_Click(object sender, EventArgs e)
{
FullscreenHandler.Value = !FullscreenHandler.Value;
_mMenViewFullscreen.Checked = FullscreenHandler.Value;

View File

@@ -315,6 +315,7 @@
<Compile Include="Tools\ExternalToolsTypeConverter.cs" />
<Compile Include="Tools\CustomCollections\INotifyCollectionUpdated.cs" />
<Compile Include="Tools\Maybe.cs" />
<Compile Include="Tools\MultiSSHController.cs" />
<Compile Include="Tools\MouseClickSimulator.cs" />
<Compile Include="Tools\NotificationAreaIcon.cs" />
<Compile Include="Tools\ScanHost.cs" />
@@ -422,6 +423,9 @@
<Compile Include="UI\Controls\ConnectionTree\NameColumn.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\MultiSshToolStrip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Controls\PageSequence\ISequenceChangingNotifier.cs" />
<Compile Include="UI\Controls\NewPasswordWithVerification.cs">
<SubType>UserControl</SubType>
@@ -1516,18 +1520,18 @@
<Reference Include="mscorlib" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>:: When passing paths to powershell scripts, check if the path ends with a backslash "\"
:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
powershell -noprofile -command "sleep 2"
set /p buildenv=&lt;buildenv.tmp
set solutionDir=$(SolutionDir)\
set targetDir=%25cd%25
set psScriptsDir=$(SolutionDir)Tools
set certPath=$(CertPath)
set certPassword=$(CertPassword)
:: Call the post build powershell script
<PostBuildEvent>:: When passing paths to powershell scripts, check if the path ends with a backslash "\"
:: If it does, then the backslash may be interpreted as an escape character. Add another backslash to cancel the first one.
powershell -noprofile -command "sleep 2"
set /p buildenv=&lt;buildenv.tmp
set solutionDir=$(SolutionDir)\
set targetDir=%25cd%25
set psScriptsDir=$(SolutionDir)Tools
set certPath=$(CertPath)
set certPassword=$(CertPassword)
:: Call the post build powershell script
powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_mremotev1.ps1" -SolutionDir "%25solutionDir%25" -TargetDir "%25targetDir%25" -TargetFileName "mRemoteNG.exe" -ConfigurationName "%25buildenv%25" -CertificatePath "%25certPath%25" -CertificatePassword "%25certPassword%25" -ExcludeFromSigning "PuTTYNG.exe"</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
@@ -1580,12 +1584,12 @@ powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_mremo
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.targets" />
<PropertyGroup>
@@ -1598,4 +1602,4 @@ powershell.exe -ExecutionPolicy Bypass -File "%25psScriptsDir%25\postbuild_mremo
</PropertyGroup>
<Error Condition="!Exists('..\packages\Geckofx45.45.0.32\build\Geckofx45.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Geckofx45.45.0.32\build\Geckofx45.targets'))" />
</Target>
</Project>
</Project>