diff --git a/PKHeX.Drawing.PokeSprite/Util/ContestColor.cs b/PKHeX.Drawing.PokeSprite/Util/ContestColor.cs new file mode 100644 index 000000000..a571b2d81 --- /dev/null +++ b/PKHeX.Drawing.PokeSprite/Util/ContestColor.cs @@ -0,0 +1,31 @@ +using System; +using System.Drawing; + +namespace PKHeX.Drawing.PokeSprite; + +/// +/// Utility class for getting the color of a contest category. +/// +public static class ContestColor +{ + public static Color Cool => Color.FromArgb(248, 152, 096); + public static Color Beauty => Color.FromArgb(128, 152, 248); + public static Color Cute => Color.FromArgb(248, 168, 208); + public static Color Clever => Color.FromArgb(112, 224, 112); + public static Color Tough => Color.FromArgb(248, 240, 056); + + /// + /// Retrieves a predefined color based on the specified index. + /// + /// The index of the color to retrieve. Valid values are 0 through 4. + /// Thrown if is less than 0 or greater than 4. + public static Color GetColor(int index) => index switch + { + 0 => Cool, + 1 => Beauty, + 2 => Cute, + 3 => Clever, + 4 => Tough, + _ => throw new ArgumentOutOfRangeException(nameof(index), index, null), + }; +} diff --git a/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs index f7392ec0a..3438e83e0 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/SizeCP.cs @@ -167,7 +167,7 @@ private void NUD_Scale_ValueChanged(object sender, EventArgs e) private void SetLabelColorHeightWeight(Control label) { if (scale is not null) - label.ForeColor = Color.Gray; // not indicative of actual size + label.ForeColor = SystemColors.ControlDark; // not indicative of actual size else label.ResetForeColor(); } diff --git a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs index 85f5e8c7e..a72d15fc9 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/VerticalTabControl.cs @@ -1,6 +1,7 @@ using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; +using PKHeX.Drawing.PokeSprite; namespace PKHeX.WinForms.Controls; @@ -24,15 +25,7 @@ protected override void OnDrawItem(DrawItemEventArgs e) var bounds = GetTabRect(index); var graphics = e.Graphics; - if (e.State == DrawItemState.Selected) - { - using var brush = new LinearGradientBrush(bounds, Color.White, Color.LightGray, 90f); - graphics.FillRectangle(brush, bounds); - } - else - { - e.DrawBackground(); - } + DrawBackground(e, bounds, graphics); using var flags = new StringFormat(); flags.Alignment = StringAlignment.Center; @@ -43,6 +36,19 @@ protected override void OnDrawItem(DrawItemEventArgs e) base.OnDrawItem(e); } + protected static void DrawBackground(DrawItemEventArgs e, Rectangle bounds, Graphics graphics) + { + if (e.State != DrawItemState.Selected) + { + e.DrawBackground(); + return; + } + + var (c1, c2) = (SystemColors.ControlLightLight, SystemColors.ScrollBar); + using var brush = new LinearGradientBrush(bounds, c1, c2, 90f); + graphics.FillRectangle(brush, bounds); + } + protected override void ScaleControl(SizeF factor, BoundsSpecified specified) { base.ScaleControl(factor, specified); @@ -60,12 +66,12 @@ public sealed class VerticalTabControlEntityEditor : VerticalTabControl /// private static readonly Color[] SelectedTags = [ - Color.FromArgb(248, 152, 096), - Color.FromArgb(128, 152, 248), - Color.FromArgb(248, 168, 208), - Color.FromArgb(112, 224, 112), - Color.FromArgb(248, 240, 056), - Color.RosyBrown, + ContestColor.Cool, // Main + ContestColor.Beauty, // Met + ContestColor.Cute, // Stats + ContestColor.Clever, // Moves + ContestColor.Tough, // Cosmetic + Color.RosyBrown, // OT ]; protected override void OnDrawItem(DrawItemEventArgs e) @@ -76,22 +82,17 @@ protected override void OnDrawItem(DrawItemEventArgs e) var bounds = GetTabRect(index); var graphics = e.Graphics; + DrawBackground(e, bounds, graphics); if (e.State == DrawItemState.Selected) { - var (c1, c2) = (SystemColors.ControlLightLight, SystemColors.ScrollBar); - using var brush = new LinearGradientBrush(bounds, c1, c2, 90f); - graphics.FillRectangle(brush, bounds); - + // draw colored pip on the left side of the tab using var pipBrush = new SolidBrush(SelectedTags[index]); var pip = GetTabRect(index) with { Width = bounds.Width / 8 }; graphics.FillRectangle(pipBrush, pip); + + // shift text to the right to avoid pip overlap bounds = bounds with { Width = bounds.Width - pip.Width, X = bounds.X + pip.Width }; } - else - { - // no need to shift text - e.DrawBackground(); - } using var flags = new StringFormat(); flags.Alignment = StringAlignment.Center; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs index 46178d86f..a1031fd7b 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs @@ -4,6 +4,7 @@ using System.Text; using System.Windows.Forms; using PKHeX.Core; +using PKHeX.Drawing.PokeSprite; using static System.Buffers.Binary.BinaryPrimitives; namespace PKHeX.WinForms; @@ -651,14 +652,7 @@ private void LoadPainting(int index) PaintingIndex = index; - NUD_Painting.BackColor = index switch - { - 0 => Color.FromArgb(248, 152, 096), - 1 => Color.FromArgb(128, 152, 248), - 2 => Color.FromArgb(248, 168, 208), - 3 => Color.FromArgb(112, 224, 112), - _ => Color.FromArgb(248, 240, 056), - }; + NUD_Painting.BackColor = ContestColor.GetColor(index); } private void SavePainting(int index)