Пример #1
0
        private void UpdateDeleteButtonText()
        {
            long deleteSize = GetDeletableFolders().Sum(item => item.TotalSize);

            btnDelete.Text    = $"Delete {Readable.FileSize(deleteSize)}";
            btnDelete.Enabled = (deleteSize > 0);
        }
Пример #2
0
        private void frmFolderList_Load(object sender, System.EventArgs e)
        {
            if (Position != null)
            {
                Position.Apply(this);
            }

            try
            {
                SuspendLayout();
                var list = new BindingList <FolderInfo>();
                foreach (var folder in Folders.OrderByDescending(item => item.TotalSize))
                {
                    list.Add(folder);
                }

                BindingSource bs = new BindingSource();
                bs.DataSource         = list;
                dgvFolders.DataSource = bs;

                lblTotalSize.Text = Readable.FileSize(Folders.Sum(item => item.TotalSize));

                _sorter = new FolderInfoSorter(dgvFolders, new DataGridViewSorter <FolderInfo> .ColumnInfo()
                {
                    Column      = colSize,
                    IsAscending = false
                });
            }
            finally
            {
                ResumeLayout();
            }
        }
Пример #3
0
        private void UpdateSelectedSize()
        {
            var dataSource = dgvFolders.DataSource as BindingSource;
            var list       = dataSource.DataSource as BindingList <FolderInfo>;

            SelectedSize         = list.Where(item => item.IsSelected).Sum(item => item.TotalSize);
            lblSelectedSize.Text = Readable.FileSize(SelectedSize);
        }
Пример #4
0
        private async Task AnalyzeFolderAsync(
            ProgressLinkLabel linkLabel, int monthsOld,
            Func <FileSystemUtil, Task <IEnumerable <FolderInfo> > > getFolders,
            Action <IEnumerable <FolderInfo> > captureResults)
        {
            var fsu     = new FileSystemUtil();
            var folders = await getFolders.Invoke(fsu);

            var deletable = folders.Where(folder => folder.IsMonthsOld(monthsOld));

            captureResults.Invoke(deletable);
            long deleteableBytes = deletable.Sum(item => item.TotalSize);

            linkLabel.Mode = ProgressLinkLabelMode.Text;
            linkLabel.Text = Readable.FileSize(deleteableBytes);
        }
Пример #5
0
        private void ShowFolderList(LinkLabel control, IEnumerable <FolderInfo> folders)
        {
            var dlg = new frmFolderList()
            {
                Position = _settings.FolderListPosition
            };

            dlg.Folders = folders;
            dlg.ShowDialog();
            _settings.FolderListPosition = dlg.Position;

            control.Text = (dlg.SelectedSize != 0) ?
                           $"{Readable.FileSize(folders.Sum(item => item.TotalSize))}, {Readable.FileSize(dlg.SelectedSize)} selected" :
                           Readable.FileSize(folders.Sum(item => item.TotalSize));

            UpdateDeleteButtonText();
        }