public void Remove(DShape d) { for (int i = 0; i < wholeList.Count; i++) { if (wholeList[i] == d) { wholeList.RemoveAt(i); return; } } }
private void Test_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) { if (curSelect != null) { IgList.Remove(curSelect); curSelect = null; pb.Refresh(); } } }
public void Add(DShape d) { List.Add(d); }
public void Add(DShape d) { wholeList.Add(d); }
private void ResetBtn(ToolStripButton bt) { flag = 0; MuiltPoint = new List <Point>(); igTmp = null; if (curSelect != null) { curSelect.IsNear = false; curSelect = null; } ReDraw(this.pb.CreateGraphics(), false); for (int i = 0; i < this.toolStrip1.Items.Count; i++) { ToolStripButton _tb = toolStrip1.Items[i] as ToolStripButton; if (_tb != null) { _tb.Checked = false; } } switch (bt.Name) { case "btnMuiltLine": tp = ImageType.MuiltLine; break; case "btnPick": tp = ImageType.Empty; break; case "btnLine": tp = ImageType.Line; break; case "btnHollowCir": tp = ImageType.HollowCir; break; case "btnHollowEllipse": tp = ImageType.HollowEllipse; break; case "btnHollowRec": tp = ImageType.HollowRectangle; break; case "btnString": tp = ImageType.Text; break; case "btnArc": tp = ImageType.Arc; break; case "btnPie": tp = ImageType.Pie; break; case "btnPolygon": tp = ImageType.Polygon; break; } bt.Checked = true; }
private void pb_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { pt_old = e.Location; if (tp == ImageType.Empty) { DShape d = IgList.GetNear(e.X, e.Y) as DShape; if (curSelect != null) { curSelect.IsNear = false; curSelect = null; } if (d != null) { d.IsNear = true; curSelect = d; } else { } pb.Refresh(); } else { MuiltPoint.Add(pt_cur); if (flag == 1) { switch (tp) { case ImageType.Line: Ig = new DLine(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; this.pb.Refresh(); break; case ImageType.HollowCir: Ig = new DHollowCircle(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; this.pb.Refresh(); break; case ImageType.MuiltLine: igTmp = new DMuiltLine(MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); this.pb.Refresh(); break; case ImageType.Polygon: break; case ImageType.Text: frmDrawText frm = new frmDrawText(); DialogResult drs = frm.ShowDialog(); if (drs == DialogResult.OK) { Ig = new DText(MuiltPoint, this.btnColor.BackColor, frm.txtStr.Text, frm.GetFont); IgList.Add(Ig); } MuiltPoint = new List <Point>(); flag = 0; this.pb.Refresh(); break; case ImageType.HollowEllipse: case ImageType.HollowRectangle: if (tp == ImageType.HollowRectangle) { Ig = new DHollowRectangle(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); } else { Ig = new DHollowEllipse(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); } IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; this.pb.Refresh(); break; case ImageType.Arc: case ImageType.Pie: igTmp = new DLine(MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); flag = 2; pb.Refresh(); break; } } else { if (flag == 2) { if (tp == ImageType.Arc) { Ig = new DArc(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); } else { Ig = new DPie(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); } IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; igTmp = null; this.pb.Refresh(); } else { flag = 1; } } } } else { if (flag == 1) { if (tp == ImageType.MuiltLine) { Ig = new DMuiltLine(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); this.IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; } else if (tp == ImageType.Polygon) { Ig = new DPolygon(this.MuiltPoint, this.btnColor.BackColor, (this.cboLine.SelectedIndex + 1) * zoom / 100); this.IgList.Add(Ig); MuiltPoint = new List <Point>(); flag = 0; } } } }