Esempio n. 1
0
        private ProtectedStringMenuItem CreateProtectedStringMenuItem(PwEntry entry, string protectedStringKey, Image image = null)
        {
            ProtectedStringMenuItem menuItem = new ProtectedStringMenuItem(entry.Uuid, protectedStringKey);

            menuItem.Text = string.Format(
                PluginStrings.EntryMenuItem,
                protectedStringKey);

            if (image != null)
            {
                menuItem.Image = image;
            }

            return(menuItem);
        }
Esempio n. 2
0
        /// <summary>
        /// Populates a drop-down menu with ProtectedStringMenuItem objects
        /// representing an entry's protected strings
        /// </summary>
        /// <param name="entry">Entry whos protected strings are listed</param>
        /// <param name="dropDown">Drop-down menu that's populated</param>
        /// <param name="itemsImage">Images to assign to all the menu-items</param>
        private void PopulateWithProtectedStringMenuItems(PwEntry entry, ToolStripDropDown dropDown, Image itemsImage = null)
        {
            foreach (KeyValuePair <string, ProtectedString> kvpA in entry.Strings)
            {
                if (kvpA.Value.IsProtected)
                {
                    ProtectedStringMenuItem item =
                        this.CreateProtectedStringMenuItem(
                            entry,
                            kvpA.Key,
                            itemsImage
                            );

                    dropDown.Items.Add(item);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Displays the character selection form for the protected string referenced by the
        /// clicked <see cref="ProtectedStringMenuItem" />.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEntryMenuItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem is ProtectedStringMenuItem)
            {
                ProtectedStringMenuItem item = (ProtectedStringMenuItem)e.ClickedItem;

                PwEntry entry = this.host.Database.RootGroup.FindEntry(item.EntryUuid, true);
                if (entry != null)
                {
                    if (entry.Strings.Exists(item.ProtectedStringKey))
                    {
                        ProtectedString procString = entry.Strings.Get(item.ProtectedStringKey);

                        // Display character selector form for the protected string
                        using (CharacterSelectorForm selectorForm = new CharacterSelectorForm(this.host, procString))
                        {
                            selectorForm.ShowDialog(this.host.MainWindow);
                        }

                        entry.Touch(false);
                    }
                }
            }
        }