2023-01-22 04:02:33 +00:00
|
|
|
using System.Drawing;
|
|
|
|
using System.Drawing.Drawing2D;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
|
2023-03-31 20:00:34 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Aligns tabs to the left side of the control with text displayed horizontally.
|
|
|
|
/// </summary>
|
2023-01-22 04:02:33 +00:00
|
|
|
public class VerticalTabControl : TabControl
|
|
|
|
{
|
|
|
|
public VerticalTabControl()
|
|
|
|
{
|
|
|
|
Alignment = TabAlignment.Right;
|
|
|
|
DrawMode = TabDrawMode.OwnerDrawFixed;
|
|
|
|
SizeMode = TabSizeMode.Fixed;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void OnDrawItem(DrawItemEventArgs e)
|
|
|
|
{
|
|
|
|
var index = e.Index;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
using var flags = new StringFormat
|
|
|
|
{
|
|
|
|
Alignment = StringAlignment.Center,
|
|
|
|
LineAlignment = StringAlignment.Center,
|
|
|
|
};
|
|
|
|
using var text = new SolidBrush(ForeColor);
|
|
|
|
var tab = TabPages[index];
|
|
|
|
graphics.DrawString(tab.Text, Font, text, bounds, flags);
|
|
|
|
base.OnDrawItem(e);
|
|
|
|
}
|
2023-01-29 03:23:43 +00:00
|
|
|
|
|
|
|
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
|
|
|
|
{
|
|
|
|
base.ScaleControl(factor, specified);
|
2023-02-02 00:55:38 +00:00
|
|
|
ItemSize = new((int)(ItemSize.Width * factor.Width), (int)(ItemSize.Height * factor.Height));
|
2023-01-29 03:23:43 +00:00
|
|
|
}
|
2023-01-22 04:02:33 +00:00
|
|
|
}
|
|
|
|
|
2023-03-31 20:00:34 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Specialized <see cref="VerticalTabControl"/> for displaying a <see cref="PKHeX.Core.PKM"/> editor tabs.
|
|
|
|
/// </summary>
|
2023-01-22 04:02:33 +00:00
|
|
|
public sealed class VerticalTabControlEntityEditor : VerticalTabControl
|
|
|
|
{
|
2023-03-31 20:00:34 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Tab stripe colors based on Contest Stats.
|
|
|
|
/// </summary>
|
2023-01-22 04:02:33 +00:00
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
protected override void OnDrawItem(DrawItemEventArgs e)
|
|
|
|
{
|
|
|
|
var index = e.Index;
|
|
|
|
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);
|
|
|
|
|
|
|
|
using var pipBrush = new SolidBrush(SelectedTags[index]);
|
|
|
|
var pip = GetTabRect(index) with { Width = bounds.Width / 8 };
|
|
|
|
graphics.FillRectangle(pipBrush, pip);
|
|
|
|
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
|
|
|
|
{
|
|
|
|
Alignment = StringAlignment.Center,
|
|
|
|
LineAlignment = StringAlignment.Center,
|
|
|
|
};
|
|
|
|
using var text = new SolidBrush(ForeColor);
|
|
|
|
var tab = TabPages[index];
|
|
|
|
graphics.DrawString(tab.Text, Font, text, bounds, flags);
|
|
|
|
}
|
|
|
|
}
|