Пример #1
0
        private void PaintPartition(PaintEventArgs e, Rectangle rectPartition, PhysicalDrive.PARTITION_INFORMATION_EX partition, PartitionType partitionType)
        {
            // ensure that a primary or logical partition should be drawn
            System.Diagnostics.Debug.Assert(partitionType != PartitionType.Extended);

            // store the current clipping region
            Region clip = e.Graphics.Clip;

            // draw a black rectangle around the current partition
            Pen       penPartition = new Pen(Color.Black, 2.0f);
            Rectangle rectBorder   = rectPartition;

            rectBorder.Inflate(-(int)Math.Ceiling(penPartition.Width / 2), -(int)Math.Ceiling(penPartition.Width / 2));
            e.Graphics.DrawRectangle(penPartition, rectBorder);

            // fill the rectangle with white color (partition not selected) or with a hatched brush (partition selected)
            Rectangle rectInner = rectBorder;

            rectInner.Inflate(-(int)Math.Ceiling(penPartition.Width / 2), -(int)Math.Ceiling(penPartition.Width / 2));
            Brush brush;

            if (partition.PartitionNumber == selectedPartitionNumber)
            {
                brush = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(230, 230, 230), Color.White);
            }
            else
            {
                brush = new SolidBrush(Color.White);
            }
            e.Graphics.FillRectangle(brush, rectInner);

            // add the title - a box coloured using the partition type color with border which contains the partition number
            Rectangle rectTitle = rectInner;

            rectTitle.Height = 17;
            e.Graphics.FillRectangle(new SolidBrush(GetColor(partitionType)), rectTitle);
            e.Graphics.DrawLine(penPartition, new Point(rectTitle.Left, rectTitle.Bottom), new Point(rectTitle.Right, rectTitle.Bottom));

            // draw further information about the partiton
            e.Graphics.Clip = new Region(rectInner);

            //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            Font font = new Font(new FontFamily("Arial"), 9, FontStyle.Regular);

            e.Graphics.DrawString(string.Format("[{0}]", partition.PartitionNumber), font, new SolidBrush(Color.White), rectInner.Left, rectInner.Top);
            string type = PartitionTypes.GetPartitionType(partition.Mbr.PartitionType);

            if (type == null)
            {
                type = "Unknown";
            }
            e.Graphics.DrawString(type, font, new SolidBrush(Color.Black), rectInner.Left, rectInner.Top + 20);
            e.Graphics.DrawString(PhysicalDrive.GetAsBestFitSizeUnit(partition.PartitionLength), font, new SolidBrush(Color.Black), rectInner.Left, rectInner.Top + 40);

            // reset the clipping region
            e.Graphics.Clip = clip;
        }
Пример #2
0
        private void PaintPartition(PaintEventArgs e, Rectangle rectPartition, PhysicalDrive.PARTITION_INFORMATION_EX partition, PartitionType partitionType)
        {
            // ensure that a primary or logical partition should be drawn
            System.Diagnostics.Debug.Assert(partitionType != PartitionType.Extended);

            // store the current clipping region
            Region clip = e.Graphics.Clip;

            // draw a black rectangle around the current partition
            Pen penPartition = new Pen(Color.Black, 2.0f);
            Rectangle rectBorder = rectPartition;
            rectBorder.Inflate(-(int)Math.Ceiling(penPartition.Width / 2), -(int)Math.Ceiling(penPartition.Width / 2));
            e.Graphics.DrawRectangle(penPartition, rectBorder);

            // fill the rectangle with white color (partition not selected) or with a hatched brush (partition selected)
            Rectangle rectInner = rectBorder;
            rectInner.Inflate(-(int)Math.Ceiling(penPartition.Width / 2), -(int)Math.Ceiling(penPartition.Width / 2));
            Brush brush;
            if (partition.PartitionNumber == selectedPartitionNumber)
            {
                brush = new HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.FromArgb(230, 230, 230), Color.White);
            }
            else
            {
                brush = new SolidBrush(Color.White);
            }
            e.Graphics.FillRectangle(brush, rectInner);

            // add the title - a box coloured using the partition type color with border which contains the partition number
            Rectangle rectTitle = rectInner;
            rectTitle.Height = 17;
            e.Graphics.FillRectangle(new SolidBrush(GetColor(partitionType)), rectTitle);
            e.Graphics.DrawLine(penPartition, new Point(rectTitle.Left, rectTitle.Bottom), new Point(rectTitle.Right, rectTitle.Bottom));

            // draw further information about the partiton
            e.Graphics.Clip = new Region(rectInner);

            //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            Font font = new Font(new FontFamily("Arial"), 9, FontStyle.Regular);
            e.Graphics.DrawString(string.Format("[{0}]", partition.PartitionNumber), font, new SolidBrush(Color.White), rectInner.Left, rectInner.Top);
            string type = PartitionTypes.GetPartitionType(partition.Mbr.PartitionType);
            if (type == null)
            {
                type = "Unknown";
            }
            e.Graphics.DrawString(type, font, new SolidBrush(Color.Black), rectInner.Left, rectInner.Top + 20);
            e.Graphics.DrawString(PhysicalDrive.GetAsBestFitSizeUnit(partition.PartitionLength), font, new SolidBrush(Color.Black), rectInner.Left, rectInner.Top + 40);

            // reset the clipping region
            e.Graphics.Clip = clip;
        }
Пример #3
0
 public override string ToString()
 {
     return(string.Format("PhysicalDrive{0} ({1})", DriveNumber, PhysicalDrive.GetAsBestFitSizeUnit(Size)));
 }
Пример #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="drive">The drive of the device.</param>
 public Device(PhysicalDrive.DriveInfo drive)
 {
     this.Drive = drive;
     this.Partition = null;
 }
Пример #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="drive">The drive of the device.</param>
 /// <param name="partition">The partition of the drive.</param>
 public Device(PhysicalDrive.DriveInfo drive, uint partition)
 {
     this.Drive = drive;
     this.Partition = partition;
 }