Hex Editor - text option in Find Box, this feature converts text to its byte codes and searches that byte array
This commit is contained in:
parent
ad162b614f
commit
eae73accf3
|
@ -31,6 +31,8 @@
|
|||
this.FindBox = new System.Windows.Forms.TextBox();
|
||||
this.Find_Prev = new System.Windows.Forms.Button();
|
||||
this.Find_Next = new System.Windows.Forms.Button();
|
||||
this.HexRadio = new System.Windows.Forms.RadioButton();
|
||||
this.TextRadio = new System.Windows.Forms.RadioButton();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// FindBox
|
||||
|
@ -40,6 +42,7 @@
|
|||
this.FindBox.Name = "FindBox";
|
||||
this.FindBox.Size = new System.Drawing.Size(156, 20);
|
||||
this.FindBox.TabIndex = 0;
|
||||
this.FindBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.FindBox_KeyPress);
|
||||
//
|
||||
// Find_Prev
|
||||
//
|
||||
|
@ -61,11 +64,37 @@
|
|||
this.Find_Next.UseVisualStyleBackColor = true;
|
||||
this.Find_Next.Click += new System.EventHandler(this.Find_Next_Click);
|
||||
//
|
||||
// HexRadio
|
||||
//
|
||||
this.HexRadio.AutoSize = true;
|
||||
this.HexRadio.Checked = true;
|
||||
this.HexRadio.Location = new System.Drawing.Point(13, 69);
|
||||
this.HexRadio.Name = "HexRadio";
|
||||
this.HexRadio.Size = new System.Drawing.Size(44, 17);
|
||||
this.HexRadio.TabIndex = 3;
|
||||
this.HexRadio.TabStop = true;
|
||||
this.HexRadio.Text = "Hex";
|
||||
this.HexRadio.UseVisualStyleBackColor = true;
|
||||
this.HexRadio.CheckedChanged += new System.EventHandler(this.HexRadio_CheckedChanged);
|
||||
//
|
||||
// TextRadio
|
||||
//
|
||||
this.TextRadio.AutoSize = true;
|
||||
this.TextRadio.Location = new System.Drawing.Point(63, 69);
|
||||
this.TextRadio.Name = "TextRadio";
|
||||
this.TextRadio.Size = new System.Drawing.Size(46, 17);
|
||||
this.TextRadio.TabIndex = 4;
|
||||
this.TextRadio.Text = "Text";
|
||||
this.TextRadio.UseVisualStyleBackColor = true;
|
||||
this.TextRadio.CheckedChanged += new System.EventHandler(this.TextRadio_CheckedChanged);
|
||||
//
|
||||
// HexFind
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(178, 77);
|
||||
this.ClientSize = new System.Drawing.Size(178, 93);
|
||||
this.Controls.Add(this.TextRadio);
|
||||
this.Controls.Add(this.HexRadio);
|
||||
this.Controls.Add(this.Find_Next);
|
||||
this.Controls.Add(this.Find_Prev);
|
||||
this.Controls.Add(this.FindBox);
|
||||
|
@ -84,5 +113,7 @@
|
|||
private System.Windows.Forms.TextBox FindBox;
|
||||
private System.Windows.Forms.Button Find_Prev;
|
||||
private System.Windows.Forms.Button Find_Next;
|
||||
private System.Windows.Forms.RadioButton HexRadio;
|
||||
private System.Windows.Forms.RadioButton TextRadio;
|
||||
}
|
||||
}
|
|
@ -31,17 +31,84 @@ namespace BizHawk.MultiClient
|
|||
private void HexFind_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (location.X > 0 && location.Y > 0)
|
||||
{
|
||||
this.Location = location;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetFindBoxChars()
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(FindBox.Text))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else if (HexRadio.Checked)
|
||||
{
|
||||
return FindBox.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
List<byte> bytes = new List<byte>();
|
||||
foreach (char c in FindBox.Text)
|
||||
{
|
||||
bytes.Add(Convert.ToByte(c));
|
||||
}
|
||||
|
||||
StringBuilder bytestring = new StringBuilder();
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
bytestring.Append(String.Format("{0:X2}", b));
|
||||
}
|
||||
|
||||
return bytestring.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void Find_Prev_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.MainForm.HexEditor1.FindPrev(FindBox.Text);
|
||||
Global.MainForm.HexEditor1.FindPrev(GetFindBoxChars());
|
||||
}
|
||||
|
||||
private void Find_Next_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.MainForm.HexEditor1.FindNext(FindBox.Text);
|
||||
Global.MainForm.HexEditor1.FindNext(GetFindBoxChars());
|
||||
}
|
||||
|
||||
private void FindBox_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == '\b')
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (HexRadio.Checked)
|
||||
{
|
||||
if (!InputValidate.IsValidHexNumber(e.KeyChar))
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeCasing()
|
||||
{
|
||||
if (HexRadio.Checked)
|
||||
{
|
||||
FindBox.CharacterCasing = CharacterCasing.Upper;
|
||||
}
|
||||
else
|
||||
{
|
||||
FindBox.CharacterCasing = CharacterCasing.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
private void HexRadio_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeCasing();
|
||||
}
|
||||
|
||||
private void TextRadio_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ChangeCasing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue