Beispiel #1
0
        /// <summary>
        /// This creates the 3*3 WPF grid used by the buttons, and creates 8 buttons labeled '1' to '8'
        /// </summary>
        private void SetupGridStructure()
        {
            //create an instance of puzzleLogic
            _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);
            }

            //add the buttons in a pile (they are placed according to the underlying PuzzleLogic later)
            for (var i = 0; i < 8; i++)
            {
                var button = GetNewButton();
                button.SetValue(RowProperty, 0);
                button.SetValue(ColumnProperty, 0);
                button.Content = "" + (i + 1);
                Children.Add(button);
            }
        }
        /// <summary>
        /// This creates the 3*3 WPF grid used by the buttons, and creates 8 buttons labeled '1' to '8'
        /// </summary>
        private void SetupGridStructure()
        {
            //create an instance of puzzleLogic
            _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);
            }

            //add the buttons in a pile (they are placed according to the underlying PuzzleLogic later)
            for (var i = 0; i < 8; i++)
            {
                var button = GetNewButton();
                button.SetValue(RowProperty, 0);
                button.SetValue(ColumnProperty, 0);
                button.Content = "" + (i + 1);
                Children.Add(button);
            }
        }