UI tweaks, mid fan support

This commit is contained in:
seerge
2023-03-21 13:14:53 +01:00
parent cdb633be04
commit 9ff572b8f6
11 changed files with 102 additions and 63 deletions

View File

@@ -12,6 +12,7 @@ public class ASUSWmi
public const uint CPU_Fan = 0x00110013;
public const uint GPU_Fan = 0x00110014;
public const uint Mid_Fan = 0x00110031;
public const uint PerformanceMode = 0x00120075; // Thermal Control

View File

@@ -62,8 +62,7 @@ namespace Starlight.AnimeMatrix
Off = 0,
Dim = 1,
Medium = 2,
Full = 3,
Super = 4, //test, doesn't work
Full = 3
}
@@ -79,7 +78,7 @@ namespace Starlight.AnimeMatrix
public int MaxRows = 61;
public int FullRows = 11;
public int EmptyFirstRow = 1;
public int EmptyFirstRow = 0;
private int frameIndex = 0;
@@ -87,9 +86,6 @@ namespace Starlight.AnimeMatrix
: base(0x0B05, 0x193B, 640)
{
string model = GetModel();
Logger.WriteLine("Animatrix: " + model);
if (model.Contains("401"))
{
EmptyFirstRow = 1;
@@ -199,15 +195,12 @@ namespace Starlight.AnimeMatrix
{
EnsureRowInRange(y);
var start = RowToLinearAddress(y) - XStart(y);
if (x >= XStart(y) && x < XEnd(y))
{
//Debug.Write((start + x).ToString("D4") + ",");
SetLedLinear(start + x, value);
return start + x;
}
//Debug.Write(" ");
return -1;
}
@@ -320,12 +313,8 @@ namespace Starlight.AnimeMatrix
Debug.Write("ERROR");
counter++;
}
}
}
//Debug.Write("\n");
}
}

View File

@@ -45,6 +45,7 @@ public static class ControlHelper
_invert = invert;
AdjustControls(container.Controls);
_invert = false;
}
public static void Resize(RForm container, float baseScale = 2)
@@ -92,7 +93,7 @@ public static class ControlHelper
if (pictureBox != null && pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = AdjustImage(pictureBox.BackgroundImage);
var combo = control as RComboBox;
if (combo != null)
{

View File

@@ -1,4 +1,5 @@
using Microsoft.Win32;
using GHelper;
using Microsoft.Win32;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
@@ -19,7 +20,7 @@ namespace CustomControls
[DllImport("DwmApi")] //System.Runtime.InteropServices
private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, int[] attrValue, int attrSize);
public bool darkTheme = false;
public bool darkTheme;
private static bool IsDarkTheme()
{
@@ -39,8 +40,12 @@ namespace CustomControls
if (setDPI)
ControlHelper.Resize(this);
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4);
ControlHelper.Adjust(this, darkTheme, changed);
if (changed)
{
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4);
ControlHelper.Adjust(this, darkTheme, changed);
}
}
}
@@ -235,13 +240,18 @@ namespace CustomControls
{
//Fields
private int borderSize = 5;
private int borderRadius = 5;
private bool activated = false;
private bool secondary = false;
public int BorderRadius
{
get { return borderRadius; }
set
{
borderRadius = value;
}
}
private Color borderColor = Color.Transparent;
public Color BorderColor
{
get { return borderColor; }
@@ -252,6 +262,7 @@ namespace CustomControls
}
private bool activated = false;
public bool Activated
{
get { return activated; }
@@ -264,6 +275,7 @@ namespace CustomControls
}
}
private bool secondary = false;
public bool Secondary
{
get { return secondary; }

4
app/Fans.Designer.cs generated
View File

@@ -203,6 +203,7 @@ namespace GHelper
chartMid.Text = "chartMid";
title3.Name = "Title3";
chartMid.Titles.Add(title3);
chartMid.Visible = false;
//
// labelFans
//
@@ -233,6 +234,7 @@ namespace GHelper
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonReset.BackColor = SystemColors.ControlLight;
buttonReset.BorderColor = Color.Transparent;
buttonReset.BorderRadius = 2;
buttonReset.FlatStyle = FlatStyle.Flat;
buttonReset.Location = new Point(30, 1081);
buttonReset.Margin = new Padding(4, 2, 4, 2);
@@ -249,6 +251,7 @@ namespace GHelper
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonApply.BackColor = SystemColors.ControlLight;
buttonApply.BorderColor = Color.Transparent;
buttonApply.BorderRadius = 2;
buttonApply.FlatStyle = FlatStyle.Flat;
buttonApply.Location = new Point(542, 1081);
buttonApply.Margin = new Padding(4, 2, 4, 2);
@@ -319,6 +322,7 @@ namespace GHelper
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonApplyPower.BackColor = SystemColors.ControlLight;
buttonApplyPower.BorderColor = Color.Transparent;
buttonApplyPower.BorderRadius = 2;
buttonApplyPower.FlatStyle = FlatStyle.Flat;
buttonApplyPower.Location = new Point(20, 1081);
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);

