Beispiel #1
0
        protected void OnClickDeprecated(EventArgs e)
        {
            MouseEventArgs eventArgs = e as MouseEventArgs;

            if (!Opened)
            {
                if (!Defused && eventArgs.Button == MouseButtons.Left)
                {
                    if (ContainsBomb)
                    {
                        OnStateChanged();
                    }
                    else
                    {
                        Image = numberedSquaresTable[NeighbouringBombsCount];
                        if (NeighbouringBombsCount == 0)
                        {
                            Parent.SuspendLayout();
                            ParentBoard.TryExpandZeroSquares(FieldLocation);
                            Parent.ResumeLayout();
                        }
                    }
                    State = MineCellState.Opened;
                }
                else if (eventArgs.Button == MouseButtons.Right)
                {
                    Image = Image == CellImagesProvider.Defused ? CellImagesProvider.Default : CellImagesProvider.Defused;
                    State = Defused ? MineCellState.Closed : MineCellState.Defused;
                }
            }
            else if (eventArgs.Button == MouseButtons.Middle)
            {
                ParentBoard.TryExpandNonZeroSquare(this.FieldLocation);
            }
        }
Beispiel #2
0
 private void ExecuteCommand(MineCellCommand requestedCommand)
 {
     if (!Opened)
     {
         if (requestedCommand == MineCellCommand.Open && !Defused)
         {
             if (ContainsBomb)
             {
                 State = MineCellState.Exploded;
                 OnStateChanged();
             }
             else
             {
                 Image = numberedSquaresTable[NeighbouringBombsCount];
                 if (NeighbouringBombsCount == 0)
                 {
                     Parent.SuspendLayout();
                     ParentBoard.TryExpandZeroSquares(FieldLocation);
                     Parent.ResumeLayout();
                 }
             }
             State = MineCellState.Opened;
         }
         else if (requestedCommand == MineCellCommand.Defuse)
         {
             State = Defused ? MineCellState.Closed : MineCellState.Defused;
         }
     }
     else if (requestedCommand == MineCellCommand.Expand)
     {
         ParentBoard.TryExpandNonZeroSquare(this.FieldLocation);
     }
 }