//private void DumpChangedProperties(ManagementBaseObject oldObj, ManagementBaseObject newObj) //{ // foreach (var p in oldObj.Properties) // { // var v1 = p.Value == null ? "(null)" : p.Value.ToString(); // var v2 = newObj[p.Name] == null ? "(null)" : newObj[p.Name].ToString(); // if (v1 != v2) // { // Debug.WriteLine("{0}: {1} => {2}", p.Name, v1, v2); // } // } //} private void frmMain_Load(object sender, EventArgs e) { #if DEBUG btnWipe.Visible = true; #endif DriveTools.StartDriveChangeNotification(DriveChanged); ResetProgress(); FillDriveList(); }
private void LoadDiskDrives() { m_DrivesFound = false; string m_SelectedID = null; BeginInvoke(new Action(() => { if (lstDiskDrive.SelectedItem != null) { m_SelectedID = lstDiskDrive.SelectedItem.ToString(); } lstDiskDrive.DataSource = null; lstDiskDrive.Items.Clear(); lstDiskDrive.Items.Add("(loading...)"); lstDiskDrive.SelectedIndex = 0; this.Refresh(); })); WmiInfo.LoadDiskInfo(); BeginInvoke(new Action(() => { var l = DriveTools.GetRemovableDiskDrives().OrderBy(z => z.ID).ToList(); lstDiskDrive.Items.Clear(); if (l.Count == 0) { lstDiskDrive.Items.Add("(No removable disk drives found)"); lstDiskDrive.SelectedIndex = 0; } else { lstDiskDrive.DataSource = l; m_DrivesFound = true; var o = l.FirstOrDefault(z => z.ID == m_SelectedID); if (o != null) { lstDiskDrive.SelectedItem = o; } else { lstDiskDrive_SelectedIndexChanged(this, EventArgs.Empty); } } lstDiskDrive.Refresh(); })); }
private void frmMain_FormClosed(object sender, FormClosedEventArgs e) { DriveTools.StopDriveChangeNotification(); }