예제 #1
0
파일: frmRegister.cs 프로젝트: kanhar/xna
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (!txtPassword_2.Text.ToString().Equals(txtPassword.Text.ToString()))
            {
                MessageBox.Show("Error: Passwords dont match");
                return;
            }

            try
            {
                User myUser = new User();
                myUser.Email = txtEmail.Text;
                myUser.CostPerGame = 1.0;
                myUser.Balance = 50;
                myUser.Password = txtPassword.Text;
                myUser.UserName = txtUsername.Text;
                myUser.ImageURL = Helper.GetImageDirectory() + "\\" +  txtImage.Text;

                UserList myUserList = new UserList();
                XMLHelper<UserList> myXML = new XMLHelper<UserList>();
                myXML.Load(ref myUserList);
                if(myUserList.FindName(myUser.UserName) == -1)
                {
                    myUserList.AddItem(myUser);
                    myXML.Save(myUserList);
                    this.Dispose();
                    if (WriteInHome != null)
                        WriteInHome();
                }
                else
                {
                    MessageBox.Show("This Username has been Taken, Please Select Another Name");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occurred: " + ex.Message.ToString());
                return;
            }
        }
예제 #2
0
파일: frmPRHome.cs 프로젝트: kanhar/xna
        void myProgram_GameEnded(Object obj)
        {
            if (this.InvokeRequired)
            {
                 this.Invoke(new MethodInvoker(delegate { this.Visible = true; }));
                 txtPass2.Invoke(new MethodInvoker(delegate { txtPass2.Text = ""; }));
                 String Msg = "At this point ControlPasses back to the main Form, along with an object which represents the updated list of the two players that were playing the game";
                 MessageBox.Show(Msg);
                 GamePlayers myGame = new GamePlayers();
                 UserList myUserList = new UserList();
                 XMLHelper<GamePlayers> myXMLGame = new XMLHelper<GamePlayers>();
                 XMLHelper<UserList> myXMLUser = new XMLHelper<UserList>();

                 myXMLGame.Load(ref myGame);
                 myXMLUser.Load(ref myUserList);

                 if (myGame.myPlayers.Length > 0)
                 {
                     int one = myUserList.FindName(myGame.myPlayers[0].UserName);
                     int two = myUserList.FindName(myGame.myPlayers[1].UserName);
                     myUserList.myUsers[one].TotalWins = myUserList.myUsers[one].TotalWins + myGame.myPlayers[0].TotalWins;
                     myUserList.myUsers[one].TotalGames = myUserList.myUsers[one].TotalGames + myGame.myPlayers[0].TotalGames;

                     myUserList.myUsers[two].TotalWins = myUserList.myUsers[two].TotalWins + myGame.myPlayers[1].TotalWins;
                     myUserList.myUsers[two].TotalGames = myUserList.myUsers[two].TotalGames + myGame.myPlayers[1].TotalGames;

                     myXMLUser.Save(myUserList);

                 }
            }
        }
예제 #3
0
파일: frmPRViewUser.cs 프로젝트: kanhar/xna
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!txtPassword_2.Text.ToString().Equals(txtPassword.Text.ToString()))
            {
                MessageBox.Show("Error: Passwords dont match");
                return;
            }

            try
            {
                User myUser = new User();
                myUser.Email = txtEmail.Text;
                myUser.ImageURL = SelectedImageURL;
                myUser.Password = txtPassword.Text;
                myUser.IsApproved = true;
                myUser.UserName = txtUsername.Text;
                myUser.ImageURL = txtImage.Text;

                UserList myUserList = new UserList();
                XMLHelper<UserList> myXML = new XMLHelper<UserList>();
                myXML.Load(ref myUserList);
                int Index = myUserList.FindName(myUser.UserName);
                if (Index != -1)
                {
                    myUserList.RemoveItem(Index);
                    myUserList.AddItem(myUser);
                    myXML.Save(myUserList);
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Error: This username does not exist");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Occurred: " + ex.Message.ToString());
                return;
            }
        }