New Hex Editor - add the plumbing for the HexView widget, that will use the GDIRenderer as the basis for the drawing.

This commit is contained in:
adelikat 2015-12-24 11:15:29 -05:00
parent da25052e09
commit 60692450e8
7 changed files with 113 additions and 26 deletions

View File

@ -479,6 +479,9 @@
<Compile Include="CustomControls\HexTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\HexView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\InputConfigBase.cs">
<SubType>Form</SubType>
</Compile>

View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.CustomControls;
namespace BizHawk.Client.EmuHawk
{
public class HexView : Control
{
private readonly GDIRenderer Gdi;
private readonly Font NormalFont;
private Size _charSize;
public HexView()
{
NormalFont = new Font("Courier New", 8); // Only support fixed width
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
SetStyle(ControlStyles.Opaque, true);
Gdi = new GDIRenderer();
using (var g = CreateGraphics())
using (var LCK = Gdi.LockGraphics(g))
{
_charSize = Gdi.MeasureString("A", NormalFont); // TODO make this a property so changing it updates other values.
}
}
protected override void Dispose(bool disposing)
{
Gdi.Dispose();
NormalFont.Dispose();
base.Dispose(disposing);
}
protected override void OnPaint(PaintEventArgs e)
{
using (var LCK = Gdi.LockGraphics(e.Graphics))
{
Gdi.StartOffScreenBitmap(Width, Height);
// White Background
Gdi.SetBrush(Color.White);
Gdi.SetSolidPen(Color.White);
Gdi.FillRectangle(0, 0, Width, Height);
Gdi.DrawString("Hello World", new Point(10, 10));
Gdi.CopyToScreen();
Gdi.EndOffScreenBitmap();
}
}
}
}

View File

