private void addDiskToVolumeMenuItem_Click(object sender, EventArgs e) { DynamicVolume volume = (DynamicVolume)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Key; DynamicDiskExtent extent = (DynamicDiskExtent)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Value; List <DynamicDisk> dynamicDisks = GetDynamicDisks(); List <DynamicDisk> diskGroup = DynamicDiskHelper.FindDiskGroup(dynamicDisks, volume.DiskGroupGuid); AddDiskForm addDisk = new AddDiskForm(diskGroup, volume); DialogResult result = addDisk.ShowDialog(); if (result == DialogResult.OK) { if (Environment.OSVersion.Version.Major >= 6) { // Windows 7 / 2008 will likely make changes to the disk group, it will be marked as 'dirty' if we don't wait Thread.Sleep(Windows6WaitTimeBeforeRefresh); } UpdateView(); if (Environment.OSVersion.Version.Major >= 6) { //MessageBox.Show("Please go to Disk Management and reactivate the disk group", "Operation completed successfully"); MessageBox.Show("The volume has been extended successfully.\nyou can now proceed to extend the underlying file system.", "Operation completed successfully"); } else { string message = "The volume has been extended successfully.\nyou can now proceed to extend the underlying file system."; message += "\n\n" + OperatingSystemHelper.GetUpdateMessage(); MessageBox.Show(message, "Operation completed successfully"); } } }
private void resumeOperationMenuItem_Click(object sender, EventArgs e) { DynamicVolume volume = (DynamicVolume)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Key; DynamicDiskExtent extent = (DynamicDiskExtent)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Value; List <DynamicDisk> dynamicDisks = GetDynamicDisks(); List <DynamicDisk> diskGroup = DynamicDiskHelper.FindDiskGroup(dynamicDisks, volume.DiskGroupGuid); ResumeForm resumeForm = new ResumeForm(diskGroup, volume, extent); DialogResult result = resumeForm.ShowDialog(); if (result == DialogResult.OK) { UpdateView(); if (Environment.OSVersion.Version.Major >= 6) { MessageBox.Show("Click OK to Continue", "Operation completed successfully"); } else { string message = OperatingSystemHelper.GetUpdateMessage(); MessageBox.Show(message, "Operation completed successfully"); } } }
private void moveExtentMenuItem_Click(object sender, EventArgs e) { DynamicVolume volume = (DynamicVolume)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Key; DynamicDiskExtent extent = (DynamicDiskExtent)((KeyValuePair <Volume, DiskExtent>)extentContextMenu.Tag).Value; List <DynamicDisk> dynamicDisks = GetDynamicDisks(); List <DynamicDisk> diskGroup = DynamicDiskHelper.FindDiskGroup(dynamicDisks, volume.DiskGroupGuid); bool isBootVolume; if (RetainHelper.IsVolumeRetained(volume, out isBootVolume)) { StringBuilder builder = new StringBuilder(); builder.AppendLine("You're trying to move a retained volume (volume that has a partition"); builder.AppendLine("associated with it)."); builder.AppendLine("If an operating system is present on this volume, a reconfiguration"); builder.AppendLine("might be necessary before you could boot it successfully."); builder.AppendLine("This operation is currently not supported."); MessageBox.Show(builder.ToString(), "Warning"); return; } if (DynamicDiskPartitionerResumeRecord.HasValidSignature(volume.ReadSector(0))) { StringBuilder builder = new StringBuilder(); builder.AppendLine("There is already an operation in progress"); builder.AppendLine("Use the RESUME command to resume the operation"); MessageBox.Show(builder.ToString(), "Error"); return; } MoveExtentForm moveExtent = new MoveExtentForm(diskGroup, volume, extent); DialogResult result = moveExtent.ShowDialog(); if (result == DialogResult.OK) { if (Environment.OSVersion.Version.Major >= 6) { // Windows 7 / 2008 will likely make changes to the disk group, it will be marked as 'dirty' if we don't wait Thread.Sleep(Windows6WaitTimeBeforeRefresh); } UpdateView(); if (Environment.OSVersion.Version.Major >= 6) { //MessageBox.Show("Please go to Disk Management and reactivate the disk group", "Operation completed successfully"); MessageBox.Show("Click OK to Continue", "Operation completed successfully"); } else { string message = OperatingSystemHelper.GetUpdateMessage(); MessageBox.Show(message, "Operation completed successfully"); } } }
public static void UnlockDiskGroup(List <DynamicDisk> diskGroup) { if (Environment.OSVersion.Version.Major >= 6) { DiskOfflineHelper.OnlineAll(diskGroup); LockManager.UnlockAllDisksAndVolumes(); } else { OperatingSystemHelper.RestartLDMAndUnlockDisksAndVolumes(); } }