From 63f35598fc4e4c994845363193d9df9a38d941c2 Mon Sep 17 00:00:00 2001 From: Souryo Date: Tue, 3 Oct 2017 18:28:42 -0400 Subject: [PATCH] Debugger: Fixed hex editor coloring when character view is disabled --- GUI.NET/Debugger/HexBox/HexBox.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/GUI.NET/Debugger/HexBox/HexBox.cs b/GUI.NET/Debugger/HexBox/HexBox.cs index 10451c6d..fca4f2a6 100644 --- a/GUI.NET/Debugger/HexBox/HexBox.cs +++ b/GUI.NET/Debugger/HexBox/HexBox.cs @@ -2504,8 +2504,6 @@ namespace Be.Windows.Forms void PaintHex(Graphics g, long startByte, long endByte) { - Brush brush = new SolidBrush(GetDefaultForeColor()); - Brush selBrush = new SolidBrush(_selectionForeColor); Brush selBrushBack = new SolidBrush(_selectionBackColor); int counter = -1; @@ -2513,21 +2511,28 @@ namespace Be.Windows.Forms bool isKeyInterpreterActive = _keyInterpreter == null || _keyInterpreter.GetType() == typeof(KeyInterpreter); + if(this.ByteColorProvider != null) { + this.ByteColorProvider.Prepare(_startByte, intern_endByte); + } + for (long i = startByte; i < intern_endByte + 1; i++) { counter++; Point gridPoint = GetGridBytePoint(counter); byte b = _byteProvider.ReadByte(i); - bool isSelectedByte = i >= _bytePos && i <= (_bytePos + _selectionLength - 1) && _selectionLength != 0; - - if (isSelectedByte && isKeyInterpreterActive) - { - PaintHexStringSelected(g, b, selBrush, selBrushBack, gridPoint); + Color byteColor = this.ForeColor; + if(this.ByteColorProvider != null) { + byteColor = this.ByteColorProvider.GetByteColor(_startByte, i); } - else - { - PaintHexString(g, b, brush, gridPoint); + + bool isSelectedByte = i >= _bytePos && i <= (_bytePos + _selectionLength - 1) && _selectionLength != 0; + using(Brush byteBrush = new SolidBrush(byteColor)) { + if(isSelectedByte && isKeyInterpreterActive) { + PaintHexStringSelected(g, b, byteBrush, selBrushBack, gridPoint); + } else { + PaintHexString(g, b, byteBrush, gridPoint); + } } } }