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 ...
随机推荐
- Python 文件 write() 方法
概述 Python 文件 write() 方法用于向文件中写入指定字符串. 在文件关闭前或缓冲区刷新前,字符串内容存储在缓冲区中,这时你在文件中是看不到写入的内容的. 语法 write() 方法语法如 ...
- 关于try catch
说明try块中有return语句时,仍然会首先执行finally块中的语句,然后方法再返回. 如果try块中存在System.exit(0);语句,那么就不会执行finally块中的代码,因为Syst ...
- JS实现PC、Android、IOS端的点击按钮复制内容功能
直接上代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...
- linux关闭selinux和firewall
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config setenforce 0
- tengine 的优化
查服务器CPU的核数 : [root@c01 conf]# grep processor /proc/cpuinfo |wc -l 4 [root@c01 conf]# grep -c process ...
- lua -- string
table.keys 返回指定表格中的所有键. 格式: keys = table.keys(表格对象) 用法示例: , b = , c = } local keys = table.keys(t) - ...
- (原创)一个和c#中Lazy<T>类似的c++ Lazy<T>类的实现
在.net 4.0中增加一个延迟加载类Lazy<T>,它的作用是实现按需延迟加载,也许很多人用过.一个典型的应用场景是这样的:当初始化某个对象时,该对象引用了一个大对象,需要创建,这个对象 ...
- localtime 和 localtime_r
#include <cstdlib> #include <iostream> #include <time.h> #include <stdio.h> ...
- Python Redis pipeline操作和Redis乐观锁保持数据一致性
Redis是建立在TCP协议基础上的CS架构,客户端client对redis server采取请求响应的方式交互. redis 乐观锁:也可理解为版本号比较机制,主要是说在读取数据逇时候同时读取其版本 ...
- Asp.Net IIS7.5伪静态设置
注意:先要将应用池设置为集成模式,修改OK后,再改成经典模式.否则,什么托管程序出不来. 1.新建网站,这里不做介绍,很简单.并把网站设置为集成模式 2.添加通配符脚本映射 打开之后显示如下界面,在右 ...