Migrate media info panel from Eto.Forms to Avalonia.

This commit is contained in:
2020-04-15 05:52:13 +01:00
parent e5a73f86de
commit d8ac5cf9a8
10 changed files with 627 additions and 884 deletions

View File

@@ -1219,8 +1219,6 @@
<e p="Forms" t="Include">
<e p="frmDump.xeto" t="Include" />
<e p="frmDump.xeto.cs" t="Include" />
<e p="frmMain.xeto" t="Include" />
<e p="frmMain.xeto.cs" t="Include" />
<e p="frmMediaScan.xeto" t="Include" />
<e p="frmMediaScan.xeto.cs" t="Include" />
</e>
@@ -1269,10 +1267,10 @@
<e p="FileSystemPanel.xaml.cs" t="Include" />
<e p="ImageInfoPanel.xaml" t="Include" />
<e p="ImageInfoPanel.xaml.cs" t="Include" />
<e p="MediaInfoPanel.xaml" t="Include" />
<e p="MediaInfoPanel.xaml.cs" t="Include" />
<e p="PartitionPanel.xaml" t="Include" />
<e p="PartitionPanel.xaml.cs" t="Include" />
<e p="pnlScsiInfo.xeto" t="Include" />
<e p="pnlScsiInfo.xeto.cs" t="Include" />
<e p="SubdirectoryPanel.xaml" t="Include" />
<e p="SubdirectoryPanel.xaml.cs" t="Include" />
</e>
@@ -1318,6 +1316,7 @@
<e p="ImageVerifyViewModel.cs" t="Include" />
<e p="LicenseDialogViewModel.cs" t="Include" />
<e p="MainWindowViewModel.cs" t="Include" />
<e p="MediaInfoViewModel.cs" t="Include" />
<e p="PartitionViewModel.cs" t="Include" />
<e p="PcmciaInfoViewModel.cs" t="Include" />
<e p="PluginsDialogViewModel.cs" t="Include" />

View File

@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : frmMain.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Main window.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the main GUI window.
//
// ==[ 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
// ****************************************************************************/
-->
<Form xmlns="http://schema.picoe.ca/eto.forms" Title="Aaru" ClientSize="600, 450" Padding="10">
<Splitter Orientation="Horizontal" Panel1MinimumSize="200" FixedPanel="Panel1" ID="splMain">
<Splitter.Panel1>
<TreeGridView ID="treeImages" SelectedItemChanged="OnTreeImagesSelectedItemChanged"
Expanding="OnTreeImagesItemExpanding"/>
</Splitter.Panel1>
<Splitter.Panel2>
<Panel/>
</Splitter.Panel2>
</Splitter>
<Form.Menu>
<MenuBar>
<ButtonMenuItem Text="&amp;File">
<ButtonMenuItem Text="&amp;Open" Click="OnMenuOpen"/>
</ButtonMenuItem>
<ButtonMenuItem Text="&amp;Devices">
<ButtonMenuItem Text="&amp;Refresh" Click="OnDeviceRefresh" Shortcut="F5"/>
</ButtonMenuItem>
<ButtonMenuItem Text="&amp;Window">
<ButtonMenuItem Text="&amp;Console" Click="OnMenuConsole"/>
</ButtonMenuItem>
<ButtonMenuItem Text="&amp;Help">
<ButtonMenuItem Text="&amp;Encodings" Click="OnMenuEncodings"/>
<ButtonMenuItem Text="&amp;Plugins" Click="OnMenuPlugins"/>
<ButtonMenuItem Text="&amp;Statistics" Click="OnMenuStatistics"/>
</ButtonMenuItem>
<MenuBar.ApplicationItems>
<ButtonMenuItem Text="Settings.." Shortcut="{On Control+O, Mac=Application+Comma}"
Click="OnMenuSettings"/>
</MenuBar.ApplicationItems>
<MenuBar.QuitItem>
<ButtonMenuItem Text="Quit" Shortcut="CommonModifier+Q" Click="OnMenuQuit"/>
</MenuBar.QuitItem>
<MenuBar.AboutItem>
<ButtonMenuItem Text="About..." Click="OnMenuAbout"/>
</MenuBar.AboutItem>
</MenuBar>
</Form.Menu>
</Form>

View File