@ -1072,7 +1072,7 @@
//
this.RecordAVMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.RecordHS;
this.RecordAVMenuItem.Name = "RecordAVMenuItem";
this.RecordAVMenuItem.Size = new System.Drawing.Size(223, 22);
this.RecordAVMenuItem.Size = new System.Drawing.Size(225, 22);
this.RecordAVMenuItem.Text = "&Record AVI/WAV";
this.RecordAVMenuItem.Click += new System.EventHandler(this.RecordAVMenuItem_Click);
//
@ -1080,7 +1080,7 @@
//
this.ConfigAndRecordAVMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.AVI;
this.ConfigAndRecordAVMenuItem.Name = "ConfigAndRecordAVMenuItem";
this.ConfigAndRecordAVMenuItem.Size = new System.Drawing.Size(223, 22);
this.ConfigAndRecordAVMenuItem.Size = new System.Drawing.Size(225, 22);
this.ConfigAndRecordAVMenuItem.Text = "Config and Record AVI/WAV";
this.ConfigAndRecordAVMenuItem.Click += new System.EventHandler(this.ConfigAndRecordAVMenuItem_Click);
//
@ -1088,26 +1088,26 @@
//
this.StopAVIMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.Stop;
this.StopAVIMenuItem.Name = "StopAVIMenuItem";
this.StopAVIMenuItem.Size = new System.Drawing.Size(223, 22);
this.StopAVIMenuItem.Size = new System.Drawing.Size(225, 22);
this.StopAVIMenuItem.Text = "&Stop AVI/WAV";
this.StopAVIMenuItem.Click += new System.EventHandler(this.StopAVMenuItem_Click);
//
// toolStripSeparator19
//
this.toolStripSeparator19.Name = "toolStripSeparator19";
this.toolStripSeparator19.Size = new System.Drawing.Size(220, 6);
this.toolStripSeparator19.Size = new System.Drawing.Size(222, 6);
//
// CaptureOSDMenuItem
//
this.CaptureOSDMenuItem.Name = "CaptureOSDMenuItem";
this.CaptureOSDMenuItem.Size = new System.Drawing.Size(223, 22);
this.CaptureOSDMenuItem.Size = new System.Drawing.Size(225, 22);
this.CaptureOSDMenuItem.Text = "Capture OSD";
this.CaptureOSDMenuItem.Click += new System.EventHandler(this.CaptureOSDMenuItem_Click);
//
// SynclessRecordingMenuItem
//
this.SynclessRecordingMenuItem.Name = "SynclessRecordingMenuItem";
this.SynclessRecordingMenuItem.Size = new System.Drawing.Size(223, 22);
this.SynclessRecordingMenuItem.Size = new System.Drawing.Size(225, 22);
this.SynclessRecordingMenuItem.Text = "S&yncless Recording Tools";
this.SynclessRecordingMenuItem.Click += new System.EventHandler(this.SynclessRecordingMenuItem_Click);
//
@ -1865,7 +1865,7 @@
this.batchRunnerToolStripMenuItem,
this.ExperimentalToolsSubMenu});
this.ToolsSubMenu.Name = "ToolsSubMenu";
this.ToolsSubMenu.Size = new System.Drawing.Size(47, 19);
this.ToolsSubMenu.Size = new System.Drawing.Size(48, 19);
this.ToolsSubMenu.Text = "&Tools";
this.ToolsSubMenu.DropDownOpened += new System.EventHandler(this.ToolsSubMenu_DropDownOpened);
//
@ -2046,6 +2046,7 @@
this.NewHexEditorMenuItem.Name = "NewHexEditorMenuItem";
this.NewHexEditorMenuItem.Size = new System.Drawing.Size(155, 22);
this.NewHexEditorMenuItem.Text = "New Hex Editor";
this.NewHexEditorMenuItem.Click += new System.EventHandler(this.NewHexEditorMenuItem_Click);
//
// NESSubMenu
//
@ -2212,7 +2213,7 @@
//
this.PceControllerSettingsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.GameController;
this.PceControllerSettingsMenuItem.Name = "PceControllerSettingsMenuItem";
this.PceControllerSettingsMenuItem.Size = new System.Drawing.Size(258, 22);
this.PceControllerSettingsMenuItem.Size = new System.Drawing.Size(259, 22);
this.PceControllerSettingsMenuItem.Text = "Controller Settings";
this.PceControllerSettingsMenuItem.Click += new System.EventHandler(this.PceControllerSettingsMenuItem_Click);
//
@ -2220,59 +2221,59 @@
//
this.PCEGraphicsSettingsMenuItem.Image = global::BizHawk.Client.EmuHawk.Properties.Resources.tvIcon;
this.PCEGraphicsSettingsMenuItem.Name = "PCEGraphicsSettingsMenuItem";
this.PCEGraphicsSettingsMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEGraphicsSettingsMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEGraphicsSettingsMenuItem.Text = "Graphics Settings";
this.PCEGraphicsSettingsMenuItem.Click += new System.EventHandler(this.PCEGraphicsSettingsMenuItem_Click);
//
// toolStripSeparator32
//
this.toolStripSeparator32.Name = "toolStripSeparator32";
this.toolStripSeparator32.Size = new System.Drawing.Size(255, 6);
this.toolStripSeparator32.Size = new System.Drawing.Size(256, 6);
//
// PCEBGViewerMenuItem
//
this.PCEBGViewerMenuItem.Name = "PCEBGViewerMenuItem";
this.PCEBGViewerMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEBGViewerMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEBGViewerMenuItem.Text = "&BG Viewer";
this.PCEBGViewerMenuItem.Click += new System.EventHandler(this.PCEBGViewerMenuItem_Click);
//
// PCEtileViewerToolStripMenuItem
//
this.PCEtileViewerToolStripMenuItem.Name = "PCEtileViewerToolStripMenuItem";
this.PCEtileViewerToolStripMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEtileViewerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEtileViewerToolStripMenuItem.Text = "&Tile Viewer";
this.PCEtileViewerToolStripMenuItem.Click += new System.EventHandler(this.PceTileViewerMenuItem_Click);
//
// PceSoundDebuggerToolStripMenuItem
//
this.PceSoundDebuggerToolStripMenuItem.Name = "PceSoundDebuggerToolStripMenuItem";
this.PceSoundDebuggerToolStripMenuItem.Size = new System.Drawing.Size(258, 22);
this.PceSoundDebuggerToolStripMenuItem.Size = new System.Drawing.Size(259, 22);
this.PceSoundDebuggerToolStripMenuItem.Text = "&Sound Debugger";
this.PceSoundDebuggerToolStripMenuItem.Click += new System.EventHandler(this.PceSoundDebuggerToolStripMenuItem_Click);
//
// toolStripSeparator25
//
this.toolStripSeparator25.Name = "toolStripSeparator25";
this.toolStripSeparator25.Size = new System.Drawing.Size(255, 6);
this.toolStripSeparator25.Size = new System.Drawing.Size(256, 6);
//
// PCEAlwaysPerformSpriteLimitMenuItem
//
this.PCEAlwaysPerformSpriteLimitMenuItem.Name = "PCEAlwaysPerformSpriteLimitMenuItem";
this.PCEAlwaysPerformSpriteLimitMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEAlwaysPerformSpriteLimitMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEAlwaysPerformSpriteLimitMenuItem.Text = "Always Perform Sprite Limit";
this.PCEAlwaysPerformSpriteLimitMenuItem.Click += new System.EventHandler(this.PCEAlwaysPerformSpriteLimitMenuItem_Click);
//
// PCEAlwaysEqualizeVolumesMenuItem
//
this.PCEAlwaysEqualizeVolumesMenuItem.Name = "PCEAlwaysEqualizeVolumesMenuItem";
this.PCEAlwaysEqualizeVolumesMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEAlwaysEqualizeVolumesMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEAlwaysEqualizeVolumesMenuItem.Text = "Always Equalize Volumes (PCE-CD)";
this.PCEAlwaysEqualizeVolumesMenuItem.Click += new System.EventHandler(this.PCEAlwaysEqualizeVolumesMenuItem_Click);
//
// PCEArcadeCardRewindEnableMenuItem
//
this.PCEArcadeCardRewindEnableMenuItem.Name = "PCEArcadeCardRewindEnableMenuItem";
this.PCEArcadeCardRewindEnableMenuItem.Size = new System.Drawing.Size(258, 22);
this.PCEArcadeCardRewindEnableMenuItem.Size = new System.Drawing.Size(259, 22);
this.PCEArcadeCardRewindEnableMenuItem.Text = "Arcade Card Rewind-Enable Hack";
this.PCEArcadeCardRewindEnableMenuItem.Click += new System.EventHandler(this.PCEArcadeCardRewindEnableMenuItem_Click);
//

