Builds and basically works

This commit is contained in:
Brandon Wulf
2017-07-14 18:16:27 -07:00
parent 88961fbdb5
commit 49390574bf
11 changed files with 428 additions and 17 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);
@@ -378,6 +381,11 @@ namespace mRemoteNG.App
/// </summary>
public const int WM_KEYUP = 0x101;
/// <summary>
///
/// </summary>
public const int WM_CHAR = 0x102;
/// <summary>
///
/// </summary>

View File

@@ -18,6 +18,8 @@ namespace mRemoteNG.App
private static DockContent _helpPanel = new DockContent();
private static ExternalToolsWindow _externalappsForm;
private static DockContent _externalappsPanel = new DockContent();
private static SSHCommandWIndow _sshcommandForm;
private static DockContent _sshcommandPanel = new DockContent();
private static PortScanWindow _portscanForm;
private static DockContent _portscanPanel = new DockContent();
private static UltraVNCWindow _ultravncscForm;
@@ -33,6 +35,8 @@ namespace mRemoteNG.App
public static DockContent ErrorsPanel { get; set; } = new DockContent();
public static ScreenshotManagerWindow ScreenshotForm { get; set; }
public static DockContent ScreenshotPanel { get; set; } = new DockContent();
public static SSHCommandWIndow SSHCommandForm { get; set; }
public static DockContent SSHCommandPanel { get; set; } = new DockContent();
public static UpdateWindow UpdateForm { get; set; }
public static DockContent UpdatePanel { get; set; } = new DockContent();
public static SSHTransferWindow SshtransferForm { get; set; }
@@ -100,6 +104,15 @@ namespace mRemoteNG.App
}
_externalappsForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.SSHCommandWindow))
{
if (_sshcommandForm == null || _sshcommandForm.IsDisposed)
{
_sshcommandForm = new SSHCommandWIndow(_sshcommandPanel);
_sshcommandPanel = _sshcommandForm;
}
_externalappsForm.Show(frmMain.Default.pnlDock);
}
else if (windowType.Equals(WindowType.PortScan))
{
_portscanForm = new PortScanWindow(_portscanPanel);

View File

@@ -76,6 +76,9 @@ namespace mRemoteNG.Config.Settings
if (persistString == typeof(ScreenshotManagerWindow).ToString())
return Windows.ScreenshotPanel;
if (persistString == typeof(SSHCommandWIndow).ToString())
return Windows.SSHCommandPanel;
}
catch (Exception ex)
{
@@ -99,6 +102,9 @@ namespace mRemoteNG.Config.Settings
Windows.ScreenshotForm = new ScreenshotManagerWindow(Windows.ScreenshotPanel);
Windows.ScreenshotPanel = Windows.ScreenshotForm;
Windows.SSHCommandForm = new SSHCommandWIndow(Windows.SSHCommandPanel);
Windows.SSHCommandPanel = Windows.SSHCommandForm;
Windows.UpdateForm = new UpdateWindow(Windows.UpdatePanel);
Windows.UpdatePanel = Windows.UpdateForm;
}

View File

@@ -22,7 +22,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

@@ -61,6 +61,7 @@ namespace mRemoteNG.UI.Forms
this.mMenViewConfig = new System.Windows.Forms.ToolStripMenuItem();
this.mMenViewErrorsAndInfos = new System.Windows.Forms.ToolStripMenuItem();
this.mMenViewScreenshotManager = new System.Windows.Forms.ToolStripMenuItem();
this.mMenViewMultiPuttyCommand = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.mMenViewJumpTo = new System.Windows.Forms.ToolStripMenuItem();
this.mMenViewJumpToConnectionsConfig = new System.Windows.Forms.ToolStripMenuItem();
@@ -336,6 +337,7 @@ namespace mRemoteNG.UI.Forms
this.mMenViewConfig,
this.mMenViewErrorsAndInfos,
this.mMenViewScreenshotManager,
this.mMenViewMultiPuttyCommand,
this.ToolStripSeparator1,
this.mMenViewJumpTo,
this.mMenViewResetLayout,
@@ -406,6 +408,13 @@ namespace mRemoteNG.UI.Forms
this.mMenViewScreenshotManager.Size = new System.Drawing.Size(228, 22);
this.mMenViewScreenshotManager.Text = "Screenshot Manager";
this.mMenViewScreenshotManager.Click += new System.EventHandler(this.mMenViewScreenshotManager_Click);
//
// mMenViewMultiPuttyCommand
//
this.mMenViewMultiPuttyCommand.Name = "mMenViewMultiPuttyCommand";
this.mMenViewMultiPuttyCommand.Size = new System.Drawing.Size(228, 22);
this.mMenViewMultiPuttyCommand.Text = "Multi Putty Commander";
this.mMenViewMultiPuttyCommand.Click += new System.EventHandler(this.mMenViewMultiPuttyCommand_Click);
//
// ToolStripSeparator1
//
@@ -842,6 +851,7 @@ namespace mRemoteNG.UI.Forms
internal System.Windows.Forms.ToolStripMenuItem mMenInfoDonate;
internal System.Windows.Forms.ToolStripSeparator mMenViewSep3;
internal ToolStripSplitButton btnQuickConnect;
internal System.Windows.Forms.ToolStripMenuItem mMenViewMultiPuttyCommand;
internal System.Windows.Forms.ToolStripMenuItem mMenViewJumpTo;
internal System.Windows.Forms.ToolStripMenuItem mMenViewJumpToConnectionsConfig;
internal System.Windows.Forms.ToolStripMenuItem mMenViewJumpToErrorsInfos;

