[Aaru.Gui] Reformat and cleanup.

This commit is contained in:
2023-10-03 23:27:57 +01:00
parent 0bcfdb28cb
commit 6ffde343ce
183 changed files with 10346 additions and 10135 deletions

View File

@@ -77,11 +77,13 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase
ErrorNumber errno = inputFormat.ReadMediaTag(tag, out byte[] data);
if(errno == ErrorNumber.NoError)
{
TagsList.Add(new MediaTagModel
{
Tag = tag,
Data = data
});
}
}
}
@@ -217,7 +219,8 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase
break;
case MediaTagType.Xbox_DMI:
DecodedText = DMI.IsXbox360(value.Data) ? DMI.PrettifyXbox360(value.Data)
DecodedText = DMI.IsXbox360(value.Data)
? DMI.PrettifyXbox360(value.Data)
: DMI.PrettifyXbox(value.Data);
break;

View File

@@ -395,10 +395,11 @@ public sealed class ImageChecksumViewModel : ViewModelBase
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork()
{
var opticalMediaImage = _inputFormat as IOpticalMediaImage;
bool formatHasTracks = false;
var opticalMediaImage = _inputFormat as IOpticalMediaImage;
var formatHasTracks = false;
if(opticalMediaImage != null)
{
try
{
formatHasTracks = opticalMediaImage.Tracks?.Count > 0;
@@ -407,6 +408,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
{
formatHasTracks = false;
}
}
// Setup progress bars
await Dispatcher.UIThread.InvokeAsync(() =>
@@ -470,6 +472,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
ErrorNumber errno;
if(opticalMediaImage?.Tracks != null)
{
try
{
Checksum trackChecksum = null;
@@ -490,6 +493,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
});
if(currentTrack.StartSector - previousTrackEnd != 0 && ChecksumMediaChecked)
{
for(ulong i = previousTrackEnd + 1; i < currentTrack.StartSector; i++)
{
ulong sector = i;
@@ -514,6 +518,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
mediaChecksum?.Update(hiddenSector);
}
}
AaruConsole.DebugWriteLine(MODULE_NAME, UI.Track_0_starts_at_sector_1_and_ends_at_sector_2,
currentTrack.Sequence, currentTrack.StartSector, currentTrack.EndSector);
@@ -612,18 +617,21 @@ public sealed class ImageChecksumViewModel : ViewModelBase
return;
foreach(CommonTypes.AaruMetadata.Checksum chk in trackChecksum.End())
{
TrackChecksums.Add(new ChecksumModel
{
Track = currentTrack.Sequence.ToString(),
Algorithm = chk.Type.ToString(),
Hash = chk.Value
});
}
});
previousTrackEnd = currentTrack.EndSector;
}
if(opticalMediaImage.Info.Sectors - previousTrackEnd != 0 && ChecksumMediaChecked)
{
for(ulong i = previousTrackEnd + 1; i < opticalMediaImage.Info.Sectors; i++)
{
ulong sector = i;
@@ -648,6 +656,7 @@ public sealed class ImageChecksumViewModel : ViewModelBase
mediaChecksum?.Update(hiddenSector);
}
}
await Dispatcher.UIThread.InvokeAsync(() =>
{
@@ -655,11 +664,13 @@ public sealed class ImageChecksumViewModel : ViewModelBase
return;
foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
{
MediaChecksums.Add(new ChecksumModel
{
Algorithm = chk.Type.ToString(),
Hash = chk.Value
});
}
});
}
catch(Exception ex)
@@ -667,12 +678,10 @@ public sealed class ImageChecksumViewModel : ViewModelBase
AaruConsole.DebugWriteLine(Localization.Core.Could_not_get_tracks_because_0, ex.Message);
AaruConsole.WriteLine("Unable to get separate tracks, not checksumming them");
}
}
else
{
await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = false; });
mediaChecksum = new Checksum(enabledChecksums);
@@ -755,25 +764,25 @@ public sealed class ImageChecksumViewModel : ViewModelBase
await Dispatcher.UIThread.InvokeAsync(() =>
{
foreach(CommonTypes.AaruMetadata.Checksum chk in mediaChecksum.End())
{
MediaChecksums.Add(new ChecksumModel
{
Algorithm = chk.Type.ToString(),
Hash = chk.Value
});
}
});
}
if(ChecksumTracksChecked)
await Dispatcher.UIThread.InvokeAsync(() =>
{
TrackChecksumsVisible = true;
});
{
await Dispatcher.UIThread.InvokeAsync(() => { TrackChecksumsVisible = true; });
}
if(ChecksumMediaChecked)
await Dispatcher.UIThread.InvokeAsync(() =>
{
MediaChecksumsVisible = true;
});
{
await Dispatcher.UIThread.InvokeAsync(() => { MediaChecksumsVisible = true; });
}
Statistics.AddCommand("checksum");

View File

