大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
效果如图,代码如下:
目前成都创新互联已为上千家的企业提供了网站建设、域名、虚拟空间、成都网站托管、企业网站设计、定边网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
Public Class Form1
'Circle类
Class Circle
Public Center As Point
Public Radius As Single
Public Sub New(c As Point, r As Single)
Center = c
Radius = r
End Sub
'绘制
Public Sub Draw(g As Graphics, pen As Pen)
g.DrawEllipse(pen, New RectangleF(Center.X - Radius, Center.Y - Radius, Radius * 2, Radius * 2))
End Sub
End Class
Private downPoint As Point '记录鼠标按下位置
Private circleList As New List(Of Circle) '已存放圆的列表
Private tmpCircle As Circle '临时圆(正在拖动)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DoubleBuffered = True '启用双缓冲绘图,避免闪烁
End Sub
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
downPoint = e.Location '记下位置
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.Button Windows.Forms.MouseButtons.Left Then Return '左键没按下则退出
Dim r As Single = Math.Sqrt((e.X - downPoint.X) ^ 2 + (e.Y - downPoint.Y) ^ 2) '算出半径
tmpCircle = New Circle(downPoint, r) '更新临时圆
Refresh() '先刷新掉之前绘制的临时圆
tmpCircle.Draw(Me.CreateGraphics, Pens.Black) '绘制临时圆
End Sub
Private Sub Form1_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
circleList.Add(tmpCircle) '鼠标弹起,把临时圆加入圆列表
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
For Each c As Circle In circleList
c.Draw(e.Graphics, Pens.Black) '绘制出每个圆
Next
End Sub
End Class
上位机软件接收大量数据并显示,会造成界面卡顿,可采用双缓冲技术,即将数据存到内存,再将其绘制到界面,比将数据直接绘制到界面要省很多时间
添加在子进程里面,就加在你批量传输代码里的每一个传输后面,也就是大批量中的每传输一个数据就暂停一下,而不是每一个大批量才暂停一下。
VB.NET画图是不能设置双缓冲的,双缓冲是指窗体,从来没说是针对控件。
不用graphic.clear清理重画就不会闪烁。你可以先把容器删了再重新建立一个再去画。
简单举例:
Graphics g;
Pen p;
Panel pl;
构造函数初始化:
p=new Pen(Color.Red,2);
pl=panel1;
造成闪烁的画法:
g=pl.CreateGraphics();
g.Clear(SystemColor.ButtonFace);
//.....画新的
不会闪烁的办法:
this.Controls.ReMoveAt(panel1);
pl=new Panel();
pl.Name="panel1";
//....创建容器控件
this.Controls.Add(pl);
//继续画