コード例 #1
0
ファイル: Main.cs プロジェクト: paulocmarques/PowerToys
        /// <summary>
        /// Return a filtered list, based on the given query
        /// </summary>
        /// <param name="query">The query to filter the list</param>
        /// <param name="delayedExecution">False if this is the first pass through plugins, true otherwise. Slow plugins should run delayed.</param>
        /// <returns>A filtered list, can be empty when nothing was found</returns>
        public List <Result> Query(Query query, bool delayedExecution)
        {
            if (!delayedExecution || !_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search) || _cache is null)
            {
                return(new List <Result>(0));
            }

            // Get results from cache if they already exist for this query, otherwise query OneNote. Results will be cached for 1 day.
            var results = _cache.GetOrAdd(query.Search, () =>
            {
                var pages = OneNoteProvider.FindPages(query.Search);

                return(pages.Select(p => new Result
                {
                    IcoPath = _iconPath,
                    Title = p.Name,
                    QueryTextDisplay = p.Name,
                    SubTitle = @$ "{p.Notebook.Name}\{p.Section.Name}",
                    Action = (_) => OpenPageInOneNote(p),
                    ContextData = p,
                    ToolTipData = new ToolTipData(Name, @$ "{p.Notebook.Name}\{p.Section.Name}\{p.Name}"),
コード例 #2
0
ファイル: Main.cs プロジェクト: SOlangsam/PowerToys
        /// <summary>
        /// Return a filtered list, based on the given query
        /// </summary>
        /// <param name="query">The query to filter the list</param>
        /// <returns>A filtered list, can be empty when nothing was found</returns>
        public List <Result> Query(Query query)
        {
            if (!_oneNoteInstalled || query is null || string.IsNullOrWhiteSpace(query.Search))
            {
                return(new List <Result>(0));
            }

            var pages = OneNoteProvider.FindPages(query.Search);

            return(pages.Select(p => new Result
            {
                IcoPath = _iconPath,
                Title = p.Name,
                QueryTextDisplay = p.Name,
                SubTitle = @$ "{p.Notebook.Name}\{p.Section.Name}",
                Action = (_) =>
                {
                    p.OpenInOneNote();
                    ShowOneNote();
                    return true;
                },
                ContextData = p,
                ToolTipData = new ToolTipData(Name, @$ "{p.Notebook.Name}\{p.Section.Name}\{p.Name}"),