Dark Theme

This commit is contained in:
seerge
2023-03-20 14:32:45 +01:00
parent 4d347df45c
commit 7065ba8661
8 changed files with 529 additions and 243 deletions

133
app/ControlHelper.cs Normal file
View File

@@ -0,0 +1,133 @@
using System.Drawing.Drawing2D;
using System.Windows.Forms.DataVisualization.Charting;
using CustomControls;
public static class ControlHelper
{
static bool _invert = false;
static float _scale = 1;
static Color formBack = Color.FromArgb(255, 35, 35, 35);
static Color backMain = Color.FromArgb(255, 50, 50, 50);
static Color foreMain = Color.White;
static Color borderMain = Color.FromArgb(255, 50, 50, 50);
static Color buttonMain = Color.FromArgb(255, 100,100,100);
public static void Adjust(Control container, float baseScale = 2, bool invert = false)
{
_scale = GetDpiScale(container).Value / baseScale;
_invert = invert;
if (_invert)
{
container.BackColor = formBack;
container.ForeColor = foreMain;
}
AdjustControls(container.Controls);
}
private static void AdjustControls(Control.ControlCollection controls)
{
foreach (Control control in controls)
{
var button = control as Button;
if (button != null)
{
if (_invert)
{
button.BackColor = backMain;
button.ForeColor = foreMain;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderColor = borderMain;
}
if (button.Image is not null)
button.Image = AdjustImage(button.Image);
}
var pictureBox = control as PictureBox;
if (pictureBox != null)
{
if (pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = AdjustImage(pictureBox.BackgroundImage);
}
var combo = control as RComboBox;
if (combo != null && _invert)
{
combo.BackColor = borderMain;
combo.ForeColor = foreMain;
combo.BorderColor = borderMain;
combo.ButtonColor = buttonMain;
}
var chart = control as Chart;
if (chart != null && _invert)
{
chart.BackColor = backMain;
chart.ChartAreas[0].BackColor = backMain;
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreMain;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreMain;
chart.ChartAreas[0].AxisX.TitleForeColor = foreMain;
chart.ChartAreas[0].AxisY.TitleForeColor = foreMain;
chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = foreMain;
chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = foreMain;
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = foreMain;
chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = foreMain;
chart.ChartAreas[0].AxisX.LineColor = foreMain;
chart.ChartAreas[0].AxisY.LineColor = foreMain;
chart.Titles[0].ForeColor = foreMain;
}
AdjustControls(control.Controls);
}
}
public static Lazy<float> GetDpiScale(Control control)
{
return new Lazy<float>(() =>
{
using (var graphics = control.CreateGraphics())
return graphics.DpiX / 96.0f;
});
}
private static Image AdjustImage(Image image)
{
var newSize = new Size((int)(image.Width * _scale), (int)(image.Height * _scale));
var pic = new Bitmap(newSize.Width, newSize.Height);
using (var g = Graphics.FromImage(pic))
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(image, new Rectangle(new Point(), newSize));
}
if (_invert)
{
for (int y = 0; (y <= (pic.Height - 1)); y++)
{
for (int x = 0; (x <= (pic.Width - 1)); x++)
{
Color col = pic.GetPixel(x, y);
pic.SetPixel(x, y, Color.FromArgb(col.A, (255 - col.R), (255 - col.G), (255 - col.B)));
}
}
}
return pic;
}
}

290
app/CustomControls.cs Normal file
View File

