2020-04-17 21:45:50 +01:00
|
|
|
// /***************************************************************************
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : MediaInfoViewModel.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// View model and code for the media information panel.
|
|
|
|
|
//
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-02-18 10:02:53 +00:00
|
|
|
// Copyright © 2011-2022 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
namespace Aaru.Gui.ViewModels.Panels;
|
|
|
|
|
|
2020-04-15 05:52:13 +01:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reactive;
|
|
|
|
|
using System.Text;
|
2022-03-26 16:52:00 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-04-16 20:40:25 +01:00
|
|
|
using Aaru.Gui.ViewModels.Tabs;
|
|
|
|
|
using Aaru.Gui.ViewModels.Windows;
|
|
|
|
|
using Aaru.Gui.Views.Tabs;
|
|
|
|
|
using Aaru.Gui.Views.Windows;
|
2020-04-15 05:52:13 +01:00
|
|
|
using Avalonia;
|
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Media.Imaging;
|
|
|
|
|
using Avalonia.Platform;
|
2020-04-16 03:18:10 +01:00
|
|
|
using MessageBox.Avalonia;
|
|
|
|
|
using MessageBox.Avalonia.Enums;
|
2020-04-15 05:52:13 +01:00
|
|
|
using ReactiveUI;
|
2020-04-16 21:29:40 +01:00
|
|
|
using ScsiInfo = Aaru.Core.Media.Info.ScsiInfo;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public sealed class MediaInfoViewModel : ViewModelBase
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
readonly string _devicePath;
|
|
|
|
|
readonly ScsiInfo _scsiInfo;
|
|
|
|
|
readonly Window _view;
|
|
|
|
|
BlurayInfo _blurayInfo;
|
|
|
|
|
CompactDiscInfo _compactDiscInfo;
|
|
|
|
|
string _densitySupport;
|
|
|
|
|
DvdInfo _dvdInfo;
|
|
|
|
|
DvdWritableInfo _dvdWritableInfo;
|
|
|
|
|
string _generalVisible;
|
|
|
|
|
Bitmap _mediaLogo;
|
|
|
|
|
string _mediaSerial;
|
|
|
|
|
string _mediaSize;
|
|
|
|
|
string _mediaType;
|
|
|
|
|
string _mediumSupport;
|
|
|
|
|
bool _mmcVisible;
|
|
|
|
|
bool _saveDensitySupportVisible;
|
|
|
|
|
bool _saveGetConfigurationVisible;
|
|
|
|
|
bool _saveMediumSupportVisible;
|
|
|
|
|
bool _saveReadCapacity16Visible;
|
|
|
|
|
bool _saveReadCapacityVisible;
|
|
|
|
|
bool _saveReadMediaSerialVisible;
|
|
|
|
|
bool _saveRecognizedFormatLayersVisible;
|
|
|
|
|
bool _saveWriteProtectionStatusVisible;
|
|
|
|
|
bool _sscVisible;
|
|
|
|
|
XboxInfo _xboxInfo;
|
|
|
|
|
|
|
|
|
|
public MediaInfoViewModel(ScsiInfo scsiInfo, string devicePath, Window view)
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
_view = view;
|
|
|
|
|
SaveReadMediaSerialCommand = ReactiveCommand.Create(ExecuteSaveReadMediaSerialCommand);
|
|
|
|
|
SaveReadCapacityCommand = ReactiveCommand.Create(ExecuteSaveReadCapacityCommand);
|
|
|
|
|
SaveReadCapacity16Command = ReactiveCommand.Create(ExecuteSaveReadCapacity16Command);
|
|
|
|
|
SaveGetConfigurationCommand = ReactiveCommand.Create(ExecuteSaveGetConfigurationCommand);
|
|
|
|
|
SaveRecognizedFormatLayersCommand = ReactiveCommand.Create(ExecuteSaveRecognizedFormatLayersCommand);
|
|
|
|
|
SaveWriteProtectionStatusCommand = ReactiveCommand.Create(ExecuteSaveWriteProtectionStatusCommand);
|
|
|
|
|
SaveDensitySupportCommand = ReactiveCommand.Create(ExecuteSaveDensitySupportCommand);
|
|
|
|
|
SaveMediumSupportCommand = ReactiveCommand.Create(ExecuteSaveMediumSupportCommand);
|
|
|
|
|
DumpCommand = ReactiveCommand.Create(ExecuteDumpCommand);
|
|
|
|
|
ScanCommand = ReactiveCommand.Create(ExecuteScanCommand);
|
|
|
|
|
IAssetLoader assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
|
|
|
|
|
_devicePath = devicePath;
|
|
|
|
|
_scsiInfo = scsiInfo;
|
|
|
|
|
|
|
|
|
|
var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png");
|
|
|
|
|
|
2022-03-17 00:46:26 +00:00
|
|
|
MediaLogo = assets?.Exists(mediaResource) == true ? new Bitmap(assets.Open(mediaResource)) : null;
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
MediaType = scsiInfo.MediaType.ToString();
|
|
|
|
|
|
|
|
|
|
if(scsiInfo.Blocks != 0 &&
|
|
|
|
|
scsiInfo.BlockSize != 0)
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
ulong totalSize = scsiInfo.Blocks * scsiInfo.BlockSize;
|
|
|
|
|
|
2022-11-13 19:59:24 +00:00
|
|
|
MediaSize = totalSize switch
|
|
|
|
|
{
|
|
|
|
|
> 1099511627776 => $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize
|
|
|
|
|
} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)",
|
|
|
|
|
> 1073741824 => $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize
|
|
|
|
|
} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)",
|
|
|
|
|
> 1048576 => $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize
|
|
|
|
|
} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)",
|
|
|
|
|
> 1024 => $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize
|
|
|
|
|
} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)",
|
|
|
|
|
_ => $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize
|
|
|
|
|
} bytes/each. (for a total of {totalSize} bytes)"
|
|
|
|
|
};
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(scsiInfo.MediaSerialNumber != null)
|
|
|
|
|
{
|
|
|
|
|
var sbSerial = new StringBuilder();
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
for(var i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
|
2022-03-06 13:29:38 +00:00
|
|
|
sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
MediaSerial = sbSerial.ToString();
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
SaveReadMediaSerialVisible = scsiInfo.MediaSerialNumber != null;
|
|
|
|
|
SaveReadCapacityVisible = scsiInfo.ReadCapacity != null;
|
|
|
|
|
SaveReadCapacity16Visible = scsiInfo.ReadCapacity16 != null;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
SaveGetConfigurationVisible = scsiInfo.MmcConfiguration != null;
|
|
|
|
|
SaveRecognizedFormatLayersVisible = scsiInfo.RecognizedFormatLayers != null;
|
|
|
|
|
SaveWriteProtectionStatusVisible = scsiInfo.WriteProtectionStatus != null;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
MmcVisible = SaveGetConfigurationVisible || SaveRecognizedFormatLayersVisible ||
|
|
|
|
|
SaveWriteProtectionStatusVisible;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(scsiInfo.DensitySupportHeader.HasValue)
|
|
|
|
|
DensitySupport = Decoders.SCSI.SSC.DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(scsiInfo.MediaTypeSupportHeader.HasValue)
|
|
|
|
|
MediumSupport = Decoders.SCSI.SSC.DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
SaveDensitySupportVisible = scsiInfo.DensitySupport != null;
|
|
|
|
|
SaveMediumSupportVisible = scsiInfo.MediaTypeSupport != null;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
SscVisible = SaveDensitySupportVisible || SaveMediumSupportVisible;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
CompactDiscInfo = new CompactDiscInfo
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.DiscInformation,
|
|
|
|
|
scsiInfo.Session, scsiInfo.RawToc, scsiInfo.Pma,
|
2022-03-07 07:36:44 +00:00
|
|
|
scsiInfo.CdTextLeadIn, scsiInfo.DecodedToc, scsiInfo.DecodedAtip,
|
|
|
|
|
scsiInfo.DecodedSession, scsiInfo.FullToc,
|
|
|
|
|
scsiInfo.DecodedCdTextLeadIn, scsiInfo.DecodedDiscInformation,
|
|
|
|
|
scsiInfo.Mcn, scsiInfo.Isrcs, _view)
|
2022-03-06 13:29:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DvdInfo = new DvdInfo
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-07 07:36:44 +00:00
|
|
|
DataContext = new DvdInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi, scsiInfo.DvdCmi,
|
|
|
|
|
scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca, scsiInfo.DvdAacs,
|
|
|
|
|
scsiInfo.DecodedPfi, _view)
|
2022-03-06 13:29:38 +00:00
|
|
|
};
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
XboxInfo = new XboxInfo
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,
|
|
|
|
|
scsiInfo.DecodedXboxSecuritySector, _view)
|
|
|
|
|
};
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
DvdWritableInfo = new DvdWritableInfo
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
DataContext = new DvdWritableInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdRamDds,
|
|
|
|
|
scsiInfo.DvdRamCartridgeStatus, scsiInfo.DvdRamSpareArea,
|
|
|
|
|
scsiInfo.LastBorderOutRmd, scsiInfo.DvdPreRecordedInfo,
|
2022-03-07 07:36:44 +00:00
|
|
|
scsiInfo.DvdrMediaIdentifier, scsiInfo.DvdrPhysicalInformation,
|
2022-03-06 13:29:38 +00:00
|
|
|
scsiInfo.HddvdrMediumStatus, scsiInfo.HddvdrLastRmd,
|
|
|
|
|
scsiInfo.DvdrLayerCapacity, scsiInfo.DvdrDlMiddleZoneStart,
|
|
|
|
|
scsiInfo.DvdrDlJumpIntervalSize,
|
|
|
|
|
scsiInfo.DvdrDlManualLayerJumpStartLba,
|
|
|
|
|
scsiInfo.DvdrDlRemapAnchorPoint, scsiInfo.DvdPlusAdip,
|
|
|
|
|
scsiInfo.DvdPlusDcb, _view)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BlurayInfo = new BlurayInfo
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea,
|
|
|
|
|
scsiInfo.BlurayDds, scsiInfo.BlurayCartridgeStatus,
|
|
|
|
|
scsiInfo.BluraySpareAreaInformation, scsiInfo.BlurayPowResources,
|
|
|
|
|
scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl,
|
|
|
|
|
scsiInfo.BlurayPac, _view)
|
|
|
|
|
};
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
public ReactiveCommand<Unit, Task> SaveReadMediaSerialCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveReadCapacityCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveReadCapacity16Command { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveGetConfigurationCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveRecognizedFormatLayersCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveWriteProtectionStatusCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveDensitySupportCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> SaveMediumSupportCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> DumpCommand { get; }
|
|
|
|
|
public ReactiveCommand<Unit, Task> ScanCommand { get; }
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
public Bitmap MediaLogo
|
|
|
|
|
{
|
|
|
|
|
get => _mediaLogo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaLogo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string GeneralVisible
|
|
|
|
|
{
|
|
|
|
|
get => _generalVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _generalVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string MediaType
|
|
|
|
|
{
|
|
|
|
|
get => _mediaType;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaType, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string MediaSize
|
|
|
|
|
{
|
|
|
|
|
get => _mediaSize;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaSize, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string MediaSerial
|
|
|
|
|
{
|
|
|
|
|
get => _mediaSerial;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediaSerial, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveReadMediaSerialVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveReadMediaSerialVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveReadMediaSerialVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveReadCapacityVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveReadCapacityVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveReadCapacityVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveReadCapacity16Visible
|
|
|
|
|
{
|
|
|
|
|
get => _saveReadCapacity16Visible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveReadCapacity16Visible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool MmcVisible
|
|
|
|
|
{
|
|
|
|
|
get => _mmcVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mmcVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveGetConfigurationVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveGetConfigurationVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveGetConfigurationVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveRecognizedFormatLayersVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveRecognizedFormatLayersVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveRecognizedFormatLayersVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveWriteProtectionStatusVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveWriteProtectionStatusVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveWriteProtectionStatusVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SscVisible
|
|
|
|
|
{
|
|
|
|
|
get => _sscVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _sscVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string DensitySupport
|
|
|
|
|
{
|
|
|
|
|
get => _densitySupport;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _densitySupport, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public string MediumSupport
|
|
|
|
|
{
|
|
|
|
|
get => _mediumSupport;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _mediumSupport, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveDensitySupportVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveDensitySupportVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveDensitySupportVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public bool SaveMediumSupportVisible
|
|
|
|
|
{
|
|
|
|
|
get => _saveMediumSupportVisible;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _saveMediumSupportVisible, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public CompactDiscInfo CompactDiscInfo
|
|
|
|
|
{
|
|
|
|
|
get => _compactDiscInfo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _compactDiscInfo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public DvdInfo DvdInfo
|
|
|
|
|
{
|
|
|
|
|
get => _dvdInfo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _dvdInfo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public DvdWritableInfo DvdWritableInfo
|
|
|
|
|
{
|
|
|
|
|
get => _dvdWritableInfo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _dvdWritableInfo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public XboxInfo XboxInfo
|
|
|
|
|
{
|
|
|
|
|
get => _xboxInfo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _xboxInfo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public BlurayInfo BlurayInfo
|
|
|
|
|
{
|
|
|
|
|
get => _blurayInfo;
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _blurayInfo, value);
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task SaveElement(byte[] data)
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
var dlgSaveBinary = new SaveFileDialog();
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-11-15 01:35:06 +00:00
|
|
|
dlgSaveBinary.Filters?.Add(new FileDialogFilter
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
Extensions = new List<string>(new[]
|
|
|
|
|
{
|
|
|
|
|
"*.bin"
|
|
|
|
|
}),
|
|
|
|
|
Name = "Binary"
|
|
|
|
|
});
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
string result = await dlgSaveBinary.ShowAsync(_view);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
if(result is null)
|
|
|
|
|
return;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
var saveFs = new FileStream(result, FileMode.Create);
|
|
|
|
|
saveFs.Write(data, 0, data.Length);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
saveFs.Close();
|
|
|
|
|
}
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveReadMediaSerialCommand() => await SaveElement(_scsiInfo.MediaSerialNumber);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveReadCapacityCommand() => await SaveElement(_scsiInfo.ReadCapacity);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveReadCapacity16Command() => await SaveElement(_scsiInfo.ReadCapacity16);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveGetConfigurationCommand() => await SaveElement(_scsiInfo.MmcConfiguration);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveRecognizedFormatLayersCommand() => await SaveElement(_scsiInfo.RecognizedFormatLayers);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveWriteProtectionStatusCommand() => await SaveElement(_scsiInfo.WriteProtectionStatus);
|
2020-04-16 19:28:39 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveDensitySupportCommand() => await SaveElement(_scsiInfo.DensitySupport);
|
2020-04-16 19:28:39 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteSaveMediumSupportCommand() => await SaveElement(_scsiInfo.MediaTypeSupport);
|
2020-04-16 19:28:39 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteDumpCommand()
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
2022-11-13 19:38:03 +00:00
|
|
|
switch(_scsiInfo.MediaType)
|
2020-04-15 05:52:13 +01:00
|
|
|
{
|
2022-11-13 19:38:03 +00:00
|
|
|
case CommonTypes.MediaType.GDR or CommonTypes.MediaType.GDROM:
|
|
|
|
|
await MessageBoxManager.
|
|
|
|
|
GetMessageBoxStandardWindow("Error", "GD-ROM dump support is not yet implemented.", ButtonEnum.Ok,
|
|
|
|
|
Icon.Error).ShowDialog(_view);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
case CommonTypes.MediaType.XGD or CommonTypes.MediaType.XGD2 or CommonTypes.MediaType.XGD3
|
|
|
|
|
when _scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true:
|
|
|
|
|
await MessageBoxManager.
|
|
|
|
|
GetMessageBoxStandardWindow("Error", "Dumping Xbox discs require a Kreon drive.", ButtonEnum.Ok,
|
|
|
|
|
Icon.Error).ShowDialog(_view);
|
|
|
|
|
|
|
|
|
|
return;
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var mediaDumpWindow = new MediaDump();
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
mediaDumpWindow.DataContext =
|
|
|
|
|
new MediaDumpViewModel(_devicePath, _scsiInfo.DeviceInfo, mediaDumpWindow, _scsiInfo);
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
mediaDumpWindow.Show();
|
|
|
|
|
}
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-26 16:52:00 +00:00
|
|
|
async Task ExecuteScanCommand()
|
2022-03-06 13:29:38 +00:00
|
|
|
{
|
|
|
|
|
switch(_scsiInfo.MediaType)
|
|
|
|
|
{
|
|
|
|
|
// TODO: GD-ROM
|
|
|
|
|
case CommonTypes.MediaType.GDR:
|
|
|
|
|
case CommonTypes.MediaType.GDROM:
|
|
|
|
|
await MessageBoxManager.
|
2022-03-07 07:36:44 +00:00
|
|
|
GetMessageBoxStandardWindow("Error", "GD-ROM scan support is not yet implemented.", ButtonEnum.Ok,
|
|
|
|
|
Icon.Error).ShowDialog(_view);
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return;
|
2020-04-15 05:52:13 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
// TODO: Xbox
|
|
|
|
|
case CommonTypes.MediaType.XGD:
|
|
|
|
|
case CommonTypes.MediaType.XGD2:
|
|
|
|
|
case CommonTypes.MediaType.XGD3:
|
|
|
|
|
await MessageBoxManager.
|
2022-03-07 07:36:44 +00:00
|
|
|
GetMessageBoxStandardWindow("Error", "Scanning Xbox discs is not yet supported.", ButtonEnum.Ok,
|
|
|
|
|
Icon.Error).ShowDialog(_view);
|
2020-04-16 03:18:10 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return;
|
2020-04-15 05:52:13 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
|
|
|
|
|
var mediaScanWindow = new MediaScan();
|
|
|
|
|
|
|
|
|
|
mediaScanWindow.DataContext = new MediaScanViewModel(_devicePath, mediaScanWindow);
|
|
|
|
|
|
|
|
|
|
mediaScanWindow.Show();
|
2020-04-15 05:52:13 +01:00
|
|
|
}
|
|
|
|
|
}
|