@@ -67,10 +67,9 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _cancel;
Metadata _aaruMetadata;
bool _aaruMetadataFromImageVisible;
string _metadataJsonText;
bool _cancel;
bool _closeVisible;
string _commentsText;
bool _commentsVisible;
@@ -106,6 +105,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
bool _mediaSerialNumberVisible;
string _mediaTitleText;
bool _mediaTitleVisible;
string _metadataJsonText;
bool _optionsVisible;
bool _progress1Visible;
bool _progress2Indeterminate;
@@ -128,35 +128,8 @@ public sealed class ImageConvertViewModel : ViewModelBase
bool _stopVisible;
string _title;
public string SourceImageLabel => UI.Source_image;
public string OutputFormatLabel => UI.Output_format;
public string ChooseLabel => UI.ButtonLabel_Choose;
public string SectorsLabel => UI.How_many_sectors_to_convert_at_once;
public string ForceLabel => UI.Continue_conversion_even_if_data_lost;
public string CreatorLabel => UI.Who_person_created_the_image;
public string GetFromSourceImageLabel => UI.ButtonLabel_Get_from_source_image;
public string MetadataLabel => UI.Title_Metadata;
public string MediaLabel => UI.Title_Media;
public string TitleLabel => UI.Title_Title;
public string ManufacturerLabel => UI.Title_Manufacturer;
public string ModelLabel => UI.Title_Model;
public string SerialNumberLabel => UI.Title_Serial_number;
public string BarcodeLabel => UI.Title_Barcode;
public string PartNumberLabel => UI.Title_Part_number;
public string NumberInSequenceLabel => UI.Title_Number_in_sequence;
public string LastMediaOfTheSequenceLabel => UI.Title_Last_media_of_the_sequence;
public string DriveLabel => UI.Title_Drive;
public string FirmwareRevisionLabel => UI.Title_Firmware_revision;
public string CommentsLabel => UI.Title_Comments;
public string AaruMetadataLabel => UI.Title_Existing_Aaru_Metadata_sidecar;
public string FromImageLabel => UI.Title_From_image;
public string ResumeFileLabel => UI.Title_Existing_resume_file;
public string StartLabel => UI.ButtonLabel_Start;
public string CloseLabel => UI.ButtonLabel_Close;
public string StopLabel => UI.ButtonLabel_Stop;
public ImageConvertViewModel([JetBrains.Annotations.NotNull] IMediaImage inputFormat, string imageSource,
Window view)
Window view)
{
_view = view;
_inputFormat = inputFormat;
@@ -207,10 +180,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
continue;
if(plugin.SupportedMediaTypes.Contains(inputFormat.Info.MediaType))
{
PluginsList.Add(new ImagePluginModel
{
Plugin = plugin
});
}
}
AaruMetadataFromImageVisible = inputFormat.AaruMetadata != null;
@@ -223,6 +198,33 @@ public sealed class ImageConvertViewModel : ViewModelBase
ResumeFileText = _dumpHardware == null ? "" : UI._From_image_;
}
public string SourceImageLabel => UI.Source_image;
public string OutputFormatLabel => UI.Output_format;
public string ChooseLabel => UI.ButtonLabel_Choose;
public string SectorsLabel => UI.How_many_sectors_to_convert_at_once;
public string ForceLabel => UI.Continue_conversion_even_if_data_lost;
public string CreatorLabel => UI.Who_person_created_the_image;
public string GetFromSourceImageLabel => UI.ButtonLabel_Get_from_source_image;
public string MetadataLabel => UI.Title_Metadata;
public string MediaLabel => UI.Title_Media;
public string TitleLabel => UI.Title_Title;
public string ManufacturerLabel => UI.Title_Manufacturer;
public string ModelLabel => UI.Title_Model;
public string SerialNumberLabel => UI.Title_Serial_number;
public string BarcodeLabel => UI.Title_Barcode;
public string PartNumberLabel => UI.Title_Part_number;
public string NumberInSequenceLabel => UI.Title_Number_in_sequence;
public string LastMediaOfTheSequenceLabel => UI.Title_Last_media_of_the_sequence;
public string DriveLabel => UI.Title_Drive;
public string FirmwareRevisionLabel => UI.Title_Firmware_revision;
public string CommentsLabel => UI.Title_Comments;
public string AaruMetadataLabel => UI.Title_Existing_Aaru_Metadata_sidecar;
public string FromImageLabel => UI.Title_From_image;
public string ResumeFileLabel => UI.Title_Existing_resume_file;
public string StartLabel => UI.ButtonLabel_Start;
public string CloseLabel => UI.ButtonLabel_Close;
public string StopLabel => UI.ButtonLabel_Stop;
public string Title
{
get => _title;
@@ -606,7 +608,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void DoWork(object plugin)
{
bool warning = false;
var warning = false;
if(plugin is not IWritableImage outputFormat)
{
@@ -714,13 +716,15 @@ public sealed class ImageConvertViewModel : ViewModelBase
foreach(MediaTagType mediaTag in _inputFormat.Info.ReadableMediaTags.Where(mediaTag =>
!outputFormat.SupportedMediaTags.Contains(mediaTag) && !ForceChecked))
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Converting_image_will_lose_media_tag_0,
mediaTag),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Converting_image_will_lose_media_tag_0,
mediaTag),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
return;
}
@@ -740,13 +744,15 @@ public sealed class ImageConvertViewModel : ViewModelBase
continue;
}
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Converting_image_will_lose_sector_tag_0,
sectorTag),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Converting_image_will_lose_sector_tag_0,
sectorTag),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
return;
}
@@ -795,14 +801,14 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputFormat.Create(DestinationText, _inputFormat.Info.MediaType, parsedOptions, _inputFormat.Info.Sectors,
_inputFormat.Info.SectorSize))
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_creating_output_image,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_creating_output_image,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_creating_output_image, outputFormat.ErrorMessage);
@@ -838,18 +844,21 @@ public sealed class ImageConvertViewModel : ViewModelBase
};
if(!_cancel)
{
if(!outputFormat.SetImageInfo(metadata))
{
if(ForceChecked != true)
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_setting_metadata_not_continuing,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_setting_metadata_not_continuing,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_setting_metadata_not_continuing, outputFormat.ErrorMessage);
@@ -859,6 +868,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
warning = true;
AaruConsole.ErrorWriteLine(Localization.Core.Error_0_setting_metadata, outputFormat.ErrorMessage);
}
}
if(tracks != null &&
!_cancel &&
@@ -874,14 +884,16 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputOptical.SetTracks(tracks))
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_sending_tracks_list_to_output_image,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_sending_tracks_list_to_output_image,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_sending_tracks_list_to_output_image, outputFormat.ErrorMessage);
@@ -923,11 +935,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
if(errno == ErrorNumber.NoError)
{
await Dispatcher.UIThread.InvokeAsync(action: async () =>
await Dispatcher.UIThread.InvokeAsync(async () =>
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_media_tag_not_continuing,
Format(
UI.
Error_0_writing_media_tag_not_continuing,
outputFormat.ErrorMessage),
icon: Icon.Error).ShowWindowDialogAsync(_view));
@@ -935,11 +949,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () =>
await Dispatcher.UIThread.InvokeAsync(async () =>
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_media_tag_not_continuing,
Format(
UI.
Error_0_reading_media_tag_not_continuing,
errno), icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1012,12 +1028,16 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(useLong)
{
errno = sectorsToDo == 1 ? _inputFormat.ReadSectorLong(doneSectors, out sector)
errno = sectorsToDo == 1
? _inputFormat.ReadSectorLong(doneSectors, out sector)
: _inputFormat.ReadSectorsLong(doneSectors, sectorsToDo, out sector);
if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1 ? outputFormat.WriteSectorLong(sector, doneSectors)
{
result = sectorsToDo == 1
? outputFormat.WriteSectorLong(sector, doneSectors)
: outputFormat.WriteSectorsLong(sector, doneSectors, sectorsToDo);
}
else
{
result = true;
@@ -1030,12 +1050,15 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, doneSectors);
@@ -1045,12 +1068,16 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
errno = sectorsToDo == 1 ? _inputFormat.ReadSector(doneSectors, out sector)
errno = sectorsToDo == 1
? _inputFormat.ReadSector(doneSectors, out sector)
: _inputFormat.ReadSectors(doneSectors, sectorsToDo, out sector);
if(errno == ErrorNumber.NoError)
result = sectorsToDo == 1 ? outputFormat.WriteSector(sector, doneSectors)
{
result = sectorsToDo == 1
? outputFormat.WriteSector(sector, doneSectors)
: outputFormat.WriteSectors(sector, doneSectors, sectorsToDo);
}
else
{
result = true;
@@ -1063,12 +1090,15 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_reading_sector_1_not_continuing, errno, doneSectors);
@@ -1078,6 +1108,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
if(!result)
{
if(ForceChecked)
{
warning = true;
@@ -1087,19 +1118,23 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_sector_1_not_continuing,
outputFormat.ErrorMessage,
doneSectors),
icon: Icon.Error).ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_writing_sector_1_not_continuing,
outputFormat.ErrorMessage,
doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
outputFormat.ErrorMessage, doneSectors);
return;
}
}
doneSectors += sectorsToDo;
}
@@ -1249,10 +1284,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1302,10 +1339,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1319,6 +1358,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
if(!result)
{
if(ForceChecked)
{
warning = true;
@@ -1328,20 +1368,24 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_sector_1_not_continuing,
outputFormat.
ErrorMessage,
doneSectors),
icon: Icon.Error).ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_writing_sector_1_not_continuing,
outputFormat.
ErrorMessage,
doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
AaruConsole.ErrorWriteLine(UI.Error_0_writing_sector_1_not_continuing,
outputFormat.ErrorMessage, doneSectors);
return;
}
}
doneSectors += sectorsToDo;
}
@@ -1355,16 +1399,21 @@ public sealed class ImageConvertViewModel : ViewModelBase
});
if(isrcs.Count > 0)
{
foreach(KeyValuePair<byte, string> isrc in isrcs)
{
outputOptical.WriteSectorTag(Encoding.UTF8.GetBytes(isrc.Value), isrc.Key,
SectorTagType.CdTrackIsrc);
}
}
if(trackFlags.Count > 0)
{
foreach(KeyValuePair<byte, byte> flags in trackFlags)
outputOptical.WriteSectorTag(new[]
{
flags.Value
}, flags.Key, SectorTagType.CdTrackFlags);
{
outputOptical.WriteSectorTag(new[] { flags.Value }, flags.Key, SectorTagType.CdTrackFlags);
}
}
if(mcn != null)
outputOptical.WriteMediaTag(Encoding.UTF8.GetBytes(mcn), MediaTagType.CD_MCN);
@@ -1423,10 +1472,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
out sector);
if(errno == ErrorNumber.NoError)
{
result = sectorsToDo == 1
? outputFormat.WriteSectorLong(sector, doneSectors + track.StartSector)
: outputFormat.WriteSectorsLong(sector, doneSectors + track.StartSector,
sectorsToDo);
}
else
{
result = true;
@@ -1439,10 +1490,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1453,15 +1506,18 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
errno = sectorsToDo == 1 ? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector)
errno = sectorsToDo == 1
? _inputFormat.ReadSector(doneSectors + track.StartSector, out sector)
: _inputFormat.ReadSectors(doneSectors + track.StartSector, sectorsToDo,
out sector);
if(errno == ErrorNumber.NoError)
{
result = sectorsToDo == 1
? outputFormat.WriteSector(sector, doneSectors + track.StartSector)
: outputFormat.WriteSectors(sector, doneSectors + track.StartSector,
sectorsToDo);
}
else
{
result = true;
@@ -1474,10 +1530,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_sector_1_not_continuing,
Format(
UI.
Error_0_reading_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1488,6 +1546,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
if(!result)
{
if(ForceChecked)
{
warning = true;
@@ -1497,17 +1556,21 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_sector_1_not_continuing,
outputFormat.
ErrorMessage,
doneSectors),
icon: Icon.Error).ShowWindowDialogAsync(_view));
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_writing_sector_1_not_continuing,
outputFormat.
ErrorMessage,
doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
return;
}
}
doneSectors += sectorsToDo;
}
@@ -1576,11 +1639,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () =>
await Dispatcher.UIThread.InvokeAsync(async () =>
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_media_tag_not_continuing,
Format(
UI.
Error_0_reading_media_tag_not_continuing,
errno),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1592,6 +1657,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
if(!result)
{
if(ForceChecked)
{
warning = true;
@@ -1601,11 +1667,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () =>
await Dispatcher.UIThread.InvokeAsync(async () =>
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_tag_not_continuing,
Format(
UI.
Error_0_writing_tag_not_continuing,
outputFormat.
ErrorMessage),
icon: Icon.Error).
@@ -1613,6 +1681,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
return;
}
}
continue;
}
@@ -1648,10 +1717,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
out sector);
if(errno == ErrorNumber.NoError)
{
result = sectorsToDo == 1
? outputFormat.WriteSectorTag(sector, doneSectors + track.StartSector, tag)
: outputFormat.WriteSectorsTag(sector, doneSectors + track.StartSector,
sectorsToDo, tag);
}
else
{
result = true;
@@ -1665,10 +1736,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_reading_tag_for_sector_1_not_continuing,
Format(
UI.
Error_0_reading_tag_for_sector_1_not_continuing,
errno, doneSectors),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
@@ -1678,6 +1751,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
if(!result)
{
if(ForceChecked)
{
warning = true;
@@ -1687,10 +1761,12 @@ public sealed class ImageConvertViewModel : ViewModelBase
}
else
{
await Dispatcher.UIThread.InvokeAsync(action: async () => await MessageBoxManager.
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_writing_tag_for_sector_1_not_continuing,
Format(
UI.
Error_0_writing_tag_for_sector_1_not_continuing,
outputFormat.
ErrorMessage,
doneSectors),
@@ -1699,6 +1775,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
return;
}
}
doneSectors += sectorsToDo;
}
@@ -1758,7 +1835,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error, UI.Operation_canceled_the_output_file_is_not_correct,
icon: Icon.Error).ShowWindowDialogAsync(_view);
icon: Icon.Error).ShowWindowDialogAsync(_view);
CloseVisible = true;
StopVisible = false;
@@ -1771,13 +1848,15 @@ public sealed class ImageConvertViewModel : ViewModelBase
if(!outputFormat.Close())
{
await Dispatcher.UIThread.InvokeAsync(async () => await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error,
string.
Format(UI.Error_0_closing_output_image_Contents_are_not_correct,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
GetMessageBoxStandard(UI.Title_Error,
string.
Format(
UI.
Error_0_closing_output_image_Contents_are_not_correct,
outputFormat.
ErrorMessage),
icon: Icon.Error).
ShowWindowDialogAsync(_view));
return;
}
@@ -1786,9 +1865,10 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
await MessageBoxManager.
GetMessageBoxStandard(warning ? UI.Title_Warning : UI.Title_Conversion_success,
warning ? UI.Some_warnings_happened_Check_console
: UI.Image_converted_successfully,
icon: warning ? Icon.Warning : Icon.Info).ShowWindowDialogAsync(_view);
warning
? UI.Some_warnings_happened_Check_console
: UI.Image_converted_successfully,
icon: warning ? Icon.Warning : Icon.Info).ShowWindowDialogAsync(_view);
CloseVisible = true;
StopVisible = false;
@@ -2018,11 +2098,8 @@ public sealed class ImageConvertViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
".json"
})
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[] { ".json" })
});
string[] result = await dlgMetadata.ShowAsync(_view);
@@ -2067,11 +2144,8 @@ public sealed class ImageConvertViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Choose_existing_resume_file,
Extensions = new List<string>(new[]
{
".json"
})
Name = UI.Dialog_Choose_existing_resume_file,
Extensions = new List<string>(new[] { ".json" })
});
string[] result = await dlgMetadata.ShowAsync(_view);
@@ -2096,9 +2170,11 @@ public sealed class ImageConvertViewModel : ViewModelBase
ResumeFileText = result[0];
}
else
{
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error, UI.Resume_file_does_not_contain_dump_hardware_information,
icon: Icon.Error).ShowWindowDialogAsync(_view);
}
}
catch
{

View File

@@ -291,6 +291,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
[JetBrains.Annotations.NotNull]
public string Title => UI.Title_Calculating_entropy;
public ObservableCollection<TrackEntropyModel> TrackEntropy { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
@@ -331,9 +332,11 @@ public sealed class ImageEntropyViewModel : ViewModelBase
AaruConsole.WriteLine(UI.Entropy_for_track_0_is_1, trackEntropy.Track, trackEntropy.Entropy);
if(trackEntropy.UniqueSectors != null)
{
AaruConsole.WriteLine(UI.Track_0_has_1_unique_sectors_2, trackEntropy.Track,
trackEntropy.UniqueSectors,
(double)trackEntropy.UniqueSectors / trackEntropy.Sectors);
}
}
}
@@ -358,7 +361,9 @@ public sealed class ImageEntropyViewModel : ViewModelBase
ResultsVisible = true;
if(SeparatedTracksChecked)
{
foreach(EntropyResults trackEntropy in _tracksEntropy)
{
TrackEntropy.Add(new TrackEntropyModel
{
Track = trackEntropy.Track.ToString(),
@@ -366,6 +371,8 @@ public sealed class ImageEntropyViewModel : ViewModelBase
UniqueSectors = $"{trackEntropy.UniqueSectors} ({
(trackEntropy.UniqueSectors ?? 0) / (double)trackEntropy.Sectors:P3})"
});
}
}
if(WholeDiscChecked != true)
return;

