示例#1
0
        /// <summary>
        /// Free resources
        /// </summary>
        public override void Terminate()
        {
            RPCServer.Terminate();
            lock (_lockRPCClientManagers)
            {
                foreach (KeePassRPCClientManager manager in _RPCClientManagers.Values)
                {
                    manager.Terminate();
                }
                _RPCClientManagers.Clear();
            }

            // Tell any waiting RPC threads to just go ahead (and not wait for the user to finish interacting
            // with the KP UI.
            //KeePassRPCService.ensureDBisOpenEWH.Set();

            // remove event listeners
            _host.MainWindow.FileOpened  -= OnKPDBOpen;
            _host.MainWindow.FileClosed  -= OnKPDBClose;
            _host.MainWindow.FileCreated -= OnKPDBOpen; // or need a specific handler here?
            _host.MainWindow.FileSaving  -= OnKPDBSaving;
            _host.MainWindow.FileSaved   -= OnKPDBSaved;
            _host.MainWindow.DocumentManager.ActiveDocumentSelected -= OnKPDBSelected;

            GlobalWindowManager.WindowAdded -= GwmWindowAddedHandler;

            // Remove 'Tools' menu items
            ToolStripItemCollection tsMenu = _host.MainWindow.ToolsMenu.DropDownItems;

            tsMenu.Remove(_keePassRPCOptions);

            // Remove group context menu items
            ContextMenuStrip gcm = _host.MainWindow.GroupContextMenu;

            gcm.Items.Remove(_tsSeparator1);
            gcm.Items.Remove(_keeFoxRootMenu);

            if (logger != null)
            {
                logger.Close();
            }
        }