@@ -0,0 +1,290 @@
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
namespace CustomControls
{
public class RForm : Form
{
protected static Color colorEco = Color.FromArgb(255, 6, 180, 138);
protected static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
protected static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
public static extern bool CheckSystemDarkModeStatus();
public static bool darkTheme = CheckSystemDarkModeStatus();
[DllImport("DwmApi")] //System.Runtime.InteropServices
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize);
protected override void OnHandleCreated(EventArgs e)
{
if (darkTheme && DwmSetWindowAttribute(Handle, 19, new[] { 1 }, 4) != 0)
DwmSetWindowAttribute(Handle, 20, new[] { 1 }, 4);
}
}
public class RComboBox : ComboBox
{
private Color borderColor = Color.Gray;
[DefaultValue(typeof(Color), "Gray")]
public Color BorderColor
{
get { return borderColor; }
set
{
if (borderColor != value)
{
borderColor = value;
Invalidate();
}
}
}
private Color buttonColor = Color.LightGray;
[DefaultValue(typeof(Color), "LightGray")]
public Color ButtonColor
{
get { return buttonColor; }
set
{
if (buttonColor != value)
{
buttonColor = value;
Invalidate();
}
}
}
private Color arrowColor = Color.Gray;
[DefaultValue(typeof(Color), "Gray")]
public Color ArrowColor
{
get { return arrowColor; }
set
{
if (arrowColor != value)
{
arrowColor = value;
Invalidate();
}
}
}
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple)
{
var clientRect = ClientRectangle;
var dropDownButtonWidth = SystemInformation.HorizontalScrollBarArrowWidth;
var outerBorder = new Rectangle(clientRect.Location,
new Size(clientRect.Width - 1, clientRect.Height - 1));
var innerBorder = new Rectangle(outerBorder.X + 1, outerBorder.Y + 1,
outerBorder.Width - dropDownButtonWidth - 2, outerBorder.Height - 2);
var innerInnerBorder = new Rectangle(innerBorder.X + 1, innerBorder.Y + 1,
innerBorder.Width - 2, innerBorder.Height - 2);
var dropDownRect = new Rectangle(innerBorder.Right + 1, innerBorder.Y,
dropDownButtonWidth, innerBorder.Height + 1);
if (RightToLeft == RightToLeft.Yes)
{
innerBorder.X = clientRect.Width - innerBorder.Right;
innerInnerBorder.X = clientRect.Width - innerInnerBorder.Right;
dropDownRect.X = clientRect.Width - dropDownRect.Right;
dropDownRect.Width += 1;
}
var innerBorderColor = Enabled ? BackColor : SystemColors.Control;
var outerBorderColor = Enabled ? BorderColor : SystemColors.ControlDark;
var buttonColor = Enabled ? ButtonColor : SystemColors.Control;
var middle = new Point(dropDownRect.Left + dropDownRect.Width / 2,
dropDownRect.Top + dropDownRect.Height / 2);
var arrow = new Point[]
{
new Point(middle.X - 3, middle.Y - 2),
new Point(middle.X + 4, middle.Y - 2),
new Point(middle.X, middle.Y + 2)
};
var ps = new PAINTSTRUCT();
bool shoulEndPaint = false;
IntPtr dc;
if (m.WParam == IntPtr.Zero)
{
dc = BeginPaint(Handle, ref ps);
m.WParam = dc;
shoulEndPaint = true;
}
else
{
dc = m.WParam;
}
var rgn = CreateRectRgn(innerInnerBorder.Left, innerInnerBorder.Top,
innerInnerBorder.Right, innerInnerBorder.Bottom);
SelectClipRgn(dc, rgn);
DefWndProc(ref m);
DeleteObject(rgn);
rgn = CreateRectRgn(clientRect.Left, clientRect.Top,
clientRect.Right, clientRect.Bottom);
SelectClipRgn(dc, rgn);
using (var g = Graphics.FromHdc(dc))
{
using (var b = new SolidBrush(buttonColor))
{
g.FillRectangle(b, dropDownRect);
}
using (var b = new SolidBrush(arrowColor))
{
g.FillPolygon(b, arrow);
}
using (var p = new Pen(innerBorderColor))
{
g.DrawRectangle(p, innerBorder);
g.DrawRectangle(p, innerInnerBorder);
}
using (var p = new Pen(outerBorderColor))
{
g.DrawRectangle(p, outerBorder);
}
}
if (shoulEndPaint)
EndPaint(Handle, ref ps);
DeleteObject(rgn);
}
else
base.WndProc(ref m);
}
private const int WM_PAINT = 0xF;
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int L, T, R, B;
}
[StructLayout(LayoutKind.Sequential)]
public struct PAINTSTRUCT
{
public IntPtr hdc;
public bool fErase;
public int rcPaint_left;
public int rcPaint_top;
public int rcPaint_right;
public int rcPaint_bottom;
public bool fRestore;
public bool fIncUpdate;
public int reserved1;
public int reserved2;
public int reserved3;
public int reserved4;
public int reserved5;
public int reserved6;
public int reserved7;
public int reserved8;
}
[DllImport("user32.dll")]
private static extern IntPtr BeginPaint(IntPtr hWnd,
[In, Out] ref PAINTSTRUCT lpPaint);
[DllImport("user32.dll")]
private static extern bool EndPaint(IntPtr hWnd, ref PAINTSTRUCT lpPaint);
[DllImport("gdi32.dll")]
public static extern int SelectClipRgn(IntPtr hDC, IntPtr hRgn);
[DllImport("user32.dll")]
public static extern int GetUpdateRgn(IntPtr hwnd, IntPtr hrgn, bool fErase);
public enum RegionFlags
{
ERROR = 0,
NULLREGION = 1,
SIMPLEREGION = 2,
COMPLEXREGION = 3,
}
[DllImport("gdi32.dll")]
internal static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")]
private static extern IntPtr CreateRectRgn(int x1, int y1, int x2, int y2);
}
public class RButton : Button
{
//Fields
private int borderSize = 5;
private int borderRadius = 3;
private bool activated = false;
private Color borderColor = Color.Transparent;
public Color BorderColor
{
get { return borderColor; }
set
{
borderColor = value;
}
}
public bool Activated
{
get { return activated; }
set
{
if (activated != value)
this.Invalidate();
activated = value;
}
}
public RButton()
{
this.FlatStyle = FlatStyle.Flat;
this.FlatAppearance.BorderSize = 0;
}
private GraphicsPath GetFigurePath(Rectangle rect, int radius)
{
GraphicsPath path = new GraphicsPath();
float curveSize = radius * 2F;
path.StartFigure();
path.AddArc(rect.X, rect.Y, curveSize, curveSize, 180, 90);
path.AddArc(rect.Right - curveSize, rect.Y, curveSize, curveSize, 270, 90);
path.AddArc(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize, 0, 90);
path.AddArc(rect.X, rect.Bottom - curveSize, curveSize, curveSize, 90, 90);
path.CloseFigure();
return path;
}
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
float ratio = pevent.Graphics.DpiX / 192.0f;
int border = (int)(ratio * borderSize);
Rectangle rectSurface = this.ClientRectangle;
Rectangle rectBorder = Rectangle.Inflate(rectSurface, -border, -border);
Color borderDrawColor = activated ? borderColor : Color.Transparent;
using (GraphicsPath pathSurface = GetFigurePath(rectSurface, borderRadius + border))
using (GraphicsPath pathBorder = GetFigurePath(rectBorder, borderRadius))
using (Pen penSurface = new Pen(this.Parent.BackColor, border))
using (Pen penBorder = new Pen(borderDrawColor, border))
{
penBorder.Alignment = PenAlignment.Outset;
pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
this.Region = new Region(pathSurface);
pevent.Graphics.DrawPath(penSurface, pathSurface);
pevent.Graphics.DrawPath(penBorder, pathBorder);
}
}
}
}

