
对labview通过usb控制agilent33220任意波形手写输入的再一次完善.doc
7页对对 labviewlabview 通过通过 USBUSB 控制控制 agilent33220agilent33220 任意波形手写输入的再一次任意波形手写输入的再一次完善完善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.IO;namespace WindowsFormsApplication6{public partial class Form1 : Form{public Form1(){InitializeComponent();myTimer = new HiPerfTimer();}private Point point, pp; private bool mark = false; private int aa;Image myImage = new Bitmap(689, 399); //建个图层。
内存法private void pictureBox1_MouseMove(object sender, MouseEventArgs e){if(mark)//mark=true 时才触发,鼠标没左键的时候不会进行{Graphics g = Graphics.FromImage(myImage);g.DrawLine(Pens.Red,point.X,point.Y, e.X, e.Y);//在图层里面,避免 n 多的问题画线为红色point.X = e.X;point.Y = e.Y;}}private void pictureBox1_MouseDown(object sender, MouseEventArgs e){myTimer.ClearTimer();myTimer.Start();File.Delete(“c:\\2.txt“); //下次再画时删除2.txtGraphics g = Graphics.FromImage(myImage);g.Clear(Color.Empty);pictureBox1.Image = myImage;//3 句话,清空picturebox。
if (e.Button == MouseButtons.Left)// 鼠标左键才正式画画,避免失误点击了右键{pp.X = e.X;point.X = e.X;point.Y = e.Y;mark = true;//mark 开始时 false,左键以后为true}}private void pictureBox1_MouseUp(object sender, MouseEventArgs e){myTimer.Stop();label2.Text = “画图所用时间:“ + “\n“ +(myTimer.Duration / 1000).ToString(“####.###“) + “秒“;myTimer.ClearTimer();myTimer.Start();mark = false;//为下次画做准备Bitmap image = (Bitmap)myImage;System.Drawing.Imaging.BitmapData data = image.LockBits( new Rectangle( 0 , 0 , image.Width , image.Height ) , System.Drawing.Imaging.ImageLockMode.ReadWrite , image.PixelFormat );StringBuilder sb = new StringBuilder();int endx; int startx;startx = pp.X;if (point.X > data.Width) endx = data.Width;else endx = point.X;if (pp.X > point.X) { endx = pp.X; startx = point.X; } //支持右侧向左侧画,代码有点搓。
unsafe{byte* ptr = (byte*)(data.Scan0);byte *p=(byte*)(data.Scan0);for (int j = startx; j 2aa = 0; }}private void timer1_Tick(object sender, EventArgs e){if (mark){label3.Text = “瞬时坐标:“ + “\n“ +“X=“ + point.X.ToString() + “\n“ + “Y=“ + (400 - point.Y).ToString();//label 显示 x,y 值pictureBox1.Image = myImage;//图层显示在picturebox 里面}}private void pictureBox2_MouseDown(object sender, MouseEventArgs e){System.Diagnostics.Process.Start(“IEXPLORE.EXE“, “ }下载地址:。
