first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibreHardwareMonitor.UI.Themes
|
||||
{
|
||||
public class BlackTheme : LightTheme
|
||||
{
|
||||
private readonly Color[] _plotColorPalette;
|
||||
public override Color ForegroundColor => Color.FromArgb(218, 218, 218);
|
||||
public override Color BackgroundColor => Color.FromArgb(0, 0, 0);
|
||||
public override Color HyperlinkColor => Color.FromArgb(144, 220, 232);
|
||||
public override Color SelectedForegroundColor => ForegroundColor;
|
||||
public override Color SelectedBackgroundColor => ColorTranslator.FromHtml("#090A17");
|
||||
public override Color LineColor => ColorTranslator.FromHtml("#070A12");
|
||||
public override Color StrongLineColor => ColorTranslator.FromHtml("#091217");
|
||||
public override Color[] PlotColorPalette => _plotColorPalette;
|
||||
public override Color PlotGridMajorColor => Color.FromArgb(73, 73, 73);
|
||||
public override Color PlotGridMinorColor => Color.FromArgb(33, 33, 33);
|
||||
public override bool WindowTitlebarFallbackToImmersiveDarkMode => true;
|
||||
|
||||
public BlackTheme() : base("black", "Black")
|
||||
{
|
||||
string[] colors = {
|
||||
"#FF2525",
|
||||
"#1200FF",
|
||||
"#00FF5B",
|
||||
"#FFE53B",
|
||||
"#00FFFF",
|
||||
"#FF0A6C",
|
||||
"#2D27FF",
|
||||
"#FF2CDF",
|
||||
"#00E1FD",
|
||||
"#0A5057"
|
||||
};
|
||||
|
||||
_plotColorPalette = colors.Select(color => ColorTranslator.FromHtml(color)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibreHardwareMonitor.UI.Themes
|
||||
{
|
||||
public class DarkTheme : LightTheme
|
||||
{
|
||||
private readonly Color[] _plotColorPalette;
|
||||
public override Color ForegroundColor => Color.FromArgb(233, 233, 233);
|
||||
public override Color BackgroundColor => Color.FromArgb(30, 30, 30);
|
||||
public override Color HyperlinkColor => Color.FromArgb(144, 220, 232);
|
||||
public override Color SelectedForegroundColor => ForegroundColor;
|
||||
public override Color SelectedBackgroundColor => Color.FromArgb(45, 45, 45);
|
||||
public override Color LineColor => Color.FromArgb(38, 38, 38);
|
||||
public override Color StrongLineColor => Color.FromArgb(53, 53, 53);
|
||||
public override Color[] PlotColorPalette => _plotColorPalette;
|
||||
public override Color PlotGridMajorColor => Color.FromArgb(93, 93, 93);
|
||||
public override Color PlotGridMinorColor => Color.FromArgb(53, 53, 53);
|
||||
public override bool WindowTitlebarFallbackToImmersiveDarkMode => true;
|
||||
|
||||
public DarkTheme() : base("dark", "Dark")
|
||||
{
|
||||
string[] colors = {
|
||||
"#F07178",
|
||||
"#82AAFF",
|
||||
"#C3E88D",
|
||||
"#FFCB6B",
|
||||
"#009688",
|
||||
"#89DDF3",
|
||||
"#FFE082",
|
||||
"#7986CB",
|
||||
"#C792EA",
|
||||
"#FF5370",
|
||||
"#73d1c8",
|
||||
"#F78C6A"
|
||||
};
|
||||
|
||||
_plotColorPalette = colors.Select(color => ColorTranslator.FromHtml(color)).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace LibreHardwareMonitor.UI.Themes
|
||||
{
|
||||
public class LightTheme : Theme
|
||||
{
|
||||
private readonly Color[] _plotColorPalette = new Color[] {
|
||||
Color.Blue,
|
||||
Color.OrangeRed,
|
||||
Color.Green,
|
||||
Color.LightSeaGreen,
|
||||
Color.Goldenrod,
|
||||
Color.DarkViolet,
|
||||
Color.YellowGreen,
|
||||
Color.SaddleBrown,
|
||||
Color.RoyalBlue,
|
||||
Color.DeepPink,
|
||||
Color.MediumSeaGreen,
|
||||
Color.Olive,
|
||||
Color.Firebrick
|
||||
};
|
||||
|
||||
public LightTheme(string id, string displayName) : base(id, displayName) { }
|
||||
public override Color ForegroundColor => Color.FromArgb(0, 0, 0);
|
||||
public override Color BackgroundColor => Color.FromArgb(255, 255, 255);
|
||||
public override Color HyperlinkColor => Color.FromArgb(0, 0, 255);
|
||||
public override Color SelectedForegroundColor => ForegroundColor;
|
||||
public override Color SelectedBackgroundColor => Color.FromArgb(240, 240, 240);
|
||||
public override Color LineColor => Color.FromArgb(247, 247, 247);
|
||||
public override Color StrongLineColor => Color.FromArgb(209, 209, 209);
|
||||
public override Color[] PlotColorPalette => _plotColorPalette;
|
||||
public override Color PlotGridMajorColor => Color.FromArgb(192, 192, 192);
|
||||
public override Color PlotGridMinorColor => Color.FromArgb(232, 232, 232);
|
||||
public override bool WindowTitlebarFallbackToImmersiveDarkMode => false;
|
||||
|
||||
public LightTheme() : base("light", "Light") { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LibreHardwareMonitor.UI.Themes
|
||||
{
|
||||
public class ThemedHScrollIndicator : Control
|
||||
{
|
||||
private readonly HScrollBar _scrollbar;
|
||||
private int _startValue = 0;
|
||||
private int _startPos = 0;
|
||||
private bool _isScrolling = false;
|
||||
|
||||
public static void AddToControl(Control control)
|
||||
{
|
||||
foreach (Control child in control.Controls)
|
||||
{
|
||||
if (child is HScrollBar scrollbar)
|
||||
{
|
||||
control.Controls.Add(new ThemedHScrollIndicator(scrollbar));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ThemedHScrollIndicator(HScrollBar scrollBar)
|
||||
{
|
||||
_scrollbar = scrollBar;
|
||||
|
||||
Height = 8;
|
||||
SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
Left = 0;
|
||||
Top = scrollBar.Parent.Height - Height;
|
||||
Size = new Size(scrollBar.Parent.Width, Height);
|
||||
Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom;
|
||||
Visible = scrollBar.Visible;
|
||||
|
||||
scrollBar.VisibleChanged += (s, e) => Visible = (s as ScrollBar).Visible;
|
||||
scrollBar.Scroll += (s, e) => Invalidate();
|
||||
scrollBar.ValueChanged += (s, e) => Invalidate();
|
||||
|
||||
scrollBar.Height = 0;
|
||||
this.MouseDown += OnMouseDown;
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_isScrolling)
|
||||
return;
|
||||
|
||||
_isScrolling = true;
|
||||
|
||||
//note: this.Capture is true when the control is clicked, no need to handle this
|
||||
|
||||
_startPos = e.X;
|
||||
_startValue = _scrollbar.Value;
|
||||
|
||||
this.MouseUp += OnMouseUp;
|
||||
this.MouseMove += OnMouseMove;
|
||||
}
|
||||
|
||||
private void OnMouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
_isScrolling = false;
|
||||
this.MouseUp -= OnMouseUp;
|
||||
this.MouseMove -= OnMouseMove;
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_isScrolling)
|
||||
return;
|
||||
|
||||
//pixel to range scaling:
|
||||
double totalRange = _scrollbar.Maximum - _scrollbar.Minimum;
|
||||
|
||||
if (totalRange <= 0)
|
||||
return;
|
||||
|
||||
double scaleToPercent = totalRange / Bounds.Width;
|
||||
double scrollValue = _startValue + (e.X - _startPos) * scaleToPercent;
|
||||
|
||||
if (scrollValue < _scrollbar.Minimum)
|
||||
scrollValue = _scrollbar.Minimum;
|
||||
|
||||
if (scrollValue > (_scrollbar.Maximum - _scrollbar.LargeChange))
|
||||
scrollValue = _scrollbar.Maximum - _scrollbar.LargeChange;
|
||||
|
||||
_scrollbar.Value = (int)scrollValue;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarBackground))
|
||||
g.FillRectangle(brush, new Rectangle(0, 0, Bounds.Width, Bounds.Height));
|
||||
|
||||
int width = Bounds.Width;
|
||||
int range = _scrollbar.Maximum - _scrollbar.Minimum;
|
||||
|
||||
if (range > 0)
|
||||
{
|
||||
int start = width * (_scrollbar.Value - _scrollbar.Minimum) / range;
|
||||
int end = width * (_scrollbar.Value - _scrollbar.Minimum + _scrollbar.LargeChange) / range;
|
||||
using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarTrack))
|
||||
g.FillRectangle(brush, new Rectangle(start, 2, end - start, Bounds.Height - 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LibreHardwareMonitor.UI.Themes
|
||||
{
|
||||
public class ThemedVScrollIndicator : Control
|
||||
{
|
||||
private readonly VScrollBar _scrollbar;
|
||||
private int _startValue = 0;
|
||||
private int _startPos = 0;
|
||||
private bool _isScrolling = false;
|
||||
|
||||
public static void AddToControl(Control control)
|
||||
{
|
||||
foreach (Control child in control.Controls)
|
||||
{
|
||||
if (child is VScrollBar scrollbar)
|
||||
{
|
||||
control.Controls.Add(new ThemedVScrollIndicator(scrollbar));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ThemedVScrollIndicator(VScrollBar scrollBar)
|
||||
{
|
||||
_scrollbar = scrollBar;
|
||||
|
||||
Width = 8;
|
||||
SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
Left = scrollBar.Parent.Width - Width;
|
||||
Top = 0;
|
||||
Size = new Size(Width, scrollBar.Parent.Height);
|
||||
Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
|
||||
Visible = scrollBar.Visible;
|
||||
|
||||
scrollBar.VisibleChanged += (s, e) => Visible = (s as ScrollBar).Visible;
|
||||
scrollBar.Scroll += (s, e) => Invalidate();
|
||||
scrollBar.ValueChanged += (s, e) => Invalidate();
|
||||
|
||||
scrollBar.Width = 0;
|
||||
this.MouseDown += OnMouseDown;
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_isScrolling)
|
||||
return;
|
||||
|
||||
_isScrolling = true;
|
||||
|
||||
//note: this.Capture is true when the control is clicked, no need to handle this
|
||||
|
||||
_startPos = e.Y;
|
||||
_startValue = _scrollbar.Value;
|
||||
|
||||
this.MouseUp += OnMouseUp;
|
||||
this.MouseMove += OnMouseMove;
|
||||
}
|
||||
|
||||
private void OnMouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
_isScrolling = false;
|
||||
this.MouseUp -= OnMouseUp;
|
||||
this.MouseMove -= OnMouseMove;
|
||||
}
|
||||
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_isScrolling)
|
||||
return;
|
||||
|
||||
//pixel to range scaling:
|
||||
double totalRange = _scrollbar.Maximum - _scrollbar.Minimum;
|
||||
|
||||
if (totalRange <= 0)
|
||||
return;
|
||||
|
||||
double scaleToPercent = totalRange / Bounds.Height;
|
||||
double scrollValue = _startValue + (e.Y - _startPos) * scaleToPercent;
|
||||
|
||||
if (scrollValue < _scrollbar.Minimum)
|
||||
scrollValue = _scrollbar.Minimum;
|
||||
|
||||
if (scrollValue > (_scrollbar.Maximum - _scrollbar.LargeChange))
|
||||
scrollValue = _scrollbar.Maximum - _scrollbar.LargeChange;
|
||||
|
||||
_scrollbar.Value = (int)scrollValue;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarBackground))
|
||||
g.FillRectangle(brush, new Rectangle(0, 0, Bounds.Width, Bounds.Height));
|
||||
|
||||
int height = Bounds.Height;
|
||||
int range = _scrollbar.Maximum - _scrollbar.Minimum;
|
||||
|
||||
if (range > 0)
|
||||
{
|
||||
int start = height * (_scrollbar.Value - _scrollbar.Minimum) / range;
|
||||
int end = height * (_scrollbar.Value - _scrollbar.Minimum + _scrollbar.LargeChange) / range;
|
||||
using (SolidBrush brush = new SolidBrush(Theme.Current.ScrollbarTrack))
|
||||
g.FillRectangle(brush, new Rectangle(2, start, Bounds.Width - 4, end - start));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user