View File

@@ -79,7 +79,7 @@ public sealed class ImageSidecarViewModel : ViewModelBase
bool _stopVisible;
public ImageSidecarViewModel(IMediaImage inputFormat, string imageSource, Guid filterId, Encoding encoding,
Window view)
Window view)
{
_view = view;
_inputFormat = inputFormat;
@@ -275,10 +275,7 @@ public sealed class ImageSidecarViewModel : ViewModelBase
}
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
});
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { Progress2Visible = false; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -291,16 +288,10 @@ public sealed class ImageSidecarViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
});
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { Progress2Visible = true; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = false; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -313,16 +304,10 @@ public sealed class ImageSidecarViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = true; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
StatusText = text;
});
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() => { StatusText = text; });
void ExecuteCloseCommand() => _view.Close();
@@ -342,11 +327,8 @@ public sealed class ImageSidecarViewModel : ViewModelBase
dlgDestination.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
"*.json"
})
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[] { "*.json" })
});
string result = await dlgDestination.ShowAsync(_view);

View File

@@ -402,11 +402,13 @@ public sealed class ImageVerifyViewModel : ViewModelBase
if(VerifyImageChecked)
{
if(_inputFormat is not IVerifiableImage verifiableImage)
{
await Dispatcher.UIThread.InvokeAsync(() =>
{
ImageResultVisible = true;
ImageResultText = UI.Disc_image_does_not_support_verification;
});
}
else
{
await Dispatcher.UIThread.InvokeAsync(() =>
@@ -423,7 +425,7 @@ public sealed class ImageVerifyViewModel : ViewModelBase
var chkStopwatch = new Stopwatch();
chkStopwatch.Start();
bool? discCheckStatus = verifiableImage.VerifyMediaImage();
bool? discCheckStatus = verifiableImage.VerifyMediaImage();
chkStopwatch.Stop();
await Dispatcher.UIThread.InvokeAsync(() =>
@@ -431,11 +433,11 @@ public sealed class ImageVerifyViewModel : ViewModelBase
ImageResultVisible = true;
ImageResultText = discCheckStatus switch
{
true => UI.Disc_image_checksums_are_correct,
false => UI.Disc_image_checksums_are_incorrect,
null => UI.Disc_image_does_not_contain_checksums
};
{
true => UI.Disc_image_checksums_are_correct,
false => UI.Disc_image_checksums_are_incorrect,
null => UI.Disc_image_does_not_contain_checksums
};
});
AaruConsole.VerboseWriteLine(UI.Checking_disc_image_checksums_took_0,
@@ -504,11 +506,15 @@ public sealed class ImageVerifyViewModel : ViewModelBase
List<ulong> tempUnknownLbas;
if(remainingSectors < 512)
{
inputOptical.VerifySectors(currentSector, (uint)remainingSectors, currentTrack.Sequence,
out tempFailingLbas, out tempUnknownLbas);
}
else
{
inputOptical.VerifySectors(currentSector, 512, currentTrack.Sequence, out tempFailingLbas,
out tempUnknownLbas);
}
failingLbas.AddRange(tempFailingLbas);
@@ -564,11 +570,15 @@ public sealed class ImageVerifyViewModel : ViewModelBase
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);
@@ -607,10 +617,12 @@ public sealed class ImageVerifyViewModel : ViewModelBase
SectorErrorsVisible = true;
foreach(ulong t in failingLbas)
{
ErrorList.Add(new LbaModel
{
Lba = t.ToString()
});
}
}
}
@@ -627,16 +639,18 @@ public sealed class ImageVerifyViewModel : ViewModelBase
SectorsUnknownsVisible = true;
foreach(ulong t in unknownLbas)
{
UnknownList.Add(new LbaModel
{
Lba = t.ToString()
});
}
}
}
SectorSummaryVisible = true;
TotalSectorsText = string.Format(UI.Total_sectors, _inputFormat.Info.Sectors);
TotalSectorErrorsText = string.Format(UI.Total_errors, failingLbas.Count);
TotalSectorsText = string.Format(UI.Total_sectors, _inputFormat.Info.Sectors);
TotalSectorErrorsText = string.Format(UI.Total_errors, failingLbas.Count);
TotalSectorUnknownsText = string.Format(UI.Total_unknowns, unknownLbas.Count);
TotalSectorErrorsUnknownsText =