@@ -1,321 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : frmMain.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Main window.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements main GUI window.
//
// --[ 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.ComponentModel;
using System.IO;
using Aaru.Console;
using Aaru.Core;
using Aaru.Core.Media.Info;
using Aaru.Devices;
using Aaru.Gui.Panels;
using Eto.Drawing;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace Aaru.Gui.Forms
{
public class frmMain : Form
{
readonly Bitmap devicesIcon;
readonly Bitmap ejectIcon;
readonly Bitmap hardDiskIcon;
readonly Bitmap imagesIcon;
readonly Label lblError;
/// <summary>This is to remember that column is an image to be set in future</summary>
readonly Image nullImage;
readonly Bitmap opticalIcon;
readonly TreeGridItem placeholderItem;
readonly Bitmap removableIcon;
readonly Bitmap sdIcon;
readonly Bitmap tapeIcon;
readonly TreeGridItemCollection treeImagesItems;
readonly ContextMenu treeImagesMenu;
readonly Bitmap usbIcon;
bool closing;
GridView grdFiles;
TreeGridView treeImages;
public frmMain(bool debug, bool verbose)
{
XamlReader.Load(this);
lblError = new Label();
grdFiles = new GridView();
nullImage = null;
ConsoleHandler.Init();
ConsoleHandler.Debug = debug;
ConsoleHandler.Verbose = verbose;
treeImagesItems = new TreeGridItemCollection();
treeImages.Columns.Add(new GridColumn
{
HeaderText = "Name", DataCell = new ImageTextCell(0, 1)
});
treeImages.AllowMultipleSelection = false;
treeImages.ShowHeader = false;
treeImages.DataStore = treeImagesItems;
// TODO: SVG
imagesIcon =
new Bitmap(ResourceHandler.
GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.inode-directory.png"));
devicesIcon =
new Bitmap(ResourceHandler.GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.computer.png"));
hardDiskIcon =
new Bitmap(ResourceHandler.GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.drive-harddisk.png"));
opticalIcon =
new Bitmap(ResourceHandler.GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.drive-optical.png"));
usbIcon =
new Bitmap(ResourceHandler.
GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.drive-removable-media-usb.png"));
removableIcon =
new Bitmap(ResourceHandler.
GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.drive-removable-media.png"));
sdIcon =
new Bitmap(ResourceHandler.
GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.media-flash-sd-mmc.png"));
tapeIcon =
new Bitmap(ResourceHandler.GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.media-tape.png"));
ejectIcon =
new Bitmap(ResourceHandler.GetResourceStream("Aaru.Gui.Assets.Icons.oxygen._32x32.media-eject.png"));
imagesRoot = new TreeGridItem
{
Values = new object[]
{
imagesIcon, "Images"
}
};
devicesRoot = new TreeGridItem
{
Values = new object[]
{
devicesIcon, "Devices"
}
};
treeImagesItems.Add(imagesRoot);
treeImagesItems.Add(devicesRoot);
placeholderItem = new TreeGridItem
{
Values = new object[]
{
nullImage, "You should not be seeing this"
}
};
Closing += OnClosing;
treeImagesMenu = new ContextMenu();
treeImagesMenu.Opening += OnTreeImagesMenuOpening;
treeImages.ContextMenu = treeImagesMenu;
}
void OnTreeImagesMenuOpening(object sender, EventArgs e)
{
OnTreeImagesSelectedItemChanged(treeImages, e);
treeImagesMenu.Items.Clear();
var menuItem = new ButtonMenuItem
{
Text = "Close all images"
};
menuItem.Click += CloseAllImages;
treeImagesMenu.Items.Add(menuItem);
menuItem = new ButtonMenuItem
{
Text = "Refresh devices"
};
// menuItem.Click += OnDeviceRefresh;
treeImagesMenu.Items.Add(menuItem);
if(!(treeImages.SelectedItem is TreeGridItem selectedItem))
return;
if(selectedItem.Values.Length < 4)
return;
}
// TODO
void CloseAllImages(object sender, EventArgs eventArgs) => Eto.Forms.MessageBox.Show("Not yet implemented");
void OnClosing(object sender, CancelEventArgs e)
{
// This prevents an infinite loop of crashes :p
if(closing)
return;
closing = true;
Application.Instance.Quit();
}
protected void OnTreeImagesSelectedItemChanged(object sender, EventArgs e)
{
if(!(sender is TreeGridView tree))
return;
if(!(tree.SelectedItem is TreeGridItem selectedItem))
return;
splMain.Panel2 = null;
if(selectedItem.Values.Length >= 4 &&
selectedItem.Values[3] is Panel infoPanel)
{
splMain.Panel2 = infoPanel;
return;
}
if(selectedItem.Values.Length < 4)
return;
switch(selectedItem.Values[3])
{
case string devErrorMessage when selectedItem.Parent == devicesRoot:
lblError.Text = devErrorMessage;
splMain.Panel2 = lblError;
break;
}
}
protected void OnTreeImagesItemExpanding(object sender, TreeGridViewItemCancelEventArgs e)
{
// First expansion of a device
if((e.Item as TreeGridItem)?.Children?.Count != 1 ||
((TreeGridItem)e.Item).Children[0] != placeholderItem)
return;
if(((TreeGridItem)e.Item).Parent == devicesRoot)
{
var deviceItem = (TreeGridItem)e.Item;
deviceItem.Children.Clear();
Device dev;
try
{
dev = new Device((string)deviceItem.Values[2]);
if(dev.IsRemote)
Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem,
dev.RemoteOperatingSystemVersion, dev.RemoteArchitecture);
if(dev.Error)
{
deviceItem.Values[3] = $"Error {dev.LastError} opening device";
e.Cancel = true;
treeImages.ReloadData();
treeImages.SelectedItem = deviceItem;
return;
}
}
catch(SystemException ex)
{
deviceItem.Values[3] = ex.Message;
e.Cancel = true;
treeImages.ReloadData();
AaruConsole.ErrorWriteLine(ex.Message);
treeImages.SelectedItem = deviceItem;
return;
}
if(!dev.IsRemovable)
deviceItem.Children.Add(new TreeGridItem
{
Values = new object[]
{
nullImage, "Non-removable device commands not yet implemented"
}
});
else
{
// TODO: Removable non-SCSI?
var scsiInfo = new ScsiInfo(dev);
if(!scsiInfo.MediaInserted)
deviceItem.Children.Add(new TreeGridItem
{
Values = new object[]
{
ejectIcon, "No media inserted"
}
});
else
{
// TODO: SVG
Stream logo =
ResourceHandler.GetResourceStream($"Aaru.Gui.Assets.Logos.Media.{scsiInfo.MediaType}.png");
deviceItem.Children.Add(new TreeGridItem
{
Values = new[]
{
logo == null ? null : new Bitmap(logo), scsiInfo.MediaType, deviceItem.Values[2],
new pnlScsiInfo(scsiInfo, (string)deviceItem.Values[2])
}
});
}
}
dev.Close();
}
}
#region XAML IDs
readonly TreeGridItem devicesRoot;
readonly TreeGridItem imagesRoot;
Splitter splMain;
#endregion
}
}

View File

@@ -1,3 +1,4 @@
using Aaru.Gui.ViewModels;
using Avalonia.Media.Imaging;
namespace Aaru.Gui.Models
@@ -7,5 +8,8 @@ namespace Aaru.Gui.Models
public Bitmap Icon { get; set; }
public string Name { get; set; }
public string DevicePath { get; set; }
public bool NonRemovable { get; set; }
public bool NoMediaInserted { get; set; }
public MediaInfoViewModel ViewModel { get; set; }
}
}

View File

@@ -0,0 +1,115 @@
<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.Panels.MediaInfoPanel">
<Design.DataContext>
<vm:MediaInfoViewModel />
</Design.DataContext>
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center" Text="Media information" />
<Image HorizontalAlignment="Center" Source="{Binding MediaLogo}" />
<TabControl>
<TabItem IsVisible="{Binding GeneralVisible}">
<TabItem.Header>
<TextBlock Text="General" />
</TabItem.Header>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="Media type" /> <TextBox Text="{Binding MediaType}" IsReadOnly="True" />
</StackPanel>
<TextBlock IsVisible="{Binding !!MediaSize}" Text="{Binding MediaSize}" />
<StackPanel Orientation="Horizontal" IsVisible="{Binding !!MediaSerial}">
<TextBlock Text="Media serial number" />
<TextBox Text="{Binding MediaSerial}" IsReadOnly="True" />
</StackPanel>
<Button IsVisible="{Binding SaveReadMediaSerialVisible}"
Command="{Binding SaveReadMediaSerialCommand}">
<TextBlock Text="Save READ MEDIA SERIAL NUMBER response" />
</Button>
<Button IsVisible="{Binding SaveReadCapacityVisible}" Command="{Binding SaveReadCapacityCommand}">
<TextBlock Text="Save READ CAPACITY response" />
</Button>
<Button IsVisible="{Binding SaveReadCapacity16Visible}"
Command="{Binding SaveReadCapacity16Command}">
<TextBlock Text="Save READ CAPACITY (16) response" />
</Button>
</StackPanel>
</TabItem>
<TabItem IsVisible="{Binding MmcVisible}">
<TabItem.Header>
<TextBlock Text="MMC" />
</TabItem.Header>
<StackPanel Orientation="Vertical">
<Button IsVisible="{Binding SaveGetConfigurationVisible}"
Command="{Binding SaveGetConfigurationCommand}">
<TextBlock Text="Save GET CONFIGURATION response" />
</Button>
<Button IsVisible="{Binding SaveRecognizedFormatLayersVisible}"
Command="{Binding SaveRecognizedFormatLayersCommand}">
<TextBlock Text="Save RECOGNIZED FORMAT LAYERS response" />
</Button>
<Button IsVisible="{Binding SaveWriteProtectionStatusVisible}"
Command="{Binding SaveWriteProtectionStatusCommand}">
<TextBlock Text="Save WRITE PROTECTION STATUS response" />
</Button>
</StackPanel>
</TabItem>
<TabItem IsVisible="{Binding SscVisible}">
<TabItem.Header>
<TextBlock Text="SSC" />
</TabItem.Header>
<StackPanel Orientation="Vertical">
<TextBlock IsVisible="{Binding !!DensitySupport}"
Text="Densities supported by currently inserted media" />
<TextBox IsVisible="{Binding !!DensitySupport}" Text="{Binding DensitySupport}" IsReadOnly="True" />
<TextBlock IsVisible="{Binding !!MediumSupport}" Text="Medium types currently inserted in device" />
<TextBox Text="{Binding MediumSupport}" IsReadOnly="True" />
<Button IsVisible="{Binding SaveDensitySupportVisible}"
Command="{Binding SaveDensitySupportCommand}">
<TextBlock Text="Save REPORT DENSITY SUPPORT (MEDIA) response" />
</Button>
<Button IsVisible="{Binding SaveMediumSupportVisible}" Command="{Binding SaveMediumSupportCommand}">
<TextBlock Text="Save REPORT DENSITY SUPPORT (MEDIUM &amp; MEDIA) response" />
</Button>
</StackPanel>
</TabItem>
<TabItem IsVisible="{Binding !!CompactDiscInfo}">
<TabItem.Header>
<TextBlock Text="CompactDisc" />
</TabItem.Header>
<ContentControl Content="{Binding CompactDiscInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!DvdInfo}">
<TabItem.Header>
<TextBlock Text="DVD" />
</TabItem.Header>
<ContentControl Content="{Binding DvdInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!DvdWritableInfo}">
<TabItem.Header>
<TextBlock Text="DVD±R(W)" />
</TabItem.Header>
<ContentControl Content="{Binding DvdWritableInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!XboxInfo}">
<TabItem.Header>
<TextBlock Text="Xbox" />
</TabItem.Header>
<ContentControl Content="{Binding XboxInfo}" />
</TabItem>
<TabItem IsVisible="{Binding !!BlurayInfo}">
<TabItem.Header>
<TextBlock Text="Blu-ray" />
</TabItem.Header>
<ContentControl Content="{Binding BlurayInfo}" />
</TabItem>
</TabControl>
<Button Command="{Binding DumpCommand}">
<TextBlock Text="Dump media to image" />
</Button>
<Button Command="{Binding ScanCommand}">
<TextBlock Text="Scan media surface" />
</Button>
</StackPanel>
</UserControl>

View File

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

View File

@@ -1,113 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : pnlScsiInfo.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : SCSI media information panel.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the SCSI 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/>.
//
// ============================================================================
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
-->
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Aaru.Gui.Controls;assembly=Aaru.Gui">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Center">
<Label ID="lblMediaInfo" Text="Media information"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Center" VerticalAlignment="Top">
<ImageView ID="imgMediaLogo" Visible="False"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Center" VerticalAlignment="Top">
<local:SvgImageView ID="svgMediaLogo" Visible="False"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True" VerticalAlignment="Stretch">
<TabControl ID="tabInfos">
<TabPage ID="tabGeneral" Text="General" Visible="False">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label ID="lblType" Text="Media type"/>
<TextBox ID="txtType" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Left">
<Label ID="lblMediaSize" Visible="False"
Text="Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal" ID="stkMediaSerial" Visible="False">
<Label ID="lblMediaSerial" Text="Media serial number"/>
<TextBox ID="txtMediaSerial" ReadOnly="True"/>
</StackLayout>
</StackLayoutItem>
<Button ID="btnSaveReadMediaSerial" Text="Save READ MEDIA SERIAL NUMBER response"
Click="OnBtnSaveReadMediaSerialClick" Visible="False"/>
<Button ID="btnSaveReadCapacity" Text="Save READ CAPACITY response"
Click="OnBtnSaveReadCapacityClick" Visible="False"/>
<Button ID="btnSaveReadCapacity16" Text="Save READ CAPACITY (16) response"
Click="OnBtnSaveReadCapacity16Click" Visible="False"/>
</StackLayout>
</TabPage>
<TabPage ID="tabMmc" Text="MMC" Visible="False">
<StackLayout Orientation="Vertical">
<Button Click="OnBtnSaveGetConfigurationClick" ID="btnSaveGetConfiguration"
Text="Save GET CONFIGURATION response" Visible="False"/>
<Button Click="OnBtnSaveRecognizedFormatLayersClick" ID="btnSaveRecognizedFormatLayers"
Text="Save RECOGNIZED FORMAT LAYERS response" Visible="False"/>
<Button Click="OnBtnSaveWriteProtectionStatusClick" ID="btnSaveWriteProtectionStatus"
Text="Save WRITE PROTECTION STATUS response" Visible="False"/>
</StackLayout>
</TabPage>
<TabPage ID="tabSsc" Text="SSC" Visible="False">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<GroupBox ID="grpDensitySupport" Text="Densities supported by currently inserted media"
Visible="False">
<TextArea ID="txtDensitySupport" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<GroupBox ID="grpMediumSupport" Text="Medium types currently inserted in device"
Visible="False">
<TextArea ID="txtMediumSupport" ReadOnly="True"/>
</GroupBox>
</StackLayoutItem>
<Button Click="OnBtnSaveDensitySupportClick" ID="btnSaveDensitySupport"
Text="Save REPORT DENSITY SUPPORT (MEDIA) response" Visible="False"/>
<Button Click="OnBtnSaveMediumSupportClick" ID="btnSaveMediumSupport"
Text="Save REPORT DENSITY SUPPORT (MEDIUM &amp; MEDIA) response" Visible="False"/>
</StackLayout>
</TabPage>
</TabControl>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Left" VerticalAlignment="Bottom">
<Button Click="OnBtnDumpClick" ID="btnDump" Text="Dump media to image"/>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Left" VerticalAlignment="Bottom">
<Button Click="OnBtnScanClick" ID="btnScan" Text="Scan media surface"/>
</StackLayoutItem>
</StackLayout>
</Panel>

View File

@@ -1,318 +0,0 @@
// /***************************************************************************
// Aaru Data Preservation Suite
// ----------------------------------------------------------------------------
//
// Filename : pnlScsiInfo.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : SCSI media information panel.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements the SCSI 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/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2020 Natalia Portillo
// ****************************************************************************/
using System;
using System.IO;
using System.Text;
using Aaru.CommonTypes;
using Aaru.Core.Media.Info;
using Aaru.Decoders.SCSI.SSC;
using Aaru.Gui.Controls;
using Aaru.Gui.Forms;
using Aaru.Gui.Tabs;
using Eto.Drawing;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace Aaru.Gui.Panels
{
public class pnlScsiInfo : Panel
{
readonly string devicePath;
readonly ScsiInfo scsiInfo;
public pnlScsiInfo(ScsiInfo scsiInfo, string devicePath)
{
XamlReader.Load(this);
this.scsiInfo = scsiInfo;
Stream logo = ResourceHandler.GetResourceStream($"Aaru.Gui.Assets.Logos.Media.{scsiInfo.MediaType}.svg");
/* if(logo != null)
{
svgMediaLogo.SvgStream = logo;
svgMediaLogo.Visible = true;
}
else
{*/
logo = ResourceHandler.GetResourceStream($"Aaru.Gui.Assets.Logos.Media.{scsiInfo.MediaType}.png");
if(logo != null)
{
imgMediaLogo.Image = new Bitmap(logo);
imgMediaLogo.Visible = true;
}
//}
txtType.Text = scsiInfo.MediaType.ToString();
lblMediaSize.Text =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {scsiInfo.Blocks * scsiInfo.BlockSize} bytes)";
lblMediaSize.Visible = scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0;
if(scsiInfo.MediaSerialNumber != null)
{
stkMediaSerial.Visible = true;
var sbSerial = new StringBuilder();
for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
txtMediaSerial.Text = sbSerial.ToString();
}
btnSaveReadMediaSerial.Visible = this.scsiInfo.MediaSerialNumber != null;
btnSaveReadCapacity.Visible = this.scsiInfo.ReadCapacity != null;
btnSaveReadCapacity16.Visible = this.scsiInfo.ReadCapacity16 != null;
btnSaveGetConfiguration.Visible = this.scsiInfo.MmcConfiguration != null;
btnSaveRecognizedFormatLayers.Visible = this.scsiInfo.RecognizedFormatLayers != null;
btnSaveWriteProtectionStatus.Visible = this.scsiInfo.WriteProtectionStatus != null;
tabMmc.Visible = btnSaveGetConfiguration.Visible || btnSaveRecognizedFormatLayers.Visible ||
btnSaveWriteProtectionStatus.Visible;
if(this.scsiInfo.DensitySupportHeader.HasValue)
{
grpDensitySupport.Visible = true;
txtDensitySupport.Text = DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
}
if(this.scsiInfo.MediaTypeSupportHeader.HasValue)
{
grpMediumSupport.Visible = true;
txtMediumSupport.Text = DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
}
btnSaveDensitySupport.Visible = scsiInfo.DensitySupport != null;
btnSaveMediumSupport.Visible = scsiInfo.MediaTypeSupport != null;
tabSsc.Visible = grpDensitySupport.Visible || grpMediumSupport.Visible || btnSaveDensitySupport.Visible ||
btnSaveMediumSupport.Visible;
/*
var tabCompactDiscInfo = new tabCompactDiscInfo();
tabCompactDiscInfo.LoadData(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.CompactDiscInformation, scsiInfo.Session,
scsiInfo.RawToc, this.scsiInfo.Pma, this.scsiInfo.CdTextLeadIn,
this.scsiInfo.DecodedToc, this.scsiInfo.DecodedAtip,
this.scsiInfo.DecodedSession, this.scsiInfo.FullToc,
this.scsiInfo.DecodedCdTextLeadIn, this.scsiInfo.DecodedCompactDiscInformation,
this.scsiInfo.Mcn, this.scsiInfo.Isrcs);
tabInfos.Pages.Add(tabCompactDiscInfo);
*/
/*
var tabDvdInfo = new tabDvdInfo();
tabDvdInfo.LoadData(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi, scsiInfo.DvdCmi,
scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca, scsiInfo.DvdAacs,
this.scsiInfo.DecodedPfi);
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();
tabDvdWritableInfo.LoadData(scsiInfo.MediaType, scsiInfo.DvdRamDds, scsiInfo.DvdRamCartridgeStatus,
scsiInfo.DvdRamSpareArea, scsiInfo.LastBorderOutRmd,
scsiInfo.DvdPreRecordedInfo, scsiInfo.DvdrMediaIdentifier,
scsiInfo.DvdrPhysicalInformation, scsiInfo.HddvdrMediumStatus,
scsiInfo.HddvdrLastRmd, scsiInfo.DvdrLayerCapacity,
scsiInfo.DvdrDlMiddleZoneStart, scsiInfo.DvdrDlJumpIntervalSize,
scsiInfo.DvdrDlManualLayerJumpStartLba, scsiInfo.DvdrDlRemapAnchorPoint,
scsiInfo.DvdPlusAdip, scsiInfo.DvdPlusDcb);
tabInfos.Pages.Add(tabDvdWritableInfo);
*/
/*
var tabBlurayInfo = new tabBlurayInfo();
tabBlurayInfo.LoadData(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea, scsiInfo.BlurayDds,
scsiInfo.BlurayCartridgeStatus, scsiInfo.BluraySpareAreaInformation,
scsiInfo.BlurayPowResources, scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl,
scsiInfo.BlurayPac);
tabInfos.Pages.Add(tabBlurayInfo);
*/
this.devicePath = devicePath;
}
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 OnBtnSaveReadMediaSerialClick(object sender, EventArgs e) =>
SaveElement(scsiInfo.MediaSerialNumber);
protected void OnBtnSaveReadCapacityClick(object sender, EventArgs e) => SaveElement(scsiInfo.ReadCapacity);
protected void OnBtnSaveReadCapacity16Click(object sender, EventArgs e) => SaveElement(scsiInfo.ReadCapacity16);
protected void OnBtnSaveGetConfigurationClick(object sender, EventArgs e) =>
SaveElement(scsiInfo.MmcConfiguration);
protected void OnBtnSaveRecognizedFormatLayersClick(object sender, EventArgs e) =>
SaveElement(scsiInfo.RecognizedFormatLayers);
protected void OnBtnSaveWriteProtectionStatusClick(object sender, EventArgs e) =>
SaveElement(scsiInfo.WriteProtectionStatus);
protected void OnBtnSaveDensitySupportClick(object sender, EventArgs e) => SaveElement(scsiInfo.DensitySupport);
protected void OnBtnSaveMediumSupportClick(object sender, EventArgs e) =>
SaveElement(scsiInfo.MediaTypeSupport);
protected void OnBtnSaveXboxSsClick(object sender, EventArgs e) => SaveElement(scsiInfo.XboxSecuritySector);
protected void OnBtnDumpClick(object sender, EventArgs e)
{
if(scsiInfo.MediaType == MediaType.GDR ||
scsiInfo.MediaType == MediaType.GDROM)
{
Eto.Forms.MessageBox.Show("GD-ROM dump support is not yet implemented.", MessageBoxType.Error);
return;
}
if((scsiInfo.MediaType == MediaType.XGD || scsiInfo.MediaType == MediaType.XGD2 ||
scsiInfo.MediaType == MediaType.XGD3) &&
scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true)
Eto.Forms.MessageBox.Show("Dumping Xbox discs require a Kreon drive.", MessageBoxType.Error);
var dumpForm = new frmDump(devicePath, scsiInfo.DeviceInfo, scsiInfo);
dumpForm.Show();
}
protected void OnBtnScanClick(object sender, EventArgs e)
{
if(scsiInfo.MediaType == MediaType.GDR ||
scsiInfo.MediaType == MediaType.GDROM)
{
Eto.Forms.MessageBox.Show("GD-ROM scan support is not yet implemented.", MessageBoxType.Error);
return;
}
if(scsiInfo.MediaType == MediaType.XGD ||
scsiInfo.MediaType == MediaType.XGD2 ||
scsiInfo.MediaType == MediaType.XGD3)
Eto.Forms.MessageBox.Show("Scanning Xbox discs is not yet supported.", MessageBoxType.Error);
var scanForm = new frmMediaScan(devicePath, scsiInfo.DeviceInfo, scsiInfo);
scanForm.Show();
}
#region XAML controls
#pragma warning disable 169
#pragma warning disable 649
Label lblMediaInfo;
TabControl tabInfos;
TabPage tabGeneral;
Label lblType;
TextBox txtType;
Label lblMediaSize;
StackLayout stkMediaSerial;
Label lblMediaSerial;
TextBox txtMediaSerial;
Button btnSaveReadCapacity;
Button btnSaveReadCapacity16;
Button btnSaveReadMediaSerial;
TabPage tabMmc;
Button btnSaveGetConfiguration;
Button btnSaveRecognizedFormatLayers;
Button btnSaveWriteProtectionStatus;
TabPage tabSsc;
GroupBox grpDensitySupport;
TextArea txtDensitySupport;
GroupBox grpMediumSupport;
TextArea txtMediumSupport;
Button btnSaveDensitySupport;
Button btnSaveMediumSupport;
TabPage tabXbox;
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;
Button btnDump;
ImageView imgMediaLogo;
SvgImageView svgMediaLogo;
Button btnScan;
#pragma warning restore 169
#pragma warning restore 649
#endregion
}
}

View File

@@ -13,6 +13,7 @@ using Aaru.CommonTypes.Structs;
using Aaru.CommonTypes.Structs.Devices.SCSI;
using Aaru.Console;
using Aaru.Core;
using Aaru.Core.Media.Info;
using Aaru.Database;
using Aaru.Devices;
using Aaru.Gui.Models;
@@ -170,33 +171,39 @@ namespace Aaru.Gui.ViewModels
this.RaiseAndSetIfChanged(ref _treeViewSelectedItem, value);
if(value is ImageModel imageModel)
ContentPanel = null;
switch(value)
{
case ImageModel imageModel:
ContentPanel = new ImageInfoPanel
{
DataContext = imageModel.ViewModel
};
if(value is PartitionModel partitionModel)
break;
case PartitionModel partitionModel:
ContentPanel = new PartitionPanel
{
DataContext = partitionModel.ViewModel
};
if(value is FileSystemModel fileSystemModel)
break;
case FileSystemModel fileSystemModel:
ContentPanel = new FileSystemPanel
{
DataContext = fileSystemModel.ViewModel
};
if(value is SubdirectoryModel subdirectoryModel)
{
break;
case SubdirectoryModel subdirectoryModel:
ContentPanel = new SubdirectoryPanel
{
DataContext = new SubdirectoryViewModel(subdirectoryModel, _view)
};
}
if(value is DeviceModel deviceModel)
break;
case DeviceModel deviceModel:
{
if(deviceModel.ViewModel is null)
{
@@ -220,6 +227,37 @@ namespace Aaru.Gui.ViewModels
deviceModel.ViewModel = new DeviceInfoViewModel(devInfo, _view);
if(!dev.IsRemovable)
deviceModel.Media.Add(new MediaModel
{
NonRemovable = true, Name = "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 = "No media inserted"
});
else
{
var mediaResource =
new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png");
deviceModel.Media.Add(new MediaModel
{
DevicePath = deviceModel.Path,
Icon = _assets.Exists(mediaResource)
? new Bitmap(_assets.Open(mediaResource)) : null,
Name = $"{scsiInfo.MediaType}",
ViewModel = new MediaInfoViewModel(scsiInfo, deviceModel.Path, _view)
});
}
}
dev.Close();
}
catch(SystemException ex)
@@ -238,6 +276,27 @@ namespace Aaru.Gui.ViewModels
{
DataContext = deviceModel.ViewModel
};
break;
}
case MediaModel mediaModel when mediaModel.NonRemovable:
ContentPanel = "Non-removable device commands not yet implemented";
break;
case MediaModel mediaModel when mediaModel.NoMediaInserted:
ContentPanel = "No media inserted";
break;
case MediaModel mediaModel:
{
if(mediaModel.ViewModel != null)
ContentPanel = new MediaInfoPanel
{
DataContext = mediaModel.ViewModel
};
break;
}
}
}
}

View File

@@ -0,0 +1,378 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reactive;
using System.Text;
using Aaru.Core.Media.Info;
using Aaru.Gui.Tabs;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using ReactiveUI;
namespace Aaru.Gui.ViewModels
{
public class MediaInfoViewModel : ViewModelBase
{
readonly string _devicePath;
readonly ScsiInfo _scsiInfo;
readonly Window _view;
BlurayInfoTab _blurayInfo;
CompactDiscInfoTab _compactDiscInfo;
string _densitySupport;
DvdInfoTab _dvdInfo;
DvdWritableInfoTab _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;
XboxInfoTab _xboxInfo;
public MediaInfoViewModel(ScsiInfo scsiInfo, string devicePath, Window view)
{
_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");
MediaLogo = assets.Exists(mediaResource) ? new Bitmap(assets.Open(mediaResource)) : null;
MediaType = scsiInfo.MediaType.ToString();
if(scsiInfo.Blocks != 0 &&
scsiInfo.BlockSize != 0)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {scsiInfo.Blocks * scsiInfo.BlockSize} bytes)";
if(scsiInfo.MediaSerialNumber != null)
{
var sbSerial = new StringBuilder();
for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
MediaSerial = sbSerial.ToString();
}
SaveReadMediaSerialVisible = scsiInfo.MediaSerialNumber != null;
SaveReadCapacityVisible = scsiInfo.ReadCapacity != null;
SaveReadCapacity16Visible = scsiInfo.ReadCapacity16 != null;
SaveGetConfigurationVisible = scsiInfo.MmcConfiguration != null;
SaveRecognizedFormatLayersVisible = scsiInfo.RecognizedFormatLayers != null;
SaveWriteProtectionStatusVisible = scsiInfo.WriteProtectionStatus != null;
MmcVisible = SaveGetConfigurationVisible || SaveRecognizedFormatLayersVisible ||
SaveWriteProtectionStatusVisible;
if(scsiInfo.DensitySupportHeader.HasValue)
DensitySupport = Decoders.SCSI.SSC.DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
if(scsiInfo.MediaTypeSupportHeader.HasValue)
MediumSupport = Decoders.SCSI.SSC.DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
SaveDensitySupportVisible = scsiInfo.DensitySupport != null;
SaveMediumSupportVisible = scsiInfo.MediaTypeSupport != null;
SscVisible = SaveDensitySupportVisible || SaveMediumSupportVisible;
CompactDiscInfo = new CompactDiscInfoTab
{
DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.CompactDiscInformation,
scsiInfo.Session, scsiInfo.RawToc, scsiInfo.Pma,
scsiInfo.CdTextLeadIn, scsiInfo.DecodedToc,
scsiInfo.DecodedAtip, scsiInfo.DecodedSession,
scsiInfo.FullToc, scsiInfo.DecodedCdTextLeadIn,
scsiInfo.DecodedCompactDiscInformation, scsiInfo.Mcn,
scsiInfo.Isrcs, _view)
};
DvdInfo = new DvdInfoTab
{
DataContext = new DvdInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi,
scsiInfo.DvdCmi, scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca,
scsiInfo.DvdAacs, scsiInfo.DecodedPfi, _view)
};
XboxInfo = new XboxInfoTab
{
DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,
scsiInfo.DecodedXboxSecuritySector, _view)
};
DvdWritableInfo = new DvdWritableInfoTab
{
DataContext = new DvdWritableInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdRamDds,
scsiInfo.DvdRamCartridgeStatus, scsiInfo.DvdRamSpareArea,
scsiInfo.LastBorderOutRmd, scsiInfo.DvdPreRecordedInfo,
scsiInfo.DvdrMediaIdentifier,
scsiInfo.DvdrPhysicalInformation,
scsiInfo.HddvdrMediumStatus, scsiInfo.HddvdrLastRmd,
scsiInfo.DvdrLayerCapacity, scsiInfo.DvdrDlMiddleZoneStart,
scsiInfo.DvdrDlJumpIntervalSize,
scsiInfo.DvdrDlManualLayerJumpStartLba,
scsiInfo.DvdrDlRemapAnchorPoint, scsiInfo.DvdPlusAdip,
scsiInfo.DvdPlusDcb, _view)
};
BlurayInfo = new BlurayInfoTab
{
DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea,
scsiInfo.BlurayDds, scsiInfo.BlurayCartridgeStatus,
scsiInfo.BluraySpareAreaInformation, scsiInfo.BlurayPowResources,
scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl,
scsiInfo.BlurayPac, _view)
};
}
public ReactiveCommand<Unit, Unit> SaveReadMediaSerialCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacityCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacity16Command { get; }
public ReactiveCommand<Unit, Unit> SaveGetConfigurationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveRecognizedFormatLayersCommand { get; }
public ReactiveCommand<Unit, Unit> SaveWriteProtectionStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDensitySupportCommand { get; }
public ReactiveCommand<Unit, Unit> SaveMediumSupportCommand { get; }
public ReactiveCommand<Unit, Unit> DumpCommand { get; }
public ReactiveCommand<Unit, Unit> ScanCommand { get; }
public Bitmap MediaLogo
{
get => _mediaLogo;
set => this.RaiseAndSetIfChanged(ref _mediaLogo, value);
}
public string GeneralVisible
{
get => _generalVisible;
set => this.RaiseAndSetIfChanged(ref _generalVisible, value);
}
public string MediaType
{
get => _mediaType;
set => this.RaiseAndSetIfChanged(ref _mediaType, value);
}
public string MediaSize
{
get => _mediaSize;
set => this.RaiseAndSetIfChanged(ref _mediaSize, value);
}
public string MediaSerial
{
get => _mediaSerial;
set => this.RaiseAndSetIfChanged(ref _mediaSerial, value);
}
public bool SaveReadMediaSerialVisible
{
get => _saveReadMediaSerialVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadMediaSerialVisible, value);
}
public bool SaveReadCapacityVisible
{
get => _saveReadCapacityVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacityVisible, value);
}
public bool SaveReadCapacity16Visible
{
get => _saveReadCapacity16Visible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacity16Visible, value);
}
public bool MmcVisible
{
get => _mmcVisible;
set => this.RaiseAndSetIfChanged(ref _mmcVisible, value);
}
public bool SaveGetConfigurationVisible
{
get => _saveGetConfigurationVisible;
set => this.RaiseAndSetIfChanged(ref _saveGetConfigurationVisible, value);
}
public bool SaveRecognizedFormatLayersVisible
{
get => _saveRecognizedFormatLayersVisible;
set => this.RaiseAndSetIfChanged(ref _saveRecognizedFormatLayersVisible, value);
}
public bool SaveWriteProtectionStatusVisible
{
get => _saveWriteProtectionStatusVisible;
set => this.RaiseAndSetIfChanged(ref _saveWriteProtectionStatusVisible, value);
}
public bool SscVisible
{
get => _sscVisible;
set => this.RaiseAndSetIfChanged(ref _sscVisible, value);
}
public string DensitySupport
{
get => _densitySupport;
set => this.RaiseAndSetIfChanged(ref _densitySupport, value);
}
public string MediumSupport
{
get => _mediumSupport;
set => this.RaiseAndSetIfChanged(ref _mediumSupport, value);
}
public bool SaveDensitySupportVisible
{
get => _saveDensitySupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveDensitySupportVisible, value);
}
public bool SaveMediumSupportVisible
{
get => _saveMediumSupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveMediumSupportVisible, value);
}
public CompactDiscInfoTab CompactDiscInfo
{
get => _compactDiscInfo;
set => this.RaiseAndSetIfChanged(ref _compactDiscInfo, value);
}
public DvdInfoTab DvdInfo
{
get => _dvdInfo;
set => this.RaiseAndSetIfChanged(ref _dvdInfo, value);
}
public DvdWritableInfoTab DvdWritableInfo
{
get => _dvdWritableInfo;
set => this.RaiseAndSetIfChanged(ref _dvdWritableInfo, value);
}
public XboxInfoTab XboxInfo
{
get => _xboxInfo;
set => this.RaiseAndSetIfChanged(ref _xboxInfo, value);
}
public BlurayInfoTab BlurayInfo
{
get => _blurayInfo;
set => this.RaiseAndSetIfChanged(ref _blurayInfo, value);
}
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();
}
void ExecuteSaveReadMediaSerialCommand() => SaveElement(_scsiInfo.MediaSerialNumber);
void ExecuteSaveReadCapacityCommand() => SaveElement(_scsiInfo.ReadCapacity);
void ExecuteSaveReadCapacity16Command() => SaveElement(_scsiInfo.ReadCapacity16);
void ExecuteSaveGetConfigurationCommand() => SaveElement(_scsiInfo.MmcConfiguration);
void ExecuteSaveRecognizedFormatLayersCommand() => SaveElement(_scsiInfo.RecognizedFormatLayers);
void ExecuteSaveWriteProtectionStatusCommand() => SaveElement(_scsiInfo.WriteProtectionStatus);
void ExecuteSaveDensitySupportCommand() => SaveElement(_scsiInfo.DensitySupport);
void ExecuteSaveMediumSupportCommand() => SaveElement(_scsiInfo.MediaTypeSupport);
void ExecuteDumpCommand()
{
/* TODO: frmDump
if(scsiInfo.MediaType == MediaType.GDR ||
scsiInfo.MediaType == MediaType.GDROM)
{
Eto.Forms.MessageBox.Show("GD-ROM dump support is not yet implemented.", MessageBoxType.Error);
return;
}
if((scsiInfo.MediaType == MediaType.XGD || scsiInfo.MediaType == MediaType.XGD2 ||
scsiInfo.MediaType == MediaType.XGD3) &&
scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true)
Eto.Forms.MessageBox.Show("Dumping Xbox discs require a Kreon drive.", MessageBoxType.Error);
var dumpForm = new frmDump(devicePath, scsiInfo.DeviceInfo, scsiInfo);
dumpForm.Show();
*/
}
void ExecuteScanCommand()
{
/* TODO: frmMediaScan
if(scsiInfo.MediaType == MediaType.GDR ||
scsiInfo.MediaType == MediaType.GDROM)
{
Eto.Forms.MessageBox.Show("GD-ROM scan support is not yet implemented.", MessageBoxType.Error);
return;
}
if(scsiInfo.MediaType == MediaType.XGD ||
scsiInfo.MediaType == MediaType.XGD2 ||
scsiInfo.MediaType == MediaType.XGD3)
Eto.Forms.MessageBox.Show("Scanning Xbox discs is not yet supported.", MessageBoxType.Error);
var scanForm = new frmMediaScan(devicePath, scsiInfo.DeviceInfo, scsiInfo);
scanForm.Show();
*/
}
}
}