コード例 #1
0
        //flag a button on a right mouse click
        public void FlagButton(KeyValuePair <int, Button> button, MineField mineField)
        {
            Button currentButton = button.Value;

            //get the space we are working with
            Space space = new Space();

            foreach (KeyValuePair <int, Space> currentSpace in mineField.Spaces)
            {
                if (currentSpace.Key == button.Key)
                {
                    space = currentSpace.Value;
                }
            }

            if (space.Flagged)
            {
                currentButton.Image = null;
                space.Flagged       = false;
                mineField.ReturnFlag();
            }
            else
            {
                if (mineField.GetFlag() >= 1)
                {
                    currentButton.Image = Resource1.Flag;
                    space.Flagged       = true;
                }
            }
        }