Auto off for matrix on battery

This commit is contained in:
seerge
2023-03-06 19:57:47 +01:00
parent 6c3d4b9cb2
commit 003a19d94b
4 changed files with 105 additions and 88 deletions

107
Fans.Designer.cs generated
View File

@@ -58,29 +58,29 @@
//
chartArea1.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea1);
chartCPU.Location = new Point(195, 14);
chartCPU.Margin = new Padding(2, 1, 2, 1);
chartCPU.Location = new Point(390, 28);
chartCPU.Margin = new Padding(4, 2, 4, 2);
chartCPU.Name = "chartCPU";
chartCPU.Size = new Size(416, 218);
chartCPU.Size = new Size(832, 436);
chartCPU.TabIndex = 0;
chartCPU.Text = "chartCPU";
//
// buttonApply
//
buttonApply.Location = new Point(473, 476);
buttonApply.Margin = new Padding(2, 1, 2, 1);
buttonApply.Location = new Point(946, 952);
buttonApply.Margin = new Padding(4, 2, 4, 2);
buttonApply.Name = "buttonApply";
buttonApply.Size = new Size(137, 22);
buttonApply.Size = new Size(274, 44);
buttonApply.TabIndex = 1;
buttonApply.Text = "Apply Fan Curve";
buttonApply.UseVisualStyleBackColor = true;
//
// buttonReset
//
buttonReset.Location = new Point(195, 476);
buttonReset.Margin = new Padding(2, 1, 2, 1);
buttonReset.Location = new Point(390, 952);
buttonReset.Margin = new Padding(4, 2, 4, 2);
buttonReset.Name = "buttonReset";
buttonReset.Size = new Size(137, 22);
buttonReset.Size = new Size(274, 44);
buttonReset.TabIndex = 2;
buttonReset.Text = "Factory Defaults";
buttonReset.UseVisualStyleBackColor = true;
@@ -89,10 +89,10 @@
//
chartArea2.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea2);
chartGPU.Location = new Point(195, 240);
chartGPU.Margin = new Padding(2, 1, 2, 1);
chartGPU.Location = new Point(390, 480);
chartGPU.Margin = new Padding(4, 2, 4, 2);
chartGPU.Name = "chartGPU";
chartGPU.Size = new Size(416, 225);
chartGPU.Size = new Size(832, 450);
chartGPU.TabIndex = 3;
chartGPU.Text = "chart1";
//
@@ -107,11 +107,11 @@
groupBox1.Controls.Add(label1);
groupBox1.Controls.Add(trackCPU);
groupBox1.Controls.Add(trackTotal);
groupBox1.Location = new Point(6, 6);
groupBox1.Margin = new Padding(2, 1, 2, 1);
groupBox1.Location = new Point(12, 12);
groupBox1.Margin = new Padding(4, 2, 4, 2);
groupBox1.Name = "groupBox1";
groupBox1.Padding = new Padding(3, 2, 3, 2);
groupBox1.Size = new Size(178, 459);
groupBox1.Padding = new Padding(6, 4, 6, 4);
groupBox1.Size = new Size(356, 918);
groupBox1.TabIndex = 4;
groupBox1.TabStop = false;
groupBox1.Text = "Power Limits (PPT)";
@@ -120,22 +120,23 @@
//
labelApplied.AutoSize = true;
labelApplied.ForeColor = Color.Tomato;
labelApplied.Location = new Point(8, 18);
labelApplied.Margin = new Padding(2, 0, 2, 0);
labelApplied.Location = new Point(16, 36);
labelApplied.Margin = new Padding(4, 0, 4, 0);
labelApplied.Name = "labelApplied";
labelApplied.Size = new Size(71, 15);
labelApplied.Size = new Size(143, 32);
labelApplied.TabIndex = 13;
labelApplied.Text = "Not Applied";
//
// pictureFine
//
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureFine.BackgroundImage = Properties.Resources.everything_is_fine_itsfine;
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
pictureFine.Location = new Point(5, 343);
pictureFine.Margin = new Padding(2, 1, 2, 1);
pictureFine.Image = Properties.Resources.everything_is_fine_itsfine;
pictureFine.Location = new Point(10, 682);
pictureFine.Margin = new Padding(4, 2, 4, 2);
pictureFine.Name = "pictureFine";
pictureFine.Size = new Size(167, 112);
pictureFine.Size = new Size(336, 226);
pictureFine.SizeMode = PictureBoxSizeMode.Zoom;
pictureFine.TabIndex = 12;
pictureFine.TabStop = false;
pictureFine.Visible = false;
@@ -144,10 +145,10 @@
//
labelInfo.AutoSize = true;
labelInfo.Dock = DockStyle.Bottom;
labelInfo.Location = new Point(3, 442);
labelInfo.Margin = new Padding(2, 0, 2, 0);
labelInfo.Location = new Point(6, 882);
labelInfo.Margin = new Padding(4, 0, 4, 0);
labelInfo.Name = "labelInfo";
labelInfo.Size = new Size(32, 15);
labelInfo.Size = new Size(65, 32);
labelInfo.TabIndex = 11;
labelInfo.Text = "label";
//
@@ -155,10 +156,10 @@
//
labelCPU.AutoSize = true;
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelCPU.Location = new Point(106, 59);
labelCPU.Margin = new Padding(2, 0, 2, 0);
labelCPU.Location = new Point(212, 118);
labelCPU.Margin = new Padding(4, 0, 4, 0);
labelCPU.Name = "labelCPU";
labelCPU.Size = new Size(30, 15);
labelCPU.Size = new Size(61, 32);
labelCPU.TabIndex = 10;
labelCPU.Text = "CPU";
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
@@ -167,10 +168,10 @@
//
labelTotal.AutoSize = true;
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelTotal.Location = new Point(21, 59);
labelTotal.Margin = new Padding(2, 0, 2, 0);
labelTotal.Location = new Point(42, 118);
labelTotal.Margin = new Padding(4, 0, 4, 0);
labelTotal.Name = "labelTotal";
labelTotal.Size = new Size(34, 15);
labelTotal.Size = new Size(70, 32);
labelTotal.TabIndex = 9;
labelTotal.Text = "Total";
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
@@ -178,10 +179,10 @@
// label2
//
label2.AutoSize = true;
label2.Location = new Point(108, 43);
label2.Margin = new Padding(2, 0, 2, 0);
label2.Location = new Point(216, 86);
label2.Margin = new Padding(4, 0, 4, 0);
label2.Name = "label2";
label2.Size = new Size(30, 15);
label2.Size = new Size(58, 32);
label2.TabIndex = 8;
label2.Text = "CPU";
label2.TextAlign = ContentAlignment.MiddleCenter;
@@ -189,36 +190,36 @@
// label1
//
label1.AutoSize = true;
label1.Location = new Point(22, 43);
label1.Margin = new Padding(2, 0, 2, 0);
label1.Location = new Point(44, 86);
label1.Margin = new Padding(4, 0, 4, 0);
label1.Name = "label1";
label1.Size = new Size(32, 15);
label1.Size = new Size(65, 32);
label1.TabIndex = 7;
label1.Text = "Total";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// trackCPU
//
trackCPU.Location = new Point(109, 83);
trackCPU.Margin = new Padding(2, 1, 2, 1);
trackCPU.Location = new Point(218, 166);
trackCPU.Margin = new Padding(4, 2, 4, 2);
trackCPU.Maximum = 85;
trackCPU.Minimum = 15;
trackCPU.Name = "trackCPU";
trackCPU.Orientation = Orientation.Vertical;
trackCPU.Size = new Size(45, 208);
trackCPU.Size = new Size(90, 416);
trackCPU.TabIndex = 6;
trackCPU.TickFrequency = 5;
trackCPU.Value = 80;
//
// trackTotal
//
trackTotal.Location = new Point(23, 83);
trackTotal.Margin = new Padding(2, 1, 2, 1);
trackTotal.Location = new Point(46, 166);
trackTotal.Margin = new Padding(4, 2, 4, 2);
trackTotal.Maximum = 150;
trackTotal.Minimum = 15;
trackTotal.Name = "trackTotal";
trackTotal.Orientation = Orientation.Vertical;
trackTotal.Size = new Size(45, 208);
trackTotal.Size = new Size(90, 416);
trackTotal.TabIndex = 5;
trackTotal.TickFrequency = 5;
trackTotal.TickStyle = TickStyle.TopLeft;
@@ -226,10 +227,10 @@
//
// buttonApplyPower
//
buttonApplyPower.Location = new Point(8, 476);
buttonApplyPower.Margin = new Padding(2, 1, 2, 1);
buttonApplyPower.Location = new Point(16, 952);
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
buttonApplyPower.Name = "buttonApplyPower";
buttonApplyPower.Size = new Size(176, 22);
buttonApplyPower.Size = new Size(352, 44);
buttonApplyPower.TabIndex = 11;
buttonApplyPower.Text = "Apply Power Limits";
buttonApplyPower.UseVisualStyleBackColor = true;
@@ -237,20 +238,20 @@
// checkAuto
//
checkAuto.AutoSize = true;
checkAuto.Location = new Point(381, 479);
checkAuto.Margin = new Padding(2, 1, 2, 1);
checkAuto.Location = new Point(762, 958);
checkAuto.Margin = new Padding(4, 2, 4, 2);
checkAuto.Name = "checkAuto";
checkAuto.Size = new Size(86, 19);
checkAuto.Size = new Size(165, 36);
checkAuto.TabIndex = 12;
checkAuto.Text = "Auto Apply";
checkAuto.UseVisualStyleBackColor = true;
//
// Fans
//
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleDimensions = new SizeF(192F, 192F);
AutoScaleMode = AutoScaleMode.Dpi;
AutoSize = true;
ClientSize = new Size(621, 510);
ClientSize = new Size(1242, 1020);
Controls.Add(checkAuto);
Controls.Add(buttonApplyPower);
Controls.Add(groupBox1);
@@ -258,7 +259,7 @@
Controls.Add(buttonReset);
Controls.Add(buttonApply);
Controls.Add(chartCPU);
Margin = new Padding(2, 1, 2, 1);
Margin = new Padding(4, 2, 4, 2);
MaximizeBox = false;
MdiChildrenMinimizedAnchorBottom = false;
MinimizeBox = false;

