使用
Double-Buer
来实现无闪烁动态折线图
最近研究实时数据相关问题,要求做出实时数据曲线,在网上找了好多例子,大家各有特点。不过对与无闪烁的这个例子
还是很感兴趣。下面针对该例子进行详解,以便初学者能直观的使用。
使用 VS2008 新建一个 C#Windows 窗体程序,命名为 GraphView,主窗体中需要修改的参数为以下:
Name:frmGraphView
AutoScaleMode:Font
FormBorderStyle:FixedSingle
MaximizeBox:False
Size:500,405
StartPosition:CenterScreen
Text:Graph View
添加控件 PictureBox,该控件需要修改的参数如下:
Name:picGraph
BackColor:Black
BorderStyle:Fixed3D
Dock:Fill
Size:494,373
在 Form1.cs 文件:
需要引用的命名空间:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Drawing.Imaging;
using System.Collections;
为主窗体添加相应函数 FormClosing,在主窗体的 FormClosing 中双击就 OK,同样的操作为 PictureBox 控件添加 Paint 函数。
程序所有代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
评论25