Exemplo n.º 1
0
 private void ShowSize(DirectoryData root)
 {
     FileCategories fc = (FileCategories)tscbCategories.SelectedItem;
     Dictionary<string, long> size = root.TotalSize(fc);
     dotnetCHARTING.WinForms.SeriesCollection sc = new dotnetCHARTING.WinForms.SeriesCollection();
     foreach (KeyValuePair<string, long> ext in size) {
         dotnetCHARTING.WinForms.Series s = new dotnetCHARTING.WinForms.Series(ext.Key);
         dotnetCHARTING.WinForms.Element el = new dotnetCHARTING.WinForms.Element();
         el.YValue = ext.Value;
         s.Elements.Add(el);
         sc.Add(s);
     }
     sc.Sort(dotnetCHARTING.WinForms.ElementValue.YValue, "Desc");
     chart1.SeriesCollection.Clear();
     chart1.SeriesCollection.Add(sc);
 }
Exemplo n.º 2
0
        private void ShowCount(DirectoryData root, int nbShown)
        {
            FileCategories fc = (FileCategories)tscbCategories.SelectedItem;
            Dictionary<string, int> count = root.TotalCount(fc);
            var sortedDict = from entry in count orderby entry.Value descending select entry;

            dotnetCHARTING.WinForms.SeriesCollection sc = new dotnetCHARTING.WinForms.SeriesCollection();
            int nb = 0;
            dotnetCHARTING.WinForms.Series sOther = new dotnetCHARTING.WinForms.Series("Other");
            dotnetCHARTING.WinForms.Element elOther = new dotnetCHARTING.WinForms.Element();
            elOther.Color = Color.White;
            elOther.YValue = 0;
            sOther.Elements.Add(elOther);
            foreach (KeyValuePair<string, int> ext in sortedDict) {
                if (nb < nbShown) {
                    dotnetCHARTING.WinForms.Series s = new dotnetCHARTING.WinForms.Series(ext.Key);
                    dotnetCHARTING.WinForms.Element el = new dotnetCHARTING.WinForms.Element();
                    el.Color = Color.White;
            #if DEBUG
                    Console.WriteLine("{0}: {1}", s.Name, el.Color);
            #endif
                    el.YValue = ext.Value;
                    s.Elements.Add(el);
                    sc.Add(s);
                } else {
                    elOther.YValue += ext.Value;
                }

                //dotnetCHARTING.WinForms.SmartPalette sp = s.GetSmartPalette(dotnetCHARTING.WinForms.Palette.One);
                //sp.SaveState("PaletteOne.xml");
                nb++;
            }

            // Check if there are some aggregated values
            if (elOther.YValue > 0) {
                sc.Add(sOther);
            }

            //sc.Sort(dotnetCHARTING.WinForms.ElementValue.YValue, "Desc");
            chart1.SeriesCollection.Clear();
            chart1.SeriesCollection.Add(sc);
            dotnetCHARTING.WinForms.SmartPalette sp = new dotnetCHARTING.WinForms.SmartPalette();
            //dotnetCHARTING.WinForms.Palette.Autumn;
            Color c = new Color();
            c = Color.FromArgb(156, 154, 255);
        }
Exemplo n.º 3
0
        private void ShowCount(DirectoryData root)
        {
            FileCategories fc = (FileCategories)tscbCategories.SelectedItem;
            Dictionary<string, int> count = root.TotalCount(fc);

            dotnetCHARTING.WinForms.SeriesCollection sc = new dotnetCHARTING.WinForms.SeriesCollection();
            foreach (KeyValuePair<string, int> ext in count) {
                dotnetCHARTING.WinForms.Series s = new dotnetCHARTING.WinForms.Series(ext.Key);
                dotnetCHARTING.WinForms.Element el = new dotnetCHARTING.WinForms.Element();
                el.Color = Color.White;
                Console.WriteLine("{0}: {1}", s.Name, el.Color);
                el.YValue = ext.Value;
                s.Elements.Add(el);
                sc.Add(s);

                //dotnetCHARTING.WinForms.SmartPalette sp = s.GetSmartPalette(dotnetCHARTING.WinForms.Palette.One);
                //sp.SaveState("PaletteOne.xml");
            }

            sc.Sort(dotnetCHARTING.WinForms.ElementValue.YValue, "Desc");
            chart1.SeriesCollection.Clear();
            chart1.SeriesCollection.Add(sc);
            dotnetCHARTING.WinForms.SmartPalette sp = new dotnetCHARTING.WinForms.SmartPalette();
            //dotnetCHARTING.WinForms.Palette.Autumn;
            Color c = new Color();
            c = Color.FromArgb(156, 154, 255);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Start reading the directories in a separate thread
        /// </summary>
        /// <param name="rootPath"></param>
        private void ReadDirectoryData(string rootPath)
        {
            _dd = new DirectoryData();
            _readDirectoryData = new Thread(new ParameterizedThreadStart(_dd.ReadDirectoryData));
            _readDirectoryData.Start(rootPath);

            timer1.Enabled = true;
        }
Exemplo n.º 5
0
 private DirectoryData(DirectoryData parent, DirectoryInfo di)
 {
     ReadDirectoryData(parent, di);
 }
Exemplo n.º 6
0
 private void ReadDirectoryData(DirectoryData parent, DirectoryInfo di)
 {
     if (!_abort) {
         _name = di.Name;
         _parent = parent;
         // Create the counters lists
         _count = new Dictionary<string, int>();
         _size = new Dictionary<string, long>();
         _children = new List<DirectoryData>();
         _lastDate = DateTime.MinValue;
         _firstDate = DateTime.MaxValue;
         _lastFile = "";
         // Read the directory's content
         try {
             foreach (FileInfo fi in di.GetFiles()) {
                 string ext = GetExtension(fi.Name);
                 if (_count.ContainsKey(ext)) {
                     _count[ext]++;
                 } else {
                     _count[ext] = 1;
                 }
                 if (_size.ContainsKey(ext)) {
                     _size[ext] += fi.Length;
                 } else {
                     _size[ext] = fi.Length;
                 }
                 if (fi.LastWriteTime > _lastDate) {
                     _lastDate = fi.LastWriteTime;
                     _lastFile = fi.FullName;
                 }
                 if (fi.LastWriteTime < _firstDate) {
                     _firstDate = fi.LastWriteTime;
                     _firstFile = fi.FullName;
                 }
             }
             // Read the sub directories
             foreach (DirectoryInfo sdi in di.GetDirectories()) {
                 // Rule out CVS directories
                 if (!sdi.Name.Equals("CVS")) {
                     Directories++;
                     DirectoryData child = new DirectoryData(this, sdi);
                     _children.Add(child);
                     if (child._lastDate > _lastDate) {
                         _lastDate = child._lastDate;
                         _lastFile = child._lastFile;
                     }
                     if (child._firstDate < _firstDate) {
                         _firstDate = child._firstDate;
                         _firstFile = child._firstFile;
                     }
                 }
             }
         } catch (Exception ex) {
             Console.WriteLine(ex.Message);
         }
     }
 }