Hi all,
I have a project to draw thousands of cells of a cellular network to a picturebox. These cells are basically represented by a line.
My program is looking like this :
The problem that I have is that it takes some time to draw all these lines and I wand to add some more functionality to it and it becomes really slow.Code:Private Sub ReDraw() Dim Pi As Double Pi = 3.141592654 Me.PictureBox1.Refresh() Dim sectorsize As Integer sectorsize = 40 Dim myGraphics As Graphics = PictureBox1.CreateGraphics Dim myFont As Font Dim myBrush As Brush myBrush = New Drawing.SolidBrush(Color.DarkCyan) myFont = New System.Drawing.Font("Verdana", 6) Dim myPen As Pen myPen = New Pen(Brushes.DarkMagenta, 10) For Each row In CellData.CellsTable.Rows Dim Temp As String, sector As String, Band As Integer Dim X1, Y1, X2, Y2, X5, Y5 As Integer X1 = row("X") Y1 = row("Y") X2 = row("X") + sectorsize * Math.Sin(row("Azimuth") * Pi / 180) Y2 = row("Y") - sectorsize * Math.Cos(row("Azimuth") * Pi / 180) myGraphics.DrawLine(myPen, X1, Y1, X2, Y2) Next row End Sub
So how can I make it faster ?
Here are the possibilities I can think of :
1) Put screen updating on hold at the beginning of the Sub and resume it at the end. How to do it ?
2) I know that processing is way faster that print to screen so is there a way of preparing a collection or a buffer and draw it ?
3) Is it possible to save all these lines as a bitmap and then print bitmap on the screen?
Thank you
Fabrice




Reply With Quote