2020-04-17 21:45:50 +01:00
|
|
|
// /***************************************************************************
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : ImageVerifyViewModel.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// View model and code for the image verification 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/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-12-19 10:45:18 +00:00
|
|
|
// Copyright © 2011-2025 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2020-04-13 01:19:55 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
2023-09-26 20:16:24 +01:00
|
|
|
using System.Diagnostics;
|
2022-11-14 01:38:50 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-04-13 01:19:55 +01:00
|
|
|
using System.Reactive;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Aaru.CommonTypes.Interfaces;
|
|
|
|
|
using Aaru.CommonTypes.Structs;
|
|
|
|
|
using Aaru.Core;
|
|
|
|
|
using Aaru.Gui.Models;
|
2022-11-19 21:10:41 +00:00
|
|
|
using Aaru.Localization;
|
2025-08-17 05:50:25 +01:00
|
|
|
using Aaru.Logging;
|
2020-04-13 01:19:55 +01:00
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Threading;
|
2023-09-26 03:39:10 +01:00
|
|
|
using Humanizer;
|
|
|
|
|
using Humanizer.Localisation;
|
2020-04-13 01:19:55 +01:00
|
|
|
using ReactiveUI;
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Gui.ViewModels.Windows;
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public sealed class ImageVerifyViewModel : ViewModelBase
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
readonly IMediaImage _inputFormat;
|
|
|
|
|
readonly Window _view;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
public ImageVerifyViewModel(IMediaImage inputFormat, Window view)
|
|
|
|
|
{
|
|
|
|
|
_view = view;
|
|
|
|
|
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
|
|
|
|
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
|
|
|
|
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
|
|
|
|
|
_inputFormat = inputFormat;
|
|
|
|
|
_cancel = false;
|
2024-05-01 04:39:38 +01:00
|
|
|
ErrorList = [];
|
|
|
|
|
UnknownList = [];
|
2022-03-06 13:29:38 +00:00
|
|
|
VerifyImageEnabled = true;
|
|
|
|
|
VerifySectorsEnabled = true;
|
|
|
|
|
CloseVisible = true;
|
|
|
|
|
StartVisible = true;
|
|
|
|
|
OptionsVisible = true;
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2023-10-03 12:59:30 +01:00
|
|
|
public string VerifyImageLabel => UI.Verify_media_image_if_supported;
|
2022-11-19 21:10:41 +00:00
|
|
|
public string VerifySectorsLabel => UI.Verify_all_sectors_if_supported;
|
|
|
|
|
public string LBALabel => UI.Title_LBA;
|
|
|
|
|
public string StartLabel => UI.ButtonLabel_Start;
|
|
|
|
|
public string CloseLabel => UI.ButtonLabel_Close;
|
|
|
|
|
public string StopLabel => UI.ButtonLabel_Stop;
|
2022-11-16 21:40:54 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
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; }
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool VerifyImageEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _verifyImageEnabled;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifyImageEnabled, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool VerifySectorsEnabled
|
|
|
|
|
{
|
|
|
|
|
get => _verifySectorsEnabled;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsEnabled, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool VerifySectorsVisible
|
|
|
|
|
{
|
|
|
|
|
get => _verifySectorsVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public double ProgressMaxValue
|
|
|
|
|
{
|
|
|
|
|
get => _progressMaxValue;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool VerifyImageChecked
|
|
|
|
|
{
|
|
|
|
|
get => _verifyImageChecked;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifyImageChecked, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool ProgressIndeterminate
|
|
|
|
|
{
|
|
|
|
|
get => _progressIndeterminate;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool ImageResultVisible
|
|
|
|
|
{
|
|
|
|
|
get => _imageResultVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _imageResultVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string ImageResultText
|
|
|
|
|
{
|
|
|
|
|
get => _imageResultText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _imageResultText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool VerifySectorsChecked
|
|
|
|
|
{
|
|
|
|
|
get => _verifySectorsChecked;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _verifySectorsChecked, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool Progress2Visible
|
|
|
|
|
{
|
|
|
|
|
get => _progress2Visible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool Progress2Indeterminate
|
|
|
|
|
{
|
|
|
|
|
get => _progress2Indeterminate;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public double Progress2MaxValue
|
|
|
|
|
{
|
|
|
|
|
get => _progress2MaxValue;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string ProgressText
|
|
|
|
|
{
|
|
|
|
|
get => _progressText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progressText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public double ProgressValue
|
|
|
|
|
{
|
|
|
|
|
get => _progressValue;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public double Progress2Value
|
|
|
|
|
{
|
|
|
|
|
get => _progress2Value;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string Progress2Text
|
|
|
|
|
{
|
|
|
|
|
get => _progress2Text;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SectorsErrorsAllVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsErrorsAllVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string SectorsErrorsAllText
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsErrorsAllText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SectorsUnknownAllVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsUnknownAllVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string SectorsUnknownAllText
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsUnknownAllText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string SectorErrorsText
|
|
|
|
|
{
|
|
|
|
|
get => _sectorErrorsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorErrorsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SectorErrorsVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sectorErrorsVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorErrorsVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SectorsUnknownsVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsUnknownsVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string SectorsUnknownsText
|
|
|
|
|
{
|
|
|
|
|
get => _sectorsUnknownsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SectorSummaryVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sectorSummaryVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sectorSummaryVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string TotalSectorsText
|
|
|
|
|
{
|
|
|
|
|
get => _totalSectorsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _totalSectorsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string TotalSectorErrorsText
|
|
|
|
|
{
|
|
|
|
|
get => _totalSectorErrorsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string TotalSectorUnknownsText
|
|
|
|
|
{
|
|
|
|
|
get => _totalSectorUnknownsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _totalSectorUnknownsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string TotalSectorErrorsUnknownsText
|
|
|
|
|
{
|
|
|
|
|
get => _totalSectorErrorsUnknownsText;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsUnknownsText, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool OptionsVisible
|
|
|
|
|
{
|
|
|
|
|
get => _optionsVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _optionsVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool ResultsVisible
|
|
|
|
|
{
|
|
|
|
|
get => _resultsVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _resultsVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool ProgressVisible
|
|
|
|
|
{
|
|
|
|
|
get => _progressVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool StartVisible
|
|
|
|
|
{
|
|
|
|
|
get => _startVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool StopVisible
|
|
|
|
|
{
|
|
|
|
|
get => _stopVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
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;
|
|
|
|
|
|
2022-03-16 11:47:00 +00:00
|
|
|
VerifySectorsVisible = _inputFormat is IOpticalMediaImage or IVerifiableSectorsImage;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
// TODO: Do not offer the option to use this form if the image does not support any kind of verification
|
|
|
|
|
new Thread(DoWork).Start();
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void DoWork()
|
|
|
|
|
{
|
|
|
|
|
bool formatHasTracks;
|
|
|
|
|
var inputOptical = _inputFormat as IOpticalMediaImage;
|
|
|
|
|
var verifiableSectorsImage = _inputFormat as IVerifiableSectorsImage;
|
|
|
|
|
|
|
|
|
|
try
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
formatHasTracks = inputOptical?.Tracks?.Count > 0;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
catch
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
formatHasTracks = false;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// Setup progress bars
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
ProgressVisible = true;
|
|
|
|
|
ProgressMaxValue = 0;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
if(VerifyImageChecked || VerifySectorsChecked) ProgressMaxValue = 1;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(formatHasTracks && inputOptical != null)
|
|
|
|
|
ProgressMaxValue += inputOptical.Tracks.Count;
|
|
|
|
|
else
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(VerifySectorsChecked)
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
ProgressMaxValue = 2;
|
|
|
|
|
Progress2Visible = false;
|
|
|
|
|
Progress2Visible = false;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Progress2Visible = true;
|
|
|
|
|
Progress2Visible = true;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ProgressMaxValue++;
|
|
|
|
|
});
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(VerifyImageChecked)
|
|
|
|
|
{
|
2022-11-14 01:20:28 +00:00
|
|
|
if(_inputFormat is not IVerifiableImage verifiableImage)
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2020-04-13 01:19:55 +01:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
ImageResultVisible = true;
|
2022-11-19 21:10:41 +00:00
|
|
|
ImageResultText = UI.Disc_image_does_not_support_verification;
|
2020-04-13 01:19:55 +01:00
|
|
|
});
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-11-19 21:10:41 +00:00
|
|
|
ProgressText = UI.Checking_media_image;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(VerifySectorsChecked)
|
|
|
|
|
ProgressValue = 1;
|
|
|
|
|
else
|
|
|
|
|
ProgressIndeterminate = true;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Progress2Indeterminate = true;
|
|
|
|
|
});
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
var chkStopwatch = new Stopwatch();
|
|
|
|
|
chkStopwatch.Start();
|
2023-10-03 23:27:57 +01:00
|
|
|
bool? discCheckStatus = verifiableImage.VerifyMediaImage();
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Stop();
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
ImageResultVisible = true;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-11-13 19:59:24 +00:00
|
|
|
ImageResultText = discCheckStatus switch
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
|
|
|
|
true => UI.Disc_image_checksums_are_correct,
|
|
|
|
|
false => UI.Disc_image_checksums_are_incorrect,
|
|
|
|
|
null => UI.Disc_image_does_not_contain_checksums
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(VerifySectorsChecked)
|
|
|
|
|
{
|
2023-09-26 20:16:24 +01:00
|
|
|
var chkStopwatch = new Stopwatch();
|
2024-05-01 04:39:38 +01:00
|
|
|
List<ulong> failingLbas = [];
|
|
|
|
|
List<ulong> unknownLbas = [];
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
Progress2Visible = true;
|
|
|
|
|
Progress2Indeterminate = false;
|
|
|
|
|
Progress2MaxValue = _inputFormat.Info.Sectors / 512d;
|
|
|
|
|
StopEnabled = true;
|
|
|
|
|
});
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(formatHasTracks)
|
|
|
|
|
{
|
|
|
|
|
ulong currentSectorAll = 0;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Restart();
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
foreach(Track currentTrack in inputOptical.Tracks)
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
ProgressText = string.Format(UI.Verifying_track_0_of_1,
|
|
|
|
|
currentTrack.Sequence,
|
2022-11-19 21:10:41 +00:00
|
|
|
inputOptical.Tracks.Count);
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ProgressValue++;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ulong remainingSectors = currentTrack.EndSector - currentTrack.StartSector;
|
|
|
|
|
ulong currentSector = 0;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
|
|
|
|
while(remainingSectors > 0)
|
|
|
|
|
{
|
|
|
|
|
if(_cancel)
|
|
|
|
|
{
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
CloseVisible = true;
|
|
|
|
|
StartVisible = false;
|
|
|
|
|
StopVisible = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ulong all = currentSectorAll;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Progress2Value = all / 512d;
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Progress2Text = string.Format(UI.Checking_sector_0_of_1_on_track_2,
|
|
|
|
|
all,
|
|
|
|
|
_inputFormat.Info.Sectors,
|
|
|
|
|
currentTrack.Sequence);
|
2020-04-13 01:19:55 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
List<ulong> tempFailingLbas;
|
|
|
|
|
List<ulong> tempUnknownLbas;
|
|
|
|
|
|
|
|
|
|
if(remainingSectors < 512)
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
inputOptical.VerifySectors(currentSector,
|
|
|
|
|
(uint)remainingSectors,
|
|
|
|
|
currentTrack.Sequence,
|
|
|
|
|
out tempFailingLbas,
|
|
|
|
|
out tempUnknownLbas);
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
else
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
inputOptical.VerifySectors(currentSector,
|
|
|
|
|
512,
|
|
|
|
|
currentTrack.Sequence,
|
|
|
|
|
out tempFailingLbas,
|
2022-03-07 07:36:44 +00:00
|
|
|
out tempUnknownLbas);
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2020-04-13 01:19:55 +01:00
|
|
|
|
|
|
|
|
failingLbas.AddRange(tempFailingLbas);
|
|
|
|
|
|
|
|
|
|
unknownLbas.AddRange(tempUnknownLbas);
|
|
|
|
|
|
|
|
|
|
if(remainingSectors < 512)
|
|
|
|
|
{
|
|
|
|
|
currentSector += remainingSectors;
|
2022-03-06 13:29:38 +00:00
|
|
|
currentSectorAll += remainingSectors;
|
2020-04-13 01:19:55 +01:00
|
|
|
remainingSectors = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentSector += 512;
|
2022-03-06 13:29:38 +00:00
|
|
|
currentSectorAll += 512;
|
2020-04-13 01:19:55 +01:00
|
|
|
remainingSectors -= 512;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Stop();
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2022-11-14 01:20:28 +00:00
|
|
|
else if(verifiableSectorsImage is not null)
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
ulong remainingSectors = _inputFormat.Info.Sectors;
|
|
|
|
|
ulong currentSector = 0;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Restart();
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
while(remainingSectors > 0)
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(_cancel)
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
CloseVisible = true;
|
|
|
|
|
StartVisible = false;
|
|
|
|
|
StopVisible = false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ulong sector = currentSector;
|
|
|
|
|
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Progress2Value = (int)(sector / 512);
|
2022-11-19 21:10:41 +00:00
|
|
|
Progress2Text = string.Format(UI.Checking_sector_0_of_1, sector, _inputFormat.Info.Sectors);
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
List<ulong> tempFailingLbas;
|
|
|
|
|
List<ulong> tempUnknownLbas;
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(remainingSectors < 512)
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
verifiableSectorsImage.VerifySectors(currentSector,
|
|
|
|
|
(uint)remainingSectors,
|
|
|
|
|
out tempFailingLbas,
|
2022-03-07 07:36:44 +00:00
|
|
|
out tempUnknownLbas);
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
else
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
verifiableSectorsImage.VerifySectors(currentSector,
|
|
|
|
|
512,
|
|
|
|
|
out tempFailingLbas,
|
2022-03-06 13:29:38 +00:00
|
|
|
out tempUnknownLbas);
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
failingLbas.AddRange(tempFailingLbas);
|
|
|
|
|
|
|
|
|
|
unknownLbas.AddRange(tempUnknownLbas);
|
|
|
|
|
|
|
|
|
|
if(remainingSectors < 512)
|
|
|
|
|
{
|
|
|
|
|
currentSector += remainingSectors;
|
|
|
|
|
remainingSectors = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentSector += 512;
|
|
|
|
|
remainingSectors -= 512;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Stop();
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-26 03:39:10 +01:00
|
|
|
AaruConsole.VerboseWriteLine(UI.Checking_sector_checksums_took_0,
|
2023-09-26 20:16:24 +01:00
|
|
|
chkStopwatch.Elapsed.Humanize(minUnit: TimeUnit.Second));
|
2020-04-13 01:19:55 +01:00
|
|
|
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
if(failingLbas.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if(failingLbas.Count == (int)_inputFormat.Info.Sectors)
|
|
|
|
|
{
|
|
|
|
|
SectorsErrorsAllVisible = true;
|
2022-11-19 21:10:41 +00:00
|
|
|
SectorsErrorsAllText = UI.All_sectors_contain_errors;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-19 21:10:41 +00:00
|
|
|
SectorErrorsText = UI.LBAs_with_error;
|
2022-03-06 13:29:38 +00:00
|
|
|
SectorErrorsVisible = true;
|
|
|
|
|
|
|
|
|
|
foreach(ulong t in failingLbas)
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
ErrorList.Add(new LbaModel
|
|
|
|
|
{
|
|
|
|
|
Lba = t.ToString()
|
|
|
|
|
});
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(unknownLbas.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if(unknownLbas.Count == (int)_inputFormat.Info.Sectors)
|
|
|
|
|
{
|
|
|
|
|
SectorsUnknownAllVisible = true;
|
2022-11-19 21:10:41 +00:00
|
|
|
SectorsUnknownAllText = UI.All_sectors_are_unknown;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-11-19 21:10:41 +00:00
|
|
|
SectorsUnknownsText = UI.Unknown_LBAs;
|
2022-03-06 13:29:38 +00:00
|
|
|
SectorsUnknownsVisible = true;
|
|
|
|
|
|
|
|
|
|
foreach(ulong t in unknownLbas)
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
UnknownList.Add(new LbaModel
|
|
|
|
|
{
|
|
|
|
|
Lba = t.ToString()
|
|
|
|
|
});
|
2023-10-03 23:27:57 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SectorSummaryVisible = true;
|
2023-10-03 23:27:57 +01:00
|
|
|
TotalSectorsText = string.Format(UI.Total_sectors, _inputFormat.Info.Sectors);
|
|
|
|
|
TotalSectorErrorsText = string.Format(UI.Total_errors, failingLbas.Count);
|
2022-11-19 21:10:41 +00:00
|
|
|
TotalSectorUnknownsText = string.Format(UI.Total_unknowns, unknownLbas.Count);
|
2022-03-06 13:29:38 +00:00
|
|
|
|
2022-11-19 21:10:41 +00:00
|
|
|
TotalSectorErrorsUnknownsText =
|
|
|
|
|
string.Format(UI.Total_errors_plus_unknowns, failingLbas.Count + unknownLbas.Count);
|
2020-04-13 01:19:55 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Statistics.AddCommand("verify");
|
2020-04-13 01:19:55 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-13 01:19:55 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
OptionsVisible = false;
|
|
|
|
|
ResultsVisible = true;
|
|
|
|
|
ProgressVisible = false;
|
|
|
|
|
StartVisible = false;
|
|
|
|
|
StopVisible = false;
|
|
|
|
|
CloseVisible = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ExecuteCloseCommand() => _view.Close();
|
|
|
|
|
|
|
|
|
|
internal void ExecuteStopCommand()
|
|
|
|
|
{
|
|
|
|
|
_cancel = true;
|
|
|
|
|
StopEnabled = false;
|
2020-04-13 01:19:55 +01:00
|
|
|
}
|
|
|
|
|
}
|