예제 #1
0
        private bool Query(IQuickWindow quickWindow)
        {
            bool bInited = TestEverything(quickWindow);

            if (!bInited)
            {
                CurrentDescriptionType = DescriptionType.NotInited;
                quickWindow.Refresh(0);
                return(false);
            }

            QuickEverything.Everything_Reset();
            QuickEverything.Everything_SetMax(MAX_FILE_NUMBER_IN_ONE_QUERY);
            QuickEverything.Everything_SetOffset(GetPage() * MAX_FILE_NUMBER_IN_ONE_QUERY);

            string arg = quickWindow.GetArgument();

            if (arg == null)
            {
                return(false);
            }

            //改善易用性,将/视为\
            arg = arg.Replace('/', '\\');
            SearchOption option = SearchOption.File;
            string       a      = arg.Trim().ToLower();

            if (a.StartsWith("folder:"))
            {
                option = SearchOption.Folder;
            }
            else if (a.StartsWith("all:"))
            {
                option = SearchOption.All;
            }

            string realQueryText = arg;

            if (option == SearchOption.File)
            {
                realQueryText = "file:" + arg;
            }
            else if (option == SearchOption.Folder)
            {
                realQueryText = "folder:" + arg;
            }

            QuickEverything.Everything_SetSearchW(realQueryText);
            QuickEverything.Everything_QueryW(true);
            int count = QuickEverything.Everything_GetNumResults();
            EVERYTHING_RESULT result = (EVERYTHING_RESULT)QuickEverything.Everything_GetLastError();

            if (result == EVERYTHING_RESULT.EVERYTHING_OK && count > 0)
            {
                ReplaceMethods(quickWindow, count);
                return(true);
            }
            CurrentDescriptionType = DescriptionType.NoResult;
            return(false);
        }
예제 #2
0
        private bool TestEverything(IQuickWindow quickWindow)
        {
            // 返回引擎是否已经初始化
            QuickEverything.Everything_Reset();
            QuickEverything.Everything_SetMax(1);
            QuickEverything.Everything_SetOffset(0);
            QuickEverything.Everything_SetSearchW("*");
            bool success     = false;
            bool startServer = false;
            int  times       = 0;

            do
            {
                success = QuickEverything.Everything_QueryW(true);
                if (success)
                {
                    quickWindow.UnlockWindow();
                    int count = QuickEverything.Everything_GetNumResults();
                    return(count > 0 ? true : false);
                }
                else
                {
                    quickWindow.LockWindow();
                    if (!startServer)
                    {
                        StartService();
                        startServer = true;
                    }
                    Thread.Sleep(COUNT_DOWN_TIMEOUT);
                    times++;
                    if (times > MAX_TRYING_TIMES)
                    {
                        return(false);
                    }
                }
            } while (!success);
            Debug.Assert(false, "应该在success的时候就返回了");
            return(false);
        }