Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1193 → Rev 1194

/TCPproxy/trunk/ListenForm.cs
0,0 → 1,84
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
 
namespace TCPproxy
{
public partial class ListenForm : Form
{
private int listenPort;
private string resendHost;
private IPAddress resendIp;
private int resendPort;
 
public ListenForm()
{
InitializeComponent();
}
 
public bool Execute(Form owner,
ref int listenPort, ref string resendHost, out IPAddress resendIp, ref int resendPort)
{
listenPortBox.Text = (listenPort == 0) ? "" : listenPort.ToString();
resendHostBox.Text = resendHost;
resendPortBox.Text = (resendPort == 0) ? "" : resendPort.ToString();
 
if(this.ShowDialog(owner) != DialogResult.OK) {
resendIp = null;
return false;
}
 
listenPort = this.listenPort;
resendHost = this.resendHost;
resendIp = this.resendIp;
resendPort = this.resendPort;
 
return true;
}
 
private void startButton_Click(object sender, EventArgs e)
{
// parse listen port
try
{
listenPort = int.Parse(listenPortBox.Text);
}
catch(FormatException)
{
MessageBox.Show("Listen port must be an integer number");
return;
}
 
// get resend host
try
{
resendIp = HostUtils.ResendHostToIp(resendHostBox.Text);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
resendHost = resendHostBox.Text;
// parse resend port
try
{
resendPort = int.Parse(resendPortBox.Text);
}
catch(FormatException)
{
MessageBox.Show("Resend port must be an integer number");
return;
}
 
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}