Exemple #1
0
        private void SetupThePuzzleGridStructure()
        {
            _puzzleLogic = new PuzzleLogic(_numRows);

            // Define rows and columns in the Grid
            for (var row = 0; row < _numRows; row++)
            {
                var r = new RowDefinition {
                    Height = GridLength.Auto
                };
                RowDefinitions.Add(r);

                var c = new ColumnDefinition {
                    Width = GridLength.Auto
                };
                ColumnDefinitions.Add(c);
            }

            var buttonStyle = (Style)Resources["PuzzleButtonStyle"];

            // Now add the buttons in
            var i = 1;

            for (var row = 0; row < _numRows; row++)
            {
                for (var col = 0; col < _numRows; col++)
                {
                    // lower right cell is empty
                    if (_numRows != 1 && row == _numRows - 1 && col == _numRows - 1)
                    {
                        continue;
                    }
                    var b = new Button {
                        FontSize = 24
                    };

                    // Styling comes in only here...
                    if (IsApplyingStyle)
                    {
                        b.Style = buttonStyle;
                    }

                    b.SetValue(RowProperty, row);
                    b.SetValue(ColumnProperty, col);
                    b.Content = i.ToString();
                    i++;
                    Children.Add(b);
                }
            }
        }
Exemple #2
0
        private void SetupThePuzzleGridStructure()
        {
            _puzzleLogic = new PuzzleLogic(_numRows);

            // Define rows and columns in the Grid
            for (var row = 0; row < _numRows; row++)
            {
                var r = new RowDefinition {Height = GridLength.Auto};
                RowDefinitions.Add(r);

                var c = new ColumnDefinition {Width = GridLength.Auto};
                ColumnDefinitions.Add(c);
            }

            var buttonStyle = (Style) Resources["PuzzleButtonStyle"];

            // Now add the buttons in
            var i = 1;
            for (var row = 0; row < _numRows; row++)
            {
                for (var col = 0; col < _numRows; col++)
                {
                    // lower right cell is empty
                    if (_numRows != 1 && row == _numRows - 1 && col == _numRows - 1)
                    {
                        continue;
                    }
                    var b = new Button {FontSize = 24};

                    // Styling comes in only here...
                    if (IsApplyingStyle)
                    {
                        b.Style = buttonStyle;
                    }

                    b.SetValue(RowProperty, row);
                    b.SetValue(ColumnProperty, col);
                    b.Content = i.ToString();
                    i++;
                    Children.Add(b);
                }
            }
        }