private void ShowDriveData(DriveInfo drive)
        {
            DriveData driveData = new DriveData(drive);

            txtSize.Text = driveData.LongSize;
            txtLabel.Text = driveData.VolumeLabel;

            try
            {
                pbSize.Maximum = driveData.MaximumSize;

                pbSize.Value = driveData.MaximumSize -
                    driveData.AvailableFreeSpace;
            }
            catch (Exception)
            {

            }

            imgDriveType.Source = driveData.DriveIcon;

            //if (drive.IsReady)
            //{
            //    string totalShort = SizeFileInString.GetSizeInStr(drive.TotalSize);
            //    string totalLong = drive.TotalSize.ToString();

            //    string availableShort = SizeFileInString.GetSizeInStr(drive.AvailableFreeSpace);
            //    string availableLong = drive.AvailableFreeSpace.ToString();

            //    txtSize.Text = string.Format("(Free: {0} from {1} ({2} from {3}))", availableShort, totalShort, availableLong, totalLong);

            //    txtLabel.Text = drive.VolumeLabel;

            //    pbSize.Maximum = drive.TotalSize;

            //    try
            //    {
            //        pbSize.Value = drive.TotalSize - drive.AvailableFreeSpace;
            //    }
            //    catch (Exception)
            //    {

            //    }

            //}
            //else
            //{

            //}

            //switch (drive.DriveType)
            //{
            //    case DriveType.CDRom:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_cdrom.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Fixed:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_fixed.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Network:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_network.ico", UriKind.Relative));
            //        break;
            //    case DriveType.NoRootDirectory:
            //        break;
            //    case DriveType.Ram:
            //        break;
            //    case DriveType.Removable:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_removable.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Unknown:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_unknown.ico", UriKind.Relative));
            //        break;
            //    default:
            //        break;
            //}
        }
Exemple #2
0
        /// <summary>
        /// Заполняем элементы управления данными
        /// </summary>
        private void ShowDriveData()
        {
            DriveData driveData = new DriveData(drive);

            txtSize.Text = driveData.LongSize;

            try
            {
                pbSize.Maximum = driveData.MaximumSize;
                pbSize.Value = driveData.MaximumSize -
                    driveData.AvailableFreeSpace;
            }
            catch (Exception)
            {
                //pbSize.MaxWidth = 300;
            }

            imgDriveType.Source = driveData.DriveIcon;

            //txtInfo.Text = string.Format("name:{0} type:{1}",
            //    drive.Name[0].ToString(), drive.DriveType);
            txtDriveLabel.Text = driveData.VolumeLabel;
            txtDriveName.Text = driveData.Drive.Name[0].ToString();
            txtDriveType.Text = driveData.Drive.DriveType.ToString();

            if (!driveData.Drive.IsReady)
            {
                //txtSize.Text = Properties.Resources.TheDriveIsNotReady;
                txtSize.Text = LanguagesManager.GetCurrLanguage().DDDriveIsNotReady;
            }

            //if (drive.IsReady)
            //{
            //    string totalShort = SizeFileInString.GetSizeInStr(drive.TotalSize);
            //    string totalLong = drive.TotalSize.ToString();

            //    string availableShort = SizeFileInString.GetSizeInStr(drive.AvailableFreeSpace);
            //    string availableLong = drive.AvailableFreeSpace.ToString();

            //    txtSize.Text = string.Format("Free: {0} from {1} ({2} from {3})", availableShort, totalShort, availableLong, totalLong);

            //    pbSize.Maximum = drive.TotalSize;

            //    try
            //    {
            //        pbSize.Value = drive.TotalSize - drive.AvailableFreeSpace;
            //    }
            //    catch (Exception)
            //    {

            //    }

            //    txtInfo.Text = string.Format("name:{0} label:{1} type:{2}",
            //        drive.Name[0].ToString(), drive.VolumeLabel, drive.DriveType);

            //}
            //else
            //{
            //    txtInfo.Text = string.Format("name:{0} type:{1}",
            //        drive.Name[0].ToString(), drive.DriveType);
            //    txtSize.Text = "The drive is not read";
            //}

            //switch (drive.DriveType)
            //{
            //    case DriveType.CDRom:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_cdrom.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Fixed:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_fixed.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Network:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_network.ico", UriKind.Relative));
            //        break;
            //    case DriveType.NoRootDirectory:
            //        break;
            //    case DriveType.Ram:
            //        break;
            //    case DriveType.Removable:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_removable.ico", UriKind.Relative));
            //        break;
            //    case DriveType.Unknown:
            //        imgDriveType.Source = new BitmapImage(new Uri("/Icons/drive_unknown.ico", UriKind.Relative));
            //        break;
            //    default:
            //        break;
            //}
        }