Пример #1
0
 public Boolean AddItem(User myUser)
 {
     try
     {
         myActiveUserList.Add(myUser);
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
Пример #2
0
 public frmPRViewUser(User myUser)
 {
     InitializeComponent();
     txtEmail.Text = "";
     txtImage.Text = myUser.ImageURL;
     txtEmail.Text = myUser.Email;
     txtPassword.Text = myUser.Password;
     txtPassword.PasswordChar = '*';
     txtPassword_2.Text = myUser.Password;
     txtPassword_2.PasswordChar ='*';
     txtUsername.Text = myUser.UserName;
     txtUsername.Enabled= false;
     pictureBox1.ImageLocation = myUser.ImageURL;
     txtGamesWon.Text = myUser.TotalWins.ToString();
     txtTotalGames.Text= myUser.TotalGames.ToString();
     txtSkill.Text = myUser.GetSkill().ToString();
     Refresh();
     SelectedImageURL = myUser.ImageURL;
 }
Пример #3
0
 public frmHome(User myUserOne)
 {
     InitializeComponent();
     CurrentUser = myUserOne;
     RefreshSavedGames(CurrentUser);
     txtUser1.Text = myUserOne.UserName;
     myPlayers.AddItem(myUserOne);
     if (myUserOne.Balance <= 0)
     {
         lblLowBalance.Visible = true;
         lblLowBalance.Text = "Warning: Balance depleted, You will not be able to play Multiplayer Games";
     }
     else if(myUserOne.Balance/myUserOne.CostPerGame <= 3)
     {
         lblLowBalance.Visible = true;
         lblLowBalance.Text = "Warning: Balance is Low, At your current Cost Per Game, You can Play only 3 more Games";
     }
     else
     {
         lblLowBalance.Text = "";
         lblLowBalance.Visible = false;
     }
 }
Пример #4
0
 public void RefreshSavedGames(User myUser)
 {
     mySavedGamesXML.Load(ref mySavedGames);
     lblSavedGames.Visible = false;
     if (mySavedGames.myGames.Length == 0)
     {
         lblSavedGames.Visible = true;
         lblSavedGames.Text = "No Games Loaded for Current User";
     }
     else
     {
         for (int i = 0; i < mySavedGames.myGames.Length; i++)
         {
             SaveGame Current = mySavedGames.myGames[i];
             if (Current.Player1_Name.ToUpper().Equals(myUser.UserName.ToUpper()) || Current.Player2_Name.ToUpper().Equals(myUser.UserName.ToUpper()))
             {
                 cbSavedGames.Items.Add(Current.ToString());
             }
         }
     }
 }
Пример #5
0
        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;
            }
        }