mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Migrate image verify from Eto.Forms to Avalonia.
This commit is contained in:
489
.idea/.idea.Aaru/.idea/contentModel.xml
generated
489
.idea/.idea.Aaru/.idea/contentModel.xml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,101 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
|
||||||
// /***************************************************************************
|
|
||||||
// The Disc Image Chef
|
|
||||||
// ============================================================================
|
|
||||||
//
|
|
||||||
// Filename : frmImageVerify.xeto
|
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
||||||
//
|
|
||||||
// Component : Image verification window.
|
|
||||||
//
|
|
||||||
// ==[ Description ] ==========================================================
|
|
||||||
//
|
|
||||||
// Defines the structure for the image verification GUI window.
|
|
||||||
//
|
|
||||||
// ==[ License ] ==============================================================
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General public License as
|
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
// ============================================================================
|
|
||||||
// Copyright © 2011-2020 Natalia Portillo
|
|
||||||
// ****************************************************************************/
|
|
||||||
-->
|
|
||||||
<Form xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
Title="Verify image" ClientSize="600, 450" Padding="10">
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
|
||||||
ID="stkOptions">
|
|
||||||
<CheckBox Text="Verify disc image if supported." ID="chkVerifyImage" Checked="True"/>
|
|
||||||
<CheckBox Text="Verify all sectors if supported." ID="chkVerifySectors" Checked="True"/>
|
|
||||||
</StackLayout>
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
|
||||||
ID="stkResults" Visible="False">
|
|
||||||
<StackLayout Orientation="Horizontal" HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch" ID="stkSectorResults" Visible="False">
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch" ID="stkSectorErrors" Visible="False">
|
|
||||||
<GroupBox ID="grpSectorErrors">
|
|
||||||
<TreeGridView ID="treeSectorErrors"/>
|
|
||||||
</GroupBox>
|
|
||||||
</StackLayout>
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch" ID="stkSectorUnknowns" Visible="False">
|
|
||||||
<GroupBox ID="grpSectorsUnknowns">
|
|
||||||
<TreeGridView ID="treeSectorsUnknowns"/>
|
|
||||||
</GroupBox>
|
|
||||||
</StackLayout>
|
|
||||||
</StackLayout>
|
|
||||||
<Label ID="lblImageResult" Visible="False"/>
|
|
||||||
<Label ID="lblSectorsErrorsAll" Visible="False"/>
|
|
||||||
<Label ID="lblSectorsUnknownAll" Visible="False"/>
|
|
||||||
<GroupBox ID="grpSectorSummary" Visible="False">
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch"
|
|
||||||
VerticalContentAlignment="Stretch">
|
|
||||||
<Label ID="lblTotalSectors"/>
|
|
||||||
<Label ID="lblTotalSectorErrors"/>
|
|
||||||
<Label ID="lblTotalSectorUnknowns"/>
|
|
||||||
<Label ID="lblTotalSectorErrorsUnknowns"/>
|
|
||||||
</StackLayout>
|
|
||||||
</GroupBox>
|
|
||||||
</StackLayout>
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
|
||||||
ID="stkProgress" Visible="False">
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
|
||||||
ID="stkProgress1">
|
|
||||||
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
|
|
||||||
<Label ID="lblProgress"/>
|
|
||||||
</StackLayoutItem>
|
|
||||||
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
|
|
||||||
<ProgressBar ID="prgProgress"/>
|
|
||||||
</StackLayoutItem>
|
|
||||||
</StackLayout>
|
|
||||||
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
|
|
||||||
ID="stkProgress2">
|
|
||||||
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
|
|
||||||
<Label ID="lblProgress2"/>
|
|
||||||
</StackLayoutItem>
|
|
||||||
<StackLayoutItem HorizontalAlignment="Center" Expand="True">
|
|
||||||
<ProgressBar ID="prgProgress2"/>
|
|
||||||
</StackLayoutItem>
|
|
||||||
</StackLayout>
|
|
||||||
</StackLayout>
|
|
||||||
<StackLayoutItem HorizontalAlignment="Right" Expand="True">
|
|
||||||
<StackLayout Orientation="Horizontal" HorizontalContentAlignment="Right" VerticalContentAlignment="Bottom">
|
|
||||||
<Button ID="btnStart" Text="Start" Click="OnBtnStart"/>
|
|
||||||
<Button ID="btnClose" Text="Close" Click="OnBtnClose"/>
|
|
||||||
<Button ID="btnStop" Text="Stop" Enabled="False" Visible="False" Click="OnBtnStop"/>
|
|
||||||
</StackLayout>
|
|
||||||
</StackLayoutItem>
|
|
||||||
</StackLayout>
|
|
||||||
</Form>
|
|
||||||
@@ -1,473 +0,0 @@
|
|||||||
// /***************************************************************************
|
|
||||||
// Aaru Data Preservation Suite
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Filename : frmImageVerify.xeto.cs
|
|
||||||
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
||||||
//
|
|
||||||
// Component : Image verification window.
|
|
||||||
//
|
|
||||||
// --[ Description ] ----------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Implements verifying media image.
|
|
||||||
//
|
|
||||||
// --[ License ] --------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General public License as
|
|
||||||
// published by the Free Software Foundation, either version 3 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General public License
|
|
||||||
// along with this program. If not, see ;http://www.gnu.org/licenses/>.
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// Copyright © 2011-2020 Natalia Portillo
|
|
||||||
// ****************************************************************************/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
using Aaru.CommonTypes.Interfaces;
|
|
||||||
using Aaru.CommonTypes.Structs;
|
|
||||||
using Aaru.Console;
|
|
||||||
using Aaru.Core;
|
|
||||||
using Eto.Forms;
|
|
||||||
using Eto.Serialization.Xaml;
|
|
||||||
|
|
||||||
namespace Aaru.Gui.Forms
|
|
||||||
{
|
|
||||||
public class frmImageVerify : Form
|
|
||||||
{
|
|
||||||
readonly IMediaImage inputFormat;
|
|
||||||
bool cancel;
|
|
||||||
|
|
||||||
public frmImageVerify(IMediaImage inputFormat)
|
|
||||||
{
|
|
||||||
this.inputFormat = inputFormat;
|
|
||||||
XamlReader.Load(this);
|
|
||||||
cancel = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnBtnStart(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
chkVerifyImage.Enabled = false;
|
|
||||||
chkVerifySectors.Enabled = false;
|
|
||||||
btnClose.Visible = false;
|
|
||||||
btnStart.Visible = false;
|
|
||||||
btnStop.Visible = true;
|
|
||||||
stkProgress.Visible = true;
|
|
||||||
lblProgress2.Visible = false;
|
|
||||||
|
|
||||||
chkVerifySectors.Visible = inputFormat as IOpticalMediaImage != null ||
|
|
||||||
inputFormat as IVerifiableSectorsImage != null;
|
|
||||||
|
|
||||||
// TODO: Do not offer the option to use this form if the image does not support any kind of verification
|
|
||||||
|
|
||||||
new Thread(DoWork).Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DoWork()
|
|
||||||
{
|
|
||||||
bool? correctDisc = null;
|
|
||||||
long totalSectors = 0;
|
|
||||||
long errorSectors = 0;
|
|
||||||
long correctSectors = 0;
|
|
||||||
long unknownSectors = 0;
|
|
||||||
bool formatHasTracks;
|
|
||||||
|
|
||||||
var inputOptical = inputFormat as IOpticalMediaImage;
|
|
||||||
var verifiableSectorsImage = inputFormat as IVerifiableSectorsImage;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
formatHasTracks = inputOptical?.Tracks?.Count > 0;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
formatHasTracks = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup progress bars
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
stkProgress.Visible = true;
|
|
||||||
prgProgress.MaxValue = 0;
|
|
||||||
|
|
||||||
if(chkVerifyImage.Checked == true ||
|
|
||||||
chkVerifySectors.Checked == true)
|
|
||||||
prgProgress.MaxValue = 1;
|
|
||||||
|
|
||||||
if(formatHasTracks && inputOptical != null)
|
|
||||||
prgProgress.MaxValue += inputOptical.Tracks.Count;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(chkVerifySectors.Checked == true)
|
|
||||||
{
|
|
||||||
prgProgress.MaxValue = 2;
|
|
||||||
prgProgress2.Visible = false;
|
|
||||||
lblProgress2.Visible = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
prgProgress2.Visible = true;
|
|
||||||
lblProgress2.Visible = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prgProgress.MaxValue++;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(chkVerifyImage.Checked == true)
|
|
||||||
{
|
|
||||||
if(!(inputFormat is IVerifiableImage verifiableImage))
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblImageResult.Visible = true;
|
|
||||||
lblImageResult.Text = "Disc image does not support verification.";
|
|
||||||
});
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblProgress.Text = "Checking media image...";
|
|
||||||
|
|
||||||
if(chkVerifySectors.Checked == true)
|
|
||||||
prgProgress.Value = 1;
|
|
||||||
else
|
|
||||||
prgProgress.Indeterminate = true;
|
|
||||||
|
|
||||||
prgProgress2.Indeterminate = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
DateTime startCheck = DateTime.UtcNow;
|
|
||||||
bool? discCheckStatus = verifiableImage.VerifyMediaImage();
|
|
||||||
DateTime endCheck = DateTime.UtcNow;
|
|
||||||
|
|
||||||
TimeSpan checkTime = endCheck - startCheck;
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblImageResult.Visible = true;
|
|
||||||
|
|
||||||
switch(discCheckStatus)
|
|
||||||
{
|
|
||||||
case true:
|
|
||||||
lblImageResult.Text = "Disc image checksums are correct";
|
|
||||||
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
lblImageResult.Text = "Disc image checksums are incorrect";
|
|
||||||
|
|
||||||
break;
|
|
||||||
case null:
|
|
||||||
lblImageResult.Text = "Disc image does not contain checksums";
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
correctDisc = discCheckStatus;
|
|
||||||
|
|
||||||
AaruConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds",
|
|
||||||
checkTime.TotalSeconds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chkVerifySectors.Checked == true)
|
|
||||||
{
|
|
||||||
DateTime startCheck = DateTime.Now;
|
|
||||||
DateTime endCheck = startCheck;
|
|
||||||
List<ulong> failingLbas = new List<ulong>();
|
|
||||||
List<ulong> unknownLbas = new List<ulong>();
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblProgress2.Visible = true;
|
|
||||||
prgProgress2.Indeterminate = false;
|
|
||||||
prgProgress2.MaxValue = (int)(inputFormat.Info.Sectors / 512);
|
|
||||||
btnStop.Enabled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
if(formatHasTracks)
|
|
||||||
{
|
|
||||||
List<Track> inputTracks = inputOptical.Tracks;
|
|
||||||
ulong currentSectorAll = 0;
|
|
||||||
|
|
||||||
startCheck = DateTime.UtcNow;
|
|
||||||
|
|
||||||
foreach(Track currentTrack in inputOptical.Tracks)
|
|
||||||
{
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
lblProgress.Text =
|
|
||||||
$"Verifying track {currentTrack.TrackSequence} of {inputOptical?.Tracks.Count}";
|
|
||||||
|
|
||||||
prgProgress.Value++;
|
|
||||||
});
|
|
||||||
|
|
||||||
ulong remainingSectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector;
|
|
||||||
ulong currentSector = 0;
|
|
||||||
|
|
||||||
while(remainingSectors > 0)
|
|
||||||
{
|
|
||||||
if(cancel)
|
|
||||||
{
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
btnClose.Visible = true;
|
|
||||||
btnStart.Visible = false;
|
|
||||||
btnStop.Visible = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong all = currentSectorAll;
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
prgProgress2.Value = (int)(all / 512);
|
|
||||||
|
|
||||||
lblProgress2.Text =
|
|
||||||
$"Checking sector {all} of {inputFormat.Info.Sectors}, on track {currentTrack.TrackSequence}";
|
|
||||||
});
|
|
||||||
|
|
||||||
List<ulong> tempfailingLbas;
|
|
||||||
List<ulong> tempunknownLbas;
|
|
||||||
|
|
||||||
if(remainingSectors < 512)
|
|
||||||
inputOptical.VerifySectors(currentSector, (uint)remainingSectors,
|
|
||||||
currentTrack.TrackSequence, out tempfailingLbas,
|
|
||||||
out tempunknownLbas);
|
|
||||||
else
|
|
||||||
inputOptical.VerifySectors(currentSector, 512, currentTrack.TrackSequence,
|
|
||||||
out tempfailingLbas, out tempunknownLbas);
|
|
||||||
|
|
||||||
failingLbas.AddRange(tempfailingLbas);
|
|
||||||
|
|
||||||
unknownLbas.AddRange(tempunknownLbas);
|
|
||||||
|
|
||||||
if(remainingSectors < 512)
|
|
||||||
{
|
|
||||||
currentSector += remainingSectors;
|
|
||||||
currentSectorAll += remainingSectors;
|
|
||||||
remainingSectors = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSector += 512;
|
|
||||||
currentSectorAll += 512;
|
|
||||||
remainingSectors -= 512;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endCheck = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
else if(!(verifiableSectorsImage is null))
|
|
||||||
{
|
|
||||||
ulong remainingSectors = inputFormat.Info.Sectors;
|
|
||||||
ulong currentSector = 0;
|
|
||||||
|
|
||||||
startCheck = DateTime.UtcNow;
|
|
||||||
|
|
||||||
while(remainingSectors > 0)
|
|
||||||
{
|
|
||||||
if(cancel)
|
|
||||||
{
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
btnClose.Visible = true;
|
|
||||||
btnStart.Visible = false;
|
|
||||||
btnStop.Visible = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong sector = currentSector;
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
prgProgress2.Value = (int)(sector / 512);
|
|
||||||
lblProgress2.Text = $"Checking sector {sector} of {inputFormat.Info.Sectors}";
|
|
||||||
});
|
|
||||||
|
|
||||||
List<ulong> tempfailingLbas;
|
|
||||||
List<ulong> tempunknownLbas;
|
|
||||||
|
|
||||||
if(remainingSectors < 512)
|
|
||||||
verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
|
|
||||||
out tempfailingLbas, out tempunknownLbas);
|
|
||||||
else
|
|
||||||
verifiableSectorsImage.VerifySectors(currentSector, 512, out tempfailingLbas,
|
|
||||||
out tempunknownLbas);
|
|
||||||
|
|
||||||
failingLbas.AddRange(tempfailingLbas);
|
|
||||||
|
|
||||||
unknownLbas.AddRange(tempunknownLbas);
|
|
||||||
|
|
||||||
if(remainingSectors < 512)
|
|
||||||
{
|
|
||||||
currentSector += remainingSectors;
|
|
||||||
remainingSectors = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSector += 512;
|
|
||||||
remainingSectors -= 512;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endCheck = DateTime.UtcNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
TimeSpan checkTime = endCheck - startCheck;
|
|
||||||
|
|
||||||
AaruConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
if(failingLbas.Count > 0)
|
|
||||||
{
|
|
||||||
if(failingLbas.Count == (int)inputFormat.Info.Sectors)
|
|
||||||
{
|
|
||||||
lblSectorsErrorsAll.Visible = true;
|
|
||||||
lblSectorsErrorsAll.Text = "All sectors contain errors";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grpSectorErrors.Text = "LBAs with error:";
|
|
||||||
grpSectorErrors.Visible = true;
|
|
||||||
|
|
||||||
var errorList = new TreeGridItemCollection();
|
|
||||||
|
|
||||||
treeSectorErrors.Columns.Add(new GridColumn
|
|
||||||
{
|
|
||||||
HeaderText = "LBA", DataCell = new TextBoxCell(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
treeSectorErrors.AllowMultipleSelection = false;
|
|
||||||
treeSectorErrors.ShowHeader = false;
|
|
||||||
treeSectorErrors.DataStore = errorList;
|
|
||||||
|
|
||||||
foreach(ulong t in failingLbas)
|
|
||||||
errorList.Add(new TreeGridItem
|
|
||||||
{
|
|
||||||
Values = new object[]
|
|
||||||
{
|
|
||||||
t
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(unknownLbas.Count > 0)
|
|
||||||
{
|
|
||||||
if(unknownLbas.Count == (int)inputFormat.Info.Sectors)
|
|
||||||
{
|
|
||||||
lblSectorsErrorsAll.Visible = true;
|
|
||||||
lblSectorsErrorsAll.Text = "All sectors contain errors";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
grpSectorsUnknowns.Text = "LBAs with error:";
|
|
||||||
grpSectorsUnknowns.Visible = true;
|
|
||||||
|
|
||||||
var unknownList = new TreeGridItemCollection();
|
|
||||||
|
|
||||||
treeSectorsUnknowns.Columns.Add(new GridColumn
|
|
||||||
{
|
|
||||||
HeaderText = "LBA", DataCell = new TextBoxCell(0)
|
|
||||||
});
|
|
||||||
|
|
||||||
treeSectorsUnknowns.AllowMultipleSelection = false;
|
|
||||||
treeSectorsUnknowns.ShowHeader = false;
|
|
||||||
treeSectorsUnknowns.DataStore = unknownList;
|
|
||||||
|
|
||||||
foreach(ulong t in unknownLbas)
|
|
||||||
unknownList.Add(new TreeGridItem
|
|
||||||
{
|
|
||||||
Values = new object[]
|
|
||||||
{
|
|
||||||
t
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grpSectorSummary.Visible = true;
|
|
||||||
lblTotalSectors.Text = $"Total sectors........... {inputFormat.Info.Sectors}";
|
|
||||||
lblTotalSectorErrors.Text = $"Total errors............ {failingLbas.Count}";
|
|
||||||
lblTotalSectorUnknowns.Text = $"Total unknowns.......... {unknownLbas.Count}";
|
|
||||||
|
|
||||||
lblTotalSectorErrorsUnknowns.Text =
|
|
||||||
$"Total errors+unknowns... {failingLbas.Count + unknownLbas.Count}";
|
|
||||||
});
|
|
||||||
|
|
||||||
totalSectors = (long)inputFormat.Info.Sectors;
|
|
||||||
errorSectors = failingLbas.Count;
|
|
||||||
unknownSectors = unknownLbas.Count;
|
|
||||||
correctSectors = totalSectors - errorSectors - unknownSectors;
|
|
||||||
}
|
|
||||||
|
|
||||||
Statistics.AddCommand("verify");
|
|
||||||
|
|
||||||
Application.Instance.Invoke(() =>
|
|
||||||
{
|
|
||||||
stkOptions.Visible = false;
|
|
||||||
stkResults.Visible = true;
|
|
||||||
stkProgress.Visible = false;
|
|
||||||
btnStart.Visible = false;
|
|
||||||
btnStop.Visible = false;
|
|
||||||
btnClose.Visible = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnBtnClose(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
protected void OnBtnStop(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
cancel = true;
|
|
||||||
btnStop.Enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region XAML IDs
|
|
||||||
StackLayout stkOptions;
|
|
||||||
CheckBox chkVerifyImage;
|
|
||||||
CheckBox chkVerifySectors;
|
|
||||||
StackLayout stkResults;
|
|
||||||
StackLayout stkSectorResults;
|
|
||||||
StackLayout stkSectorErrors;
|
|
||||||
GroupBox grpSectorErrors;
|
|
||||||
TreeGridView treeSectorErrors;
|
|
||||||
StackLayout stkSectorUnknowns;
|
|
||||||
GroupBox grpSectorsUnknowns;
|
|
||||||
TreeGridView treeSectorsUnknowns;
|
|
||||||
Label lblImageResult;
|
|
||||||
Label lblSectorsErrorsAll;
|
|
||||||
Label lblSectorsUnknownAll;
|
|
||||||
GroupBox grpSectorSummary;
|
|
||||||
Label lblTotalSectors;
|
|
||||||
Label lblTotalSectorErrors;
|
|
||||||
Label lblTotalSectorUnknowns;
|
|
||||||
Label lblTotalSectorErrorsUnknowns;
|
|
||||||
StackLayout stkProgress;
|
|
||||||
StackLayout stkProgress1;
|
|
||||||
Label lblProgress;
|
|
||||||
ProgressBar prgProgress;
|
|
||||||
StackLayout stkProgress2;
|
|
||||||
Label lblProgress2;
|
|
||||||
ProgressBar prgProgress2;
|
|
||||||
Button btnStart;
|
|
||||||
Button btnClose;
|
|
||||||
Button btnStop;
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
7
Aaru.Gui/Models/LbaModel.cs
Normal file
7
Aaru.Gui/Models/LbaModel.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Aaru.Gui.Models
|
||||||
|
{
|
||||||
|
public class LbaModel
|
||||||
|
{
|
||||||
|
public string Lba { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ namespace Aaru.Gui.ViewModels
|
|||||||
public class ImageEntropyViewModel : ViewModelBase
|
public class ImageEntropyViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
readonly IMediaImage _inputFormat;
|
readonly IMediaImage _inputFormat;
|
||||||
|
readonly Window _view;
|
||||||
bool _closeVisible;
|
bool _closeVisible;
|
||||||
bool _duplicatedSectorsChecked;
|
bool _duplicatedSectorsChecked;
|
||||||
bool _duplicatedSectorsEnabled;
|
bool _duplicatedSectorsEnabled;
|
||||||
@@ -43,7 +44,6 @@ namespace Aaru.Gui.ViewModels
|
|||||||
bool _startVisible;
|
bool _startVisible;
|
||||||
bool _stopVisible;
|
bool _stopVisible;
|
||||||
EntropyResults[] _tracksEntropy;
|
EntropyResults[] _tracksEntropy;
|
||||||
readonly Window _view;
|
|
||||||
bool _wholeDiscChecked;
|
bool _wholeDiscChecked;
|
||||||
bool _wholeDiscEnabled;
|
bool _wholeDiscEnabled;
|
||||||
bool _wholeDiscVisible;
|
bool _wholeDiscVisible;
|
||||||
@@ -334,7 +334,7 @@ namespace Aaru.Gui.ViewModels
|
|||||||
|
|
||||||
void ExecuteCloseCommand() => _view.Close();
|
void ExecuteCloseCommand() => _view.Close();
|
||||||
|
|
||||||
void ExecuteStopCommand() => throw new NotImplementedException();
|
internal void ExecuteStopCommand() => throw new NotImplementedException();
|
||||||
|
|
||||||
void InitProgress() => Progress1Visible = true;
|
void InitProgress() => Progress1Visible = true;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ namespace Aaru.Gui.ViewModels
|
|||||||
readonly Window _view;
|
readonly Window _view;
|
||||||
IFilter _filter;
|
IFilter _filter;
|
||||||
ImageChecksumWindow _imageChecksumWindow;
|
ImageChecksumWindow _imageChecksumWindow;
|
||||||
ImageEntropyWindow _imageEntropyWindow;
|
ImageEntropyWindow _imageEntropyWindow;
|
||||||
|
ImageVerifyWindow _imageVerifyWindow;
|
||||||
string _imagePath;
|
string _imagePath;
|
||||||
|
|
||||||
public ImageInfoViewModel(string imagePath, IFilter filter, IMediaImage imageFormat, Window view)
|
public ImageInfoViewModel(string imagePath, IFilter filter, IMediaImage imageFormat, Window view)
|
||||||
@@ -725,23 +726,22 @@ namespace Aaru.Gui.ViewModels
|
|||||||
|
|
||||||
protected void ExecuteVerifyCommand()
|
protected void ExecuteVerifyCommand()
|
||||||
{
|
{
|
||||||
/* TODO: frmImageVerify
|
if(_imageVerifyWindow != null)
|
||||||
if(frmImageVerify != null)
|
|
||||||
{
|
{
|
||||||
frmImageVerify.Show();
|
_imageVerifyWindow.Show();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
frmImageVerify = new frmImageVerify(imageFormat);
|
_imageVerifyWindow = new ImageVerifyWindow();
|
||||||
|
_imageVerifyWindow.DataContext = new ImageVerifyViewModel(_imageFormat, _imageVerifyWindow);
|
||||||
|
|
||||||
frmImageVerify.Closed += (s, ea) =>
|
_imageVerifyWindow.Closed += (sender, args) =>
|
||||||
{
|
{
|
||||||
frmImageVerify = null;
|
_imageVerifyWindow = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
frmImageVerify.Show();
|
_imageVerifyWindow.Show();
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ExecuteChecksumCommand()
|
protected void ExecuteChecksumCommand()
|
||||||
|
|||||||
636
Aaru.Gui/ViewModels/ImageVerifyViewModel.cs
Normal file
636
Aaru.Gui/ViewModels/ImageVerifyViewModel.cs
Normal file
@@ -0,0 +1,636 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Threading;
|
||||||
|
using Aaru.CommonTypes.Interfaces;
|
||||||
|
using Aaru.CommonTypes.Structs;
|
||||||
|
using Aaru.Console;
|
||||||
|
using Aaru.Core;
|
||||||
|
using Aaru.Gui.Models;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Aaru.Gui.ViewModels
|
||||||
|
{
|
||||||
|
public class ImageVerifyViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
readonly IMediaImage _inputFormat;
|
||||||
|
bool _cancel;
|
||||||
|
bool _closeVisible;
|
||||||
|
string _imageResultText;
|
||||||
|
bool _imageResultVisible;
|
||||||
|
bool _optionsVisible;
|
||||||
|
bool _progress2Indeterminate;
|
||||||
|
double _progress2MaxValue;
|
||||||
|
string _progress2Text;
|
||||||
|
double _progress2Value;
|
||||||
|
bool _progress2Visible;
|
||||||
|
bool _progressIndeterminate;
|
||||||
|
double _progressMaxValue;
|
||||||
|
string _progressText;
|
||||||
|
double _progressValue;
|
||||||
|
bool _progressVisible;
|
||||||
|
bool _resultsVisible;
|
||||||
|
string _sectorErrorsText;
|
||||||
|
bool _sectorErrorsVisible;
|
||||||
|
string _sectorsErrorsAllText;
|
||||||
|
bool _sectorsErrorsAllVisible;
|
||||||
|
bool _sectorSummaryVisible;
|
||||||
|
string _sectorsUnknownAllText;
|
||||||
|
bool _sectorsUnknownAllVisible;
|
||||||
|
string _sectorsUnknownsText;
|
||||||
|
bool _sectorsUnknownsVisible;
|
||||||
|
bool _startVisible;
|
||||||
|
bool _stopEnabled;
|
||||||
|
bool _stopVisible;
|
||||||
|
string _totalSectorErrorsText;
|
||||||
|
string _totalSectorErrorsUnknownsText;
|
||||||
|
string _totalSectorsText;
|
||||||
|
string _totalSectorUnknownsText;
|
||||||
|
bool _verifyImageChecked;
|
||||||
|
bool _verifyImageEnabled;
|
||||||
|
bool _verifySectorsChecked;
|
||||||
|
bool _verifySectorsEnabled;
|
||||||
|
bool _verifySectorsVisible;
|
||||||
|
readonly Window _view;
|
||||||
|
|
||||||
|
public ImageVerifyViewModel(IMediaImage inputFormat, Window view)
|
||||||
|
{
|
||||||
|
_view = view;
|
||||||
|
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
||||||
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
||||||
|
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
|
||||||
|
_inputFormat = inputFormat;
|
||||||
|
_cancel = false;
|
||||||
|
ErrorList = new ObservableCollection<LbaModel>();
|
||||||
|
UnknownList = new ObservableCollection<LbaModel>();
|
||||||
|
VerifyImageEnabled = true;
|
||||||
|
VerifySectorsEnabled = true;
|
||||||
|
CloseVisible = true;
|
||||||
|
StartVisible = true;
|
||||||
|
OptionsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<LbaModel> ErrorList { get; }
|
||||||
|
public ObservableCollection<LbaModel> UnknownList { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> StartCommand { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> StopCommand { get; }
|
||||||
|
|
||||||
|
public bool VerifyImageEnabled
|
||||||
|
{
|
||||||
|
get => _verifyImageEnabled;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _verifyImageEnabled, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifySectorsEnabled
|
||||||
|
{
|
||||||
|
get => _verifySectorsEnabled;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsEnabled, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifySectorsVisible
|
||||||
|
{
|
||||||
|
get => _verifySectorsVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ProgressMaxValue
|
||||||
|
{
|
||||||
|
get => _progressMaxValue;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifyImageChecked
|
||||||
|
{
|
||||||
|
get => _verifyImageChecked;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _verifyImageChecked, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ProgressIndeterminate
|
||||||
|
{
|
||||||
|
get => _progressIndeterminate;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ImageResultVisible
|
||||||
|
{
|
||||||
|
get => _imageResultVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _imageResultVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ImageResultText
|
||||||
|
{
|
||||||
|
get => _imageResultText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _imageResultText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool VerifySectorsChecked
|
||||||
|
{
|
||||||
|
get => _verifySectorsChecked;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsChecked, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Progress2Visible
|
||||||
|
{
|
||||||
|
get => _progress2Visible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Progress2Indeterminate
|
||||||
|
{
|
||||||
|
get => _progress2Indeterminate;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Progress2MaxValue
|
||||||
|
{
|
||||||
|
get => _progress2MaxValue;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ProgressText
|
||||||
|
{
|
||||||
|
get => _progressText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progressText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double ProgressValue
|
||||||
|
{
|
||||||
|
get => _progressValue;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Progress2Value
|
||||||
|
{
|
||||||
|
get => _progress2Value;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Progress2Text
|
||||||
|
{
|
||||||
|
get => _progress2Text;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SectorsErrorsAllVisible
|
||||||
|
{
|
||||||
|
get => _sectorsErrorsAllVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SectorsErrorsAllText
|
||||||
|
{
|
||||||
|
get => _sectorsErrorsAllText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SectorsUnknownAllVisible
|
||||||
|
{
|
||||||
|
get => _sectorsUnknownAllVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SectorsUnknownAllText
|
||||||
|
{
|
||||||
|
get => _sectorsUnknownAllText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SectorErrorsText
|
||||||
|
{
|
||||||
|
get => _sectorErrorsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorErrorsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SectorErrorsVisible
|
||||||
|
{
|
||||||
|
get => _sectorErrorsVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorErrorsVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SectorsUnknownsVisible
|
||||||
|
{
|
||||||
|
get => _sectorsUnknownsVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SectorsUnknownsText
|
||||||
|
{
|
||||||
|
get => _sectorsUnknownsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SectorSummaryVisible
|
||||||
|
{
|
||||||
|
get => _sectorSummaryVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _sectorSummaryVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TotalSectorsText
|
||||||
|
{
|
||||||
|
get => _totalSectorsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalSectorsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TotalSectorErrorsText
|
||||||
|
{
|
||||||
|
get => _totalSectorErrorsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TotalSectorUnknownsText
|
||||||
|
{
|
||||||
|
get => _totalSectorUnknownsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalSectorUnknownsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string TotalSectorErrorsUnknownsText
|
||||||
|
{
|
||||||
|
get => _totalSectorErrorsUnknownsText;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsUnknownsText, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OptionsVisible
|
||||||
|
{
|
||||||
|
get => _optionsVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _optionsVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ResultsVisible
|
||||||
|
{
|
||||||
|
get => _resultsVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _resultsVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ProgressVisible
|
||||||
|
{
|
||||||
|
get => _progressVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StartVisible
|
||||||
|
{
|
||||||
|
get => _startVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StopVisible
|
||||||
|
{
|
||||||
|
get => _stopVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CloseVisible
|
||||||
|
{
|
||||||
|
get => _closeVisible;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _closeVisible, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool StopEnabled
|
||||||
|
{
|
||||||
|
get => _stopEnabled;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _stopEnabled, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExecuteStartCommand()
|
||||||
|
{
|
||||||
|
VerifyImageEnabled = false;
|
||||||
|
VerifySectorsEnabled = false;
|
||||||
|
CloseVisible = false;
|
||||||
|
StartVisible = false;
|
||||||
|
StopVisible = true;
|
||||||
|
ProgressVisible = true;
|
||||||
|
Progress2Visible = false;
|
||||||
|
|
||||||
|
VerifySectorsVisible = _inputFormat is IOpticalMediaImage ||
|
||||||
|
_inputFormat is IVerifiableSectorsImage;
|
||||||
|
|
||||||
|
// TODO: Do not offer the option to use this form if the image does not support any kind of verification
|
||||||
|
new Thread(DoWork).Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
async void DoWork()
|
||||||
|
{
|
||||||
|
bool formatHasTracks;
|
||||||
|
var inputOptical = _inputFormat as IOpticalMediaImage;
|
||||||
|
var verifiableSectorsImage = _inputFormat as IVerifiableSectorsImage;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
formatHasTracks = inputOptical?.Tracks?.Count > 0;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
formatHasTracks = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup progress bars
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ProgressVisible = true;
|
||||||
|
ProgressMaxValue = 0;
|
||||||
|
|
||||||
|
if(VerifyImageChecked || VerifySectorsChecked)
|
||||||
|
ProgressMaxValue = 1;
|
||||||
|
|
||||||
|
if(formatHasTracks && inputOptical != null)
|
||||||
|
ProgressMaxValue += inputOptical.Tracks.Count;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(VerifySectorsChecked)
|
||||||
|
{
|
||||||
|
ProgressMaxValue = 2;
|
||||||
|
Progress2Visible = false;
|
||||||
|
Progress2Visible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Progress2Visible = true;
|
||||||
|
Progress2Visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressMaxValue++;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(VerifyImageChecked)
|
||||||
|
{
|
||||||
|
if(!(_inputFormat is IVerifiableImage verifiableImage))
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ImageResultVisible = true;
|
||||||
|
ImageResultText = "Disc image does not support verification.";
|
||||||
|
});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ProgressText = "Checking media image...";
|
||||||
|
|
||||||
|
if(VerifySectorsChecked)
|
||||||
|
ProgressValue = 1;
|
||||||
|
else
|
||||||
|
ProgressIndeterminate = true;
|
||||||
|
|
||||||
|
Progress2Indeterminate = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
DateTime startCheck = DateTime.UtcNow;
|
||||||
|
bool? discCheckStatus = verifiableImage.VerifyMediaImage();
|
||||||
|
DateTime endCheck = DateTime.UtcNow;
|
||||||
|
|
||||||
|
TimeSpan checkTime = endCheck - startCheck;
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ImageResultVisible = true;
|
||||||
|
|
||||||
|
switch(discCheckStatus)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
ImageResultText = "Disc image checksums are correct";
|
||||||
|
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
ImageResultText = "Disc image checksums are incorrect";
|
||||||
|
|
||||||
|
break;
|
||||||
|
case null:
|
||||||
|
ImageResultText = "Disc image does not contain checksums";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AaruConsole.VerboseWriteLine("Checking disc image checksums took {0} seconds",
|
||||||
|
checkTime.TotalSeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(VerifySectorsChecked)
|
||||||
|
{
|
||||||
|
DateTime startCheck = DateTime.Now;
|
||||||
|
DateTime endCheck = startCheck;
|
||||||
|
List<ulong> failingLbas = new List<ulong>();
|
||||||
|
List<ulong> unknownLbas = new List<ulong>();
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
Progress2Visible = true;
|
||||||
|
Progress2Indeterminate = false;
|
||||||
|
Progress2MaxValue = _inputFormat.Info.Sectors / 512d;
|
||||||
|
StopEnabled = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(formatHasTracks)
|
||||||
|
{
|
||||||
|
ulong currentSectorAll = 0;
|
||||||
|
|
||||||
|
startCheck = DateTime.UtcNow;
|
||||||
|
|
||||||
|
foreach(Track currentTrack in inputOptical.Tracks)
|
||||||
|
{
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
ProgressText =
|
||||||
|
$"Verifying track {currentTrack.TrackSequence} of {inputOptical.Tracks.Count}";
|
||||||
|
|
||||||
|
ProgressValue++;
|
||||||
|
});
|
||||||
|
|
||||||
|
ulong remainingSectors = currentTrack.TrackEndSector - currentTrack.TrackStartSector;
|
||||||
|
ulong currentSector = 0;
|
||||||
|
|
||||||
|
while(remainingSectors > 0)
|
||||||
|
{
|
||||||
|
if(_cancel)
|
||||||
|
{
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
CloseVisible = true;
|
||||||
|
StartVisible = false;
|
||||||
|
StopVisible = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong all = currentSectorAll;
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
Progress2Value = all / 512d;
|
||||||
|
|
||||||
|
Progress2Text =
|
||||||
|
$"Checking sector {all} of {_inputFormat.Info.Sectors}, on track {currentTrack.TrackSequence}";
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ulong> tempFailingLbas;
|
||||||
|
List<ulong> tempUnknownLbas;
|
||||||
|
|
||||||
|
if(remainingSectors < 512)
|
||||||
|
inputOptical.VerifySectors(currentSector, (uint)remainingSectors,
|
||||||
|
currentTrack.TrackSequence, out tempFailingLbas,
|
||||||
|
out tempUnknownLbas);
|
||||||
|
else
|
||||||
|
inputOptical.VerifySectors(currentSector, 512, currentTrack.TrackSequence,
|
||||||
|
out tempFailingLbas, out tempUnknownLbas);
|
||||||
|
|
||||||
|
failingLbas.AddRange(tempFailingLbas);
|
||||||
|
|
||||||
|
unknownLbas.AddRange(tempUnknownLbas);
|
||||||
|
|
||||||
|
if(remainingSectors < 512)
|
||||||
|
{
|
||||||
|
currentSector += remainingSectors;
|
||||||
|
currentSectorAll += remainingSectors;
|
||||||
|
remainingSectors = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentSector += 512;
|
||||||
|
currentSectorAll += 512;
|
||||||
|
remainingSectors -= 512;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endCheck = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
else if(!(verifiableSectorsImage is null))
|
||||||
|
{
|
||||||
|
ulong remainingSectors = _inputFormat.Info.Sectors;
|
||||||
|
ulong currentSector = 0;
|
||||||
|
|
||||||
|
startCheck = DateTime.UtcNow;
|
||||||
|
|
||||||
|
while(remainingSectors > 0)
|
||||||
|
{
|
||||||
|
if(_cancel)
|
||||||
|
{
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
CloseVisible = true;
|
||||||
|
StartVisible = false;
|
||||||
|
StopVisible = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ulong sector = currentSector;
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
Progress2Value = (int)(sector / 512);
|
||||||
|
Progress2Text = $"Checking sector {sector} of {_inputFormat.Info.Sectors}";
|
||||||
|
});
|
||||||
|
|
||||||
|
List<ulong> tempFailingLbas;
|
||||||
|
List<ulong> tempUnknownLbas;
|
||||||
|
|
||||||
|
if(remainingSectors < 512)
|
||||||
|
verifiableSectorsImage.VerifySectors(currentSector, (uint)remainingSectors,
|
||||||
|
out tempFailingLbas, out tempUnknownLbas);
|
||||||
|
else
|
||||||
|
verifiableSectorsImage.VerifySectors(currentSector, 512, out tempFailingLbas,
|
||||||
|
out tempUnknownLbas);
|
||||||
|
|
||||||
|
failingLbas.AddRange(tempFailingLbas);
|
||||||
|
|
||||||
|
unknownLbas.AddRange(tempUnknownLbas);
|
||||||
|
|
||||||
|
if(remainingSectors < 512)
|
||||||
|
{
|
||||||
|
currentSector += remainingSectors;
|
||||||
|
remainingSectors = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentSector += 512;
|
||||||
|
remainingSectors -= 512;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
endCheck = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
TimeSpan checkTime = endCheck - startCheck;
|
||||||
|
AaruConsole.VerboseWriteLine("Checking sector checksums took {0} seconds", checkTime.TotalSeconds);
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
if(failingLbas.Count > 0)
|
||||||
|
{
|
||||||
|
if(failingLbas.Count == (int)_inputFormat.Info.Sectors)
|
||||||
|
{
|
||||||
|
SectorsErrorsAllVisible = true;
|
||||||
|
SectorsErrorsAllText = "All sectors contain errors";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SectorErrorsText = "LBAs with error:";
|
||||||
|
SectorErrorsVisible = true;
|
||||||
|
|
||||||
|
foreach(ulong t in failingLbas)
|
||||||
|
ErrorList.Add(new LbaModel
|
||||||
|
{
|
||||||
|
Lba = t.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(unknownLbas.Count > 0)
|
||||||
|
{
|
||||||
|
if(unknownLbas.Count == (int)_inputFormat.Info.Sectors)
|
||||||
|
{
|
||||||
|
SectorsUnknownAllVisible = true;
|
||||||
|
SectorsUnknownAllText = "All sectors are unknown";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SectorsUnknownsText = "Unknown LBAs:";
|
||||||
|
SectorsUnknownsVisible = true;
|
||||||
|
|
||||||
|
foreach(ulong t in unknownLbas)
|
||||||
|
UnknownList.Add(new LbaModel
|
||||||
|
{
|
||||||
|
Lba = t.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SectorSummaryVisible = true;
|
||||||
|
TotalSectorsText = $"Total sectors........... {_inputFormat.Info.Sectors}";
|
||||||
|
TotalSectorErrorsText = $"Total errors............ {failingLbas.Count}";
|
||||||
|
TotalSectorUnknownsText = $"Total unknowns.......... {unknownLbas.Count}";
|
||||||
|
|
||||||
|
TotalSectorErrorsUnknownsText = $"Total errors+unknowns... {failingLbas.Count + unknownLbas.Count}";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Statistics.AddCommand("verify");
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
{
|
||||||
|
OptionsVisible = false;
|
||||||
|
ResultsVisible = true;
|
||||||
|
ProgressVisible = false;
|
||||||
|
StartVisible = false;
|
||||||
|
StopVisible = false;
|
||||||
|
CloseVisible = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExecuteCloseCommand() => _view.Close();
|
||||||
|
|
||||||
|
protected internal void ExecuteStopCommand()
|
||||||
|
{
|
||||||
|
_cancel = true;
|
||||||
|
StopEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ namespace Aaru.Gui.Views
|
|||||||
|
|
||||||
protected override void OnClosing(CancelEventArgs e)
|
protected override void OnClosing(CancelEventArgs e)
|
||||||
{
|
{
|
||||||
(DataContext as ImageChecksumViewModel)?.ExecuteStopCommand();
|
(DataContext as ImageEntropyViewModel)?.ExecuteStopCommand();
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
72
Aaru.Gui/Views/ImageVerifyWindow.xaml
Normal file
72
Aaru.Gui/Views/ImageVerifyWindow.xaml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels;assembly=Aaru.Gui"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800"
|
||||||
|
d:DesignHeight="450" x:Class="Aaru.Gui.Views.ImageVerifyWindow" Icon="/Assets/aaru-logo.png"
|
||||||
|
Title="{Binding Title}">
|
||||||
|
<Design.DataContext>
|
||||||
|
<vm:ImageVerifyViewModel />
|
||||||
|
</Design.DataContext>
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding OptionsVisible}">
|
||||||
|
<CheckBox IsChecked="{Binding VerifyImageChecked}" IsEnabled="{Binding VerifyImageEnabled}">
|
||||||
|
<TextBlock Text="Verify disc image if supported." />
|
||||||
|
</CheckBox>
|
||||||
|
<CheckBox IsChecked="{Binding VerifySectorsChecked}" IsEnabled="{Binding VerifySectorsEnabled}"
|
||||||
|
IsVisible="{Binding VerifySectorsVisible}">
|
||||||
|
<TextBlock Text="Verify all sectors if supported." />
|
||||||
|
</CheckBox>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding ResultsVisible}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding SectorErrorsVisible}">
|
||||||
|
<TextBlock Text="{Binding SectorErrorsText}" />
|
||||||
|
<DataGrid Items="{Binding ErrorList}">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="LBA" Binding="{Binding Lba}" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding SectorsUnknownsVisible}">
|
||||||
|
<TextBlock Text="{Binding SectorsUnknownsText}" />
|
||||||
|
<DataGrid Items="{Binding UnknownList}">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="LBA" Binding="{Binding Lba}" />
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel IsVisible="{Binding SectorSummaryVisible}">
|
||||||
|
<TextBlock Text="{Binding ImageResultText}" IsVisible="{Binding ImageResultVisible}" />
|
||||||
|
<TextBlock Text="{Binding SectorsErrorsAllText}" IsVisible="{Binding SectorsErrorsAllVisible}" />
|
||||||
|
<TextBlock Text="{Binding SectorsUnknownAllText}" IsVisible="{Binding SectorsUnknownAllVisible}" />
|
||||||
|
<TextBlock Text="{Binding TotalSectorsText}" /> <TextBlock Text="{Binding TotalSectorErrorsText}" />
|
||||||
|
<TextBlock Text="{Binding TotalSectorUnknownsText}" />
|
||||||
|
<TextBlock Text="{Binding TotalSectorErrorsUnknownsText}" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding ProgressVisible}">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
|
<TextBlock Text="{Binding ProgressText}" />
|
||||||
|
<ProgressBar Maximum="{Binding ProgressMaxValue}" IsIndeterminate="{Binding ProgressIndeterminate}"
|
||||||
|
Value="{Binding ProgressValue}" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Vertical" IsVisible="{Binding Progress2Visible}">
|
||||||
|
<TextBlock Text="{Binding Progress2Text}" />
|
||||||
|
<ProgressBar Maximum="{Binding Progress2MaxValue}" IsIndeterminate="{Binding Progress2Indeterminate}"
|
||||||
|
Value="{Binding Progress2Value}" />
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Button Command="{Binding StartCommand}" IsVisible="{Binding StartVisible}">
|
||||||
|
<TextBlock Text="Start" />
|
||||||
|
</Button>
|
||||||
|
<Button Command="{Binding CloseCommand}" IsVisible="{Binding CloseVisible}">
|
||||||
|
<TextBlock Text="Close" />
|
||||||
|
</Button>
|
||||||
|
<Button Command="{Binding StopCommand}" IsVisible="{Binding StopVisible}" IsEnabled="{Binding StopEnabled}">
|
||||||
|
<TextBlock Text="Stop" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
||||||
27
Aaru.Gui/Views/ImageVerifyWindow.xaml.cs
Normal file
27
Aaru.Gui/Views/ImageVerifyWindow.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using Aaru.Gui.ViewModels;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace Aaru.Gui.Views
|
||||||
|
{
|
||||||
|
public class ImageVerifyWindow : Window
|
||||||
|
{
|
||||||
|
public ImageVerifyWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
#if DEBUG
|
||||||
|
this.AttachDevTools();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void InitializeComponent() => AvaloniaXamlLoader.Load(this);
|
||||||
|
|
||||||
|
protected override void OnClosing(CancelEventArgs e)
|
||||||
|
{
|
||||||
|
(DataContext as ImageVerifyViewModel)?.ExecuteStopCommand();
|
||||||
|
base.OnClosing(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user