Public Class authpanel
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBoxSetAuthCode.TextChanged

    End Sub

    Private Sub ButtonSetAuthCode_Click(sender As Object, e As EventArgs) Handles ButtonSetAuthCode.Click
        If TextBoxSetAuthCode.Text = "0000" Then
            MsgBox("Unable to set your Master-Password (It mustn't be '0000').", MsgBoxStyle.Exclamation)
            Application.Restart()
        Else
            My.Settings.AuthCode = TextBoxSetAuthCode.Text
            My.Settings.Save()
            My.Settings.Reload()
            MsgBox("Password has been successfully set.")
            Application.Restart()
        End If
    End Sub

    Private Sub authpanel_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If My.Settings.AuthCode = "0000" Then
            MsgBox("Welcome to the 'Password Manager - ZKDev'. Please set your Master-Password.")
        End If
        If My.Settings.AuthCode = "0000" Then
            TextBoxAuthCode.Enabled = False
            ButtonAuthCode.Enabled = False
            LabelInsertAuthCode.Enabled = False
        Else
            TextBoxSetAuthCode.Enabled = False
            ButtonSetAuthCode.Enabled = False
            LabelSetAuthCode.Enabled = False
        End If
        LabelAuthCode.Text = My.Settings.AuthCode
        LabelCurrentUser.Text = "Currect user: " & System.Environment.MachineName
    End Sub

    Private Sub ButtonAuthCode_Click(sender As Object, e As EventArgs) Handles ButtonAuthCode.Click
        If TextBoxAuthCode.Text = My.Settings.AuthCode Then

            Me.Enabled = False
            PWM.ShowDialog(Me)

        Else MsgBox("Password rejected", MsgBoxStyle.Critical)
        End If
    End Sub

    Private Sub ButtonChangeButton_Click(sender As Object, e As EventArgs) Handles ButtonChangeButton.Click
        Me.Enabled = False
        Change.ShowDialog(Me)
    End Sub

    Private Sub TimerPassword_Tick(sender As Object, e As EventArgs) 

    End Sub

    Private Sub LabelAuthCode_Click(sender As Object, e As EventArgs) Handles LabelAuthCode.Click

    End Sub

    Private Sub LinkLabelAboutMe_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabelAboutMe.LinkClicked
        Me.Enabled = False
        AboutMeZK.ShowDialog(Me)

    End Sub

    Private Sub LabelReset_Click(sender As Object, e As EventArgs) Handles LabelReset.Click
        My.Settings.AuthCode = "0000"
        My.Settings.Save()
        My.Settings.Reload()
        Me.Close()
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)

    End Sub
    Private Sub auth_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.Control AndAlso e.KeyCode = Keys.F10 Then
            Me.Close()
        End If
        If e.Control AndAlso e.KeyCode = Keys.F1 Then
            My.Settings.AuthCode = "0000"
            My.Settings.Save()
            My.Settings.Reload()
            Me.Close()
        End If
        If e.Control AndAlso e.KeyCode = Keys.F5 Then
            MsgBox(My.Settings.AuthCode)
        End If
    End Sub
End Class
