public Form1()
{
InitializeComponent(); this.BackColor = ColorTranslator.FromHtml("#F7F1F1");
this.TransparencyKey = ColorTranslator.FromHtml("#F7F1F1");
this.label1.Text = "ccccccccccccccccccccccccccccc";
this.label1.BackColor = Color.White;
this.Opacity = ;
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.Orange, ButtonBorderStyle.Solid);
//Draw(e.ClipRectangle, e.Graphics, 80);
//Bitmap bitmap = new Bitmap(384, 305);
//for (int i = 0; i < bitmap.Height; i++)
//{
// bitmap.SetPixel(i, i, Color.Black);
//}
//bitmap.SetPixel(2, 2, Color.Black);
//e.Graphics.DrawImage(bitmap, new Point(0, 0));
//bitmap.Save(@"d:\c.png");
SolidBrush solidBrush = new SolidBrush(Color.White);
var gpath = DrawRoundRect(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height, );
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.FillPath(solidBrush, gpath);
e.Graphics.DrawPath(Pens.White, gpath);
} /// <summary>
/// 设置窗体的Region
/// </summary>
public void SetWindowRegion()
{
GraphicsPath FormPath;
Rectangle rect = new Rectangle(, , this.Width, this.Height);
FormPath = GetRoundedRectPath(rect, );
this.Region = new Region(FormPath); }
/// <summary>
/// 绘制圆角路径
/// </summary>
/// <param name="rect"></param>
/// <param name="radius"></param>
/// <returns></returns>
private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
{
int diameter = radius;
Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
GraphicsPath path = new GraphicsPath(); // 左上角
path.AddArc(arcRect, , ); // 右上角
arcRect.X = rect.Right - diameter;
path.AddArc(arcRect, , ); // 右下角
arcRect.Y = rect.Bottom - diameter;
path.AddArc(arcRect, , ); // 左下角
arcRect.X = rect.Left;
path.AddArc(arcRect, , );
path.CloseFigure();//闭合曲线
return path;
} /// <summary>
/// 窗体size发生改变时重新设置Region属性
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Resize(object sender, EventArgs e)
{
//SetWindowRegion();
} //重绘边框
private void Draw(Rectangle rectangle, Graphics g, int radius)
{
SolidBrush solidBrush = new SolidBrush(Color.White);
Pen shadowPen = new Pen(solidBrush, );
g.SmoothingMode = SmoothingMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality;
g.DrawPath(shadowPen, DrawRoundRect(rectangle.X, rectangle.Y, rectangle.Width - , rectangle.Height - , radius));
}
public static GraphicsPath DrawRoundRect(int x, int y, int width, int height, int radius)
{
GraphicsPath gp = new GraphicsPath();
//gp.AddArc(x, y, radius, radius, 180, 90);
//gp.AddArc(width - radius, y, radius, radius, 270, 90);
//gp.AddArc(width - radius, height - radius, radius, radius, 0, 90);
//gp.AddArc(x, height - radius, radius, radius, 90, 90);
//gp.CloseAllFigures();
gp.AddArc(x, y, radius, radius, , );
gp.AddArc(width - , y, radius, radius, , );
gp.AddArc(width - radius, height - radius, radius, radius, , );
gp.AddArc(x, height - radius, radius, radius, , );
gp.CloseAllFigures();
return gp;
}

