Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
 protected virtual void OnTwoPictureBoxesClicked(TwoPictureBoxesClickedEventArgs e)
 {
     if (TwoPictureBoxesClicked != null)
     {
         TwoPictureBoxesClicked.Invoke(e);
     }
 }
Exemplo n.º 3
0
 private void m_FormGame_m_TwoPictureBoxesClicked(TwoPictureBoxesClickedEventArgs e)
 {
     m_Game.PlayTurn(e.StartLocation, e.DestLocation);
 }