Soyez le premier à donner votre avis sur cette source.
Snippet vu 10 323 fois - Téléchargée 37 fois
' ------ Page xxx.ASCX ------------ <%@ Control Language="vb" AutoEventWireup="false" Codebehind="xxx.ascx.vb" Inherits="MonProjet.DisquesControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie3-2nav3-0" %> <table class="box"> <tr class="boxheader"> <td class="boxheader">Systèmes de fichiers du Serveur</td> </tr> <tr class="boxbody"> <td><table width="100%" id="TableauDisque" align="center" runat="server"> <tr> <td align="left" valign="top"><font size="-1"><b>Lettre</b></font></td> <td align="left" valign="top"><font size="-1"><b>Chemin</b></font></td> <td align="left" valign="top"><font size="-1"><b>Type</b></font></td> <td align="left" valign="top"><font size="-1"><b>Utilisation</b></font></td> <td align="right" valign="top"><font size="-1"><b>Libre</b></font></td> <td align="right" valign="top"><font size="-1"><b>Utililisé</b></font></td> <td align="right" valign="top"><font size="-1"><b>Taille</b></font></td> </tr> </table> </td> </tr> </table> ' ---------------------------------------- ' ------ Page xxx.ASCX.VB ------------ Imports System.Web.UI.HtmlControls Public MustInherit Class DisquesControl Inherits System.Web.UI.UserControl Protected WithEvents TableauDisque As System.Web.UI.HtmlControls.HtmlTable #Region " Code généré par le Concepteur Web Form " 'Cet appel est requis par le Concepteur Web Form. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form 'Ne le modifiez pas en utilisant l'éditeur de code. InitializeComponent() End Sub #End Region ' ----------------------------------------------------- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim fso = Server.CreateObject("Scripting.FileSystemObject") Dim drives = fso.Drives Dim Drive Dim isReady Dim TotalDisqueLibre As Double = 0 Dim TotalDisque As Double = 0 For Each Drive In drives Dim MaLigne As New HtmlControls.HtmlTableRow() isReady = Drive.IsReady If isReady Then Dim Prop As Integer = CalculProportion(Drive.FreeSpace, Drive.TotalSize) TotalDisque += Drive.TotalSize TotalDisqueLibre += Drive.FreeSpace AddCell(MaLigne, Drive.DriveLetter, "left") AddCell(MaLigne, "[" & Drive.Path & "] (" & Drive.VolumeName & ")", "left") AddCell(MaLigne, Drive.FileSystem, "left") AddCell(MaLigne, RenvoiCodeImage(Prop), "left") AddCell(MaLigne, Fonctions.AfficheTaille(Drive.FreeSpace, "o"), "right") AddCell(MaLigne, Fonctions.AfficheTaille((Drive.TotalSize - Drive.FreeSpace), "o"), "right") AddCell(MaLigne, Fonctions.AfficheTaille(Drive.TotalSize, "o"), "right") Else AddCell(MaLigne, Drive.DriveLetter, "left") AddCell(MaLigne, "[" & Drive.Path & "]", "left") AddCell(MaLigne, "", "left") AddCell(MaLigne, "<i>Pas d'informations disponibles pour ce Lecteur</i>", "left", 4) End If TableauDisque.Rows.Add(MaLigne) Next Dim PropTotal As Integer = CalculProportion(TotalDisqueLibre, TotalDisque) Dim MaLigneTotal As New HtmlControls.HtmlTableRow() AddCell(MaLigneTotal, "<i>Totaux : </i>", "right", 3) AddCell(MaLigneTotal, RenvoiCodeImage(PropTotal), "left") AddCell(MaLigneTotal, Fonctions.AfficheTaille(TotalDisqueLibre, "o"), "right") AddCell(MaLigneTotal, Fonctions.AfficheTaille((TotalDisque - TotalDisqueLibre), "o"), "right") AddCell(MaLigneTotal, Fonctions.AfficheTaille(TotalDisque, "o"), "right") TableauDisque.Rows.Add(MaLigneTotal) End Sub ' ----------------------------------------------------- Private Sub AddCell(ByVal tr As HtmlTableRow, ByVal sM As String, ByVal Alignement As String, Optional ByVal ColSpan As Integer = 0) 'Ajoute une cellule dans la ligne du tableau Dim td As New HtmlTableCell() td.Align = Alignement td.VAlign = "top" If ColSpan > 0 Then td.ColSpan = ColSpan End If td.InnerHtml = "<font size='-1'>" & sM & "</font>" tr.Cells.Add(td) End Sub ' ----------------------------------------------------- Private Function CalculProportion(ByVal TailleLibre As Double, ByVal TailleTotale As Double) As Integer Return Int(((TailleTotale - TailleLibre) / TailleTotale) * 100) End Function ' ----------------------------------------------------- Private Function RenvoiCodeImage(ByVal Taille As Integer) As String Dim couleur As String = "" Dim Retour As String = "" If Taille > 95 Then couleur = "red" Retour = "<img height='10' src='./images/" & couleur & "bar_left.gif'>" Retour &= "<img src='./images/" & couleur & "bar_middle.gif' height='10' width='" Retour &= (Taille * 2) & "'><img height='10' src='./images/" & couleur & "bar_right.gif'> " & Taille & "%" Return Retour End Function ' ----------------------------------------------------- End Class ' -----------------------------------------------------
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.