画多边形form并填充背景色(可以实现圆角边框 有锯齿)的更多相关文章

  1. 使用Java、Matlab画多边形闭合折线图

    由于写论文要将“哈密顿回路问题(TSP)”的求解中间结果表示出来,查了一下使用程序画多边形图形.现在在总结一下,这个图是“由给定节点首尾相连的”闭合多边形. 1.使用matlab作闭合多边形图 没有找 ...

  2. 【编程漫谈】用JAVA画多边形

    一门语言只要带图形库就可以编程画图了,用JAVA画图有两种方式,一是在内存中画好然后生成图片,就可以看到画图的效果了.另一个就是在窗口界面上直接画,可以实时看到程序的运行效果.刚开始学编程的时候,我加 ...

  3. 最全vue的vue-amap使用高德地图插件画多边形范围

    一.在vue-cli的框架下的main.js(或者main.ts)中引入高德插件,代码如下: import Vue from 'vue' import VueAMap from 'vue-amap' ...

  4. 一个给力的html5 画多边形的例子

    只需改变参数就能画出你想要的多边形,代码简单!不得不惊叹canvas的强大! 代码奉上 <!doctype html> <html> <head> <meta ...

  5. canvas画多边形

    <canvas id = "myCanvas" width = '500' height = '500'> Canvas画正多边形 </canvas>< ...

  6. OpenLayers 根据坐标动态画多边形

    找了一上午,发现都是鼠标点击画框的,那为什么不标明了是 “鼠标”点击 呢? 想实现的功能是数据库检索坐标集合,然后根据分组提取4点坐标,最后把多个多边形形成图层放在地图上. 最后的实现: <!D ...

  7. qt 画多边形(实现鼠标拖动节点)

    ---恢复内容开始--- 2018-01-06 这个小例子实现了移动鼠标,鼠标的坐标信息跟随鼠标移动,多边形的实现,鼠标点击可以拖动多边形点的位置,(其中有个问题?我在QMainWindow下,用mo ...

  8. Scratch编程:画多边形(八)

    “ 上节课的内容全部掌握了吗?反复练习了没有,编程最好的学习方法就是练习.练习.再练习.一定要记得多动手.多动脑筋哦~~” 01 — 游戏介绍 这节我们将实现:程序提示用户输入数据,然后根据用户的输入 ...

  9. SDL系列之 - 用SDL动态地画一个圆喽 && 设置背景色

    #include <SDL.h> #include <stdlib.h> #include <string.h> #include <math.h> # ...

随机推荐

  1. WinForm打包或部署

    一.新建InstallShield项目 二. 三. 四. 五. 六. 七. 最后重新生成,安装包一般在E\Setup1\Setup1\Express\SingleImage\DiskImages\DI ...

  2. Error creating bean with name 'dataSource' defined in class path resource 报错解决办法

    在学习spring boot 的数据库操作的时候,报了一串错误

  3. js数组元素,获得某个元素的最大值。

    var rows=[{项次:1},{项次:2},{项次:3}]; Math.max.apply(Math, rows.map(function (o) { return o.项次 })) //结果:3 ...

  4. spring boot application.properties 属性详解

    2019年3月21日17:09:59 英文原版: https://docs.spring.io/spring-boot/docs/current/reference/html/common-appli ...

  5. set和 map 数据结构

    set/map数据结构 创建: var  s=new Set(); 添加成员 s.add(1) 遍历 for of s.froEach 删除 s.delete() 判断存在 s.has() 清除 s. ...

  6. 《PHP内核剖析 - FPM》

    一:概述 - FPM 定义 -  FPM(FastCGI Process Manager)是PHP FastCGI运行模式的一个进程管理器. -  FastCGI -  Web服务器(如:Nginx. ...

  7. XXL-JOB之本地环境搭建

    一.源码下载 1.官网地址 登录以下地址查看详细搭建步骤: https://www.cnblogs.com/xuxueli/p/5021979.html 2.下载源码 根据1中打开的页面,下载源码,如 ...

  8. 声明式开发 & 命令式开发

    何为声明式开发,何又为命令式开发~~~ 这里我不做太多概念的剖析,我们只要明确一个: 声明式开发只是告诉计算机需要什么,而不是把每一步都计划好:典型代表为React: 命令式开发则是每一步明确的去操作 ...

  9. centos禁ping

    Linux默认是允许Ping响应的,系统是否允许Ping由2个因素决定的:A.内核参数,B.防火墙,需要2个因素同时允许才能允许Ping,2个因素有任意一个禁Ping就无法Ping. 具体的配置方法如 ...

  10. RCNN的流程

    步骤一: 找到一个CNN分类模型 步骤二: 对于这个模型修改最后的分类层,为21类,去掉最后一个全连接层 步骤三: 根据选择性搜索提取图像的候选区域(框) 对于候选框修改大小以适应CNN输入,然后得出 ...