Example #1
0
        private void ScanChildren(FsItem item, string parentPath, CancellationToken run)
        {
            if (run.IsCancellationRequested)
            {
                return;
            }

            var scanObject = parentPath + item.Name;

            if (scanObject[scanObject.Length - 1] != Path.DirectorySeparatorChar)
            {
                scanObject += Path.DirectorySeparatorChar;
            }

            CurrentScanned = scanObject;
            item.Items     = _scanner.Scan(scanObject, ref _total);
            if (item.Items == null)
            {
                _problematic.Add(scanObject);
                return; //Access to directory denied
            }
            for (var i = item.Items.Count - 1; i >= 0; i--)
            {
                var child = item.Items[i];
                if (child.IsDir)
                {
                    ScanChildren(child, scanObject, run);
                }
                item.Size += child.Size;
            }
        }
Example #2
0
        private void LoadChartDataCollection(int dataLevel, FsItem dataPoint, long precedingObjectSize)
        {
            Series ser;
            if (!TryGetDataSeries(dataLevel, dataPoint, out ser)) return;

            if (precedingObjectSize > 0)
            {
                var delta = precedingObjectSize - _totals[ser];
                if (delta > 0)
                {
                    AddOrExtendPlaceHolder(delta, ser);
                }
            }

            foreach (var point in dataPoint.Items)
            {
                if (point.Size > _filterThreshold)
                {
                    AddPoint(ser, point.Size, point);
                }
                else
                {
                    AddOrExtendPlaceHolder(point.Size, ser);
                }
                if (point.Items != null && point.Items.Count > 0)
                {
                    LoadChartDataCollection(dataLevel + 1, point, precedingObjectSize);
                }
                precedingObjectSize += point.Size;
            }
            LoadChartDataCollection(dataLevel + 1, Empty, precedingObjectSize);
        }
Example #3
0
 public static string FsItem(FsItem source)
 {
     if (source.IsDir && source.Items == null)
     {
         return "<Access Denied>";
     }
     return source.Size == 0 ? "<Empty>" : Size(source.Size);
 }
Example #4
0
 public static string FsItem(FsItem source)
 {
     if (source.IsDir && source.Items == null)
     {
         return("<Access Denied>");
     }
     return(source.Size == 0 ? "<Empty>" : Size(source.Size));
 }
Example #5
0
        private FsItem ScanUnitInternal(string location, bool useAllocationSize, CancellationToken run)
        {
            _total = 0;
            _problematic.Clear();
            CurrentTarget = location;
            var root = new FsItem(location, 0, true);

            _scanner = new DirectoryScanner(useAllocationSize);
            ScanChildren(root, run);
            return(root);
        }
Example #6
0
 private void ScanChildren(FsItem item, string parentPath)
 {
     var pp = parentPath + item.Name + "\\";
     item.Items = DirectoryScanner.Scan(pp, ref _total);
     if (item.Items == null)
     {
         _problematic.Add(pp);
         return; //Access to directory denied
     }
     for (var i = item.Items.Count - 1; i >= (parentPath == null ? 0 : 2); i--)
     {
         var child = item.Items[i];
         if (child.IsDir) ScanChildren(child, pp);
         item.Size += child.Size;
     }
     if (parentPath != null) //in case not drive root
         item.Items.RemoveRange(0, 2); //removing "." & ".."
 }
Example #7
0
        public FsItem Scan(string driveName) //C:
        {
            _total = 0;
            _problematic.Clear();
            CurrentTarget = driveName;

            var drive = new DriveInfo(driveName);
            _occupied = drive.TotalSize - drive.TotalFreeSpace;

            var root = new FsItem(driveName, 0, true);
            ScanChildren(root, null);
            root.Items.InsertRange(0, new[]
            {
                new FsItem("[Free space]", drive.TotalFreeSpace, false),
                new FsItem("[Inaccessible]", Math.Max(0, _occupied - _total), false)
            });
            return root;
        }
Example #8
0
 private void ScanChildren(FsItem item, CancellationToken run) => ScanChildren(item, null, run);
Example #9
0
        private bool TryGetDataSeries(int dataLevel, FsItem dataPoint, out Series ser)
        {
            if (chart1.ChartAreas.Count == dataLevel)
            {
                if (dataPoint == Empty)
                {
                    ser = null;
                    return false;
                }

                //create chart area and series
                var ca = new ChartArea("chartAreaLevel" + dataLevel)
                {
                    Position =
                    {
                        Auto = false,
                        X = 0,
                        Y = 0,
                        Height = 100,
                        Width = 100
                    }
                };
                if (dataLevel > 0)
                {
                    ca.BackColor = Color.Transparent;
                }
                chart1.ChartAreas.Add(ca);

                ser = new Series("seriesLevel" + dataLevel)
                {
                    ChartArea = ca.Name,
                    ChartType = SeriesChartType.Doughnut,
                    IsXValueIndexed = true
                };
                chart1.Series.Add(ser);
                _totals.Add(ser, 0);
            }
            else
            {
                ser = chart1.Series[dataLevel];
            }
            return true;
        }