Exemple #1
0
        internal static void DrawItems(DriveInfo drive, DrawItemEventArgs e)
        {
            // Dibujamos el fondo
            e.DrawBackground();
            // Creamos los objetos GDI+
            //Brush brush = new SolidBrush(Color.Black);
            Pen   forePen   = new Pen(e.ForeColor);
            Brush foreBrush = new SolidBrush(e.ForeColor);
            // Dibujamos el borde del rectángulo

            //Icon icono = Iconos.IconAsociado(drive.Name);
            Image imagen = UtilDrive.GetDriveImage(drive);

            if (imagen != null)
            {
                e.Graphics.DrawImage(imagen, e.Bounds.Left + 2, e.Bounds.Top + 2, e.Bounds.Size.Height - 4, e.Bounds.Size.Height - 4);
            }
            // Rellenamos el rectángulo con el Color seleccionado
            // en la combo
            //e.Graphics.FillRectangle(brush, new Rectangle(e.Bounds.Left + 3, e.Bounds.Top + 3, 18, e.Bounds.Size.Height - 5));
            // Dibujamos el nombre del color
            string label = "Unkown";

            if (drive.IsReady)
            {
                label = drive.VolumeLabel;
            }

            e.Graphics.DrawString(label + " (" + drive.Name + ")", e.Font, foreBrush, e.Bounds.Size.Height + 10, e.Bounds.Top + 2);
            // Eliminamos objetos GDI+
            //brush.Dispose();
            forePen.Dispose();
            foreBrush.Dispose();
        }
Exemple #2
0
        private void comboBoxDrive_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (!(this.Items[e.Index] is DriveInfo))
            {
                return;
            }
            DriveInfo drive = (DriveInfo)this.Items[e.Index];

            UtilDrive.DrawItems(drive, e);
        }