Public Class frmSettings

    Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
        My.Settings.active_com_only_sync = rdbActCom2.Checked
        If rdbSyncMode0.Checked Then
            My.Settings.mode_auto_sync = 1
        ElseIf rdbSyncMode1.Checked Then
            My.Settings.mode_auto_sync = 2
        Else
            My.Settings.mode_auto_sync = 0
        End If
        If rdbPosTC.Checked Then
            My.Settings.timeCorrectionPos = True
        Else
            My.Settings.timeCorrectionPos = False
        End If
        My.Settings.Save()
        Application.Restart()
    End Sub

    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
        My.Settings.Reload()
        Me.Close()
    End Sub

    Private Sub frmSettings_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
            ccbCOMimp.Items.Add(My.Computer.Ports.SerialPortNames(i))
        Next
        If My.Settings.active_com_only_sync Then
            rdbActCom2.Checked = True
        Else
            rdbActCom1.Checked = True
        End If
        If My.Settings.timeCorrectionPos Then
            rdbPosTC.Checked = True
        Else
            rdbNegTC.Checked = True
        End If
        Select Case My.Settings.mode_auto_sync
            Case 0
                rdbManual.Checked = True
            Case 1
                rdbSyncMode0.Checked = True
            Case 2
                rdbSyncMode1.Checked = True
        End Select
    End Sub
End Class