Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Drive Info Graphic - Form1.vb

Form1.vb

Caricato da: Progman-92
Scarica il programma completo

  1. Imports System.IO
  2. Imports System.Drawing
  3. Imports System.Drawing.Drawing2D
  4.  
  5. Public Class Form1
  6.  
  7.     Private SceltaFatta As Boolean
  8.     Private Ampiezza As Double
  9.  
  10.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  11.         Dim DInfo As IO.DriveInfo()
  12.         DInfo = IO.DriveInfo.GetDrives()
  13.         cmbDrives.Items.AddRange(DInfo)
  14.         cmbDrives.SelectedIndex = 0
  15.         lblNumeroVolumi.Text = "Dispositivi totali trovati = " & DInfo.Length
  16.     End Sub
  17.  
  18.     Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
  19.         Dim Pen As New Pen(Color.FromArgb(50, 135, 227), 7)
  20.         Dim Rect1 As New Rectangle(368, 56, 280, 288)
  21.         Dim Sfumatura As New LinearGradientBrush(Rect1, Color.FromArgb(90, 150, 250), Color.FromArgb(140, 240, 235), LinearGradientMode.BackwardDiagonal)
  22.         e.Graphics.DrawRectangle(Pen, Rect1)
  23.         e.Graphics.FillRectangle(Sfumatura, Rect1)
  24.         Dim Rect2 As Rectangle = New Rectangle(410, 66, 200, 200)
  25.         If SceltaFatta = True Then
  26.             e.Graphics.FillPie(Brushes.Gold, Rect2, Ampiezza, 360 - Ampiezza)
  27.             e.Graphics.FillPie(Brushes.GreenYellow, Rect2, 0, Ampiezza)
  28.             Dim SpazioLibero As Rectangle = New Rectangle(376, 280, 25, 25)
  29.             Dim SpazioUsato As Rectangle = New Rectangle(376, 310, 25, 25)
  30.             e.Graphics.FillRectangle(Brushes.GreenYellow, SpazioLibero)
  31.             e.Graphics.FillRectangle(Brushes.Gold, SpazioUsato)
  32.             e.Graphics.DrawString("Spazio libero:", New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(402, 283))
  33.             e.Graphics.DrawString(txtSpazioLibero.Text, New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(480, 283))
  34.             e.Graphics.DrawString("Spazio usato:", New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(402, 313))
  35.             e.Graphics.DrawString(txtSpazioUsato.Text, New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(480, 313))
  36.         End If
  37.     End Sub
  38.  
  39.     Private Sub cmbDrives_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDrives.SelectedIndexChanged
  40.         Try
  41.             SceltaFatta = True
  42.             grpInfo.Text = "Informazioni su Volume " & (cmbDrives.Items(cmbDrives.SelectedIndex).ToString())
  43.             Info(cmbDrives.Items(cmbDrives.SelectedIndex).ToString())
  44.             Me.Invalidate()
  45.         Catch ex As Exception
  46.             cmbDrives.SelectedIndex = 0
  47.             MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
  48.         End Try
  49.     End Sub
  50.  
  51.     Private Sub Info(ByVal NomeDrive As String)
  52.         Dim DInfo As New IO.DriveInfo(NomeDrive.ToString())
  53.         txtNome.Text = DInfo.Name.ToString()
  54.         txtEtichettaVolume.Text = DInfo.VolumeLabel.ToString()
  55.         Select Case DInfo.DriveType.ToString()
  56.             Case "Fixed"
  57.                 txtTipologiaDrive.Text = "Fisso"
  58.             Case "Removable"
  59.                 txtTipologiaDrive.Text = "Rimovibile"
  60.             Case "CDRom"
  61.                 txtTipologiaDrive.Text = "CD"
  62.         End Select
  63.         txtDirectoryRadice.Text = DInfo.RootDirectory.ToString()
  64.         txtFileSystem.Text = DInfo.DriveFormat.ToString()
  65.         txtDimensioniTotali.Text = (DInfo.TotalSize / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
  66.         txtSpazioLibero.Text = (DInfo.TotalFreeSpace / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
  67.         txtSpazioUsato.Text = ((DInfo.TotalSize - DInfo.TotalFreeSpace) / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
  68.         Ampiezza = 360 * DInfo.TotalFreeSpace / DInfo.TotalSize
  69.     End Sub
  70.  
  71.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  72.         AboutBox1.ShowDialog()
  73.     End Sub
  74. End Class