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. ArcGIS AddIn 批量设置栅格图层背景色为透明

    protected override void OnClick() { // // TODO: Sample code showing how to access button host // Arc ...

  2. fatal error LNK1120: 11 unresolved externals

    一般原因是函数声明没有定义,或者c++文件没有包含include进来

  3. ul的margin撑不开想要的距离的办法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. logback使用注意点1

    logback中配置了springProfile(策略),因此在properties中只需要配置如下即可logging.config=./config/logback.xml //logback配置文 ...

  5. 深入理解iostat

    前言 iostat算是比较重要的查看块设备运行状态的工具,相信大多数使用Linux的同学都用过这个工具,或者听说过这个工具.但是对于这个工具,引起的误解也是最多的,大多数人对这个工具处于朦朦胧胧的状态 ...

  6. VSCode打开多个项目文件夹的解决方法

    最近从sublime转vscode,自然而然就会把sublime的一些习惯带过来,其中有一点让人头疼的是: 当把一个文件夹拖进vscode里面的时候,会把原来的文件夹覆盖掉,这就意味着不能同时在vsc ...

  7. APP偏移地址

    配合BootLoader的APP程序 SCB->VTOR = 0x0803C004; 这里最后还要加上4的原因是 向量表的复位向量地址是4 0地址存的是栈顶

  8. 数据结构优化dp

    本以为自己的dp已经成熟了没想到在优化上面还是欠佳 或者是思路方面优化dp还不太行. 赤壁之战 当然 很有意思的题目描述 大体上是苦肉计吧 .盖黄 ... 题意是 求出长度为m的严格上升子序列的个数 ...

  9. Logstash - Working with plugins(使用插件)

    本章节开始介绍logstash的插件及功能,插件对于logstash来说非常重要,按类别分为:input.filter.codec.output四种类型. logstash有非常丰富的插件,通过安装目 ...

  10. 透过实现小型打包工具理解webpack

    面试经常有问到 webpack,偶遇一篇比较有实用价值的且有利于理解的文章,现总结如下: 本篇文章中要实现的这个迷你打包工具,它主要能实现如下两个功能: ①.将 ES6 转换成 ES5: ②.支持在 ...