private static void OnRootChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is GraphView graphView)
            {
                FileNodeBase root = graphView.Root;
                if (root == null)
                {
                    graphView.AbortRender();
                }

                graphView.fileRoot = null;

                graphView.root = root;
                graphView.HighlightNone();
                graphView.Hover = null;
                if (root != null)
                {
                    //lock (graphView.drawBitmapLock)
                    graphView.RenderAsync();
                }
                else
                {
                    graphView.Clear();
                }
            }
        }
예제 #2
0
        private void ScanMtf(ScanningState state, CancellationToken token)
        {
            Dictionary <uint, FileNodeIndexes> fileNodes = new Dictionary <uint, FileNodeIndexes>();

            DriveInfo driveInfo = new DriveInfo(Path.GetPathRoot(state.RootPath));

            using (NtfsReader ntfs = new NtfsReader(driveInfo, RetrieveMode.StandardInformations)) {
                ReadMft(state, ntfs, fileNodes, token);
            }

            foreach (FileNodeIndexes indexes in fileNodes.Values)
            {
                FileNodeBase node = indexes.FileNode;
                //if (node.Type == FileNodeType.File)
                //	document.Extensions.Include(node.Extension, node.Size);
                if (indexes.NodeIndex == indexes.ParentNodeIndex)
                {
                    // This must be a root
                }
                else if (fileNodes.TryGetValue(indexes.ParentNodeIndex, out var parentIndexes))
                {
                    ((FolderNode)parentIndexes.FileNode).AddChild(node,
                                                                  ref parentIndexes.FileCollection, ref parentIndexes.SingleFile);
                }
                SuspendCheck();
                if (token.IsCancellationRequested)
                {
                    return;
                }
            }
        }
예제 #3
0
 public FileNodeIndexes(FileNodeBase fileNode, INtfsNode ntfsNode)
 {
     FileNode        = fileNode;
     NodeIndex       = ntfsNode.NodeIndex;
     ParentNodeIndex = ntfsNode.ParentNodeIndex;
     Path            = ntfsNode.FullName;
     if (Path.EndsWith(@"\."))
     {
         Path = Path.Substring(0, Path.Length - 1);
     }
 }
        private TreemapItem(FileNodeBase file, TreemapItem parent)
        {
            this.parent = parent;
            int count = file.ChildCount;

            children = new List <TreemapItem>(count);
            for (int i = 0; i < count; i++)
            {
                children.Add(new TreemapItem(file[i], this));
            }
            children.Sort(CompareReverse);
            children.Sort(Compare);
            size      = file.Size;
            extension = file.Extension + "";
            name      = file.Name + "";
            type      = file.Type;
            //color = file.Color;
        }
 public GraphViewHoverEventArgs(RoutedEvent routedEvent, FileNodeBase hover)
     : base(routedEvent)
 {
     Hover = hover;
 }
        private void ReadNative(Queue <FolderState> subdirs, CancellationToken token)
        {
            Win32FindData find        = new Win32FindData();
            FolderState   folderState = subdirs.Dequeue();
            ScanningState state       = folderState.State;
            FolderNode    parent      = folderState.Folder;
            bool          findResult;
            string        parentPath    = parent.Path;
            string        searchPattern = PathUtils.CombineNoChecks(parentPath, "*");

            if (!searchPattern.StartsWith(@"\\?\"))
            {
                searchPattern = @"\\?\" + searchPattern;
            }
            IntPtr hFind = FindFirstFileEx(searchPattern,
                                           FindExInfoLevels.Basic, out find,
                                           FindExSearchOps.NameMatch, IntPtr.Zero,
                                           FindExFlags.LargeFetch);

            if (hFind == InvalidHandle)
            {
                return;
            }

            FolderNode   fileCollection = null;
            FileNodeBase singleFile     = null;

            try {
                do
                {
                    string filePath = PathUtils.CombineNoChecks(parentPath, find.cFileName);
                    if (find.IsRelativeDirectory || SkipFile(state, find.cFileName, filePath))
                    {
                        // Skip these types of entries
                        findResult = FindNextFile(hFind, out find);
                        continue;
                    }
                    FileNodeBase child;
                    if (find.IsDirectory)
                    {
                        FolderNode folder = new FolderNode(find);
                        child = folder;
                        if (!find.IsSymbolicLink)
                        {
                            subdirs.Enqueue(new FolderState(folder, state));
                        }
                    }
                    else
                    {
                        FileNode file = new FileNode(find);
                        child = file;
                        if (!find.IsSymbolicLink)
                        {
                            state.ScannedSize += child.Size;
                            totalScannedSize  += child.Size;
                        }
                        file.extRecord = extensions.Include(GetExtension(file.Name), child.Size);
                    }
                    parent.AddChild(child, ref fileCollection, ref singleFile);

                    SuspendCheck();
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

                    findResult = FindNextFile(hFind, out find);
                } while (findResult);

                //if (parent.IsWatched)
                //	parent.RaiseChanged(FileNodeAction.ChildrenDone);
            }
            finally {
                FindClose(hFind);
            }
        }
 public void AddChild(FileNodeBase file)
 {
     children.Add(new TreemapItem(file, this));
 }
 public TreemapItem(FileNodeBase file) : this(file, null)
 {
 }