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.Drawing.Drawing2D;
|
||||||
using System.Windows.Forms.DataVisualization.Charting;
|
using System.Windows.Forms.DataVisualization.Charting;
|
||||||
using CustomControls;
|
|
||||||
|
|
||||||
public static class ControlHelper
|
public static class ControlHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
static bool _invert = false;
|
static bool _invert = false;
|
||||||
static bool _darkTheme = false;
|
|
||||||
|
|
||||||
static float _scale = 1;
|
static float _scale = 1;
|
||||||
|
|
||||||
static Color formBack;
|
static Color formBack;
|
||||||
@@ -17,19 +14,19 @@ public static class ControlHelper
|
|||||||
static Color borderMain;
|
static Color borderMain;
|
||||||
static Color buttonMain;
|
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;
|
_scale = GetDpiScale(container).Value / baseScale;
|
||||||
|
|
||||||
|
if (container.darkTheme)
|
||||||
if (container.DarkTheme)
|
|
||||||
{
|
{
|
||||||
formBack = Color.FromArgb(255, 35, 35, 35);
|
formBack = Color.FromArgb(255, 35, 35, 35);
|
||||||
backMain = Color.FromArgb(255, 50, 50, 50);
|
backMain = Color.FromArgb(255, 50, 50, 50);
|
||||||
foreMain = Color.White;
|
foreMain = Color.White;
|
||||||
borderMain = Color.FromArgb(255, 50, 50, 50);
|
borderMain = Color.FromArgb(255, 50, 50, 50);
|
||||||
buttonMain = Color.FromArgb(255, 100, 100, 100);
|
buttonMain = Color.FromArgb(255, 100, 100, 100);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
formBack = SystemColors.Control;
|
formBack = SystemColors.Control;
|
||||||
backMain = SystemColors.ControlLightLight;
|
backMain = SystemColors.ControlLightLight;
|
||||||
@@ -41,7 +38,7 @@ public static class ControlHelper
|
|||||||
container.BackColor = formBack;
|
container.BackColor = formBack;
|
||||||
container.ForeColor = foreMain;
|
container.ForeColor = foreMain;
|
||||||
|
|
||||||
_invert = container.invert;
|
_invert = invert;
|
||||||
AdjustControls(container.Controls);
|
AdjustControls(container.Controls);
|
||||||
_invert = false;
|
_invert = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,31 +15,23 @@ namespace CustomControls
|
|||||||
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
|
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
|
||||||
public static extern bool CheckSystemDarkModeStatus();
|
public static extern bool CheckSystemDarkModeStatus();
|
||||||
|
|
||||||
|
|
||||||
[DllImport("DwmApi")] //System.Runtime.InteropServices
|
[DllImport("DwmApi")] //System.Runtime.InteropServices
|
||||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize);
|
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 invert = false;
|
||||||
|
|
||||||
public bool DarkTheme
|
|
||||||
{
|
|
||||||
get { return _darkTheme; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_darkTheme != value)
|
|
||||||
{
|
|
||||||
_darkTheme = value;
|
|
||||||
invert = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitTheme()
|
public void InitTheme()
|
||||||
{
|
{
|
||||||
DarkTheme = CheckSystemDarkModeStatus();
|
bool newDarkTheme = CheckSystemDarkModeStatus();
|
||||||
ControlHelper.Adjust(this, 2);
|
invert = (darkTheme != newDarkTheme);
|
||||||
DwmSetWindowAttribute(this.Handle, 20, new[] { DarkTheme ? 1 : 0 }, 4);
|
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 seriesCPU;
|
||||||
Series seriesGPU;
|
Series seriesGPU;
|
||||||
|
|
||||||
|
static int MinRPM, MaxRPM;
|
||||||
|
|
||||||
static string ChartPercToRPM(int percentage, string unit = "")
|
static string ChartPercToRPM(int percentage, string unit = "")
|
||||||
{
|
{
|
||||||
int MinRPM, MaxRPM;
|
|
||||||
MinRPM = 1800;
|
|
||||||
MaxRPM = Program.config.ContainsModel("401") ? 7200 : 5800;
|
|
||||||
|
|
||||||
if (percentage == 0) return "OFF";
|
if (percentage == 0) return "OFF";
|
||||||
|
|
||||||
return (200 * Math.Round((float)(MinRPM + (MaxRPM - MinRPM) * percentage * 0.01) / 200)).ToString() + unit;
|
return (200 * Math.Round((float)(MinRPM + (MaxRPM - MinRPM) * percentage * 0.01) / 200)).ToString() + unit;
|
||||||
@@ -84,6 +82,17 @@ namespace GHelper
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
InitTheme();
|
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.Visible = false;
|
||||||
labelTip.BackColor = Color.Transparent;
|
labelTip.BackColor = Color.Transparent;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user