private void btnCreate_Click(object sender, EventArgs e) { clsProfile profile; if (txtUserName.Text != "") { profile = new clsProfile(txtUserName.Text); profile.TotalGames = 0; profile.TotalWin = 0; profile.TotalLose = 0; profile.TotalDraw = 0; profile.Rating = 1200; clsImage img = new clsImage(picAvatar.Image, picAvatar.Width, picAvatar.Height); profile.Avatar = img; profile.SaveProfile(); MessageBox.Show("Tạo Profile Thành Công !!!"); this.Close(); } else { MessageBox.Show("Bạn Chưa Nhập Tên !!!"); } }
private void chụpẢnhToolStripMenuItem_Click(object sender, EventArgs e) { if (pictureBox1.Image == null) { return; } clsImage img = new clsImage(pictureBox1.Image, 240, 240); Clipboard.SetImage(img.Avatar); MessageBox.Show("Đã lưu vào Clipboard"); }
public void LoadProfile(string ProfileName) { clsProfile profile = new clsProfile(ProfileName); profile.LoadProfile(); this._profile = profile; clsImage Avatar = profile.Avatar; picAvatar.Image = Avatar.Avatar; lblPlayerName.Text = profile.PlayerName; lblTotalWin.Text = profile.TotalWin.ToString(); lblTotalDraw.Text = profile.TotalDraw.ToString(); lblTotalLose.Text = profile.TotalLose.ToString(); lblRating.Text = profile.Rating.ToString(); }
//public clsProfile() //{ // this._PlayerName = "Guest"; // this._Rating = 1200; // this._TotalGames = 0; // this._TotalWin = 0; // this._TotalLose = 0; // this._TotalDraw = 0; // string PlayerName = this._PlayerName; // PlayerName = clsEncoding.Encode(PlayerName) + ".xml"; // path = Application.StartupPath + "\\Profiles\\" + PlayerName; //} public void LoadProfile() { DataTable tbl = clsXMLProcess.GetTable(path); DataRow r = tbl.Rows[0]; this._PlayerName = r["PlayerName"].ToString(); this._Rating = Convert.ToInt32(r["Rating"]); this._TotalGames = Convert.ToInt32(r["TotalGames"]); this._TotalWin = Convert.ToInt32(r["TotalWin"]); this._TotalLose = Convert.ToInt32(r["TotalLose"]); this._TotalDraw = Convert.ToInt32(r["TotalDraw"]); string strAvatar = ""; try { strAvatar = r["Avatar"].ToString(); this._Avatar = new clsImage(); this._Avatar.ImageFromBytes(Convert.FromBase64String(strAvatar)); } catch { } }