private void RecurseHighlightExtensions(Rgba32Color *bitmap, FileItemBase parent, Rgba32Color color, string extension) { List <FileItemBase> children = parent.Children; int count = children.Count; for (int i = 0; i < count; i++) { FileItemBase child = children[i]; Rectangle2S rc = child.Rectangle; if (rc.Width > 0 && rc.Height > 0) { if (child.IsLeaf) { if (child.Extension == extension) { HighlightRectangle(bitmap, rc, color); } } else { RecurseHighlightExtensions(bitmap, child, color, extension); } } } }
private void ScanMtf(ScanningState state, CancellationToken token) { FileNodeIndexes[] fileItemsLookup; List <FileNodeIndexes> fileItems = new List <FileNodeIndexes>(); DriveInfo driveInfo = new DriveInfo(Path.GetPathRoot(state.RootPath)); using (NtfsReader ntfs = new NtfsReader(driveInfo, RetrieveMode.StandardInformations)) { fileItemsLookup = new FileNodeIndexes[ntfs.NodeCount]; ReadMft(state, ntfs, fileItemsLookup, fileItems, token); } foreach (FileNodeIndexes indexes in fileItems) { FileItemBase item = indexes.FileItem; FileNodeIndexes parentIndexes = fileItemsLookup[indexes.ParentNodeIndex]; if (indexes.NodeIndex == indexes.ParentNodeIndex) { // This must be the drive root } else if (parentIndexes != null) { ((FolderItem)parentIndexes.FileItem).AddItem(item, ref parentIndexes.FileCollection, ref parentIndexes.FirstFile); } else { // This must be the root } if (AsyncChecks(token)) { return; } } }
public FileNodeIndexes(FileItemBase fileItem, INtfsNode ntfsNode) { FileItem = fileItem; NodeIndex = ntfsNode.NodeIndex; ParentNodeIndex = ntfsNode.ParentNodeIndex; FullName = PathUtils.TrimSeparatorDotEnd(ntfsNode.FullName); }
public static CompressItem From(FileItemBase fileInfo) { return(new() { Length = fileInfo.Length, No = fileInfo.No, FullPath = fileInfo.FullPath, UriPath = fileInfo.UriPath, Path = fileInfo.Path }); }
/// <summary>Constructs the <see cref="FileItemViewModel"/>.</summary> /// /// <param name="viewModel">The main view model containing this item.</param> /// <param name="model">The model this item represents.</param> public FileItemViewModel(MainViewModel viewModel, FileItemBase model) { ViewModel = viewModel; Model = model; if (model.Type == FileItemType.File) { ExtensionItem = model.ExtensionItem.GetViewModel <ExtensionItemViewModel>(); } else { ExtensionItem = ExtensionItemViewModel.NotAFile; } Debug.Assert(ExtensionItem != null); exists = model.Exists; HookEvents(); LoadIcon(); }
public void HighlightExtensions(IWriteableBitmap bitmap, Rectangle2I rc, FileItemBase root, Rgba32Color color, string extension) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { RecurseHighlightExtensions(pBitmapBits, root, color, extension); bitmap.SetPixels(pBitmapBits); } }
public void HighlightExtensions(WriteableBitmap bitmap, Rectangle2I rc, FileItemBase root, Rgba32Color color, string extension) { if (rc.Width <= 0 || rc.Height <= 0) { return; } renderArea = rc; InitPixels(rc, Rgba32Color.Transparent); fixed(Rgba32Color *pBitmapBits = pixels) { RecurseHighlightExtensions(pBitmapBits, root, color, extension); IntPtr bitmapBitsPtr = (IntPtr)pBitmapBits; ui.Invoke(() => { bitmap.WritePixels((Int32Rect)rc, bitmapBitsPtr, rc.Width * rc.Height * 4, bitmap.BackBufferStride); }); } }
private static void OnRootChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is GraphView graphView) { FileItemBase root = graphView.Root; if (root == null) { graphView.AbortRender(); } graphView.root = root; graphView.HighlightNone(); graphView.Hover = null; if (root != null) { //lock (graphView.drawBitmapLock) graphView.RenderAsync(); } else { graphView.Clear(); } } }
protected void Refresh(RefreshFiles[] refreshFiles, CancellationToken token) { CanDisplayProgress = rootItem.Type == FileItemType.Volume || (rootItem.Type == FileItemType.Computer && !rootItem.Children.Any(f => f.Type != FileItemType.Volume && f.Type != FileItemType.FreeSpace && f.Type != FileItemType.Unknown)); if (CanDisplayProgress) { if (rootItem.Type == FileItemType.Volume) { try { if (rootItem.CheckExists()) { DriveInfo driveInfo = new DriveInfo(rootItem.RootPath); TotalSize = driveInfo.TotalSize; TotalFreeSpace = driveInfo.TotalFreeSpace; } else { CanDisplayProgress = false; } } catch { CanDisplayProgress = false; } } else if (rootItem.Type == FileItemType.Computer) { bool anySuccess = false; foreach (FileItemBase child in rootItem.Children) { if (child is RootItem root) { try { if (root.CheckExists()) { DriveInfo driveInfo = new DriveInfo(root.RootPath); TotalSize += driveInfo.TotalSize; TotalFreeSpace += driveInfo.TotalFreeSpace; anySuccess = true; continue; } } catch { } TotalSize += root.CachedTotalSize; TotalFreeSpace += root.CachedFreeSpace; } } if (!anySuccess) { CanDisplayProgress = false; } } } // Reset the progress if applicable TotalScannedSize = Extensions.TotalSize - refreshFiles.Sum(rf => rf.Files.Sum(f => f.Size)); ProgressState = ScanProgressState.Started; foreach (RefreshFiles refresh in refreshFiles) { FolderItem parent = refresh.Parent; FolderItem fileCollection = parent.GetFileCollection(); Queue <FolderItem> subdirs = new Queue <FolderItem>(); foreach (FileItemBase refreshChild in refresh.Files) { if (!refreshChild.Refresh()) { string fullName = refreshChild.FullName; parent.RemoveItem(refreshChild, ref fileCollection); // See if the type changed (file <-> directory) FileItemBase child = null; if (refreshChild.Type == FileItemType.File) { DirectoryInfo info = new DirectoryInfo(fullName); if (info.Exists) { FolderItem folder = new FolderItem(info); child = folder; // Folder exists enqueue it for scanning if (!info.Attributes.HasFlag(FileAttributes.ReparsePoint)) { subdirs.Enqueue(folder); } } } else if (refreshChild.Type == FileItemType.Directory) { FileInfo info = new FileInfo(fullName); if (info.Exists) { ExtensionItem extension = Extensions.GetOrAddFromPath(fullName); FileItem file = new FileItem(info, extension); child = file; // File exists, add it to the scanned size if (!info.Attributes.HasFlag(FileAttributes.ReparsePoint)) { TotalScannedSize += child.Size; } } } if (child != null) { FileItem firstFile = parent.GetFirstFile(); parent.AddItem(child, ref fileCollection, ref firstFile); } } else if (!refreshChild.IsReparsePointFile) { // Folder exists enqueue it for scanning if (refreshChild is FolderItem folder) { subdirs.Enqueue(folder); } // File exists, add it to the scanned size else { TotalScannedSize += refreshChild.Size; } } if (AsyncChecks(token)) { return; } } if (subdirs.Count > 0) { RefreshFolders(subdirs, token); } if (AsyncChecks(token)) { return; } } }
public GraphViewHoverEventArgs(RoutedEvent routedEvent, FileItemBase hover) : base(routedEvent) { Hover = hover; }