首先是需求,需要制作一个聊天气泡, 但是winform中有没有类似Android的.9图,只有自己设计图形拼接气泡。

第一种是绘制空心三角形,第二种是绘制三角形区域,可以指定RGB颜色。

private void Form1_Paint(object sender, PaintEventArgs e)
{
Pen pen = new Pen(Color.Red, );
e.Graphics.DrawLine(pen, , , , );
e.Graphics.DrawLine(pen, , , , );
e.Graphics.DrawLine(pen, , , , ); Color color = System.Drawing.Color.FromArgb(((int)(((byte)()))), ((int)(((byte)()))), ((int)(((byte)()))));
Brush brushes = new SolidBrush(color);
Point[] point new Point[];
point[] = new Point(,10);
point[] = new Point(10,);
point[] = new Point(10,10);
e.Graphics.FillPolygon(brushes, point);
}

效果:

可以作为气泡中的箭头,另外四个角用椭圆:

Winform仿制QQ微信聊天窗口气泡

绘制圆角矩形的代码:

//窗口圆角
private void Main_Paint(object sender, PaintEventArgs e)
{
List<Point> list = new List<Point>();
int width = this.Width;
int height = this.Height; #region 四个圆角 //左上
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, ));
list.Add(new Point(, )); //右上
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , ));
list.Add(new Point(width - , )); //右下
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - ));
list.Add(new Point(width - , height - )); //左下
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - ));
list.Add(new Point(, height - )); #endregion Point[] points = list.ToArray(); GraphicsPath shape = new GraphicsPath();
shape.AddPolygon(points); this.Region = new System.Drawing.Region(shape); }

C#绘制三角形并填充,使用winform实现qq聊天气泡的更多相关文章

  1. winform实现QQ聊天气泡200行代码

    c# winform实现QQ聊天气泡界面,原理非常简单,通过webKitBrowser(第三方浏览器控件,因为自带的兼容性差)加载html代码实现,聊天界面是一个纯HTML的代码,与QQ的聊天界面可以 ...

  2. Linux OpenGL 实践篇-3 绘制三角形

    本次实践是绘制两个三角形,重点理解顶点数组对象和OpenGL缓存的使用. 顶点数组对象 顶点数组对象负责管理一组顶点属性,顶点属性包括位置.法线.纹理坐标等. OpenGL缓存 OpenGL缓存实质上 ...

  3. WebGL编程指南案例解析之绘制三角形

    //案例3.绘制三角形,将顶点数据存到缓冲区对象(gl.ARRAY_BUFFER)中,然后顶点着色器从里面读数据(3个顶点) //顶点着色器中去掉gl_PointSize = 10.0,绘制三角不能设 ...

  4. C#中画三角形和填充三角形的简单实现

    C#中画三角形和填充三角形的简单实现: private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graph ...

  5. 纯CCS绘制三角形箭头图案

    用CSS绘制三角形箭头.使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头! CSS代码: /* create an arrow that points up */ div.ar ...

  6. unity 绘制三角形

    哎 该学的还是要学 参考:http://www.narkii.com/club/thread-369573-1.html unity 顶点绘制三角形 脚本绘制; 其实filter和render就是进行 ...

  7. CSS 魔法系列:纯 CSS 绘制三角形(各种角度)

    我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...

  8. css绘制三角形原理

    1.新建一个元素,将它的宽高都设置为0:然后通过设置border属性来实现三角形效果,下面是css绘制三角形的原理: <!DOCTYPE html> <html> <he ...

  9. 【转载】理解GL_TRIANGLE_STRIP等绘制三角形序列的三种方式

    GL_TRIANGLE_STRIP绘制三角形方式很多时候令人疑惑,在这里对其运作机理进行解释. 一般情况下有三种绘制一系列三角形的方式,分别是GL_TRIANGLES.GL_TRIANGLE_STRI ...

随机推荐

  1. 安卓7.0遇到 android.os.FileUriExposedException: file:///storage/emulated.. exposed beyond app through Intent.getData()

    1.在AndroidManifest.xml中添加如下代码 <?xml version="1.0" encoding="utf-8"?> <m ...

  2. TextView的实现原理介绍

    记得之前在腾讯面试的时候,被面试官问到这个问题.之前认为没什么特别的,一位是面试官有益问些刁钻的问题来压工资,如今看来当是确实是懂得不多啊. 今天看到就转载过来也方便自己和他人一起来了解.探寻这个简单 ...

  3. 第一篇:初识ASP.NET控件开发_第一节:控件类及其继承关系

    1)System.Web.UI.Control(以下简称Control) Control 类是包括自定义控件.用户控件和页在内的所有 ASP.NET 服务器控件的基类..定义由所有 ASP.NET 服 ...

  4. win7 安装mysql 5.7.9记录

    -------------------------------------------------------------------------- 1. 将配置文件my.ini配置好,放到c:/wi ...

  5. Hadoop创建/删除文件夹出错

    log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFact ...

  6. eclipse自动切换到debug视图

    原文出自:http://blog.csdn.net/yizhizouxiaqu/article/details/7594502 当弹出"Confir Perspective Switch&q ...

  7. Objective的头文件@interface属性

    源码:http://files.cnblogs.com/ios8/TestPropertyDemo.zip 1 前言 最近有个疑惑 @interface中的属性和@property声明的属性有什么区别 ...

  8. [svc]centos6上部署openvpn+gg二步认证

    最近又发现个新的vpn: wireguard 为了满足员工在家办公的需求.需要 openvpn+gg方案 在centos6上部署openvpn 参考 1.安装前准备 wget -O /etc/yum. ...

  9. EMIT 动态创建类型

    https://www.cnblogs.com/xiaodlll/p/4029051.html  值得一读

  10. 【Unity】3.5 导入音频文件

    分类:Unity.C#.VS2015 创建日期:2016-04-05 一.简介 音频文件 (Audio File) 资源的选择原则应该以无故障地流畅运行为宗旨.下面列出了常用的音频文件. .AIFF ...