Imports SmartNote.SmartObjects
Imports SmartNote.BookIntegration
Public Class frmSecurity
Inherits System.Windows.Forms.Form
Public nb As New Notebook()
Private justclickedit As Boolean = False
#Region " Windows Form Designer generated code "
Public Sub New(ByVal nards As Notebook)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
nb = nards
End Sub
'took out the form designer junk
'Form overrides dispose to clean up the component list.
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
#End Region
Private Sub chkHelp_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkHelp.CheckedChanged
If chkHelp.Checked = True Then
Me.Height = 263
Else
Me.Height = 168
End If
End Sub
Private Sub frmSecurity_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If nb.Security.IsProtected = True Then
chk_Password.Checked = True
txtPassword.Enabled = True
txtConfirm.Enabled = True
Dim crypter As New Crypto(Crypto.Providers.DES)
Dim pass As String = crypter.Decrypt(nb.Security.Password, smartKEY)
txtPassword.Text = pass
txtConfirm.Text = pass
Else
chk_Password.Checked = False
txtPassword.Enabled = False
txtConfirm.Enabled = False
End If
If nb.Security.IsSerialized = True Then
chkSerial.Checked = True
Else
chkSerial.Checked = False
End If
Me.DialogResult = DialogResult.Cancel
End Sub
Private Sub txtPassword_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPassword.Leave
If txtPassword.Text = "" And justclickedit = False Then
chk_Password.Checked = False
txtPassword.Enabled = False
txtConfirm.Enabled = False
End If
justclickedit = False
End Sub
Private Sub txtConfirm_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtConfirm.Leave
If txtPassword.Text <> txtConfirm.Text Then
MsgBox("Your passwords do not match.", MsgBoxStyle.Critical, "Security Error")
txtPassword.Text = ""
txtConfirm.Text = ""
txtPassword.Select()
Else
nb.Security.IsProtected = True
nb.Security.Password = txtPassword.Text
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If chkSerial.Checked = True Then
nb.Security.IsSerialized = True
Dim r As New rRegistry()
Dim sN As String = r.QueryValue(rRegistry.ERegistryPossibleRoots.HKEY_CURRENT_USER, "Software\Legal Info-Graphics\SmartNote", "serial", "NULL")
If sN = "NULL" Then
MsgBox("Error finding Serial Number...")
nb.Security.IsSerialized = False
chkSerial.Checked = False
Else
Dim crypter As New Crypto(Crypto.Providers.DES)
Dim theserial As String = crypter.Encrypt(sN, smartKEY)
nb.Security.SerialNumber = theserial
End If
End If
If chk_Password.Checked = True Then
If txtPassword.Text <> txtConfirm.Text Then
MsgBox("Your passwords do not match.", MsgBoxStyle.Critical, "Security Error")
txtPassword.Text = ""
txtConfirm.Text = ""
txtPassword.Select()
Else
nb.Security.IsProtected = True
Dim crypter As New Crypto(Crypto.Providers.DES)
Dim thepass As String = crypter.Encrypt(txtPassword.Text, smartKEY)
nb.Security.Password = thepass
End If
End If
Me.DialogResult = DialogResult.OK
tempNoteBookforSecurity = nb
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.DialogResult = DialogResult.Cancel
Me.Close()
End Sub
Private Sub chk_Password_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chk_Password.CheckStateChanged
If chk_Password.Checked = True Then
txtPassword.Enabled = True
txtConfirm.Enabled = True
txtPassword.Select()
Else
txtPassword.Enabled = False
txtConfirm.Enabled = False
End If
justclickedit = True
End Sub
Private Sub txtPassword_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtPassword.Enter
justclickedit = False
End Sub
End Class