private void pictureBoxCurrentCell_Click(object sender, EventArgs e) { PictureBox pictureBoxClicked = sender as PictureBox; TwoPictureBoxesClickedEventArgs twoPictureBoxesClicked; if (pictureBoxClicked != null) { if (pictureBoxChoosen == null) { pictureBoxChoosen = pictureBoxClicked; pictureBoxClicked.BackgroundImage = Properties.Resources.ClickedCell; } else if (pictureBoxChoosen == pictureBoxClicked) { pictureBoxChoosen = null; pictureBoxClicked.BackgroundImage = Properties.Resources.ValidCell; } else { twoPictureBoxesClicked = new TwoPictureBoxesClickedEventArgs(); twoPictureBoxesClicked.StartLocation = getBoardPositionByLocation(pictureBoxChoosen); twoPictureBoxesClicked.DestLocation = getBoardPositionByLocation(pictureBoxClicked); OnTwoPictureBoxesClicked(twoPictureBoxesClicked); pictureBoxChoosen.BackgroundImage = Properties.Resources.ValidCell; pictureBoxChoosen = null; } } }
protected virtual void OnTwoPictureBoxesClicked(TwoPictureBoxesClickedEventArgs e) { if (TwoPictureBoxesClicked != null) { TwoPictureBoxesClicked.Invoke(e); } }
private void m_FormGame_m_TwoPictureBoxesClicked(TwoPictureBoxesClickedEventArgs e) { m_Game.PlayTurn(e.StartLocation, e.DestLocation); }