using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.IO;
namespace EstadoDiscos
{
public partial class Estado_Discos : Form
{
private long Total = 0;
private long usado = 0;
private long libre = 0;
private float dibujo;
private int angulo = 360;
private Rectangle recto;
LinearGradientBrush Rojo;
LinearGradientBrush Azul;
public Estado_Discos()
{
InitializeComponent();
}
private void dibujar_Paint(object sender, PaintEventArgs e)
{
recto = new Rectangle(1, 1, grafico.Width - 5, grafico.Height - 5);
Rojo = new LinearGradientBrush(recto, Color.FromArgb(255, 5, 5), Color.FromArgb(255, 135, 135), 2000);
Azul = new LinearGradientBrush(recto, Color.FromArgb(40, 22, 203), Color.FromArgb(111, 183, 215), 2000);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
if (dibujo != 0)
{
e.Graphics.FillPie(Azul, recto, 0, dibujo);
e.Graphics.FillPie(Rojo, recto, dibujo, angulo - dibujo);
}
else
{
e.Graphics.FillPie(Azul, recto, 0, 360);
}
}
private long ConvertirbytesaMB(Int64 Bytes)
{
long MB = Bytes / 1048576;
return MB;
}
private void leer_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{
listView1.Items.Add(drive.ToString());
try
{
usado = this.ConvertirbytesaMB(drive.TotalSize - drive.TotalFreeSpace);
libre = this.ConvertirbytesaMB(drive.TotalFreeSpace);
Total = this.ConvertirbytesaMB(drive.TotalSize);
listView1.Items[listView1.Items.Count - 1].BackColor = Color.Beige;
listView1.Items[listView1.Items.Count - 1].SubItems.Add(libre.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add(usado.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add(Total.ToString());
listView1.Items[listView1.Items.Count - 1].SubItems.Add("Listo");
}
catch
{
listView1.Items[listView1.Items.Count - 1].BackColor = Color.Peru;
listView1.Items[listView1.Items.Count - 1].SubItems.Add("No Instalado");
listView1.Items[listView1.Items.Count - 1].SubItems.Add("No Instalado");
listView1.Items[listView1.Items.Count - 1].SubItems.Add("No Instalado");
listView1.Items[listView1.Items.Count - 1].SubItems.Add("No Preparado");
}
}
}