static void updateSelectBallsGrid(DataGridView _balls) { gridTable grid = new gridTable(); grid.selectBallsGrid = _balls; }
private void updateTable(int num, int[,] poslBall, int[] colBallSr, float[] outSrBall, int[] dataRow, float srBall) { gridTable grid = new gridTable(); if (grid.selectBallsGrid == null) { mainProgressBar.Value = 0; ballRange.Enabled = false; filterMarks.Enabled = false; sorts.Enabled = false; lengthMarks = 0; for (int i = 0; i < dataRow.Length; i++) { if (dataRow[i] != 0) { lengthMarks++; } } mainProgressBar.Value = 20; columnsGen(lengthMarks / 2, colBallSr.Length); mainProgressBar.Value = mainProgressBar.Value + 20; for (int j = 0; j < Convert.ToInt32(Math.Pow(4, colBallSr.Length)); j++) { string[] data = new string[lengthMarks + (colBallSr.Length * 2) + 3]; data[lengthMarks + colBallSr.Length * 2] = outSrBall[j].ToString("N2"); for (int i = 0; i < lengthMarks; i++) { if (dataRow[i] == 0) { data[i] = null; } else { if (dataRow[i] == 0) { data[i] = null; } else { data[i] = dataRow[i].ToString(); } } } int count = 0; for (int i = 0; i <= colBallSr.Length + colBallSr.Length - 2; i = i + 2) { data[i + lengthMarks] = poslBall[count, j].ToString(); data[i + lengthMarks + 1] = colBallSr[count].ToString(); count++; } data[dataGridView1.Columns.Count - 2] = srBall.ToString("N2"); data[dataGridView1.Columns.Count - 1] = (Convert.ToSingle(data[dataGridView1.Columns.Count - 3]) - Convert.ToSingle(data[dataGridView1.Columns.Count - 2])).ToString("N2"); dataGridView1.Rows.Add(data); for (int i = 0; i < dataGridView1.Columns.Count - 3; i++) { if (i % 2 != 0) { try { if (dataGridView1[i, j].Value.ToString() == "1" && Properties.Settings.Default.oneWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.oneText; } else if (dataGridView1[i, j].Value.ToString() == "2" && Properties.Settings.Default.twoWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.twoText; } else if (dataGridView1[i, j].Value.ToString() == "3" && Properties.Settings.Default.threeWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.threeText; } else if (dataGridView1[i, j].Value.ToString() == "4" && Properties.Settings.Default.fourWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.fourText; } else if (dataGridView1[i, j].Value.ToString() == "5" && Properties.Settings.Default.fiveWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.fiveText; } else if (dataGridView1[i, j].Value.ToString() == "6" && Properties.Settings.Default.sixWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.sixText; } else if (dataGridView1[i, j].Value.ToString() == "7" && Properties.Settings.Default.sevenWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.sevenText; } else if (dataGridView1[i, j].Value.ToString() == "8" && Properties.Settings.Default.eightWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.eightText; } else if (dataGridView1[i, j].Value.ToString() == "9" && Properties.Settings.Default.nineWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.nineText; } else if (dataGridView1[i, j].Value.ToString() == "10" && Properties.Settings.Default.tenWeight) { dataGridView1[i, j].ToolTipText = Properties.Settings.Default.tenText; } else { dataGridView1[i, j].ToolTipText = ""; } } catch { dataGridView1[i, j].ToolTipText = ""; } } } float numberBall = Convert.ToSingle(dataGridView1[dataGridView1.Columns.Count - 3, j].Value); if (Properties.Settings.Default.colorIndicateOn == true) { if (numberBall >= ballStep[2]) { dataGridView1[dataGridView1.Columns.Count - 3, j].Style.BackColor = Color.FromArgb(int.Parse(Properties.Settings.Default.fiveColor, System.Globalization.NumberStyles.HexNumber)); } else if (numberBall < ballStep[2] && numberBall >= ballStep[1]) { dataGridView1[dataGridView1.Columns.Count - 3, j].Style.BackColor = Color.FromArgb(int.Parse(Properties.Settings.Default.fourColor, System.Globalization.NumberStyles.HexNumber)); } else if (numberBall < ballStep[1] && numberBall >= ballStep[0]) { dataGridView1[dataGridView1.Columns.Count - 3, j].Style.BackColor = Color.FromArgb(int.Parse(Properties.Settings.Default.threeColor, System.Globalization.NumberStyles.HexNumber)); } else if (numberBall < ballStep[0] && numberBall >= 2) { dataGridView1[dataGridView1.Columns.Count - 3, j].Style.BackColor = Color.FromArgb(int.Parse(Properties.Settings.Default.twoColor, System.Globalization.NumberStyles.HexNumber)); } } else { dataGridView1[dataGridView1.Columns.Count - 3, j].Style.BackColor = Color.White; } if (Convert.ToSingle(data[dataGridView1.Columns.Count - 3]) - Convert.ToSingle(data[dataGridView1.Columns.Count - 2]) > 0) { if (Properties.Settings.Default.colorIndicateOn == true) { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.LightGreen; } else { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.White; } } else if (Convert.ToSingle(data[dataGridView1.Columns.Count - 3]) - Convert.ToSingle(data[dataGridView1.Columns.Count - 2]) == 0) { if (Properties.Settings.Default.colorIndicateOn == true) { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.Yellow; } else { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.White; } } else { if (Properties.Settings.Default.colorIndicateOn == true) { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.OrangeRed; } else { dataGridView1[dataGridView1.Columns.Count - 1, j].Style.BackColor = Color.White; } } } mainProgressBar.Value = mainProgressBar.Value + 20; List <int> checkedRows = new List <int>(); for (int i = 0; i < dataGridView1.Rows.Count; i++) { List <List <int> > ball = new List <List <int> >(); for (int j = 1; j < 11; j++) { List <int> ballBuff = new List <int>(); for (int k = lengthMarks; k < dataGridView1.Columns.Count - 4; k = k + 2) { if (Convert.ToInt16(dataGridView1[k + 1, i].Value) == j) { ballBuff.Add(Convert.ToInt16(dataGridView1[k, i].Value)); } } ball.Add(ballBuff); } //код для отсечения не нужных чисел //int[] countBalls = new int[10]; // ghjdthbnm bool newMatch = false; for (int k = 0; k < dataGridView1.Rows.Count; k++) { //&& dataGridView1.Rows[i].Cells[dataGridView1.Columns.Count - 1].Value.ToString() != "fail" bool trueCheck = true; for (int g = 0; g < checkedRows.Count; g++) { if (k == checkedRows[g]) { trueCheck = false; } } if (k != i && trueCheck && dataGridView1.Rows[i].Cells[dataGridView1.Columns.Count - 3].Value.ToString() == dataGridView1.Rows[k].Cells[dataGridView1.Columns.Count - 3].Value.ToString()) { List <List <int> > ballTest = new List <List <int> >(); for (int j = 1; j < 11; j++) { List <int> ballBuff = new List <int>(); for (int l = lengthMarks; l < dataGridView1.Columns.Count - 4; l = l + 2) { if (Convert.ToInt16(dataGridView1[l + 1, k].Value) == j) { ballBuff.Add(Convert.ToInt16(dataGridView1[l, k].Value)); } } ballTest.Add(ballBuff); } int[,] count = new int[2, 4]; for (int h = 0; h < 10; h++) { for (int g = 0; g < ball[h].Count; g++) { for (int f = 2; f < 6; f++) { if (ball[h][g] == f) { count[0, f - 2]++; break; } } } for (int g = 0; g < ballTest[h].Count; g++) { for (int f = 2; f < 6; f++) { if (ballTest[h][g] == f) { count[1, f - 2]++; break; } } } } bool notMatch = true; for (int g = 0; g < 4; g++) { bool exitFor = false; if (count[0, g] != count[1, g]) { notMatch = false; exitFor = true; } if (exitFor) { break; } } if (notMatch) { dataGridView1.Rows.RemoveAt(i); //.RemoveAt(i) //[i].Cells[dataGridView1.Columns.Count - 1].Value = "fail"; checkedRows.Add(i); newMatch = true; } } } if (newMatch) { i = -1; } } mainProgressBar.Value = mainProgressBar.Value + 20; for (int i = 0; i < dataGridView1.Rows.Count; i++) { bool startNew = false; for (int k = lengthMarks; k < dataGridView1.Columns.Count - 4; k++) { if (k % 2 == 0) { for (int f = 0; f < 10; f++) { if ((Convert.ToInt16(dataGridView1[k, i].Value) < typeIndividual[0, f] || Convert.ToInt16(dataGridView1[k, i].Value) > typeIndividual[1, f]) && Convert.ToInt16(dataGridView1[k + 1, i].Value) == f + 1 && typeIndividual[0, f] != 0 && typeIndividual[1, f] != 0) { dataGridView1.Rows.RemoveAt(i); startNew = true; goto A; } } } } A: if (startNew) { i = -1; } } mainProgressBar.Value = mainProgressBar.Value + 20; ballRange.Enabled = true; filterMarks.Enabled = true; sorts.Enabled = true; } else { dataGridView1 = grid.selectBallsGrid; } autoResizeTable(); }