From e6ddb8182958cb6324e4b40c4a903781ca0e0b76 Mon Sep 17 00:00:00 2001 From: Foifur Date: Thu, 1 Aug 2024 15:42:41 -0700 Subject: [PATCH 1/3] Updated Hex Editor for High-DPI mode --- Source/Plugins/HexEditor/HexEditor.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/Plugins/HexEditor/HexEditor.cs b/Source/Plugins/HexEditor/HexEditor.cs index e032cce2f..87adb0bbf 100644 --- a/Source/Plugins/HexEditor/HexEditor.cs +++ b/Source/Plugins/HexEditor/HexEditor.cs @@ -16,8 +16,9 @@ namespace RTCV.Plugins.HexEditor using RTCV.CorruptCore; using RTCV.CorruptCore.Extensions; using NLog; + using System.Runtime.InteropServices; - #pragma warning disable CA2213 //Component designer classes generate their own Dispose method +#pragma warning disable CA2213 //Component designer classes generate their own Dispose method //Based on the Hex Editor from Bizhawk, available under MIT. //https://github.com/tasvideos/bizhawk public partial class HexEditor : Form @@ -66,7 +67,7 @@ public HexEditor() { DataSize = 1; - var font = new Font("Courier New", 8); + var font = new Font("Courier New", (float)8.5); // Measure the font. There seems to be some extra horizontal padding on the first // character so we'll see how much the width increases on the second character. @@ -82,6 +83,7 @@ public HexEditor() AddressesLabel.BackColor = Color.Transparent; //LoadConfigSettings(); SetHeader(); + Header.BackColor = Color.Transparent; //Closing += (o, e) => SaveConfigSettings(); Header.Font = font; @@ -179,6 +181,9 @@ await Task.Run(() => SyncObjectSingleton.FormExecute(() => { AddressesLabel.Text = GenerateMemoryViewString(true); AddressLabel.Text = GenerateAddressString(); + AddressLabel.BringToFront(); + AddressesLabel.BringToFront(); + Header.Location = new Point(28, 39); } catch (Exception e) { @@ -624,6 +629,7 @@ private void UpdateGroupBoxTitle() { var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0'); MemoryViewerBox.Text = $"{AllSpec.VanguardSpec?[VSPEC.NAME] ?? "UNKNOWN"} {_domain} - {addressesString} addresses"; + MemoryViewerBox.SendToBack(); } private void ClearNibbles() @@ -742,7 +748,7 @@ private void ResetScrollBar() private void SetUpScrollBar() { - _rowsVisible = (MemoryViewerBox.Height - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; + _rowsVisible = (MemoryViewerBox.Height + 15 - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; var totalRows = (int)((_domain.Size + 15) / 16); if (totalRows < _rowsVisible) @@ -763,7 +769,7 @@ private long GetPointedAddress(int x, int y) // Scroll value determines the first row long i = HexScrollBar.Value; - var rowoffset = y / _fontHeight; + var rowoffset = y / (_fontHeight - 2); i += rowoffset; var colWidth = (DataSize * 2) + 1; @@ -830,12 +836,13 @@ private void ClearHighlighted() private Point GetAddressCoordinates(long address) { - var extra = (address % DataSize) * _fontWidth * 2; + var xExtra = (address % DataSize) * _fontWidth * 2; + var yExtra = (address % DataSize); var xOffset = AddressesLabel.Location.X + (_fontWidth / 2) - 2; - var yOffset = AddressesLabel.Location.Y; + var yOffset = AddressesLabel.Location.Y - 2 - ((address / 16) - HexScrollBar.Value) * 2.1; return new Point( - (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + extra), + (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + xExtra), (int)((((address / 16) - HexScrollBar.Value) * _fontHeight) + yOffset) ); } @@ -1897,5 +1904,10 @@ private bool IsFrozen(long address) private void OptionsSubMenu_Click(object sender, EventArgs e) { } + + private void AddressLabel_Click(object sender, EventArgs e) + { + + } } } From de36c31eec336c1be96b977cadfe7e53816431b4 Mon Sep 17 00:00:00 2001 From: Foifur Date: Thu, 1 Aug 2024 18:02:00 -0700 Subject: [PATCH 2/3] Revert "Updated Hex Editor for High-DPI mode" This reverts commit e6ddb8182958cb6324e4b40c4a903781ca0e0b76. --- Source/Plugins/HexEditor/HexEditor.cs | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/Source/Plugins/HexEditor/HexEditor.cs b/Source/Plugins/HexEditor/HexEditor.cs index 87adb0bbf..e032cce2f 100644 --- a/Source/Plugins/HexEditor/HexEditor.cs +++ b/Source/Plugins/HexEditor/HexEditor.cs @@ -16,9 +16,8 @@ namespace RTCV.Plugins.HexEditor using RTCV.CorruptCore; using RTCV.CorruptCore.Extensions; using NLog; - using System.Runtime.InteropServices; -#pragma warning disable CA2213 //Component designer classes generate their own Dispose method + #pragma warning disable CA2213 //Component designer classes generate their own Dispose method //Based on the Hex Editor from Bizhawk, available under MIT. //https://github.com/tasvideos/bizhawk public partial class HexEditor : Form @@ -67,7 +66,7 @@ public HexEditor() { DataSize = 1; - var font = new Font("Courier New", (float)8.5); + var font = new Font("Courier New", 8); // Measure the font. There seems to be some extra horizontal padding on the first // character so we'll see how much the width increases on the second character. @@ -83,7 +82,6 @@ public HexEditor() AddressesLabel.BackColor = Color.Transparent; //LoadConfigSettings(); SetHeader(); - Header.BackColor = Color.Transparent; //Closing += (o, e) => SaveConfigSettings(); Header.Font = font; @@ -181,9 +179,6 @@ await Task.Run(() => SyncObjectSingleton.FormExecute(() => { AddressesLabel.Text = GenerateMemoryViewString(true); AddressLabel.Text = GenerateAddressString(); - AddressLabel.BringToFront(); - AddressesLabel.BringToFront(); - Header.Location = new Point(28, 39); } catch (Exception e) { @@ -629,7 +624,6 @@ private void UpdateGroupBoxTitle() { var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0'); MemoryViewerBox.Text = $"{AllSpec.VanguardSpec?[VSPEC.NAME] ?? "UNKNOWN"} {_domain} - {addressesString} addresses"; - MemoryViewerBox.SendToBack(); } private void ClearNibbles() @@ -748,7 +742,7 @@ private void ResetScrollBar() private void SetUpScrollBar() { - _rowsVisible = (MemoryViewerBox.Height + 15 - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; + _rowsVisible = (MemoryViewerBox.Height - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; var totalRows = (int)((_domain.Size + 15) / 16); if (totalRows < _rowsVisible) @@ -769,7 +763,7 @@ private long GetPointedAddress(int x, int y) // Scroll value determines the first row long i = HexScrollBar.Value; - var rowoffset = y / (_fontHeight - 2); + var rowoffset = y / _fontHeight; i += rowoffset; var colWidth = (DataSize * 2) + 1; @@ -836,13 +830,12 @@ private void ClearHighlighted() private Point GetAddressCoordinates(long address) { - var xExtra = (address % DataSize) * _fontWidth * 2; - var yExtra = (address % DataSize); + var extra = (address % DataSize) * _fontWidth * 2; var xOffset = AddressesLabel.Location.X + (_fontWidth / 2) - 2; - var yOffset = AddressesLabel.Location.Y - 2 - ((address / 16) - HexScrollBar.Value) * 2.1; + var yOffset = AddressesLabel.Location.Y; return new Point( - (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + xExtra), + (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + extra), (int)((((address / 16) - HexScrollBar.Value) * _fontHeight) + yOffset) ); } @@ -1904,10 +1897,5 @@ private bool IsFrozen(long address) private void OptionsSubMenu_Click(object sender, EventArgs e) { } - - private void AddressLabel_Click(object sender, EventArgs e) - { - - } } } From 73da232b7ee9ada13045681f690156626eb9dae4 Mon Sep 17 00:00:00 2001 From: Foifur Date: Thu, 1 Aug 2024 18:08:11 -0700 Subject: [PATCH 3/3] Update HexEditor.cs --- Source/Plugins/HexEditor/HexEditor.cs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Source/Plugins/HexEditor/HexEditor.cs b/Source/Plugins/HexEditor/HexEditor.cs index e032cce2f..87adb0bbf 100644 --- a/Source/Plugins/HexEditor/HexEditor.cs +++ b/Source/Plugins/HexEditor/HexEditor.cs @@ -16,8 +16,9 @@ namespace RTCV.Plugins.HexEditor using RTCV.CorruptCore; using RTCV.CorruptCore.Extensions; using NLog; + using System.Runtime.InteropServices; - #pragma warning disable CA2213 //Component designer classes generate their own Dispose method +#pragma warning disable CA2213 //Component designer classes generate their own Dispose method //Based on the Hex Editor from Bizhawk, available under MIT. //https://github.com/tasvideos/bizhawk public partial class HexEditor : Form @@ -66,7 +67,7 @@ public HexEditor() { DataSize = 1; - var font = new Font("Courier New", 8); + var font = new Font("Courier New", (float)8.5); // Measure the font. There seems to be some extra horizontal padding on the first // character so we'll see how much the width increases on the second character. @@ -82,6 +83,7 @@ public HexEditor() AddressesLabel.BackColor = Color.Transparent; //LoadConfigSettings(); SetHeader(); + Header.BackColor = Color.Transparent; //Closing += (o, e) => SaveConfigSettings(); Header.Font = font; @@ -179,6 +181,9 @@ await Task.Run(() => SyncObjectSingleton.FormExecute(() => { AddressesLabel.Text = GenerateMemoryViewString(true); AddressLabel.Text = GenerateAddressString(); + AddressLabel.BringToFront(); + AddressesLabel.BringToFront(); + Header.Location = new Point(28, 39); } catch (Exception e) { @@ -624,6 +629,7 @@ private void UpdateGroupBoxTitle() { var addressesString = "0x" + $"{_domain.Size / DataSize:X8}".TrimStart('0'); MemoryViewerBox.Text = $"{AllSpec.VanguardSpec?[VSPEC.NAME] ?? "UNKNOWN"} {_domain} - {addressesString} addresses"; + MemoryViewerBox.SendToBack(); } private void ClearNibbles() @@ -742,7 +748,7 @@ private void ResetScrollBar() private void SetUpScrollBar() { - _rowsVisible = (MemoryViewerBox.Height - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; + _rowsVisible = (MemoryViewerBox.Height + 15 - (_fontHeight * 2) - (_fontHeight / 2)) / _fontHeight; var totalRows = (int)((_domain.Size + 15) / 16); if (totalRows < _rowsVisible) @@ -763,7 +769,7 @@ private long GetPointedAddress(int x, int y) // Scroll value determines the first row long i = HexScrollBar.Value; - var rowoffset = y / _fontHeight; + var rowoffset = y / (_fontHeight - 2); i += rowoffset; var colWidth = (DataSize * 2) + 1; @@ -830,12 +836,13 @@ private void ClearHighlighted() private Point GetAddressCoordinates(long address) { - var extra = (address % DataSize) * _fontWidth * 2; + var xExtra = (address % DataSize) * _fontWidth * 2; + var yExtra = (address % DataSize); var xOffset = AddressesLabel.Location.X + (_fontWidth / 2) - 2; - var yOffset = AddressesLabel.Location.Y; + var yOffset = AddressesLabel.Location.Y - 2 - ((address / 16) - HexScrollBar.Value) * 2.1; return new Point( - (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + extra), + (int)((((address % 16) / DataSize) * (_fontWidth * ((DataSize * 2) + 1))) + xOffset + xExtra), (int)((((address / 16) - HexScrollBar.Value) * _fontHeight) + yOffset) ); } @@ -1897,5 +1904,10 @@ private bool IsFrozen(long address) private void OptionsSubMenu_Click(object sender, EventArgs e) { } + + private void AddressLabel_Click(object sender, EventArgs e) + { + + } } }