Private btnDraw_pressed As Boolean = False
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnDraw.Click
' indicate that from now on, the label (after the button click) should be re-painted
btnDraw_pressed = True
' refreshing the form will cause all objects to be re-painted
Me.Refresh()
End Sub
Public Sub DrawPhase(ByVal x As Integer, ByVal y As Integer, ByVal len As Integer)
Dim Xval As Integer = x
Dim Yval As Integer = y
Dim l As Integer = len
Dim myPen As New Pen(Color.Red, 3) 'new pen object
Dim g As Graphics = Label2.CreateGraphics 'new graphics object
'draws the line with pen and coordinates
g.DrawLine(myPen, Xval, Yval, Xval + l, Yval)
End Sub
Private Sub Label2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) _
Handles Label2.Paint
If btnDraw_pressed Then
'get the difference of weeks between todays date and the selected date.
diff = DateDiff(DateInterval.WeekOfYear, Today, future)
start = DateDiff(DateInterval.WeekOfYear, mbegin, Today).tostring
'Draws the line at points for length of weeks; not to scale.
DrawPhase(start * 25, 65, diff * 25)
End If
End Sub