예제 #1
0
        internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string message)
        {
            var ready     = false;
            var usbDrives = usbDriveLocator.UsbDrives.ToList();

            if (usbDrives.Count == 0)
            {
                message = "First insert a USB flash drive.";
            }
            else if (usbDrives.Count > 1)
            {
                message = "More than one USB drive detected. Please remove one.";
            }
            else
            {
                try
                {
                    var first = usbDrives[0];
#if !MONO
                    message = first.RootDirectory + " " + first.VolumeLabel + " (" +
                              Math.Floor(first.TotalFreeSpace / 1024000.0) + " Megs Free Space)";
#else
                    message = first.VolumeLabel;
                    //RootDir & volume label are the same on linux.  TotalFreeSpace is, like, maxint or something in mono 2.0
#endif
                    ready = true;
                }
                catch (Exception error)
                {
                    message = error.Message;
                    ready   = false;
                }
            }
            return(ready);
        }
예제 #2
0
        internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string message)
        {
            var ready     = false;
            var usbDrives = usbDriveLocator.UsbDrives.ToList();

            if (usbDrives.Count == 0)
            {
                message = LocalizationManager.GetString("GetUsbStatus.InsertAUsbFlashDrive", "First insert a USB flash drive.");
            }
            else if (usbDrives.Count > 1)
            {
                message = LocalizationManager.GetString("GetUsbStatus.MoreThanOneDrive", "More than one USB drive detected. Please remove one.");
            }
            else
            {
                try
                {
                    var first = usbDrives[0];
                    if (!Platform.IsMono)
                    {
                        message = string.Format(LocalizationManager.GetString(
                                                    "GetUsbStatus.DriveInfoAndFreeSpace",
                                                    "{0} {1} ({2} Megs Free Space)",
                                                    "{x} tags are replaced as follows: <root directory of the USB drive> <drive label> (<number> Megs Free Space), "
                                                    + "for example: F:\\ MyDrive (640 Megs Free Space)"),
                                                first.RootDirectory, first.VolumeLabel,
                                                Math.Floor(first.TotalFreeSpace / 1048576.0));
                    }
                    else
                    {
                        message = first.VolumeLabel;
                        //RootDir & volume label are the same on linux.  TotalFreeSpace is, like, maxint or something in mono 2.0
                    }

                    ready = true;
                }
                catch (Exception error)
                {
                    message = error.Message;
                    ready   = false;
                }
            }
            return(ready);
        }
예제 #3
0
 internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string message)
 {
     var ready = false;
     var usbDrives = usbDriveLocator.UsbDrives.ToList();
     if (usbDrives.Count == 0)
     {
         message = LocalizationManager.GetString("GetUsbStatus.InsertAUsbFlashDrive", "First insert a USB flash drive.");
     }
     else if (usbDrives.Count > 1)
     {
         message = LocalizationManager.GetString("GetUsbStatus.MoreThanOneDrive", "More than one USB drive detected. Please remove one.");
     }
     else
     {
         try
         {
             var first = usbDrives[0];
     #if !MONO
             message = string.Format(LocalizationManager.GetString("GetUsbStatus.DriveInfoAndFreeSpace", "{0} {1} ({2} Megs Free Space)",
                     "{x} tags are replaced as follows: <root directory of the USB drive> <drive label> (<number> Megs Free Space), "
                     + "for example: F:\\ MyDrive (640 Megs Free Space)"),
                 first.RootDirectory, first.VolumeLabel, Math.Floor(first.TotalFreeSpace / 1048576.0));
     #else
             message = first.VolumeLabel;
             //RootDir & volume label are the same on linux.  TotalFreeSpace is, like, maxint or something in mono 2.0
     #endif
             ready = true;
         }
         catch (Exception error)
         {
             message = error.Message;
             ready = false;
         }
     }
     return ready;
 }
예제 #4
0
 internal bool GetUsbStatusLink(IUsbDriveLocator usbDriveLocator, out string message)
 {
     var ready = false;
     if (!usbDriveLocator.UsbDrives.Any())
     {
         message = "First insert a USB flash drive.";
     }
     else if (usbDriveLocator.UsbDrives.Count() > 1)
     {
         message = "More than one USB drive detected. Please remove one.";
     }
     else
     {
         try
         {
             var first = usbDriveLocator.UsbDrives.First();
     #if !MONO
             message = first.RootDirectory + " " + first.VolumeLabel + " (" +
                                    Math.Floor(first.TotalFreeSpace / 1024000.0) + " Megs Free Space)";
     #else
             message = first.VolumeLabel;
             //RootDir & volume label are the same on linux.  TotalFreeSpace is, like, maxint or something in mono 2.0
     #endif
             ready = true;
         }
         catch (Exception error)
         {
             message = error.Message;
             ready = false;
         }
     }
     return ready;
 }