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); }
private void ReplaceMethods(IQuickWindow quickWindow, int count) { const int bufsize = 260; StringBuilder buf = new StringBuilder(bufsize); List <QuickFindItem> findItemList = new List <QuickFindItem>(); for (int i = 0; i < count; i++) { QuickEverything.Everything_GetResultFullPathNameW(i, buf, bufsize); EVERYTHING_RESULT result = (EVERYTHING_RESULT)QuickEverything.Everything_GetLastError(); if (result != EVERYTHING_RESULT.EVERYTHING_OK) { continue; } QuickFindItem item = new QuickFindItem(GetRoot(), buf.ToString()); findItemList.Add(item); } quickWindow.ReplaceMethods(findItemList.ToArray()); }