Пример #1
0
        private void SelectPhysicalDiskForm_Load(object sender, EventArgs e)
        {
            List <PhysicalDisk> physicalDisks = PhysicalDiskHelper.GetPhysicalDisks();

            if (Environment.OSVersion.Version.Major >= 6)
            {
                listPhysicalDisks.Columns.Add("Status", 60);
                columnDescription.Width -= 60;
            }
            foreach (PhysicalDisk physicalDisk in physicalDisks)
            {
                string       title        = String.Format("Disk {0}", physicalDisk.PhysicalDiskIndex);
                string       description  = physicalDisk.Description;
                string       serialNumber = physicalDisk.SerialNumber;
                string       sizeString   = FormattingHelper.GetStandardSizeString(physicalDisk.Size);
                ListViewItem item         = new ListViewItem(title);
                item.SubItems.Add(description);
                item.SubItems.Add(serialNumber);
                item.SubItems.Add(sizeString);
                if (Environment.OSVersion.Version.Major >= 6)
                {
                    bool   isOnline = physicalDisk.GetOnlineStatus();
                    string status   = isOnline ? "Online" : "Offline";
                    item.SubItems.Add(status);
                }
                item.Tag = physicalDisk;
                listPhysicalDisks.Items.Add(item);
            }
        }
Пример #2
0
        private void AddDisk(Disk disk)
        {
            string description = String.Empty;
            string sizeString  = FormattingHelper.GetStandardSizeString(disk.Size);

            if (disk is DiskImage)
            {
                description = ((DiskImage)disk).Path;
            }
            else if (disk is RAMDisk)
            {
                description = "RAM Disk";
            }
#if Win32
            else if (disk is PhysicalDisk)
            {
                description = String.Format("Physical Disk {0}", ((PhysicalDisk)disk).PhysicalDiskIndex);
            }
            else if (disk is VolumeDisk)
            {
                description = String.Format("Volume");
            }
#endif
            ListViewItem item = new ListViewItem(description);
            item.SubItems.Add(sizeString);
            listDisks.Items.Add(item);
            m_disks.Add(disk);
        }
        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);
            }
        }