Advertisement
TermSpar

Login

Jan 4th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.03 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.IO
  3. Public Class Login
  4.     Public username As String
  5.     Public password As String
  6.  
  7.     Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         chkAuto.Checked = My.Settings.Checked
  9.         username = My.Settings.Username
  10.         password = My.Settings.Password
  11.         frmDirectory.directory = My.Settings.Directory
  12.         If frmDirectory.directory = "" Or frmDirectory.directory = "0" Then
  13.             frmDirectory.Show()
  14.             My.Settings.background = Color.RoyalBlue
  15.             Me.Close()
  16.         Else
  17.             lblIncorrect.Hide()
  18.             txtUsername.Select()
  19.             txtUsername.Text = username
  20.             Dim myIPaddress As String
  21.             Dim tmpHostName As String = System.Net.Dns.GetHostName()
  22.             myIPaddress = System.Net.Dns.GetHostByName(tmpHostName).AddressList(0).ToString()
  23.             If My.Computer.FileSystem.FileExists(frmDirectory.directory) Then
  24.                 If My.Computer.FileSystem.ReadAllText(frmDirectory.directory).Contains(myIPaddress) Then
  25.                 Else
  26.                     frmCreate.Show()
  27.                     Me.Close()
  28.                 End If
  29.             Else
  30.                 frmDirectory.Show()
  31.                 Me.Close()
  32.             End If
  33.             End If
  34.     End Sub
  35.  
  36.     Private Sub Login_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  37.         My.Settings.Username = username
  38.         My.Settings.Password = password
  39.         If chkAuto.Checked = True Then
  40.             My.Settings.Checked = chkAuto.Checked = True
  41.         ElseIf chkAuto.Checked = False Then
  42.             My.Settings.Checked = False
  43.         End If
  44.     End Sub
  45.  
  46.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  47.         If txtUsername.Text = username And txtPassword.Text = password Then
  48.             frmMain.Show()
  49.             Me.Close()
  50.         Else
  51.             Timer3.Start()
  52.             txtPassword.Clear()
  53.             Timer1.Start()
  54.         End If
  55.     End Sub
  56.  
  57.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  58.         frmCreate.Show()
  59.         Me.Close()
  60.     End Sub
  61.  
  62.     Private Sub txtPassword_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles txtPassword.KeyDown
  63.         If e.KeyCode = Keys.Enter Then
  64.             Button2.PerformClick()
  65.         End If
  66.     End Sub
  67.  
  68.     Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
  69.         lblIncorrect.Show()
  70.         Timer2.Start()
  71.     End Sub
  72.  
  73.     Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
  74.         Timer1.Stop()
  75.         lblIncorrect.Hide()
  76.         Timer2.Stop()
  77.     End Sub
  78.  
  79.     Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
  80.             Dim myIPaddress As String
  81.             Dim tmpHostName As String = System.Net.Dns.GetHostName()
  82.             myIPaddress = System.Net.Dns.GetHostByName(tmpHostName).AddressList(0).ToString()
  83.             Select Case MsgBox("Are you sure you want to delete your account?", MsgBoxStyle.YesNo, "Remove Account?")
  84.                 Case MsgBoxResult.Yes
  85.                     Dim lines As New List(Of String)
  86.                     Using sr As New StreamReader(My.Settings.Directory)
  87.                         While Not sr.EndOfStream
  88.                             lines.Add(sr.ReadLine)
  89.                         End While
  90.                     End Using
  91.                     For Each line As String In lines
  92.                         If line.Contains(myIPaddress & username & password) Then
  93.                             lines.Remove(line)
  94.                             Exit For
  95.                         End If
  96.                     Next
  97.                     Using sw As New StreamWriter(My.Settings.Directory)
  98.                         For Each line As String In lines
  99.                             sw.WriteLine(line)
  100.                         Next
  101.                     End Using
  102.                     frmCreate.Show()
  103.                     Me.Close()
  104.                 Case MsgBoxResult.No
  105.         End Select
  106.     End Sub
  107.  
  108.     Private Sub txtUsername_TextChanged(sender As System.Object, e As System.EventArgs) Handles txtUsername.TextChanged
  109.         If txtUsername.Text = username Then
  110.             txtPassword.Select()
  111.         End If
  112.     End Sub
  113.  
  114.     Private Sub Timer3_Tick(sender As System.Object, e As System.EventArgs) Handles Timer3.Tick
  115.         txtUsername.Enabled = False
  116.         txtPassword.Enabled = False
  117.         Timer4.Start()
  118.     End Sub
  119.  
  120.     Private Sub Timer4_Tick(sender As System.Object, e As System.EventArgs) Handles Timer4.Tick
  121.         Timer3.Stop()
  122.         txtPassword.Text = ""
  123.         txtUsername.Enabled = True
  124.         txtPassword.Enabled = True
  125.         txtPassword.Select()
  126.         Timer4.Stop()
  127.     End Sub
  128.  
  129.     Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
  130.         frmDirectory.Show()
  131.     End Sub
  132.  
  133.     Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  134.         frmHelp.Show()
  135.     End Sub
  136.  
  137.     Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
  138.         Process.Start("http://phobicos.webs.com/")
  139.     End Sub
  140.  
  141.     Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
  142.         Application.Exit()
  143.     End Sub
  144.  
  145.     Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
  146.         Application.Restart()
  147.     End Sub
  148.  
  149.     Private Sub chkAuto_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkAuto.CheckedChanged
  150.         If chkAuto.Checked = True Then
  151.             txtPassword.PasswordChar = "⊗"
  152.         Else
  153.             txtPassword.PasswordChar = Nothing
  154.         End If
  155.     End Sub
  156. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement