Пример #1
0
 public void FillDrives()
 {
     foreach (var di in System.IO.DriveInfo.GetDrives())
     {
         if (!di.IsReady) continue;
         var hPanel = new StackPanel {Orientation = Orientation.Horizontal};
         var vPanel = new StackPanel {Orientation = Orientation.Vertical};
         var label = new TextBlock
         {
             Text = (string.IsNullOrWhiteSpace(di.VolumeLabel) || string.IsNullOrEmpty(di.VolumeLabel) ? "Local Disk " + di.Name : di.VolumeLabel),
             FontSize = 22
         };
         //quick hack TODO: add images?
         Debug.WriteLine(di.VolumeLabel  + " - " + di.Name.Length);
         var name = new TextBlock
         {
             Text = di.Name,
             FontSize = 40,
             Width = 60,
             Margin = new Thickness {Right = 10},
             Name = "Path"
         };
         hPanel.Children.Add(name);
         var space = new TextBlock
         {
             Text = $"{Helpers.PrettyByte(di.AvailableFreeSpace)} free of {Helpers.PrettyByte(di.TotalSize)}"
         };
         var driveFilled = new ProgressBar
         {
             Minimum = 0,
             Maximum = di.TotalSize,
             Value = (di.TotalSize - di.AvailableFreeSpace),
             Height = 8,
             Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x91, 0xDD))
         };
         var convertFromString = ColorConverter.ConvertFromString("White");
         if (convertFromString != null)
             driveFilled.Background = new SolidColorBrush((Color) convertFromString);
                 //it really shouldn't be this hard
         vPanel.Children.Add(label);
         vPanel.Children.Add(driveFilled);
         vPanel.Children.Add(space);
         hPanel.Children.Add(vPanel);
         hPanel.VerticalAlignment = VerticalAlignment.Stretch;
         //hPanel.Width = 200;
         hPanel.Height = 50;
         hPanel.AddHandler(MouseDownEvent, new MouseButtonEventHandler(OpenDrive));
         hPanel.Margin = new Thickness(10);
         Drives.Items.Add(hPanel);
     }
 }
Пример #2
0
 public void FillDrives()
 {
     foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives())
     {
         if (di.IsReady)
         {
             StackPanel hPanel = new StackPanel();
             hPanel.Orientation = Orientation.Horizontal;
             StackPanel vPanel = new StackPanel();
             vPanel.Orientation = Orientation.Vertical;
             TextBlock Label = new TextBlock();
             Label.Text = di.VolumeLabel;
             Label.FontSize = 22; //quick hack TODO: add images?
             TextBlock Name = new TextBlock();
             Name.Text = di.Name;
             Name.FontSize = 40;
             Name.Width = 60;
             Name.Margin = new Thickness { Right = 10 };
             Name.Name = "Path";
             hPanel.Children.Add(Name);
             TextBlock Space = new TextBlock();
             Space.Text = string.Format("{0} free of {1}", PrettyByte(di.AvailableFreeSpace), PrettyByte(di.TotalSize));
             ProgressBar DriveFilled = new ProgressBar();
             DriveFilled.Minimum = 0;
             DriveFilled.Maximum = di.TotalSize;
             DriveFilled.Value = (di.TotalSize - di.AvailableFreeSpace);
             DriveFilled.Height = 8;
             DriveFilled.Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x30, 0x91, 0xDD));
             DriveFilled.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("White")); //it really shouldn't be this hard
             vPanel.Children.Add(Label);
             vPanel.Children.Add(DriveFilled);
             vPanel.Children.Add(Space);
             hPanel.Children.Add(vPanel);
             hPanel.Width = 200;
             hPanel.Height = 50;
             hPanel.AddHandler(StackPanel.MouseDownEvent, new MouseButtonEventHandler(OpenDrive));
             hPanel.Margin = new Thickness(10);
             Drives.Items.Add(hPanel);
         }
     }
 }