Files
ReLibreHardwareMonitor/LibreHardwareMonitor/UI/Themes/ThemedToolStripRenderer.cs
T
Michael Rogers 2e207a4523 Add theme and plot thickness options (#847)
* Add theme and plot thickness options

* Cleanup

* Fixed themes, and made it so the plot colors are updated when the theme is changed

* I think supporting themes beyond dark, light, and black is unecessary for the time being.

* recall theme from settings before instantiating plot

* Check for null setting

* committing to merge

* Fix

* Cleanup

* Cleanup

* Fix from comments. Thank you kamkie!

* Fixing last UI bugs

* Fix windowed plot not theming on relaunch, change theme, show plot
2024-07-31 16:42:22 +02:00

72 lines
2.8 KiB
C#

using System.Drawing;
using System.Windows.Forms;
namespace LibreHardwareMonitor.UI.Themes
{
public class ThemedToolStripRenderer : ToolStripRenderer
{
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
{
if (e.Item is not ToolStripSeparator)
{
base.OnRenderSeparator(e);
return;
}
Rectangle bounds = new(Point.Empty, e.Item.Size);
using (Brush brush = new SolidBrush(Theme.Current.MenuBackgroundColor))
e.Graphics.FillRectangle(brush, bounds);
}
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e)
{
e.ArrowColor = e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor;
base.OnRenderArrow(e);
}
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
using (Pen pen = new Pen(e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor))
{
int x = 10;
int y = 6;
e.Graphics.DrawLine(pen, x, y + 3, x + 2, y + 5);
e.Graphics.DrawLine(pen, x + 2, y + 5, x + 6, y + 1);
e.Graphics.DrawLine(pen, x, y + 4, x + 2, y + 6);
e.Graphics.DrawLine(pen, x + 2, y + 6, x + 6, y + 2);
}
}
protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e)
{
e.TextColor = e.Item.Selected ? Theme.Current.MenuSelectedForegroundColor : Theme.Current.MenuForegroundColor;
base.OnRenderItemText(e);
}
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)
{
if (e.ToolStrip.Parent is not Form)
{
Rectangle bounds = new(Point.Empty, new Size(e.ToolStrip.Width - 1, e.ToolStrip.Height - 1));
using (Pen pen = new Pen(Theme.Current.MenuBorderColor))
e.Graphics.DrawRectangle(pen, bounds);
}
}
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e)
{
Rectangle bounds = new(Point.Empty, e.ToolStrip.Size);
using (Brush brush = new SolidBrush(Theme.Current.MenuBackgroundColor))
e.Graphics.FillRectangle(brush, bounds);
}
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
{
Rectangle bounds = new(Point.Empty, e.Item.Size);
using (Brush brush = new SolidBrush(e.Item.Selected ? Theme.Current.MenuSelectedBackgroundColor : Theme.Current.MenuBackgroundColor))
e.Graphics.FillRectangle(brush, bounds);
}
}
}