SelectPhysicalDiskWithSnapForm.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using DiskAccessLibrary;
  12. using static DiskAccessLibrary.Mod.Consts;
  13. namespace ISCSIConsole.Mods
  14. {
  15. public partial class SelectPhysicalDiskWithSnapForm : BaseForm
  16. {
  17. private PhysicalDisk _underlyingDisk;
  18. public SelectPhysicalDiskWithSnapForm()
  19. {
  20. InitializeComponent();
  21. }
  22. public Disk SelectedDisk { get; private set; }
  23. private void SelectDiskButton_Click(object sender, EventArgs e)
  24. {
  25. SelectPhysicalDiskForm selectPhysicalDisk = new SelectPhysicalDiskForm();
  26. DialogResult result = selectPhysicalDisk.ShowDialog();
  27. if (result == DialogResult.OK)
  28. {
  29. _underlyingDisk = selectPhysicalDisk.SelectedDisk;
  30. DiskTextBox.Text = $"{_underlyingDisk.Description} - {_underlyingDisk.SerialNumber}";
  31. var sb = new StringBuilder();
  32. sb.AppendLine($"Size: {_underlyingDisk.Size / MegaByte:N0} MB");
  33. sb.AppendLine($"Disk Index: {_underlyingDisk.PhysicalDiskIndex}");
  34. sb.AppendLine($"Bytes Per Sector: {_underlyingDisk.BytesPerSector}");
  35. DiskInfoValueLabel.Text = sb.ToString();
  36. }
  37. }
  38. private void SelectSnapButton_Click(object sender, EventArgs e)
  39. {
  40. if (_underlyingDisk == null)
  41. {
  42. MessageBox.Show("Select disk first.");
  43. return;
  44. }
  45. var dlg = new OpenFileDialog
  46. {
  47. Filter = "Physical Disk Differencing Disk Image (*.pdd)|*.pdd",
  48. CheckFileExists = false,
  49. };
  50. if (dlg.ShowDialog() == DialogResult.OK)
  51. {
  52. SnapFilePathTextBox.Text = dlg.FileName;
  53. if (File.Exists(SnapFilePathTextBox.Text))
  54. {
  55. }
  56. else
  57. {
  58. }
  59. }
  60. }
  61. private void btnOK_Click(object sender, EventArgs e)
  62. {
  63. }
  64. }
  65. }