/// <summary> /// Handles the Click event of the Login control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnLogin_Click(object sender, EventArgs e) { Globals.Username = txtName.Text; //If the user leaves the name empty show some error message if (String.IsNullOrWhiteSpace(Globals.Username)) { MessageBox.Show("Please enter a valid username"); return; } //Lock the text area and login button for further editing txtName.Enabled = false; btnLogin.Enabled = false; #region Initialize uMundo org.umundo.core.Node node = new org.umundo.core.Node(); org.umundo.core.Discovery disc = new org.umundo.core.Discovery(Discovery.DiscoveryType.MDNS); disc.add(node); pub = new Publisher("coreGame"); FlyHunterGreeter greeter = new FlyHunterGreeter(Globals.Username); greeter.UpdateScoreLocal += new FlyHunterGreeter.UpdateScoreLocalDelegate(UpdateScoreBoard); pub.setGreeter(greeter); FlyHunterReceiver recv = new FlyHunterReceiver(); Globals.Players = new FlyHuntMessage(); Globals.Players.Names.Add(Globals.Username); Globals.Players.Scores.Add("0"); recv.UpdateScoreLocal += new FlyHunterReceiver.UpdateScoreLocalDelegate(UpdateScoreBoard); recv.RelocateFly += new FlyHunterReceiver.RelocateFlyDelegate(RelocateFly); Globals.sub = new Subscriber("coreGame"); Globals.sub.setReceiver(recv); node.addPublisher(pub); node.addSubscriber(Globals.sub); #endregion //Enable the main panel where fly appears panelMain.Enabled = true; }