setDetails() public method

Sets the username to be displayed on the screen. This is sent by the connection module.
public setDetails ( string SelfIP, string SelfPort, string user ) : void
SelfIP string Self IP Address
SelfPort string Self Port
user string username which was accepted by the swarm while connecting
return void
示例#1
0
    //----< Connect Button Click Event >----
    private void btnConnect_Click(object sender, RoutedEventArgs e)
    {
      bool conn = false;
      if (txtUsername.Text.Trim() == "")
      {
          MessageBox.Show("Please enter the Username", "Username", MessageBoxButton.OK, MessageBoxImage.Exclamation);
          txtUsername.Focus();
      }
      else if ((rdbCreateSwarm.IsChecked == false) && (rdbJoinSwarm.IsChecked == false))
      {
          MessageBox.Show("Please select the Swarm Type", "Swarm Type", MessageBoxButton.OK, MessageBoxImage.Exclamation);
          rdbCreateSwarm.Focus();
      }
      else
      {
          //Connect to the Swarm
          if (rdbJoinSwarm.IsChecked == true)
          {
//              userList.Add("Prateek : 129.234.234.0 : 8080");
//              userList.Add("Abhay : 129.234.908.0 : 4040");
//              userList.Add("Arun : 129.432.543.0 : 3030");
//              userList.Add("Rutu : 129.324.355.0 : 2020");
              //make sure whether the user has entered the peer ip and port
              if (txtPeerIP.Text.Trim() == "" || txtPeerPort.Text.Trim() == "")
              {
                  MessageBox.Show("Please enter valid Peer IP/Port", "Peer IP/Port", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                  return;
              }
              else
              {
                  //userList = SC.JoinSwarm(txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim(), txtPeerIP.Text.Trim(), txtPeerPort.Text.Trim());
                  conn = true;
              }
          }
          else if (rdbCreateSwarm.IsChecked == true)
          {
              //SC.CreateSwarm(txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim());
              conn = true;
          }
          //SWARM MUST TELL ME IF THE CONNECTION WAS SUCCESSFUL OR NOT
          //Go to the next Window
          if (conn == true)
          {
              ProgConf winProgConf = new ProgConf(/*SC*/);
              winProgConf.setUserList(userList);
              winProgConf.setDetails(txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim());
              winProgConf.Show();
              this.Close();
          }
      }
    }
示例#2
0
 //----< Connect Button Click Event >----
 private void btnConnect_Click(object sender, RoutedEventArgs e)
 {
   bool conn = false;
   if (txtUsername.Text.Trim() == "")
   {
       MessageBox.Show("Please enter the Username", "Username", MessageBoxButton.OK, MessageBoxImage.Exclamation);
       txtUsername.Focus();
   }
   else if ((rdbCreateSwarm.IsChecked == false) && (rdbJoinSwarm.IsChecked == false))
   {
       MessageBox.Show("Please select the Swarm Type", "Swarm Type", MessageBoxButton.OK, MessageBoxImage.Exclamation);
       rdbCreateSwarm.Focus();
   }
   else
   {
       //Connect to the Swarm
       if (rdbJoinSwarm.IsChecked == true)
       {
          //make sure whether the user has entered the peer ip and port
           if (txtPeerIP.Text.Trim() == "" || txtPeerPort.Text.Trim() == "")
           {
               MessageBox.Show("Please enter valid Peer IP/Port", "Peer IP/Port", MessageBoxButton.OK, MessageBoxImage.Exclamation);
               return;
           }
           else
           {
               conn = SC.Join_Swarm(txtPeerIP.Text.Trim(), txtPeerPort.Text.Trim(), txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim());
               if (!conn)
                   MessageBox.Show("Connection Problem", "Error in Connection", MessageBoxButton.OK, MessageBoxImage.Exclamation);
           }
       }
       else if (rdbCreateSwarm.IsChecked == true)
       {
           conn = SC.Create_Swarm(txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim());
           if(!conn)
               MessageBox.Show("Connection Problem", "Error in Connection", MessageBoxButton.OK, MessageBoxImage.Exclamation);
       }
       //SWARM MUST TELL ME IF THE CONNECTION WAS SUCCESSFUL OR NOT
       //Go to the next Window
       if (conn == true)
       {
           ProgConf winProgConf = new ProgConf(SC);
           winProgConf.Conn += new ConnectionNotification(UnHide);
           winProgConf.setUserList(userList);
           winProgConf.setDetails(txtSelfIP.Text.Trim(), txtPort.Text.Trim(), txtUsername.Text.Trim());
           winProgConf.Show();
           this.Hide();
       }
   }
 }