2012-06-24 03:45:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2012-06-24 03:45:56 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class HexFind : Form
|
|
|
|
|
{
|
2013-11-20 01:37:54 +00:00
|
|
|
|
private Point _location;
|
2013-11-28 20:02:32 +00:00
|
|
|
|
|
2012-06-24 03:45:56 +00:00
|
|
|
|
public HexFind()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-02-24 03:18:43 +00:00
|
|
|
|
ChangeCasing();
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetInitialValue(string value)
|
|
|
|
|
{
|
|
|
|
|
FindBox.Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetLocation(Point p)
|
|
|
|
|
{
|
2013-11-20 01:37:54 +00:00
|
|
|
|
_location = p;
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HexFind_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-20 01:37:54 +00:00
|
|
|
|
if (_location.X > 0 && _location.Y > 0)
|
2012-09-03 01:17:03 +00:00
|
|
|
|
{
|
2013-11-20 01:37:54 +00:00
|
|
|
|
Location = _location;
|
2012-09-03 01:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetFindBoxChars()
|
|
|
|
|
{
|
2014-02-24 02:50:56 +00:00
|
|
|
|
if (string.IsNullOrWhiteSpace(FindBox.Text))
|
2012-09-03 01:17:03 +00:00
|
|
|
|
{
|
2014-02-24 02:50:56 +00:00
|
|
|
|
return string.Empty;
|
2012-09-03 01:17:03 +00:00
|
|
|
|
}
|
2014-02-24 02:50:56 +00:00
|
|
|
|
|
|
|
|
|
if (HexRadio.Checked)
|
2012-09-03 01:17:03 +00:00
|
|
|
|
{
|
|
|
|
|
return FindBox.Text;
|
|
|
|
|
}
|
2014-02-24 02:50:56 +00:00
|
|
|
|
|
2014-03-23 23:47:20 +00:00
|
|
|
|
|
|
|
|
|
var bytes = GlobalWin.Tools.HexEditor.ConvertTextToBytes(FindBox.Text);
|
|
|
|
|
|
2014-02-24 02:50:56 +00:00
|
|
|
|
var bytestring = new StringBuilder();
|
2014-03-23 23:47:20 +00:00
|
|
|
|
foreach (var b in bytes)
|
2012-09-03 01:17:03 +00:00
|
|
|
|
{
|
2014-02-24 02:50:56 +00:00
|
|
|
|
bytestring.Append(string.Format("{0:X2}", b));
|
2012-09-03 01:17:03 +00:00
|
|
|
|
}
|
2014-02-24 02:50:56 +00:00
|
|
|
|
|
|
|
|
|
return bytestring.ToString();
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Find_Prev_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.Tools.HexEditor.FindPrev(GetFindBoxChars(), false);
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Find_Next_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.Tools.HexEditor.FindNext(GetFindBoxChars(), false);
|
2012-09-03 01:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ChangeCasing()
|
|
|
|
|
{
|
2014-02-24 03:18:43 +00:00
|
|
|
|
var text = FindBox.Text;
|
|
|
|
|
var location = FindBox.Location;
|
|
|
|
|
var size = FindBox.Size;
|
|
|
|
|
|
|
|
|
|
Controls.Remove(FindBox);
|
|
|
|
|
if (HexRadio.Checked)
|
|
|
|
|
{
|
|
|
|
|
FindBox = new HexTextBox { CharacterCasing = CharacterCasing.Upper };
|
|
|
|
|
(FindBox as HexTextBox).Nullable = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FindBox = new TextBox { CharacterCasing = CharacterCasing.Normal };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FindBox.Text = text;
|
|
|
|
|
FindBox.Size = size;
|
|
|
|
|
Controls.Add(FindBox);
|
|
|
|
|
FindBox.Location = location;
|
2012-09-03 01:17:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HexRadio_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeCasing();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TextRadio_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeCasing();
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
2012-09-23 23:20:30 +00:00
|
|
|
|
|
|
|
|
|
private void FindBox_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyData == Keys.Enter)
|
|
|
|
|
{
|
2013-11-03 16:07:58 +00:00
|
|
|
|
GlobalWin.Tools.HexEditor.FindNext(GetFindBoxChars(), false);
|
2012-09-23 23:20:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-22 01:14:49 +00:00
|
|
|
|
|
|
|
|
|
private void HexFind_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.KeyCode == Keys.Escape)
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-24 03:45:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|