Migrate dvd info from Eto.Forms to Avalonia.

This commit is contained in:
2020-04-12 15:04:48 +01:00
parent 65f8200d41
commit 939ae5510b
9 changed files with 200 additions and 243 deletions

View File

@@ -1279,12 +1279,12 @@
<e p="AtaInfoTab.xaml.cs" t="Include" />
<e p="CompactDiscInfoTab.xaml" t="Include" />
<e p="CompactDiscInfoTab.xaml.cs" t="Include" />
<e p="DvdInfoTab.xaml" t="Include" />
<e p="DvdInfoTab.xaml.cs" t="Include" />
<e p="ScsiInfoTab.xaml" t="Include" />
<e p="ScsiInfoTab.xaml.cs" t="Include" />
<e p="tabBlurayInfo.xeto" t="Include" />
<e p="tabBlurayInfo.xeto.cs" t="Include" />
<e p="tabDvdInfo.xeto" t="Include" />
<e p="tabDvdInfo.xeto.cs" t="Include" />
<e p="tabDvdWritableInfo.xeto" t="Include" />
<e p="tabDvdWritableInfo.xeto.cs" t="Include" />
<e p="tabPcmciaInfo.xeto" t="Include" />
@@ -1300,6 +1300,7 @@
<e p="AtaInfoViewModel.cs" t="Include" />
<e p="CompactDiscInfoViewModel.cs" t="Include" />
<e p="ConsoleWindowViewModel.cs" t="Include" />
<e p="DvdInfoViewModel.cs" t="Include" />
<e p="EncodingsDialogViewModel.cs" t="Include" />
<e p="ImageInfoViewModel.cs" t="Include" />
<e p="LicenseDialogViewModel.cs" t="Include" />

View File

@@ -132,6 +132,12 @@
</TabItem.Header>
<ContentControl Content="{Binding CompactDiscInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!DvdInfo}">
<TabItem.Header>
<TextBlock Text="DVD / HD DVD" />
</TabItem.Header>
<ContentControl Content="{Binding DvdInfo}" />
</TabItem>
</TabControl>
<StackPanel Orientation="Horizontal" Spacing="5">
<Button Command="{Binding EntropyCommand}">

View File

