HexView - setting up some API
This commit is contained in:
parent
60692450e8
commit
ac1c7d0992
|
@ -16,6 +16,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private readonly Font NormalFont;
|
||||
private Size _charSize;
|
||||
|
||||
private long _arrayLength;
|
||||
|
||||
public HexView()
|
||||
{
|
||||
NormalFont = new Font("Courier New", 8); // Only support fixed width
|
||||
|
@ -43,6 +45,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Paint
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
using (var LCK = Gdi.LockGraphics(e.Graphics))
|
||||
|
@ -61,5 +65,52 @@ namespace BizHawk.Client.EmuHawk
|
|||
Gdi.EndOffScreenBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sets the virtual number of the length of the array to display
|
||||
/// </summary>
|
||||
[Category("Behavior")]
|
||||
public long ArrayLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return _arrayLength;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_arrayLength = value;
|
||||
RecalculateScrollBars();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
[Category("Virtual")]
|
||||
public event QueryIndexValueHandler QueryIndexValue;
|
||||
|
||||
[Category("Virtual")]
|
||||
public event QueryIndexBkColorHandler QueryIndexBgColor;
|
||||
|
||||
[Category("Virtual")]
|
||||
public event QueryIndexForeColorHandler QueryIndexForeColor;
|
||||
|
||||
public delegate void QueryIndexValueHandler(int index, out long value);
|
||||
|
||||
public delegate void QueryIndexBkColorHandler(int index, ref Color color);
|
||||
|
||||
public delegate void QueryIndexForeColorHandler(int index, ref Color color);
|
||||
|
||||
#endregion
|
||||
|
||||
private void RecalculateScrollBars()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
this.HexMenu = new System.Windows.Forms.MenuStrip();
|
||||
this.FileSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.hexView1 = new BizHawk.Client.EmuHawk.HexView();
|
||||
this.HexViewControl = new BizHawk.Client.EmuHawk.HexView();
|
||||
this.HexMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -62,23 +62,24 @@
|
|||
this.ExitMenuItem.Text = "E&xit";
|
||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||
//
|
||||
// hexView1
|
||||
// HexViewControl
|
||||
//
|
||||
this.hexView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
this.HexViewControl.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.hexView1.Location = new System.Drawing.Point(12, 27);
|
||||
this.hexView1.Name = "hexView1";
|
||||
this.hexView1.Size = new System.Drawing.Size(424, 231);
|
||||
this.hexView1.TabIndex = 1;
|
||||
this.hexView1.Text = "hexView1";
|
||||
this.HexViewControl.ArrayLength = 0;
|
||||
this.HexViewControl.Location = new System.Drawing.Point(12, 27);
|
||||
this.HexViewControl.Name = "HexViewControl";
|
||||
this.HexViewControl.Size = new System.Drawing.Size(424, 231);
|
||||
this.HexViewControl.TabIndex = 1;
|
||||
this.HexViewControl.Text = "hexView1";
|
||||
//
|
||||
// NewHexEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(448, 270);
|
||||
this.Controls.Add(this.hexView1);
|
||||
this.Controls.Add(this.HexViewControl);
|
||||
this.Controls.Add(this.HexMenu);
|
||||
this.MainMenuStrip = this.HexMenu;
|
||||
this.Name = "NewHexEditor";
|
||||
|
@ -96,6 +97,6 @@
|
|||
private System.Windows.Forms.MenuStrip HexMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
||||
private HexView hexView1;
|
||||
private HexView HexViewControl;
|
||||
}
|
||||
}
|
|
@ -23,11 +23,15 @@ namespace BizHawk.Client.EmuHawk
|
|||
InitializeComponent();
|
||||
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
|
||||
HexViewControl.QueryIndexValue += HexView_QueryIndexValue;
|
||||
HexViewControl.QueryIndexForeColor += HexView_QueryIndexForeColor;
|
||||
HexViewControl.QueryIndexBgColor += HexView_QueryIndexForeColor;
|
||||
}
|
||||
|
||||
private void NewHexEditor_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
HexViewControl.ArrayLength = MemoryDomains.MainMemory.Size;
|
||||
}
|
||||
|
||||
private void SaveConfigSettings()
|
||||
|
@ -63,6 +67,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
#endregion
|
||||
|
||||
#region HexView Callbacks
|
||||
|
||||
private void HexView_QueryIndexValue(int index, out long value)
|
||||
{
|
||||
value = MemoryDomains.MainMemory.PeekByte(index);
|
||||
}
|
||||
|
||||
private void HexView_QueryIndexBgColor(int index, ref Color color)
|
||||
{
|
||||
color = Color.White;
|
||||
}
|
||||
|
||||
private void HexView_QueryIndexForeColor(int index, ref Color color)
|
||||
{
|
||||
color = Color.Black;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menu Items
|
||||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue