用Drawing画图如何不会消失
1: protected void MainForm_Load(object sender,EventArgs e)
2: {
3: InitialPoint();
4: Bitmap bm = new Bitmap(this.Width,this.Height);
5: Graphics grp = Graphics.FromImage(bm);
6: DrawCurves(grp,lpt);
7: pictureBox1.Image =bm;
8: //if use load event,then use bitmap,if not ,there is no need.
9:
10: }
方法二:利用picturebox画图,放在Load事件中。
1: protected void MainForm_Load(object sender,EventArgs e)
2: {
3: InitialPoint();
4: Bitmap bm = new Bitmap(pictureBox1.Width,pictureBox1.Height);
5: pictureBox1.Image =bm;
6: using(Graphics grp =Graphics.FromImage(pictureBox1.Image))
7: {
8: DrawCurves(grp,lpt);
9: }
10:
11: }
方法三:将事件放在Paint事件中,这个只能放在form中,因为grp本例和e无关,但是参数是:PaintEventArgs e
1: private void Form1_Paint(object sender, PaintEventArgs e)
2: {
3: //if in this method,there is no need to use bitmap
4: InitialPoint();
5: Graphics grp =this.CreateGraphics();
6: DrawCurves(grp,lpt);
7: }
方法四:paint事件,在picturebox上,按照下边这个例子,用e这个参数,不仅可以放在form的paint上,也可以放在picturebox的paint上
1: private void pic_paint(object sender,PaintEventArgs e)
2: {
3: Graphics g = e.Graphics;
4: DrawCurves(g,lpt);
5: }
1: private void DrawCurves(Graphics grp, List<Point> pointList)
2: {
3: Point[] temps = new Point[pointList.Count];
4: pointList.CopyTo(temps);
5: grp.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
6: grp.DrawCurve(new Pen(Color.Red, 2), temps);
7: // grp.Dispose();如果用Paint事件绘图,这个似乎不可以
8: }
注明:lpt是一个List<Point>
用Drawing画图如何不会消失的更多相关文章
- 英语进阶系列-A04-英语升级练习二
古诗背诵 要求:背诵和朗读,然后翻译成现代文,并绘制图像描述图中的内容,同时看看某些内容可以用什么单词替换,时间限制到15 minutes. 速记词汇系列 要求:将词汇快速朗读并记忆,时间为8 min ...
- C# 在窗口绘制图形(打点、画圆、画线)
需要包含命名空间 using System.Drawing; 画图前需要先创建画板 void Display() { Graphics g = this.CreateGraphics(); //创建画 ...
- Winform中设置ZedGraph鼠标焦点位置画出十字线并在鼠标移出时十字线消失
场景 Winforn中设置ZedGraph曲线图的属性.坐标轴属性.刻度属性: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/10 ...
- Android开发之画图的实现
Android开发之画图的实现 四天前上完安卓的第一节课,真的是一脸懵逼,尽管熊哥说和java是差不多的,然而这个包和那个包之间的那些转换都是些什么鬼呀!!!但是四天的学习和操作下来,我觉得安卓 ...
- 对Raphael画图标的一个jquery简单封装
公司要做一个项目的demo,要求地图上可以插红旗,所以就用到了Raphael. 因为是个demo,所以地图就用了一张图片,效果如下: 所以为了更好的封装一下这个功能,就写了一个简单的插件:jquery ...
- Algorithmic Graph Drawing in TikZ
最近在写模板时需要画个图 ("图论"的"图"). 本来打算用Windows画图 (mspaint) 的, 但是效果不好, 还是决定用LaTeX的TikZ画. 这 ...
- Graphics 导出图片使用【这个主要是画图类图的使用,记录一下】
/// <summary> /// 导出信令流程矢量图 /// </summary> /// <param name="signalFlowInfos" ...
- c#代码画图
说明:此示例代码在我做的一个项目中 不过还是可以学习一下 一:直角坐标系显示数据 先看效果图:
- IOS 作业项目(4)步步完成 画图 程序(中续)
一,程序布局整理 前言://1,程序启动//2,程序流程框架//3,程序界面一致//4,程序界面功能, //这里只做页面的固定功能, //在首次创建界面时,我们会指定好固定事件触发前的固定方法 //至 ...
随机推荐
- MFC容器类介绍
我们知道如果是单个的少数几个值弄些int , long,float ,double等类型的变量来装这些值就行了.但如果值太多这样就比较麻烦.当然数据超级多时就直接放数据库里存着去了. 但如果数值不多不 ...
- Eclipse和Android Studio中的DDMS使用时什么不同?
http://www.jb51.net/softjc/454131.html Eclipse和Android Studio中的DDMS使用时什么不同? 相信很多经常开发Android应用的朋友应该都接 ...
- 编写一个JavaScript函数 parseQueryString,把URL参数解析为一个对象
var url="http://www.taobao.com/index.php?key0=0&key1=1&key2=2"; function parseQuer ...
- ZooKeeper是什么?
What is ZooKeeper? (译:什么是ZooKeeper?) ZooKeeper is a centralized service for maintaining configuratio ...
- thinkphp关联查询
$list=$model->table("$dName d ,$mName m,$cName c") ->field('d.*,m.title as musicTitl ...
- 微信公共服务平台开发(.Net 的实现)13-------网页授权(下 :C#代码的实现 )
接着上次的理论,我们这次来研究用代码实现“网页授权获取用户基本信息”,首先我们需要一个链接指向微信的授权页面,在微信开发平台中已经说了,这个链接必须在微信客户端中打开,那么我们就干脆使用文本消息来完成 ...
- [Angular2 Router] Use Params from Angular 2 Routes Inside of Components
Angular 2’s ActivatedRoute allows you to get the details of the current route into your components. ...
- [Angular2 Router] Build Angular 2 Navigation with routerLink
Angular 2 navigation is configured using the routerLink directive. The routerLink directive behaves ...
- [Angular 2] Order Dynamic Components Inside an Angular 2 ViewContainer
By default, when you generate components, they will simply be added to the page in order, one after ...
- 利用shell脚本统计文件中出现次数最多的IP
比如有如下文件test.txt 1 134.102.173.43 2 134.102.173.43 3 134.102.171.42 4 134.102.170.9 要统计出现次数最多的IP可 ...