Imports System.Windows.Forms

Public Class DialogIzracunHzCor

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub ButtonIzr_Click(sender As Object, e As EventArgs) Handles ButtonIzr.Click
        ' Pretvori DMS v decimalne stopinje za Hz
        Dim hzMer = TextBox1.Text
        Dim hzMerData = Split(hzMer, ".")
        Dim hzMerDeg As Double = hzMerData(0)
        Dim hzMerMin As Double = Microsoft.VisualBasic.Left(hzMerData(1), 2) / 60
        Dim hzMerSec As Double = Microsoft.VisualBasic.Mid(hzMerData(1), 3) / 3600
        Dim hzMerDecDeg As Double = hzMerDeg + hzMerMin + hzMerSec
        MaskedTextBoxDegHz.Text = Format(hzMerDecDeg, "0.000000").ToString
        ' Pretvori DMS v decimalne stopinje za HzCor
        Dim hzPop = TextBox2.Text
        Dim hzPopData = Split(hzPop, ".")
        Dim hzPopDeg As Double = hzPopData(0)
        Dim hzPopMin As Double = Microsoft.VisualBasic.Left(hzPopData(1).ToString, 2) / 60
        Dim hzPopSec As Double = Microsoft.VisualBasic.Mid(hzPopData(1), 3) / 3600
        Dim hzPopDecDeg As Double = hzPopDeg + hzPopMin + hzPopSec
        MaskedTextBoxDegHzCor.Text = Format(hzPopDecDeg, "0.000000").ToString
        ' Izračunaj nov Azi in izpiši v obeh formatih
        Dim hzNovDecDeg As Double = hzMerDecDeg + hzPopDecDeg
        If hzNovDecDeg >= 360 Then
            hzNovDecDeg = hzNovDecDeg - 360
        End If
        MaskedTextBoxHzNov.Text = Format(hzNovDecDeg, "0.000000").ToString
        Dim hzNov = MaskedTextBoxHzNov.Text
        Dim hzNovData = Split(hzNov, ".")
        Dim hzNovDeg As Double = Int(hzNov)
        Dim hzNovMin As Double = (hzNov - hzNovDeg) * 60
        Dim hzNovMinInt As Double = Int(hzNovMin)
        Dim hzNovSec As Double = Format(((hzNovMin - hzNovMinInt) * 60), "00")
        Dim hzNovDms As String = hzNovDeg.ToString + "." + hzNovMinInt.ToString + hzNovSec.ToString
        Dim hzNovDmsGsi As String = "21.324+00000000" + Format(hzNovDeg, "000").ToString + Format(hzNovMinInt, "00").ToString + Format(hzNovSec, "00").ToString + "0 "
        MaskedTextBoxHzNovDms.Text = hzNovDms
        MaskedTextBoxGsiHzNov.Text = hzNovDmsGsi
        'If hzNovDms >= 360 Then
        '    hzNovDms = hzNovDms - 360
        'End If
        'MaskedTextBoxDegHz.Text = Format(hzMerDecDeg, "0.000000").ToString
        'MaskedTextBoxDegHzCor.Text = Format(hzPopDecDeg, "0.000000").ToString

    End Sub

    Private Sub ButtonUpGsi_Click(sender As Object, e As EventArgs) Handles ButtonUpGsi.Click
        ' Pretvori DMS v decimalne stopinje za Hz
        Dim hzMer As Double = Microsoft.VisualBasic.Right(Replace(MaskedTextBoxGsiHz.Text, " ", ""), 8)
        Dim hzMerNumData As Double = CDbl(hzMer / 100000)
        TextBox1.Text = Format(hzMerNumData, "0.0000").ToString
        'Dim hzMerData = Split(hzMerNumData.ToString, ".")
        'Dim hzMerDeg As Double = hzMerData(0)
        'Dim hzMerMin As Double = hzMerData(1) * 60
        'Dim hzMerMinInt As Integer = Int(hzMerMin)
        'Dim hzMerSec As Double = Format(((hzMerMin - hzMerMinInt) * 60), "0")
        'Dim hzMerDms As String = hzMerDeg.ToString + "." + hzMerMinInt.ToString + hzMerSec.ToString
        'MaskedTextBoxDegHz.Text = hzMerDms.ToString
        ' Pretvori DMS v decimalne stopinje za HzCor
        Dim hzPop As Double = Microsoft.VisualBasic.Right(Replace(MaskedTextBoxGsiHzCor.Text, " ", ""), 8)
        Dim hzMPopNumData As Double = CDbl(hzPop / 100000)
        TextBox2.Text = Format(hzMPopNumData, "0.0000").ToString
        'Dim hzPopData = Split(hzMPopNumData.ToString, ".")
        'Dim hzPopDeg As Double = hzPopData(0)
        'Dim hzPopMin As Double = hzPopData(1) * 60
        'Dim hzPopMinInt As Double = Int(hzPopMin)
        'Dim hzPopSec As Double = Format(((hzPopMin - hzPopMinInt) * 60), "0")
        'Dim hzPopDms As Double = hzPopDeg.ToString + "." + hzPopMinInt.ToString + hzPopSec.ToString
        'MaskedTextBoxDegHzCor.Text = hzPopDms.ToString

        'MaskedTextBoxDegHz.Text = Format(hzMerDecDeg.ToString, "0.000000").ToString
        'MaskedTextBoxDegHzCor.Text = Format(hzPopDecDeg.ToString, "0.000000").ToString

    End Sub

End Class
