private void solider_MouseClick(object i_Sender, MouseEventArgs i_Events) { if (!m_IsSoliderIsMovingRightNow) { OvalPictureBox currentSolider = i_Sender as OvalPictureBox; if (m_IsChooseSolider == true) { removeBorderFromSoliderThatHaveBeenChosen(); Control[] soliderToMove = this.Controls.Find(String.Format("{0}{1}", m_CurrentMove.FromSquare.ToString(), k_SoliderPicName), false); soliderToMove[0].Refresh(); } TagSolider currentTagSolider = currentSolider.Tag as TagSolider; if (currentTagSolider.NumberOfPlayer == CheckerboardController.Instance.CurrentPlayer.NumberOfPlayer) { currentSolider.MakeBorder(currentSolider.CreateGraphics()); this.m_CurrentMove.FromSquare = new Square(currentTagSolider.Name[1], currentTagSolider.Name[0]); this.m_IsChooseSolider = true; } else { this.m_IsChooseSolider = false; } } }
private void solider_StartAnimationOfSoliderMovingAfterChangePlaceOnBoard(Square i_OldSquare, Square i_NewSquare) { Control[] soliderToMove = this.Controls.Find(String.Format("{0}{1}", i_OldSquare.ToString(), k_SoliderPicName), false); Control[] squareToMoveTheSolider = this.Controls.Find(String.Format("{0}{1}", i_NewSquare.ToString(), k_SquarePicName), false); Point currentLocationOfSquare = squareToMoveTheSolider[0].Location; OvalPictureBox currentSolider = soliderToMove[0] as OvalPictureBox; Point newLocation = new Point(currentLocationOfSquare.X + 2, currentLocationOfSquare.Y + 2); m_IsSoliderIsMovingRightNow = true; currentSolider.BringToFront(); currentSolider.startAnimationOfMovingSolider(newLocation); TagSolider tagOfCurrentSolider = soliderToMove[0].Tag as TagSolider; tagOfCurrentSolider.Name = i_NewSquare.ToString(); soliderToMove[0].Name = String.Format("{0}{1}", i_NewSquare.ToString(), k_SoliderPicName); }
private void applySoliderToFrontOfView(Image i_SoliderToDraw, Point i_PointToDraw, int i_Row, int i_Col, eNumberOfPlayer i_NumberOfPlayer) { OvalPictureBox solider = new OvalPictureBox(i_SoliderToDraw); solider.Location = new Point(i_PointToDraw.X + 2, i_PointToDraw.Y + 2); string stringToSetToTagName = String.Format("{0}{1}", (char)(MovementOptions.k_StartCol + i_Col), (char)(MovementOptions.k_StartRow + i_Row)); solider.Name = string.Format("{0}{1}", stringToSetToTagName, k_SoliderPicName); solider.Tag = new TagSolider(stringToSetToTagName, i_NumberOfPlayer); TagSolider tempTag = solider.Tag as TagSolider; if ((i_NumberOfPlayer == eNumberOfPlayer.Second && CheckerboardController.Instance.OtherPlayer.TypeOfPlayer != eTypeOfPlayer.Computer) || i_NumberOfPlayer == eNumberOfPlayer.First) { solider.MouseClick += solider_MouseClick; } solider.PictureOfSoliderStoppedToMove += solider_PictureOfSoliderStoppedToMove; this.Controls.Add(solider); solider.BringToFront(); }