70 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using System.Text;
 | 
						|
using System.Windows;
 | 
						|
using System.Windows.Controls;
 | 
						|
using System.Windows.Data;
 | 
						|
using System.Windows.Documents;
 | 
						|
using System.Windows.Input;
 | 
						|
using System.Windows.Media;
 | 
						|
using System.Windows.Media.Imaging;
 | 
						|
using System.Windows.Navigation;
 | 
						|
using System.Windows.Shapes;
 | 
						|
using SudokuWeek4.Models;
 | 
						|
 | 
						|
namespace SudokuWeek4.Models
 | 
						|
{
 | 
						|
	public partial class LargeCell : UserControl
 | 
						|
	{
 | 
						|
        // This array will hold the smallCells
 | 
						|
        private LittleCell[,] _littleCells;
 | 
						|
 | 
						|
        // Create the contructor
 | 
						|
        public LargeCell()
 | 
						|
		{
 | 
						|
            try
 | 
						|
            {
 | 
						|
                InitializeComponent();
 | 
						|
                Initialize();
 | 
						|
            }
 | 
						|
            catch (Exception) {
 | 
						|
                System.Console.WriteLine("Cannot create the largeCell  Sudoku Error.");
 | 
						|
            }
 | 
						|
		}
 | 
						|
 | 
						|
        // Intialize the game
 | 
						|
		private void Initialize()
 | 
						|
		{
 | 
						|
            // Clear all the contents of the bigCellGrid
 | 
						|
			bigCellGrid.Children.Clear();
 | 
						|
 | 
						|
            // Set the rows and columns to the size of the gameField
 | 
						|
            bigCellGrid.Columns = bigCellGrid.Rows = BoardModel.GameFieldCount;
 | 
						|
 | 
						|
            // Create a new array with all the smallCells to the size of the gameField
 | 
						|
            _littleCells = new LittleCell[BoardModel.GameFieldCount, BoardModel.GameFieldCount];
 | 
						|
 | 
						|
            // Create all the smallCells that will come inside the bigCells
 | 
						|
            for (int i = 0; i < BoardModel.GameFieldSize; i++)
 | 
						|
			{
 | 
						|
				Border border = new Border();
 | 
						|
				border.BorderThickness = new Thickness (1);
 | 
						|
				border.BorderBrush = Brushes.Green;
 | 
						|
				border.Margin = new Thickness (-1, -1, 0, 0);
 | 
						|
				bigCellGrid.Children.Add (border);
 | 
						|
 | 
						|
				LittleCell smallCell = new LittleCell ();
 | 
						|
				border.Child = smallCell;
 | 
						|
 | 
						|
                _littleCells[i % BoardModel.GameFieldCount, i / BoardModel.GameFieldCount] = smallCell;
 | 
						|
			}
 | 
						|
		}
 | 
						|
 | 
						|
        // This property returns the specified SmallCell
 | 
						|
		public LittleCell this[int x, int y]
 | 
						|
		{
 | 
						|
			get { return _littleCells[x, y]; }
 | 
						|
		}
 | 
						|
	}
 | 
						|
} |