hex editor - fix crash from previous commit, pass in dependencies to sub-forms
This commit is contained in:
parent
a7ccc3fdef
commit
0e218f5d4a
|
@ -126,7 +126,7 @@
|
|||
this.HexForegrnd.Name = "HexForegrnd";
|
||||
this.HexForegrnd.Size = new System.Drawing.Size(20, 20);
|
||||
this.HexForegrnd.TabIndex = 7;
|
||||
this.HexForegrnd.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexForegrnd_Click);
|
||||
this.HexForegrnd.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexForeground_Click);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
|
@ -153,7 +153,7 @@
|
|||
this.HexMenubar.Name = "HexMenubar";
|
||||
this.HexMenubar.Size = new System.Drawing.Size(20, 20);
|
||||
this.HexMenubar.TabIndex = 8;
|
||||
this.HexMenubar.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexMenubar_Click);
|
||||
this.HexMenubar.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexMenuBar_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
|
@ -171,7 +171,7 @@
|
|||
this.HexBackgrnd.Name = "HexBackgrnd";
|
||||
this.HexBackgrnd.Size = new System.Drawing.Size(20, 20);
|
||||
this.HexBackgrnd.TabIndex = 6;
|
||||
this.HexBackgrnd.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexBackgrnd_Click);
|
||||
this.HexBackgrnd.MouseClick += new System.Windows.Forms.MouseEventHandler(this.HexBackground_Click);
|
||||
//
|
||||
// HexColors_Form
|
||||
//
|
||||
|
|
|
@ -2,81 +2,87 @@
|
|||
using System.Windows.Forms;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class HexColorsForm : Form
|
||||
{
|
||||
public HexColorsForm()
|
||||
private readonly HexEditor _hexEditor;
|
||||
private readonly Config _config;
|
||||
|
||||
public HexColorsForm(HexEditor hexEditor, Config config)
|
||||
{
|
||||
_hexEditor = hexEditor;
|
||||
_config = config;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void HexColors_Form_Load(object sender, EventArgs e)
|
||||
{
|
||||
HexBackgrnd.BackColor = Global.Config.HexBackgrndColor;
|
||||
HexForegrnd.BackColor = Global.Config.HexForegrndColor;
|
||||
HexMenubar.BackColor = Global.Config.HexMenubarColor;
|
||||
HexFreeze.BackColor = Global.Config.HexFreezeColor;
|
||||
HexFreezeHL.BackColor = Global.Config.HexHighlightFreezeColor;
|
||||
HexHighlight.BackColor = Global.Config.HexHighlightColor;
|
||||
HexBackgrnd.BackColor = _config.HexBackgrndColor;
|
||||
HexForegrnd.BackColor = _config.HexForegrndColor;
|
||||
HexMenubar.BackColor = _config.HexMenubarColor;
|
||||
HexFreeze.BackColor = _config.HexFreezeColor;
|
||||
HexFreezeHL.BackColor = _config.HexHighlightFreezeColor;
|
||||
HexHighlight.BackColor = _config.HexHighlightColor;
|
||||
}
|
||||
|
||||
private void HexBackgrnd_Click(object sender, MouseEventArgs e)
|
||||
private void HexBackground_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Global.Config.HexBackgrndColor = colorDialog1.Color;
|
||||
GlobalWin.Tools.HexEditor.Header.BackColor = colorDialog1.Color;
|
||||
GlobalWin.Tools.HexEditor.MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor;
|
||||
_config.HexBackgrndColor = colorDialog1.Color;
|
||||
_hexEditor.Header.BackColor = colorDialog1.Color;
|
||||
_hexEditor.MemoryViewerBox.BackColor = _config.HexBackgrndColor;
|
||||
HexBackgrnd.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexForegrnd_Click(object sender, MouseEventArgs e)
|
||||
private void HexForeground_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Global.Config.HexForegrndColor = colorDialog1.Color;
|
||||
GlobalWin.Tools.HexEditor.Header.ForeColor = colorDialog1.Color;
|
||||
GlobalWin.Tools.HexEditor.MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor;
|
||||
_config.HexForegrndColor = colorDialog1.Color;
|
||||
_hexEditor.Header.ForeColor = colorDialog1.Color;
|
||||
_hexEditor.MemoryViewerBox.ForeColor = _config.HexForegrndColor;
|
||||
HexForegrnd.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexMenubar_Click(object sender, MouseEventArgs e)
|
||||
private void HexMenuBar_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Global.Config.HexMenubarColor = colorDialog1.Color;
|
||||
GlobalWin.Tools.HexEditor.HexMenuStrip.BackColor = Global.Config.HexMenubarColor;
|
||||
_config.HexMenubarColor = colorDialog1.Color;
|
||||
_hexEditor.HexMenuStrip.BackColor = _config.HexMenubarColor;
|
||||
HexMenubar.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexHighlight_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
if (colorDialog1.ShowDialog().IsOk())
|
||||
{
|
||||
Global.Config.HexHighlightColor = colorDialog1.Color;
|
||||
_config.HexHighlightColor = colorDialog1.Color;
|
||||
HexHighlight.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexFreeze_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
if (colorDialog1.ShowDialog().IsOk())
|
||||
{
|
||||
Global.Config.HexFreezeColor = colorDialog1.Color;
|
||||
_config.HexFreezeColor = colorDialog1.Color;
|
||||
HexFreeze.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexFreezeHL_Click(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
if (colorDialog1.ShowDialog().IsOk())
|
||||
{
|
||||
Global.Config.HexHighlightFreezeColor = colorDialog1.Color;
|
||||
_config.HexHighlightFreezeColor = colorDialog1.Color;
|
||||
HexFreezeHL.BackColor = colorDialog1.Color;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private bool _mouseIsDown;
|
||||
private byte[] _rom;
|
||||
private MemoryDomain _romDomain;
|
||||
private HexFind _hexFind = new HexFind();
|
||||
private HexFind _hexFind;
|
||||
|
||||
[ConfigPersist]
|
||||
private string LastDomain { get; set; }
|
||||
|
@ -92,6 +92,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public HexEditor()
|
||||
{
|
||||
_hexFind = new HexFind(this);
|
||||
RecentTables = new RecentFiles(8);
|
||||
DataSize = 1;
|
||||
|
||||
|
@ -106,7 +107,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
InitializeComponent();
|
||||
AddressesLabel.BackColor = Color.Transparent;
|
||||
LoadConfigSettings();
|
||||
SetHeader();
|
||||
Closing += (o, e) => CloseHexFind();
|
||||
|
||||
|
@ -441,6 +441,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void HexEditor_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadConfigSettings();
|
||||
DataSize = _domain.WordSize;
|
||||
SetDataSize(DataSize);
|
||||
|
||||
|
@ -1465,7 +1466,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_findStr = GetFindValues();
|
||||
if (!_hexFind.IsHandleCreated || _hexFind.IsDisposed)
|
||||
{
|
||||
_hexFind = new HexFind
|
||||
_hexFind = new HexFind(this)
|
||||
{
|
||||
InitialLocation = PointToScreen(AddressesLabel.Location),
|
||||
InitialValue = _findStr,
|
||||
|
|
|
@ -7,8 +7,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class HexFind : Form
|
||||
{
|
||||
public HexFind()
|
||||
private readonly HexEditor _hexEditor;
|
||||
|
||||
public HexFind(HexEditor hexEditor)
|
||||
{
|
||||
_hexEditor = hexEditor;
|
||||
InitializeComponent();
|
||||
ChangeCasing();
|
||||
}
|
||||
|
@ -18,12 +21,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
public bool InitialText { get; set; }
|
||||
|
||||
public Point InitialLocation { get; set; }
|
||||
|
||||
|
||||
public string InitialValue
|
||||
{
|
||||
get { return FindBox.Text; }
|
||||
set { FindBox.Text = value ?? ""; }
|
||||
get => FindBox.Text;
|
||||
set => FindBox.Text = value ?? "";
|
||||
}
|
||||
|
||||
private void HexFind_Load(object sender, EventArgs e)
|
||||
|
@ -55,25 +57,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
return FindBox.Text;
|
||||
}
|
||||
|
||||
var bytes = GlobalWin.Tools.HexEditor.ConvertTextToBytes(FindBox.Text);
|
||||
var bytes = _hexEditor.ConvertTextToBytes(FindBox.Text);
|
||||
|
||||
var bytestring = new StringBuilder();
|
||||
var byteString = new StringBuilder();
|
||||
foreach (var b in bytes)
|
||||
{
|
||||
bytestring.Append($"{b:X2}");
|
||||
byteString.Append($"{b:X2}");
|
||||
}
|
||||
|
||||
return bytestring.ToString();
|
||||
return byteString.ToString();
|
||||
}
|
||||
|
||||
private void Find_Prev_Click(object sender, EventArgs e)
|
||||
{
|
||||
GlobalWin.Tools.HexEditor.FindPrev(GetFindBoxChars(), false);
|
||||
_hexEditor.FindPrev(GetFindBoxChars(), false);
|
||||
}
|
||||
|
||||
private void Find_Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
GlobalWin.Tools.HexEditor.FindNext(GetFindBoxChars(), false);
|
||||
_hexEditor.FindNext(GetFindBoxChars(), false);
|
||||
}
|
||||
|
||||
private void ChangeCasing()
|
||||
|
|
Loading…
Reference in New Issue