• C# 画圆角矩形


                int width = panel2.Width;
                int height = panel2.Height;
                int lineWeight = 10;//边框宽
                int radio = 30;//圆周半径
                Graphics g = panel2.CreateGraphics();
                //panel1.BackColor = System.Drawing.Color.Transparent;
                Bitmap bm = new Bitmap(width, width);
                Graphics grs = Graphics.FromImage(bm);
                grs.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                grs.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                grs.Clear(Color.White);
                int padding = 15;//向内缩进
                //左上圆角
                grs.FillPie(Brushes.LightSalmon, padding, padding, radio * 2, radio * 2, 180, 90);
                //左下
                grs.FillPie(Brushes.LightSalmon, padding, height - 2 * radio - padding, radio * 2, radio * 2, 90, 90);
                //右上
                grs.FillPie(Brushes.LightSalmon, width - 2 * radio - padding, padding, radio * 2, radio * 2, 270, 90);
                //右下
                grs.FillPie(Brushes.LightSalmon, width - 2 * radio - padding, height - 2 * radio - padding, radio * 2, radio * 2, 0, 90);

                //竖向矩形
                grs.FillRectangle(Brushes.LightSalmon, radio + padding - 1, padding, width - 2 * radio - 2 * padding + 2, height - 2 * padding);
                //横向矩形
                grs.FillRectangle(Brushes.LightSalmon, padding, radio - 1 + padding, width - 2 * padding, height - 2 * radio - 2 * padding + 2);

                if (lineWeight > 0)
                {
                    Pen p = new Pen(Brushes.Blue, lineWeight);
                    //左上弧
                    grs.DrawArc(p, padding, padding, radio * 2, radio * 2, 180, 90);
                    //左下
                    grs.DrawArc(p, padding, height - 2 * radio - padding, radio * 2, radio * 2, 90, 90);
                    //右上
                    grs.DrawArc(p, width - 2 * radio - padding, padding, radio * 2, radio * 2, 270, 90);
                    //右下
                    grs.DrawArc(p, width - 2 * radio - padding, height - 2 * radio - padding, radio * 2, radio * 2, 0, 90);

                    //上框
                    grs.DrawLine(p, radio + padding - 1, padding, width - radio - padding + 2, padding);
                    //下
                    grs.DrawLine(p, radio + padding - 1, height - padding, width - radio - padding + 2, height - padding);
                    //左
                    grs.DrawLine(p, padding, radio + padding - 1, padding, height - radio - padding + 2);
                    //右
                    grs.DrawLine(p, width - padding, radio + padding - 1, width - padding, height - radio - padding + 2);
                }


                g.DrawImage(bm, 0, 0);
                grs.Dispose();
                bm.Dispose();
                g.Dispose();

  • 相关阅读:
    script Ngrinder_TestRunnerInsertMysqlSingle.groovy
    nGrinder TestRunnerInsertMysqlSingle.groovy
    列表导航栏实例(02)——精美电子商务网站赏析
    【网络编程】之九、事件选择WSAEventSelect
    注册界面设计(01)——精美电子商务网站赏析
    列表导航栏实例(04)——精美模板赏析
    【网络编程】之十、重叠IO Overlapped IO
    CSS大小设置实例——盒子模型
    常用数据验证正则表达式释义(附:正则表达式常用符号)
    【网络编程】之八、异步选择WSAAsyncSelect
  • 原文地址:https://www.cnblogs.com/biyyss_sun/p/4123838.html
Copyright © 2020-2023  润新知