View File

@@ -1,7 +1,6 @@
using Microsoft.Win32;
using System.Diagnostics;
using System.Management;
using Starlight.AnimeMatrix;
public class HardwareMonitor
{
@@ -56,12 +55,14 @@ namespace GHelper
try
{
wmi = new ASUSWmi();
} catch {
}
catch
{
DialogResult dialogResult = MessageBox.Show("Can't connect to ASUS ACPI. Application can't function without it. Try to install Asus System Controll Interface", "Startup Error", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Process.Start(new ProcessStartInfo("https://www.asus.com/support/FAQ/1047338/") { UseShellExecute = true });
}
}
Application.Exit();
return;
@@ -99,7 +100,7 @@ namespace GHelper
settingsForm.AutoScreen(isPlugged);
settingsForm.AutoPerformance(isPlugged);
settingsForm.SetAnimeMatrix();
settingsForm.SetMatrix(isPlugged);
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
}
@@ -136,7 +137,8 @@ namespace GHelper
try
{
intKey = Convert.ToInt32(command, 16);
} catch
}
catch
{
intKey = -1;
}

27
Settings.Designer.cs generated
View File

@@ -30,6 +30,7 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SettingsForm));
panelMatrix = new Panel();
checkMatrix = new CheckBox();
tableLayoutMatrix = new TableLayoutPanel();
buttonMatrix = new Button();
comboMatrixRunning = new ComboBox();
@@ -107,6 +108,7 @@
//
// panelMatrix
//
panelMatrix.Controls.Add(checkMatrix);
panelMatrix.Controls.Add(tableLayoutMatrix);
panelMatrix.Controls.Add(pictureMatrix);
panelMatrix.Controls.Add(labelMatrix);
@@ -114,9 +116,21 @@
panelMatrix.Location = new Point(16, 806);
panelMatrix.Margin = new Padding(4);
panelMatrix.Name = "panelMatrix";
panelMatrix.Size = new Size(722, 148);
panelMatrix.Size = new Size(722, 156);
panelMatrix.TabIndex = 33;
//
// checkMatrix
//
checkMatrix.AutoSize = true;
checkMatrix.ForeColor = SystemColors.GrayText;
checkMatrix.Location = new Point(26, 112);
checkMatrix.Margin = new Padding(4, 2, 4, 2);
checkMatrix.Name = "checkMatrix";
checkMatrix.Size = new Size(249, 36);
checkMatrix.TabIndex = 44;
checkMatrix.Text = "Turn off on battery";
checkMatrix.UseVisualStyleBackColor = true;
//
// tableLayoutMatrix
//
tableLayoutMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -206,7 +220,7 @@
panelBattery.Controls.Add(labelBatteryTitle);
panelBattery.Controls.Add(trackBattery);
panelBattery.Dock = DockStyle.Top;
panelBattery.Location = new Point(16, 954);
panelBattery.Location = new Point(16, 962);
panelBattery.Margin = new Padding(4);
panelBattery.Name = "panelBattery";
panelBattery.Size = new Size(722, 148);
@@ -277,7 +291,7 @@
panelFooter.Controls.Add(buttonQuit);
panelFooter.Controls.Add(checkStartup);
panelFooter.Dock = DockStyle.Top;
panelFooter.Location = new Point(16, 1102);
panelFooter.Location = new Point(16, 1110);
panelFooter.Margin = new Padding(4);
panelFooter.Name = "panelFooter";
panelFooter.Size = new Size(722, 64);
@@ -338,7 +352,7 @@
//
checkBoost.AutoSize = true;
checkBoost.ForeColor = SystemColors.GrayText;
checkBoost.Location = new Point(27, 158);
checkBoost.Location = new Point(27, 154);
checkBoost.Margin = new Padding(4, 2, 4, 2);
checkBoost.Name = "checkBoost";
checkBoost.Size = new Size(320, 36);
@@ -462,7 +476,7 @@
//
checkGPU.AutoSize = true;
checkGPU.ForeColor = SystemColors.GrayText;
checkGPU.Location = new Point(27, 156);
checkGPU.Location = new Point(27, 154);
checkGPU.Margin = new Padding(4, 2, 4, 2);
checkGPU.Name = "checkGPU";
checkGPU.Size = new Size(550, 36);
@@ -581,7 +595,7 @@
//
checkScreen.AutoSize = true;
checkScreen.ForeColor = SystemColors.GrayText;
checkScreen.Location = new Point(27, 156);
checkScreen.Location = new Point(27, 154);
checkScreen.Margin = new Padding(4, 2, 4, 2);
checkScreen.Name = "checkScreen";
checkScreen.Size = new Size(527, 36);
@@ -896,5 +910,6 @@
private PictureBox pictureColor2;
private PictureBox pictureColor;
private Button buttonKeyboardColor;
private CheckBox checkMatrix;
}
}

