예제 #1
0
        private void CreateBoard()
        {
            int squaresize = 8;

            Width  = squaresize * CountX;
            Height = squaresize * CountY;

            for (int i = 0; i < CountX; i++)
            {
                MainGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }
            for (int i = 0; i < CountY; i++)
            {
                MainGrid.RowDefinitions.Add(new RowDefinition());
            }

            SquareControl square;

            for (int i = 0; i < CountX; i++)
            {
                for (int j = 0; j < CountY; j++)
                {
                    square = new SquareControl(new PiecePosition(i, j), this);
                    Grid.SetColumn(square, i);
                    Grid.SetRow(square, j);
                    MainGrid.Children.Add(square);

                    square.Click += new EventHandler <BoardClickEventArgs>(square_Click);
                }
            }
        }
예제 #2
0
        private void CreateBoard()
        {
            int size = Board.BoardSize;

            for (int i = 0; i < size; i++)
            {
                MainGrid.ColumnDefinitions.Add(new ColumnDefinition());
                MainGrid.RowDefinitions.Add(new RowDefinition());
            }

            SquareControl square;

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    square = new SquareControl(new PiecePosition(i, j), this);
                    Grid.SetColumn(square, i);
                    Grid.SetRow(square, j);
                    MainGrid.Children.Add(square);

                    square.Click += new EventHandler <BoardClickEventArgs>(square_Click);
                }
            }

            var orangeStart = new Ellipse();

            orangeStart.Margin           = new Thickness(2);
            orangeStart.Fill             = Brushes.Orange;
            orangeStart.IsHitTestVisible = false;
            Grid.SetColumn(orangeStart, GameRules.OrangeStartPositionX);
            Grid.SetRow(orangeStart, GameRules.OrangeStartPositionY);
            MainGrid.Children.Add(orangeStart);

            var violetStart = new Ellipse();

            violetStart.Margin           = new Thickness(2);
            violetStart.Fill             = Brushes.Violet;
            violetStart.IsHitTestVisible = false;
            Grid.SetColumn(violetStart, GameRules.VioletStartPositionX);
            Grid.SetRow(violetStart, GameRules.VioletStartPositionY);
            MainGrid.Children.Add(violetStart);
        }