private void MoveDisk(Point point) { FirstTopDisk = FirstClickedDisks.Pop();//Đầu tiên phải xoá đĩa đầu tiên của cọc được chọn (Phương thức pop -> xoá đĩa đầu và trả lại đĩa đó) d = point; tmrAnimation.Start(); if (FirstTopDisk.Location == d) //Cập nhật toạ độ của đĩa được lấy { tmrAnimation.Stop(); } SecondClickedDisks.Push(FirstTopDisk); //Bỏ đĩa được chọn lên đầu của tập ở lần chọn thứ 2 ++moveCount; //Mỗi lần di chuyển thành công -> tăng movecount lblMoveCount.Text = string.Format("Số Lần Di Chuyển: {0} lần ", moveCount); //Và cập nhật lại label movecount ,bỏ movecount vô FirstClickedDisks = SecondClickedDisks = null; //reset 2 tập đĩa được nhấn picTowerA.BorderStyle = picTowerB.BorderStyle = picTowerC.BorderStyle = BorderStyle.None; //Vì k biết đường biên của lần chọn là cọc nào nên tắt cả 3 cọc rtbLog.Text = rtbLog.Text + Environment.NewLine + moveCount + ". " + towerA + " --> " + towerB; //thêm vào log if (DisksRodC.Count == nubLevel.Value) //Nếu đã di chuyển hết các đĩa qua cọc C rồi { //Gọi tập đĩa của cọc C lấy ra count nếu = số lượng đã chọn ở Numeric -> xử lí //btnGiveUp.PerformClick(); tmrCountTime.Stop(); nubLevel.Enabled = true; btnGiveUp.Enabled = false; btnPlay.Enabled = true; MessageBox.Show("Chúc mừng bạn đã hoàn thành trò chơi ", "Congratulation", MessageBoxButtons.OK); frmInputInfo frm = new frmInputInfo(); frm.ShowDialog(); } }