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;
break;
}
using (Brush brush = new SolidBrush(color))
{
e.Graphics.DrawString(word, font, brush, point);
}
DrawString(word, font, point, color);
point.X += size.Width + e.Graphics.MeasureString(gap.ToString(), font).Width + spacingHexModifier;
}
@ -98,10 +96,8 @@ namespace BizHawk.WinForms.Controls
string div = "|";
point.X -= spacingPreDivider;
SizeF sizeDiv = e.Graphics.MeasureString(div, font);
using (Brush brush = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(div, font, brush, point);
}
DrawString(div, font, point, this.ForeColor);
point.X += e.Graphics.MeasureString(gap.ToString(), font).Width + spacingPostDividerModifier;
@ -110,11 +106,7 @@ namespace BizHawk.WinForms.Controls
foreach (var c in chars)
{
string str = c.ToString();
using (Brush brush = new SolidBrush(this.ForeColor))
{
e.Graphics.DrawString(str, font, brush, point);
}
DrawString(str, font, point, this.ForeColor);
// fixed size
point.X += spacingAscii;
@ -123,6 +115,14 @@ namespace BizHawk.WinForms.Controls
point.X = 0;
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);
}
}
}
}
}