MemoryViewer - Display domain name, and determine which address the mouse is currently on, public method for retrieving the currently pointed to address
This commit is contained in:
parent
859eabc6b7
commit
fd383f108c
|
@ -40,11 +40,12 @@
|
|||
this.byteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.byteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.byteToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.enToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.goToAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.enToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddressBox = new System.Windows.Forms.TextBox();
|
||||
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
|
@ -57,7 +58,7 @@
|
|||
this.settingsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(531, 24);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(572, 24);
|
||||
this.menuStrip1.TabIndex = 1;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
|
@ -139,6 +140,13 @@
|
|||
this.byteToolStripMenuItem2.Text = "4 Byte";
|
||||
this.byteToolStripMenuItem2.Click += new System.EventHandler(this.byteToolStripMenuItem2_Click);
|
||||
//
|
||||
// enToolStripMenuItem
|
||||
//
|
||||
this.enToolStripMenuItem.Name = "enToolStripMenuItem";
|
||||
this.enToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
|
||||
this.enToolStripMenuItem.Text = "Big Endian";
|
||||
this.enToolStripMenuItem.Click += new System.EventHandler(this.enToolStripMenuItem_Click);
|
||||
//
|
||||
// goToAddressToolStripMenuItem
|
||||
//
|
||||
this.goToAddressToolStripMenuItem.Name = "goToAddressToolStripMenuItem";
|
||||
|
@ -169,30 +177,33 @@
|
|||
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.autoloadToolStripMenuItem.Text = "Auto-load";
|
||||
//
|
||||
// enToolStripMenuItem
|
||||
// AddressBox
|
||||
//
|
||||
this.enToolStripMenuItem.Name = "enToolStripMenuItem";
|
||||
this.enToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
|
||||
this.enToolStripMenuItem.Text = "Big Endian";
|
||||
this.enToolStripMenuItem.Click += new System.EventHandler(this.enToolStripMenuItem_Click);
|
||||
this.AddressBox.Location = new System.Drawing.Point(487, 37);
|
||||
this.AddressBox.Name = "AddressBox";
|
||||
this.AddressBox.ReadOnly = true;
|
||||
this.AddressBox.Size = new System.Drawing.Size(57, 20);
|
||||
this.AddressBox.TabIndex = 2;
|
||||
//
|
||||
// MemoryViewer
|
||||
//
|
||||
this.MemoryViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.MemoryViewer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.MemoryViewer.Location = new System.Drawing.Point(12, 37);
|
||||
this.MemoryViewer.Name = "MemoryViewer";
|
||||
this.MemoryViewer.Size = new System.Drawing.Size(499, 295);
|
||||
this.MemoryViewer.Size = new System.Drawing.Size(458, 295);
|
||||
this.MemoryViewer.TabIndex = 0;
|
||||
this.MemoryViewer.TabStop = false;
|
||||
this.MemoryViewer.Text = "RAM";
|
||||
this.MemoryViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewer_Paint);
|
||||
//
|
||||
// HexEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(531, 344);
|
||||
this.ClientSize = new System.Drawing.Size(572, 344);
|
||||
this.Controls.Add(this.AddressBox);
|
||||
this.Controls.Add(this.MemoryViewer);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
|
@ -227,5 +238,6 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem;
|
||||
private System.Windows.Forms.TextBox AddressBox;
|
||||
}
|
||||
}
|
|
@ -185,6 +185,11 @@ namespace BizHawk.MultiClient
|
|||
MemoryViewer.BigEndian ^= true;
|
||||
}
|
||||
|
||||
private void MemoryViewer_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ using System.Text;
|
|||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
public class MemoryViewer : GroupBox
|
||||
public class MemoryViewer : Panel
|
||||
{
|
||||
//TODO: 4 byte
|
||||
|
||||
public VScrollBar vScrollBar1;
|
||||
public Label info;
|
||||
|
||||
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
||||
Font font = new Font("Courier New", 10);
|
||||
Brush regBrush = Brushes.Black;
|
||||
|
@ -20,16 +20,23 @@ namespace BizHawk.MultiClient
|
|||
public bool BigEndian = false;
|
||||
string Header = "";
|
||||
|
||||
|
||||
int addressOver = -1;
|
||||
int addrOffset = 0; //If addresses are > 4 digits, this offset is how much the columns are moved to the right
|
||||
int maxRow = 0;
|
||||
|
||||
public MemoryViewer()
|
||||
{
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewer_Paint);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MemoryViewer_MouseMove);
|
||||
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.MemoryViewer_MouseClick);
|
||||
|
||||
this.vScrollBar1 = new VScrollBar();
|
||||
|
||||
Point n = new Point(this.Size);
|
||||
this.vScrollBar1.Location = new System.Drawing.Point(n.X-18, n.Y-this.Height+7);
|
||||
this.vScrollBar1.Location = new System.Drawing.Point(n.X-16, n.Y-this.Height+7);
|
||||
this.vScrollBar1.Height = this.Height-8;
|
||||
this.vScrollBar1.Width = 16;
|
||||
this.vScrollBar1.Visible = true;
|
||||
|
@ -39,8 +46,15 @@ namespace BizHawk.MultiClient
|
|||
this.vScrollBar1.Name = "vScrollBar1";
|
||||
this.vScrollBar1.TabIndex = 0;
|
||||
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScrollBar1_Scroll);
|
||||
|
||||
this.Controls.Add(this.vScrollBar1);
|
||||
|
||||
//Debugging control
|
||||
this.info = new Label();
|
||||
this.info.Text = "";
|
||||
this.info.Font = new Font("Courier New", 8);
|
||||
this.info.Location = new System.Drawing.Point(n.X / 2, 1);
|
||||
this.info.Height = 11;
|
||||
this.Controls.Add(this.info);
|
||||
}
|
||||
|
||||
//protected unsafe override void OnPaint(PaintEventArgs e)
|
||||
|
@ -54,10 +68,10 @@ namespace BizHawk.MultiClient
|
|||
int rowYoffset = 20;
|
||||
string rowStr = "";
|
||||
int addr = 0;
|
||||
int aOffset = (GetNumDigits(Domain.Size) % 4) * 9 ;
|
||||
g.DrawLine(new Pen(regBrush), this.Left + 38 + aOffset, this.Top, this.Left + 38 + aOffset, this.Bottom - 40);
|
||||
addrOffset = (GetNumDigits(Domain.Size) % 4) * 9 ;
|
||||
g.DrawLine(new Pen(regBrush), this.Left + 38 + addrOffset, this.Top, this.Left + 38 + addrOffset, this.Bottom - 40);
|
||||
g.DrawLine(new Pen(regBrush), this.Left, 34, this.Right - 16, 34);
|
||||
|
||||
|
||||
for (int i = 0; i < RowsVisible; i++)
|
||||
{
|
||||
row = i + vScrollBar1.Value;
|
||||
|
@ -94,8 +108,8 @@ namespace BizHawk.MultiClient
|
|||
break;
|
||||
|
||||
}
|
||||
|
||||
g.DrawString(Header, font, regBrush, new Point(rowX + aOffset, rowY));
|
||||
g.DrawString(Domain.Name, font, regBrush, new Point(1, 1));
|
||||
g.DrawString(Header, font, regBrush, new Point(rowX + addrOffset, rowY));
|
||||
if (row * 16 < Domain.Size)
|
||||
g.DrawString(rowStr, font, regBrush, new Point(rowX, (rowY * (i + 1)) + rowYoffset));
|
||||
}
|
||||
|
@ -162,6 +176,7 @@ namespace BizHawk.MultiClient
|
|||
public void SetMemoryDomain(MemoryDomain d)
|
||||
{
|
||||
Domain = d;
|
||||
maxRow = Domain.Size / 2;
|
||||
SetUpScrollBar();
|
||||
vScrollBar1.Value = 0;
|
||||
Refresh();
|
||||
|
@ -200,5 +215,49 @@ namespace BizHawk.MultiClient
|
|||
if (i <= 0x1000000) return 6;
|
||||
else return 8;
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
int x = e.X;
|
||||
int y = e.Y;
|
||||
info.Text = e.X.ToString() + "," + e.Y.ToString();
|
||||
|
||||
//Determine row - 32 pix header, 16 pix width
|
||||
//Scroll value determines the first row
|
||||
int row = vScrollBar1.Value;
|
||||
row += (e.Y - 32) / 16;
|
||||
//info.Text += " " + row.ToString(); //Debug
|
||||
|
||||
//Determine colums - 60 + addrOffset left padding
|
||||
//24 pixel wide addresses (when 1 byte)
|
||||
int column = (e.X - (60+addrOffset)) / 24;
|
||||
//info.Text += " " + column.ToString(); //Debug
|
||||
//TODO: 2 & 4 byte views
|
||||
|
||||
|
||||
if (row >= 0 && row <= maxRow && column >= 0 && column < 16)
|
||||
{
|
||||
addressOver = row * 16 + column;
|
||||
info.Text = String.Format("{0:X4}", addressOver);
|
||||
}
|
||||
else
|
||||
{
|
||||
addressOver = -1;
|
||||
info.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int GetPointedAddress()
|
||||
{
|
||||
if (addressOver >= 0)
|
||||
return addressOver;
|
||||
else
|
||||
return -1; //Negative means no address selected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue