private void IterateFolders(IDirectoryBrowser browser, ItemCollection items) { Mouse.OverrideCursor = Cursors.Wait; try { try { var childItems = new List <IDirectoryBrowser>(); foreach (var item in Browser.GetChildItems(browser.PathShell)) { childItems.Add(item); } if (this.Sort && browser.SpecialPathId != KF_IID.ID_FOLDERID_Desktop) { childItems.Sort((x, y) => this.SortIDirectoryBrowser(x, y)); } foreach (var item in childItems) { items.Add(CreateItem(item, item.Label)); } } catch (Exception ex) { InvokeExplorerError(new ExplorerTreeViewErrorEventArgs(ex)); } } finally { Mouse.OverrideCursor = null; } }
/// <summary> /// Returns full path of the selected node. /// </summary> /// <returns></returns> private string GetSelectedFolder() { var item = (TreeViewItem)SelectedItem; if (item == null) { return(null); } IDirectoryBrowser directoryBrowser = item.Tag as IDirectoryBrowser; if ((directoryBrowser.ItemType & DirectoryItemFlags.FileSystemDirectory) == DirectoryItemFlags.FileSystemDirectory) { return(directoryBrowser.PathFileSystem); } else { if (PInvoke.SHParseDisplayName(directoryBrowser.ParseName, IntPtr.Zero, out IntPtr pidl, 0, out uint dummy) == 0) { var path = new StringBuilder(260); if (PInvoke.SHGetPathFromIDListW(pidl, path)) { return(path.ToString()); } } } return(null); }
protected EditorImageBrowserController( IDirectoryBrowser directoryBrowser, IDirectoryPermission permission, IHostingEnvironment hostingEnvironment) : base(directoryBrowser, permission, hostingEnvironment) { }
protected EditorImageBrowserController(IDirectoryBrowser directoryBrowser, IDirectoryPermission permission, IVirtualPathProvider pathProvider, IThumbnailCreator thumbnailCreator) : base(directoryBrowser, permission, pathProvider) { this.thumbnailCreator = thumbnailCreator; }
/// <summary> /// Event type class constructor from parameter /// </summary> public BrowsingEventArgs(IDirectoryBrowser location, bool isBrowsing, BrowseResult result = BrowseResult.Unknown) : this() { Location = location; IsBrowsing = isBrowsing; Result = result; }
protected BaseFileBrowserController( IDirectoryBrowser directoryBrowser, IDirectoryPermission permission, IHostingEnvironment hostingEnvironment) { this.directoryBrowser = directoryBrowser; this.directoryBrowser.HostingEnvironment = hostingEnvironment; this.permission = permission; this.HostingEnvironment = hostingEnvironment; }
protected EditorFileBrowserController(IDirectoryBrowser directoryBrowser, IDirectoryPermission permission, IVirtualPathProvider pathProvider, IThumbnailCreator thumbnailCreator) { this.directoryBrowser = directoryBrowser; this.permission = permission; this.pathProvider = pathProvider; this.thumbnailCreator = thumbnailCreator; }
protected EditorImageBrowserController(IDirectoryBrowser directoryBrowser, IDirectoryPermission permission, IVirtualPathProvider pathProvider, IThumbnailCreator thumbnailCreator) { this.directoryBrowser = directoryBrowser; this.permission = permission; this.pathProvider = pathProvider; this.thumbnailCreator = thumbnailCreator; }
public LuceneSearchIndexer(IDirectoryBrowser browser, IApplicationSettings settings) { if (browser == null) { throw new ArgumentNullException("browser"); } if (settings == null) { throw new ArgumentNullException("settings"); } _browser = browser; _settings = settings; }
public DocumentsController(IDirectoryBrowser browser, IDocumentFormatter formatter) { if (browser == null) { throw new ArgumentNullException("browser"); } if (formatter == null) { throw new ArgumentNullException("formatter"); } this._browser = browser; this._formatter = formatter; }
/// <summary> /// Gets an array of <see cref="IDirectoryBrowser"/> model objects /// that describe the current path managed in this object. /// </summary> /// <returns></returns> public IDirectoryBrowser[] GetPathModels() { // Skip showing the desktop in the string based path int idxSrc = 0, size = _CurrentPath.Count; if ((_CurrentPath[idxSrc].GetModel().ItemType & DirectoryItemFlags.Desktop) != 0) { idxSrc = 1; size = size - 1; } IDirectoryBrowser[] ret = new IDirectoryBrowser[size]; for (int i = 0; i < size; i++) { ret[i] = _CurrentPath[idxSrc++].GetModel().Clone() as IDirectoryBrowser; } return(ret); }
public void TestWinShellPath() { IDirectoryBrowser libraries = Browser.Create(KF_IID.ID_FOLDERID_Libraries); IDirectoryBrowser music = null; Assert.IsTrue(libraries != null); foreach (var item in Browser.GetChildItems(libraries.SpecialPathId)) { // This test fails if folder was not resolved as being a known folder // All items under libraries (UsersLibrariesFolder) should be knownfolders // (CameraRollLibrary, DocumentsLibrary, MusicLibrary, PicturesLibrary, SavedPicturesLibrary, VideosLibrary) Assert.IsTrue(item.KnownFolder != null); if (string.Compare(item.SpecialPathId, KF_ParseName_IID.MusicLibrary, true) == 0) { music = item; } } Assert.IsTrue(music != null); // // String evaluates to "Libraries\Music" (item.LocalizedName) on an English system string WindowsShellPath = string.Format("{0}\\{1}", libraries.Name, music.Name); // Check if we can retrieve items for this through dedicated method IDirectoryBrowser[] winPath = Browser.GetWinShellPathItems(WindowsShellPath); Assert.IsTrue(winPath != null); Assert.IsTrue(winPath.Length == 2); Assert.IsTrue(Browser.IsTypeOf(WindowsShellPath) == PathType.WinShellPath); // Check to see if we can retrieve items for this through DirectoryExists IDirectoryBrowser[] pathItems; bool exists = Browser.DirectoryExists(WindowsShellPath, out pathItems); Assert.IsTrue(exists); Assert.IsTrue(pathItems != null); Assert.IsTrue(pathItems.Length == 2); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is TreeViewItem node) { IDirectoryBrowser directoryBrowser = node.Tag as IDirectoryBrowser; try { ImageSource result = null; if (result == null) { result = IconExtractor.GetIconSmall(directoryBrowser.PathFileSystem).ToImageSource(); } if (result == null) { result = IconExtractor.GetIconSmall(directoryBrowser.SpecialPathId).ToImageSource(); } if (result == null) { if (PInvoke.SHParseDisplayName(directoryBrowser.ParseName, IntPtr.Zero, out IntPtr pidl, 0, out uint dummy) == 0) { result = IconExtractor.GetIconSmall(pidl).ToImageSource(); } } if (result == null && directoryBrowser.IconResourceId != null) { string[] resourceId = directoryBrowser.IconResourceId.Split(','); if (resourceId.Length == 2 && int.TryParse(resourceId[1], out int iconIndex)) { if (string.IsNullOrEmpty(resourceId[0]) == false) { result = IconExtractor.GetIconSmall(resourceId[0], iconIndex).ToImageSource(); } } } return(result); } catch (Exception) { } } return(null); }
private bool IsDrive(IDirectoryBrowser directoryBrowser) { try { if ((directoryBrowser.ItemType & DirectoryItemFlags.Drive) == DirectoryItemFlags.Drive) { return(true); } if (directoryBrowser.PathFileSystem != null && new DirectoryInfo(directoryBrowser.PathFileSystem).Parent == null) { return(true); } } catch (Exception) { // ignore } return(false); }
public void TestWinShellPath2() { IDirectoryBrowser userFiles = Browser.Create(KF_IID.ID_FOLDERID_UsersFiles); Assert.IsTrue(userFiles != null); HashSet <string> KFs = new HashSet <string>(); KFs.Add(KF_ParseName_IID.Searches.ToUpper()); KFs.Add(KF_ParseName_IID.Links.ToUpper()); KFs.Add(KF_ParseName_IID.OneDrive.ToUpper()); KFs.Add(KF_ParseName_IID.Contacts.ToUpper()); KFs.Add(KF_ParseName_IID.My_Pictures.ToUpper()); KFs.Add(KF_ParseName_IID.My_Videos.ToUpper()); KFs.Add(KF_ParseName_IID.My_Music.ToUpper()); KFs.Add(KF_ParseName_IID.Downloads.ToUpper()); KFs.Add(KF_ParseName_IID.Personal.ToUpper()); KFs.Add(KF_ParseName_IID.SavedGames.ToUpper()); foreach (var item in Browser.GetChildItems(userFiles.SpecialPathId)) { // This test fails if folder was not resolved as being a known folder // All items under libraries (UsersLibrariesFolder) should be knownfolders if (item.KnownFolder != null) { if (string.IsNullOrEmpty(item.KnownFolder.ParsingName) == false) { string search = item.KnownFolder.ParsingName.ToUpper(); bool bFound = false; bFound = KFs.Contains(search); // If this tests fails it might just mean that we've encountered a // knownfolder that was not installed and running at the time this was written // So, failing this test may not be a big deal // (it really depends on the folder - is it listed above (? extend list) or not) Assert.IsTrue(bFound); } } } }
public void GetFilteredProgramFilesChildItem() { IDirectoryBrowser filterReferenceItem = null; int iCnt = 0; foreach (var item in Browser.GetChildItems(KF_IID.ID_FOLDERID_ProgramFiles)) { Assert.IsTrue(item != null); filterReferenceItem = item; iCnt++; } Assert.IsTrue(filterReferenceItem != null); // Filtering for an arbitrary item in the programm files folder should yield // a collection with one item (assuming that all item names are unique) int iCntFiltered = 0; foreach (var item in Browser.GetChildItems(KF_IID.ID_FOLDERID_ProgramFiles, filterReferenceItem.Name)) { Assert.IsTrue(item != null); iCntFiltered++; } Assert.IsTrue(iCntFiltered == 1); // Filtering for an arbitrary '*' item in the programm files folder should yield // a collection with one item (assuming that all item names are unique) iCntFiltered = 0; foreach (var item in Browser.GetChildItems(KF_IID.ID_FOLDERID_ProgramFiles, "*" + filterReferenceItem.Name + "*")) { Assert.IsTrue(item != null); iCntFiltered++; } Assert.IsTrue(iCntFiltered == 1); }
/// <summary> /// Master controller interface method to navigate all views /// to the folder indicated in <paramref name="folder"/> /// - updates all related viewmodels. /// </summary> /// <param name="itemPath"></param> /// <param name="requestor"</param> private void NavigateToFolder(IDirectoryBrowser location) { Logger.InfoFormat("'{0}'", location.FullName); // XXX Todo Keep task reference, support cancel, and remove on end? try { // XXX Todo Keep task reference, support cancel, and remove on end? var timeout = TimeSpan.FromSeconds(5); var actualTask = new Task(() => { ////string[] pathSegments = DirectoryInfoExLib.Factory.GetFolderSegments(location.FullName); var request = new BrowseRequest <IDirectoryBrowser>(location, RequestType.Navigational, _CancelTokenSource.Token); var t = Task.Factory.StartNew(() => NavigateToFolderAsync(request, null), request.CancelTok, TaskCreationOptions.LongRunning, _OneTaskScheduler); if (t.Wait(timeout) == true) { return; } _CancelTokenSource.Cancel(); // Task timed out so lets abort it return; // Signal timeout here... }); actualTask.Start(); actualTask.Wait(); } catch (System.AggregateException e) { Debug.WriteLine(e); } catch (Exception e) { Debug.WriteLine(e); } }
private int SortIDirectoryBrowser(IDirectoryBrowser x, IDirectoryBrowser y) { CompareStringNatural compareStringNatural = new CompareStringNatural(); bool xIsDrive = IsDrive(x); bool yIsDrive = IsDrive(y); if (xIsDrive && yIsDrive) { return(compareStringNatural.Compare(x.PathFileSystem, y.PathFileSystem)); } else if (xIsDrive) { return(1); } else if (yIsDrive) { return(-1); } else { return(compareStringNatural.Compare(x.Label, y.Label)); } }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <param name="other">The object to compare with the current object.</param> /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns> public bool Equals(IDirectoryBrowser other) { if (other == null) { return(false); } if (KnownFolder != null && other.KnownFolder != null) { if (KnownFolder.FolderId == other.KnownFolder.FolderId) { return(true); } } if (string.Compare(this.SpecialPathId, other.SpecialPathId, true) != 0 || string.Compare(this.PathFileSystem, other.PathFileSystem, true) != 0) { return(false); } return(true); }
public PathPatternTranslator(IDirectoryBrowser directoryBrowser) { _directoryBrowser = directoryBrowser; }
/// <summary> /// parameterized class constructor /// </summary> public ItemViewModel(IDirectoryBrowser model, int id) : this() { this._ModelStage1 = model; this._ID = id; }
/// <summary> /// Adds another <paramref name="item"/> as the last item in the current path. /// </summary> /// <param name="item"></param> public void Add(IDirectoryBrowser item) { _CurrentPath.Add(item.Clone() as IDirectoryBrowser); }