//----< 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(); } } }
//----< 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(); } } }
//----< Connect Button Click Event >---- private void btnConnect_Click(object sender, RoutedEventArgs e) { if (txtUsername.Text == "" || txtUsername.Text == " ") { 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 //userList = SwarmConnect(selfip, selfport, username, peerip, peerport); //userList = SwarmConnect1(selfip, selfport, username); //for prototype only 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 //i am making this as a function so that it can be used later if (txtPeerIP.Text == "" || txtPeerPort.Text == "") { MessageBox.Show("Please enter valid Peer IP/Port", "Peer IP/Port", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } //prototype ends ProgConf winProgConf = new ProgConf(); winProgConf.setUserList(userList); winProgConf.setUsername(txtUsername.Text); winProgConf.Show(); this.Close(); } }