<commit_before>﻿using KeePass.Plugins;
using KeePass.Util;
using KeePassLib;
using KeePassLib.Collections;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace YetAnotherFaviconDownloader
{
    public sealed class YetAnotherFaviconDownloaderExt : Plugin
    {
        // Public RSA Key (4096 bits)
        private static readonly string UpdateKey =
            "<RSAKeyValue><Modulus>yF54V4nhAFE+N7nwcHmKMU3nd+4P7CEq0zpp8w2Wq+sKofN4mw" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>8SqSDojeCCI/QGOxXPujBw" +
            "ZNlWGBunuSxuaCR/Vlx4vrlYr7lw7mFfQSjkSim7yUxoesJrYWWwjf/n6RBalOVy/REh4CTM" +
            "6wZMd7Ux9lXI89ml1tebjhAZ+GCk3QLS0wNxB9btbffDgWhAfHs7WKUk0=</Modulus><Exp" +
            "onent>AQAB</Exponent></RSAKeyValue>";

        public override string UpdateUrl
        {
            get { return "https://github.com/navossoc/KeePass-Yet-Another-Favicon-Downloader/raw/master/VERSION"; }
        }

        // Custom settings
        public static Configuration Config;

        // Plugin host interface
        private IPluginHost pluginHost;

        // Icon used by YAFD menus
        private Image menuImage;

        // Entry Context Menu
        private ToolStripSeparator entrySeparator;
        private ToolStripMenuItem entryDownloadFaviconsItem;

        // Group Context Menu
        private ToolStripSeparator groupSeparator;
        private ToolStripMenuItem groupDownloadFaviconsItem;

        // Tools Menu
        private ToolStripSeparator toolsMenuSeparator;
        private ToolStripMenuItem[] toolsMenuDropDownItems;
        private ToolStripMenuItem toolsMenuYAFD;

        // YAFD SubItems
        private ToolStripMenuItem toolsSubItemsPrefixURLsItem;
        private ToolStripMenuItem toolsSubItemsTitleFieldItem;

        public override bool Initialize(IPluginHost host)
        {
            Util.Log("Plugin Initialize");

            Debug.Assert(host != null);
            if (host == null)
            {
                return false;
            }
            pluginHost = host;

            // Custom settings
            Config = new Configuration(pluginHost.CustomConfig);

            // Require a signed version file
            UpdateCheckEx.SetFileSigKey(UpdateUrl, UpdateKey);

            // Load menus icon resource
            menuImage = Properties.Resources.Download_32;

            // Add Entry Context menu items
            entrySeparator = new ToolStripSeparator();
            entryDownloadFaviconsItem = new ToolStripMenuItem("Download Favicons", menuImage, DownloadFaviconsEntry_Click);
            pluginHost.MainWindow.EntryContextMenu.Items.Add(entrySeparator);
            pluginHost.MainWindow.EntryContextMenu.Items.Add(entryDownloadFaviconsItem);

            // Add Group Context menu items
            groupSeparator = new ToolStripSeparator();
            groupDownloadFaviconsItem = new ToolStripMenuItem("Download Favicons (recursively)", menuImage, DownloadFaviconsGroup_Click);
            pluginHost.MainWindow.GroupContextMenu.Items.Add(groupSeparator);
            pluginHost.MainWindow.GroupContextMenu.Items.Add(groupDownloadFaviconsItem);

            //////////////////////////////////////////////////////////////////////////
<commit_msg>Adds mnemonics to menu items. (issue #28)<commit_after>﻿using KeePass.Plugins;
using KeePass.Util;
using KeePassLib;
using KeePassLib.Collections;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows.Forms;

namespace YetAnotherFaviconDownloader
{
    public sealed class YetAnotherFaviconDownloaderExt : Plugin
    {
        // Public RSA Key (4096 bits)
        private static readonly string UpdateKey =
            "<RSAKeyValue><Modulus><KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "<KEY>" +
            "NcG2rwVQvr3/dbP80Aj1cGjhZgF3LO3hkr2gz/hEPUY0zHt817dWcga1nXvy6GdsotbDEQ+7" +
            "T7MGLgIWHfXZW+WcGfXgtbSPr+xHJXOMPoJ0ZSdHKyZU2m2WwX0NFJ7wc3xRyigLaFe9OZxe" +
            "TT1HzOfymtc9YJs0qw7wkDWdZZwSWPLhytEAG2SQAkVy/vp4jP8SqSDojeCCI/QGOxXPujBw" +
            "ZNlWGBunuSxuaCR/Vlx4vrlYr7lw7mFfQSjkSim7yUxoesJrYWWwjf/n6RBalOVy/REh4CTM" +
            "6wZMd7Ux9lXI89ml1tebjhAZ+GCk3QLS0wNxB9btbffDgWhAfHs7WKUk0=</Modulus><Exp" +
            "onent>AQAB</Exponent></RSAKeyValue>";

        public override string UpdateUrl
        {
            get { return "https://github.com/navossoc/KeePass-Yet-Another-Favicon-Downloader/raw/master/VERSION"; }
        }

        // Custom settings
        public static Configuration Config;

        // Plugin host interface
        private IPluginHost pluginHost;

        // Icon used by YAFD menus
        private Image menuImage;

        // Entry Context Menu
        private ToolStripSeparator entrySeparator;
        private ToolStripMenuItem entryDownloadFaviconsItem;

        // Group Context Menu
        private ToolStripSeparator groupSeparator;
        private ToolStripMenuItem groupDownloadFaviconsItem;

        // Tools Menu
        private ToolStripSeparator toolsMenuSeparator;
        private ToolStripMenuItem[] toolsMenuDropDownItems;
        private ToolStripMenuItem toolsMenuYAFD;

        // YAFD SubItems
        private ToolStripMenuItem toolsSubItemsPrefixURLsItem;
        private ToolStripMenuItem toolsSubItemsTitleFieldItem;

        public override bool Initialize(IPluginHost host)
        {
            Util.Log("Plugin Initialize");

            Debug.Assert(host != null);
            if (host == null)
            {
                return false;
            }
            pluginHost = host;

            // Custom settings
            Config = new Configuration(pluginHost.CustomConfig);

            // Require a signed version file
            UpdateCheckEx.SetFileSigKey(UpdateUrl, UpdateKey);

            // Load menus icon resource
            menuImage = Properties.Resources.Download_32;

            // Add Entry Context menu items
            entrySeparator = new ToolStripSeparator();
            entryDownloadFaviconsItem = new ToolStripMenuItem("Download &Favicons", menuImage, DownloadFaviconsEntry_Click);
            pluginHost.MainWindow.EntryContextMenu.Items.Add(entrySeparator);
            pluginHost.MainWindow.EntryContextMenu.Items.Add(entryDownloadFaviconsItem);

            // Add Group Context menu items
            groupSeparator = new ToolStripSeparator();
            groupDownloadFaviconsItem = new ToolStripMenuItem("Download Fa&vicons (recursively)", menuImage, DownloadFaviconsGroup_Click);
            pluginHost.MainWindow.GroupContextMenu.Items.Add(groupSeparator);
            pluginHost.MainWindow.GroupContextMenu.Items.Add(groupDownloadFaviconsItem);

            //////////////////////////////////////////////////////////////////////////

{'fraction_non_alphanumeric': 0.09367782909930716, 'fraction_numerical': 0.012990762124711317, 'mean_word_length': 2.3264522323571772, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4876656', 'n_tokens_mistral': 2005, 'n_tokens_neox': 1964, 'n_words': 356}