@@ -120,6 +120,7 @@ namespace Aaru.Gui.Panels
tabSsc.Visible = grpDensitySupport.Visible || grpMediumSupport.Visible || btnSaveDensitySupport.Visible ||
btnSaveMediumSupport.Visible;
/*
var tabCompactDiscInfo = new tabCompactDiscInfo();
@@ -132,6 +133,7 @@ namespace Aaru.Gui.Panels
tabInfos.Pages.Add(tabCompactDiscInfo);
*/
/*
var tabDvdInfo = new tabDvdInfo();
tabDvdInfo.LoadData(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi, scsiInfo.DvdCmi,
@@ -139,7 +141,7 @@ namespace Aaru.Gui.Panels
this.scsiInfo.DecodedPfi);
tabInfos.Pages.Add(tabDvdInfo);
*/
var tabXboxInfo = new tabXboxInfo();
tabXboxInfo.LoadData(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,

View File

@@ -0,0 +1,33 @@
<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.DvdInfoTab">
<Design.DataContext>
<vm:DvdInfoViewModel />
</Design.DataContext>
<StackPanel>
<TextBlock IsVisible="{Binding !!DvdPfiText}" Text="Physical Format Information" />
<TextBox IsReadOnly="True" IsVisible="{Binding !!DvdPfiText}" Text="{Binding DvdPfiText}" />
<TextBlock IsVisible="{Binding !!DvdCmiText}" Text="Copyright Management Information" />
<TextBox IsReadOnly="True" IsVisible="{Binding !!DvdCmiText}" Text="{Binding DvdCmiText}" />
<Button Command="{Binding SaveDvdPfiCommand}" IsVisible="{Binding SaveDvdPfiVisible}">
<TextBlock Text="Save Physical Format Information" />
</Button>
<Button Command="{Binding SaveDvdDmiCommand}" IsVisible="{Binding SaveDvdDmiVisible}">
<TextBlock Text="Save Disc Manufacturer Information" />
</Button>
<Button Command="{Binding SaveDvdCmiCommand}" IsVisible="{Binding SaveDvdCmiVisible}">
<TextBlock Text="Save Copyright Management Information" />
</Button>
<Button Command="{Binding SaveHdDvdCmiCommand}" IsVisible="{Binding SaveHdDvdCmiVisible}">
<TextBlock Text="Save Copyright Management Information" />
</Button>
<Button Command="{Binding SaveDvdBcaCommand}" IsVisible="{Binding SaveDvdBcaVisible}">
<TextBlock Text="Save Burst Cutting Area" />
</Button>
<Button Command="{Binding SaveDvdAacsCommand}" IsVisible="{Binding SaveDvdAacsVisible}">
<TextBlock Text="Save AACS Information" />
</Button>
</StackPanel>
</UserControl>

View File

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

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : tabDvdInfo.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Media information.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the DVD 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 xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Text="DVD"
Visible="False">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
<GroupBox ID="grpDvdPfi" Text="Physical Format Information" Visible="False">
<TextArea ID="txtDvdPfi" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
<GroupBox ID="grpDvdCmi" Text="Copyright Management Information" Visible="False">
<TextArea ID="txtDvdCmi" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<Button Click="OnBtnSaveDvdPfiClick" ID="btnSaveDvdPfi" Text="Save Physical Format Information"
Visible="False"/>
<Button Click="OnBtnSaveDvdDmiClick" ID="btnSaveDvdDmi" Text="Save Disc Manufacturer Information"
Visible="False"/>
<Button Click="OnBtnSaveDvdCmiClick" ID="btnSaveDvdCmi" Text="Save Copyright Management Information"
Visible="False"/>
<Button Click="OnBtnSaveHdDvdCmiClick" ID="btnSaveHdDvdCmi" Text="Save Copyright Management Information"
Visible="False"/>
<Button Click="OnBtnSaveDvdBcaClick" ID="btnSaveDvdBca" Text="Save Burst Cutting Area" Visible="False"/>
<Button Click="OnBtnSaveDvdAacsClick" ID="btnSaveDvdAacs" Text="Save AACS Information" Visible="False"/>
</StackLayout>
</TabPage>

View File

@@ -1,161 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : tabDvdInfo.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Media information.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the DVD 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.CommonTypes;
using Aaru.Decoders.DVD;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace Aaru.Gui.Tabs
{
public class tabDvdInfo : TabPage
{
byte[] DvdAacs;
byte[] DvdBca;
byte[] DvdCmi;
byte[] DvdDmi;
byte[] DvdPfi;
byte[] HddvdCopyrightInformation;
public tabDvdInfo() => XamlReader.Load(this);
internal void LoadData(MediaType mediaType, byte[] pfi, byte[] dmi, byte[] cmi, byte[] hdCopyrightInformation,
byte[] bca, byte[] aacs, PFI.PhysicalFormatInformation? decodedPfi)
{
DvdPfi = pfi;
DvdDmi = dmi;
DvdCmi = cmi;
HddvdCopyrightInformation = hdCopyrightInformation;
DvdBca = bca;
DvdAacs = aacs;
switch(mediaType)
{
case MediaType.HDDVDROM:
case MediaType.HDDVDRAM:
case MediaType.HDDVDR:
case MediaType.HDDVDRW:
case MediaType.HDDVDRDL:
case MediaType.HDDVDRWDL:
Text = "HD DVD";
break;
default:
Text = "DVD";
break;
}
if(decodedPfi.HasValue)
{
grpDvdPfi.Visible = true;
txtDvdPfi.Text = PFI.Prettify(decodedPfi);
}
if(cmi != null)
{
grpDvdCmi.Visible = true;
txtDvdCmi.Text = CSS_CPRM.PrettifyLeadInCopyright(cmi);
btnSaveDvdCmi.Visible = true;
}
btnSaveDvdPfi.Visible = pfi != null;
btnSaveDvdDmi.Visible = dmi != null;
btnSaveDvdCmi.Visible = cmi != null;
btnSaveHdDvdCmi.Visible = hdCopyrightInformation != null;
btnSaveDvdBca.Visible = bca != null;
btnSaveDvdAacs.Visible = aacs != null;
Visible = grpDvdPfi.Visible || grpDvdCmi.Visible || btnSaveDvdPfi.Visible ||
btnSaveDvdDmi.Visible ||
btnSaveDvdCmi.Visible || btnSaveHdDvdCmi.Visible || btnSaveDvdBca.Visible ||
btnSaveDvdAacs.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 OnBtnSaveDvdPfiClick(object sender, EventArgs e) => SaveElement(DvdPfi);
protected void OnBtnSaveDvdDmiClick(object sender, EventArgs e) => SaveElement(DvdDmi);
protected void OnBtnSaveDvdCmiClick(object sender, EventArgs e) => SaveElement(DvdCmi);
protected void OnBtnSaveHdDvdCmiClick(object sender, EventArgs e) => SaveElement(HddvdCopyrightInformation);
protected void OnBtnSaveDvdBcaClick(object sender, EventArgs e) => SaveElement(DvdBca);
protected void OnBtnSaveDvdAacsClick(object sender, EventArgs e) => SaveElement(DvdAacs);
#region XAML controls
#pragma warning disable 169
#pragma warning disable 649
GroupBox grpDvdPfi;
TextArea txtDvdPfi;
GroupBox grpDvdCmi;
TextArea txtDvdCmi;
GroupBox grpHdDvdCmi;
TextArea txtHdDvdCmi;
Button btnSaveDvdPfi;
Button btnSaveDvdDmi;
Button btnSaveDvdCmi;
Button btnSaveHdDvdCmi;
Button btnSaveDvdBca;
Button btnSaveDvdAacs;
#pragma warning restore 169
#pragma warning restore 649
#endregion
}
}

View File

@@ -0,0 +1,122 @@
using System.Collections.Generic;
using System.IO;
using System.Reactive;
using Aaru.CommonTypes;
using Aaru.Decoders.DVD;
using Avalonia.Controls;
using ReactiveUI;
namespace Aaru.Gui.ViewModels
{
public class DvdInfoViewModel
{
readonly byte[] _dvdAacs;
readonly byte[] _dvdBca;
readonly byte[] _dvdCmi;
readonly byte[] _dvdDmi;
readonly byte[] _dvdPfi;
readonly byte[] _hddvdCopyrightInformation;
readonly Window _view;
public DvdInfoViewModel(MediaType mediaType, byte[] pfi, byte[] dmi, byte[] cmi, byte[] hdCopyrightInformation,
byte[] bca, byte[] aacs, PFI.PhysicalFormatInformation? decodedPfi, Window view)
{
_dvdPfi = pfi;
_dvdDmi = dmi;
_dvdCmi = cmi;
_hddvdCopyrightInformation = hdCopyrightInformation;
_dvdBca = bca;
_dvdAacs = aacs;
_view = view;
SaveDvdPfiCommand = ReactiveCommand.Create(ExecuteSaveDvdPfiCommand);
SaveDvdDmiCommand = ReactiveCommand.Create(ExecuteSaveDvdDmiCommand);
SaveDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveDvdCmiCommand);
SaveHdDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveHdDvdCmiCommand);
SaveDvdBcaCommand = ReactiveCommand.Create(ExecuteSaveDvdBcaCommand);
SaveDvdAacsCommand = ReactiveCommand.Create(ExecuteSaveDvdAacsCommand);
/* TODO: Pass back
switch(mediaType)
{
case MediaType.HDDVDROM:
case MediaType.HDDVDRAM:
case MediaType.HDDVDR:
case MediaType.HDDVDRW:
case MediaType.HDDVDRDL:
case MediaType.HDDVDRWDL:
Text = "HD DVD";
break;
default:
Text = "DVD";
break;
}
*/
if(decodedPfi.HasValue)
DvdPfiText = PFI.Prettify(decodedPfi);
if(cmi != null)
DvdCmiText = CSS_CPRM.PrettifyLeadInCopyright(cmi);
SaveDvdPfiVisible = pfi != null;
SaveDvdDmiVisible = dmi != null;
SaveDvdCmiVisible = cmi != null;
SaveHdDvdCmiVisible = hdCopyrightInformation != null;
SaveDvdBcaVisible = bca != null;
SaveDvdAacsVisible = aacs != null;
}
public ReactiveCommand<Unit, Unit> SaveDvdPfiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdDmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHdDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdBcaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdAacsCommand { get; }
public string DvdPfiText { get; }
public string DvdCmiText { get; }
public bool SaveDvdPfiVisible { get; }
public bool SaveDvdDmiVisible { get; }
public bool SaveDvdCmiVisible { get; }
public bool SaveHdDvdCmiVisible { get; }
public bool SaveDvdBcaVisible { get; }
public bool SaveDvdAacsVisible { 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();
}
protected void ExecuteSaveDvdPfiCommand() => SaveElement(_dvdPfi);
protected void ExecuteSaveDvdDmiCommand() => SaveElement(_dvdDmi);
protected void ExecuteSaveDvdCmiCommand() => SaveElement(_dvdCmi);
protected void ExecuteSaveHdDvdCmiCommand() => SaveElement(_hddvdCopyrightInformation);
protected void ExecuteSaveDvdBcaCommand() => SaveElement(_dvdBca);
protected void ExecuteSaveDvdAacsCommand() => SaveElement(_dvdAacs);
}
}

