zoukankan      html  css  js  c++  java
  • C# JackLib系列之GdiHelper圆角矩形的快速生成

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Drawing2D;

    namespace JackLib.GdiHelper {

        /// <summary>
        /// GdiHelper
        /// </summary>
        public class GdiHelper {
            /// <summary>
            /// 获取圆角矩形
            /// </summary>
            /// <param name="rect">原始矩形</param>
            /// <param name="radius">圆角大小(像素)</param>
            /// <returns></returns>
            public static GraphicsPath GetRoundRectangle(Rectangle rect, int radius) {
                GraphicsPath path = new GraphicsPath();
                Point lefttop = new Point(rect.X, rect.Y);
                Point righttop = new Point(rect.X + rect.Width, rect.Y);
                Point rightbottom = new Point(rect.X + rect.Width, rect.Y + rect.Height);
                Point leftbottom = new Point(rect.X, rect.Y + rect.Height);
                path.AddArc(lefttop.X, lefttop.Y, radius * 2, radius * 2, 180, 90);
                path.AddLine(lefttop.X + radius, lefttop.Y, righttop.X - radius, righttop.Y);
                path.AddArc(righttop.X - radius * 2, righttop.Y, radius * 2, radius * 2, 270, 90);
                path.AddLine(righttop.X, righttop.Y + radius, rightbottom.X, rightbottom.Y - radius);
                path.AddArc(rightbottom.X - radius * 2, rightbottom.Y - radius * 2, radius * 2, radius * 2, 0, 90);
                path.AddLine(rightbottom.X - radius, rightbottom.Y, leftbottom.X + 5, leftbottom.Y);
                path.AddArc(leftbottom.X, leftbottom.Y - radius * 2, radius * 2, radius * 2, 90, 90);
                path.AddLine(lefttop.X, leftbottom.Y - radius, lefttop.X, lefttop.Y + radius);
                path.CloseFigure();
                return path;
            }
        }
    }


  • 相关阅读:
    strcat strcpy 使用出现的问题汇总
    MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法
    nginx 设置反响代理实现nginx集群
    js 去掉字符串最后一个字符
    二维数组 获取某键值集合
    oracle 序列
    递归数据查询
    oracle 递归查询
    jQuery EasyUI API 中文文档
    SecureCRT使用的技巧 键盘修改
  • 原文地址:https://www.cnblogs.com/shaozhuyong/p/5130528.html
Copyright © 2011-2022 走看看