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

DOTNETBAR制作圆角窗体和圆角控件代码实例

程序员文章站 2024-02-22 10:00:28
1、如果制作圆角窗体,窗体先继承dotnetbar的:public partial class form2 : devcomponents.dotnetbar.office...

1、如果制作圆角窗体,窗体先继承dotnetbar的:public partial class form2 : devcomponents.dotnetbar.office2007form

然后窗体里加上一个donterbar的panel,然后设置panel为fill占满整个窗体

然后设置panel的cornertype为rounded,然后窗体就变为圆角的了: panelex1.style.cornertype = devcomponents.dotnetbar.ecornertype.rounded;

2、如果是圆角控件就照葫芦画瓢,把panel放在控件上面,然后设置为fill,再设置panel的cornertype为rounded就变为圆角控件了

dotnetbar的button控件默认就可以设置为圆角按钮的

今天弄个了一天最后弄出了圆角窗体,可是不是用dotnetbar,原来dotnetbar实现不了,以下是本人实现圆角窗体的代码

 

复制代码 代码如下:

 /// <summary>
        /// 重绘窗体为圆角
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dispenserform_paint(object sender, painteventargs e)
        {
            form form = ((form)sender);
            list<point> list = new list<point>();
            int width = form.width;
            int height = form.height;

            //左上
            list.add(new point(0, 5));
            list.add(new point(1, 5));
            list.add(new point(1, 3));
            list.add(new point(2, 3));
            list.add(new point(2, 2));
            list.add(new point(3, 2));
            list.add(new point(3, 1));
            list.add(new point(5, 1));
            list.add(new point(5, 0));
            //右上
            list.add(new point(width - 5, 0));
            list.add(new point(width - 5, 1));
            list.add(new point(width - 3, 1));
            list.add(new point(width - 3, 2));
            list.add(new point(width - 2, 2));
            list.add(new point(width - 2, 3));
            list.add(new point(width - 1, 3));
            list.add(new point(width - 1, 5));
            list.add(new point(width - 0, 5));
            //右下
            list.add(new point(width - 0, height - 5));
            list.add(new point(width - 1, height - 5));
            list.add(new point(width - 1, height - 3));
            list.add(new point(width - 2, height - 3));
            list.add(new point(width - 2, height - 2));
            list.add(new point(width - 3, height - 2));
            list.add(new point(width - 3, height - 1));
            list.add(new point(width - 5, height - 1));
            list.add(new point(width - 5, height - 0));
            //左下
            list.add(new point(5, height - 0));
            list.add(new point(5, height - 1));
            list.add(new point(3, height - 1));
            list.add(new point(3, height - 2));
            list.add(new point(2, height - 2));
            list.add(new point(2, height - 3));
            list.add(new point(1, height - 3));
            list.add(new point(1, height - 5));
            list.add(new point(0, height - 5));

            point[] points = list.toarray();

            graphicspath shape = new graphicspath();
            shape.addpolygon(points);

            //将窗体的显示区域设为graphicspath的实例
            form.region = new system.drawing.region(shape);
        }