Implement hexadecimal view of sectors on GUI.

This commit is contained in:
2018-11-17 20:00:55 +00:00
parent 5f47063433
commit 634ec59925
6 changed files with 153 additions and 0 deletions

View File

@@ -1634,6 +1634,8 @@
<e p="frmImageVerify.xeto.cs" t="Include" />
<e p="frmMain.xeto" t="Include" />
<e p="frmMain.xeto.cs" t="Include" />
<e p="frmPrintHex.xeto" t="Include" />
<e p="frmPrintHex.xeto.cs" t="Include" />
</e>
<e p="Panels" t="Include">
<e p="pnlDeviceInfo.xeto" t="Include" />

View File

@@ -184,11 +184,15 @@ namespace DiscImageChef.Gui.Forms
null).Show();
};
treeImagesMenu.Items.Add(menuItem);
menuItem = new ButtonMenuItem {Text = "View sectors"};
menuItem.Click += (a, b) => { new frmPrintHex(image).Show(); };
treeImagesMenu.Items.Add(menuItem);
}
}
void CloseAllImages(object sender, EventArgs eventArgs)
{
// TODO
MessageBox.Show("Not yet implemented");
}

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?><!--
// /***************************************************************************
// The Disc Image Chef
// ============================================================================
//
// Filename : frmPrintHex.xeto
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Form to show hexadecimal dumps of sectors.
//
// ==[ Description ] ==========================================================
//
// Defines the structure for the print hex 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-2018 Natalia Portillo
// ****************************************************************************/
-->
<Form xmlns="http://schema.picoe.ca/eto.forms" Title="Sector viewer" ClientSize="600, 450" Padding="10">
<StackLayout Orientation="Vertical" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<StackLayout Orientation="Horizontal" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Label Text="Sector" ID="lblSector"/>
<NumericStepper ID="nmuSector" ValueChanged="OnNmuSectorValueChanged"/>
<Label Text="of XXXXX" ID="lblSectors"/>
</StackLayout>
<CheckBox ID="chkLongSector" Text="Show long sector"/>
<StackLayoutItem Expand="True">
<TextArea ID="txtPrintHex"/>
</StackLayoutItem>
</StackLayout>
</Form>

View File

@@ -0,0 +1,85 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : frmPrintHex.xeto.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Form to show hexadecimal dumps of sectors.
//
// --[ Description ] ----------------------------------------------------------
//
// Implements hexadecimal sector viewer.
//
// --[ 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-2018 Natalia Portillo
// ****************************************************************************/
using System;
using DiscImageChef.CommonTypes.Interfaces;
using Eto.Forms;
using Eto.Serialization.Xaml;
namespace DiscImageChef.Gui.Forms
{
// TODO: Decode long sector components
// TODO: Panel with string representation of contents
public class frmPrintHex : Form
{
const int HEX_COLUMNS = 32;
IMediaImage inputFormat;
public frmPrintHex(IMediaImage inputFormat)
{
this.inputFormat = inputFormat;
XamlReader.Load(this);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
try
{
inputFormat.ReadSectorLong(0);
chkLongSector.Checked = true;
}
catch { chkLongSector.Visible = false; }
lblSectors.Text = $"of {inputFormat.Info.Sectors}";
nmuSector.Value = 0;
OnNmuSectorValueChanged(nmuSector, e);
}
void OnNmuSectorValueChanged(object sender, EventArgs e)
{
txtPrintHex.Text =
PrintHex
.ByteArrayToHexArrayString(chkLongSector.Checked == true ? inputFormat.ReadSectorLong((ulong)nmuSector.Value) : inputFormat.ReadSector((ulong)nmuSector.Value),
HEX_COLUMNS);
}
#region XAML IDs
Label lblSector;
NumericStepper nmuSector;
Label lblSectors;
CheckBox chkLongSector;
TextArea txtPrintHex;
#endregion
}
}

View File

@@ -118,6 +118,7 @@
<Button ID="btnChecksum" Text="Checksum" Click="OnBtnChecksum"/>
<Button ID="btnConvert" Text="Convert to..." Click="OnBtnConvert"/>
<Button ID="btnCreateSidecar" Text="Create CICM XML sidecar..." Click="OnBtnCreateSidecar"/>
<Button ID="btnViewSectors" Text="View sectors" Click="OnBtnViewSectors"/>
</StackLayout>
</StackLayoutItem>
</StackLayout>

View File

@@ -61,6 +61,7 @@ namespace DiscImageChef.Gui.Panels
frmImageEntropy frmImageEntropy;
frmImageSidecar frmImageSidecar;
frmImageVerify frmImageVerify;
frmPrintHex frmPrintHex;
IMediaImage imageFormat;
string imagePath;
@@ -859,6 +860,19 @@ namespace DiscImageChef.Gui.Panels
frmImageSidecar.Show();
}
protected void OnBtnViewSectors(object sender, EventArgs e)
{
if(frmPrintHex != null)
{
frmPrintHex.Show();
return;
}
frmPrintHex = new frmPrintHex(imageFormat);
frmPrintHex.Closed += (s, ea) => { frmPrintHex = null; };
frmPrintHex.Show();
}
#region XAML controls
#pragma warning disable 169
#pragma warning disable 649
@@ -908,6 +922,7 @@ namespace DiscImageChef.Gui.Panels
Button btnVerify;
Button btnChecksum;
Button btnConvert;
Button btnViewSectors;
#pragma warning restore 169
#pragma warning restore 649
#endregion