欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

解析C#中如何把控件的边框角画为圆弧

程序员文章站 2023-12-20 11:25:34
复制代码 代码如下:private void draw(graphics graphics, control control)    ...

复制代码 代码如下:

private void draw(graphics graphics, control control)
        {
            float x = float.parse(control.width.tostring()) - 1;
            float y = float.parse(control.height.tostring()) - 1;
            pointf[] pointfs = {
                new pointf(2,     0),
                new pointf(x-2,   0),
                new pointf(x-1,   1),
                new pointf(x,     2),
                new pointf(x,     y-2),
                new pointf(x-1,   y-1),
                new pointf(x-2,   y),
                new pointf(2,     y),
                new pointf(1,     y-1),
                new pointf(0,     y-2),
                new pointf(0,     2),
                new pointf(1,     1)
                };

            graphicspath path = new graphicspath();
            path.addlines(pointfs);

            pen pen = new pen(color.fromargb(150, color.blue), 1);
            pen.dashstyle = dashstyle.solid;
            graphics.drawpath(pen, path);
        }


首先要把控件注册一个事件:控件名称.paint+=事件名称,然后把以上函数进行传参,如:draw(e.graphics, this.control);

上一篇:

下一篇: