HexEditor - some code tidy

This commit is contained in:
Asnivor 2024-10-25 17:23:15 +01:00
parent 7ed690679a
commit f7bc67f393
1 changed files with 13 additions and 13 deletions

View File

@ -86,10 +86,8 @@ namespace BizHawk.WinForms.Controls
color = this.ForeColor; color = this.ForeColor;
break; break;
} }
using (Brush brush = new SolidBrush(color))
{ DrawString(word, font, point, color);
e.Graphics.DrawString(word, font, brush, point);
}
point.X += size.Width + e.Graphics.MeasureString(gap.ToString(), font).Width + spacingHexModifier; point.X += size.Width + e.Graphics.MeasureString(gap.ToString(), font).Width + spacingHexModifier;
} }
@ -98,10 +96,8 @@ namespace BizHawk.WinForms.Controls
string div = "|"; string div = "|";
point.X -= spacingPreDivider; point.X -= spacingPreDivider;
SizeF sizeDiv = e.Graphics.MeasureString(div, font); SizeF sizeDiv = e.Graphics.MeasureString(div, font);
using (Brush brush = new SolidBrush(this.ForeColor))
{ DrawString(div, font, point, this.ForeColor);
e.Graphics.DrawString(div, font, brush, point);
}
point.X += e.Graphics.MeasureString(gap.ToString(), font).Width + spacingPostDividerModifier; point.X += e.Graphics.MeasureString(gap.ToString(), font).Width + spacingPostDividerModifier;
@ -110,11 +106,7 @@ namespace BizHawk.WinForms.Controls
foreach (var c in chars) foreach (var c in chars)
{ {
string str = c.ToString(); string str = c.ToString();
DrawString(str, font, point, this.ForeColor);
using (Brush brush = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(str, font, brush, point);
}
// fixed size // fixed size
point.X += spacingAscii; point.X += spacingAscii;
@ -123,6 +115,14 @@ namespace BizHawk.WinForms.Controls
point.X = 0; point.X = 0;
point.Y += e.Graphics.MeasureString(line, font).Height + spacingLineModifier; point.Y += e.Graphics.MeasureString(line, font).Height + spacingLineModifier;
} }
void DrawString(string s, Font f, PointF p, Color color)
{
using (Brush brush = new SolidBrush(color))
{
e.Graphics.DrawString(s, f, brush, p);
}
}
} }
} }
} }