MemoryViewer.cs isn't being used anymore

This commit is contained in:
adelikat 2013-11-28 20:05:35 +00:00
parent d37f186107
commit bbcc7f3b5f
3 changed files with 0 additions and 702 deletions

View File

@ -477,9 +477,6 @@
<Compile Include="tools\HexEditor\HexFind.Designer.cs">
<DependentUpon>HexFind.cs</DependentUpon>
</Compile>
<Compile Include="tools\HexEditor\MemoryViewer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="tools\IToolForm.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Client.cs" />
<Compile Include="tools\Lua\Libraries\EmuLuaLibrary.Console.cs" />
@ -870,9 +867,6 @@
<EmbeddedResource Include="tools\HexEditor\HexFind.resx">
<DependentUpon>HexFind.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\HexEditor\MemoryViewer.resx">
<DependentUpon>MemoryViewer.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\Lua\LuaConsole.resx">
<DependentUpon>LuaConsole.cs</DependentUpon>
</EmbeddedResource>

View File

@ -1,573 +0,0 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Text;
using System.Globalization;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public class MemoryViewer : Panel
{
//TODO: highlighting and address determining for 2 & 4 byte viewing
//2 & 4 byte typing in
//show nibbles on top of highlighted address
//Multi-highlight
//different back color for frozen addresses
public VScrollBar VScrollBar1;
public Brush HighlightBrush = Brushes.LightBlue;
public bool BigEndian = false;
public bool BlazingFast = false;
private string _info = String.Empty;
private MemoryDomain _domain = new MemoryDomain("NULL", 1024, MemoryDomain.Endian.Little, addr => 0,
delegate(int a, byte v) { v = 0; });
private readonly Font _font = new Font("Courier New", 8);
private int _rowsVisible;
private int _dataSize = 1;
private string _header = String.Empty;
private int _numDigits = 4;
private readonly char[] _nibbles = { 'G', 'G', 'G', 'G' }; //G = off 0-9 & A-F are acceptable values
private int _addressHighlighted = -1;
private int _addressOver = -1;
private int _addrOffset; //If addresses are > 4 digits, this offset is how much the columns are moved to the right
private int _maxRow;
private int _row;
private int _addr;
private const int ROWX = 1;
private const int ROWY = 4;
public MemoryViewer()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
BorderStyle = BorderStyle.Fixed3D;
MouseMove += MemoryViewer_MouseMove;
MouseClick += MemoryViewer_MouseClick;
VScrollBar1 = new VScrollBar();
var n = new Point(Size);
VScrollBar1.Location = new Point(n.X - 16, n.Y - Height + 7);
VScrollBar1.Height = Height - 8;
VScrollBar1.Width = 16;
VScrollBar1.Visible = true;
VScrollBar1.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom)
| AnchorStyles.Right;
VScrollBar1.LargeChange = 16;
VScrollBar1.Name = "vScrollBar1";
VScrollBar1.TabIndex = 0;
VScrollBar1.Scroll += vScrollBar1_Scroll;
Controls.Add(VScrollBar1);
SetHeader();
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Up)
{
GoToAddress(_addressHighlighted - 16);
}
else if (keyData == Keys.Down)
{
GoToAddress(_addressHighlighted + 16);
}
else if (keyData == Keys.Left)
{
GoToAddress(_addressHighlighted - 1);
}
else if (keyData == Keys.Right)
{
GoToAddress(_addressHighlighted + 1);
}
else if (keyData == Keys.Tab)
{
_addressHighlighted += 8;
Refresh();
}
else if (keyData == Keys.PageDown)
{
GoToAddress(_addressHighlighted + (_rowsVisible * 16));
}
else if (keyData == Keys.PageUp)
{
GoToAddress(_addressHighlighted - (_rowsVisible * 16));
}
else if (keyData == Keys.Home)
{
GoToAddress(0);
}
else if (keyData == Keys.End)
{
GoToAddress(GetSize() - 1);
}
return true;
}
private void ClearNibbles()
{
for (var i = 0; i < 4; i++)
{
_nibbles[i] = 'G';
}
}
protected override void OnKeyUp(KeyEventArgs e)
{
if (!InputValidate.IsValidHexNumber(((char)e.KeyCode).ToString()))
{
if (e.Control && e.KeyCode == Keys.G)
GoToSpecifiedAddress();
e.Handled = true;
return;
}
//TODO: 2 byte & 4 byte
if (_nibbles[0] == 'G')
{
_nibbles[0] = (char)e.KeyCode;
_info = _nibbles[0].ToString();
}
else
{
var temp = _nibbles[0].ToString() + ((char)e.KeyCode);
var x = int.Parse(temp, NumberStyles.HexNumber);
_domain.PokeByte(_addressHighlighted, (byte)x);
ClearNibbles();
SetHighlighted(_addressHighlighted + 1);
Refresh();
}
base.OnKeyUp(e);
}
public void SetHighlighted(int address)
{
if (address < 0)
address = 0;
if (address >= _domain.Size)
address = _domain.Size - 1;
if (!IsVisible(address))
{
var v = (address / 16) - _rowsVisible + 1;
if (v < 0)
v = 0;
VScrollBar1.Value = v;
}
_addressHighlighted = address;
_addressOver = address;
_info = String.Format("{0:X4}", _addressOver);
Refresh();
}
protected override void OnPaint(PaintEventArgs e)
{
unchecked
{
_row = 0;
_addr = 0;
var rowStr = new StringBuilder();
_addrOffset = (_numDigits % 4) * 9;
if (_addressHighlighted >= 0 && IsVisible(_addressHighlighted))
{
var left = ((_addressHighlighted % 16) * 20) + 52 + _addrOffset - (_addressHighlighted % 4);
var top = (((_addressHighlighted / 16) - VScrollBar1.Value) * (_font.Height - 1)) + 36;
var rect = new Rectangle(left, top, 16, 14);
e.Graphics.DrawRectangle(new Pen(HighlightBrush), rect);
e.Graphics.FillRectangle(HighlightBrush, rect);
}
rowStr.Append(_domain.Name + " " + _info + '\n');
rowStr.Append(_header + '\n');
for (var i = 0; i < _rowsVisible; i++)
{
_row = i + VScrollBar1.Value;
if (_row * 16 >= _domain.Size)
break;
rowStr.AppendFormat("{0:X" + _numDigits + "} ", _row * 16);
switch (_dataSize)
{
default:
case 1:
_addr = (_row * 16);
for (var j = 0; j < 16; j++)
{
if (_addr + j < _domain.Size)
rowStr.AppendFormat("{0:X2} ", _domain.PeekByte(_addr + j));
}
rowStr.Append(" | ");
for (var k = 0; k < 16; k++)
{
rowStr.Append(Remap(_domain.PeekByte(_addr + k)));
}
rowStr.AppendLine();
break;
case 2:
_addr = (_row * 16);
for (var j = 0; j < 16; j += 2)
{
if (_addr + j < _domain.Size)
rowStr.AppendFormat("{0:X4} ", MakeValue(_addr + j, _dataSize, BigEndian));
}
rowStr.AppendLine();
rowStr.Append(" | ");
for (var k = 0; k < 16; k++)
{
rowStr.Append(Remap(_domain.PeekByte(_addr + k)));
}
break;
case 4:
_addr = (_row * 16);
for (var j = 0; j < 16; j += 4)
{
if (_addr < _domain.Size)
rowStr.AppendFormat("{0:X8} ", MakeValue(_addr + j, _dataSize, BigEndian));
}
rowStr.AppendLine();
rowStr.Append(" | ");
for (var k = 0; k < 16; k++)
{
rowStr.Append(Remap(_domain.PeekByte(_addr + k)));
}
break;
}
}
e.Graphics.DrawString(rowStr.ToString(), _font, Brushes.Black, new Point(ROWX, ROWY));
}
}
static char Remap(byte val)
{
if (val < ' ')
{
return '.';
}
else if (val >= 0x80)
{
return '.';
}
else
{
return (char)val;
}
}
private int MakeValue(int address, int size, bool bigendian)
{
var x = 0;
if (size == 1 || size == 2 || size == 4)
{
switch (size)
{
case 1:
x = _domain.PeekByte(address);
break;
case 2:
x = _domain.PeekWord(address, bigendian);
break;
case 4:
x = (int) _domain.PeekDWord(address, bigendian);
break;
}
return x;
}
else
{
return 0; //fail
}
}
public void ResetScrollBar()
{
VScrollBar1.Value = 0;
SetUpScrollBar();
Refresh();
}
public void SetUpScrollBar()
{
_rowsVisible = ((Height - 8) / 13) - 1;
var totalRows = _domain.Size / 16;
var MaxRows = (totalRows - _rowsVisible) + 16;
if (MaxRows > 0)
{
VScrollBar1.Visible = true;
if (VScrollBar1.Value > MaxRows)
{
VScrollBar1.Value = MaxRows;
}
VScrollBar1.Maximum = MaxRows;
}
else
{
VScrollBar1.Visible = false;
}
}
public void SetMemoryDomain(MemoryDomain d)
{
_domain = d;
_maxRow = _domain.Size / 2;
SetUpScrollBar();
VScrollBar1.Value = 0;
Refresh();
}
public string DomainName()
{
return _domain.ToString();
}
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
SetUpScrollBar();
Refresh();
}
public void SetDataSize(int size)
{
if (size == 1 || size == 2 || size == 4)
_dataSize = size;
SetHeader();
}
private void SetHeader()
{
switch (_dataSize)
{
case 1:
_header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F";
break;
case 2:
_header = " 0 2 4 6 8 A C E";
break;
case 4:
_header = " 0 4 8 C";
break;
}
_numDigits = GetNumDigits(_domain.Size);
}
public int GetDataSize()
{
return _dataSize;
}
private static int GetNumDigits(Int32 i)
{
unchecked
{
if (i <= 0x10000) return 4;
if (i <= 0x1000000) return 6;
else return 8;
}
}
private void SetAddressOver(int x, int y)
{
//Scroll value determines the first row
var i = VScrollBar1.Value;
i += (y - 36) / (_font.Height - 1);
var column = (x - (49 + _addrOffset)) / 20;
//TODO: 2 & 4 byte views
if (i >= 0 && i <= _maxRow && column >= 0 && column < 16)
{
_addressOver = i * 16 + column;
_info = String.Format("{0:X4}", _addressOver);
}
else
{
_addressOver = -1;
_info = String.Empty;
}
}
private void MemoryViewer_MouseMove(object sender, MouseEventArgs e)
{
SetAddressOver(e.X, e.Y);
}
public void HighlightPointed()
{
if (_addressOver >= 0)
{
_addressHighlighted = _addressOver;
}
else
_addressHighlighted = -1;
ClearNibbles();
Focus();
Refresh();
}
private void MemoryViewer_MouseClick(object sender, MouseEventArgs e)
{
SetAddressOver(e.X, e.Y);
if (_addressOver == _addressHighlighted && _addressOver >= 0)
{
_addressHighlighted = -1;
Refresh();
}
else
{
HighlightPointed();
}
}
public int GetPointedAddress()
{
if (_addressOver >= 0)
{
return _addressOver;
}
else
{
return -1; //Negative = no address pointed
}
}
public int GetHighlightedAddress()
{
if (_addressHighlighted >= 0)
{
return _addressHighlighted;
}
else
{
return -1; //Negative = no address highlighted
}
}
public bool IsVisible(int address)
{
unchecked
{
var i = address >> 4;
if (i >= VScrollBar1.Value && i < (_rowsVisible + VScrollBar1.Value))
{
return true;
}
else
{
return false;
}
}
}
public void PokeHighlighted(int value)
{
//TODO: 2 byte & 4 byte
if (_addressHighlighted >= 0)
_domain.PokeByte(_addressHighlighted, (byte)value);
}
public int GetSize()
{
return _domain.Size;
}
public byte GetPointedValue()
{
return _domain.PeekByte(_addressOver);
}
public MemoryDomain GetDomain()
{
return _domain;
}
public void GoToAddress(int address)
{
if (address < 0)
address = 0;
if (address >= GetSize())
address = GetSize() - 1;
SetHighlighted(address);
ClearNibbles();
Refresh();
}
public void GoToSpecifiedAddress()
{
var i = new InputPrompt {Text = "Go to Address"};
i.SetMessage("Enter a hexadecimal value");
GlobalWin.Sound.StopSound();
i.ShowDialog();
GlobalWin.Sound.StartSound();
if (i.UserOK && InputValidate.IsValidHexNumber(i.UserText))
{
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
}
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x0201: //WM_LBUTTONDOWN
{
Focus();
return;
}
//case 0x0202://WM_LBUTTONUP
//{
// return;
//}
case 0x0203://WM_LBUTTONDBLCLK
{
return;
}
case 0x0204://WM_RBUTTONDOWN
{
return;
}
case 0x0205://WM_RBUTTONUP
{
return;
}
case 0x0206://WM_RBUTTONDBLCLK
{
return;
}
case 0x0014: //WM_ERASEBKGND
if (BlazingFast)
{
m.Result = new IntPtr(1);
}
break;
}
base.WndProc(ref m);
}
}
}

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>