2022-06-18 18:04:24 +00:00
|
|
|
using System;
|
2019-02-17 22:51:35 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
2019-02-09 21:15:37 +00:00
|
|
|
using System.Drawing;
|
2019-02-17 22:51:35 +00:00
|
|
|
using PKHeX.Core;
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.WinForms;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Drawing Configuration for painting and updating controls
|
|
|
|
/// </summary>
|
|
|
|
[Serializable]
|
|
|
|
public sealed class DrawConfig : IDisposable
|
2019-02-09 21:15:37 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
private const string PKM = "Pokémon Editor";
|
|
|
|
private const string Moves = "Moves";
|
|
|
|
private const string Hovering = "Hovering";
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Hovering), Description("Hovering over a PKM color 1.")]
|
|
|
|
public Color GlowInitial { get; set; } = Color.White;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Hovering), Description("Hovering over a PKM color 2.")]
|
|
|
|
public Color GlowFinal { get; set; } = Color.LightSkyBlue;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
#region PKM
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Background color of a ComboBox when the selected item is not valid.")]
|
|
|
|
public Color InvalidSelection { get; set; } = Color.DarkSalmon;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Default colored marking.")]
|
|
|
|
public Color MarkDefault { get; set; } = Color.Black;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Blue colored marking.")]
|
|
|
|
public Color MarkBlue { get; set; } = Color.FromArgb(000, 191, 255);
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Pink colored marking.")]
|
|
|
|
public Color MarkPink { get; set; } = Color.FromArgb(255, 117, 179);
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Male gender color.")]
|
|
|
|
public Color Male { get; set; } = Color.Blue;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Female gender color.")]
|
|
|
|
public Color Female { get; set; } = Color.Red;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Shiny star when using unicode characters.")]
|
|
|
|
public string ShinyUnicode { get; set; } = "☆";
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(PKM), Description("Shiny star when not using unicode characters.")]
|
|
|
|
public string ShinyDefault { get; set; } = "*";
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
#endregion
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
#region Moves
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Moves), Description("Legal move choice background color.")]
|
|
|
|
public Color BackLegal { get; set; } = Color.FromArgb(200, 255, 200);
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Moves), Description("Legal move choice text color.")]
|
|
|
|
public Color TextColor { get; set; } = SystemColors.WindowText;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Moves), Description("Illegal Legal move choice background color.")]
|
|
|
|
public Color BackColor { get; set; } = SystemColors.Window;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Moves), Description("Highlighted move choice background color.")]
|
|
|
|
public Color BackHighlighted { get; set; } = SystemColors.Highlight;
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[Category(Moves), Description("Highlighted move choice text color.")]
|
|
|
|
public Color TextHighlighted { get; set; } = SystemColors.HighlightText;
|
2019-02-17 22:51:35 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
#endregion
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public DrawConfig() => LoadBrushes();
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public Color GetGenderColor(int gender) => gender switch
|
|
|
|
{
|
|
|
|
0 => Male,
|
|
|
|
1 => Female,
|
|
|
|
_ => TextColor,
|
|
|
|
};
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public bool GetMarkingColor(int markval, out Color c)
|
|
|
|
{
|
|
|
|
switch (markval)
|
2019-02-09 21:15:37 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
case 1: c = MarkBlue; return true;
|
|
|
|
case 2: c = MarkPink; return true;
|
|
|
|
default: c = MarkDefault; return false; // recolor not required
|
2019-02-09 21:15:37 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public Color GetText(bool highlight) => highlight ? TextHighlighted : TextColor;
|
|
|
|
public Color GetBackground(bool legal, bool highlight) => highlight ? BackHighlighted : (legal ? BackLegal : BackColor);
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
[NonSerialized]
|
|
|
|
public readonly BrushSet Brushes = new();
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void LoadBrushes()
|
|
|
|
{
|
|
|
|
Brushes.BackLegal = new SolidBrush(BackLegal);
|
|
|
|
Brushes.Text = new SolidBrush(TextColor);
|
|
|
|
Brushes.BackDefault = new SolidBrush(BackColor);
|
|
|
|
Brushes.TextHighlighted = new SolidBrush(TextHighlighted);
|
|
|
|
Brushes.BackHighlighted = new SolidBrush(BackHighlighted);
|
|
|
|
}
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void Dispose() => Brushes.Dispose();
|
2019-02-09 21:15:37 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
var props = ReflectUtil.GetAllPropertyInfoCanWritePublic(typeof(DrawConfig));
|
|
|
|
var lines = new List<string>();
|
|
|
|
foreach (var p in props)
|
2019-02-17 22:51:35 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
if (p.PropertyType == typeof(BrushSet))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
var name = p.Name;
|
|
|
|
var value = p.PropertyType == typeof(Color) ? ((Color)p.GetValue(this)!).ToArgb() : p.GetValue(this);
|
|
|
|
lines.Add($"{name}\t{value}");
|
2019-02-17 22:51:35 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
return string.Join("\n", lines);
|
2019-02-09 21:15:37 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|
2019-10-26 19:58:55 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public sealed class BrushSet : IDisposable
|
|
|
|
{
|
|
|
|
public Brush Text { get; set; } = Brushes.Black;
|
|
|
|
public Brush BackLegal { get; set; } = Brushes.DarkSeaGreen;
|
|
|
|
public Brush BackDefault { get; set; } = Brushes.White;
|
|
|
|
public Brush TextHighlighted { get; set; } = Brushes.White;
|
|
|
|
public Brush BackHighlighted { get; set; } = Brushes.Blue;
|
2019-10-26 19:58:55 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public Brush GetText(bool highlight) => highlight ? TextHighlighted : Text;
|
|
|
|
public Brush GetBackground(bool legal, bool highlight) => highlight ? BackHighlighted : (legal ? BackLegal : BackDefault);
|
2019-10-26 19:58:55 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
Text.Dispose();
|
|
|
|
BackLegal.Dispose();
|
|
|
|
BackDefault.Dispose();
|
|
|
|
TextHighlighted.Dispose();
|
|
|
|
BackHighlighted.Dispose();
|
2019-10-26 19:58:55 +00:00
|
|
|
}
|
2019-02-09 21:15:37 +00:00
|
|
|
}
|