示例#1
0
文件: This.cs 项目: Puddler/Chess
        public BoardVM CreateNewBoard(SolidColorBrush whiteColor, SolidColorBrush blackColor)
        {
            BoardVM board = new BoardVM();
            List<char> files = new List<char>() { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
            List<int> ranks = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 };

            foreach (char file in files)
            {
                foreach (int rank in ranks)
                {
                    SolidColorBrush color = Brushes.Transparent;
                    if (file == 'A' || file == 'C' || file == 'E' || file == 'G')
                    {
                        if (rank % 2 == 0) color = whiteColor;
                        else color = blackColor;
                    }
                    else
                    {
                        if (rank % 2 == 0) color = blackColor;
                        else color = whiteColor;
                    }
                    board.AddSquare(new BoardSquareVM(file, rank, color));
                }
            }
            return board;
        }
示例#2
0
文件: This.cs 项目: Puddler/Chess
 public static This CreateNewGame()
 {
     This game = new This();
     This.Images = new Images();
     This.Board = game.CreateNewBoard(Brushes.BlanchedAlmond, Brushes.Chocolate);
     return game;
 }