C#绘制三角形并填充,使用winform实现qq聊天气泡
首先是需求,需要制作一个聊天气泡, 但是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);
}
效果:

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

绘制圆角矩形的代码:
//窗口圆角
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聊天气泡的更多相关文章
- winform实现QQ聊天气泡200行代码
c# winform实现QQ聊天气泡界面,原理非常简单,通过webKitBrowser(第三方浏览器控件,因为自带的兼容性差)加载html代码实现,聊天界面是一个纯HTML的代码,与QQ的聊天界面可以 ...
- Linux OpenGL 实践篇-3 绘制三角形
本次实践是绘制两个三角形,重点理解顶点数组对象和OpenGL缓存的使用. 顶点数组对象 顶点数组对象负责管理一组顶点属性,顶点属性包括位置.法线.纹理坐标等. OpenGL缓存 OpenGL缓存实质上 ...
- WebGL编程指南案例解析之绘制三角形
//案例3.绘制三角形,将顶点数据存到缓冲区对象(gl.ARRAY_BUFFER)中,然后顶点着色器从里面读数据(3个顶点) //顶点着色器中去掉gl_PointSize = 10.0,绘制三角不能设 ...
- C#中画三角形和填充三角形的简单实现
C#中画三角形和填充三角形的简单实现: private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graph ...
- 纯CCS绘制三角形箭头图案
用CSS绘制三角形箭头.使用纯CSS,你只需要很少的代码就可以创作出各种浏览器都兼容的三角形箭头! CSS代码: /* create an arrow that points up */ div.ar ...
- unity 绘制三角形
哎 该学的还是要学 参考:http://www.narkii.com/club/thread-369573-1.html unity 顶点绘制三角形 脚本绘制; 其实filter和render就是进行 ...
- CSS 魔法系列:纯 CSS 绘制三角形(各种角度)
我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...
- css绘制三角形原理
1.新建一个元素,将它的宽高都设置为0:然后通过设置border属性来实现三角形效果,下面是css绘制三角形的原理: <!DOCTYPE html> <html> <he ...
- 【转载】理解GL_TRIANGLE_STRIP等绘制三角形序列的三种方式
GL_TRIANGLE_STRIP绘制三角形方式很多时候令人疑惑,在这里对其运作机理进行解释. 一般情况下有三种绘制一系列三角形的方式,分别是GL_TRIANGLES.GL_TRIANGLE_STRI ...
随机推荐
- 一步一步掌握线程机制(六)---Atomic变量和Thread局部变量
前面我们已经讲过如何让对象具有Thread安全性,让它们能够在同一时间在两个或以上的Thread中使用.Thread的安全性在多线程设计中非常重要,因为race condition是非常难以重现和修正 ...
- WSAAsyncSelect模型触发不了FD_Close消息?
原帖链接: http://bbs.csdn.net/topics/330164174 楼主: Server用WSAAsyncSelect模型,Client关闭程序时(不进行shutdown与close ...
- android发送短信代码(短信内容超长处理)
一条短信只可容纳70个中文,所以当短信长度超过70个中文字符时程序就要特殊处理了. 有两种方式: 1.通过sendTextMessage()方法依次发送拆分后的短信,该方式有个弊端就是用户会分条收到短 ...
- Java – How to get current date time
Java – How to get current date time 1. Code SnippetsFor java.util.Date, just create a new Date() Dat ...
- Matlab 2016b 正式版下载
Matlab 2016b 正式版下载 这两天为完成最优化大作业,zyy又开始鼓捣matlab了.之前我装的是matlab 2013a,发现不支持求解整数规划,遂更新了一下. 下载地址 链接:http ...
- 关于Big Endian 和 Little Endian
Big Endian 和 Little Endian 一.字节序 来自:http://ayazh.gjjblog.com/archives/1058846/ 谈到字节序的问题,必然牵涉到两大CPU派系 ...
- iOS上的http请求:get、post以及同步、异步
1.get: view sourceprint" class="item about" style="color:rgb(51,51,51); text-dec ...
- 互联网创业原则与创业模式attilax大总结
互联网创业原则与创业模式attilax大总结 1. 适合普通人的的创业模式1 1.1. 网络创业 兼职创业 概念创业 团队 创业 内部创业..1 2. 创业模式大总结1 2.1. 工作室创业1 2 ...
- 浅析PCIe链路LTSSM状态机
我们知道,在PCIe链路可以正常工作之前,需要对PCIe链路进行链路训练,在这个过程中,就会用LTSSM状态机.LTSSM全称是Link Training and Status State Machi ...
- 【iOS XMPP】使用XMPPFramewok(三):好友状态
转自:http://www.cnblogs.com/dyingbleed/archive/2013/05/13/3071544.html 好友状态 获取好友状态,通过实现 - (void)xmppSt ...