View File

@@ -89,12 +89,21 @@ namespace GHelper
comboMatrix.DropDownClosed += ComboMatrix_SelectedValueChanged;
comboMatrixRunning.DropDownClosed += ComboMatrixRunning_SelectedValueChanged;
checkMatrix.CheckedChanged += CheckMatrix_CheckedChanged; ;
buttonMatrix.Click += ButtonMatrix_Click;
SetTimer();
}
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
{
if (sender is null) return;
CheckBox check = (CheckBox)sender;
Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0);
}
private static void StartMatrixTimer()
{
matrixTimer.Enabled = true;
@@ -194,23 +203,24 @@ namespace GHelper
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
{
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
SetAnimeMatrix();
SetMatrix();
}
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
{
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
SetAnimeMatrix();
SetMatrix();
}
public void SetAnimeMatrix()
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
{
if (mat is null) return;
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
bool auto = Program.config.getConfig("matrix_auto") == 1;
if (brightness < 0) brightness = 0;
if (running < 0) running = 0;
@@ -224,7 +234,7 @@ namespace GHelper
StopMatrixTimer();
if (brightness == 0)
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online))
{
mat.SetDisplayState(false);
}
@@ -384,6 +394,8 @@ namespace GHelper
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
}
}
@@ -970,37 +982,24 @@ namespace GHelper
private void trackBatteryChange(object? sender, EventArgs e)
{
if (sender is null)
return;
if (sender is null) return;
TrackBar bar = (TrackBar)sender;
SetBatteryChargeLimit(bar.Value);
}
private void checkGPU_CheckedChanged(object? sender, EventArgs e)
{
if (sender is null)
return;
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
Program.config.setConfig("gpu_auto", 1);
else
Program.config.setConfig("gpu_auto", 0);
if (sender is null) return;
CheckBox check = (CheckBox)sender;
Program.config.setConfig("gpu_auto", check.Checked ? 1 : 0);
}
private void checkScreen_CheckedChanged(object? sender, EventArgs e)
{
if (sender is null)
return;
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
Program.config.setConfig("screen_auto", 1);
else
Program.config.setConfig("screen_auto", 0);
if (sender is null) return;
CheckBox check = (CheckBox)sender;
Program.config.setConfig("screen_auto", check.Checked ? 1 : 0);
}