Hex Editor - vertical scrollbar

This commit is contained in:
andres.delikat 2011-03-06 23:55:10 +00:00
parent 3a3e3ca46a
commit c5a7e43331
2 changed files with 56 additions and 36 deletions

View File

@ -28,7 +28,6 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.MemoryViewer = new MemoryViewer();
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -40,26 +39,15 @@
this.byteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.byteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.byteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.byteToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.goToAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goToAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// 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.Location = new System.Drawing.Point(12, 37);
this.MemoryViewer.Name = "MemoryViewer";
this.MemoryViewer.Size = new System.Drawing.Size(484, 328);
this.MemoryViewer.TabIndex = 0;
this.MemoryViewer.TabStop = false;
this.MemoryViewer.Text = "RAM";
this.MemoryViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewer_Paint);
//
// menuStrip1 // menuStrip1
// //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -68,7 +56,7 @@
this.settingsToolStripMenuItem}); this.settingsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(508, 24); this.menuStrip1.Size = new System.Drawing.Size(534, 24);
this.menuStrip1.TabIndex = 1; this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -115,7 +103,7 @@
// memoryDomainsToolStripMenuItem // memoryDomainsToolStripMenuItem
// //
this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem"; this.memoryDomainsToolStripMenuItem.Name = "memoryDomainsToolStripMenuItem";
this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.memoryDomainsToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.memoryDomainsToolStripMenuItem.Text = "&Memory Domains"; this.memoryDomainsToolStripMenuItem.Text = "&Memory Domains";
// //
// dataSizeToolStripMenuItem // dataSizeToolStripMenuItem
@ -125,27 +113,35 @@
this.byteToolStripMenuItem1, this.byteToolStripMenuItem1,
this.byteToolStripMenuItem2}); this.byteToolStripMenuItem2});
this.dataSizeToolStripMenuItem.Name = "dataSizeToolStripMenuItem"; this.dataSizeToolStripMenuItem.Name = "dataSizeToolStripMenuItem";
this.dataSizeToolStripMenuItem.Size = new System.Drawing.Size(166, 22); this.dataSizeToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.dataSizeToolStripMenuItem.Text = "Data Size"; this.dataSizeToolStripMenuItem.Text = "Data Size";
// //
// byteToolStripMenuItem // byteToolStripMenuItem
// //
this.byteToolStripMenuItem.Name = "byteToolStripMenuItem"; this.byteToolStripMenuItem.Name = "byteToolStripMenuItem";
this.byteToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.byteToolStripMenuItem.Size = new System.Drawing.Size(116, 22);
this.byteToolStripMenuItem.Text = "1 Byte"; this.byteToolStripMenuItem.Text = "1 Byte";
// //
// byteToolStripMenuItem1 // byteToolStripMenuItem1
// //
this.byteToolStripMenuItem1.Name = "byteToolStripMenuItem1"; this.byteToolStripMenuItem1.Name = "byteToolStripMenuItem1";
this.byteToolStripMenuItem1.Size = new System.Drawing.Size(152, 22); this.byteToolStripMenuItem1.Size = new System.Drawing.Size(116, 22);
this.byteToolStripMenuItem1.Text = "2 Byte"; this.byteToolStripMenuItem1.Text = "2 Byte";
// //
// byteToolStripMenuItem2 // byteToolStripMenuItem2
// //
this.byteToolStripMenuItem2.Name = "byteToolStripMenuItem2"; this.byteToolStripMenuItem2.Name = "byteToolStripMenuItem2";
this.byteToolStripMenuItem2.Size = new System.Drawing.Size(152, 22); this.byteToolStripMenuItem2.Size = new System.Drawing.Size(116, 22);
this.byteToolStripMenuItem2.Text = "4 Byte"; this.byteToolStripMenuItem2.Text = "4 Byte";
// //
// goToAddressToolStripMenuItem
//
this.goToAddressToolStripMenuItem.Name = "goToAddressToolStripMenuItem";
this.goToAddressToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
this.goToAddressToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.goToAddressToolStripMenuItem.Text = "Go to Address";
this.goToAddressToolStripMenuItem.Click += new System.EventHandler(this.goToAddressToolStripMenuItem_Click);
//
// settingsToolStripMenuItem // settingsToolStripMenuItem
// //
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -160,6 +156,7 @@
this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem"; this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem";
this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(186, 22); this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.restoreWindowSizeToolStripMenuItem.Text = "&Restore Window Size"; this.restoreWindowSizeToolStripMenuItem.Text = "&Restore Window Size";
this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click);
// //
// autoloadToolStripMenuItem // autoloadToolStripMenuItem
// //
@ -167,19 +164,35 @@
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(186, 22); this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.autoloadToolStripMenuItem.Text = "Auto-load"; this.autoloadToolStripMenuItem.Text = "Auto-load";
// //
// goToAddressToolStripMenuItem // vScrollBar1
// //
this.goToAddressToolStripMenuItem.Name = "goToAddressToolStripMenuItem"; this.vScrollBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.goToAddressToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); | System.Windows.Forms.AnchorStyles.Right)));
this.goToAddressToolStripMenuItem.Size = new System.Drawing.Size(192, 22); this.vScrollBar1.LargeChange = 16;
this.goToAddressToolStripMenuItem.Text = "Go to Address"; this.vScrollBar1.Location = new System.Drawing.Point(515, 42);
this.goToAddressToolStripMenuItem.Click += new System.EventHandler(this.goToAddressToolStripMenuItem_Click); this.vScrollBar1.Name = "vScrollBar1";
this.vScrollBar1.Size = new System.Drawing.Size(16, 323);
this.vScrollBar1.TabIndex = 0;
//
// 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.Location = new System.Drawing.Point(12, 37);
this.MemoryViewer.Name = "MemoryViewer";
this.MemoryViewer.Size = new System.Drawing.Size(502, 328);
this.MemoryViewer.TabIndex = 0;
this.MemoryViewer.TabStop = false;
this.MemoryViewer.Text = "RAM";
this.MemoryViewer.Paint += new System.Windows.Forms.PaintEventHandler(this.MemoryViewer_Paint);
// //
// HexEditor // HexEditor
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(508, 377); this.ClientSize = new System.Drawing.Size(534, 377);
this.Controls.Add(this.vScrollBar1);
this.Controls.Add(this.MemoryViewer); this.Controls.Add(this.MemoryViewer);
this.Controls.Add(this.menuStrip1); this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1; this.MainMenuStrip = this.menuStrip1;
@ -211,5 +224,6 @@
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
private System.Windows.Forms.VScrollBar vScrollBar1;
} }
} }

