Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Form1
Private SceltaFatta As Boolean
Private Ampiezza As Double
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DInfo As IO.DriveInfo()
DInfo = IO.DriveInfo.GetDrives()
cmbDrives.Items.AddRange(DInfo)
cmbDrives.SelectedIndex = 0
lblNumeroVolumi.Text = "Dispositivi totali trovati = " & DInfo.Length
End Sub
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim Pen As New Pen(Color.FromArgb(50, 135, 227), 7)
Dim Rect1 As New Rectangle(368, 56, 280, 288)
Dim Sfumatura As New LinearGradientBrush(Rect1, Color.FromArgb(90, 150, 250), Color.FromArgb(140, 240, 235), LinearGradientMode.BackwardDiagonal)
e.Graphics.DrawRectangle(Pen, Rect1)
e.Graphics.FillRectangle(Sfumatura, Rect1)
Dim Rect2 As Rectangle = New Rectangle(410, 66, 200, 200)
If SceltaFatta = True Then
e.Graphics.FillPie(Brushes.Gold, Rect2, Ampiezza, 360 - Ampiezza)
e.Graphics.FillPie(Brushes.GreenYellow, Rect2, 0, Ampiezza)
Dim SpazioLibero As Rectangle = New Rectangle(376, 280, 25, 25)
Dim SpazioUsato As Rectangle = New Rectangle(376, 310, 25, 25)
e.Graphics.FillRectangle(Brushes.GreenYellow, SpazioLibero)
e.Graphics.FillRectangle(Brushes.Gold, SpazioUsato)
e.Graphics.DrawString("Spazio libero:", New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(402, 283))
e.Graphics.DrawString(txtSpazioLibero.Text, New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(480, 283))
e.Graphics.DrawString("Spazio usato:", New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(402, 313))
e.Graphics.DrawString(txtSpazioUsato.Text, New Font("Microsoft Sans Serif", 9, FontStyle.Regular), Brushes.Blue, New PointF(480, 313))
End If
End Sub
Private Sub cmbDrives_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbDrives.SelectedIndexChanged
Try
SceltaFatta = True
grpInfo.Text = "Informazioni su Volume " & (cmbDrives.Items(cmbDrives.SelectedIndex).ToString())
Info(cmbDrives.Items(cmbDrives.SelectedIndex).ToString())
Me.Invalidate()
Catch ex As Exception
cmbDrives.SelectedIndex = 0
MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub Info(ByVal NomeDrive As String)
Dim DInfo As New IO.DriveInfo(NomeDrive.ToString())
txtNome.Text = DInfo.Name.ToString()
txtEtichettaVolume.Text = DInfo.VolumeLabel.ToString()
Select Case DInfo.DriveType.ToString()
Case "Fixed"
txtTipologiaDrive.Text = "Fisso"
Case "Removable"
txtTipologiaDrive.Text = "Rimovibile"
Case "CDRom"
txtTipologiaDrive.Text = "CD"
End Select
txtDirectoryRadice.Text = DInfo.RootDirectory.ToString()
txtFileSystem.Text = DInfo.DriveFormat.ToString()
txtDimensioniTotali.Text = (DInfo.TotalSize / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
txtSpazioLibero.Text = (DInfo.TotalFreeSpace / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
txtSpazioUsato.Text = ((DInfo.TotalSize - DInfo.TotalFreeSpace) / (1024 * 1024 * 1024)).ToString("#,##0.00") & " GB"
Ampiezza = 360 * DInfo.TotalFreeSpace / DInfo.TotalSize
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
AboutBox1.ShowDialog()
End Sub
End Class