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 = di.VolumeLabel,
FontSize = 22
};
var name = new TextBlock
{
Text = di.Name,
FontSize = 40,
Margin = new Thickness {Right = 10},
Name = "Path"
};
hPanel.Children.Add(name);
var space = new TextBlock
{
MinWidth = 200,
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.Width = 250;
hPanel.Height = 50;
hPanel.AddHandler(StackPanel.MouseDownEvent, new MouseButtonEventHandler(OpenDrive));
hPanel.Margin = new Thickness(10);
Drives.Items.Add(hPanel);
}
}