Ejemplo n.º 1
0
        /// <summary>
        /// Populates the list of USB drives for the drop down.
        /// </summary>
        private void PopulateUsbDrives()
        {
            if (this.driveService == null)
            {
                throw new InvalidOperationException("Media type must be selected first.");
            }

            var driveOptions = new List<KeyValuePair<string, string>>();

            // Enumerate drives and format their labels.
            foreach (var drive in this.driveService.Drives)
            {
                string format = !drive.IsReady
                                    ? GetDriveLabel(drive)
                                    : String.Format(
                                          CultureInfo.CurrentUICulture,
                                          Properties.Resources.UsbDriveFormat,
                                          GetDriveLabel(drive),
                                          FormatFreeSpace(drive.TotalFreeSpace));

                driveOptions.Add(new KeyValuePair<string, string>(drive.Name, format));
            }

            // If no drives, display default option.
            if (driveOptions.Count <= 0)
            {
                driveOptions.Add(new KeyValuePair<string, string>(String.Empty, Properties.Resources.UsbNoDrivesDropDown));
            }

            this.view.UsbDrives = driveOptions.AsReadOnly();
        }