In case you want to restrict the access of the keypad, a modification to the OnClick event is needed.
Protected Overrides Sub OnClick(e As System.EventArgs)
MyBase.OnClick(e)
ReadUserInfo()
If m_PLCAddressKeypad IsNot Nothing AndAlso (String.Compare(m_PLCAddressKeypad, "") <> 0) And Enabled Then
Dim PassCodeKeypad As New MfgControl.AdvancedHMI.Controls.AlphaKeyboard3(m_KeypadWidth) With {
.PasswordChar = True,
.ForeColor = Color.Red,
.Text = "ENTER PASSCODE"
}
PassCodeKeypad.ShowDialog()
'If PassCodeKeypad.Value <> "1234" Then
If PassCodeKeypad.Value <> Password Then
MsgBox("INVALID PASS CODE!")
Exit Sub
End If
ActivateKeypad()
End If
End Sub
And if you do not want to use the hardcoded password, but rather read from an xml file then:
Dim Password As String
Private Sub ReadUserInfo()
'Dim UserName As String
Dim doc As System.Xml.XmlDocument = New System.Xml.XmlDocument()
Dim filePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "Credential.xml")
doc.Load(filePath)
For Each m_node As System.Xml.XmlNode In doc.SelectNodes("/passwordlist/User")
'UserName = m_node.Item("UserName").InnerText
Password = m_node.Item("Password").InnerText
Next
End Sub