Ejemplo n.º 1
0
 public AddDlg(EncryptedStorage es, bool edit = false, KeyEntry entry = null)
 {
     InitializeComponent();
     mStorage = es;
     mEditMode = edit;
     mKeyEntry = entry;
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbFilter.Text))
                return;

            if (string.IsNullOrEmpty(mSettings.Filename))
            {
                MessageBox.Show("Please register key storage first!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (mPassword == null)
            {
                PasswordDlg pdlg = new PasswordDlg();
                if (pdlg.ShowDialog(this) != DialogResult.OK || string.IsNullOrEmpty(pdlg.Password))
                    return;
                mPassword = pdlg.Password;
                pdlg.Dispose();
            }
            SetShowPasswords(showPasswordsToolStripMenuItem.Checked);
            SetPasswordTimer();
            EncryptedStorage es = new EncryptedStorage(mSettings.Filename);
            string t = tbFilter.Text.Trim();
            if (tbFilter.Text == "*")
                t = "";
            try
            {
                List<KeyEntry> entries = es.GetEntries(mPassword, t);
                if (entries == null || entries.Count() == 0)
                {
                    ResetStatus();
                    if (entries != null)
                        entries.Clear();
                }
                else
                {
                    lbStatusResults.Text = string.Format("Results: {0}", entries.Count());
                    //if (dt.Rows.Count > 1)
                    //	gridResults.Focus();
                    SetResultsTimer();
                }
                if (entries == null)
                    gridResults.DataSource = mEmptyList;
                else
                    gridResults.DataSource = entries;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ResetPassword();
            }
        }
Ejemplo n.º 3
0
        private void ctxDelete_Click(object sender, EventArgs e)
        {
            KeyEntry entry = GetCurrentKeyEntry();
            if (entry == null) return;

            if (MessageBox.Show("Are you sure you want to delete entry for " + entry.Domain + "?", "Confirm",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                using (PasswordDlg pdlg = new PasswordDlg(true))
                {
                    if (pdlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        EncryptedStorage enc = new EncryptedStorage(mSettings.Filename);
                        try
                        {
                            if (enc.RemoveEntry(entry, pdlg.Password))
                            {
                                MessageBox.Show("Entry has been removed!", "Removed",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ResetResults();
                            }
                            else
                                MessageBox.Show("Entry cannot be removed!", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Operation failed!\r\n" + ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }