public override void mouseDrag(object sender, MouseEventArgs e) { a.Add(new Point(e.X, e.Y)); Graphics gra = this.getRefCADPanel().PictureBox.CreateGraphics(); this.getOperShape().setP2(new Point(e.X, e.Y)); gra.DrawLine(BaseShape.getPen((Color)this.getRefCADPanel().c[this.getRefCADPanel().c.Count - 1]), this.getOperShape().getP1(), this.getOperShape().getP2()); this.getOperShape().setP1(this.getOperShape().getP2()); gra.Dispose(); }
public override void draw(Graphics g, Color c) { try { g.DrawCurve(BaseShape.getPen(c), P); } catch (Exception e) { } }
public override void draw(Graphics g, Color c) { drawRec(getP1(), getP2()); g.DrawRectangle(BaseShape.getPen(c), rec); }
//绘制圆角矩形 public override void draw(Graphics g, Color c) { drawRec(getP1(), getP2()); int a = 30; Pen p = BaseShape.getPen(c); int h = Math.Abs(getP1().Y - getP2().Y); int w = Math.Abs(getP1().X - getP2().X); int x = getP1().X; int y = getP1().Y; int x1 = getP2().X; int y1 = getP2().Y; //移动到原点右下 if (x > x1 && y > y1) { g.DrawArc(p, x - a, y - a, a, a, 0, 90); g.DrawLine(p, x + a / 2 - w, y, x - a / 2, y); g.DrawArc(p, x1, y - a, a, a, 90, 90); g.DrawLine(p, x, y - h + a / 2, x, y - a / 2); g.DrawLine(p, x1, y - h + a / 2, x1, y - a / 2); g.DrawArc(p, x - a, y - h, a, a, 0, -90); g.DrawLine(p, x + a / 2 - w, y1, x - a / 2, y1); g.DrawArc(p, x1, y1, a, a, 180, 90); } //移动到原点左下 if (x > x1 && y < y1) { g.DrawArc(p, x - a, y, a, a, 0, -90); g.DrawLine(p, x1 + a / 2, y, x - a / 2, y); g.DrawArc(p, x1, y, a, a, 180, 90); g.DrawLine(p, x, y + a / 2, x, y + h - a / 2); g.DrawLine(p, x - w, y + a / 2, x - w, y + h - a / 2); g.DrawArc(p, x1, y + h - a, a, a, 180, -90); g.DrawLine(p, x1 + a / 2, y + h, x - a / 2, y + h); g.DrawArc(p, x - a, y + h - a, a, a, 0, 90); } //移动到原点右上 if (x < x1 && y > y1) { g.DrawArc(p, x, y - a, a, a, 90, 90); g.DrawLine(p, x + a / 2, y, x - a / 2 + w, y); g.DrawArc(p, x + w - a, y - a, a, a, 0, 90); g.DrawLine(p, x, y - a / 2, x, y - h + a / 2); g.DrawLine(p, x + w, y - a / 2, x + w, y - h + a / 2); g.DrawArc(p, x1 - a, y1, a, a, 0, -90); g.DrawArc(p, x, y - h, a, a, 180, 90); g.DrawLine(p, x + a / 2, y1, x - a / 2 + w, y1); } //移动到原点左上 if (x < x1 && y < y1) { g.DrawArc(p, x, y, a, a, 180, 90); g.DrawLine(p, x + a / 2, y, x - a / 2 + w, y); g.DrawArc(p, x + w - a, y, a, a, 270, 90); g.DrawLine(p, x, y + a / 2, x, y - a / 2 + h); g.DrawArc(p, x, y1 - a, a, a, 90, 90); g.DrawLine(p, x + a / 2, y1, x + w - a / 2, y1); g.DrawArc(p, x1 - a, y1 - a, a, a, 0, 90); g.DrawLine(p, x + w, y + a / 2, x + w, y1 - a / 2); } }
//重写画方法 public override void draw(Graphics g, Color c) { //画线 g.DrawLine(BaseShape.getPen(c), this.getP1(), this.getP2()); }