Public Class FormIzracunMeasure
    Public g As Graphics

    Dim stnE
    Dim stnN
    Dim stnH
    Dim stnHinst
    Dim merIme
    Dim merE
    Dim merN
    Dim merH
    Dim merHpriz
    Dim merPriz
    Dim merPrCons

    Private Sub FormIzracunMeasure_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        g = Me.CreateGraphics()

        cbPrizma.SelectedIndex = 0
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbPrizma.SelectedIndexChanged
        Dim cb = cbPrizma.Text

        Select Case cb
            Case "Red Laser"
                tbMerPrCons.Text = "+0.0344"
                tbMerPrCons.Enabled = False
                LabelPrCons.Enabled = False
            Case "Leica Circ. Prism"
                tbMerPrCons.Text = "+0.0000"
                tbMerPrCons.Enabled = False
                LabelPrCons.Enabled = False
            Case "Leica Mini Prism"
                tbMerPrCons.Text = "+0.0175"
                tbMerPrCons.Enabled = False
                LabelPrCons.Enabled = False
            Case "Vnos konstante..."
                tbMerPrCons.Text = "+0.0000"
                tbMerPrCons.Enabled = True
                LabelPrCons.Enabled = True
            Case Else

        End Select
    End Sub

    Public Sub PrikazGrafike()
        g.Clear(SystemColors.Control)

        Dim deltaE = merE - stnE
        Dim deltaN = merN - stnN
        Dim fakt

        If deltaE > deltaN Then
            fakt = 120 / deltaE
        Else
            fakt = 120 / deltaN
        End If

        Dim izrE = deltaE * fakt
        Dim izrN = deltaN * fakt

        Dim grStnE As Single = 130
        Dim grStnN As Single = 130
        Dim grMerE As Single = izrE + 130
        Dim grMerN As Single = izrN + 130

        tbGsiOut.Text = "dE=" + deltaE.ToString + " dN=" + deltaN.ToString + " / f=" + fakt.ToString + " / iE=" + izrE.ToString + " iN=" + izrN.ToString + " gE=" + grMerE.ToString + " gN=" + grMerN.ToString

        g.DrawLine(Pens.DarkBlue, New Point(grStnE, grStnN), New Point(grMerE, grMerN))
        g.DrawRectangle(Pens.Gray, 10, 10, 240, 240)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        stnE = CDbl(tbStnE.Text)
        stnN = CDbl(tbStnN.Text)
        stnH = CDbl(tbStnH.Text)
        stnHinst = CDbl(tbStnHins.Text)
        merIme = tbMerIme.Text.ToString
        merE = CDbl(tbMerE.Text)
        merN = CDbl(tbMerN.Text)
        merH = CDbl(tbMerH.Text)
        merHpriz = CDbl(tbMerHpriz.Text)
        merPriz = cbPrizma.Text.ToString
        merPrCons = CDbl(tbMerPrCons.Text)

        PrikazGrafike()

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Me.Close()
    End Sub
End Class