Exemplo n.º 1
0
        public void CreateGrid(int size)
        {
            MatrixLogics.Reset();

            mainGrid.Children.Clear();
            mainGrid.RowDefinitions.Clear();
            mainGrid.ColumnDefinitions.Clear();

            RowDefinition    rd;
            ColumnDefinition cd;

            for (int i = 0; i < size; i++)
            {
                rd        = new RowDefinition();
                rd.Height = new GridLength(1, GridUnitType.Star);
                mainGrid.RowDefinitions.Add(rd);
                cd       = new ColumnDefinition();
                cd.Width = new GridLength(1, GridUnitType.Star);
                mainGrid.ColumnDefinitions.Add(cd);
            }



            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    Button b = new Button();
                    b.Tag        = "button";
                    b.FontFamily = new FontFamily("Comic Sans MS");
                    b.FontWeight = FontWeights.Bold;
                    b.FontSize   = 200 / size;
                    b.Foreground = Brushes.Orange;
                    b.Background = Brushes.White;
                    Style s = new Style();

                    //Trigger t = new Trigger();
                    //t.Property = TextBlock.IsMouseOverProperty;
                    //t.Value = true;
                    //Setter setter = new Setter(TextBlock.ForegroundProperty, Brushes.Red);
                    //t.Setters.Add(setter);
                    //s.Triggers.Add(t);
                    b.Style  = s;
                    b.Click += move;
                    Grid.SetRow(b, i);
                    Grid.SetColumn(b, j);
                    mainGrid.Children.Add(b);
                }
            }
        }
Exemplo n.º 2
0
        public void CreateGrid(int size)
        {
            movesCount    = 0;
            isPlayerXturn = false;
            isPlayable    = true;
            MatrixLogics.Reset();

            mainGrid.Children.Clear();
            mainGrid.RowDefinitions.Clear();
            mainGrid.ColumnDefinitions.Clear();

            RowDefinition    rd;
            ColumnDefinition cd;

            for (int i = 0; i < size; i++)
            {
                rd        = new RowDefinition();
                rd.Height = new GridLength(1, GridUnitType.Star);
                mainGrid.RowDefinitions.Add(rd);
                cd       = new ColumnDefinition();
                cd.Width = new GridLength(1, GridUnitType.Star);
                mainGrid.ColumnDefinitions.Add(cd);
            }



            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    Button b = new Button();
                    b.Tag        = "button";
                    b.FontFamily = new FontFamily("Comic Sans MS");
                    b.FontWeight = FontWeights.Bold;
                    b.FontSize   = 200 / size;
                    b.Foreground = Brushes.Orange;
                    b.Background = Brushes.White;
                    b.Click     += move;
                    Grid.SetRow(b, i);
                    Grid.SetColumn(b, j);
                    mainGrid.Children.Add(b);
                }
            }
        }