From 4db328f7adef2714b3338e76795c8105210dda13 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 28 May 2017 10:13:34 -0500 Subject: [PATCH] Hex Editor - Find box - remember Hex vs Text radio selection --- BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs | 12 ++++++++++-- BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs | 13 +++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 12010313ce..02752e22b6 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -1489,7 +1489,13 @@ namespace BizHawk.Client.EmuHawk } UpdateValues(); - } + } + + private bool _lastSearchWasText = false; + private void SearchTypeChanged(bool isText) + { + _lastSearchWasText = isText; + } private void FindMenuItem_Click(object sender, EventArgs e) { @@ -1499,7 +1505,9 @@ namespace BizHawk.Client.EmuHawk _hexFind = new HexFind { InitialLocation = PointToScreen(AddressesLabel.Location), - InitialValue = _findStr + InitialValue = _findStr, + SearchTypeChangedCallback = SearchTypeChanged, + InitialText = _lastSearchWasText }; _hexFind.Show(); diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs index ba9f29c44f..8bfd208351 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexFind.cs @@ -13,7 +13,12 @@ namespace BizHawk.Client.EmuHawk ChangeCasing(); } + // Hacky values to remember the Hex vs Text radio selection across searches + public Action SearchTypeChangedCallback { get; set; } + public bool InitialText { get; set; } + public Point InitialLocation { get; set; } + public string InitialValue { @@ -28,8 +33,14 @@ namespace BizHawk.Client.EmuHawk Location = InitialLocation; } + if (InitialText) + { + TextRadio.Select(); + } + FindBox.Focus(); FindBox.Select(); + } private string GetFindBoxChars() @@ -100,11 +111,13 @@ namespace BizHawk.Client.EmuHawk private void HexRadio_CheckedChanged(object sender, EventArgs e) { ChangeCasing(); + SearchTypeChangedCallback?.Invoke(false); } private void TextRadio_CheckedChanged(object sender, EventArgs e) { ChangeCasing(); + SearchTypeChangedCallback?.Invoke(true); } private void FindBox_KeyDown(object sender, KeyEventArgs e)