PublicClass SpeedViewClass SpeedView Private xStep, yStep AsSingle Private mMaxSpeed AsInteger=10 Private Infos AsNew ArrayList PublicClass InfoClass Info PublicWriteAsInteger Public Read AsInteger Public y AsSingle Public DrawWrite AsBoolean Public DrawRead AsBoolean End Class PublicProperty MaxSpeed()Property MaxSpeed() AsInteger Get Return mMaxSpeed EndGet Set(ByVal value AsInteger) If mMaxSpeed <> value Then mMaxSpeed = value PictureBox1.Invalidate() Me.Invalidate() EndIf EndSet End Property PrivateSub PictureBox1_Paint()Sub PictureBox1_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Dim point1, point2 As PointF '绘制网格 For i AsInteger=1To9 point1 =New PointF(xStep * i, 0) point2 =New PointF(xStep * i, PictureBox1.Height) e.Graphics.DrawLine(Pens.Blue, point1, point2) Next '绘制图形 For i AsInteger=0To Infos.Count -1 Dim ThisInfo As Info =CType(Infos(i), Info) '绘制写速度 If ThisInfo.DrawWrite Then Dim p1, p2 As Point p1 =New Point(0, yStep * i) p2 =New Point(ThisInfo.Write * PictureBox1.Width / (MaxSpeed *1024), yStep * i) e.Graphics.DrawLine(New Pen(Color.Red, 4), p1, p2) EndIf '绘制读速度 If ThisInfo.DrawRead Then Dim p1, p2 As Point p1 =New Point(0, yStep * i +4) p2 =New Point(ThisInfo.Read * PictureBox1.Width / (MaxSpeed *1024), yStep * i +4) e.Graphics.DrawLine(New Pen(Color.Black, 4), p1, p2) EndIf Next End Sub PrivateSub PictureBox1_SizeChanged()Sub PictureBox1_SizeChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles PictureBox1.SizeChanged xStep = PictureBox1.Width /10 yStep = PictureBox1.Height /12 End Sub PrivateSub SpeedView_Paint()Sub SpeedView_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) HandlesMe.Paint '绘制x轴刻度 For i AsInteger=0To10 Dim point As Point DimstrAsString= (MaxSpeed * i /10).ToString Dim size As SizeF = e.Graphics.MeasureString(str, Me.Font) point =New Point(PictureBox1.Left + i * xStep - size.Width /2, PictureBox1.Bottom) e.Graphics.DrawString(str, Me.Font, Brushes.Blac
可以测试驱动器(包含优盘自动识别插入、卸载)的读(Read)写(Write)速度,并以图形化的方式直观显示读写按照二进制形式进行测试程序运行效果图如下: 主要源码如下:1、柱状图控件源码Public Class SpeedViewClass SpeedView Private xStep, yStep As Single Private mMaxSpe