コード例 #1
0
ファイル: MainWindow.cs プロジェクト: mysoun/Hanyu
        private void ctlCertDelete_Click(object sender, EventArgs e)
        {
            if (this.ctlCerts.SelectedItems.Count != 1)
                return;

            var cert = (Cert)this.ctlCerts.SelectedItems[0].Tag;

            if (MessageBox.Show(this, "정말 삭제하시겠습니까?\n삭제한 후에는 복구할 수 없습니다.", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                return;

            if (DateTime.Now < cert.NotAfter)
            {
                using (var frm = new InputPassword())
                {
                    if (frm.ShowDialog("비밀번호를 입력해주세요") != DialogResult.OK)
                        return;

                    var oldPassword = (string)frm.Tag;
                    if (!cert.CheckPassword(oldPassword))
                    {
                        MessageBox.Show(this, "비밀번호가 일치하지 않습니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
            }

            cert.Remove();
            this.RefreshList();
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: mysoun/Hanyu
        private void ctlCheckPassword_Click(object sender, EventArgs e)
        {
            if (this.ctlCerts.SelectedItems.Count != 1)
                return;

            using (var frm = new InputPassword())
            {
                if (frm.ShowDialog("비밀번호를 입력해주세요") != DialogResult.OK)
                    return;

                var cert = (Cert)this.ctlCerts.SelectedItems[0].Tag;

                var passwd = (string)frm.Tag;
                if (cert.CheckPassword(passwd))
                    MessageBox.Show(this, "비밀번호가 일치합니다!",        this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                    MessageBox.Show(this, "비밀번호가 일치하지 않습니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: mysoun/Hanyu
        private void ctlChangePassword_Click(object sender, EventArgs e)
        {
            if (this.ctlCerts.SelectedItems.Count != 1)
                return;

            using (var frm = new InputPassword())
            {
                if (frm.ShowDialog("비밀번호를 입력해주세요") != DialogResult.OK)
                    return;

                var cert = (Cert)this.ctlCerts.SelectedItems[0].Tag;

                var oldPassword = (string)frm.Tag;
                if (!cert.CheckPassword(oldPassword))
                {
                    MessageBox.Show(this, "비밀번호가 일치하지 않습니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (frm.ShowDialog("새로운 비밀번호를 입력해주세요") != DialogResult.OK)
                    return;
                var newPassword = (string)frm.Tag;

                if (frm.ShowDialog("새로운 비밀번호를 다시 입력해주세요") != DialogResult.OK)
                    return;
                var newPassword2 = (string)frm.Tag;

                if (!newPassword.Equals(newPassword2, StringComparison.CurrentCulture))
                    MessageBox.Show(this, "두 비밀번호가 일치하지 않습니다!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                if (cert.ChangePassword(oldPassword, newPassword))
                    MessageBox.Show(this, "비밀번호를 변경하였습니다!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                    MessageBox.Show(this, "알 수 없는 오류가 발생하였습니다.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }