예제 #1
0
        private void EditButton_Click(object sender, EventArgs e)
        { // Edit the current entry. Display previous password in password field if master password
          // is added, otherwise blank.
            string curr  = listBox1.SelectedItem.ToString();
            var    entry = new NamePassBox(curr, this.passSet ? this.data[curr] : "");

            entry.ShowDialog();
            if (entry.passResult == "" || entry.nameResult == "")
            {
                return;                                         // If clicked cancel.
            }
            this.data.Remove(listBox1.SelectedItem.ToString()); // Remove old item.
            this.data[entry.nameResult] = entry.passResult;
            this.changesMade            = true;
            this.listBox1.SelectedIndex = -1;
            this.Populate();
            this.CheckState();
        }
예제 #2
0
        private void AddEntryButton_Click(object sender, EventArgs e)
        { // Store a service and password in the database.
            NamePassBox entry = new NamePassBox();

            entry.ShowDialog();

            if (entry.passResult != "" && entry.nameResult != "")
            {
                if (this.data.GetKeys().Contains(entry.nameResult))
                {
                    MessageBox.Show("A service with this name already exists.", "Name reuse", MessageBoxButtons.OK);
                }
                else
                {
                    this.data[entry.nameResult] = entry.passResult;
                    this.changesMade            = true;
                    this.Populate();
                }

                this.listBox1.SelectedIndex = -1;
                this.CheckState();
            }
        }