Exemplo n.º 1
0
        private async void SetDrive(object sender, RoutedEventArgs e)
        {
            var info = (DriveInfo)((Button)(sender)).DataContext;

            _scanner = new DriveScanner();

            Progress.Text = "0";

            Ready.Visibility       = Visibility.Hidden;
            Processing.Visibility  = Visibility.Visible;
            ItemsControl.IsEnabled = false;

            _refresher.Start();

            await Task.Run(() =>
            {
                App.Current.Context.StatisticsRoot = _scanner.ScanDrive(info.Name.Substring(0, 2));
                App.Current.Context.Problematic.Clear();
                App.Current.Context.Problematic.AddRange(_scanner.Inaccessible);
            });

            _refresher.Stop();

            ItemsControl.IsEnabled = true;
            Processing.Visibility  = Visibility.Hidden;
            Ready.Visibility       = Visibility.Visible;
        }
Exemplo n.º 2
0
        private async void LoadDrive(ToolStripItem sender)
        {
            var target = sender.Text.Substring(0, 2);

            _scanner = new DriveScanner();

            toolStrip1.Enabled = false;
            timer1.Start();

            var root = await Task.Run(() => _scanner.ScanDrive(target));

            listBox1.Items.Clear();
            listBox1.Items.AddRange(_scanner.Inaccessible.Cast <object>().ToArray());

            _totals.Clear();

            chart1.BeginInit();
            chart1.ChartAreas.Clear();
            chart1.Series.Clear();

            label2.Text = Humanize.Size(root.Items[1].Size);

            var percent = 0.0025f * toolStripComboBox2.SelectedIndex;

            if (toolStripComboBox1.SelectedIndex == 1)
            {
                root.Items.RemoveRange(0, 2);
                _filterThreshold = _scanner.GetDisplayThreshold(percent, false);
            }
            else
            {
                _filterThreshold = _scanner.GetDisplayThreshold(percent, true);
            }
            LoadChartDataCollection(0, root, 0);
            AlignDoughnuts();
            chart1.EndInit();

            timer1.Stop();
            toolStripProgressBar1.Value = 0;
            toolStripLabel2.Text        = string.Empty;
            toolStrip1.Enabled          = true;
        }