Explore10.StartPage.FillDrives C# (CSharp) Method

FillDrives() public method

public FillDrives ( ) : void
return void
        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);
            }
        }

Usage Example

Ejemplo n.º 1
0
        private void GoHome(object sender, RoutedEventArgs e)
        {
            Places.IsOpen = false;
            StartPage page = new StartPage();

            page.FillDrives();
            TabItem tab = (TabItem)tabDynamic.SelectedItem;

            tab.Header  = "This PC";
            tab.Content = page;
        }
All Usage Examples Of Explore10.StartPage::FillDrives