Hex Editor - Context menu with Poke & Add to Ram Watch options
This commit is contained in:
parent
be69565135
commit
4909aa8084
|
@ -28,6 +28,7 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditor));
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -46,8 +47,13 @@
|
|||
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AddressBox = new System.Windows.Forms.TextBox();
|
||||
this.ViewerContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.pokeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.freezeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.addToRamWatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.ViewerContextMenuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
|
@ -185,12 +191,43 @@
|
|||
this.AddressBox.Size = new System.Drawing.Size(57, 20);
|
||||
this.AddressBox.TabIndex = 2;
|
||||
//
|
||||
// ViewerContextMenuStrip
|
||||
//
|
||||
this.ViewerContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.pokeToolStripMenuItem,
|
||||
this.freezeToolStripMenuItem,
|
||||
this.addToRamWatchToolStripMenuItem});
|
||||
this.ViewerContextMenuStrip.Name = "ViewerContextMenuStrip";
|
||||
this.ViewerContextMenuStrip.Size = new System.Drawing.Size(176, 92);
|
||||
//
|
||||
// pokeToolStripMenuItem
|
||||
//
|
||||
this.pokeToolStripMenuItem.Name = "pokeToolStripMenuItem";
|
||||
this.pokeToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.pokeToolStripMenuItem.Text = "&Poke";
|
||||
this.pokeToolStripMenuItem.Click += new System.EventHandler(this.pokeToolStripMenuItem_Click);
|
||||
//
|
||||
// freezeToolStripMenuItem
|
||||
//
|
||||
this.freezeToolStripMenuItem.Enabled = false;
|
||||
this.freezeToolStripMenuItem.Name = "freezeToolStripMenuItem";
|
||||
this.freezeToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.freezeToolStripMenuItem.Text = "&Freeze";
|
||||
//
|
||||
// addToRamWatchToolStripMenuItem
|
||||
//
|
||||
this.addToRamWatchToolStripMenuItem.Name = "addToRamWatchToolStripMenuItem";
|
||||
this.addToRamWatchToolStripMenuItem.Size = new System.Drawing.Size(175, 22);
|
||||
this.addToRamWatchToolStripMenuItem.Text = "&Add to Ram Watch";
|
||||
this.addToRamWatchToolStripMenuItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click);
|
||||
//
|
||||
// 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.ContextMenuStrip = this.ViewerContextMenuStrip;
|
||||
this.MemoryViewer.Location = new System.Drawing.Point(12, 37);
|
||||
this.MemoryViewer.Name = "MemoryViewer";
|
||||
this.MemoryViewer.Size = new System.Drawing.Size(458, 295);
|
||||
|
@ -215,6 +252,7 @@
|
|||
this.Resize += new System.EventHandler(this.HexEditor_Resize);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ViewerContextMenuStrip.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -240,5 +278,9 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem;
|
||||
private System.Windows.Forms.TextBox AddressBox;
|
||||
private System.Windows.Forms.ContextMenuStrip ViewerContextMenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem pokeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem freezeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem addToRamWatchToolStripMenuItem;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ using System.Drawing;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Globalization;
|
||||
|
||||
namespace BizHawk.MultiClient
|
||||
{
|
||||
|
@ -15,7 +16,6 @@ namespace BizHawk.MultiClient
|
|||
//Find text box - autohighlights matches, and shows total matches
|
||||
//Implement Goto address
|
||||
//Users can customize background, & text colors
|
||||
//Context menu - Poke, Freeze/Unfreeze, Watch
|
||||
//Tool strip
|
||||
//Double click sends all highlighted to Ram Watch not just currently pointed
|
||||
//Add to Ram Watch menu item, enabled conditionally on if any address is highlighted
|
||||
|
@ -190,7 +190,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
private void AddToRamWatch()
|
||||
{
|
||||
//Add to RAM Watch
|
||||
int address = MemoryViewer.GetPointedAddress();
|
||||
|
@ -230,6 +230,38 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
AddToRamWatch();
|
||||
}
|
||||
|
||||
private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
int p = MemoryViewer.GetPointedAddress();
|
||||
if (p >= 0)
|
||||
{
|
||||
InputPrompt i = new InputPrompt();
|
||||
i.Text = "Poke " + String.Format("{0:X}", p);
|
||||
i.SetMessage("Enter a hexadecimal value");
|
||||
i.ShowDialog();
|
||||
|
||||
if (i.UserOK)
|
||||
{
|
||||
if (InputValidate.IsValidHexNumber(i.UserText))
|
||||
{
|
||||
int value = int.Parse(i.UserText, NumberStyles.HexNumber);
|
||||
MemoryViewer.HighlightPointed();
|
||||
MemoryViewer.PokeHighlighted(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddToRamWatch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,6 +120,9 @@
|
|||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="ViewerContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>126, 17</value>
|
||||
</metadata>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
this.Cancel.TabIndex = 3;
|
||||
this.Cancel.Text = "&Cancel";
|
||||
this.Cancel.UseVisualStyleBackColor = true;
|
||||
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
|
||||
//
|
||||
// InputPrompt
|
||||
//
|
||||
|
|
|
@ -22,14 +22,25 @@ namespace BizHawk.MultiClient
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SetMessage(string message)
|
||||
{
|
||||
PromptLabel.Text = message;
|
||||
}
|
||||
|
||||
private void InputPrompt_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
private void OK_Click(object sender, EventArgs e)
|
||||
{
|
||||
UserOK = true;
|
||||
UserText = PromptBox.Text;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ namespace BizHawk.MultiClient
|
|||
public class MemoryViewer : Panel
|
||||
{
|
||||
//TODO: highlighting and address determining for 2 & 4 byte viewing
|
||||
//2 & 4 byte typign in
|
||||
//show nibbles instead of highlighted address
|
||||
//double check that typign into last column moves to the next
|
||||
//If moving to an offscreen address, increment scrollbar
|
||||
|
||||
public VScrollBar vScrollBar1;
|
||||
public Label info;
|
||||
|
@ -298,9 +302,8 @@ namespace BizHawk.MultiClient
|
|||
SetAddressOver(e.X, e.Y);
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseClick(object sender, MouseEventArgs e)
|
||||
public void HighlightPointed()
|
||||
{
|
||||
SetAddressOver(e.X, e.Y);
|
||||
if (addressOver >= 0)
|
||||
{
|
||||
addressHighlighted = addressOver;
|
||||
|
@ -312,6 +315,12 @@ namespace BizHawk.MultiClient
|
|||
this.Refresh();
|
||||
}
|
||||
|
||||
private void MemoryViewer_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
SetAddressOver(e.X, e.Y);
|
||||
HighlightPointed();
|
||||
}
|
||||
|
||||
public int GetPointedAddress()
|
||||
{
|
||||
if (addressOver >= 0)
|
||||
|
@ -337,5 +346,12 @@ namespace BizHawk.MultiClient
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PokeHighlighted(int value)
|
||||
{
|
||||
//TODO: 2 byte & 4 byte
|
||||
if (addressHighlighted >= 0)
|
||||
Domain.PokeByte(addressHighlighted, (byte)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue