Esempio n. 1
0
        void btnScan_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (_txtStartPort.Text == string.Empty || _txtStopPort.Text == string.Empty)
            {
                MessageBox.Show("Please enter a start port and a stop port");
            }
            else
            {
                if (btn.Text == "Scan")
                {
                    _worker = new BackgroundWorker();
                    _worker.WorkerReportsProgress      = true;
                    _worker.WorkerSupportsCancellation = true;
                    _worker.DoWork             += new DoWorkEventHandler(_worker_DoWork);
                    _worker.ProgressChanged    += new ProgressChangedEventHandler(_worker_ProgressChanged);
                    _worker.RunWorkerCompleted += _worker_RunWorkerCompleted;
                    _worker.RunWorkerAsync();

                    _txtScanOutput.Text = "";
                    _txtScanOutput.AppendText("Starting port scan..." + Environment.NewLine);
                    _txtScanOutput.AppendText("Port scanning host: " + _txtHost.Text + Environment.NewLine);
                    _txtScanOutput.AppendText(Environment.NewLine);

                    btn.Text = "Stop";
                }
                else
                {
                    _worker.CancelAsync();
                    btn.Text = "Scan";
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Appends text to the current text of a rich text box.
 /// </summary>
 /// <param name="text">The text to append to the current contents of the text box.</param>
 public void AppendText(string text)
 {
     _textBox.AppendText(text);
 }