Migrate xbox info from Eto.Forms to Avalonia.

This commit is contained in:
2020-04-12 18:59:16 +01:00
parent 9589b9ba80
commit 864b3942e5
9 changed files with 158 additions and 235 deletions

View File

@@ -1292,8 +1292,8 @@
<e p="ScsiInfoTab.xaml.cs" t="Include" />
<e p="SdMmcInfo.xaml" t="Include" />
<e p="SdMmcInfo.xaml.cs" t="Include" />
<e p="tabXboxInfo.xeto" t="Include" />
<e p="tabXboxInfo.xeto.cs" t="Include" />
<e p="XboxInfoTab.xaml" t="Include" />
<e p="XboxInfoTab.xaml.cs" t="Include" />
</e>
<e p="ViewLocator.cs" t="Include" />
<e p="ViewModels" t="Include">
@@ -1316,6 +1316,7 @@
<e p="SplashWindowViewModel.cs" t="Include" />
<e p="StatisticsDialogViewModel.cs" t="Include" />
<e p="ViewModelBase.cs" t="Include" />
<e p="XboxInfoViewModel.cs" t="Include" />
</e>
<e p="Views" t="Include">
<e p="AboutDialog.xaml" t="Include" />

View File

@@ -162,6 +162,12 @@
</TabItem.Header>
<ContentControl Content="{Binding SdMmcInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!XboxInfo}">
<TabItem.Header>
<TextBlock Text="Xbox" />
</TabItem.Header>
<ContentControl Content="{Binding XboxInfo}" />
</TabItem>
</TabControl>
<StackPanel Orientation="Horizontal" Spacing="5">
<Button Command="{Binding EntropyCommand}">

View File

