Exemplo n.º 1
0
        protected override void OnExit(ExitEventArgs e)
        {
            hotKey.Dispose();
            indexer.Dispose();
            indexer = null;
            searcher.Dispose();
            searcher = null;

            base.OnExit(e);
        }
Exemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            Debug.Listeners.Add(new ConsoleTraceListener());

            hotKey = new ManagedWinapi.Hotkey();
            //hotKey.WindowsKey = true;
            hotKey.Shift = true;
            hotKey.KeyCode = System.Windows.Forms.Keys.Space ;
            hotKey.HotkeyPressed += new EventHandler(hotKey_HotkeyPressed);

            try
            {
                hotKey.Enabled = true;
            }
            catch (ManagedWinapi.HotkeyAlreadyInUseException)
            {
                MessageBox.Show("Could not register hotkey (win+space already in use)", "Register key error", MessageBoxButton.OK, MessageBoxImage.Error);

                ShutdownMode = System.Windows.ShutdownMode.OnLastWindowClose;
            }

            var paths = winmole.Properties.Settings.Default.IndexedPaths;

            ICollection<KeyValuePair<string, List<string>>> pathsAndExt = TransofrmSettingsPaths(paths);

            indexer = new IndexingService(pathsAndExt);

            searcher = new SearchService();
            mainWindow = new MainWindow(searcher);

            indexer.BuildIndex();

            base.OnStartup(e);

            if(ShutdownMode == System.Windows.ShutdownMode.OnLastWindowClose)
            {
                ShowMainWindow();
            }
        }