I met a question about the efficiency of GDI+.
There are several variables and methods
as below:
1.points, such as A(Represents a coordinate point, such as X Y Z), B, C, D, E, etc.
2 List named Cmd1, used to add points by thread
3.paint method, in this method, the set of points connected to the line
4.thread for the constant addition of new points,such as F,G,H,I,J etc.
In Paint Method,i use g.DrawLine() to link a and b,c,d,e.
In thread,when i add new points,i will call invalid to refresh component.
so my question is,points become more and more, how can I maintain high efficiency, and redraw,
do not start from the a point to re - drawline.
What I have tried:
Sub DrawGLines2(g As Graphics)
g.SmoothingMode = SmoothingMode.HighSpeed
Dim Pen As New Pen(Brushes.White)
Dim i 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
thread will call AddPoint to add a,b,c,d,e points,and use invalid method to refresh,when i call invalid,the "For Each cmd As Cmd1 In Cmd1s" for each will begin from A point,so when points become more and more, how can I maintain high efficiency, and redraw, do not start from A point to re - drawline