Exemplo n.º 1
0
        public SearchResult[] PerformSearch(string search, FrecencyStorage frecencyStorage)
        {
            var frecencyData = frecencyStorage.GetFrecencyData();
            Func <IIndexable, int> boosterFunc = x => frecencyData.ContainsKey(x.BoostIdentifier) ? frecencyData[x.BoostIdentifier] : 0;

            _selectaSeacher = _selectaSeacher.Search(search, boosterFunc);
            return(_selectaSeacher.SearchResults.Take(100).ToArray());
        }
Exemplo n.º 2
0
        public MainViewModel()
        {
            _actionRegistry = new ActionRegistry();

            _actionRegistry.RegisterIndexer(() => new ControlPanelIndexer().GetControlPanelItems());
            _actionRegistry.RegisterIndexer(() => new WindowsStoreAppIndexer().GetWindowsStoreApps());

            _actionRegistry.RegisterAction <OpenAction>();
            _actionRegistry.RegisterAction <OpenAsAdminAction>();
            _actionRegistry.RegisterAction <ContainingFolderConverter>();

            _actionRegistry.RegisterAction <WindowsStoreAppOpenAction>();

            var frecencyPath = CatapultPaths.FrecencyPath;

            _frecencyStorage = new FrecencyStorage(frecencyPath);

            _actionRegistry.RegisterAction <KillProcessAction>();
            _actionRegistry.RegisterAction <OpenLastLogAction>();
            _actionRegistry.RegisterAction <OpenLogFolderAction>();
            _actionRegistry.RegisterAction <OpenConfigAction>();
            _actionRegistry.RegisterAction <EnableRunAtStartUpAction>();
            _actionRegistry.RegisterAction <DisableRunAtStartUpAction>();
            _actionRegistry.RegisterAction <ReindexFilesAction>();

            _actionRegistry.RegisterAction <CheckForUpdatesAction>();
            CheckForUpdatesAction.UpdateCheckAction = SquirrelIntegration.Instance.CheckForUpdates;

            SquirrelIntegration.OnUpdateFound += version =>
            {
                _actionRegistry.RegisterAction <UpgradeCatapultAction>();
                UpgradeCatapultAction.UpgradeAction = SquirrelIntegration.Instance.UpgradeToNewVersion;
            };

            _actionRegistry.RegisterAction <GoogleAction>();
            _actionRegistry.RegisterAction <WikipediaAction>();

            _actionRegistry.RegisterAction <ClipboardHistoryAction>();
            _actionRegistry.RegisterAction <UnderscorizeClipboardString>();
            _actionRegistry.RegisterAction <TripleBacktickClipboardString>();

            _actionRegistry.RegisterAction <WindowsSleepAction>();
            _actionRegistry.RegisterAction <WindowsRestartAction>();
            _actionRegistry.RegisterAction <WindowsShutdownAction>();
            _actionRegistry.RegisterAction <WindowsShutdownForceAction>();
            _actionRegistry.RegisterAction <WindowsLockComputerAction>();
            _actionRegistry.RegisterAction <WindowsLogOffAction>();

            FileIconResolver.ResolverFunc = WindowsFileIconResolver.Resolve;

            Reset();

            StartIntentService(Dispatcher.CurrentDispatcher);

            StackPushed += MainViewModel_StackPushed;
        }
        public SearchResult[] PerformSearch(string search, FrecencyStorage frecencyStorage)
        {
            _searcher = _searcher.Search(search);

            if (search.IsNullOrWhiteSpace() && _primaryIndexable != null)
            {
                var primarySearchResult = new SearchResult(_primaryIndexable.Name, 0, _primaryIndexable, ImmutableHashSet.Create <int>());
                return(new[] { primarySearchResult }.Concat(_searcher.SearchResults.Where(x => x.TargetItem != _primaryIndexable)).ToArray());
            }

            return(_searcher.SearchResults);
        }
Exemplo n.º 4
0
        public SearchResult[] PerformSearch(string search, FrecencyStorage frecencyStorage)
        {
            var results = new[] { new SearchResult(search, 0, new StringIndexable(search), ImmutableHashSet.Create <int>()) };

            if (_autocompleterFunc == null)
            {
                return(results);
            }

            SearchResult[] autocompleteResults = _autocompleterFunc(search);
            return(results.Concat(autocompleteResults).ToArray());
        }
Exemplo n.º 5
0
        public SearchResult[] PerformSearch(string search, FrecencyStorage frecencyStorage)
        {
            bool updated;

            _indexableUpdateState = _indexableUpdateState.CheckUpdate(out updated);

            if (updated)
            {
                Log.Information("Updated searcher with new indexables.");
                _selectaSeacher = Searcher.Create(_indexableUpdateState.Indexables);
            }

            var frecencyData = frecencyStorage.GetFrecencyData();
            Func <IIndexable, int> boosterFunc = x => frecencyData.ContainsKey(x.BoostIdentifier) ? frecencyData[x.BoostIdentifier] : 0;

            _selectaSeacher = _selectaSeacher.Search(search, boosterFunc);

            SearchResult[] searchResults = _selectaSeacher.SearchResults.Take(100).ToArray();

            try
            {
                double result = _calculationEngine.Calculate(search);
                var    name   = result.ToString(CultureInfo.InvariantCulture);

                if (!string.Equals(name, search?.Trim(), StringComparison.InvariantCultureIgnoreCase))
                {
                    searchResults = searchResults.Concat(new[] { new SearchResult(name, 0, new StringIndexable(name, "Result of formula"), ImmutableHashSet.Create <int>()) }).ToArray();
                }
            }
            catch
            {
                // Ignore calculation errors.
            }

            return(searchResults);
        }