Exemplo n.º 1
0
        // Function to copy items to the system clipboard.
        private void CopyMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // Handle menu item clicked.
            ToolStripItem item = e.ClickedItem;
            // Copy password to clipboard.
            string returnedValue = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, item.Text);

            Clipboard.SetText(returnedValue);
        }
Exemplo n.º 2
0
        // Function to handle clicks on context menu strip.
        private void ContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            // Handle menu item clicked.
            ToolStripItem item = e.ClickedItem;

            if (item.Text == "Delete")
            {
                // Confirm user wants to delete password entry.
                string website = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Website");
                if (MessageBox.Show("Are you sure you want to delete this password entry for " + website + "?", "Confirm deletion", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    // Delete the password entry.
                    PasswordManage.RemovePasswordEntry(rightClickedWebsiteRow);
                }
            }
            else if (item.Text == "Edit")
            {
                // Get desired password entry data.
                string username = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Username");
                string email    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Email");
                string website  = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Website");
                string password = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Password");
                string notes    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Notes");
                string pin      = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "PIN");
                string phone    = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Phone");

                // Update text boxes. And pass in right clicked website row.
                EditPasswordEntryForm editPasswordForm = new EditPasswordEntryForm();
                editPasswordForm.UpdateTextBoxes(username, email, website, password, notes, rightClickedWebsiteRow);
                // Show edit form.
                editPasswordForm.ShowDialog();
            }
            else if (item.Text == "Show notes")
            {
                // Show the notes for the password.
                string notes = PasswordManage.ShowStoredItem(rightClickedWebsiteRow, "Notes");
                MessageBox.Show(notes, "Notes");
            }
        }