private void cboDeleteRegion_SelectedIndexChanged(object sender, EventArgs e) { Regex reg = new Regex(@"\D"); string s = reg.Replace(cboDeleteRegion.SelectedItem.ToString(), ""); int regionIDInt = int.Parse(s); foreach (BenMAPRollback rollback in _monitorRollbackLine.BenMAPRollbacks) { if (regionIDInt == rollback.RegionID) { _currentBenMAPRollback = rollback; } } ColorMap(); }
private void btnAddRegion_Click(object sender, EventArgs e) { try { SelectRegionRollbackType frm = new SelectRegionRollbackType(); DialogResult rtn = frm.ShowDialog(); if (rtn != DialogResult.OK) { return; } string name = frm.ControlName; int i = GetPercentageControlCount(flowLayoutPanel1); int j = GetIncrementalControlCount(flowLayoutPanel1); int k = GetToStandardControlCount(flowLayoutPanel1); switch (name) { case "Percentage": PercentageControl pc = new PercentageControl(); if (i == 0 && j == 0 && k == 0) { pc.Location = new Point(0, 0); } else { pc.Location = new Point(0, i * 101 + j * 101 + k * 370 + (i + j + k - 1) * 1); } Label lablePc = new Label(); pc.Controls.Add(lablePc); while (dicRegion.ContainsValue(regionnumber)) { regionnumber++; } lablePc.Text = "Region" + " " + regionnumber.ToString(); lablePc.Location = new Point(40, 3); Button buttonPc = new Button(); pc.Controls.Add(buttonPc); buttonPc.Size = new Size(35, 23); buttonPc.Location = new Point(0, 0); buttonPc.Text = ""; Random randomPc = new Random(); buttonPc.BackColor = Color.FromArgb(randomPc.Next(255), randomPc.Next(255), randomPc.Next(255)); Regex reg = new Regex(@"\D"); string s = reg.Replace(lablePc.Text, ""); int regionIDInt = int.Parse(s); pc.RegionID = regionIDInt; PercentageRollback pr = new PercentageRollback(); pr.DrawingColor = buttonPc.BackColor.R + "," + buttonPc.BackColor.G + "," + buttonPc.BackColor.B; pr.RegionID = regionIDInt; pr.SelectRegions = new List <RowCol>(); pr.RollbackType = RollbackType.percentage; _monitorRollbackLine.BenMAPRollbacks.Add(pr); _currentBenMAPRollback = pr; pc._PercentageRollback = pr; this.flowLayoutPanel1.Controls.Add(pc); dicRegion.Add(lablePc.Text, regionIDInt); break; case "Incremental": IncrementalControl ic = new IncrementalControl(); if (i == 0 && j == 0 && k == 0) { ic.Location = new Point(0, 0); } else { ic.Location = new Point(0, i * 101 + j * 101 + k * 370 + (i + j + k - 1) * 1); } Label lableIc = new Label(); ic.Controls.Add(lableIc); while (dicRegion.ContainsValue(regionnumber)) { regionnumber++; } lableIc.Text = "Region" + " " + regionnumber.ToString(); lableIc.Location = new Point(40, 3); Button buttonIc = new Button(); ic.Controls.Add(buttonIc); buttonIc.Size = new Size(35, 23); buttonIc.Location = new Point(0, 0); buttonIc.Text = ""; Random randomIc = new Random(); buttonIc.BackColor = Color.FromArgb(randomIc.Next(255), randomIc.Next(255), randomIc.Next(255)); ic.Name = lableIc.Text; reg = new Regex(@"\D"); s = reg.Replace(lableIc.Text, ""); regionIDInt = int.Parse(s); ic.RegionID = regionIDInt; IncrementalRollback ir = new IncrementalRollback(); ir.DrawingColor = buttonIc.BackColor.R + "," + buttonIc.BackColor.G + "," + buttonIc.BackColor.B; ir.RegionID = regionIDInt; ir.SelectRegions = new List <RowCol>(); ir.RollbackType = RollbackType.incremental; _monitorRollbackLine.BenMAPRollbacks.Add(ir); _currentBenMAPRollback = ir; ic._IncrementalRollback = ir; this.flowLayoutPanel1.Controls.Add(ic); dicRegion.Add(lableIc.Text, regionIDInt); break; case "ToStandard": ToStandardControl sc = new ToStandardControl(_monitorRollbackLine.Pollutant); if (i == 0 && j == 0 && k == 0) { sc.Location = new Point(0, 0); } else { sc.Location = new Point(0, i * 101 + j * 101 + k * 370 + (i + j + k - 1) * 1); } Label lableSc = new Label(); sc.Controls.Add(lableSc); while (dicRegion.ContainsValue(regionnumber)) { regionnumber++; } lableSc.Text = "Region" + " " + regionnumber.ToString(); lableSc.Location = new Point(40, 3); Button buttonSc = new Button(); sc.Controls.Add(buttonSc); buttonSc.Size = new Size(35, 23); buttonSc.Location = new Point(0, 0); buttonSc.Text = ""; Random randomSc = new Random(); buttonSc.BackColor = Color.FromArgb(randomSc.Next(255), randomSc.Next(255), randomSc.Next(255)); reg = new Regex(@"\D"); s = reg.Replace(lableSc.Text, ""); regionIDInt = int.Parse(s); StandardRollback sr = new StandardRollback(); sr.DrawingColor = buttonSc.BackColor.R + "," + buttonSc.BackColor.G + "," + buttonSc.BackColor.B; sr.RegionID = regionIDInt; sr.SelectRegions = new List <RowCol>(); sr.RollbackType = RollbackType.standard; _monitorRollbackLine.BenMAPRollbacks.Add(sr); _currentBenMAPRollback = sr; sc._StandardRollback = sr; this.flowLayoutPanel1.Controls.Add(sc); dicRegion.Add(lableSc.Text, regionIDInt); break; default: break; } int flpCtlInx = this.flowLayoutPanel1.Controls.Count - 1; if (this.flowLayoutPanel1.Controls[flpCtlInx].Controls[1].GetType().Name == "Label") { cboDeleteRegion.Items.Add(this.flowLayoutPanel1.Controls[flpCtlInx].Controls[1].Text); } cboDeleteRegion.SelectedIndex = cboDeleteRegion.Items.Count - 1; } catch (Exception ex) { Logger.LogError(ex); } }