@@ -142,12 +142,14 @@ namespace Aaru.Gui.Panels
tabInfos.Pages.Add(tabDvdInfo);
*/
/*
var tabXboxInfo = new tabXboxInfo();
tabXboxInfo.LoadData(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,
scsiInfo.DecodedXboxSecuritySector);
tabInfos.Pages.Add(tabXboxInfo);
*/
/*
var tabDvdWritableInfo = new tabDvdWritableInfo();

View File

@@ -0,0 +1,44 @@
<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:Aaru.Gui.ViewModels" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Aaru.Gui.Tabs.XboxInfoTab">
<Design.DataContext>
<vm:XboxInfoViewModel />
</Design.DataContext>
<StackPanel>
<StackPanel IsVisible="{Binding XboxInformationVisible}">
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxL0VideoText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxL0VideoText}" />
</StackPanel>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxL1VideoText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxL1VideoText}" />
</StackPanel>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxMiddleZoneText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxMiddleZoneText}" />
</StackPanel>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxGameSizeText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxGameSizeText}" />
</StackPanel>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxTotalSizeText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxTotalSizeText}" />
</StackPanel>
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!XboxRealBreakText}">
<TextBlock Text="Video layer 0 size" /> <TextBox IsReadOnly="True" Text="{Binding XboxRealBreakText}" />
</StackPanel>
</StackPanel>
<StackPanel>
<StackPanel IsVisible="{Binding !!XboxDmiText}">
<TextBlock Text="Disc Manufacturing Information" />
<TextBox IsReadOnly="True" Text="{Binding XboxDmiText}" />
</StackPanel>
<StackPanel IsVisible="{Binding !!XboxSsText}">
<TextBlock Text="Security Sector" /> <TextBox IsReadOnly="True" Text="{Binding XboxSsText}" />
</StackPanel>
<Button HorizontalAlignment="Right" IsVisible="{Binding SaveXboxSsVisible}"
Command="{Binding SaveXboxSsCommand}">
<TextBlock Text="Save Xbox Security Sector" />
</Button>
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -0,0 +1,12 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Aaru.Gui.Tabs
{
public class XboxInfoTab : UserControl
{
public XboxInfoTab() => InitializeComponent();
void InitializeComponent() => AvaloniaXamlLoader.Load(this);
}
}

View File

@@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : tabXboxInfo.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Media information.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the Xbox media information.
//
// ==[ 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/>.
//
// ============================================================================
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
-->
<TabPage Text="Xbox" Visible="False" xmlns="http://schema.picoe.ca/eto.forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackLayout Orientation="Vertical">
<StackLayout Orientation="Vertical" ID="stkXboxInformation" Visible="False">
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxL0Video" Text="Video layer 0 size"/>
<TextBox ID="txtXboxL0Video" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxL1Video" Text="Video layer 1 size"/>
<TextBox ID="txtXboxL1Video" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxMiddleZone" Text="Middle zone size"/>
<TextBox ID="txtXboxMiddleZone" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxGameSize" Text="Game data size"/>
<TextBox ID="txtXboxGameSize" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxTotalSize" Text="Total size"/>
<TextBox ID="txtXboxTotalSize" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblXboxRealBreak" Text="Real layer break"/>
<TextBox ID="txtXboxRealBreak" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
</StackLayout>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True" VerticalAlignment="Stretch">
<GroupBox ID="grpXboxDmi" Text="Disc Manufacturing Information" Visible="False">
<TextArea ID="txtXboxDmi" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True" VerticalAlignment="Stretch">
<GroupBox ID="grpXboxSs" Text="Security Sector" Visible="False">
<TextArea ID="txtXboxSs" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<Button ID="btnSaveXboxSs" Click="OnBtnSaveXboxSsClick" Text="Save Xbox Security Sector" Visible="False"/>
</StackLayout>
</TabPage>

View File

@@ -1,140 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : tabXboxInfo.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Media information.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the Xbox media information.
//
// --[ 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.IO;
using Aaru.Core.Media.Info;
using Aaru.Decoders.Xbox;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace Aaru.Gui.Tabs
{
public class tabXboxInfo : TabPage
{
byte[] xboxSecuritySector;
public tabXboxInfo() => XamlReader.Load(this);
internal void LoadData(XgdInfo xgdInfo, byte[] dmi, byte[] securitySector,
SS.SecuritySector? decodedSecuritySector)
{
xboxSecuritySector = securitySector;
if(xgdInfo != null)
{
stkXboxInformation.Visible = true;
txtXboxL0Video.Text = $"{xgdInfo.L0Video} sectors";
txtXboxL1Video.Text = $"{xgdInfo.L1Video} sectors";
txtXboxMiddleZone.Text = $"{xgdInfo.MiddleZone} sectors";
txtXboxGameSize.Text = $"{xgdInfo.GameSize} sectors";
txtXboxTotalSize.Text = $"{xgdInfo.TotalSize} sectors";
txtXboxRealBreak.Text = xgdInfo.LayerBreak.ToString();
}
if(dmi != null)
{
if(DMI.IsXbox(dmi))
{
grpXboxDmi.Visible = true;
txtXboxDmi.Text = DMI.PrettifyXbox(dmi);
}
else if(DMI.IsXbox360(dmi))
{
grpXboxDmi.Visible = true;
txtXboxDmi.Text = DMI.PrettifyXbox360(dmi);
}
}
if(decodedSecuritySector.HasValue)
{
grpXboxSs.Visible = true;
txtXboxSs.Text = SS.Prettify(decodedSecuritySector);
}
btnSaveXboxSs.Visible = securitySector != null;
Visible = stkXboxInformation.Visible || grpXboxDmi.Visible || grpXboxSs.Visible || btnSaveXboxSs.Visible;
}
void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileFilter
{
Extensions = new[]
{
"*.bin"
},
Name = "Binary"
});
DialogResult result = dlgSaveBinary.ShowDialog(this);
if(result != DialogResult.Ok)
return;
var saveFs = new FileStream(dlgSaveBinary.FileName, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
protected void OnBtnSaveXboxSsClick(object sender, EventArgs e) => SaveElement(xboxSecuritySector);
#region XAML controls
#pragma warning disable 169
#pragma warning disable 649
StackLayout stkXboxInformation;
Label lblXboxL0Video;
TextBox txtXboxL0Video;
Label lblXboxL1Video;
TextBox txtXboxL1Video;
Label lblXboxMiddleZone;
TextBox txtXboxMiddleZone;
Label lblXboxGameSize;
TextBox txtXboxGameSize;
Label lblXboxTotalSize;
TextBox txtXboxTotalSize;
Label lblXboxRealBreak;
TextBox txtXboxRealBreak;
GroupBox grpXboxDmi;
TextArea txtXboxDmi;
GroupBox grpXboxSs;
TextArea txtXboxSs;
Button btnSaveXboxSs;
#pragma warning restore 169
#pragma warning restore 649
#endregion
}
}

View File

@@ -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; }

View 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);
}
}