Example #1
0
        /*
         * Handles Mouse down, records if it is right or left to detect both
         * ignore if game over
         */
        public void MouseDownHandle(Object sender, MouseEventArgs e)
        {
            if (!GameOver)
            {
                if (e.Button == MouseButtons.Left)
                {
                    LeftButton = true;
                }
                else if (e.Button == MouseButtons.Right)
                {
                    RightButton = true;
                }

                // determine cell
                int x, y;
                x = e.X / (scale * 16);
                y = e.Y / (scale * 16);

                Cell cell = minefield.getCell(x, y);

                //show worried face
                if ((cell.CellState == CellState.DOWN && RightButton && LeftButton) ||
                    (cell.CellState == CellState.UP && LeftButton))
                {
                    faceinator.state = GraphicsLibrary.WORRIED;
                    form.Refresh();
                }

                //if chord show surrounding as down
                if (LeftButton && RightButton && cell.CellState == CellState.DOWN)
                {
                    List <Cell> Surrounding = GetSurrounding(minefield.getField(), cell);
                    foreach (Cell c in Surrounding)
                    {
                        if (c.CellState == CellState.UP &&
                            !c.Flagged)
                        {
                            c.TempDown  = true;
                            c.CellState = CellState.DOWN;
                        }
                    }

                    form.Refresh();
                }
            }
        }