Exemplo n.º 1
0
        public SectionControl(Section sect)
        {
            section = sect;
            InitializeComponent();

            tableLayoutPanel1.Controls.Clear();

            for (int i = 0; i < 9; i++)
                tableLayoutPanel1.Controls.Add(new SquareControl(section.squares[i]) {Dock = DockStyle.Fill});
        }
Exemplo n.º 2
0
        private void setupRegions()
        {
            // rows
            for (int i = 0; i < 9; i++)
            {
                _rows[i] = new Row();
                for (int j = 0; j < 9; j++)
                {
                    int index0 = (i*9) + j;
                    _rows[i].squares[j] = _squares[index0];
                    _squares[index0].Row = _rows[i];
                }
            }

            // columns
            for (int i = 0; i < 9; i++)
            {
                _columns[i] = new Column();

                for (int j = 0; j < 9; j++)
                {
                    int index0 = i + (j*9);
                    _columns[i].squares[j] = _squares[index0];
                    _squares[index0].Column = _columns[i];
                }
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    _sections[i + (j*3)] = new Section();

                    Square[] sq = {
                                      _squares[((i*3) + 0) + (((j*3) + 0)*9)],
                                      _squares[((i*3) + 1) + (((j*3) + 0)*9)],
                                      _squares[((i*3) + 2) + (((j*3) + 0)*9)],
                                      _squares[((i*3) + 0) + (((j*3) + 1)*9)],
                                      _squares[((i*3) + 1) + (((j*3) + 1)*9)],
                                      _squares[((i*3) + 2) + (((j*3) + 1)*9)],
                                      _squares[((i*3) + 0) + (((j*3) + 2)*9)],
                                      _squares[((i*3) + 1) + (((j*3) + 2)*9)],
                                      _squares[((i*3) + 2) + (((j*3) + 2)*9)],
                                  };

                    _squares[((i*3) + 0) + (((j*3) + 0)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 0) + (((j*3) + 1)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 0) + (((j*3) + 2)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 1) + (((j*3) + 0)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 1) + (((j*3) + 1)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 1) + (((j*3) + 2)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 2) + (((j*3) + 0)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 2) + (((j*3) + 1)*9)].Section = _sections[i + (j*3)];
                    _squares[((i*3) + 2) + (((j*3) + 2)*9)].Section = _sections[i + (j*3)];

                    _sections[i + (j*3)].squares = sq;
                }
            }
            return;
        }