Drive.cs

Description du code

Drive.cs est un fichier du projet BrolExplorer.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/brolexplorer/.

Projet BrolExplorer :

Explorateur de media en CSharp.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5. using be.gaudry.model.enums;
  6. using be.gaudry.model;
  7. using System.IO;
  8. using be.gaudry.model.drawing;
  9.  
  10. namespace be.gaudry.explorer.model
  11. {
  12. public class Drive
  13. {
  14. [DllImport("kernel32.dll")]
  15. public static extern long GetDriveType(string driveLetter);
  16. /*[DllImport("kernel32.dll")]
  17.   public static extern long GetVolumeInformation(
  18.   string strPathName,
  19.   StringBuilder strVolumeNameBuffer,
  20.   long lngVolumeNameSize,
  21.   long lngVolumeSerialNumber,
  22.   long lngMaximumComponentLength,
  23.   long lngFileSystemFlags,
  24.   StringBuilder strFileSystemNameBuffer,
  25.   long lngFileSystemNameSize
  26.   );*/
  27.  
  28. /// <summary>
  29. /// Deprecated : use "internal static SHELL32_ICON getDriveIcon(System.IO.DriveInfo di)" instead
  30. /// </summary>
  31. /// <param name="drive"></param>
  32. /// <returns></returns>
  33. public static SHELL32_ICON getDriveType(string drive)
  34. {
  35. long driveType = GetDriveType(drive);
  36. switch (driveType)
  37. {
  38. case 8976214553213796355: return SHELL32_ICON.drive_HD;
  39. case 8976214553213796357: return SHELL32_ICON.drive_cd;
  40. //case 8976214553213796357: return SYSTEM_ICON.drive_removable;
  41. case 8976214553213796354: return SHELL32_ICON.drive_floppy;
  42. //case 8976214553213796357: return SYSTEM_ICON.drive_remoteDisk;
  43. //case 8976214553213796357: return SYSTEM_ICON.drivr_ramDisk;
  44. }
  45. //if ((driveType & 3) == 3) return SYSTEM_ICON.drive_HD;
  46. //if ((driveType & 5) == 5) return SYSTEM_ICON.drive_cd;
  47. if ((driveType & 2) == 2) return SHELL32_ICON.drive_removable;
  48. if ((driveType & 4) == 4) return SHELL32_ICON.drive_remoteDisk;
  49. if ((driveType & 6) == 6) return SHELL32_ICON.drive_ramDisk;
  50. return SHELL32_ICON.drive_HD;
  51. }
  52.  
  53.  
  54. internal static SHELL32_ICON getDriveIcon(System.IO.DriveInfo di)
  55. {
  56. switch (di.DriveType)
  57. {
  58. case System.IO.DriveType.CDRom: return SHELL32_ICON.drive_cd;
  59. case System.IO.DriveType.Fixed: return SHELL32_ICON.drive_HD;
  60. case System.IO.DriveType.Network: return SHELL32_ICON.drive_remoteDisk;
  61. case System.IO.DriveType.Removable: return SHELL32_ICON.drive_removable;
  62. case System.IO.DriveType.NoRootDirectory: return SHELL32_ICON.folderClosed;
  63. case System.IO.DriveType.Ram: return SHELL32_ICON.drive_ramDisk;
  64. case System.IO.DriveType.Unknown: return SHELL32_ICON.drive_HD;
  65.  
  66. }
  67. return SHELL32_ICON.drive_HD;
  68. }
  69.  
  70. public class DriveInfoHelper
  71. {
  72. private string text, toolTipText;
  73. private SHELL32_ICON iconType;
  74. private DriveInfo driveInfo;
  75.  
  76. public DriveInfoHelper(string driveName) : this(new DriveInfo(driveName)) { }
  77. public DriveInfoHelper(System.IO.DriveInfo drive)
  78. {
  79. driveInfo = drive;
  80. try
  81. {
  82. if (drive.IsReady)
  83. {
  84. toolTipText = string.Format("{0} pour {1} ({2}% d'espace libre)",
  85. Units.getLengthString(drive.TotalSize),
  86. drive.VolumeLabel.Equals(string.Empty) ? drive.Name : drive.VolumeLabel,
  87. Convert.ToInt16(((Double)drive.AvailableFreeSpace / drive.TotalSize) * 100)
  88. );
  89. text = string.Format(
  90. "{0} ({1})",
  91. drive.VolumeLabel.Equals(string.Empty) ? drive.Name : drive.VolumeLabel,
  92. drive.Name.Remove(1)
  93. );
  94. }
  95. else
  96. {
  97. toolTipText = string.Format("{0} non disponible.",
  98. drive.Name
  99. );
  100. text = drive.Name;
  101. }
  102. switch (drive.DriveType)
  103. {
  104. case System.IO.DriveType.CDRom:
  105.  
  106. if (drive.IsReady)
  107. {
  108. iconType = SHELL32_ICON.disc;
  109. }
  110. else
  111. {
  112. iconType = SHELL32_ICON.drive_cd;
  113. }
  114. break;
  115.  
  116. case System.IO.DriveType.Fixed:
  117. iconType = SHELL32_ICON.drive_HD;
  118. break;
  119.  
  120. case System.IO.DriveType.Network:
  121. iconType = SHELL32_ICON.drive_remoteDisk;
  122. break;
  123.  
  124. case System.IO.DriveType.Removable:
  125. iconType = SHELL32_ICON.drive_removable;
  126. break;
  127.  
  128. case System.IO.DriveType.NoRootDirectory:
  129. iconType = SHELL32_ICON.folderClosed;
  130. break;
  131.  
  132. case System.IO.DriveType.Ram:
  133. iconType = SHELL32_ICON.drive_ramDisk;
  134. break;
  135.  
  136. case System.IO.DriveType.Unknown:
  137. iconType = SHELL32_ICON.drive_HD;
  138. break;
  139.  
  140. default:
  141. iconType = SHELL32_ICON.drive_HD;
  142. break;
  143. }
  144. }
  145. catch (IOException e)
  146. {
  147. toolTipText = e.Message;
  148. }
  149. }
  150.  
  151. public string Text
  152. {
  153. get { return text; }
  154. }
  155. public string ToolTipText
  156. {
  157. get { return toolTipText; }
  158. }
  159. public SHELL32_ICON IconType
  160. {
  161. get { return iconType; }
  162. }
  163. public System.Drawing.Image Icon
  164. {
  165. get { return IconExtractor.getShell32Bitmap(iconType); }
  166. }
  167. public DriveInfo DriveInfo
  168. {
  169. get { return driveInfo; }
  170. }
  171. }
  172. }
  173. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/brolexplorer/model/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1734903567 22/12/2024 22:39:27
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/brolexplorer/model/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csDrive.cs6.66 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csDirectoryTreeNode.cs2.79 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csMediaBrowser.cs13.11 Ko31/10/2018 18:32:21-refusé-
Afficher le fichier .cs|.csMediaParser.cs5.71 Ko31/10/2018 18:32:21-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/10/2009, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/cs-brolexplorer-source-rf-model//Drive.cs.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.