View File

@@ -72,22 +72,22 @@ namespace Aaru.Gui.ViewModels.Windows;
public sealed class MainWindowViewModel : ViewModelBase
{
const string MODULE_NAME = "Main Window ViewModel";
readonly DevicesRootModel _devicesRoot;
readonly Bitmap _ejectIcon;
readonly Bitmap _genericFolderIcon;
readonly Bitmap _genericHddIcon;
readonly Bitmap _genericOpticalIcon;
readonly Bitmap _genericTapeIcon;
readonly ImagesRootModel _imagesRoot;
readonly Bitmap _removableIcon;
readonly Bitmap _sdIcon;
readonly Bitmap _usbIcon;
readonly MainWindow _view;
Views.Dialogs.Console _console;
object _contentPanel;
bool _devicesSupported;
object _treeViewSelectedItem;
const string MODULE_NAME = "Main Window ViewModel";
readonly DevicesRootModel _devicesRoot;
readonly Bitmap _ejectIcon;
readonly Bitmap _genericFolderIcon;
readonly Bitmap _genericHddIcon;
readonly Bitmap _genericOpticalIcon;
readonly Bitmap _genericTapeIcon;
readonly ImagesRootModel _imagesRoot;
readonly Bitmap _removableIcon;
readonly Bitmap _sdIcon;
readonly Bitmap _usbIcon;
readonly MainWindow _view;
Views.Dialogs.Console _console;
object _contentPanel;
bool _devicesSupported;
object _treeViewSelectedItem;
public MainWindowViewModel(MainWindow view)
{
@@ -148,15 +148,18 @@ public sealed class MainWindowViewModel : ViewModelBase
_usbIcon =
new
Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png")));
Bitmap(AssetLoader.Open(
new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media-usb.png")));
_removableIcon =
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png")));
new Bitmap(AssetLoader.Open(
new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-removable-media.png")));
_sdIcon =
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-flash-sd-mmc.png")));
_ejectIcon = new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png")));
_ejectIcon =
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/media-eject.png")));
}
public string FileLabel => UI.Menu_File;
@@ -193,6 +196,7 @@ public sealed class MainWindowViewModel : ViewModelBase
[NotNull]
public string Greeting => UI.Welcome_to_Aaru;
public ObservableCollection<RootModel> TreeRoot { get; }
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
public ReactiveCommand<Unit, Unit> ConsoleCommand { get; }
@@ -292,23 +296,27 @@ public sealed class MainWindowViewModel : ViewModelBase
deviceModel.ViewModel = new DeviceInfoViewModel(devInfo, _view);
if(!dev.IsRemovable)
{
deviceModel.Media.Add(new MediaModel
{
NonRemovable = true,
Name = UI.Non_removable_device_commands_not_yet_implemented
});
}
else
{
// TODO: Removable non-SCSI?
var scsiInfo = new ScsiInfo(dev);
if(!scsiInfo.MediaInserted)
{
deviceModel.Media.Add(new MediaModel
{
NoMediaInserted = true,
Icon = _ejectIcon,
Name = UI.No_media_inserted
});
}
else
{
var mediaResource =
@@ -317,7 +325,8 @@ public sealed class MainWindowViewModel : ViewModelBase
deviceModel.Media.Add(new MediaModel
{
DevicePath = deviceModel.Path,
Icon = AssetLoader.Exists(mediaResource) ? new Bitmap(AssetLoader.Open(mediaResource))
Icon = AssetLoader.Exists(mediaResource)
? new Bitmap(AssetLoader.Open(mediaResource))
: null,
Name = $"{scsiInfo.MediaType}",
ViewModel = new MediaInfoViewModel(scsiInfo, deviceModel.Path, _view)
@@ -346,10 +355,12 @@ public sealed class MainWindowViewModel : ViewModelBase
case MediaModel mediaModel:
{
if(mediaModel.ViewModel != null)
{
ContentPanel = new MediaInfo
{
DataContext = mediaModel.ViewModel
};
}
break;
}
@@ -533,7 +544,7 @@ public sealed class MainWindowViewModel : ViewModelBase
if(inputFilter == null)
{
MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Cannot_open_specified_file, ButtonEnum.Ok,
Icon.Error);
Icon.Error);
return;
}
@@ -543,7 +554,7 @@ public sealed class MainWindowViewModel : ViewModelBase
if(ImageFormat.Detect(inputFilter) is not IMediaImage imageFormat)
{
MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Image_format_not_identified,
ButtonEnum.Ok, Icon.Error);
ButtonEnum.Ok, Icon.Error);
return;
}
@@ -557,8 +568,8 @@ public sealed class MainWindowViewModel : ViewModelBase
if(opened != ErrorNumber.NoError)
{
MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
string.Format(UI.Error_0_opening_image_format,
opened), ButtonEnum.Ok, Icon.Error);
string.Format(UI.Error_0_opening_image_format,
opened), ButtonEnum.Ok, Icon.Error);
AaruConsole.ErrorWriteLine(UI.Unable_to_open_image_format);
AaruConsole.ErrorWriteLine(UI.No_error_given);
@@ -587,7 +598,7 @@ public sealed class MainWindowViewModel : ViewModelBase
List<CommonTypes.Partition> partitions = Core.Partitions.GetAll(imageFormat);
Core.Partitions.AddSchemesToStats(partitions);
bool checkRaw = false;
var checkRaw = false;
List<string> idPlugins;
Type pluginType;
PluginBase plugins = PluginBase.Singleton;
@@ -632,6 +643,7 @@ public sealed class MainWindowViewModel : ViewModelBase
AaruConsole.WriteLine(string.Format(UI.Identified_by_0_plugins, idPlugins.Count));
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -655,13 +667,14 @@ public sealed class MainWindowViewModel : ViewModelBase
var filesystemModel = new FileSystemModel
{
VolumeName = rofs?.Metadata.VolumeName is null
? fsMetadata.VolumeName is null ? $"{fsMetadata.Type}"
? fsMetadata.VolumeName is null
? $"{fsMetadata.Type}"
: $"{fsMetadata.VolumeName} ({fsMetadata.Type})"
: $"{rofs.Metadata.VolumeName} ({rofs.Metadata.Type})",
Filesystem = fs,
ReadOnlyFilesystem = rofs,
ViewModel = new FileSystemViewModel(rofs?.Metadata ?? fsMetadata,
information)
information)
};
// TODO: Trap expanding item
@@ -680,6 +693,7 @@ public sealed class MainWindowViewModel : ViewModelBase
Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type);
partitionModel.FileSystems.Add(filesystemModel);
}
}
}
schemeModel.Partitions.Add(partitionModel);
@@ -707,6 +721,7 @@ public sealed class MainWindowViewModel : ViewModelBase
AaruConsole.WriteLine(string.Format(UI.Identified_by_0_plugins, idPlugins.Count));
foreach(string pluginName in idPlugins)
{
if(plugins.Filesystems.TryGetValue(pluginName, out pluginType))
{
if(Activator.CreateInstance(pluginType) is not IFilesystem fs)
@@ -729,7 +744,8 @@ public sealed class MainWindowViewModel : ViewModelBase
var filesystemModel = new FileSystemModel
{
VolumeName = rofs?.Metadata.VolumeName is null
? fsMetadata.VolumeName is null ? $"{fsMetadata.Type}"
? fsMetadata.VolumeName is null
? $"{fsMetadata.Type}"
: $"{fsMetadata.VolumeName} ({fsMetadata.Type})"
: $"{rofs.Metadata.VolumeName} ({rofs.Metadata.Type})",
Filesystem = fs,
@@ -753,6 +769,7 @@ public sealed class MainWindowViewModel : ViewModelBase
Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type);
imageModel.PartitionSchemesOrFileSystems.Add(filesystemModel);
}
}
}
}
@@ -765,7 +782,7 @@ public sealed class MainWindowViewModel : ViewModelBase
catch(Exception ex)
{
MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Unable_to_open_image_format,
ButtonEnum.Ok, Icon.Error);
ButtonEnum.Ok, Icon.Error);
AaruConsole.ErrorWriteLine(UI.Unable_to_open_image_format);
AaruConsole.ErrorWriteLine(Localization.Core.Error_0, ex.Message);
@@ -775,7 +792,7 @@ public sealed class MainWindowViewModel : ViewModelBase
catch(Exception ex)
{
MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, UI.Exception_reading_file, ButtonEnum.Ok,
Icon.Error);
Icon.Error);
AaruConsole.ErrorWriteLine(string.Format(UI.Error_reading_file_0, ex.Message));
AaruConsole.DebugWriteLine(MODULE_NAME, ex.StackTrace);
@@ -817,9 +834,11 @@ public sealed class MainWindowViewModel : ViewModelBase
if(dev != null)
{
if(dev is Devices.Remote.Device remoteDev)
{
Statistics.AddRemote(remoteDev.RemoteApplication, remoteDev.RemoteVersion,
remoteDev.RemoteOperatingSystem, remoteDev.RemoteOperatingSystemVersion,
remoteDev.RemoteArchitecture);
}
switch(dev.Type)
{
@@ -830,7 +849,8 @@ public sealed class MainWindowViewModel : ViewModelBase
case PeripheralDeviceTypes.DirectAccess:
case PeripheralDeviceTypes.SCSIZonedBlockDevice:
case PeripheralDeviceTypes.SimplifiedDevice:
deviceModel.Icon = dev.IsRemovable ? dev.IsUsb ? _usbIcon : _removableIcon
deviceModel.Icon = dev.IsRemovable
? dev.IsUsb ? _usbIcon : _removableIcon
: _genericHddIcon;
break;

View File

@@ -112,7 +112,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
bool _useResume;
bool _useSidecar;
public MediaDumpViewModel(string devicePath, DeviceInfo deviceInfo, Window view,
public MediaDumpViewModel(string devicePath, DeviceInfo deviceInfo, Window view,
[CanBeNull] ScsiInfo scsiInfo = null)
{
_view = view;
@@ -144,6 +144,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
if(scsiInfo != null)
mediaType = scsiInfo.MediaType;
else
{
switch(deviceInfo.Type)
{
case DeviceType.SecureDigital:
@@ -164,6 +165,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
break;
}
}
PluginBase plugins = PluginBase.Singleton;
@@ -173,10 +175,12 @@ public sealed class MediaDumpViewModel : ViewModelBase
continue;
if(plugin.SupportedMediaTypes.Contains(mediaType))
{
PluginsList.Add(new ImagePluginModel
{
Plugin = plugin
});
}
}
Encodings.AddRange(Encoding.GetEncodings().Select(info => new EncodingModel
@@ -514,11 +518,8 @@ public sealed class MediaDumpViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
".json"
})
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[] { ".json" })
});
string[] result = dlgMetadata.ShowAsync(_view).Result;
@@ -719,16 +720,16 @@ public sealed class MediaDumpViewModel : ViewModelBase
else if(File.Exists(_outputPrefix + ".resume.xml"))
{
// Should be covered by virtue of being the same exact class as the JSON above
#pragma warning disable IL2026
#pragma warning disable IL2026
var xs = new XmlSerializer(typeof(Resume));
#pragma warning restore IL2026
#pragma warning restore IL2026
var sr = new StreamReader(_outputPrefix + ".resume.xml");
// Should be covered by virtue of being the same exact class as the JSON above
#pragma warning disable IL2026
#pragma warning disable IL2026
_resume = (Resume)xs.Deserialize(sr);
#pragma warning restore IL2026
#pragma warning restore IL2026
sr.Close();
}
@@ -737,7 +738,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
{
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error, UI.Incorrect_resume_file_cannot_use_it, ButtonEnum.Ok,
Icon.Error).ShowWindowDialogAsync(_view);
Icon.Error).ShowWindowDialogAsync(_view);
Resume = false;
@@ -746,13 +747,13 @@ public sealed class MediaDumpViewModel : ViewModelBase
if(_resume == null ||
_resume.NextBlock <= _resume.LastBlock ||
(_resume.BadBlocks.Count != 0 && !_resume.Tape))
_resume.BadBlocks.Count != 0 && !_resume.Tape)
return;
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Warning,
UI.Media_already_dumped_correctly_please_choose_another_destination,
ButtonEnum.Ok, Icon.Warning).ShowWindowDialogAsync(_view);
UI.Media_already_dumped_correctly_please_choose_another_destination,
ButtonEnum.Ok, Icon.Warning).ShowWindowDialogAsync(_view);
Resume = false;
}
@@ -814,6 +815,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
Encoding encoding = null;
if(SelectedEncoding is not null)
{
try
{
encoding = Claunia.Encoding.Encoding.GetEncoding(SelectedEncoding.Name);
@@ -824,6 +826,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
return;
}
}
Dictionary<string, string> parsedOptions = new();
@@ -901,10 +904,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
});
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { Progress2Visible = false; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress2(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -917,16 +917,10 @@ public sealed class MediaDumpViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
});
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() => { Progress2Visible = true; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = false; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -939,10 +933,7 @@ public sealed class MediaDumpViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = true; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void PulseProgress(string text) => await Dispatcher.UIThread.InvokeAsync(() =>

View File

@@ -110,10 +110,10 @@ public sealed class MediaScanViewModel : ViewModelBase
CloseVisible = true;
BlockMapList = new ObservableCollection<(ulong block, double duration)>();
// ChartPoints = new ObservableCollection<DataPoint>();
StepsX = double.NaN;
StepsY = double.NaN;
AxesColor = Colors.Black;
LineColor = Colors.Yellow;
StepsX = double.NaN;
StepsY = double.NaN;
AxesColor = Colors.Black;
LineColor = Colors.Yellow;
}
public string SpeedLabel => UI.ButtonLabel_Stop;
@@ -350,7 +350,7 @@ public sealed class MediaScanViewModel : ViewModelBase
case null:
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_opening_device, devErrno),
ButtonEnum.Ok, Icon.Error).ShowWindowDialogAsync(_view);
ButtonEnum.Ok, Icon.Error).ShowWindowDialogAsync(_view);
StopVisible = false;
StartVisible = true;
@@ -370,7 +370,7 @@ public sealed class MediaScanViewModel : ViewModelBase
{
await MessageBoxManager.
GetMessageBoxStandard(UI.Title_Error, string.Format(UI.Error_0_opening_device, dev.LastError),
ButtonEnum.Ok, Icon.Error).ShowWindowDialogAsync(_view);
ButtonEnum.Ok, Icon.Error).ShowWindowDialogAsync(_view);
StopVisible = false;
StartVisible = true;
@@ -412,12 +412,12 @@ public sealed class MediaScanViewModel : ViewModelBase
MinSpeed = string.Format(Localization.Core.Slowest_speed_burst_0,
ByteSize.FromBytes(results.MinSpeed).Per(1.Seconds()).Humanize());
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);
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);
E = string.Format(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, results.E);
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, results.F);
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, results.F);
UnreadableSectors = string.Format(Localization.Core._0_sectors_could_not_be_read,
results.UnreadableSectors.Count);
@@ -456,7 +456,7 @@ public sealed class MediaScanViewModel : ViewModelBase
*/
if(currentSpeed > MaxY)
MaxY = currentSpeed + (currentSpeed / 10d);
MaxY = currentSpeed + currentSpeed / 10d;
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
@@ -479,12 +479,12 @@ public sealed class MediaScanViewModel : ViewModelBase
case 0x0021:
case 0x0022:
MaxX = blocks switch
{
<= 360000 => 360000,
<= 405000 => 405000,
<= 445500 => 445500,
_ => blocks
};
{
<= 360000 => 360000,
<= 405000 => 405000,
<= 445500 => 445500,
_ => blocks
};
StepsX = MaxX / 10;
StepsY = 150 * 4;
@@ -521,13 +521,13 @@ public sealed class MediaScanViewModel : ViewModelBase
case 0x0043:
case 0x0040: // BD
MaxX = blocks switch
{
<= 12219392 => 12219392,
<= 24438784 => 24438784,
<= 48878592 => 48878592,
<= 62500864 => 62500864,
_ => blocks
};
{
<= 12219392 => 12219392,
<= 24438784 => 24438784,
<= 48878592 => 48878592,
<= 62500864 => 62500864,
_ => blocks
};
StepsX = MaxX / 10;
StepsY = 4394.5;
@@ -541,11 +541,11 @@ public sealed class MediaScanViewModel : ViewModelBase
case 0x0058:
case 0x005A:
MaxX = blocks switch
{
<= 7361599 => 7361599,
<= 16305407 => 16305407,
_ => blocks
};
{
<= 7361599 => 7361599,
<= 16305407 => 16305407,
_ => blocks
};
StepsX = MaxX / 10;
StepsY = 4394.5;
@@ -571,10 +571,7 @@ public sealed class MediaScanViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = false; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateProgress(string text, long current, long maximum) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -587,10 +584,7 @@ public sealed class MediaScanViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() => { Progress1Visible = true; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void PulseProgress(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -613,10 +607,7 @@ public sealed class MediaScanViewModel : ViewModelBase
});
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
});
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() => { ProgressText = text; });
[SuppressMessage("ReSharper", "AsyncVoidMethod")]
async void OnScanUnreadable(ulong sector) => await Dispatcher.UIThread.InvokeAsync(() =>
@@ -659,11 +650,11 @@ public sealed class MediaScanViewModel : ViewModelBase
break;
}
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);
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);
E = string.Format(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, _localResults.E);
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, _localResults.F);
F = string.Format(Localization.Core._0_sectors_took_more_than_500_ms, _localResults.F);
});
}

View File

@@ -147,12 +147,15 @@ public sealed class SplashWindowViewModel : ViewModelBase
ctx.Database.EnsureCreated();
ctx.Database.
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
ExecuteSqlRaw(
"CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database.
ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{
migration}', '0.0.0')");
}
ctx.SaveChanges();
}
@@ -165,9 +168,11 @@ public sealed class SplashWindowViewModel : ViewModelBase
a.Revision,
a.Bus
}).Where(a => a.Count() > 1).Distinct().Select(a => a.Key))
{
ctx.RemoveRange(ctx.SeenDevices.
Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model &&
d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1));
}
// Remove nulls
ctx.RemoveRange(ctx.SeenDevices.Where(d => d.Manufacturer == null && d.Model == null &&

View File

@@ -83,7 +83,8 @@ public sealed class ViewSectorViewModel : ViewModelBase
byte[] sector;
ErrorNumber errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
ErrorNumber errno = LongSectorChecked
? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
: _inputFormat.ReadSector((ulong)SectorNumber, out sector);
if(errno == ErrorNumber.NoError)