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. 听说尤雨溪在开发vue4.0?是谁煽动了前端圈的焦虑情绪

    导火索因P图而起 今天前端圈里被一张P图搞得好热闹,最初只是QQ群里一个冒名尤雨溪的前端网友发了一句调侃的话,原话截图如下: 看完觉得好搞笑,说尤雨溪在开发vue4.0,有谁学不动了,就给他发10块钱 ...

  2. spring boot 加载application配置文件

    这就要注意了

  3. CodeForces 1143 B. Nirvana

    题目 解决思路是,每个位上都是9的情况,遍历一下就可以了. #include <iostream> using namespace std; int n; int a[35]; int m ...

  4. jmeter常用插件介绍

    一.下载安装及使用 下载地址:jmeter-plugins.org 安装:下载后文件为plugins-manager.jar格式,将其放入jmeter安装目录下的lib/ext目录,然后重启jmete ...

  5. jmeter 之变量传递

    最近遇到个问题,一个线程组的变量怎么应用到另一个线程组,试了下,通过提取器设置的变量只能用于当前线程组,不能用于其他线程组,只能试试设置property Parameters,应该还有别的办法这只是其 ...

  6. esp32固件烧录

    正常使用IO0置空即可.烧录时需要en引脚接高电平,IO0接地,使用乐鑫的烧录工具烧录即可.注意如果启用wifi,供电一定要不小于500ma,普通的usb转ttl模块无法满足wifi启动的,被坑的好惨 ...

  7. Luogu4587 [FJOI2016]神秘数

    题目大意:给定一个长度为$n$的正整数序列$a_i$,$m$次询问,每次询问$[l,r]$,求最小的无法表示成$a_l,a_{l+1},\ldots,a_r$的子集之和的正整数. 数据范围:$1\le ...

  8. MySQL中0、'0'作为条件时的区别

    一.现象: 今天查询时,某字段x为varchar 可能的值为A B C 0 1 2 3 4 想把0 1 2 3 4的所有数据查出,使用的SQL为 select * from table where x ...

  9. 常用sql 集合记录整理

    select 'truncate table ' + Name + ';' from sysobjects where xtype='U' order by name asc; -- 查询出指定库的 ...

  10. levmar : Levenberg-Marquardt库编译

    levmar : Levenberg-Marquardt 是非线性优化的一个库 1.使用CMake生成sln项目,编译 clapack库 在levmar工程中,打开misc.c文件,在最开始添加#in ...