/// <summary> /// Gets a list of logical drives attached to thisPC. /// </summary> /// <returns></returns> private SuggestQueryResultModel ListRootItems(string input) { SuggestQueryResultModel result = new SuggestQueryResultModel(); // Get Root Items below ThisPC var parent = Browser.MyComputer; foreach (var item in Browser.GetChildItems(parent.SpecialPathId, input + "*", SubItemFilter.NameOrParsName, true)) { if (Browser.IsTypeOf(item.ParseName) != PathType.SpecialFolder) { var Itemsuggest = CreateItem(item.Label, item.ParseName, PathType.FileSystemPath, parent); result.ResultList.Add(Itemsuggest); } } // Get Root Items below Desktop parent = Browser.DesktopDirectory; foreach (var item in Browser.GetChildItems(parent.SpecialPathId, input + "*", SubItemFilter.NameOnly, true)) { // filter out RecycleBin, ControlPanel... since its not that useful here... bool IsFilteredItem = string.Compare(item.ParseName, "::{645FF040-5081-101B-9F08-00AA002F954E}", true) == 0 || string.Compare(item.ParseName, "::{26EE0668-A00A-44D7-9371-BEB064C98683}", true) == 0; // Filter out ThisPC since its items are handled in previous loop bool IsThisPC = string.Compare(item.ParseName, "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", true) == 0; if (IsFilteredItem == false && IsThisPC == false) { var Itemsuggest = CreateItem(item.Label, item.Name, PathType.WinShellPath, parent); result.ResultList.Add(Itemsuggest); } } // Pronounce path as invalid if list of suggestions is empty and path is non-existing // We do this here because path could be non-existing but we could still find filter suggestions // (eg: 'c' -> suggestion 'C:\') if (result.ResultList.Count == 0) { IDirectoryBrowser[] pathItems = null; if (Browser.DirectoryExists(input, out pathItems) == false) { result.ValidInput = false; } } return(result); }
/// <summary> /// Gets a list of child elements (if any available) of the list item in the array. /// </summary> /// <param name="path"></param> /// <param name="pathType"></param> /// <param name="searchMask"></param> /// <returns></returns> private static Task <SuggestQueryResultModel> ListChildren(IDirectoryBrowser[] path, PathType pathType, LocationIndicator li, string searchMask = null) { if (li != null) { li.ResetPath(path); } var dirPath = path[path.Length - 1]; SuggestQueryResultModel result = new SuggestQueryResultModel(); string namedPath = string.Empty; if (pathType == PathType.WinShellPath) { namedPath = path[0].Name; for (int i = 1; i < path.Length; i++) { namedPath = namedPath + '\\' + path[i].Name; } } foreach (var item in Browser.GetChildItems(dirPath.PathShell, searchMask, SubItemFilter.NameOnly, true)) { SuggestionListItem Itemsuggest = null; if (pathType == PathType.WinShellPath) { Itemsuggest = CreateItem(item.Label, namedPath + '\\' + item.Name, PathType.WinShellPath, path); } else { if (Browser.IsTypeOf(item.ParseName) != PathType.SpecialFolder) { Itemsuggest = CreateItem(item.Label, item.ParseName, PathType.FileSystemPath, path); } } result.ResultList.Add(Itemsuggest); } return(Task.FromResult <SuggestQueryResultModel>(result)); }
/// <summary> /// Gets a list of subdirectories to the given path if it exists. /// The returned items Value contain a complete path for each item. /// </summary> /// <returns></returns> private SuggestQueryResultModel ListSubItems(string input, string searchMask = null) { SuggestQueryResultModel result = new SuggestQueryResultModel(); var parent = Browser.Create(input); foreach (var item in Browser.GetChildItems(input, searchMask, SubItemFilter.NameOnly, true)) { if (Browser.IsTypeOf(item.ParseName) != PathType.SpecialFolder) { result.ResultList.Add(CreateItem(item.Label, item.ParseName, PathType.FileSystemPath, parent)); } } return(result); }