View File

@@ -8,6 +8,7 @@ using Aaru.CommonTypes.Interfaces;
using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Decoders.CD;
using Aaru.Decoders.DVD;
using Aaru.Decoders.SCSI;
using Aaru.Gui.Models;
using Aaru.Gui.Tabs;
@@ -340,7 +341,6 @@ namespace Aaru.Gui.ViewModels
mediaCatalogueNumber, null, _view)
};
/* TODO: tabDvdInfo
byte[] dvdPfi = null;
byte[] dvdDmi = null;
byte[] dvdCmi = null;
@@ -371,13 +371,12 @@ namespace Aaru.Gui.ViewModels
imageFormat.Info.ReadableMediaTags.Contains(MediaTagType.DVD_BCA))
dvdBca = imageFormat.ReadDiskTag(MediaTagType.DVD_BCA);
var tabDvdInfo = new tabDvdInfo();
DvdInfo = new DvdInfoTab
{
DataContext = new DvdInfoViewModel(imageFormat.Info.MediaType, dvdPfi, dvdDmi, dvdCmi,
hddvdCopyrightInformation, dvdBca, null, decodedPfi, _view)
};
tabDvdInfo.LoadData(imageFormat.Info.MediaType, dvdPfi, dvdDmi, dvdCmi, hddvdCopyrightInformation, dvdBca,
null, decodedPfi);
tabInfos.Pages.Add(tabDvdInfo);
*/
/* TODO: tabDvdWritableinfo
byte[] dvdRamDds = null;
@@ -653,6 +652,7 @@ namespace Aaru.Gui.ViewModels
public ScsiInfoTab ScsiInfo { get; }
public AtaInfoTab AtaInfo { get; }
public CompactDiscInfoTab CompactDiscInfo { get; }
public DvdInfoTab DvdInfo { get; }
public Bitmap MediaLogo { get; }
public string ImagePathText { get; }
public string FilterText { get; }