注册 登录
编程论坛 C# 论坛

想实现类似示波器的图像平移失败了,大家帮忙看看问题出在哪里

kk232778910 发布于 2015-05-11 13:57, 606 次点击
private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            int h = pictureBox1.Height;
            graph = e.Graphics;
            pictureBox1.BackColor = Color.Black;
            for (int 线 = 0; 线 < 100; 线 = 线 + 10)
            {
                graph.DrawLine(线条, new Point(线, 0), new Point(线, 100));//竖线需X坐标=同  
                graph.DrawLine(线条1, new Point(0, 线), new Point(200, 线));//横线需Y坐标=同  
                graph.DrawLine(线条, new Point(线 + 100, 0), new Point(线 + 100, 100));//竖线需X坐标=同  
            }
            for (int i = 0; i < 9; i++)
            {
               
                graph.DrawLine(p, i * 10, h - shuzu[i], (i+1) *10, h-shuzu[i+1]);

            }
         
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            int len = 10;
            for (int i = 0; i < len; i++)
            {
                //判断数组越界
                if (i < len - 1)
                {
                    shuzu[i] = shuzu[i + 1];
                }
                else
                {
                    shuzu[len - 1] = rmd.Next(0,100);   
                }
            }
            Invalidate();
        }  
    }
更多 0
1 回复
#2
kk2327789102015-05-11 20:34
我自己解决了。。invalidate改为 picturebox.invalidate()就可以使得控件重绘
1