View File

@ -12,9 +12,9 @@ namespace BizHawk.MultiClient
public partial class HexEditor : Form public partial class HexEditor : Form
{ {
//TODO: //TODO:
//Length of values doesn't match
//Find text box - autohighlights matches, and shows total matches //Find text box - autohighlights matches, and shows total matches
//Implement Goto address //Implement Goto address
//Scroll bar
//Users can customize background, & text colors //Users can customize background, & text colors
//Context menu - Poke, Freeze/Unfreeze, Watch //Context menu - Poke, Freeze/Unfreeze, Watch
//Tool strip //Tool strip
@ -73,21 +73,23 @@ namespace BizHawk.MultiClient
{ {
unchecked unchecked
{ {
e.Graphics.DrawLine(new Pen(regBrush), MemoryViewer.Left + 46, MemoryViewer.Top, MemoryViewer.Left + 46, MemoryViewer.Bottom-40); int row = 0;
e.Graphics.DrawString(HEADER, font, regBrush, new Point(16, 16)); int rowX = 8;
e.Graphics.DrawLine(new Pen(regBrush), MemoryViewer.Left, 34, MemoryViewer.Right-16, 34);
int rowX = 16;
int rowY = 16; int rowY = 16;
int rowYoffset = 20; int rowYoffset = 20;
string rowStr; string rowStr;
e.Graphics.DrawString(HEADER, font, regBrush, new Point(rowX, rowY));
e.Graphics.DrawLine(new Pen(regBrush), MemoryViewer.Left + 38, MemoryViewer.Top, MemoryViewer.Left + 38, MemoryViewer.Bottom - 40);
e.Graphics.DrawLine(new Pen(regBrush), MemoryViewer.Left, 34, MemoryViewer.Right - 16, 34);
for (int i = 0; i < Domain.Size / 16; i++) for (int i = 0; i < Domain.Size / 16; i++)
{ {
rowStr = String.Format("{0:X4}", i*16) + " "; //TODO: num digits based on size of domain row = i + vScrollBar1.Value;
rowStr = String.Format("{0:X4}", row*16) + " "; //TODO: num digits based on size of domain
for (int j = 0; j < 16; j++) for (int j = 0; j < 16; j++)
{ {
rowStr += String.Format("{0:X2}", Domain.PeekByte((i*16)+j)) + " "; //TODO: format based on data size rowStr += String.Format("{0:X2}", Domain.PeekByte((row*16)+j)) + " "; //TODO: format based on data size
} }
e.Graphics.DrawString(rowStr, font, regBrush, new Point(rowX, (rowY*(i+1))+rowYoffset)); e.Graphics.DrawString(rowStr, font, regBrush, new Point(rowX, (rowY*(i+1))+rowYoffset));
@ -162,6 +164,10 @@ namespace BizHawk.MultiClient
} }
else else
memoryDomainsToolStripMenuItem.Enabled = false; memoryDomainsToolStripMenuItem.Enabled = false;
//Set up scrollbar
vScrollBar1.Maximum = Domain.Size / 16;
vScrollBar1.Value = 0;
} }
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e) private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)