24
app/Fans.Designer.cs generated
View File

@@ -1,4 +1,7 @@
namespace GHelper
using CustomControls;
using System.Windows.Forms.DataVisualization.Charting;
namespace GHelper
{
partial class Fans
{
@@ -33,20 +36,20 @@
panelFans = new Panel();
labelTip = new Label();
labelBoost = new Label();
comboBoost = new ComboBox();
comboBoost = new RComboBox();
picturePerf = new PictureBox();
tableFanCharts = new TableLayoutPanel();
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
chartCPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
labelFans = new Label();
checkAuto = new CheckBox();
buttonReset = new Button();
buttonApply = new Button();
buttonReset = new RButton();
buttonApply = new RButton();
panelPower = new Panel();
pictureBox1 = new PictureBox();
labelPowerLimits = new Label();
checkApplyPower = new CheckBox();
buttonApplyPower = new Button();
buttonApplyPower = new RButton();
panelCPU = new Panel();
labelCPU = new Label();
label2 = new Label();
@@ -121,6 +124,7 @@
comboBoost.Name = "comboBoost";
comboBoost.Size = new Size(266, 40);
comboBoost.TabIndex = 38;
comboBoost.BorderColor = Color.White;
//
// picturePerf
//
@@ -163,6 +167,7 @@
chartGPU.Size = new Size(760, 476);
chartGPU.TabIndex = 17;
chartGPU.Text = "chart1";
chartGPU.Titles.Add("");
//
// chartCPU
//
@@ -175,6 +180,7 @@
chartCPU.Size = new Size(760, 476);
chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU";
chartCPU.Titles.Add("");
//
// labelFans
//
@@ -456,11 +462,11 @@
#endregion
private Panel panelFans;
private CheckBox checkAuto;
private Button buttonReset;
private Button buttonApply;
private RButton buttonReset;
private RButton buttonApply;
private Panel panelPower;
private CheckBox checkApplyPower;
private Button buttonApplyPower;
private RButton buttonApplyPower;
private Panel panelCPU;
private Label labelCPU;
private Label label2;
@@ -479,7 +485,7 @@
private Label labelFans;
private PictureBox picturePerf;
private PictureBox pictureBox1;
private ComboBox comboBoost;
private RComboBox comboBoost;
private Label labelBoost;
private Label labelTip;
}

View File

@@ -1,9 +1,10 @@
using System.Diagnostics;
using System.Windows.Forms.DataVisualization.Charting;
using CustomControls;
namespace GHelper
{
public partial class Fans : Form
public partial class Fans : RForm
{
DataPoint curPoint = null;
@@ -34,10 +35,7 @@ namespace GHelper
if (Program.settingsForm.perfName.Length > 0)
labelFans.Text = "Fan Profiles: " + Program.settingsForm.perfName;
if (chart.Titles.Count > 0)
chart.Titles[0].Text = title;
else
chart.Titles.Add(title);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.LightGray;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.LightGray;
@@ -85,6 +83,8 @@ namespace GHelper
InitializeComponent();
ControlHelper.Adjust(this, 2, darkTheme);
labelTip.Visible = false;
labelTip.BackColor = Color.Transparent;
@@ -93,8 +93,8 @@ namespace GHelper
seriesCPU = chartCPU.Series.Add("CPU");
seriesGPU = chartGPU.Series.Add("GPU");
seriesCPU.Color = Color.Blue;
seriesGPU.Color = Color.Red;
seriesCPU.Color = colorStandard;
seriesGPU.Color = colorTurbo;
chartCPU.MouseMove += ChartCPU_MouseMove;
chartCPU.MouseUp += ChartCPU_MouseUp;
@@ -245,12 +245,12 @@ namespace GHelper
{
if (applied)
{
labelApplied.ForeColor = Color.Blue;
labelApplied.ForeColor = colorStandard;
labelApplied.Text = "Applied";
}
else
{
labelApplied.ForeColor = Color.Red;
labelApplied.ForeColor = colorTurbo;
labelApplied.Text = "Not Applied";
}

View File

@@ -1,67 +0,0 @@
using System.Drawing.Drawing2D;
public static class HighDpiHelper
{
public static void AdjustControlImagesDpiScale(Control container, float baseScale = 2)
{
var dpiScale = GetDpiScale(container).Value;
AdjustControlImagesDpiScale(container.Controls, dpiScale / baseScale);
}
public static void AdjustButtonDpiScale(ButtonBase button, float dpiScale)
{
var image = button.Image;
if (image == null)
return;
button.Image = ScaleImage(image, dpiScale);
}
private static void AdjustControlImagesDpiScale(Control.ControlCollection controls, float dpiScale)
{
foreach (Control control in controls)
{
var button = control as ButtonBase;
if (button != null)
AdjustButtonDpiScale(button, dpiScale);
AdjustControlImagesDpiScale(control.Controls, dpiScale);
}
}
public static Lazy<float> GetDpiScale(Control control)
{
return new Lazy<float>(() =>
{
using (var graphics = control.CreateGraphics())
return graphics.DpiX / 96.0f;
});
}
private static Image ScaleImage(Image image, float dpiScale)
{
var newSize = ScaleSize(image.Size, dpiScale);
var newBitmap = new Bitmap(newSize.Width, newSize.Height);
using (var g = Graphics.FromImage(newBitmap))
{
// According to this blog post http://blogs.msdn.com/b/visualstudio/archive/2014/03/19/improving-high-dpi-support-for-visual-studio-2013.aspx
// NearestNeighbor is more adapted for 200% and 200%+ DPI
var interpolationMode = InterpolationMode.HighQualityBicubic;
if (dpiScale >= 2.0f)
interpolationMode = InterpolationMode.NearestNeighbor;
g.InterpolationMode = interpolationMode;
g.DrawImage(image, new Rectangle(new Point(), newSize));
}
return newBitmap;
}
private static Size ScaleSize(Size size, float scale)
{
return new Size((int)(size.Width * scale), (int)(size.Height * scale));
}
}

View File

@@ -1,85 +0,0 @@
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace CustomControls
{
public class RoundedButton : Button
{
//Fields
private int borderSize = 5;
private int borderRadius = 5;
private bool activated = false;
private Color borderColor = Color.Transparent;
public Color BorderColor
{
get { return borderColor; }
set
{
borderColor = value;
}
}
public bool Activated
{
get { return activated; }
set
{
if (activated != value)
this.Invalidate();
activated = value;
}
}
public RoundedButton()
{
this.FlatStyle = FlatStyle.Flat;
this.FlatAppearance.BorderSize = 0;
}
private GraphicsPath GetFigurePath(Rectangle rect, int radius)
{
GraphicsPath path = new GraphicsPath();
float curveSize = radius * 2F;
path.StartFigure();
path.AddArc(rect.X, rect.Y, curveSize, curveSize, 180, 90);
path.AddArc(rect.Right - curveSize, rect.Y, curveSize, curveSize, 270, 90);
path.AddArc(rect.Right - curveSize, rect.Bottom - curveSize, curveSize, curveSize, 0, 90);
path.AddArc(rect.X, rect.Bottom - curveSize, curveSize, curveSize, 90, 90);
path.CloseFigure();
return path;
}
protected override void OnPaint(PaintEventArgs pevent)
{
base.OnPaint(pevent);
float ratio = pevent.Graphics.DpiX / 192.0f;
int border = (int)(ratio * borderSize);
Rectangle rectSurface = this.ClientRectangle;
Rectangle rectBorder = Rectangle.Inflate(rectSurface, -border, -border);
Color borderDrawColor = activated ? borderColor : Color.Transparent;
using (GraphicsPath pathSurface = GetFigurePath(rectSurface, borderRadius+ border))
using (GraphicsPath pathBorder = GetFigurePath(rectBorder, borderRadius))
using (Pen penSurface = new Pen(this.Parent.BackColor, border))
using (Pen penBorder = new Pen(borderDrawColor, border))
{
penBorder.Alignment = PenAlignment.Outset;
pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
this.Region = new Region(pathSurface);
pevent.Graphics.DrawPath(penSurface, pathSurface);
pevent.Graphics.DrawPath(penBorder, pathBorder);
}
}
}
}

111
app/Settings.Designer.cs generated
View File

@@ -34,9 +34,9 @@ namespace GHelper
panelMatrix = new Panel();
checkMatrix = new CheckBox();
tableLayoutMatrix = new TableLayoutPanel();
comboMatrix = new ComboBox();
buttonMatrix = new Button();
comboMatrixRunning = new ComboBox();
comboMatrix = new RComboBox();
buttonMatrix = new RButton();
comboMatrixRunning = new RComboBox();
pictureMatrix = new PictureBox();
labelMatrix = new Label();
panelBattery = new Panel();
@@ -46,46 +46,46 @@ namespace GHelper
labelBatteryTitle = new Label();
trackBattery = new TrackBar();
panelFooter = new Panel();
buttonQuit = new Button();
buttonQuit = new RButton();
checkStartup = new CheckBox();
panelPerformance = new Panel();
picturePerf = new PictureBox();
labelPerf = new Label();
labelCPUFan = new Label();
tablePerf = new TableLayoutPanel();
buttonSilent = new RoundedButton();
buttonBalanced = new RoundedButton();
buttonTurbo = new RoundedButton();
buttonFans = new Button();
buttonSilent = new RButton();
buttonBalanced = new RButton();
buttonTurbo = new RButton();
buttonFans = new RButton();
panelGPU = new Panel();
labelTipGPU = new Label();
pictureGPU = new PictureBox();
labelGPU = new Label();
labelGPUFan = new Label();
tableGPU = new TableLayoutPanel();
buttonEco = new RoundedButton();
buttonStandard = new RoundedButton();
buttonOptimized = new RoundedButton();
buttonUltimate = new RoundedButton();
buttonEco = new RButton();
buttonStandard = new RButton();
buttonOptimized = new RButton();
buttonUltimate = new RButton();
panelScreen = new Panel();
labelTipScreen = new Label();
tableScreen = new TableLayoutPanel();
buttonScreenAuto = new RoundedButton();
button60Hz = new RoundedButton();
button120Hz = new RoundedButton();
buttonScreenAuto = new RButton();
button60Hz = new RButton();
button120Hz = new RButton();
pictureScreen = new PictureBox();
labelSreen = new Label();
panelKeyboard = new Panel();
tableLayoutKeyboard = new TableLayoutPanel();
buttonKeyboard = new Button();
comboKeyboard = new ComboBox();
buttonKeyboard = new RButton();
comboKeyboard = new RComboBox();
panelColor = new Panel();
pictureColor2 = new PictureBox();
pictureColor = new PictureBox();
buttonKeyboardColor = new Button();
buttonKeyboardColor = new RButton();
pictureKeyboard = new PictureBox();
labelKeyboard = new Label();
buttonMiniled = new RoundedButton();
buttonMiniled = new RButton();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
@@ -161,6 +161,8 @@ namespace GHelper
//
// comboMatrix
//
comboMatrix.BorderColor = Color.White;
comboMatrix.ButtonColor = SystemColors.ControlLight;
comboMatrix.Dock = DockStyle.Top;
comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrix.FormattingEnabled = true;
@@ -175,9 +177,12 @@ namespace GHelper
//
// buttonMatrix
//
buttonMatrix.BackColor = SystemColors.ButtonFace;
buttonMatrix.Activated = false;
buttonMatrix.BackColor = SystemColors.ControlLight;
buttonMatrix.BorderColor = Color.Transparent;
buttonMatrix.Dock = DockStyle.Top;
buttonMatrix.FlatAppearance.BorderSize = 0;
buttonMatrix.FlatStyle = FlatStyle.Flat;
buttonMatrix.Location = new Point(390, 8);
buttonMatrix.Margin = new Padding(4, 8, 4, 8);
buttonMatrix.Name = "buttonMatrix";
@@ -188,6 +193,8 @@ namespace GHelper
//
// comboMatrixRunning
//
comboMatrixRunning.BorderColor = Color.White;
comboMatrixRunning.ButtonColor = SystemColors.ControlLight;
comboMatrixRunning.Dock = DockStyle.Top;
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true;
@@ -315,8 +322,11 @@ namespace GHelper
//
// buttonQuit
//
buttonQuit.Activated = false;
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = SystemColors.ButtonFace;
buttonQuit.BackColor = SystemColors.ControlLight;
buttonQuit.BorderColor = Color.Transparent;
buttonQuit.FlatStyle = FlatStyle.Flat;
buttonQuit.Location = new Point(578, 16);
buttonQuit.Margin = new Padding(8, 4, 8, 4);
buttonQuit.Name = "buttonQuit";
@@ -472,9 +482,12 @@ namespace GHelper
//
// buttonFans
//
buttonFans.BackColor = SystemColors.ButtonFace;
buttonFans.Activated = false;
buttonFans.BackColor = SystemColors.ControlLight;
buttonFans.BorderColor = Color.Transparent;
buttonFans.Dock = DockStyle.Fill;
buttonFans.FlatAppearance.BorderSize = 0;
buttonFans.FlatStyle = FlatStyle.Flat;
buttonFans.Image = Properties.Resources.icons8_fan_48;
buttonFans.ImageAlign = ContentAlignment.BottomCenter;
buttonFans.Location = new Point(583, 4);
@@ -687,7 +700,6 @@ namespace GHelper
tableScreen.Controls.Add(buttonScreenAuto, 0, 0);
tableScreen.Controls.Add(button60Hz, 1, 0);
tableScreen.Controls.Add(button120Hz, 2, 0);
tableScreen.Location = new Point(16, 51);
tableScreen.Margin = new Padding(8, 4, 8, 4);
tableScreen.Name = "tableScreen";
@@ -723,7 +735,7 @@ namespace GHelper
button60Hz.FlatAppearance.BorderSize = 0;
button60Hz.FlatStyle = FlatStyle.Flat;
button60Hz.ForeColor = SystemColors.ControlText;
button60Hz.Location = new Point(390, 4);
button60Hz.Location = new Point(197, 4);
button60Hz.Margin = new Padding(4);
button60Hz.Name = "button60Hz";
button60Hz.Size = new Size(185, 72);
@@ -740,7 +752,7 @@ namespace GHelper
button120Hz.FlatAppearance.BorderSize = 0;
button120Hz.FlatStyle = FlatStyle.Flat;
button120Hz.ForeColor = SystemColors.ControlText;
button120Hz.Location = new Point(583, 4);
button120Hz.Location = new Point(390, 4);
button120Hz.Margin = new Padding(4);
button120Hz.Name = "button120Hz";
button120Hz.Size = new Size(185, 72);
@@ -808,9 +820,12 @@ namespace GHelper
//
// buttonKeyboard
//
buttonKeyboard.BackColor = SystemColors.ButtonFace;
buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.Dock = DockStyle.Top;
buttonKeyboard.FlatAppearance.BorderSize = 0;
buttonKeyboard.FlatStyle = FlatStyle.Flat;
buttonKeyboard.Location = new Point(390, 8);
buttonKeyboard.Margin = new Padding(4, 8, 4, 8);
buttonKeyboard.Name = "buttonKeyboard";
@@ -821,7 +836,10 @@ namespace GHelper
//
// comboKeyboard
//
comboKeyboard.BorderColor = Color.White;
comboKeyboard.ButtonColor = SystemColors.ControlLight;
comboKeyboard.Dock = DockStyle.Top;
comboKeyboard.FlatStyle = FlatStyle.Flat;
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboKeyboard.FormattingEnabled = true;
comboKeyboard.ItemHeight = 32;
@@ -868,10 +886,13 @@ namespace GHelper
//
// buttonKeyboardColor
//
buttonKeyboardColor.Activated = false;
buttonKeyboardColor.BackColor = SystemColors.ButtonHighlight;
buttonKeyboardColor.BorderColor = Color.Transparent;
buttonKeyboardColor.Dock = DockStyle.Top;
buttonKeyboardColor.FlatAppearance.BorderColor = Color.Red;
buttonKeyboardColor.FlatAppearance.BorderSize = 2;
buttonKeyboardColor.FlatStyle = FlatStyle.Flat;
buttonKeyboardColor.ForeColor = SystemColors.ControlText;
buttonKeyboardColor.Location = new Point(0, 0);
buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8);
@@ -991,50 +1012,50 @@ namespace GHelper
private Label labelBatteryTitle;
private TrackBar trackBattery;
private Panel panelFooter;
private Button buttonQuit;
private RButton buttonQuit;
private CheckBox checkStartup;
private Panel panelPerformance;
private PictureBox picturePerf;
private Label labelPerf;
private Label labelCPUFan;
private TableLayoutPanel tablePerf;
private RoundedButton buttonTurbo;
private RoundedButton buttonBalanced;
private RoundedButton buttonSilent;
private RButton buttonTurbo;
private RButton buttonBalanced;
private RButton buttonSilent;
private Panel panelGPU;
private PictureBox pictureGPU;
private Label labelGPU;
private Label labelGPUFan;
private TableLayoutPanel tableGPU;
private RoundedButton buttonUltimate;
private RoundedButton buttonStandard;
private RoundedButton buttonEco;
private RButton buttonUltimate;
private RButton buttonStandard;
private RButton buttonEco;
private Panel panelScreen;
private TableLayoutPanel tableScreen;
private RoundedButton buttonScreenAuto;
private RoundedButton button60Hz;
private RButton buttonScreenAuto;
private RButton button60Hz;
private PictureBox pictureScreen;
private Label labelSreen;
private Panel panelKeyboard;
private PictureBox pictureKeyboard;
private Label labelKeyboard;
private TableLayoutPanel tableLayoutMatrix;
private Button buttonMatrix;
private ComboBox comboMatrixRunning;
private ComboBox comboMatrix;
private RComboBox comboMatrixRunning;
private RComboBox comboMatrix;
private TableLayoutPanel tableLayoutKeyboard;
private Button buttonKeyboard;
private ComboBox comboKeyboard;
private RComboBox comboKeyboard;
private Panel panelColor;
private PictureBox pictureColor2;
private PictureBox pictureColor;
private Button buttonKeyboardColor;
private CheckBox checkMatrix;
private RoundedButton button120Hz;
private Button buttonFans;
private RoundedButton buttonOptimized;
private RButton button120Hz;
private RButton buttonOptimized;
private Label labelTipGPU;
private Label labelTipScreen;
private RoundedButton buttonMiniled;
private RButton buttonMiniled;
private RButton buttonMatrix;
private RButton buttonKeyboard;
private RButton buttonKeyboardColor;
private RButton buttonFans;
}
}

View File

@@ -1,4 +1,5 @@
using Starlight.AnimeMatrix;
using CustomControls;
using Starlight.AnimeMatrix;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Timers;
@@ -6,13 +7,9 @@ using System.Timers;
namespace GHelper
{
public partial class SettingsForm : Form
public partial class SettingsForm : RForm
{
static Color colorEco = Color.FromArgb(255, 6, 180, 138);
static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
static System.Timers.Timer aTimer = default!;
static System.Timers.Timer matrixTimer = default!;
@@ -29,7 +26,7 @@ namespace GHelper
{
InitializeComponent();
HighDpiHelper.AdjustControlImagesDpiScale(this, 2);
ControlHelper.Adjust(this, 2, darkTheme);
FormClosing += SettingsForm_FormClosing;
@@ -95,6 +92,7 @@ namespace GHelper
checkStartup.CheckedChanged += CheckStartup_CheckedChanged;
labelVersion.Click += LabelVersion_Click;
labelVersion.ForeColor = Color.FromArgb(128, Color.Gray);
buttonOptimized.MouseMove += ButtonOptimized_MouseHover;
buttonOptimized.MouseLeave += ButtonGPU_MouseLeave;
@@ -123,6 +121,7 @@ namespace GHelper
}
private void Button120Hz_MouseHover(object? sender, EventArgs e)
{
labelTipScreen.Text = "Max refresh rate + screen overdrive for lower latency";
@@ -668,27 +667,16 @@ namespace GHelper
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
if (frequency < 0)
{
button60Hz.Enabled = false;
button120Hz.Enabled = false;
buttonScreenAuto.Enabled = false;
labelSreen.Text = "Laptop Screen: Turned off";
button60Hz.BackColor = SystemColors.ControlLight;
button120Hz.BackColor = SystemColors.ControlLight;
buttonScreenAuto.BackColor = SystemColors.ControlLight;
}
else
{
button60Hz.Enabled = true;
button120Hz.Enabled = true;
buttonScreenAuto.Enabled = true;
button60Hz.BackColor = SystemColors.ControlLightLight;
button120Hz.BackColor = SystemColors.ControlLightLight;
buttonScreenAuto.BackColor = SystemColors.ControlLightLight;
labelSreen.Text = "Laptop Screen: " + frequency + "Hz" + ((overdrive == 1) ? " + Overdrive" : "");
}
bool screenEnabled = (frequency >= 0);
ButtonEnabled(button60Hz, screenEnabled);
ButtonEnabled(button120Hz, screenEnabled);
ButtonEnabled(buttonScreenAuto, screenEnabled);
ButtonEnabled(buttonMiniled, screenEnabled);
labelSreen.Text = screenEnabled
? "Laptop Screen: " + frequency + "Hz" + ((overdrive == 1) ? " + Overdrive" : "")
: "Laptop Screen: Turned off";
button60Hz.Activated = false;
button120Hz.Activated = false;
@@ -1220,7 +1208,7 @@ namespace GHelper
public void ButtonEnabled(Button but, bool enabled)
{
but.Enabled = enabled;
but.BackColor = enabled ? SystemColors.ControlLightLight : SystemColors.ControlLight;
but.BackColor = enabled ? Color.FromArgb(255, but.BackColor) : Color.FromArgb(100, but.BackColor);
}
public void SetStartupCheck(bool status)