【发布时间】:2016-12-27 02:23:55
【问题描述】:
我遇到了一个关于 GDI+ 效率的问题。 有几个变量和方法 如下: 1.Points,如A(表示坐标点,如X Y Z)、B、C、D、E等
2 名为Cmd1的列表,用于线程加点
3.Paint 方法,在该方法中,连接线的点的集合
4.线程用于不断添加新点,如F、G、H、I、J等
在 Paint Method 中,我使用 g.DrawLine() 来链接 a 和 b,c,d,e。 在线程中,当我添加新点时,我将调用无效来刷新组件。 所以我的问题是,积分越来越多,如何才能保持高效率,重绘,
不要从a点开始重新画线。
Sub DrawGLines2(g As Graphics)
g.SmoothingMode = SmoothingMode.HighSpeed
Dim Pen As New Pen(Brushes.White)
Dim i As Int32
'Dim c As Int32
Dim preCmd1 As Cmd1
Try
For Each cmd As Cmd1 In Cmd1s
Dim pfs() As PointF = cmd.PointFs.ToArray
If preCmd1 IsNot Nothing Then
g.DrawLine(Pen, cmd.PointFs(0), preCmd1.PointFs(0))
End If
preCmd1 = cmd
End If
Next
Catch ex As Exception
Debug.Print(ex.Message)
End Try
End Sub
Private Sub Sheet_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
If Me.Cmd1s.Count>0 Then
DrawGLines2(e.Graphics)
End If
End Sub
Public Sub AddPoint(x As Double, y As Double, z As Double, Optional G As Int32 = -1)
Dim cmd1 As DrvSimu.Cmd1 = Nothing
If cmd1 Is Nothing Then
cmd1 = New DrvSimu.Cmd1
Me.Cmd1s.Add(cmd1)
End If
Dim pf3d As New PointF3D(x, y, z)
cmd1.PointF3Ds.Add(pf3d)
Me.Invalidate()
End Sub
线程会调用AddPoint添加a,b,c,d,e点,并使用invalid方法刷新,当我调用invalid时,每个的“For Each cmd As Cmd1 In Cmd1s”将从A点开始,所以当点越来越多时,如何保持高效率,重绘,不要从A点开始重新画线
【问题讨论】:
标签: visual-foxpro