Example #1
0
        private void BGW_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            FileSystemInfo fsi = e.Argument as FileSystemInfo;

            ItemSize item = new ItemSize();

            item.Name     = fsi.Name;
            item.IsFolder = Directory.Exists(fsi.FullName);
            item.Size     = GetItemSize(fsi.FullName);
            _jobsItemList.Add(item);
        }
Example #2
0
        private void BGW_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            if (--_jobsCount == 0) //The last job
            {
                if (!_jobCancelling)
                {
                    List <ItemSize> sortedItemList = new List <ItemSize>();

                    double   totalSize  = 0;
                    ItemSize otherItems = new ItemSize()
                    {
                        Name = "Others", Size = 0, IsFolder = false
                    };
                    foreach (var item in _jobsItemList.OrderBy(i => i.Size).Reverse())
                    {
                        if (sortedItemList.Count < TOP_SIZE_ITEMS_COUNT)
                        {
                            sortedItemList.Add(item);
                        }
                        else
                        {
                            otherItems.Size += item.Size;
                        }

                        totalSize += item.Size;
                    }

                    if (_jobsItemList.Count > TOP_SIZE_ITEMS_COUNT)
                    {
                        sortedItemList.Add(otherItems);
                    }

                    if (totalSize != 0)
                    {
                        foreach (var item in sortedItemList)
                        {
                            item.Percentage = item.Size / totalSize;
                        }
                    }

                    ShowSortedItemsInGraph(sortedItemList);
                    ShowSortedItemsInText(sortedItemList);
                }
                else
                {
                    SizeMessage.Text = "The task was cancelled.";
                }

                BtnSize.Tag = "Ready";
            }
        }
Example #3
0
        private void BGW_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            if (--_jobsCount == 0) //The last job
            {
                if (!_jobCancelling)
                {
                    List<ItemSize> sortedItemList = new List<ItemSize>();

                    double totalSize = 0;
                    ItemSize otherItems = new ItemSize() { Name = "Others", Size = 0, IsFolder = false };
                    foreach (var item in _jobsItemList.OrderBy(i => i.Size).Reverse())
                    {
                        if (sortedItemList.Count < TOP_SIZE_ITEMS_COUNT)
                            sortedItemList.Add(item);
                        else
                            otherItems.Size += item.Size;

                        totalSize += item.Size;
                    }

                    if (_jobsItemList.Count > TOP_SIZE_ITEMS_COUNT)
                        sortedItemList.Add(otherItems);

                    if (totalSize != 0)
                    {
                        foreach (var item in sortedItemList)
                        {
                            item.Percentage = item.Size / totalSize;
                        }
                    }

                    ShowSortedItemsInGraph(sortedItemList);
                    ShowSortedItemsInText(sortedItemList);
                }
                else
                {
                    SizeMessage.Text = "The task was cancelled.";
                }

                BtnSize.Tag = "Ready";
            }
        }
Example #4
0
        private void BGW_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            FileSystemInfo fsi = e.Argument as FileSystemInfo;

            ItemSize item = new ItemSize();
            item.Name = fsi.Name;
            item.IsFolder = Directory.Exists(fsi.FullName);
            item.Size = GetItemSize(fsi.FullName);
            _jobsItemList.Add(item);
        }