2020-04-17 21:45:50 +01:00
|
|
|
// /***************************************************************************
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : MediaScanViewModel.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// View model and code for the media scan 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-17 05:23:17 +01:00
|
|
|
using System.Collections.ObjectModel;
|
2022-11-14 01:38:50 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-04-16 03:18:10 +01:00
|
|
|
using System.Threading;
|
2022-03-26 16:52:00 +00:00
|
|
|
using System.Threading.Tasks;
|
2025-08-20 21:19:43 +01:00
|
|
|
using System.Windows.Input;
|
2020-04-16 03:18:10 +01:00
|
|
|
using Aaru.Core;
|
|
|
|
|
using Aaru.Core.Devices.Scanning;
|
|
|
|
|
using Aaru.Devices;
|
2022-11-19 21:10:41 +00:00
|
|
|
using Aaru.Localization;
|
2020-04-16 03:18:10 +01:00
|
|
|
using Avalonia.Controls;
|
2020-04-17 19:09:09 +01:00
|
|
|
using Avalonia.Media;
|
2020-04-16 03:18:10 +01:00
|
|
|
using Avalonia.Threading;
|
2025-08-20 21:19:43 +01:00
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2023-09-26 02:40:11 +01:00
|
|
|
using Humanizer;
|
|
|
|
|
using Humanizer.Bytes;
|
2023-09-26 03:39:10 +01:00
|
|
|
using Humanizer.Localisation;
|
2023-09-26 01:29:07 +01:00
|
|
|
using MsBox.Avalonia;
|
|
|
|
|
using MsBox.Avalonia.Enums;
|
|
|
|
|
|
2023-09-25 22:58:48 +01:00
|
|
|
//using OxyPlot;
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Gui.ViewModels.Windows;
|
|
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
public sealed partial class MediaScanViewModel : ViewModelBase
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
2025-11-19 23:09:43 +00:00
|
|
|
readonly Device _device;
|
2022-03-06 13:29:38 +00:00
|
|
|
readonly Window _view;
|
2025-08-20 21:19:43 +01:00
|
|
|
[ObservableProperty]
|
|
|
|
|
string _a;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _avgSpeed;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
Color _axesColor;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _b;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
ulong _blocks;
|
|
|
|
|
ulong _blocksToRead;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _c;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _closeVisible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _d;
|
2025-11-19 23:09:43 +00:00
|
|
|
readonly string _devicePath;
|
2025-08-20 21:19:43 +01:00
|
|
|
[ObservableProperty]
|
|
|
|
|
string _e;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _f;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
Color _lineColor;
|
|
|
|
|
ScanResults _localResults;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _maxSpeed;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _maxX;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _maxY;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _minSpeed;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _minX;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _minY;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _progress1Visible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progress2Indeterminate;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progress2MaxValue;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progress2Text;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progress2Value;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progress2Visible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _progressIndeterminate;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _progressMaxValue;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _progressText;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _progressValue;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _progressVisible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _resultsVisible;
|
|
|
|
|
MediaScan _scanner;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _startVisible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _stepsX;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
double _stepsY;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _stopEnabled;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
bool _stopVisible;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _totalTime;
|
|
|
|
|
[ObservableProperty]
|
|
|
|
|
string _unreadableSectors;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
2025-11-19 23:09:43 +00:00
|
|
|
public MediaScanViewModel(Device device, string devicePath, Window view)
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
2025-11-19 23:09:43 +00:00
|
|
|
_device = device;
|
2022-03-06 13:29:38 +00:00
|
|
|
_devicePath = devicePath;
|
|
|
|
|
_view = view;
|
|
|
|
|
StopVisible = false;
|
2025-08-20 21:19:43 +01:00
|
|
|
StartCommand = new RelayCommand(Start);
|
|
|
|
|
CloseCommand = new RelayCommand(Close);
|
|
|
|
|
StopCommand = new RelayCommand(Stop);
|
2022-03-06 13:29:38 +00:00
|
|
|
StartVisible = true;
|
|
|
|
|
CloseVisible = true;
|
2024-05-01 04:39:38 +01:00
|
|
|
BlockMapList = [];
|
2024-05-01 04:05:22 +01:00
|
|
|
|
2023-09-25 22:58:48 +01:00
|
|
|
// ChartPoints = new ObservableCollection<DataPoint>();
|
2023-10-03 23:27:57 +01:00
|
|
|
StepsX = double.NaN;
|
|
|
|
|
StepsY = double.NaN;
|
|
|
|
|
AxesColor = Colors.Black;
|
|
|
|
|
LineColor = Colors.Yellow;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2020-04-17 05:23:17 +01:00
|
|
|
|
2022-11-19 21:10:41 +00:00
|
|
|
public string SpeedLabel => UI.ButtonLabel_Stop;
|
|
|
|
|
public string KbsLabel => UI.Kb_s;
|
|
|
|
|
public string BlockLabel => UI.Title_Block;
|
2022-11-16 21:40:54 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public ObservableCollection<(ulong block, double duration)> BlockMapList { get; }
|
2024-05-01 04:05:22 +01:00
|
|
|
|
2023-09-25 22:58:48 +01:00
|
|
|
// public ObservableCollection<DataPoint> ChartPoints { get; }
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string Title { get; }
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
public ICommand StartCommand { get; }
|
|
|
|
|
public ICommand CloseCommand { get; }
|
|
|
|
|
public ICommand StopCommand { get; }
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
void Close() => _view.Close();
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
internal void Stop() => _scanner?.Abort();
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2025-08-20 21:19:43 +01:00
|
|
|
void Start()
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
StopVisible = true;
|
|
|
|
|
StartVisible = false;
|
|
|
|
|
CloseVisible = false;
|
|
|
|
|
ProgressVisible = true;
|
|
|
|
|
ResultsVisible = true;
|
2024-05-01 04:05:22 +01:00
|
|
|
|
2023-09-25 22:58:48 +01:00
|
|
|
// ChartPoints.Clear();
|
2022-03-06 13:29:38 +00:00
|
|
|
new Thread(DoWork).Start();
|
|
|
|
|
}
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: Allow to save MHDD and ImgBurn log files
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void DoWork()
|
|
|
|
|
{
|
|
|
|
|
_localResults = new ScanResults();
|
2025-11-19 23:09:43 +00:00
|
|
|
_scanner = new MediaScan(null, null, _devicePath, _device, false);
|
2022-03-06 13:29:38 +00:00
|
|
|
_scanner.ScanTime += OnScanTime;
|
|
|
|
|
_scanner.ScanUnreadable += OnScanUnreadable;
|
|
|
|
|
_scanner.UpdateStatus += UpdateStatus;
|
|
|
|
|
_scanner.StoppingErrorMessage += StoppingErrorMessage;
|
|
|
|
|
_scanner.PulseProgress += PulseProgress;
|
|
|
|
|
_scanner.InitProgress += InitProgress;
|
|
|
|
|
_scanner.UpdateProgress += UpdateProgress;
|
|
|
|
|
_scanner.EndProgress += EndProgress;
|
|
|
|
|
_scanner.InitBlockMap += InitBlockMap;
|
|
|
|
|
_scanner.ScanSpeed += ScanSpeed;
|
|
|
|
|
|
|
|
|
|
ScanResults results = _scanner.Scan();
|
|
|
|
|
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2023-09-26 03:39:10 +01:00
|
|
|
TotalTime = string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands,
|
|
|
|
|
results.TotalTime.Seconds().Humanize(minUnit: TimeUnit.Second),
|
|
|
|
|
results.ProcessingTime.Seconds().Humanize(minUnit: TimeUnit.Second));
|
2022-11-19 21:10:41 +00:00
|
|
|
|
2023-09-26 02:40:11 +01:00
|
|
|
AvgSpeed = string.Format(Localization.Core.Average_speed_0,
|
2025-11-19 23:10:17 +00:00
|
|
|
ByteSize.FromMegabytes(results.AvgSpeed).Per(1.Seconds()).Humanize());
|
2023-09-26 02:40:11 +01:00
|
|
|
|
|
|
|
|
MaxSpeed = string.Format(Localization.Core.Fastest_speed_burst_0,
|
2025-11-19 23:10:17 +00:00
|
|
|
ByteSize.FromMegabytes(results.MaxSpeed).Per(1.Seconds()).Humanize());
|
2023-09-26 02:40:11 +01:00
|
|
|
|
|
|
|
|
MinSpeed = string.Format(Localization.Core.Slowest_speed_burst_0,
|
2025-11-19 23:10:17 +00:00
|
|
|
ByteSize.FromMegabytes(results.MinSpeed).Per(1.Seconds()).Humanize());
|
2023-09-26 02:40:11 +01:00
|
|
|
|
2023-10-03 23:27:57 +01:00
|
|
|
A = string.Format(Localization.Core._0_sectors_took_less_than_3_ms, results.A);
|
|
|
|
|
B = string.Format(Localization.Core._0_sectors_took_less_than_10_ms_but_more_than_3_ms, results.B);
|
|
|
|
|
C = string.Format(Localization.Core._0_sectors_took_less_than_50_ms_but_more_than_10_ms, results.C);
|
|
|
|
|
D = string.Format(Localization.Core._0_sectors_took_less_than_150_ms_but_more_than_50_ms, results.D);
|
2022-11-19 21:10:41 +00:00
|
|
|
E = string.Format(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, results.E);
|
2023-10-03 23:27:57 +01:00
|
|
|
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, results.F);
|
2022-11-19 21:10:41 +00:00
|
|
|
|
|
|
|
|
UnreadableSectors = string.Format(Localization.Core._0_sectors_could_not_be_read,
|
|
|
|
|
results.UnreadableSectors.Count);
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: Show list of unreadable sectors
|
|
|
|
|
/*
|
|
|
|
|
if(results.UnreadableSectors.Count > 0)
|
|
|
|
|
foreach(ulong bad in results.UnreadableSectors)
|
|
|
|
|
string.Format("Sector {0} could not be read", bad);
|
2020-04-16 03:18:10 +01:00
|
|
|
*/
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: Show results
|
|
|
|
|
/*
|
2022-12-03 16:07:10 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(results.SeekTotal != 0 || results.SeekMin != double.MaxValue || results.SeekMax != double.MinValue)
|
2022-12-03 16:07:10 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
string.Format("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
|
|
|
|
|
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
|
|
|
|
|
*/
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
Statistics.AddCommand("media-scan");
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
await WorkFinished();
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void ScanSpeed(ulong sector, double currentSpeed) => await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
2023-09-25 22:58:48 +01:00
|
|
|
/* TODO: Abandoned project need to find replacement
|
2022-03-06 13:29:38 +00:00
|
|
|
if(ChartPoints.Count == 0)
|
|
|
|
|
ChartPoints.Add(new DataPoint(0, currentSpeed));
|
2020-04-17 19:09:09 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
ChartPoints.Add(new DataPoint(sector, currentSpeed));
|
2023-09-25 22:58:48 +01:00
|
|
|
*/
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
if(currentSpeed > MaxY) MaxY = currentSpeed + currentSpeed / 10d;
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void InitBlockMap(ulong blocks, ulong blockSize, ulong blocksToRead, ushort currentProfile) =>
|
|
|
|
|
await Dispatcher.UIThread.InvokeAsync(() =>
|
2020-04-16 03:18:10 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Blocks = blocks / blocksToRead;
|
|
|
|
|
_blocksToRead = blocksToRead;
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
MinX = 0;
|
|
|
|
|
MinY = 0;
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
switch(currentProfile)
|
2020-04-16 03:18:10 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
case 0x0005: // CD and DDCD
|
|
|
|
|
case 0x0008:
|
|
|
|
|
case 0x0009:
|
|
|
|
|
case 0x000A:
|
|
|
|
|
case 0x0020:
|
|
|
|
|
case 0x0021:
|
|
|
|
|
case 0x0022:
|
2022-11-13 19:59:24 +00:00
|
|
|
MaxX = blocks switch
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
|
|
|
|
<= 360000 => 360000,
|
|
|
|
|
<= 405000 => 405000,
|
|
|
|
|
<= 445500 => 445500,
|
|
|
|
|
_ => blocks
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 150 * 4;
|
|
|
|
|
MaxY = StepsY * 12.5;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 0x0010: // DVD SL
|
|
|
|
|
case 0x0011:
|
|
|
|
|
case 0x0012:
|
|
|
|
|
case 0x0013:
|
|
|
|
|
case 0x0014:
|
|
|
|
|
case 0x0018:
|
|
|
|
|
case 0x001A:
|
|
|
|
|
case 0x001B:
|
|
|
|
|
MaxX = 2298496;
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 1352.5;
|
|
|
|
|
MaxY = StepsY * 18;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 0x0015: // DVD DL
|
|
|
|
|
case 0x0016:
|
|
|
|
|
case 0x0017:
|
|
|
|
|
case 0x002A:
|
|
|
|
|
case 0x002B:
|
|
|
|
|
MaxX = 4173824;
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 1352.5;
|
|
|
|
|
MaxY = StepsY * 18;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 0x0041:
|
|
|
|
|
case 0x0042:
|
|
|
|
|
case 0x0043:
|
|
|
|
|
case 0x0040: // BD
|
2022-11-13 19:59:24 +00:00
|
|
|
MaxX = blocks switch
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
|
|
|
|
<= 12219392 => 12219392,
|
|
|
|
|
<= 24438784 => 24438784,
|
|
|
|
|
<= 48878592 => 48878592,
|
|
|
|
|
<= 62500864 => 62500864,
|
|
|
|
|
_ => blocks
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 4394.5;
|
|
|
|
|
MaxY = StepsY * 18;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case 0x0050: // HD DVD
|
|
|
|
|
case 0x0051:
|
|
|
|
|
case 0x0052:
|
|
|
|
|
case 0x0053:
|
|
|
|
|
case 0x0058:
|
|
|
|
|
case 0x005A:
|
2022-11-13 19:59:24 +00:00
|
|
|
MaxX = blocks switch
|
2023-10-03 23:27:57 +01:00
|
|
|
{
|
|
|
|
|
<= 7361599 => 7361599,
|
|
|
|
|
<= 16305407 => 16305407,
|
|
|
|
|
_ => blocks
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 4394.5;
|
|
|
|
|
MaxY = StepsY * 8;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
MaxX = blocks;
|
|
|
|
|
StepsX = MaxX / 10;
|
|
|
|
|
StepsY = 625;
|
|
|
|
|
MaxY = StepsY;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task WorkFinished() => await Dispatcher.UIThread.InvokeAsync(() =>
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
StopVisible = false;
|
|
|
|
|
StartVisible = true;
|
|
|
|
|
CloseVisible = true;
|
|
|
|
|
ProgressVisible = false;
|
|
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2023-10-03 23:27:57 +01:00
|
|
|
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = false; });
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-07 07:36:44 +00:00
|
|
|
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
ProgressText = text;
|
|
|
|
|
ProgressIndeterminate = false;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
ProgressMaxValue = maximum;
|
|
|
|
|
ProgressValue = current;
|
|
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2023-10-03 23:27:57 +01:00
|
|
|
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = true; });
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void PulseProgress(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
ProgressText = text;
|
|
|
|
|
ProgressIndeterminate = true;
|
|
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-11-15 01:35:06 +00:00
|
|
|
|
|
|
|
|
// ReSharper disable once AsyncVoidLambda
|
2023-09-25 22:58:48 +01:00
|
|
|
async void StoppingErrorMessage(string text) => await Dispatcher.UIThread.InvokeAsync(async () =>
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
ProgressText = text;
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error)
|
|
|
|
|
.ShowWindowDialogAsync(_view);
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-15 01:35:06 +00:00
|
|
|
await WorkFinished();
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2023-10-03 23:27:57 +01:00
|
|
|
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() => { ProgressText = text; });
|
2022-03-06 13:29:38 +00:00
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void OnScanUnreadable(ulong sector) => await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
_localResults.Errored += _blocksToRead;
|
2022-11-19 21:10:41 +00:00
|
|
|
UnreadableSectors = string.Format(Localization.Core._0_sectors_could_not_be_read, _localResults.Errored);
|
2022-03-06 13:29:38 +00:00
|
|
|
BlockMapList.Add((sector / _blocksToRead, double.NaN));
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-14 01:38:50 +00:00
|
|
|
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
|
2022-03-06 13:29:38 +00:00
|
|
|
async void OnScanTime(ulong sector, double duration) => await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
{
|
|
|
|
|
BlockMapList.Add((sector / _blocksToRead, duration));
|
|
|
|
|
|
2022-11-13 19:38:03 +00:00
|
|
|
switch(duration)
|
|
|
|
|
{
|
|
|
|
|
case < 3:
|
|
|
|
|
_localResults.A += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case >= 3 and < 10:
|
|
|
|
|
_localResults.B += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case >= 10 and < 50:
|
|
|
|
|
_localResults.C += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case >= 50 and < 150:
|
|
|
|
|
_localResults.D += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case >= 150 and < 500:
|
|
|
|
|
_localResults.E += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case >= 500:
|
|
|
|
|
_localResults.F += _blocksToRead;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
2023-10-03 23:27:57 +01:00
|
|
|
A = string.Format(Localization.Core._0_sectors_took_less_than_3_ms, _localResults.A);
|
|
|
|
|
B = string.Format(Localization.Core._0_sectors_took_less_than_10_ms_but_more_than_3_ms, _localResults.B);
|
|
|
|
|
C = string.Format(Localization.Core._0_sectors_took_less_than_50_ms_but_more_than_10_ms, _localResults.C);
|
|
|
|
|
D = string.Format(Localization.Core._0_sectors_took_less_than_150_ms_but_more_than_50_ms, _localResults.D);
|
2022-11-19 21:10:41 +00:00
|
|
|
E = string.Format(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, _localResults.E);
|
2023-10-03 23:27:57 +01:00
|
|
|
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, _localResults.F);
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2020-04-16 03:18:10 +01:00
|
|
|
}
|