private void SelectPhysicalDiskForm_Load(object sender, EventArgs e)
        {
            List <Volume> volumes = WindowsVolumeHelper.GetVolumes();

            for (int index = 0; index < volumes.Count; index++)
            {
                Volume volume = volumes[index];
                string title  = String.Format("Volume {0}", index);
                string type   = VolumeHelper.GetVolumeTypeString(volume);
                string status = VolumeHelper.GetVolumeStatusString(volume);

                ulong  volumeID = 0;
                string name     = String.Empty;
                if (volume is DynamicVolume)
                {
                    volumeID = ((DynamicVolume)volume).VolumeID;
                    name     = ((DynamicVolume)volume).Name;
                }
                else if (volume is GPTPartition)
                {
                    name = ((GPTPartition)volume).PartitionName;
                }
                ListViewItem item = new ListViewItem(title);
                item.SubItems.Add(name);
                item.SubItems.Add(type);
                item.SubItems.Add(status);
                item.SubItems.Add(FormattingHelper.GetStandardSizeString(volume.Size));
                item.Tag = volume;
                listVolumes.Items.Add(item);
            }
        }
Beispiel #2
0
        public static string GetVolumeInformation(Volume volume)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendFormat("Volume size: {0} bytes\n", volume.Size.ToString("###,###,###,###,##0"));
            builder.AppendFormat("Volume type: {0}\n", VolumeHelper.GetVolumeTypeString(volume));
            if (volume is GPTPartition)
            {
                builder.AppendFormat("Partition name: {0}\n", ((GPTPartition)volume).PartitionName);
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendFormat("Volume name: {0}\n", ((DynamicVolume)volume).Name);
                builder.AppendFormat("Volume status: {0}\n", VolumeHelper.GetVolumeStatusString(volume));
            }

            Guid?windowsVolumeGuid = WindowsVolumeHelper.GetWindowsVolumeGuid(volume);

            if (windowsVolumeGuid.HasValue)
            {
                List <string> mountPoints = WindowsVolumeManager.GetMountPoints(windowsVolumeGuid.Value);
                foreach (string volumePath in mountPoints)
                {
                    builder.AppendFormat("Volume path: {0}\n", volumePath);
                }
                bool isMounted = WindowsVolumeManager.IsMounted(windowsVolumeGuid.Value);
                builder.AppendFormat("Mounted: {0}\n", isMounted);
            }
            builder.AppendLine();

            if (volume is MirroredVolume)
            {
                builder.AppendLine("Extents:");
                List <DynamicVolume> components = ((MirroredVolume)volume).Components;
                for (int componentIndex = 0; componentIndex < components.Count; componentIndex++)
                {
                    if (componentIndex != 0)
                    {
                        builder.AppendLine();
                    }
                    DynamicVolume component = components[componentIndex];
                    builder.AppendFormat("Component {0}:\n", componentIndex);
                    builder.Append(GetExtentsInformation(component));
                }
            }
            else if (volume is DynamicVolume)
            {
                builder.AppendLine("Extents:");
                builder.Append(GetExtentsInformation((DynamicVolume)volume));
            }
            else if (volume is Partition)
            {
                Partition partition             = (Partition)volume;
                long      partitionOffset       = partition.FirstSector * partition.BytesPerSector;
                string    partitionOffsetString = FormattingHelper.GetStandardSizeString(partitionOffset);
                builder.AppendFormat("Partiton Offset: {0}, Start Sector: {1}\n", partitionOffsetString, partition.FirstSector);
            }

            return(builder.ToString());
        }
Beispiel #3
0
        private void Extent_Paint(object sender, PaintEventArgs e)
        {
            CheckBox         chkExtent = (CheckBox)sender;
            VisualDiskExtent extent    = (VisualDiskExtent)chkExtent.Tag;
            Brush            brush     = DiskStyling.GetVolumeBrush(extent.Volume);
            int bannerLocationX        = 1;
            int bannerLocationY        = 2;
            int bannerWidth            = chkExtent.Width - bannerLocationX - 2;
            int bannerTextLocationX    = 2;
            int bannerTextLocationY    = 0;

            if (chkExtent.Checked)
            {
                bannerLocationX++;
                bannerLocationY++;
                bannerTextLocationX++;
                bannerTextLocationY++;
            }
            e.Graphics.FillRectangle(brush, bannerLocationX, bannerLocationY, bannerWidth, ExtentBannerHeight);
            string typeString = VolumeHelper.GetVolumeTypeString(extent.Volume);

            if (extent.Volume == null)
            {
                typeString = "Free";
            }
            Font  font            = new Font(chkExtent.Font.FontFamily, 7);
            Brush bannerTextBrush = Brushes.White;

            if (extent.Volume is Raid5Volume)
            {
                bannerTextBrush = Brushes.Black;
            }
            e.Graphics.DrawString(typeString, font, bannerTextBrush, bannerTextLocationX, bannerTextLocationY);
        }