Ejemplo n.º 1
0
 private void MainDLG_Load(object sender, EventArgs e)
 {
     panelLogin.Enabled       = true;
     panelConnectData.Enabled = false;
     lblRX.Visible            = lblTX.Visible = lblRXTXErr.Visible = false;
     txtUsername.Text         = Settings.Default.LastUsername;
     txtServer.Text           = Settings.Default.LastServer;
     lblPing.Text             = "";
     this.Text = Program.Title;
     UpdateRXTXStat();
     if (Program.Connection == "server")
     {
         if (Program.Password == "*")
         {
             frmPassword frm = new frmPassword(Program.Server, Program.Username);
             if (frm.ShowDialog() != DialogResult.OK)
             {
                 this.Close();
                 return;
             }
             Program.Password = frm.Password;
         }
         txtServer.Text   = Program.Server;
         txtUsername.Text = Program.Username;
         txtPassword.Text = Program.Password;
         cmdConnect_Click(sender, e);
         if (panelConnectData.Enabled == false)
         {
             this.Close();
             return;
         }
         MID = Program.MachineID;
         txtListenOn.Text    = Program.LocalPort.ToString();
         txtConnectTo.Text   = Program.RemoteServer;
         txtConnectPort.Text = Program.RemotePort.ToString();
         cmdStart_Click(sender, e);
     }
     if (Program.Connection == "direct")
     {
         txtServer.Text = Program.Server;
         cmdConnect_Click(sender, e);
         if (panelConnectData.Enabled == false)
         {
             this.Close();
             return;
         }
         MID = Program.MachineID;
         ComputerData    d = Program.net.GetComputerDetail(MID);
         LSTComputerData c = new LSTComputerData("<<MID>> " + d.Computername, "", Program.MachineID);
         lstComputer.Items.Add(c);
         lstComputer.SelectedItem = c;
         txtListenOn.Text         = Program.LocalPort.ToString();
         txtConnectTo.Text        = Program.RemoteServer;
         txtConnectPort.Text      = Program.RemotePort.ToString();
         cmdStart_Click(sender, e);
     }
 }
Ejemplo n.º 2
0
        private void lstComputer_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstComputer.SelectedItem == null)
            {
                MID             = "";
                lblPing.Text    = "Status pending ..";
                picStatus.Image = Resources.Help.ToBitmap();
                return;
            }
            LSTComputerData c = (LSTComputerData)lstComputer.SelectedItem;

            MID             = c.ID;
            lblPing.Text    = "Status pending ..";
            picStatus.Image = Resources.Help.ToBitmap();
        }
Ejemplo n.º 3
0
        private void cmdStart_Click(object sender, EventArgs e)
        {
            LSTComputerData c = (LSTComputerData)lstComputer.SelectedItem;
            int             LocalPort;

            if (int.TryParse(txtListenOn.Text, out LocalPort) == false)
            {
                MessageBox.Show(this, "Invalid Listen on Number.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (LocalPort < 1 && LocalPort > 65535)
            {
                MessageBox.Show(this, "Invalid Listen on Number Range (must beween 1-65535).", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (txtConnectTo.Text.Trim() == "")
            {
                MessageBox.Show(this, "Connect to missing", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            int RemotePort;

            if (int.TryParse(txtConnectPort.Text, out RemotePort) == false)
            {
                MessageBox.Show(this, "Invalid Remote Port Number.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (RemotePort < 1 && LocalPort > 65535)
            {
                MessageBox.Show(this, "Invalid Remote Port Number Range (must beween 1-65535).", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            netc           = new NetworkConnection();
            netc.OnRXTX   += Netc_OnRXTX;
            netc.OnStatus += Netc_OnStatus;
            if (netc.StartConnection(Program.net.CloneElement(), c.ID, LocalPort, txtConnectTo.Text.Trim(), RemotePort) == false)
            {
                MessageBox.Show(this, "Connection failed.", Program.Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            panelConnectData.Enabled = false;
        }