void square_Click(object sender, BoardClickEventArgs e)
 {
     if (Click != null)
     {
         Click(this, e);
     }
 }
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (isAnimating)
            {
                return;
            }

            double x = e.GetPosition(this).X - BorderStrokeThickness;
            double actualCellWidth = (((Grid)sender).ActualWidth - 2 * BorderStrokeThickness) / 7;
            int    columnClicked   = (int)(x / actualCellWidth);

            if (columnClicked > 6)
            {
                columnClicked = 6;
            }
            if (columnClicked < 0)
            {
                columnClicked = 0;
            }

            BoardClickEventArgs args = new BoardClickEventArgs {
                ColumnClicked = columnClicked
            };

            BoardClick?.Invoke(sender, args);
        }
Esempio n. 3
0
        void square_Click(object sender, BoardClickEventArgs e)
        {
            if (Click != null && Hand != null)
            {
                int variantX = e.PiecePosition.X / PieceSizeX;
                int variantY = e.PiecePosition.Y / PieceSizeY;

                int ind = variantX + variantY * PieceCountX;
                if (ind >= Hand.HandPieces.Count)
                {
                    return;
                }
                Click(this, new HandClickEventArgs(Hand.HandPieces[ind]));
            }
        }
Esempio n. 4
0
 static public void Press_Down(BoardClickEventArgs e)
 {
     if (e.key == KeyCode.Space && e.IsDown)
     {
         Console.WriteLine(new Vector2(Pos_Hei, Pos_Wid));
         if (Pos_Hei == -1)
         {
             Clean_Old();
         }
         if (Game.State_of_Game != 2)
         {
             Game.Do_it();
         }
     }
     else
     if (e.key == KeyCode.Up && e.IsDown && Pos_Hei > 0)
     {
         Pos_Hei -= 1;
     }
     else
     if (e.key == KeyCode.Down && e.IsDown && Pos_Hei < Height_Cnt - 1)
     {
         Pos_Hei += 1;
     }
     else
     if (e.key == KeyCode.Left && e.IsDown && Pos_Wid > 0)
     {
         Pos_Wid -= 1;
     }
     else
     if (e.key == KeyCode.Right && e.IsDown && Pos_Wid < Width_Cnt - 1)
     {
         Pos_Wid += 1;
     }
     else
     if (e.key == KeyCode.F5 && e.IsDown)
     {
         Clean_Old();
     }
 }
Esempio n. 5
0
 protected override void OnKeyDown(object sender, BoardClickEventArgs e)
 {
     SweeperSource.Press_Down(e);
     base.OnKeyDown(sender, e);
 }
Esempio n. 6
0
 void Board_Click(object sender, BoardClickEventArgs e)
 {
     (DataContext as GameCoordinator).OnBoardClick(e.PiecePosition);
 }