public void CreateFileSystemItem(FileSystemItemType type, string content) { var newItem = fileSystemItemCreator.Create(type, content, openedFileSystemItem, FileSystemItemAreaType.Miniature); openedFileSystemItem.AddChild(newItem); FileSystemItems.Insert(0, newItem); }
private static MediaListItemType TranslateMediaEnum(FileSystemItemType pFsItemType) { switch (pFsItemType) { case FileSystemItemType.Directory: case FileSystemItemType.HardDrive: case FileSystemItemType.MemoryCard: case FileSystemItemType.CdDrive: return(MediaListItemType.Group); default: return(MediaListItemType.Song); } }
public FileSystemItem Create(FileSystemItemType type, string content, FileSystemItem parent, FileSystemItemAreaType areaType) { var child = new FileSystemItem { Children = new List <FileSystemItem>(), Content = content, Parent = parent, Type = type, BackgroundColor = colorGetter.GetNextColor() }; child.ModifyArea(areaType); return(child); }
public FileSystemItem(string path, bool loadChildren = true) { Serilog.Log.Debug("Getting path #{Path}", path); //special case: blank path should give list of drives if (String.IsNullOrEmpty(path)) { Serilog.Log.Debug("Getting drive list"); Children = DriveInfo.GetDrives().Select(d => new FileSystemItem(d.Name, false)).ToList <FileSystemItem>(); _typeEnum = FileSystemItemType.Directory; LastModifiedTime = DateTime.Now; return; } //special case: when accessing root of a drive, trailing slash won't come through, but is required to access root of drive if (path.EndsWith(":")) { path += @"\"; } Path = path; FileAttributes attr = File.GetAttributes(path); if (attr.HasFlag(FileAttributes.Directory)) { _typeEnum = FileSystemItemType.Directory; DirectoryInfo dir = new DirectoryInfo(path); LastModifiedTime = dir.LastWriteTime; if (loadChildren) { Children = dir.GetFileSystemInfos().Select(s => new FileSystemItem(s.FullName, false)).ToList <FileSystemItem>(); } } else { _typeEnum = FileSystemItemType.File; FileInfo file = new FileInfo(path); Size = file.Length; LastModifiedTime = file.LastWriteTime; } }
/// <summary> /// Warning: Do NOT use this constructor if <paramref name="fileSystemItemType"/> is /// <see cref="Modern.FileBrowser.FileSystemItemType.Drive"/>. Doing so will throw /// a <see cref="System.ArgumentException"/>. /// </summary> /// <param name="fullName"></param> /// <param name="fileSystemItemType"></param> /// <exception cref="System.ArgumentException"> /// Thrown if <paramref name="fileSystemItemType"/> is /// <see cref="Modern.FileBrowser.FileSystemItemType.Drive"/>. /// </exception> public FileSystemItemUI(string fullName, FileSystemItemType fileSystemItemType, string displayText = null) { FullName = fullName; FileSystemItemType = fileSystemItemType; _cachedName = displayText; FileSystemInfo info = null; switch (fileSystemItemType) { case FileSystemItemType.File: case FileSystemItemType.Library: { FileInfo fInfo = new FileInfo(fullName); Path = fInfo.DirectoryName; try { Size = fInfo.Length; } catch { } info = fInfo; } break; case FileSystemItemType.Folder: { DirectoryInfo dInfo = new DirectoryInfo(fullName); try { Path = dInfo.Parent.FullName; } catch { } info = dInfo; } break; default: throw new ArgumentException("This constructor should only be used for files or folders.", "fileSystemItemType"); } fileSystemInfo = info; }
/// <summary> /// Создает экземпляр класса /// </summary> /// <param name="itemType">Тип элемента</param> /// <param name="name">Наименование элемента</param> /// <param name="subFilesExt">Фильтр расширений файлов, входящих в подчиненные элементы</param> private FileSystemItem(FileSystemItemType itemType, String name, IList<String> subFilesExt) { _itemType = itemType; _name = name; _subFilesExt = subFilesExt; }
/// <inheritdoc/> public override async Task <IFileSystemItem> GetFileSystemItemAsync(string userFileSystemPath, FileSystemItemType itemType, byte[] itemId) { if (itemType == FileSystemItemType.File) { return(new VirtualFile(userFileSystemPath, this, this)); } else { return(new VirtualFolder(userFileSystemPath, this, this)); } }
public HashedFileSystemItem(string name, FileSystemItemType type, FileSystemItemAccess access, string hash) : base(name, type, access) { Hash = hash; }
private void CreateDirectory_OnClick(object sender, RoutedEventArgs e) { ContentFillingPopup.IsOpen = true; creatingFileSystemItemType = FileSystemItemType.Directory; }
private void deleteProgress(string deletedItem, FileSystemItemType type) { string deletedWhatType = type == FileSystemItemType.File ? "file" : "directory"; SendReport($"Deleted {deletedWhatType} {deletedItem}", ReportType.Progress); }
public override async Task <IFileSystemItem> GetFileSystemItemAsync(string path, FileSystemItemType itemType) { string remotePath = Mapping.MapPath(path); logger.LogMessage($"{nameof(IEngine)}.{nameof(GetFileSystemItemAsync)}()", path, remotePath); if (File.Exists(remotePath)) { return(new VirtualFile(path, this)); } else if (Directory.Exists(remotePath)) { return(new VirtualFolder(path, this)); } return(null); }
public FileSystemItem(FileSystemItemType itemType) : this() { ItemType = itemType; }
public FileSystemItem(string name, FileSystemItemType type, FileSystemItemAccess access) { this.name = name; this.type = type; this.access = access; }
public FileSystemItem(string pDisplayString, MediaListItemType pMediaItemType, string pKey, int pSpecificType) : base(pDisplayString, pMediaItemType) { ItemType = (FileSystemItemType)pSpecificType; FullPath = pKey; }
public FileSystemItem(string pDisplayString, FileSystemItemType pItemType, string pPath) : base(pDisplayString, TranslateMediaEnum(pItemType)) { ItemType = pItemType; FullPath = pPath; }