示例#1
0
 void ShowPosiblePositions(CellButton pressedCell)
 {
     game.FindPosiblePositions(); //ищем возможные ходы
     foreach (var pos in game.PosiblePositions)
     {
         buttons[pos.X, pos.Y].BackColor = Color.YellowGreen; //помечаем их зеленым
         buttons[pos.X, pos.Y].Enabled   = true;              //даем возмонжость нажать на эти клетки
     }
     pressedCell.BackColor = Color.Green;                     //нажатую кнопку выделели
 }
示例#2
0
        /// <summary>
        /// Метод создающий кнопку на форме
        /// </summary>
        /// <param name="i">кордината</param>
        /// <param name="j">координата</param>
        /// <returns></returns>
        CellButton MakeButton(int i, int j)
        {
            CellButton button = new CellButton(new Position(i, j));

            if ((i + j) % 2 == 1)
            {
                button.BackColor = Color.Brown;
            }
            else
            {
                button.BackColor = Color.OldLace;
            }
            var size = new Size(80, 80);

            button.Size        = size;
            button.Font        = new Font("Times New Roman", 28F, FontStyle.Regular, GraphicsUnit.Point, 204);
            button.Location    = new Point(j * 80 + 40, i * 80);
            button.Click      += SwapBlocks;
            button.MouseEnter += ShowCurrentPosition;
            button.Enabled     = false;
            Controls.Add(button);
            return(button);
        }