FrmTunnelTCP: Replace ListBox with CtrOutput.

This commit is contained in:
2018-02-18 02:50:30 +01:00
parent c51354ce91
commit fe45ffd4ce
2 changed files with 19 additions and 33 deletions

View File

@@ -36,7 +36,7 @@
this.txtRemoteHost = new System.Windows.Forms.TextBox();
this.txtRemotePort = new System.Windows.Forms.TextBox();
this.txtLocalPort = new System.Windows.Forms.TextBox();
this.lsbOutput = new System.Windows.Forms.ListBox();
this.ctrOutput = new VAR.Toolbox.Controls.CtrOutput();
this.SuspendLayout();
//
// btnRun
@@ -113,22 +113,20 @@
//
// lsbOutput
//
this.lsbOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.ctrOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lsbOutput.FormattingEnabled = true;
this.lsbOutput.ItemHeight = 20;
this.lsbOutput.Location = new System.Drawing.Point(12, 108);
this.lsbOutput.Name = "lsbOutput";
this.lsbOutput.Size = new System.Drawing.Size(427, 244);
this.lsbOutput.TabIndex = 8;
this.ctrOutput.Location = new System.Drawing.Point(12, 108);
this.ctrOutput.Name = "lsbOutput";
this.ctrOutput.Size = new System.Drawing.Size(427, 244);
this.ctrOutput.TabIndex = 8;
//
// FrmTunnelTCP
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(451, 425);
this.Controls.Add(this.lsbOutput);
this.Controls.Add(this.ctrOutput);
this.Controls.Add(this.txtLocalPort);
this.Controls.Add(this.txtRemotePort);
this.Controls.Add(this.txtRemoteHost);
@@ -156,6 +154,6 @@
private System.Windows.Forms.TextBox txtRemoteHost;
private System.Windows.Forms.TextBox txtRemotePort;
private System.Windows.Forms.TextBox txtLocalPort;
private System.Windows.Forms.ListBox lsbOutput;
private VAR.Toolbox.Controls.CtrOutput ctrOutput;
}
}

View File

@@ -44,7 +44,7 @@ namespace VAR.Toolbox.UI
_running = true;
btnStop.Enabled = true;
btnRun.Enabled = false;
lsbOutput.Items.Clear();
ctrOutput.Clean();
string remoteHost = txtRemoteHost.Text;
int remotePort = Convert.ToInt32(txtRemotePort.Text);
@@ -57,18 +57,6 @@ namespace VAR.Toolbox.UI
thread.Start();
}
private void lblOutput_AddText(string text)
{
if (lsbOutput.InvokeRequired)
{
lsbOutput.Invoke((MethodInvoker)(() => { lsbOutput.Items.Add(text); }));
}
else
{
lsbOutput.Items.Add(text);
}
}
private void TunnelTCP(string remoteHost, int remotePort, int localPort)
{
try
@@ -105,9 +93,9 @@ namespace VAR.Toolbox.UI
}
catch (Exception ex)
{
lblOutput_AddText("Excepcion: " + ex.Message);
lblOutput_AddText("Backtrace:");
lblOutput_AddText(ex.StackTrace);
ctrOutput.AddLine("Excepcion: " + ex.Message);
ctrOutput.AddLine("Backtrace:");
ctrOutput.AddLine(ex.StackTrace);
}
}
@@ -124,7 +112,7 @@ namespace VAR.Toolbox.UI
long totalRecv = 0;
// Info
lblOutput_AddText(
ctrOutput.AddLine(
DateTime.Now.ToString() +
" Nuevo Cliente: " +
((IPEndPoint)clientSock.RemoteEndPoint).Address);
@@ -169,7 +157,7 @@ namespace VAR.Toolbox.UI
}
catch (Exception ex)
{
lblOutput_AddText("No se pudo enviar... (" + ex.Message + ")");
ctrOutput.AddLine("No se pudo enviar... (" + ex.Message + ")");
}
totalRecv += enviado;
} while (enviado <= 0 && remoteSock.Connected);
@@ -197,7 +185,7 @@ namespace VAR.Toolbox.UI
}
catch (Exception ex)
{
lblOutput_AddText("No se pudo enviar... (" + ex.Message + ")");
ctrOutput.AddLine("No se pudo enviar... (" + ex.Message + ")");
Thread.Sleep(10);
}
totalSent += enviado;
@@ -207,7 +195,7 @@ namespace VAR.Toolbox.UI
}
// Info
lblOutput_AddText(
ctrOutput.AddLine(
DateTime.Now.ToString() +
" Desconexion de cliente: " +
((IPEndPoint)clientSock.RemoteEndPoint).Address +
@@ -219,9 +207,9 @@ namespace VAR.Toolbox.UI
}
catch (Exception ex)
{
lblOutput_AddText("Excepcion: " + ex.Message);
lblOutput_AddText("Backtrace:");
lblOutput_AddText(ex.StackTrace);
ctrOutput.AddLine("Excepcion: " + ex.Message);
ctrOutput.AddLine("Backtrace:");
ctrOutput.AddLine(ex.StackTrace);
}
}