View File

@@ -273,15 +273,16 @@ namespace GHelper
{
byte[] curve = Program.wmi.GetFanCurve(2);
if (curve.All(singleByte => singleByte == 0))
{
Program.config.setConfig("mid_fan", 0);
chartMid.Visible = false;
} else
}
else
{
Program.config.setConfig("mid_fan", 1);
chartMid.Visible = true;
SetChart(chartMid, 2);
LoadProfile(seriesMid, 2);
}
@@ -351,7 +352,7 @@ namespace GHelper
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
if (Program.config.getConfig("mid_fan") == 1)
ApplyProfile(seriesMid, 2);
}
@@ -360,7 +361,7 @@ namespace GHelper
LoadProfile(seriesCPU, 0, 1);
LoadProfile(seriesGPU, 1, 1);
if (Program.config.getConfig("mid_fan") == 1)
if (Program.config.getConfig("mid_fan") == 1)
LoadProfile(seriesMid, 2, 1);
checkAuto.Checked = false;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.35</AssemblyVersion>
<AssemblyVersion>0.36</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -86,9 +86,5 @@ public static class HardwareMonitor
catch (Exception ex)
{
}
finally
{
Logger.WriteLine($"GpuTemperatureProvider: {GpuTemperatureProvider?.GetType().Name}");
}
}
}

View File

@@ -77,8 +77,15 @@ namespace GHelper
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
CheckForUpdates();
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
{
SettingsToggle();
}
Application.Run();
}

View File

