Imports System.Math
Imports System.Drawing.Drawing2D
Public Class Form14
    Private Sub plClock_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles plClock.Paint

        Dim g As Graphics = e.Graphics
        Dim myPen As New Pen(Brushes.Black, 2)
        Dim myBigPen As New Pen(Brushes.Blue, 4)

        myxAngel = ((90 - (6 * mySec)) * Math.PI) / 180

        myxLength = Math.Cos(myxAngel) * 100

        myyAngel = ((90 - (6 * mySec)) * Math.PI) / 180
        myyLength = Math.Sin(myyAngel) * 100
        g.DrawLine(myPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxLength), Integer.Parse(plClock.Height / 2) - CInt(myyLength))

        If FirstDamnedTick = True Then
            myxHourAngel = ((90 - ((6 * (myMin - (myMin Mod (12))) / 12) + 30 * myHour)) * Math.PI) / 180


            myxHourLength = Math.Cos(myxHourAngel) * 70

            myyHourAngel = ((90 - ((6 * (myMin - (myMin Mod (12))) / 12) + 30 * myHour)) * Math.PI) / 180
            myyHourLength = Math.Sin(myyHourAngel) * 70

            g.DrawLine(myPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxHourLength), Integer.Parse(plClock.Height / 2) - CInt(myyHourLength))
            FirstDamnedTick = False
        End If

        If MinTick = True Then

            myxMinAngel = ((90 - (6 * myMin)) * Math.PI) / 180

            myxMinLength = Math.Cos(myxMinAngel) * 95

            myyMinAngel = ((90 - (6 * myMin)) * Math.PI) / 180
            myyMinLength = Math.Sin(myyMinAngel) * 95

            g.DrawLine(myPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxMinLength), Integer.Parse(plClock.Height / 2) - CInt(myyMinLength))
            MinTick = False
        End If
        If HourTick = True Then
            myxHourAngel = ((90 - ((6 * (myMin - (myMin Mod (12))) / 12) + 30 * myHour)) * Math.PI) / 180


            myxHourLength = Math.Cos(myxHourAngel) * 90


            myyHourAngel = ((90 - ((6 * (myMin - (myMin Mod (12))) / 12) + 30 * myHour)) * Math.PI) / 180
            myyHourLength = Math.Sin(myyHourAngel) * 90


            g.DrawLine(myPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxHourLength), Integer.Parse(plClock.Height / 2) - CInt(myyHourLength))
            HourTick = False
        End If

        g.DrawLine(myBigPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxMinLength), Integer.Parse(plClock.Height / 2) - CInt(myyMinLength))
        g.DrawLine(myBigPen, Integer.Parse(plClock.Width / 2), Integer.Parse(plClock.Height / 2), Integer.Parse(plClock.Width / 2) + CInt(myxHourLength), Integer.Parse(plClock.Height / 2) - CInt(myyHourLength))


    End Sub

    Private Sub tmrMin_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMin.Tick
        myMin = myMin + 1
        lblMin.Text = myMin

        If myMin Mod (12) = 0 Then
            HourTick = True
        End If


        If myMin > 59 Then
            myMin = 0
            lblMin.Text = 0
            If FirstHour = True Then

                myHour = myHour + 1
                lblHour.Text = myHour
                tmrHour.Enabled = True
                FirstHour = False

            End If
            If myHour > 12 Then
                myHour = myHour Mod 12

                lblHour.Text = myHour
            End If

        End If
    End Sub

    Private Sub tmrSec_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrSec.Tick
        mySec = mySec + 1
        lblSec.Text = mySec
        plClock.Refresh()

        If mySec > 59 Then
            mySec = 0
            lblSec.Text = 0
            MinTick = True


            If FirstMin = True Then

                myMin = myMin + 1
                lblMin.Text = myMin
                tmrMin.Enabled = True
                FirstMin = False

            End If

        End If
    End Sub

    Private Sub tmrHour_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrHour.Tick
        myHour = myHour + 1
        lblHour.Text = myHour
        If myHour > 12 Then
            myHour = 1
            lblHour.Text = 1
        End If
    End Sub
    Private Sub Form14_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            lblSec.Text = mySec
            lblMin.Text = myMin
            lblHour.Text = myHour

            If myHour > 12 Then
                myHour = myHour Mod 12
                lblHour.Text = myHour
            End If



        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        LoginForm1.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        LoginForm2.Show()
    End Sub
End Class