mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Migrate xbox info from Eto.Forms to Avalonia.
This commit is contained in:
@@ -10,6 +10,7 @@ using Aaru.CommonTypes.Structs.Devices.SCSI;
|
||||
using Aaru.Decoders.CD;
|
||||
using Aaru.Decoders.DVD;
|
||||
using Aaru.Decoders.SCSI;
|
||||
using Aaru.Decoders.Xbox;
|
||||
using Aaru.Gui.Models;
|
||||
using Aaru.Gui.Tabs;
|
||||
using Avalonia;
|
||||
@@ -502,8 +503,6 @@ namespace Aaru.Gui.ViewModels
|
||||
blurayPowResources, blurayTrackResources, null, null, _view)
|
||||
};
|
||||
|
||||
/* TODO: tabXboxInfo
|
||||
|
||||
byte[] xboxDmi = null;
|
||||
byte[] xboxSecuritySector = null;
|
||||
SS.SecuritySector? decodedXboxSecuritySector = null;
|
||||
@@ -519,10 +518,10 @@ namespace Aaru.Gui.ViewModels
|
||||
decodedXboxSecuritySector = SS.Decode(xboxSecuritySector);
|
||||
}
|
||||
|
||||
var tabXboxInfo = new tabXboxInfo();
|
||||
tabXboxInfo.LoadData(null, xboxDmi, xboxSecuritySector, decodedXboxSecuritySector);
|
||||
tabInfos.Pages.Add(tabXboxInfo);
|
||||
*/
|
||||
XboxInfo = new XboxInfoTab
|
||||
{
|
||||
DataContext = new XboxInfoViewModel(null, xboxDmi, xboxSecuritySector, decodedXboxSecuritySector, _view)
|
||||
};
|
||||
|
||||
byte[] pcmciaCis = null;
|
||||
|
||||
@@ -651,6 +650,7 @@ namespace Aaru.Gui.ViewModels
|
||||
public DvdInfoTab DvdInfo { get; }
|
||||
public DvdWritableInfoTab DvdWritableInfo { get; }
|
||||
public BlurayInfoTab BlurayInfo { get; }
|
||||
public XboxInfoTab XboxInfo { get; }
|
||||
public PcmciaInfoTab PcmciaInfo { get; }
|
||||
public SdMmcInfoTab SdMmcInfo { get; }
|
||||
public Bitmap MediaLogo { get; }
|
||||
|
||||
85
Aaru.Gui/ViewModels/XboxInfoViewModel.cs
Normal file
85
Aaru.Gui/ViewModels/XboxInfoViewModel.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using Aaru.Core.Media.Info;
|
||||
using Aaru.Decoders.Xbox;
|
||||
using Avalonia.Controls;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Aaru.Gui.ViewModels
|
||||
{
|
||||
public class XboxInfoViewModel
|
||||
{
|
||||
Window _view;
|
||||
readonly byte[] xboxSecuritySector;
|
||||
|
||||
public XboxInfoViewModel(XgdInfo xgdInfo, byte[] dmi, byte[] securitySector,
|
||||
SS.SecuritySector? decodedSecuritySector, Window view)
|
||||
{
|
||||
xboxSecuritySector = securitySector;
|
||||
SaveXboxSsCommand = ReactiveCommand.Create(ExecuteSaveXboxSsCommand);
|
||||
|
||||
if(xgdInfo != null)
|
||||
{
|
||||
XboxInformationVisible = true;
|
||||
XboxL0VideoText = $"{xgdInfo.L0Video} sectors";
|
||||
XboxL1VideoText = $"{xgdInfo.L1Video} sectors";
|
||||
XboxMiddleZoneText = $"{xgdInfo.MiddleZone} sectors";
|
||||
XboxGameSizeText = $"{xgdInfo.GameSize} sectors";
|
||||
XboxTotalSizeText = $"{xgdInfo.TotalSize} sectors";
|
||||
XboxRealBreakText = xgdInfo.LayerBreak.ToString();
|
||||
}
|
||||
|
||||
if(dmi != null)
|
||||
{
|
||||
if(DMI.IsXbox(dmi))
|
||||
XboxDmiText = DMI.PrettifyXbox(dmi);
|
||||
else if(DMI.IsXbox360(dmi))
|
||||
XboxDmiText = DMI.PrettifyXbox360(dmi);
|
||||
}
|
||||
|
||||
if(decodedSecuritySector.HasValue)
|
||||
XboxSsText = SS.Prettify(decodedSecuritySector);
|
||||
|
||||
SaveXboxSsVisible = securitySector != null;
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SaveXboxSsCommand { get; }
|
||||
public bool XboxInformationVisible { get; }
|
||||
public bool SaveXboxSsVisible { get; }
|
||||
public string XboxL0VideoText { get; }
|
||||
public string XboxL1VideoText { get; }
|
||||
public string XboxMiddleZoneText { get; }
|
||||
public string XboxGameSizeText { get; }
|
||||
public string XboxTotalSizeText { get; }
|
||||
public string XboxRealBreakText { get; }
|
||||
public string XboxDmiText { get; }
|
||||
public string XboxSsText { get; }
|
||||
|
||||
async void SaveElement(byte[] data)
|
||||
{
|
||||
var dlgSaveBinary = new SaveFileDialog();
|
||||
|
||||
dlgSaveBinary.Filters.Add(new FileDialogFilter
|
||||
{
|
||||
Extensions = new List<string>(new[]
|
||||
{
|
||||
"*.bin"
|
||||
}),
|
||||
Name = "Binary"
|
||||
});
|
||||
|
||||
string result = await dlgSaveBinary.ShowAsync(_view);
|
||||
|
||||
if(result is null)
|
||||
return;
|
||||
|
||||
var saveFs = new FileStream(result, FileMode.Create);
|
||||
saveFs.Write(data, 0, data.Length);
|
||||
|
||||
saveFs.Close();
|
||||
}
|
||||
|
||||
public void ExecuteSaveXboxSsCommand() => SaveElement(xboxSecuritySector);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user