@@ -68,11 +68,13 @@ namespace GHelper
buttonOptimized = new RButton();
buttonUltimate = new RButton();
panelScreen = new Panel();
labelMidFan = new Label();
labelTipScreen = new Label();
tableScreen = new TableLayoutPanel();
buttonScreenAuto = new RButton();
button60Hz = new RButton();
button120Hz = new RButton();
buttonMiniled = new RButton();
pictureScreen = new PictureBox();
labelSreen = new Label();
panelKeyboard = new Panel();
@@ -85,7 +87,6 @@ namespace GHelper
buttonKeyboardColor = new RButton();
pictureKeyboard = new PictureBox();
labelKeyboard = new Label();
buttonMiniled = new RButton();
panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
@@ -180,6 +181,7 @@ namespace GHelper
buttonMatrix.Activated = false;
buttonMatrix.BackColor = SystemColors.ControlLight;
buttonMatrix.BorderColor = Color.Transparent;
buttonMatrix.BorderRadius = 2;
buttonMatrix.Dock = DockStyle.Top;
buttonMatrix.FlatAppearance.BorderSize = 0;
buttonMatrix.FlatStyle = FlatStyle.Flat;
@@ -327,12 +329,13 @@ namespace GHelper
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = SystemColors.ControlLight;
buttonQuit.BorderColor = Color.Transparent;
buttonQuit.BorderRadius = 2;
buttonQuit.FlatStyle = FlatStyle.Flat;
buttonQuit.Location = new Point(578, 16);
buttonQuit.Location = new Point(599, 16);
buttonQuit.Margin = new Padding(8, 4, 8, 4);
buttonQuit.Name = "buttonQuit";
buttonQuit.Secondary = true;
buttonQuit.Size = new Size(208, 44);
buttonQuit.Size = new Size(185, 44);
buttonQuit.TabIndex = 18;
buttonQuit.Text = "Quit";
buttonQuit.UseVisualStyleBackColor = false;
@@ -426,6 +429,7 @@ namespace GHelper
buttonSilent.BackColor = SystemColors.ControlLightLight;
buttonSilent.BackgroundImageLayout = ImageLayout.None;
buttonSilent.BorderColor = Color.Transparent;
buttonSilent.BorderRadius = 5;
buttonSilent.CausesValidation = false;
buttonSilent.Dock = DockStyle.Fill;
buttonSilent.FlatAppearance.BorderSize = 0;
@@ -448,6 +452,7 @@ namespace GHelper
buttonBalanced.Activated = false;
buttonBalanced.BackColor = SystemColors.ControlLightLight;
buttonBalanced.BorderColor = Color.Transparent;
buttonBalanced.BorderRadius = 5;
buttonBalanced.Dock = DockStyle.Fill;
buttonBalanced.FlatAppearance.BorderSize = 0;
buttonBalanced.FlatStyle = FlatStyle.Flat;
@@ -469,6 +474,7 @@ namespace GHelper
buttonTurbo.Activated = false;
buttonTurbo.BackColor = SystemColors.ControlLightLight;
buttonTurbo.BorderColor = Color.Transparent;
buttonTurbo.BorderRadius = 5;
buttonTurbo.Dock = DockStyle.Fill;
buttonTurbo.FlatAppearance.BorderSize = 0;
buttonTurbo.FlatStyle = FlatStyle.Flat;
@@ -490,6 +496,7 @@ namespace GHelper
buttonFans.Activated = false;
buttonFans.BackColor = SystemColors.ControlLight;
buttonFans.BorderColor = Color.Transparent;
buttonFans.BorderRadius = 5;
buttonFans.Dock = DockStyle.Fill;
buttonFans.FlatAppearance.BorderSize = 0;
buttonFans.FlatStyle = FlatStyle.Flat;
@@ -592,6 +599,7 @@ namespace GHelper
buttonEco.Activated = false;
buttonEco.BackColor = SystemColors.ControlLightLight;
buttonEco.BorderColor = Color.Transparent;
buttonEco.BorderRadius = 5;
buttonEco.CausesValidation = false;
buttonEco.Dock = DockStyle.Top;
buttonEco.FlatAppearance.BorderSize = 0;
@@ -614,6 +622,7 @@ namespace GHelper
buttonStandard.Activated = false;
buttonStandard.BackColor = SystemColors.ControlLightLight;
buttonStandard.BorderColor = Color.Transparent;
buttonStandard.BorderRadius = 5;
buttonStandard.Dock = DockStyle.Top;
buttonStandard.FlatAppearance.BorderSize = 0;
buttonStandard.FlatStyle = FlatStyle.Flat;
@@ -635,6 +644,7 @@ namespace GHelper
buttonOptimized.Activated = false;
buttonOptimized.BackColor = SystemColors.ControlLightLight;
buttonOptimized.BorderColor = Color.Transparent;
buttonOptimized.BorderRadius = 5;
buttonOptimized.Dock = DockStyle.Top;
buttonOptimized.FlatAppearance.BorderSize = 0;
buttonOptimized.FlatStyle = FlatStyle.Flat;
@@ -656,6 +666,7 @@ namespace GHelper
buttonUltimate.Activated = false;
buttonUltimate.BackColor = SystemColors.ControlLightLight;
buttonUltimate.BorderColor = Color.Transparent;
buttonUltimate.BorderRadius = 5;
buttonUltimate.Dock = DockStyle.Top;
buttonUltimate.FlatAppearance.BorderSize = 0;
buttonUltimate.FlatStyle = FlatStyle.Flat;
@@ -676,6 +687,7 @@ namespace GHelper
//
panelScreen.AutoSize = true;
panelScreen.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelScreen.Controls.Add(labelMidFan);
panelScreen.Controls.Add(labelTipScreen);
panelScreen.Controls.Add(tableScreen);
panelScreen.Controls.Add(pictureScreen);
@@ -688,6 +700,17 @@ namespace GHelper
panelScreen.Size = new Size(810, 181);
panelScreen.TabIndex = 38;
//
// labelMidFan
//
labelMidFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelMidFan.Location = new Point(488, 13);
labelMidFan.Margin = new Padding(8, 0, 8, 0);
labelMidFan.Name = "labelMidFan";
labelMidFan.Size = new Size(296, 34);
labelMidFan.TabIndex = 25;
labelMidFan.Text = " ";
labelMidFan.TextAlign = ContentAlignment.TopRight;
//
// labelTipScreen
//
labelTipScreen.ForeColor = SystemColors.GrayText;
@@ -711,7 +734,6 @@ namespace GHelper
tableScreen.Controls.Add(button60Hz, 1, 0);
tableScreen.Controls.Add(button120Hz, 2, 0);
tableScreen.Controls.Add(buttonMiniled, 3, 0);
tableScreen.Location = new Point(16, 51);
tableScreen.Margin = new Padding(8, 4, 8, 4);
tableScreen.Name = "tableScreen";
@@ -725,6 +747,7 @@ namespace GHelper
buttonScreenAuto.Activated = false;
buttonScreenAuto.BackColor = SystemColors.ControlLightLight;
buttonScreenAuto.BorderColor = Color.Transparent;
buttonScreenAuto.BorderRadius = 5;
buttonScreenAuto.Dock = DockStyle.Fill;
buttonScreenAuto.FlatAppearance.BorderSize = 0;
buttonScreenAuto.FlatStyle = FlatStyle.Flat;
@@ -743,6 +766,7 @@ namespace GHelper
button60Hz.Activated = false;
button60Hz.BackColor = SystemColors.ControlLightLight;
button60Hz.BorderColor = Color.Transparent;
button60Hz.BorderRadius = 5;
button60Hz.CausesValidation = false;
button60Hz.Dock = DockStyle.Fill;
button60Hz.FlatAppearance.BorderSize = 0;
@@ -762,6 +786,7 @@ namespace GHelper
button120Hz.Activated = false;
button120Hz.BackColor = SystemColors.ControlLightLight;
button120Hz.BorderColor = Color.Transparent;
button120Hz.BorderRadius = 5;
button120Hz.Dock = DockStyle.Fill;
button120Hz.FlatAppearance.BorderSize = 0;
button120Hz.FlatStyle = FlatStyle.Flat;
@@ -775,6 +800,26 @@ namespace GHelper
button120Hz.Text = "120Hz + OD";
button120Hz.UseVisualStyleBackColor = false;
//
// buttonMiniled
//
buttonMiniled.Activated = false;
buttonMiniled.BackColor = SystemColors.ControlLightLight;
buttonMiniled.BorderColor = Color.Transparent;
buttonMiniled.BorderRadius = 5;
buttonMiniled.CausesValidation = false;
buttonMiniled.Dock = DockStyle.Fill;
buttonMiniled.FlatAppearance.BorderSize = 0;
buttonMiniled.FlatStyle = FlatStyle.Flat;
buttonMiniled.ForeColor = SystemColors.ControlText;
buttonMiniled.Location = new Point(583, 4);
buttonMiniled.Margin = new Padding(4);
buttonMiniled.Name = "buttonMiniled";
buttonMiniled.Secondary = false;
buttonMiniled.Size = new Size(185, 72);
buttonMiniled.TabIndex = 3;
buttonMiniled.Text = "Miniled";
buttonMiniled.UseVisualStyleBackColor = false;
//
// pictureScreen
//
pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage");
@@ -838,6 +883,7 @@ namespace GHelper
buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.BorderRadius = 2;
buttonKeyboard.Dock = DockStyle.Top;
buttonKeyboard.FlatAppearance.BorderSize = 0;
buttonKeyboard.FlatStyle = FlatStyle.Flat;
@@ -905,6 +951,7 @@ namespace GHelper
buttonKeyboardColor.Activated = false;
buttonKeyboardColor.BackColor = SystemColors.ButtonHighlight;
buttonKeyboardColor.BorderColor = Color.Transparent;
buttonKeyboardColor.BorderRadius = 2;
buttonKeyboardColor.Dock = DockStyle.Top;
buttonKeyboardColor.FlatStyle = FlatStyle.Flat;
buttonKeyboardColor.ForeColor = SystemColors.ControlText;
@@ -939,25 +986,6 @@ namespace GHelper
labelKeyboard.TabIndex = 32;
labelKeyboard.Text = "Laptop Keyboard";
//
// buttonMiniled
//
buttonMiniled.Activated = false;
buttonMiniled.BackColor = SystemColors.ControlLightLight;
buttonMiniled.BorderColor = Color.Transparent;
buttonMiniled.CausesValidation = false;
buttonMiniled.Dock = DockStyle.Fill;
buttonMiniled.FlatAppearance.BorderSize = 0;
buttonMiniled.FlatStyle = FlatStyle.Flat;
buttonMiniled.ForeColor = SystemColors.ControlText;
buttonMiniled.Location = new Point(197, 4);
buttonMiniled.Margin = new Padding(4);
buttonMiniled.Name = "buttonMiniled";
buttonMiniled.Secondary = false;
buttonMiniled.Size = new Size(185, 72);
buttonMiniled.TabIndex = 3;
buttonMiniled.Text = "Miniled";
buttonMiniled.UseVisualStyleBackColor = false;
//
// SettingsForm
//
AutoScaleDimensions = new SizeF(192F, 192F);
@@ -1073,5 +1101,6 @@ namespace GHelper
private RButton buttonKeyboard;
private RButton buttonKeyboardColor;
private RButton buttonFans;
private Label labelMidFan;
}
}

View File

@@ -532,7 +532,7 @@ namespace GHelper
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count-1) : 0;
comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count - 1) : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0;
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
@@ -707,7 +707,8 @@ namespace GHelper
{
buttonMiniled.Activated = (miniled == 1);
Program.config.setConfig("miniled", miniled);
} else
}
else
{
buttonMiniled.Visible = false;
}
@@ -758,6 +759,8 @@ namespace GHelper
private static string FormatFan(int fan)
{
if (fan < 0) return null;
if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM";
else
@@ -769,6 +772,7 @@ namespace GHelper
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
string midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
string cpuTemp = "";
string gpuTemp = "";
@@ -791,6 +795,7 @@ namespace GHelper
{
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan;
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
if (midFan is not null) Program.settingsForm.labelMidFan.Text = "Mid" + midFan;
Program.settingsForm.labelBattery.Text = battery;
});
}
@@ -996,12 +1001,6 @@ namespace GHelper
if (!ultimate)
{
tableGPU.Controls.Remove(buttonUltimate);
/*
* buttonFans.Image = null;
buttonFans.Height = 44;
*/
tablePerf.ColumnCount = 0;
tableGPU.ColumnCount = 0;
tableScreen.ColumnCount = 0;