View File

@ -1369,6 +1369,11 @@ namespace BizHawk.Client.EmuHawk
new BatchRun().ShowDialog();
}
private void NewHexEditorMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.Load<NewHexEditor>();
}
#endregion
#region NES

View File

@ -4094,6 +4094,5 @@ namespace BizHawk.Client.EmuHawk
quickNESToolStripMenuItem.Checked = Global.Config.NES_InQuickNES == true;
nesHawkToolStripMenuItem.Checked = Global.Config.NES_InQuickNES == false;
}
}
}

View File

@ -124,7 +124,7 @@
<data name="DisplayConfigMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA67AAAOuwHH+NQ2AAABpElE
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA66AAAOugEVvzbSAAABpElE
QVQ4T52TQUsCURSF33+SDAUxRAyEwQiEksiFUJEMhGEDOcQgRi2UGJBgCkFIZDDbGEGWEsTMItBNrdu3
ad3y1HmkVNosvHC4l3u+A2/ezIi/5fP58D1OlJf3qzRNmwCn7TzrZ8AzfGk3kM1mkcvlUCgUUCqVUKlU
UK1WwSDFmTt6ZMgyw6zIZDIYDAYziVmRTqfhui5WDhoI7VxAMa6xdvKIDWsgxZk7emTIRiIR2ZkVqVQK
@ -138,7 +138,7 @@
<data name="FirmwaresMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABBJAAAQSQGYcYbyAAAAcElE
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABBIAAAQSAFKNmQWAAAAcElE
QVQ4T82Q4QoAIQiDffR7804DY+pOov5c8GltwyiRR8YVTLTFOsWK2iA0eAapQkPOznwRGnJ25rX87AmK
/3ruFCvhCR9oclI8PNggJHg7A46w4rf5zY6H8jlAxQQOKMPWBswSIpmloXkEFbeR8QKDpKJKL1M/dQAA
AABJRU5ErkJggg==
@ -147,7 +147,7 @@
<data name="gameSharkConverterToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGPUlE
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA7DAAAOwwHHb6hkAAAGPUlE
QVRIS7WWaVCTVxSGUWf0h3+gQhFqx6WgFG0tE5AwKSBLQIjAgGIrCLEgEmSTTSSUWBhAghI2bcsSNukU
CGHAALKFPeyLCjoECy7gPjru+9I3fmkIaQD94Tt3Ml++3HOee88599yovP/M+mTAu3fvnj9//vDhwwcP
HuDz0aNHT58+ff36tfTn/+kTAM+ePbt58+Y/HzQ5OXnlypWrV69OT0/fuHED7+/evYsJ0qly+ijA48eP
@ -582,7 +582,7 @@
<data name="toolStripMenuItem8.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA67AAAOuwHH+NQ2AAABpElE
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA66AAAOugEVvzbSAAABpElE
QVQ4T52TQUsCURSF33+SDAUxRAyEwQiEksiFUJEMhGEDOcQgRi2UGJBgCkFIZDDbGEGWEsTMItBNrdu3
ad3y1HmkVNosvHC4l3u+A2/ezIi/5fP58D1OlJf3qzRNmwCn7TzrZ8AzfGk3kM1mkcvlUCgUUCqVUKlU
UK1WwSDFmTt6ZMgyw6zIZDIYDAYziVmRTqfhui5WDhoI7VxAMa6xdvKIDWsgxZk7emTIRiIR2ZkVqVQK
@ -596,7 +596,7 @@
<data name="toolStripMenuItem11.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABBJAAAQSQGYcYbyAAAAcElE
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAABBIAAAQSAFKNmQWAAAAcElE
QVQ4T82Q4QoAIQiDffR7804DY+pOov5c8GltwyiRR8YVTLTFOsWK2iA0eAapQkPOznwRGnJ25rX87AmK
/3ruFCvhCR9oclI8PNggJHg7A46w4rf5zY6H8jlAxQQOKMPWBswSIpmloXkEFbeR8QKDpKJKL1M/dQAA
AABJRU5ErkJggg==