View File

@@ -705,6 +705,7 @@ namespace mRemoteNG.UI.Forms
mMenViewConfig.Checked = !Windows.ConfigForm.IsHidden;
mMenViewErrorsAndInfos.Checked = !Windows.ErrorsForm.IsHidden;
mMenViewScreenshotManager.Checked = !Windows.ScreenshotForm.IsHidden;
mMenViewMultiPuttyCommand.Checked = !Windows.SSHCommandPanel.IsHidden;
mMenViewExtAppsToolbar.Checked = tsExternalTools.Visible;
mMenViewQuickConnectToolbar.Checked = tsQuickConnect.Visible;
@@ -783,6 +784,20 @@ namespace mRemoteNG.UI.Forms
}
}
private void mMenViewMultiPuttyCommand_Click(object sender, EventArgs e)
{
if (mMenViewMultiPuttyCommand.Checked == false)
{
Windows.SSHCommandPanel.Show(pnlDock);
mMenViewMultiPuttyCommand.Checked = true;
}
else
{
Windows.SSHCommandPanel.Hide();
mMenViewMultiPuttyCommand.Checked = false;
}
}
private void mMenViewJumpToConnectionsConfig_Click(object sender, EventArgs e)
{
if (pnlDock.ActiveContent == Windows.TreePanel)

View File

@@ -0,0 +1,75 @@
namespace mRemoteNG.UI.Window
{
partial class SSHCommandWIndow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtSSHCommand = new System.Windows.Forms.RichTextBox();
this.lstCommands = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// txtSSHCommand
//
this.txtSSHCommand.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtSSHCommand.Location = new System.Drawing.Point(0, 0);
this.txtSSHCommand.MinimumSize = new System.Drawing.Size(0, 150);
this.txtSSHCommand.Name = "txtSSHCommand";
this.txtSSHCommand.Size = new System.Drawing.Size(821, 532);
this.txtSSHCommand.TabIndex = 0;
this.txtSSHCommand.Text = "";
this.txtSSHCommand.Enter += new System.EventHandler(this.txtSSHCommand_Enter);
this.txtSSHCommand.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSSHCommand_KeyDown);
this.txtSSHCommand.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtSSHCommand_KeyUp);
//
// lstCommands
//
this.lstCommands.Dock = System.Windows.Forms.DockStyle.Right;
this.lstCommands.FormattingEnabled = true;
this.lstCommands.ItemHeight = 16;
this.lstCommands.Location = new System.Drawing.Point(701, 0);
this.lstCommands.Name = "lstCommands";
this.lstCommands.Size = new System.Drawing.Size(120, 532);
this.lstCommands.TabIndex = 1;
this.lstCommands.Visible = false;
//
// SSHCommandWIndow
//
this.ClientSize = new System.Drawing.Size(821, 532);
this.Controls.Add(this.lstCommands);
this.Controls.Add(this.txtSSHCommand);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Name = "SSHCommandWIndow";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox txtSSHCommand;
private System.Windows.Forms.ListBox lstCommands;
}
}

View File

