/// <summary>
        /// The <c>Initialize</c> function is called by KeePass when
        /// you should initialize your plugin (create menu items, etc.).
        /// </summary>
        /// <param name="host">Plugin host interface. By using this
        /// interface, you can access the KeePass main window and the
        /// currently opened database.</param>
        /// <returns>You must return <c>true</c> in order to signal
        /// successful initialization. If you return <c>false</c>,
        /// KeePass unloads your plugin (without calling the
        /// <c>Terminate</c> function of your plugin).</returns>
        public override bool Initialize(IPluginHost host)
        {
            _host = host;
            _port = (int)Settings.Default["Port"];

            _tsmiSep1 = new ToolStripSeparator();

            _tsmiSettings = new ToolStripMenuItem();
            _tsmiSettings.Text = "Bookmarklet Plugin Settings";
            _tsmiSettings.Click += OnSettingsClick;

            _tsmiCreateBookmarklet = new ToolStripMenuItem();
            _tsmiCreateBookmarklet.Text = "Create Bookmarklet";
            _tsmiCreateBookmarklet.Click += OnCreateBookmarkletClick;

            _host.MainWindow.ToolsMenu.DropDownItems.Add(_tsmiSep1);
            _host.MainWindow.ToolsMenu.DropDownItems.Add(_tsmiSettings);
            _host.MainWindow.ToolsMenu.DropDownItems.Add(_tsmiCreateBookmarklet);

            _server = new Server(_port, _host);
            _server.Start();

            return true; // Initialization successful
        }
        public void OnSettingsClick(object sender, EventArgs e)
        {
            FrmSettings frmSettings = new FrmSettings();
            frmSettings.txtPort.Text = _port.ToString();

            if (frmSettings.ShowDialog() == DialogResult.OK)
            {
                _server.Stop();

                _port = int.Parse(frmSettings.txtPort.Text);

                Settings.Default["Port"] = _port;
                Settings.Default.Save();

                _server = new Server(_port, _host);
                _server.Start();
            }
        }