private void resetDataFields_Click(object sender, EventArgs e) { var boxes = groupBox3.Controls.OfType <Control>().ToList(); foreach (Control ctrl in boxes) { groupBox3.Controls.Remove(ctrl); ctrl.Dispose(); } var boxes2 = groupBox2.Controls.OfType <Control>().ToList(); foreach (Control ctrl in boxes2) { groupBox2.Controls.Remove(ctrl); ctrl.Dispose(); } chart1.Series.Clear(); chart1.Legends.Clear(); foreach (Control ctrl in groupBox1.Controls) { if (!(ctrl is TextBox)) { continue; } ctrl.Enabled = true; } instance = null; initButtonLogic(); }
private void calculateButton_Click(object sender, EventArgs e) { int quorum = 0; var data = new List <int>(); Regex rgxField = new Regex(@"task(\d+)Field"); foreach (TextBox ctrl in groupBox3.Controls.OfType <TextBox>().Where(ctrl => rgxField.IsMatch(ctrl.Name))) { try { var arg = int.Parse(ctrl.Text); data.Add(arg); quorum++; } catch (Exception) { quorum--; } } if (quorum != tasknum) { MessageBox.Show(@"Давай по новой", @"ConveyerLab", MessageBoxButtons.OK); return; } instance = new FacilityCPU(tact, swit, data); for (int i = 0; i < tasknum; i++) { chart1.Series.Add($"Series{i + 1}"); chart1.Series[$"Series{i + 1}"].ChartType = SeriesChartType.RangeBar; chart1.Series[$"Series{i + 1}"].ChartArea = "ChartArea1"; chart1.Legends.Add(new Legend($"Legend{i + 1}")); chart1.Legends[$"Legend{i + 1}"].DockedToChartArea = "ChartArea1"; chart1.Series[$"Series{i + 1}"].Legend = $"Legend{i + 1}"; chart1.Series[$"Series{i + 1}"].IsVisibleInLegend = true; chart1.Series[$"Series{i + 1}"].LegendText = $"Task #{i + 1}"; } for (var i = 0; i < instance.dur_index.Count; i++) { if (instance.dur_index[i] == int.MaxValue) { continue; } var seriesIndex = $"Series{instance.dur_index[i] + 1}"; chart1.Series[seriesIndex].Points.AddXY(1, i * 20, i * 20 + 20); } chart1.DataBind(); checkAnswerButton.Enabled = true; calculateButton.Enabled = false; resetDataFields.Enabled = true; generateTestBoxes(); MessageBox.Show(@"Ответ округляй до десятых!", @"ConveyerLab", MessageBoxButtons.OK); }