解决方案 »
- SOAP WEB服务 与JAVE对接,实现注意点
- 升级Vs2005 sp1 后 没装sp1的机子Dll链接失败的问题。
- 接口是不是相当于函数声明,但没有定义它的功能?
- 再求救:我可以用process类的某些方法判断某一进程是否已结束吗?怎么写?
- 请问如何获取当前时间?
- 请教:网页对话框接收从其他网页传过来的中文数据是乱码,怎么解决?
- 请教读取Excel文件数据问题
- 关于.NET跨平台!!!
- 关于在foreach参数中 多线程问题 在线等 谢谢了!! foreach (ListViewItem te
- 问个问题vc6怎么样编译C#
- 退出对话框
- 请教一个问题,postmessage给后台窗体发送消息,已经成功,可以在小画家画图
//采集数据,采集时间对应的值。时间休整成整数,可以是开始时间的增量s
void GetData(int time, int value)
{
dataList.Add(new Point(time, value));
} //在重画事件中将数据画出折线图
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
for (int i = 0; i < dataList.Count - 1; i++)
{
Point p1 = dataList[i];
Point p2 = dataList[i + 1];
e.Graphics.DrawLine(new Pen(Color.Black), p1, p2);
}
}
int count = dt.Rows.Count;
Point[] p = new Point[count];
for (int i = 0; i < count ; i++) //定义曲线转折点
{
p[i].X = picturebox1.Width/ count * i;
p[i].Y = picturebox1.Height - Convert.ToInt32((Convert.ToDouble(dt.Rows[i][0]) * picturebox1.Height/10));
}
g.DrawLines(new Pen(Color.red), p);
//绘制曲线是g.DrawCurve(Rp, p);
现在有个问题就是坐标的X轴是固定的,但是要一直在上面显示Y轴也就是mcurrent的值,这样来看X轴用固定的时间又是不正确的
错误 11 当前上下文中不存在名称“dt”
错误 12 当前上下文中不存在名称“dt”
大哥,dt就是DataTable啊,我想弄明白点,mcurrent是一个量?你想做成实时变化的?实时变化的就放在Timer控件里头。。
{
int count = mcurrent++;
Point[] p = new Point[count];
for (int i = 0; i < count; i++)
{
p[i].X = pictureBox3.Width / count * i;
p[i].Y = pictureBox3.Height - Convert.ToInt32((mcurrent * pictureBox3.Height / 10));
}
e.Graphics.DrawLines(new Pen(Color.Yellow), p); }
写成这样,但是没有反应不能画出曲线
假设其中mcurrent大概在65左右,Y轴最大刻度100,让mcurrent能实时显示到坐标系中去
首先自己写个类 ,然后把 类DrawLineS放到Timer的Timer_Tick中即可。类你参考一下下面的代码
public Bitmap mybitmap;
public void DrawLineS(Color color, float Xmax, float Ymax, PictureBox picbox, Point[] ptlist)
{
mybitmap = new Bitmap(picbox.Width, picbox.Height);//设定位图大小
Graphics doublebufferg = Graphics.FromImage(mybitmap);//从位图上获取“画布”
doublebufferg.Clear(Color.White);//用背景色刷新 Rectangle rect = new Rectangle(0, 0, picbox.Width, picbox.Height);
doublebufferg.FillRectangle(new SolidBrush(Color.White), rect); //要显示的实时曲线部分
Point temp = new Point();
for (int j = 0; j < picbox.Width / 5 - 1; j++)
{
temp = ptlist[j + 1];
ptlist[j] = new Point(temp.X - 5, temp.Y);
} Point lastpt = new Point();
lastpt.X = picbox.Width;
lastpt.Y = mcurrent * picbox.Height /10;
ptlist[picbox.Width / 5 - 1] = lastpt;
doublebufferg.DrawLines(new Pen(color, 1), ptlist); //将缓冲中的位图绘制到我们的窗体上
Graphics g = picbox.CreateGraphics();//创建 PictureBox窗体的画布 g.Clear(Color.White);
g.DrawImage(mybitmap, 0, 0);
}
public Point[] ptlist;
private void Frm_Load(object sender, EventArgs e)
{
//设置控件的样式和行为,以减少图像的闪烁
this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.UpdateStyles(); //实例化数组
ptlist = new Point[this.pictureBox1.Width / 5];
Point pt;
for (int i = 0; i < this.pictureBox1.Width / 5; i++)
{
pt = new Point();
pt.X = 5 * i;//5个像素绘制一个点
pt.Y = mcurrent * this.pictureBox1.Height /10; ptlist[i] = pt;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
drawtest.DrawLineS(Color.Blue, pictureBox1, ptlist);
}
额,去掉drawtest就行了。。
错误 13 当前上下文中不存在名称“DrawLineS”
加了public void DrawLines(Pen pen, Point[] points);后drawtest.DrawLineS(Color.Blue, pictureBox1, ptlist);行报错
错误 6 “DrawLines”方法没有任何重载采用“3”个参数