Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            RestoreImages(e);
            base.OnMouseUp(e);
            MouseEventArgs  eventArgs        = e as MouseEventArgs;
            MineCellCommand requestedCommand = GetCommand(eventArgs);

            ExecuteCommand(requestedCommand);
        }