//绘制圆角矩形
        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);
            }
        }
Пример #2
0
 //绘制椭圆   调用Drawing 的绘制椭圆方法
 public override void draw(Graphics g, Color c)
 {
     drawRec(getP1(), getP2());
     g.DrawEllipse(BaseShape.getPen(c), rec);
 }
Пример #3
0
 //重写画方法
 public override void draw(Graphics g, Color c)
 {
     //画线
     g.DrawLine(BaseShape.getPen(c), this.getP1(), this.getP2());
 }