Use `Brushes.*` instead of creating new ones from `Color` constants

This commit is contained in:
YoshiRulz 2024-09-26 08:31:58 +10:00 committed by James Groom
parent f4298d74f4
commit 0313e1c119
4 changed files with 12 additions and 5 deletions

View File

@ -8,8 +8,10 @@ namespace BizHawk.Client.EmuHawk.CustomControls
private readonly Pen _currentPen = Pens.Black.GetMutableCopy();
private readonly SolidBrush _currentBrush = new SolidBrush(Color.Black);
private readonly SolidBrush _currentStringBrush = new SolidBrush(Color.Black);
private readonly SolidBrush _currentBrush = ((SolidBrush) Brushes.Black).GetMutableCopy();
private readonly SolidBrush _currentStringBrush = ((SolidBrush) Brushes.Black).GetMutableCopy();
private Font _currentFont;
private bool _rotateString;

View File

@ -73,8 +73,8 @@ namespace BizHawk.Client.EmuHawk
}
else
{
using (var sb = new SolidBrush(Color.Black))
{
var sb = Brushes.Black;
g.FillRectangle(sb, _bmp.Width, 0, Width - _bmp.Width, Height);
g.FillRectangle(sb, 0, _bmp.Height, _bmp.Width, Height - _bmp.Height);
}

View File

@ -6,6 +6,10 @@ namespace BizHawk.Client.EmuHawk
{
public static class DrawingExtensions
{
public static T GetMutableCopy<T>(this T b)
where T : Brush
=> (T) b.Clone();
public static Pen GetMutableCopy(this Pen p)
=> (Pen) p.Clone();
}

View File

@ -5,8 +5,9 @@ namespace BizHawk.Client.EmuHawk
{
public sealed class PaletteViewer : Control
{
private readonly SolidBrush BgPalettesBrush = new SolidBrush(Color.Black);
private readonly SolidBrush SpritePalettesBrush = new SolidBrush(Color.Black);
private readonly SolidBrush BgPalettesBrush = ((SolidBrush) Brushes.Black).GetMutableCopy();
private readonly SolidBrush SpritePalettesBrush = ((SolidBrush) Brushes.Black).GetMutableCopy();
public class Palette
{