Beispiel #1
0
 private void Signout_Click(object sender, EventArgs e)
 {
     Data.SerializingXML.Serializing(user);
     Settings.Default.User     = null;
     Settings.Default.Password = null;
     Settings.Default.Save();
     LoginSignup.LoginForm sign = new LoginSignup.LoginForm(user);
     this.Hide();
     sign.ShowDialog();
     this.Close();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (IsUserUsed())
            {
                MessageBox.Show("This User already Used.");
            }

            else if (Password.Text == RPassword.Text && Password.Text != string.Empty && RPassword.Text != string.Empty && FName.Text != string.Empty)
            {
                try
                {
                    if (user.DataList == null)
                    {
                        System.IO.File.Copy(data.Patch, $"UserData\\PlayerImage\\PlayerImage0");
                        data.Patch        = $"UserData\\PlayerImage\\PlayerImage0";
                        pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
                    }
                    else
                    {
                        System.IO.File.Copy(data.Patch, $"UserData\\PlayerImage\\PlayerImage{user.DataList.Count}");
                        data.Patch        = $"UserData\\PlayerImage\\PlayerImage{user.DataList.Count}";
                        pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                data.FullName  = FName.Text;
                data.DateBirth = Bdate.Value;
                data.User      = User.Text;
                data.Password  = Password.Text;
                data.Lose      = 0;
                data.Win       = 0;
                data.Money     = 1000;
                data.Gold      = 200;
                if (male.Checked)
                {
                    data.Sex = male.Text;
                }
                else if (famale.Checked)
                {
                    data.Sex = famale.Text;
                }
                else
                {
                    MessageBox.Show("Please choose a gender.");
                }
                if (user.DataList == null)
                {
                    user.DataList = new List <Data.Data>();
                }
                user.DataList.Add(data);
                Data.SerializingXML.Serializing(user);
                LoginForm login = new LoginForm(user);
                this.Hide();
                login.ShowDialog();
                this.Close();
            }

            else
            {
                MessageBox.Show("Password Not Match.");
            }
        }