private void InitEvents() { /*关闭窗口*/ this.btnCancel.Click += new EventHandler(delegate(object sender, EventArgs args) { this.form.Close(); }); this.tbPwd.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbPwd)) { if (this.tbPwd.Text.TrimEnd() == Common.User.Pwd) this.lbAlarmPwd.Text = "√ correct password."; else { this.tbPwd.Focus(); this.lbAlarmPwd.Text = "x wrong password."; } } else { this.tbPwd.Focus(); this.lbAlarmPwd.Text = "x none content."; } }); /*新密码校验*/ this.tbNewPwd.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbNewPwd)) { //判断密钥长度 if (Common.Policy == null) this.lbAlarmNewPwd.Text = "√"; else { if (tbNewPwd.Text.TrimEnd().Length >= Common.Policy.MinPwdSize) { if (tbNewPwd.Text.TrimEnd() != Common.User.Pwd) this.lbAlarmNewPwd.Text = "√"; else { this.lbAlarmNewPwd.Text = "x same as current."; this.tbNewPwd.Focus(); } } else { this.lbAlarmNewPwd.Text = "x min pwd size is " + Common.Policy.MinPwdSize.ToString(); this.tbNewPwd.Focus(); } } } else if (!Common.TextBoxChecked(tbNewPwd)) { this.tbNewPwd.Focus(); this.lbAlarmNewPwd.Text = "x none content"; } if (Common.PasswordConfirmed(tbNewPwd, tbConfirm)) this.lbAlarmConfirm.Text = "√"; }); /*密码确认*/ this.tbConfirm.Leave += new EventHandler(delegate(object sender, EventArgs args) { if (Common.TextBoxChecked(tbConfirm)) { if (Common.PasswordConfirmed(tbNewPwd, tbConfirm)) this.lbAlarmConfirm.Text = "√"; else { this.lbAlarmConfirm.Text = "x confirmed failure"; } } else { this.tbConfirm.Focus(); this.lbAlarmConfirm.Text = "x none content"; } }); /*保存修改后的密码*/ this.btnOK.Click += new EventHandler(delegate(object sender, EventArgs args) { OK(); }); /*确认密码回车*/ this.tbConfirm.KeyPress += new KeyPressEventHandler(delegate(object sender, KeyPressEventArgs args) { if (args.KeyChar == 13) OK(); }); }