mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
UI tweaks
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
using System;
|
||||
using CustomControls;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using CustomControls;
|
||||
|
||||
public static class ControlHelper
|
||||
{
|
||||
|
||||
static bool _invert = false;
|
||||
static bool _darkTheme = false;
|
||||
|
||||
static float _scale = 1;
|
||||
|
||||
static Color formBack;
|
||||
@@ -17,19 +14,19 @@ public static class ControlHelper
|
||||
static Color borderMain;
|
||||
static Color buttonMain;
|
||||
|
||||
public static void Adjust(RForm container, float baseScale = 2)
|
||||
public static void Adjust(RForm container, float baseScale = 2, bool invert = false)
|
||||
{
|
||||
_scale = GetDpiScale(container).Value / baseScale;
|
||||
|
||||
|
||||
if (container.DarkTheme)
|
||||
if (container.darkTheme)
|
||||
{
|
||||
formBack = Color.FromArgb(255, 35, 35, 35);
|
||||
backMain = Color.FromArgb(255, 50, 50, 50);
|
||||
foreMain = Color.White;
|
||||
borderMain = Color.FromArgb(255, 50, 50, 50);
|
||||
buttonMain = Color.FromArgb(255, 100, 100, 100);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
formBack = SystemColors.Control;
|
||||
backMain = SystemColors.ControlLightLight;
|
||||
@@ -41,7 +38,7 @@ public static class ControlHelper
|
||||
container.BackColor = formBack;
|
||||
container.ForeColor = foreMain;
|
||||
|
||||
_invert = container.invert;
|
||||
_invert = invert;
|
||||
AdjustControls(container.Controls);
|
||||
_invert = false;
|
||||
}
|
||||
@@ -63,7 +60,7 @@ public static class ControlHelper
|
||||
if (button.Image is not null)
|
||||
button.Image = AdjustImage(button.Image);
|
||||
}
|
||||
|
||||
|
||||
var pictureBox = control as PictureBox;
|
||||
if (pictureBox != null)
|
||||
{
|
||||
@@ -86,7 +83,7 @@ public static class ControlHelper
|
||||
gb.ForeColor = foreMain;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var chart = control as Chart;
|
||||
if (chart != null)
|
||||
{
|
||||
@@ -94,7 +91,7 @@ public static class ControlHelper
|
||||
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;
|
||||
|
||||
|
||||
@@ -15,31 +15,23 @@ namespace CustomControls
|
||||
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
|
||||
public static extern bool CheckSystemDarkModeStatus();
|
||||
|
||||
|
||||
[DllImport("DwmApi")] //System.Runtime.InteropServices
|
||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize);
|
||||
|
||||
protected bool _darkTheme;
|
||||
public bool darkTheme;
|
||||
public bool invert = false;
|
||||
|
||||
public bool DarkTheme
|
||||
{
|
||||
get { return _darkTheme; }
|
||||
set
|
||||
{
|
||||
if (_darkTheme != value)
|
||||
{
|
||||
_darkTheme = value;
|
||||
invert = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitTheme()
|
||||
{
|
||||
DarkTheme = CheckSystemDarkModeStatus();
|
||||
ControlHelper.Adjust(this, 2);
|
||||
DwmSetWindowAttribute(this.Handle, 20, new[] { DarkTheme ? 1 : 0 }, 4);
|
||||
bool newDarkTheme = CheckSystemDarkModeStatus();
|
||||
invert = (darkTheme != newDarkTheme);
|
||||
darkTheme = newDarkTheme;
|
||||
|
||||
ControlHelper.Adjust(this, 2, invert);
|
||||
try
|
||||
{
|
||||
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4);
|
||||
} catch { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
17
app/Fans.cs
17
app/Fans.cs
@@ -11,12 +11,10 @@ namespace GHelper
|
||||
Series seriesCPU;
|
||||
Series seriesGPU;
|
||||
|
||||
static int MinRPM, MaxRPM;
|
||||
|
||||
static string ChartPercToRPM(int percentage, string unit = "")
|
||||
{
|
||||
int MinRPM, MaxRPM;
|
||||
MinRPM = 1800;
|
||||
MaxRPM = Program.config.ContainsModel("401") ? 7200 : 5800;
|
||||
|
||||
if (percentage == 0) return "OFF";
|
||||
|
||||
return (200 * Math.Round((float)(MinRPM + (MaxRPM - MinRPM) * percentage * 0.01) / 200)).ToString() + unit;
|
||||
@@ -84,6 +82,17 @@ namespace GHelper
|
||||
InitializeComponent();
|
||||
InitTheme();
|
||||
|
||||
MinRPM = 1800;
|
||||
|
||||
if (Program.config.ContainsModel("401"))
|
||||
MaxRPM = 7200;
|
||||
else if (Program.config.ContainsModel("503"))
|
||||
MaxRPM = 6800;
|
||||
else
|
||||
MaxRPM = 5800;
|
||||
|
||||
|
||||
|
||||
labelTip.Visible = false;
|
||||
labelTip.BackColor = Color.Transparent;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user