@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using mRemoteNG.Connection.Protocol;
using mRemoteNG.App;
using System.Collections;
using mRemoteNG.Connection;
namespace mRemoteNG.UI.Window
{
public partial class SSHCommandWIndow : BaseWindow
{
public SSHCommandWIndow(DockContent panel)
{
InitializeComponent();
WindowType = WindowType.SSHCommandWindow;
DockPnl = panel;
HideOnClose = true;
Icon = Resources.Screenshot_Icon;
Name = "SSHCommander";
TabText = "Multi-SSH";
Text = "Multi-SSH Commander";
}
#region Private Fields
private ArrayList processHandlers = new ArrayList();
#endregion
#region Public Methods
#region Event Handlers
private void SSHCommandWindow_Load(object sender, EventArgs e)
{
Control.CheckForIllegalCrossThreadCalls = false;
}
#endregion
private void txtSSHCommand_Enter(object sender, EventArgs e)
{
try
{
var connectionInfoList = Runtime.ConnectionTreeModel.GetRecursiveChildList();
//.Where( node-> !(node is Container.ContainerInfo));
var previouslyOpenedConnections = connectionInfoList.Where(item => item.OpenConnections.Count > 0);
//var connectionInfoList = connectionTree.GetRootConnectionNode().GetRecursiveChildList().Where(node => !(node is ContainerInfo));
//var previouslyOpenedConnections = connectionInfoList.Where(item => item.PleaseConnect);
//foreach (var connectionInfo in previouslyOpenedConnections)
//{
// _connectionInitiator.OpenConnection(connectionInfo);
//}
processHandlers.Clear();
foreach (ConnectionInfo connection in previouslyOpenedConnections)
{
foreach (ProtocolBase _base in connection.OpenConnections)
{
if (_base.GetType().IsSubclassOf(typeof(PuttyBase)))
{
processHandlers.Add((PuttyBase)_base);
}
}
}
}
catch (Exception ex)
{
}
}
private void txtSSHCommand_KeyDown(object sender, KeyEventArgs e)
{
if (processHandlers.Count == 0)
{
e.SuppressKeyPress = true;
return;
}
if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)
{
e.SuppressKeyPress = true;
//string lastCommand = "";
//if (lstCommands.SelectedIndex == lstCommands.Items.Count)
//{
// lastCommand = lstCommands.Items[lstCommands.Items.Count].ToString();
//}
if (e.KeyCode == Keys.Up && lstCommands.SelectedIndex -1 > -1 && lstCommands.SelectedItem.ToString() == txtSSHCommand.Text)
{
lstCommands.SelectedIndex -= 1;
}
if (e.KeyCode == Keys.Down && lstCommands.SelectedIndex + 1 < lstCommands.Items.Count)
{
lstCommands.SelectedIndex += 1;
}
txtSSHCommand.Text = lstCommands.SelectedItem.ToString();
txtSSHCommand.Select(txtSSHCommand.TextLength, 0);
}
if (e.Control == true && e.KeyCode != Keys.V && e.Alt == false)
{
sendAllKey(NativeMethods.WM_KEYDOWN, e.KeyValue);
}
if (e.KeyCode == Keys.Enter)
{
string strLine = txtSSHCommand.Text;
foreach (char chr1 in strLine)
{
sendAllKey(NativeMethods.WM_CHAR, Convert.ToByte(chr1));
}
sendAllKey(NativeMethods.WM_KEYDOWN, 13); // Enter = char13
}
}
private void gotoEndOfText()
{
if (txtSSHCommand.Text.Trim() != "")
{
lstCommands.Items.Add(txtSSHCommand.Text.Trim());
}
lstCommands.SelectedIndex = lstCommands.Items.Count - 1;
txtSSHCommand.Clear();
}
private void sendAllKey(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));
}
}
private void txtSSHCommand_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
gotoEndOfText();
}
}
}
#endregion
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -17,5 +17,6 @@ namespace mRemoteNG.UI
PortScan = 14,
UltraVNCSC = 16,
ComponentsCheck = 17,
SSHCommandWindow = 18,
}
}

View File

@@ -47,6 +47,12 @@
<ResolveComReferenceSilent>True</ResolveComReferenceSilent>
</PropertyGroup>
<ItemGroup>
<Reference Include="AxInterop.MSTSCLib">
<HintPath>References\AxInterop.MSTSCLib.dll</HintPath>
</Reference>
<Reference Include="AxInterop.WFICALib">
<HintPath>References\AxInterop.WFICALib.dll</HintPath>
</Reference>
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
@@ -59,6 +65,10 @@
<HintPath>..\packages\Geckofx45.45.0.22\lib\net40\Geckofx-Winforms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Interop.WFICALib">
<HintPath>References\Interop.WFICALib.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="ADTree, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -488,6 +498,12 @@
<Compile Include="UI\Window\ScreenshotManagerWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Window\SSHCommandWIndow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Window\SSHCommandWIndow.Designer.cs">
<DependentUpon>SSHCommandWIndow.cs</DependentUpon>
</Compile>
<Compile Include="UI\Window\SSHTransferWindow.cs">
<SubType>Form</SubType>
</Compile>
@@ -671,6 +687,9 @@
<DependentUpon>ScreenshotManagerWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="UI\Window\SSHCommandWIndow.resx">
<DependentUpon>SSHCommandWIndow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Window\SSHTransferWindow.resx">
<DependentUpon>SSHTransferWindow.cs</DependentUpon>
<SubType>Designer</SubType>
@@ -1219,14 +1238,6 @@
<WrapperTool>aximp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="AxWFICALib">
<Guid>{238F6F80-B8B4-11CF-8771-00A024541EE3}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>7</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>aximp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="MSTSCLib">
<Guid>{8C11EFA1-92C3-11D1-BC1E-00C04FA31489}</Guid>
<VersionMajor>1</VersionMajor>
@@ -1235,14 +1246,6 @@
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="WFICALib">
<Guid>{238F6F80-B8B4-11CF-8771-00A024541EE3}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>7</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib" />