Code: Select all
Imports System.Drawing
Imports System.Drawing.Drawing2D
…
Public gfx As Graphics
Public bmp As Bitmap
…
Private Sub DrawChart(ByVal Az As Double(), ByVal delT As Double())
Dim sizePnt As Integer = 2
Dim pointPen As New Pen(Color.Black, sizePnt)
Dim gridLine As New Pen(Color.LightGray, 1)
Dim maxDataPoints As Integer = Az.Length
Dim chartHeight As Integer = Me.bmp.Height
Dim chartWidth As Integer = Me.bmp.Width
Dim minYpos As Integer = chartHeight
Dim maxYpos As Integer = 10
' Adjustable Values
Dim vrtRatio As Double = chartHeight / 4.0
Dim hrzRatio As Double = chartWidth / 360.0
' Drawing Border Lines
Dim borderLine As New Pen(Color.DarkGray, 2)
'Left Border
Me.gfx.DrawLine(borderLine, New Point(0, chartHeight), New Point(0, 0))
' Bottom Border
Me.gfx.DrawLine(borderLine, New Point(0, chartHeight), New Point(chartWidth, chartHeight))
' Right Border
Me.gfx.DrawLine(borderLine, New Point(chartWidth, chartHeight), New Point(chartWidth, 0))
' Top Border
Me.gfx.DrawLine(borderLine, New Point(0, 0), New Point(chartWidth, 0))
' Drawing X-Axis (Azimuth -180 - +180))
Me.gfx.DrawLine(borderLine, New Point(0, chartHeight / 2), New Point(chartWidth, chartHeight / 2))
Dim xPos As Single = 0
Dim snglAz As Single = -180.0
Dim shiftX As Single = chartWidth / 8
While (snglAz <= 180.0)
Me.gfx.DrawString(snglAz.ToString(), New Font("Arial", 5), New SolidBrush(Color.Gray), New Point(xPos, chartHeight / 2 + 1))
Me.gfx.DrawLine(gridLine, New Point(xPos, 0), New Point(xPos, chartHeight))
snglAz += 45.0
xPos += shiftX
End While
' Drawing Y-Axis (Time -2.00 - +2.00)
Me.gfx.DrawLine(borderLine, New Point(chartWidth / 2, chartHeight), New Point(chartWidth / 2, 0))
Dim yPos As Single = 0
Dim snglDelT As Single = 2.0
Dim shiftY As Single = chartHeight / 8
While (snglDelT >= -2.0)
If (snglDelT <> 0) Then
Me.gfx.DrawString(snglDelT.ToString("F"), New Font("Arial", 5), New SolidBrush(Color.Gray), New Point(chartWidth / 2 + 2, yPos))
Me.gfx.DrawLine(gridLine, New Point(0, yPos), New Point(chartWidth, yPos))
End If
snglDelT -= 0.5
yPos += shiftY
End While
' Drawing the Points
For i As Integer = 0 To maxDataPoints - 1
xPos = Convert.ToSingle(Az(i) * hrzRatio)
yPos = Convert.ToSingle(Math.Abs(delT(i) - 2.0) * vrtRatio)
Me.gfx.DrawRectangle(pointPen, xPos, yPos, sizePnt, sizePnt)
Next
End Sub