19-06-18, 04:50 PM
ما شاء الله فكرة رائعة جدا
لكن لماذا تايمر منفصل لكل حدث
عموما بعد اذنك قمت بالتعديل على الكود
حيث تم الغاء كل التايمرز و الاكتفاء بواحد فقط و حذف الموديول
و اعادة ترقيم الصور فى المجلد ( show password ) لتبدأ الارقام من 25 الى 30 بدلا من 1 الى 6
و هذا هو كود النموذج بعد التعديل
لكن لماذا تايمر منفصل لكل حدث
عموما بعد اذنك قمت بالتعديل على الكود
حيث تم الغاء كل التايمرز و الاكتفاء بواحد فقط و حذف الموديول
و اعادة ترقيم الصور فى المجلد ( show password ) لتبدأ الارقام من 25 الى 30 بدلا من 1 الى 6
و هذا هو كود النموذج بعد التعديل
كود :
Public Class Form1
Private WithEvents TT As New Timer
Private CurrentBox As Integer = 0 '1 user select 2 user typing 3 password hidden 4 password shown 5 password leave
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Chk_showpass.Checked = False
TxtPass.PasswordChar = "*"
End Sub
Private Sub Form1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DoubleClick
Application.Exit()
End Sub
Public Shared Function get_num(ByVal path As String) As Integer
Dim num As Integer
num = Val(IO.Path.GetFileNameWithoutExtension(path))
Return num
End Function
Public Function TextPercent(ByVal Box As TextBox) As Integer 'داله لحساب النسبة المئوية لامتلاء textbox1
Dim g As Graphics = Me.CreateGraphics
Dim s As SizeF = g.MeasureString(Box.Text.ToString, New Font("Times New Roman", 16, FontStyle.Bold And FontStyle.Italic))
Dim result As Integer = Math.Round((s.Width / Box.Width) * 100)
Return result
End Function
Private Sub TxtUser_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtUser.Click
CurrentBox = 1
PictureBox1.ImageLocation = Application.StartupPath & "\images\email select\1.png"
TT.Enabled = True
End Sub
Private Sub TxtUser_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtUser.TextChanged
If TxtUser.Text = "" Then PictureBox1.ImageLocation = Application.StartupPath & "\images\email typing\1.png"
CurrentBox = 2
TT.Enabled = True
End Sub
Private Sub TxtPass_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtPass.Enter
If CurrentBox < 3 Then
PictureBox1.ImageLocation = Application.StartupPath & "\images\password select\1.png"
CurrentBox = 3
If Chk_showpass.Checked Then CurrentBox = 4
End If
TT.Enabled = True
End Sub
Private Sub TxtPass_Leave(sender As Object, e As EventArgs) Handles TxtPass.Leave
CurrentBox = 5
PictureBox1.ImageLocation = Application.StartupPath & "\images\password deselect\1.png"
TT.Enabled = True
End Sub
Private Sub Chk_showpass_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chk_showpass.CheckedChanged
If CurrentBox < 3 Then
PictureBox1.ImageLocation = Application.StartupPath & "\images\password select\1.png"
ElseIf CurrentBox = 5 Then
PictureBox1.ImageLocation = Application.StartupPath & "\images\password select\21.png"
If Chk_showpass.Checked = False Then PictureBox1.ImageLocation = Application.StartupPath & "\images\show password\25.png"
End If
If Chk_showpass.Checked = False Then
CurrentBox = 3
TxtPass.PasswordChar = "*"
Else
CurrentBox = 4
TxtPass.PasswordChar = ""
End If
TxtPass.Focus()
End Sub
Private Sub TT_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TT.Tick
Select Case CurrentBox
Case 1
Dim file As String = Application.StartupPath & "\images\email select\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
If IO.File.Exists(file) = True Then
PictureBox1.ImageLocation = file
Else
TT.Enabled = False
End If
Case 2
If TxtUser.Text <> "" Then
If TextPercent(TxtUser) > get_num(PictureBox1.ImageLocation) AndAlso TxtUser.Focused = True Then
If TextPercent(TxtUser) <= TxtUser.Width AndAlso TextPercent(TxtUser) <= 100 Then
Dim file As String = Application.StartupPath & "\images\email typing\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
PictureBox1.ImageLocation = file
End If
ElseIf TextPercent(TxtUser) < get_num(PictureBox1.ImageLocation) AndAlso TxtUser.Focused = True Then
If TextPercent(TxtUser) <= TxtUser.Width AndAlso TextPercent(TxtUser) <= 100 Then
Dim file As String = Application.StartupPath & "\images\email typing\" & get_num(PictureBox1.ImageLocation) - 1 & ".png"
PictureBox1.ImageLocation = file
End If
End If
End If
Case 3
Dim file As String = Application.StartupPath & "\images\password select\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
If IO.File.Exists(file) = True Then
PictureBox1.ImageLocation = file
Else
TT.Enabled = False
End If
Case 4
Dim file As String = ""
If get_num(PictureBox1.ImageLocation) < 24 Then
file = Application.StartupPath & "\images\password select\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
Else
file = Application.StartupPath & "\images\show password\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
End If
If IO.File.Exists(file) = True Then
PictureBox1.ImageLocation = file
Else
TT.Enabled = False
End If
Case 5
Dim file As String = Application.StartupPath & "\images\password deselect\" & get_num(PictureBox1.ImageLocation) + 1 & ".png"
If IO.File.Exists(file) = True Then
PictureBox1.ImageLocation = file
Else
TT.Enabled = False
End If
Case Else
Dim file As String = Application.StartupPath & "\images\email select\1.png"
If IO.File.Exists(file) = True Then PictureBox1.ImageLocation = file
TT.Stop()
End Select
End Sub
End Class