Update media scan GUI error times via events.

This commit is contained in:
2019-04-21 01:54:06 +01:00
parent a800ddb0ab
commit 5dd3903005
6 changed files with 26 additions and 4 deletions

View File

@@ -109,4 +109,10 @@ namespace DiscImageChef.Core
/// <param name="time">Time in milliseconds</param> /// <param name="time">Time in milliseconds</param>
/// <param name="blocks">Number of blocks scanned</param> /// <param name="blocks">Number of blocks scanned</param>
public delegate void ScanTimeHandler(double time, uint blocks); public delegate void ScanTimeHandler(double time, uint blocks);
/// <summary>
/// Specified a number of blocks could not be read on scan
/// </summary>
/// <param name="blocks">Number of blocks scanned</param>
public delegate void ScanUnreadableHandler(uint blocks);
} }

View File

@@ -155,6 +155,7 @@ namespace DiscImageChef.Core.Devices.Scanning
} }
else else
{ {
ScanUnreadable?.Invoke(blocksToRead);
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
@@ -250,6 +251,7 @@ namespace DiscImageChef.Core.Devices.Scanning
} }
else else
{ {
ScanUnreadable?.Invoke(blocksToRead);
results.Errored += blocksToRead; results.Errored += blocksToRead;
results.UnreadableSectors.Add(currentBlock); results.UnreadableSectors.Add(currentBlock);
mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration); mhddLog.Write(currentBlock, duration < 500 ? 65535 : duration);

View File

@@ -68,6 +68,7 @@ namespace DiscImageChef.Core.Devices.Scanning
/// Event raised to update the status of an undeterminate progress bar /// Event raised to update the status of an undeterminate progress bar
/// </summary> /// </summary>
public event PulseProgressHandler PulseProgress; public event PulseProgressHandler PulseProgress;
public event ScanTimeHandler ScanTime; public event ScanTimeHandler ScanTime;
public event ScanUnreadableHandler ScanUnreadable;
} }
} }

View File

@@ -345,6 +345,7 @@ namespace DiscImageChef.Core.Devices.Scanning
} }
else else
{ {
ScanUnreadable?.Invoke(blocksToRead);
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);
@@ -417,6 +418,7 @@ namespace DiscImageChef.Core.Devices.Scanning
// TODO: Separate errors on kind of errors. // TODO: Separate errors on kind of errors.
else else
{ {
ScanUnreadable?.Invoke(blocksToRead);
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);

View File

@@ -186,6 +186,7 @@ namespace DiscImageChef.Core.Devices.Scanning
} }
else else
{ {
ScanUnreadable?.Invoke(blocksToRead);
results.Errored += blocksToRead; results.Errored += blocksToRead;
for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b); for(ulong b = i; b < i + blocksToRead; b++) results.UnreadableSectors.Add(b);

View File

@@ -98,9 +98,10 @@ namespace DiscImageChef.Gui.Forms
Statistics.AddDevice(dev); Statistics.AddDevice(dev);
localResults = new ScanResults(); localResults = new ScanResults();
scanner = new MediaScan(null, null, devicePath, dev); scanner = new MediaScan(null, null, devicePath, dev);
scanner.ScanTime += OnScanTime; scanner.ScanTime += OnScanTime;
scanner.ScanUnreadable += OnScanUnreadable;
ScanResults results = scanner.Scan(); ScanResults results = scanner.Scan();
Application.Instance.Invoke(() => Application.Instance.Invoke(() =>
@@ -147,6 +148,15 @@ namespace DiscImageChef.Gui.Forms
}); });
} }
void OnScanUnreadable(uint blocks)
{
Application.Instance.Invoke(() =>
{
localResults.Errored += blocks;
lblUnreadableSectors.Text = $"{localResults.Errored} sectors could not be read.";
});
}
void OnScanTime(double time, uint blocks) void OnScanTime(double time, uint blocks)
{ {
Application.Instance.Invoke(() => Application.Instance.Invoke(() =>