View File

@ -31,6 +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.HexMenu.SuspendLayout();
this.SuspendLayout();
//
@ -40,7 +41,7 @@
this.FileSubMenu});
this.HexMenu.Location = new System.Drawing.Point(0, 0);
this.HexMenu.Name = "HexMenu";
this.HexMenu.Size = new System.Drawing.Size(284, 24);
this.HexMenu.Size = new System.Drawing.Size(448, 24);
this.HexMenu.TabIndex = 0;
this.HexMenu.Text = "menuStrip1";
//
@ -57,15 +58,27 @@
//
this.ExitMenuItem.Name = "ExitMenuItem";
this.ExitMenuItem.ShortcutKeyDisplayString = "Alt+F4";
this.ExitMenuItem.Size = new System.Drawing.Size(152, 22);
this.ExitMenuItem.Size = new System.Drawing.Size(134, 22);
this.ExitMenuItem.Text = "E&xit";
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
//
// hexView1
//
this.hexView1.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";
//
// NewHexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 261);
this.ClientSize = new System.Drawing.Size(448, 270);
this.Controls.Add(this.hexView1);
this.Controls.Add(this.HexMenu);
this.MainMenuStrip = this.HexMenu;
this.Name = "NewHexEditor";
@ -83,5 +96,6 @@
private System.Windows.Forms.MenuStrip HexMenu;
private System.Windows.Forms.ToolStripMenuItem FileSubMenu;
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private HexView hexView1;
}
}