Imports ZedGraph
Public Class geometrygraph
Private Sub contourplot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call CreateGraph_Contour(zg3)
End Sub
Sub CreateGraph_Contour(ByVal zgc As ZedGraphControl)
Dim myPane As GraphPane = zgc.GraphPane
myPane.Title.Text = "Geometry Test"
myPane.XAxis.Title.Text = "X Number"
myPane.YAxis.Title.Text = "Y Number"
Dim i As Integer = 0
Dim j As Integer = 0
Dim k As Integer = 0
Dim myCurve As LineItem
' Draws boxes around each array point
For j = 0 To UBound(geometry.geomArray, 2)
For i = 0 To UBound(geometry.geomArray, 1)
Dim list As New PointPairList()
Dim x As Integer, y As Integer
x = i
y = j
list.Add(x, y)
x = i + 1
y = j
list.Add(x, y)
x = i + 1
y = j + 1
list.Add(x, y)
x = i
y = j + 1
list.Add(x, y)
list.Add(list(0)) ' duplicate the first point at the end to complete the circle
' Add a curve with a suitable level, no symbols
Dim myCurve2 As LineItem = myPane.AddCurve("Level=" + k.ToString(), list, Color.Black, SymbolType.None)
myCurve2.Line.IsSmooth = False ' Smooth out the contours a little
' Fill the boxes with colour depending on array contents
myCurve = myPane.CurveList(k)
If geometry.geomArray(i, j) = 1 Then
myCurve.Line.Fill = New Fill(Color.Red, Color.Red, 45.0F)
End If
If geometry.geomArray(i, j) = 2 Then
myCurve.Line.Fill = New Fill(Color.Blue, Color.Blue, 45.0F)
End If
If geometry.geomArray(i, j) = 3 Then
myCurve.Line.Fill = New Fill(Color.Yellow, Color.Yellow, 45.0F)
End If
k += 1
End If
Next i
Next j
myPane.Legend.IsVisible = False
myPane.Chart.Fill = New Fill(Color.White, Color.White, 45.0F)
myPane.Fill = New Fill(Color.White, Color.White, 45.0F)
' Manually set the axis ranges
myPane.XAxis.Scale.Min = 0
myPane.XAxis.Scale.Max = UBound(geometry.geomArray, 1) + 1
myPane.YAxis.Scale.Min = 0
myPane.YAxis.Scale.Max = UBound(geometry.geomArray, 2) + 1
zgc.AxisChange()
End Sub
End Class