Ejemplo n.º 1
0
        private void OnCellClick(object sender, DataGridViewCellEventArgs e)
        {
            bool selectionsChanged = false;

            if (e.RowIndex < 0 && e.ColumnIndex >=2 && e.ColumnIndex <=5)
            {
                foreach (DataGridViewRow row in _grid.Rows)
                {
                    int col = e.ColumnIndex;
                    int horseNumber = (int)row.Tag;
                    int pos = col - 2;
                    _ss.AddHorse(pos, horseNumber);
                    PaintSelectionCell(row, col);
                    selectionsChanged = true;
                }

            }
            else if (e.RowIndex >= 0)
            {
                int col = e.ColumnIndex;
                int horseNumber = (int)_grid.Rows[e.RowIndex].Tag;
                if (col >= 2 && col <= 5)
                {
                    int pos = col - 2;
                    _ss.ToggleHorse(pos, horseNumber);

                    PaintSelectionCell(_grid.Rows[e.RowIndex], col);
                    selectionsChanged = true;
                }
                else if(col == 6)
                {
                    MandatoryHorseLimitation m = new MandatoryHorseLimitation(horseNumber);
                    if (_ss.ContainsLimitation(m))
                    {
                        _ss.RemoveLimitation(m);
                    }
                    else
                    {
                        _ss.AddLimitation(m);
                    }

                    PaintMandatoryHorseCell(_grid.Rows[e.RowIndex]);
                    selectionsChanged = true;
                }
            }

            if (selectionsChanged)
            {
                CountSystem();
               // _gridDevelopedCombinations.Columns.Clear();
            }
        }
Ejemplo n.º 2
0
 private void PaintMandatoryHorseCell(DataGridViewRow row)
 {
     MandatoryHorseLimitation m = new MandatoryHorseLimitation((int)row.Tag);
     int col = 6;
     Color color = _ss.ContainsLimitation(m) ? Color.Green : Color.White;
     row.Cells[col].Style.BackColor = color;
     row.Cells[col].Style.SelectionBackColor = color;
 }