mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e6fa6d9b0 | ||
|
|
be133cd238 | ||
|
|
30f678d08f | ||
|
|
cf201632d5 |
@@ -200,7 +200,6 @@ public class ASUSWmi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
|
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
|
||||||
{
|
{
|
||||||
ManagementEventWatcher watcher = new ManagementEventWatcher();
|
ManagementEventWatcher watcher = new ManagementEventWatcher();
|
||||||
|
|||||||
16
AppConfig.cs
16
AppConfig.cs
@@ -44,8 +44,9 @@ public class AppConfig
|
|||||||
File.WriteAllText(configFile, jsonString);
|
File.WriteAllText(configFile, jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConfig(string name)
|
public int getConfig(string name, bool performance = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (config.ContainsKey(name))
|
if (config.ContainsKey(name))
|
||||||
return int.Parse(config[name].ToString());
|
return int.Parse(config[name].ToString());
|
||||||
else return -1;
|
else return -1;
|
||||||
@@ -141,4 +142,17 @@ public class AppConfig
|
|||||||
return curve;
|
return curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getConfigPerf(string name)
|
||||||
|
{
|
||||||
|
int mode = getConfig("performance_mode");
|
||||||
|
return getConfig(name + "_" + mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigPerf(string name, int value)
|
||||||
|
{
|
||||||
|
int mode = getConfig("performance_mode");
|
||||||
|
setConfig(name + "_" + mode, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
472
Fans.Designer.cs
generated
472
Fans.Designer.cs
generated
@@ -28,103 +28,265 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||||
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
|
||||||
chartCPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
panelFans = new Panel();
|
||||||
buttonApply = new Button();
|
checkAuto = new CheckBox();
|
||||||
buttonReset = new Button();
|
|
||||||
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||||
groupBox1 = new GroupBox();
|
buttonReset = new Button();
|
||||||
|
buttonApply = new Button();
|
||||||
|
chartCPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||||
|
panelPower = new Panel();
|
||||||
|
labelPowerLimits = new Label();
|
||||||
|
checkApplyPower = new CheckBox();
|
||||||
|
buttonApplyPower = new Button();
|
||||||
|
panelCPU = new Panel();
|
||||||
|
labelCPU = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
trackCPU = new TrackBar();
|
||||||
|
panelTotal = new Panel();
|
||||||
|
labelTotal = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
trackTotal = new TrackBar();
|
||||||
labelApplied = new Label();
|
labelApplied = new Label();
|
||||||
pictureFine = new PictureBox();
|
pictureFine = new PictureBox();
|
||||||
labelInfo = new Label();
|
labelInfo = new Label();
|
||||||
labelCPU = new Label();
|
panelFans.SuspendLayout();
|
||||||
labelTotal = new Label();
|
|
||||||
label2 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
trackCPU = new TrackBar();
|
|
||||||
trackTotal = new TrackBar();
|
|
||||||
buttonApplyPower = new Button();
|
|
||||||
checkAuto = new CheckBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
|
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
|
||||||
groupBox1.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureFine).BeginInit();
|
panelPower.SuspendLayout();
|
||||||
|
panelCPU.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackCPU).BeginInit();
|
((System.ComponentModel.ISupportInitialize)trackCPU).BeginInit();
|
||||||
|
panelTotal.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackTotal).BeginInit();
|
((System.ComponentModel.ISupportInitialize)trackTotal).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureFine).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// chartCPU
|
// panelFans
|
||||||
//
|
//
|
||||||
chartArea1.Name = "ChartArea1";
|
panelFans.Controls.Add(checkAuto);
|
||||||
chartCPU.ChartAreas.Add(chartArea1);
|
panelFans.Controls.Add(chartGPU);
|
||||||
chartCPU.Location = new Point(390, 28);
|
panelFans.Controls.Add(buttonReset);
|
||||||
chartCPU.Margin = new Padding(4, 2, 4, 2);
|
panelFans.Controls.Add(buttonApply);
|
||||||
chartCPU.Name = "chartCPU";
|
panelFans.Controls.Add(chartCPU);
|
||||||
chartCPU.Size = new Size(832, 436);
|
panelFans.Dock = DockStyle.Left;
|
||||||
chartCPU.TabIndex = 0;
|
panelFans.Location = new Point(363, 0);
|
||||||
chartCPU.Text = "chartCPU";
|
panelFans.Margin = new Padding(10);
|
||||||
|
panelFans.MinimumSize = new Size(868, 1089);
|
||||||
|
panelFans.Name = "panelFans";
|
||||||
|
panelFans.Padding = new Padding(10);
|
||||||
|
panelFans.Size = new Size(872, 1089);
|
||||||
|
panelFans.TabIndex = 12;
|
||||||
//
|
//
|
||||||
// buttonApply
|
// checkAuto
|
||||||
//
|
//
|
||||||
buttonApply.Location = new Point(946, 952);
|
checkAuto.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonApply.Margin = new Padding(4, 2, 4, 2);
|
checkAuto.AutoSize = true;
|
||||||
buttonApply.Name = "buttonApply";
|
checkAuto.Location = new Point(584, 981);
|
||||||
buttonApply.Size = new Size(274, 44);
|
checkAuto.Margin = new Padding(4, 2, 4, 2);
|
||||||
buttonApply.TabIndex = 1;
|
checkAuto.Name = "checkAuto";
|
||||||
buttonApply.Text = "Apply Fan Curve";
|
checkAuto.Size = new Size(165, 36);
|
||||||
buttonApply.UseVisualStyleBackColor = true;
|
checkAuto.TabIndex = 17;
|
||||||
//
|
checkAuto.Text = "Auto Apply";
|
||||||
// buttonReset
|
checkAuto.UseVisualStyleBackColor = true;
|
||||||
//
|
|
||||||
buttonReset.Location = new Point(390, 952);
|
|
||||||
buttonReset.Margin = new Padding(4, 2, 4, 2);
|
|
||||||
buttonReset.Name = "buttonReset";
|
|
||||||
buttonReset.Size = new Size(274, 44);
|
|
||||||
buttonReset.TabIndex = 2;
|
|
||||||
buttonReset.Text = "Factory Defaults";
|
|
||||||
buttonReset.UseVisualStyleBackColor = true;
|
|
||||||
//
|
//
|
||||||
// chartGPU
|
// chartGPU
|
||||||
//
|
//
|
||||||
chartArea2.Name = "ChartArea1";
|
chartGPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
chartGPU.ChartAreas.Add(chartArea2);
|
chartArea5.Name = "ChartArea1";
|
||||||
chartGPU.Location = new Point(390, 480);
|
chartGPU.ChartAreas.Add(chartArea5);
|
||||||
|
chartGPU.Location = new Point(22, 502);
|
||||||
chartGPU.Margin = new Padding(4, 2, 4, 2);
|
chartGPU.Margin = new Padding(4, 2, 4, 2);
|
||||||
chartGPU.Name = "chartGPU";
|
chartGPU.Name = "chartGPU";
|
||||||
chartGPU.Size = new Size(832, 450);
|
chartGPU.Size = new Size(810, 460);
|
||||||
chartGPU.TabIndex = 3;
|
chartGPU.TabIndex = 16;
|
||||||
chartGPU.Text = "chart1";
|
chartGPU.Text = "chart1";
|
||||||
//
|
//
|
||||||
// groupBox1
|
// buttonReset
|
||||||
//
|
//
|
||||||
groupBox1.Controls.Add(labelApplied);
|
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
groupBox1.Controls.Add(pictureFine);
|
buttonReset.Location = new Point(22, 1025);
|
||||||
groupBox1.Controls.Add(labelInfo);
|
buttonReset.Margin = new Padding(4, 2, 4, 2);
|
||||||
groupBox1.Controls.Add(labelCPU);
|
buttonReset.Name = "buttonReset";
|
||||||
groupBox1.Controls.Add(labelTotal);
|
buttonReset.Size = new Size(231, 44);
|
||||||
groupBox1.Controls.Add(label2);
|
buttonReset.TabIndex = 15;
|
||||||
groupBox1.Controls.Add(label1);
|
buttonReset.Text = "Factory Defaults";
|
||||||
groupBox1.Controls.Add(trackCPU);
|
buttonReset.UseVisualStyleBackColor = true;
|
||||||
groupBox1.Controls.Add(trackTotal);
|
//
|
||||||
groupBox1.Location = new Point(12, 12);
|
// buttonApply
|
||||||
groupBox1.Margin = new Padding(4, 2, 4, 2);
|
//
|
||||||
groupBox1.Name = "groupBox1";
|
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
groupBox1.Padding = new Padding(6, 4, 6, 4);
|
buttonApply.Location = new Point(584, 1025);
|
||||||
groupBox1.Size = new Size(356, 918);
|
buttonApply.Margin = new Padding(4, 2, 4, 2);
|
||||||
groupBox1.TabIndex = 4;
|
buttonApply.Name = "buttonApply";
|
||||||
groupBox1.TabStop = false;
|
buttonApply.Size = new Size(248, 44);
|
||||||
groupBox1.Text = "Power Limits (PPT)";
|
buttonApply.TabIndex = 14;
|
||||||
|
buttonApply.Text = "Apply Fan Curve";
|
||||||
|
buttonApply.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// chartCPU
|
||||||
|
//
|
||||||
|
chartCPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
chartArea6.Name = "ChartArea1";
|
||||||
|
chartCPU.ChartAreas.Add(chartArea6);
|
||||||
|
chartCPU.Location = new Point(22, 21);
|
||||||
|
chartCPU.Margin = new Padding(10);
|
||||||
|
chartCPU.Name = "chartCPU";
|
||||||
|
chartCPU.Size = new Size(810, 460);
|
||||||
|
chartCPU.TabIndex = 13;
|
||||||
|
chartCPU.Text = "chartCPU";
|
||||||
|
//
|
||||||
|
// panelPower
|
||||||
|
//
|
||||||
|
panelPower.Controls.Add(labelPowerLimits);
|
||||||
|
panelPower.Controls.Add(checkApplyPower);
|
||||||
|
panelPower.Controls.Add(buttonApplyPower);
|
||||||
|
panelPower.Controls.Add(panelCPU);
|
||||||
|
panelPower.Controls.Add(panelTotal);
|
||||||
|
panelPower.Controls.Add(labelApplied);
|
||||||
|
panelPower.Controls.Add(pictureFine);
|
||||||
|
panelPower.Controls.Add(labelInfo);
|
||||||
|
panelPower.Dock = DockStyle.Left;
|
||||||
|
panelPower.Location = new Point(0, 0);
|
||||||
|
panelPower.Name = "panelPower";
|
||||||
|
panelPower.Size = new Size(363, 1089);
|
||||||
|
panelPower.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// labelPowerLimits
|
||||||
|
//
|
||||||
|
labelPowerLimits.AutoSize = true;
|
||||||
|
labelPowerLimits.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
|
labelPowerLimits.Location = new Point(23, 15);
|
||||||
|
labelPowerLimits.Name = "labelPowerLimits";
|
||||||
|
labelPowerLimits.Size = new Size(229, 32);
|
||||||
|
labelPowerLimits.TabIndex = 26;
|
||||||
|
labelPowerLimits.Text = "Power Limits (PPT)";
|
||||||
|
//
|
||||||
|
// checkApplyPower
|
||||||
|
//
|
||||||
|
checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
checkApplyPower.AutoSize = true;
|
||||||
|
checkApplyPower.Location = new Point(17, 981);
|
||||||
|
checkApplyPower.Margin = new Padding(4, 2, 4, 2);
|
||||||
|
checkApplyPower.Name = "checkApplyPower";
|
||||||
|
checkApplyPower.Size = new Size(165, 36);
|
||||||
|
checkApplyPower.TabIndex = 25;
|
||||||
|
checkApplyPower.Text = "Auto Apply";
|
||||||
|
checkApplyPower.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonApplyPower
|
||||||
|
//
|
||||||
|
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
buttonApplyPower.Location = new Point(17, 1025);
|
||||||
|
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
|
||||||
|
buttonApplyPower.Name = "buttonApplyPower";
|
||||||
|
buttonApplyPower.Size = new Size(321, 44);
|
||||||
|
buttonApplyPower.TabIndex = 24;
|
||||||
|
buttonApplyPower.Text = "Apply Power Limits";
|
||||||
|
buttonApplyPower.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// panelCPU
|
||||||
|
//
|
||||||
|
panelCPU.Controls.Add(labelCPU);
|
||||||
|
panelCPU.Controls.Add(label2);
|
||||||
|
panelCPU.Controls.Add(trackCPU);
|
||||||
|
panelCPU.Location = new Point(184, 89);
|
||||||
|
panelCPU.Name = "panelCPU";
|
||||||
|
panelCPU.Size = new Size(160, 510);
|
||||||
|
panelCPU.TabIndex = 23;
|
||||||
|
//
|
||||||
|
// labelCPU
|
||||||
|
//
|
||||||
|
labelCPU.AutoSize = true;
|
||||||
|
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
|
labelCPU.Location = new Point(43, 41);
|
||||||
|
labelCPU.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
labelCPU.Name = "labelCPU";
|
||||||
|
labelCPU.Size = new Size(61, 32);
|
||||||
|
labelCPU.TabIndex = 13;
|
||||||
|
labelCPU.Text = "CPU";
|
||||||
|
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(45, 7);
|
||||||
|
label2.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(58, 32);
|
||||||
|
label2.TabIndex = 12;
|
||||||
|
label2.Text = "CPU";
|
||||||
|
label2.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// trackCPU
|
||||||
|
//
|
||||||
|
trackCPU.Location = new Point(47, 89);
|
||||||
|
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(90, 416);
|
||||||
|
trackCPU.TabIndex = 11;
|
||||||
|
trackCPU.TickFrequency = 5;
|
||||||
|
trackCPU.Value = 80;
|
||||||
|
//
|
||||||
|
// panelTotal
|
||||||
|
//
|
||||||
|
panelTotal.Controls.Add(labelTotal);
|
||||||
|
panelTotal.Controls.Add(label1);
|
||||||
|
panelTotal.Controls.Add(trackTotal);
|
||||||
|
panelTotal.Location = new Point(17, 89);
|
||||||
|
panelTotal.Name = "panelTotal";
|
||||||
|
panelTotal.Size = new Size(160, 511);
|
||||||
|
panelTotal.TabIndex = 22;
|
||||||
|
//
|
||||||
|
// labelTotal
|
||||||
|
//
|
||||||
|
labelTotal.AutoSize = true;
|
||||||
|
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||||
|
labelTotal.Location = new Point(46, 41);
|
||||||
|
labelTotal.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
labelTotal.Name = "labelTotal";
|
||||||
|
labelTotal.Size = new Size(70, 32);
|
||||||
|
labelTotal.TabIndex = 12;
|
||||||
|
labelTotal.Text = "Total";
|
||||||
|
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(48, 7);
|
||||||
|
label1.Margin = new Padding(4, 0, 4, 0);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(65, 32);
|
||||||
|
label1.TabIndex = 11;
|
||||||
|
label1.Text = "Total";
|
||||||
|
label1.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// trackTotal
|
||||||
|
//
|
||||||
|
trackTotal.Location = new Point(44, 89);
|
||||||
|
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(90, 416);
|
||||||
|
trackTotal.TabIndex = 10;
|
||||||
|
trackTotal.TickFrequency = 5;
|
||||||
|
trackTotal.TickStyle = TickStyle.TopLeft;
|
||||||
|
trackTotal.Value = 125;
|
||||||
//
|
//
|
||||||
// labelApplied
|
// labelApplied
|
||||||
//
|
//
|
||||||
labelApplied.AutoSize = true;
|
labelApplied.AutoSize = true;
|
||||||
labelApplied.ForeColor = Color.Tomato;
|
labelApplied.ForeColor = Color.Tomato;
|
||||||
labelApplied.Location = new Point(16, 36);
|
labelApplied.Location = new Point(23, 51);
|
||||||
labelApplied.Margin = new Padding(4, 0, 4, 0);
|
labelApplied.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelApplied.Name = "labelApplied";
|
labelApplied.Name = "labelApplied";
|
||||||
labelApplied.Size = new Size(143, 32);
|
labelApplied.Size = new Size(143, 32);
|
||||||
labelApplied.TabIndex = 13;
|
labelApplied.TabIndex = 21;
|
||||||
labelApplied.Text = "Not Applied";
|
labelApplied.Text = "Not Applied";
|
||||||
//
|
//
|
||||||
// pictureFine
|
// pictureFine
|
||||||
@@ -132,170 +294,80 @@
|
|||||||
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
|
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
|
||||||
pictureFine.Image = Properties.Resources.everything_is_fine_itsfine;
|
pictureFine.Image = Properties.Resources.everything_is_fine_itsfine;
|
||||||
pictureFine.Location = new Point(10, 682);
|
pictureFine.Location = new Point(17, 694);
|
||||||
pictureFine.Margin = new Padding(4, 2, 4, 2);
|
pictureFine.Margin = new Padding(4, 2, 4, 2);
|
||||||
pictureFine.Name = "pictureFine";
|
pictureFine.Name = "pictureFine";
|
||||||
pictureFine.Size = new Size(336, 226);
|
pictureFine.Size = new Size(327, 254);
|
||||||
pictureFine.SizeMode = PictureBoxSizeMode.Zoom;
|
pictureFine.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
pictureFine.TabIndex = 12;
|
pictureFine.TabIndex = 20;
|
||||||
pictureFine.TabStop = false;
|
pictureFine.TabStop = false;
|
||||||
pictureFine.Visible = false;
|
pictureFine.Visible = false;
|
||||||
//
|
//
|
||||||
// labelInfo
|
// labelInfo
|
||||||
//
|
//
|
||||||
labelInfo.AutoSize = true;
|
labelInfo.Location = new Point(17, 603);
|
||||||
labelInfo.Dock = DockStyle.Bottom;
|
|
||||||
labelInfo.Location = new Point(6, 882);
|
|
||||||
labelInfo.Margin = new Padding(4, 0, 4, 0);
|
labelInfo.Margin = new Padding(4, 0, 4, 0);
|
||||||
labelInfo.Name = "labelInfo";
|
labelInfo.Name = "labelInfo";
|
||||||
labelInfo.Size = new Size(65, 32);
|
labelInfo.Size = new Size(327, 371);
|
||||||
labelInfo.TabIndex = 11;
|
labelInfo.TabIndex = 19;
|
||||||
labelInfo.Text = "label";
|
labelInfo.Text = "label";
|
||||||
//
|
//
|
||||||
// labelCPU
|
|
||||||
//
|
|
||||||
labelCPU.AutoSize = true;
|
|
||||||
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
|
||||||
labelCPU.Location = new Point(212, 118);
|
|
||||||
labelCPU.Margin = new Padding(4, 0, 4, 0);
|
|
||||||
labelCPU.Name = "labelCPU";
|
|
||||||
labelCPU.Size = new Size(61, 32);
|
|
||||||
labelCPU.TabIndex = 10;
|
|
||||||
labelCPU.Text = "CPU";
|
|
||||||
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// labelTotal
|
|
||||||
//
|
|
||||||
labelTotal.AutoSize = true;
|
|
||||||
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
|
||||||
labelTotal.Location = new Point(42, 118);
|
|
||||||
labelTotal.Margin = new Padding(4, 0, 4, 0);
|
|
||||||
labelTotal.Name = "labelTotal";
|
|
||||||
labelTotal.Size = new Size(70, 32);
|
|
||||||
labelTotal.TabIndex = 9;
|
|
||||||
labelTotal.Text = "Total";
|
|
||||||
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(216, 86);
|
|
||||||
label2.Margin = new Padding(4, 0, 4, 0);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(58, 32);
|
|
||||||
label2.TabIndex = 8;
|
|
||||||
label2.Text = "CPU";
|
|
||||||
label2.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(44, 86);
|
|
||||||
label1.Margin = new Padding(4, 0, 4, 0);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(65, 32);
|
|
||||||
label1.TabIndex = 7;
|
|
||||||
label1.Text = "Total";
|
|
||||||
label1.TextAlign = ContentAlignment.MiddleCenter;
|
|
||||||
//
|
|
||||||
// trackCPU
|
|
||||||
//
|
|
||||||
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(90, 416);
|
|
||||||
trackCPU.TabIndex = 6;
|
|
||||||
trackCPU.TickFrequency = 5;
|
|
||||||
trackCPU.Value = 80;
|
|
||||||
//
|
|
||||||
// trackTotal
|
|
||||||
//
|
|
||||||
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(90, 416);
|
|
||||||
trackTotal.TabIndex = 5;
|
|
||||||
trackTotal.TickFrequency = 5;
|
|
||||||
trackTotal.TickStyle = TickStyle.TopLeft;
|
|
||||||
trackTotal.Value = 125;
|
|
||||||
//
|
|
||||||
// buttonApplyPower
|
|
||||||
//
|
|
||||||
buttonApplyPower.Location = new Point(16, 952);
|
|
||||||
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
|
|
||||||
buttonApplyPower.Name = "buttonApplyPower";
|
|
||||||
buttonApplyPower.Size = new Size(352, 44);
|
|
||||||
buttonApplyPower.TabIndex = 11;
|
|
||||||
buttonApplyPower.Text = "Apply Power Limits";
|
|
||||||
buttonApplyPower.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkAuto
|
|
||||||
//
|
|
||||||
checkAuto.AutoSize = true;
|
|
||||||
checkAuto.Location = new Point(762, 958);
|
|
||||||
checkAuto.Margin = new Padding(4, 2, 4, 2);
|
|
||||||
checkAuto.Name = "checkAuto";
|
|
||||||
checkAuto.Size = new Size(165, 36);
|
|
||||||
checkAuto.TabIndex = 12;
|
|
||||||
checkAuto.Text = "Auto Apply";
|
|
||||||
checkAuto.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// Fans
|
// Fans
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||||
AutoScaleMode = AutoScaleMode.Dpi;
|
AutoScaleMode = AutoScaleMode.Dpi;
|
||||||
AutoSize = true;
|
AutoSize = true;
|
||||||
ClientSize = new Size(1242, 1020);
|
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
Controls.Add(checkAuto);
|
ClientSize = new Size(1220, 1089);
|
||||||
Controls.Add(buttonApplyPower);
|
Controls.Add(panelFans);
|
||||||
Controls.Add(groupBox1);
|
Controls.Add(panelPower);
|
||||||
Controls.Add(chartGPU);
|
|
||||||
Controls.Add(buttonReset);
|
|
||||||
Controls.Add(buttonApply);
|
|
||||||
Controls.Add(chartCPU);
|
|
||||||
Margin = new Padding(4, 2, 4, 2);
|
Margin = new Padding(4, 2, 4, 2);
|
||||||
MaximizeBox = false;
|
MaximizeBox = false;
|
||||||
MdiChildrenMinimizedAnchorBottom = false;
|
MdiChildrenMinimizedAnchorBottom = false;
|
||||||
MinimizeBox = false;
|
MinimizeBox = false;
|
||||||
|
MinimumSize = new Size(0, 1160);
|
||||||
Name = "Fans";
|
Name = "Fans";
|
||||||
ShowIcon = false;
|
ShowIcon = false;
|
||||||
ShowInTaskbar = false;
|
ShowInTaskbar = false;
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Fans and Power";
|
Text = "Fans and Power";
|
||||||
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
|
panelFans.ResumeLayout(false);
|
||||||
|
panelFans.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
|
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
|
||||||
groupBox1.ResumeLayout(false);
|
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
|
||||||
groupBox1.PerformLayout();
|
panelPower.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)pictureFine).EndInit();
|
panelPower.PerformLayout();
|
||||||
|
panelCPU.ResumeLayout(false);
|
||||||
|
panelCPU.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackCPU).EndInit();
|
((System.ComponentModel.ISupportInitialize)trackCPU).EndInit();
|
||||||
|
panelTotal.ResumeLayout(false);
|
||||||
|
panelTotal.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
|
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureFine).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
private Panel panelFans;
|
||||||
private System.Windows.Forms.DataVisualization.Charting.Chart chartCPU;
|
|
||||||
private Button buttonApply;
|
|
||||||
private Button buttonReset;
|
|
||||||
private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU;
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private Label labelCPU;
|
|
||||||
private Label labelTotal;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
private TrackBar trackCPU;
|
|
||||||
private TrackBar trackTotal;
|
|
||||||
private Button buttonApplyPower;
|
|
||||||
private Label labelInfo;
|
|
||||||
private PictureBox pictureFine;
|
|
||||||
private Label labelApplied;
|
|
||||||
private CheckBox checkAuto;
|
private CheckBox checkAuto;
|
||||||
|
private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU;
|
||||||
|
private Button buttonReset;
|
||||||
|
private Button buttonApply;
|
||||||
|
private System.Windows.Forms.DataVisualization.Charting.Chart chartCPU;
|
||||||
|
private Panel panelPower;
|
||||||
|
private CheckBox checkApplyPower;
|
||||||
|
private Button buttonApplyPower;
|
||||||
|
private Panel panelCPU;
|
||||||
|
private Label labelCPU;
|
||||||
|
private Label label2;
|
||||||
|
private TrackBar trackCPU;
|
||||||
|
private Panel panelTotal;
|
||||||
|
private Label labelTotal;
|
||||||
|
private Label label1;
|
||||||
|
private TrackBar trackTotal;
|
||||||
|
private Label labelApplied;
|
||||||
|
private PictureBox pictureFine;
|
||||||
|
private Label labelInfo;
|
||||||
|
private Label labelPowerLimits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
97
Fans.cs
97
Fans.cs
@@ -103,25 +103,30 @@ namespace GHelper
|
|||||||
buttonApplyPower.Click += ButtonApplyPower_Click;
|
buttonApplyPower.Click += ButtonApplyPower_Click;
|
||||||
|
|
||||||
checkAuto.Click += CheckAuto_Click;
|
checkAuto.Click += CheckAuto_Click;
|
||||||
|
checkApplyPower.Click += CheckApplyPower_Click;
|
||||||
|
|
||||||
//labelInfo.MaximumSize = new Size(280, 0);
|
//labelInfo.MaximumSize = new Size(280, 0);
|
||||||
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nValues will be applied\nonly after you click 'Apply'\nand reset after performance\nmode changes.\n\nUse carefully and\non your own risk!";
|
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nUse carefully and\non your own risk!";
|
||||||
|
|
||||||
LoadFans();
|
InitFans();
|
||||||
VisualisePower(true);
|
InitPower();
|
||||||
|
|
||||||
Shown += Fans_Shown;
|
Shown += Fans_Shown;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckApplyPower_Click(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is null) return;
|
||||||
|
CheckBox chk = (CheckBox)sender;
|
||||||
|
Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
private void CheckAuto_Click(object? sender, EventArgs e)
|
private void CheckAuto_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is null)
|
if (sender is null) return;
|
||||||
return;
|
|
||||||
|
|
||||||
CheckBox chk = (CheckBox)sender;
|
CheckBox chk = (CheckBox)sender;
|
||||||
|
Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
||||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), chk.Checked ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
|
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
|
||||||
@@ -135,38 +140,31 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ButtonApplyPower_Click(object? sender, EventArgs e)
|
private void ButtonApplyPower_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
int limit_total = trackTotal.Value;
|
Program.settingsForm.SetPower();
|
||||||
int limit_cpu = trackCPU.Value;
|
ApplyLabel(true);
|
||||||
|
|
||||||
Program.config.setConfig("limit_total", limit_total);
|
|
||||||
Program.config.setConfig("limit_cpu", limit_cpu);
|
|
||||||
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
|
||||||
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUA2, limit_cpu);
|
|
||||||
|
|
||||||
labelApplied.ForeColor = Color.Blue;
|
|
||||||
labelApplied.Text = "Applied";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VisualisePower(bool init = false)
|
public void InitPower(bool changed = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
panelPower.Visible = (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0);
|
||||||
|
panelCPU.Visible = (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0);
|
||||||
|
|
||||||
int limit_total;
|
int limit_total;
|
||||||
int limit_cpu;
|
int limit_cpu;
|
||||||
|
bool apply = Program.config.getConfigPerf("auto_apply_power") == 1;
|
||||||
|
|
||||||
if (init)
|
if (changed)
|
||||||
{
|
|
||||||
limit_total = Program.config.getConfig("limit_total");
|
|
||||||
limit_cpu = Program.config.getConfig("limit_cpu");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
limit_total = trackTotal.Value;
|
limit_total = trackTotal.Value;
|
||||||
limit_cpu = trackCPU.Value;
|
limit_cpu = trackCPU.Value;
|
||||||
|
ApplyLabel(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
limit_total = Program.config.getConfigPerf("limit_total");
|
||||||
|
limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||||
|
ApplyLabel(apply);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit_total < 0) limit_total = DefaultTotal;
|
if (limit_total < 0) limit_total = DefaultTotal;
|
||||||
@@ -176,35 +174,48 @@ namespace GHelper
|
|||||||
if (limit_cpu < 0) limit_cpu = DefaultCPU;
|
if (limit_cpu < 0) limit_cpu = DefaultCPU;
|
||||||
if (limit_cpu > MaxCPU) limit_cpu = MaxCPU;
|
if (limit_cpu > MaxCPU) limit_cpu = MaxCPU;
|
||||||
if (limit_cpu < MinCPU) limit_cpu = MinCPU;
|
if (limit_cpu < MinCPU) limit_cpu = MinCPU;
|
||||||
|
|
||||||
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
||||||
|
|
||||||
trackTotal.Value = limit_total;
|
trackTotal.Value = limit_total;
|
||||||
trackCPU.Value = limit_cpu;
|
trackCPU.Value = limit_cpu;
|
||||||
|
checkApplyPower.Checked = apply;
|
||||||
|
|
||||||
labelTotal.Text = trackTotal.Value.ToString() + "W";
|
labelTotal.Text = trackTotal.Value.ToString() + "W";
|
||||||
labelCPU.Text = trackCPU.Value.ToString() + "W";
|
labelCPU.Text = trackCPU.Value.ToString() + "W";
|
||||||
|
|
||||||
pictureFine.Visible = (limit_cpu > 85 || limit_total > 145);
|
pictureFine.Visible = (limit_cpu > 85 || limit_total > 145);
|
||||||
|
|
||||||
|
Program.config.setConfigPerf("limit_total", limit_total);
|
||||||
|
Program.config.setConfigPerf("limit_cpu", limit_cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void TrackTotal_Scroll(object? sender, EventArgs e)
|
private void TrackTotal_Scroll(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
VisualisePower();
|
InitPower(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TrackCPU_Scroll(object? sender, EventArgs e)
|
private void TrackCPU_Scroll(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
VisualisePower();
|
InitPower(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetApplyLabel()
|
|
||||||
|
public void ApplyLabel(bool applied = false)
|
||||||
{
|
{
|
||||||
labelApplied.ForeColor = Color.Red;
|
if (applied)
|
||||||
labelApplied.Text = "Not Applied";
|
{
|
||||||
|
labelApplied.ForeColor = Color.Blue;
|
||||||
|
labelApplied.Text = "Applied";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
labelApplied.ForeColor = Color.Red;
|
||||||
|
labelApplied.Text = "Not Applied";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFans()
|
public void InitFans()
|
||||||
{
|
{
|
||||||
|
|
||||||
SetChart(chartCPU, 0);
|
SetChart(chartCPU, 0);
|
||||||
@@ -213,7 +224,7 @@ namespace GHelper
|
|||||||
LoadProfile(seriesCPU, 0);
|
LoadProfile(seriesCPU, 0);
|
||||||
LoadProfile(seriesGPU, 1);
|
LoadProfile(seriesGPU, 1);
|
||||||
|
|
||||||
int auto_apply = Program.config.getConfig("auto_apply_" + Program.config.getConfig("performance_mode"));
|
int auto_apply = Program.config.getConfigPerf("auto_apply");
|
||||||
|
|
||||||
checkAuto.Checked = (auto_apply == 1);
|
checkAuto.Checked = (auto_apply == 1);
|
||||||
|
|
||||||
@@ -275,15 +286,19 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ButtonReset_Click(object? sender, EventArgs e)
|
private void ButtonReset_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
LoadProfile(seriesCPU, 0, 1);
|
LoadProfile(seriesCPU, 0, 1);
|
||||||
LoadProfile(seriesGPU, 1, 1);
|
LoadProfile(seriesGPU, 1, 1);
|
||||||
|
|
||||||
checkAuto.Checked = false;
|
checkAuto.Checked = false;
|
||||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), 0);
|
checkApplyPower.Checked = false;
|
||||||
|
|
||||||
|
Program.config.setConfigPerf("auto_apply", 0);
|
||||||
|
Program.config.setConfigPerf("auto_apply_power", 0);
|
||||||
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
|
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
|
||||||
|
|
||||||
ResetApplyLabel();
|
ApplyLabel(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<AssemblyName>GHelper</AssemblyName>
|
<AssemblyName>GHelper</AssemblyName>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AssemblyVersion>0.16</AssemblyVersion>
|
<AssemblyVersion>0.18</AssemblyVersion>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
123
NativeMethods.cs
123
NativeMethods.cs
@@ -1,5 +1,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Management;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
public class NativeMethods
|
public class NativeMethods
|
||||||
{
|
{
|
||||||
@@ -160,10 +162,42 @@ public class NativeMethods
|
|||||||
string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
|
string lpszDeviceName, ref DEVMODE lpDevMode, IntPtr hwnd,
|
||||||
DisplaySettingsFlags dwflags, IntPtr lParam);
|
DisplaySettingsFlags dwflags, IntPtr lParam);
|
||||||
|
|
||||||
|
// ENUM DISPLAYS
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
static extern bool EnumDisplayDevicesA(string lpDevice, uint iDevNum, ref DISPLAY_DEVICE lpDisplayDevice, uint dwFlags);
|
||||||
|
|
||||||
public const int ENUM_CURRENT_SETTINGS = -1;
|
[Flags()]
|
||||||
|
public enum DisplayDeviceStateFlags : int
|
||||||
|
{
|
||||||
|
AttachedToDesktop = 0x1,
|
||||||
|
MultiDriver = 0x2,
|
||||||
|
PrimaryDevice = 0x4,
|
||||||
|
MirroringDriver = 0x8,
|
||||||
|
VGACompatible = 0x10,
|
||||||
|
Removable = 0x20,
|
||||||
|
ModesPruned = 0x8000000,
|
||||||
|
Remote = 0x4000000,
|
||||||
|
Disconnect = 0x2000000
|
||||||
|
}
|
||||||
|
|
||||||
public const string laptopScreenName = "\\\\.\\DISPLAY1";
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
|
public struct DISPLAY_DEVICE
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.U4)]
|
||||||
|
public int cb;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
||||||
|
public string DeviceName;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string DeviceString;
|
||||||
|
[MarshalAs(UnmanagedType.U4)]
|
||||||
|
public DisplayDeviceStateFlags StateFlags;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string DeviceID;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string DeviceKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
|
||||||
public static DEVMODE CreateDevmode()
|
public static DEVMODE CreateDevmode()
|
||||||
{
|
{
|
||||||
@@ -174,34 +208,91 @@ public class NativeMethods
|
|||||||
return dm;
|
return dm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Screen FindLaptopScreen()
|
public const int ENUM_CURRENT_SETTINGS = -1;
|
||||||
{
|
public const string laptopScreenName = "\\\\.\\DISPLAY1";
|
||||||
var screens = Screen.AllScreens;
|
|
||||||
Screen laptopScreen = null;
|
|
||||||
|
|
||||||
foreach (var screen in screens)
|
public static string FindLaptopScreen()
|
||||||
|
{
|
||||||
|
string laptopScreen = null;
|
||||||
|
|
||||||
|
DISPLAY_DEVICE d = new DISPLAY_DEVICE();
|
||||||
|
d.cb = Marshal.SizeOf(d);
|
||||||
|
|
||||||
|
List<string> activeScreens = new List<string>();
|
||||||
|
int counter = 0;
|
||||||
|
int deviceNum = -1;
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (screen.DeviceName == laptopScreenName)
|
var searcherActive = new ManagementObjectSearcher(@"\\.\root\wmi", "SELECT * FROM WmiMonitorBasicDisplayParams");
|
||||||
|
var resultsActive = searcherActive.Get();
|
||||||
|
foreach (var result in resultsActive)
|
||||||
{
|
{
|
||||||
laptopScreen = screen;
|
activeScreens.Add(result["InstanceName"].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var searcher = new ManagementObjectSearcher(@"\\.\root\wmi", "SELECT * FROM WmiMonitorConnectionParams");
|
||||||
|
var results = searcher.Get();
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var result in results)
|
||||||
|
{
|
||||||
|
long technology;
|
||||||
|
long.TryParse(result["VideoOutputTechnology"].ToString(), out technology);
|
||||||
|
string instanceName = result["InstanceName"].ToString();
|
||||||
|
|
||||||
|
if (technology == 0x80000000 && activeScreens.Contains(instanceName))
|
||||||
|
{
|
||||||
|
deviceNum = counter;
|
||||||
|
//Debug.WriteLine(result["InstanceName"]);
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
} catch
|
||||||
|
{
|
||||||
|
Debug.WriteLine("Failed to detect built in display");
|
||||||
|
deviceNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (laptopScreen is null) return null;
|
counter = 0;
|
||||||
else return laptopScreen;
|
for (uint id = 0; EnumDisplayDevicesA(null, id, ref d, 0); id++)
|
||||||
|
{
|
||||||
|
if ((d.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
|
||||||
|
{
|
||||||
|
//Debug.WriteLine(d.DeviceID);
|
||||||
|
//Debug.WriteLine(d.DeviceName);
|
||||||
|
if (counter == deviceNum)
|
||||||
|
{
|
||||||
|
laptopScreen = d.DeviceName;
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mismatch between active screens and enumerated screens, fallback to old method
|
||||||
|
if (counter != activeScreens.Count)
|
||||||
|
{
|
||||||
|
laptopScreen = null;
|
||||||
|
foreach (var screen in Screen.AllScreens)
|
||||||
|
if (screen.DeviceName == laptopScreenName)
|
||||||
|
laptopScreen = screen.DeviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return laptopScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetRefreshRate()
|
public static int GetRefreshRate()
|
||||||
{
|
{
|
||||||
DEVMODE dm = CreateDevmode();
|
DEVMODE dm = CreateDevmode();
|
||||||
|
|
||||||
Screen laptopScreen = FindLaptopScreen();
|
string laptopScreen = FindLaptopScreen();
|
||||||
int frequency = -1;
|
int frequency = -1;
|
||||||
|
|
||||||
if (laptopScreen is null)
|
if (laptopScreen is null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
|
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
|
||||||
{
|
{
|
||||||
frequency = dm.dmDisplayFrequency;
|
frequency = dm.dmDisplayFrequency;
|
||||||
}
|
}
|
||||||
@@ -212,15 +303,15 @@ public class NativeMethods
|
|||||||
public static int SetRefreshRate(int frequency = 120)
|
public static int SetRefreshRate(int frequency = 120)
|
||||||
{
|
{
|
||||||
DEVMODE dm = CreateDevmode();
|
DEVMODE dm = CreateDevmode();
|
||||||
Screen laptopScreen = FindLaptopScreen();
|
string laptopScreen = FindLaptopScreen();
|
||||||
|
|
||||||
if (laptopScreen is null)
|
if (laptopScreen is null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen.DeviceName, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
|
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
|
||||||
{
|
{
|
||||||
dm.dmDisplayFrequency = frequency;
|
dm.dmDisplayFrequency = frequency;
|
||||||
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen.DeviceName, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
|
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
Program.cs
11
Program.cs
@@ -96,13 +96,16 @@ namespace GHelper
|
|||||||
private static void SetAutoModes()
|
private static void SetAutoModes()
|
||||||
{
|
{
|
||||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
settingsForm.AutoGPUMode(isPlugged);
|
|
||||||
settingsForm.AutoScreen(isPlugged);
|
|
||||||
settingsForm.AutoPerformance(isPlugged);
|
|
||||||
|
|
||||||
settingsForm.SetMatrix(isPlugged);
|
Debug.WriteLine(isPlugged.ToString());
|
||||||
|
|
||||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||||
|
settingsForm.AutoPerformance(isPlugged);
|
||||||
|
settingsForm.AutoScreen(isPlugged);
|
||||||
|
|
||||||
|
settingsForm.AutoGPUMode(isPlugged);
|
||||||
|
settingsForm.SetMatrix(isPlugged);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
|
|||||||
51
Settings.cs
51
Settings.cs
@@ -97,6 +97,8 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
|
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is null) return;
|
if (sender is null) return;
|
||||||
@@ -174,9 +176,9 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string fileName = "";
|
string fileName = null;
|
||||||
|
|
||||||
Thread t = new Thread((ThreadStart)(() =>
|
Thread t = new Thread(() =>
|
||||||
{
|
{
|
||||||
OpenFileDialog of = new OpenFileDialog();
|
OpenFileDialog of = new OpenFileDialog();
|
||||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
||||||
@@ -185,18 +187,22 @@ namespace GHelper
|
|||||||
fileName = of.FileName;
|
fileName = of.FileName;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}));
|
});
|
||||||
|
|
||||||
t.SetApartmentState(ApartmentState.STA);
|
t.SetApartmentState(ApartmentState.STA);
|
||||||
t.Start();
|
t.Start();
|
||||||
t.Join();
|
t.Join();
|
||||||
|
|
||||||
Program.config.setConfig("matrix_picture", fileName);
|
if (fileName is not null)
|
||||||
SetMatrixPicture(fileName);
|
|
||||||
BeginInvoke(delegate
|
|
||||||
{
|
{
|
||||||
comboMatrixRunning.SelectedIndex = 2;
|
Program.config.setConfig("matrix_picture", fileName);
|
||||||
});
|
SetMatrixPicture(fileName);
|
||||||
|
BeginInvoke(delegate
|
||||||
|
{
|
||||||
|
comboMatrixRunning.SelectedIndex = 2;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +311,7 @@ namespace GHelper
|
|||||||
if (fans == null || fans.Text == "")
|
if (fans == null || fans.Text == "")
|
||||||
{
|
{
|
||||||
fans = new Fans();
|
fans = new Fans();
|
||||||
Debug.WriteLine("Starting fans");
|
//Debug.WriteLine("Starting fans");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fans.Visible)
|
if (fans.Visible)
|
||||||
@@ -682,6 +688,20 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetPower()
|
||||||
|
{
|
||||||
|
int limit_total = Program.config.getConfigPerf("limit_total");
|
||||||
|
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||||
|
|
||||||
|
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
||||||
|
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||||
|
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||||
|
|
||||||
|
Debug.WriteLine(limit_total.ToString() + ", " + limit_cpu.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
|
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -712,16 +732,21 @@ namespace GHelper
|
|||||||
|
|
||||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||||
|
|
||||||
if (Program.config.getConfig("auto_apply_" + PerformanceMode) == 1)
|
if (Program.config.getConfigPerf("auto_apply") == 1)
|
||||||
{
|
{
|
||||||
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
|
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
|
||||||
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
|
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Program.config.getConfigPerf("auto_apply_power") == 1)
|
||||||
|
{
|
||||||
|
SetPower();
|
||||||
|
}
|
||||||
|
|
||||||
if (fans != null && fans.Text != "")
|
if (fans != null && fans.Text != "")
|
||||||
{
|
{
|
||||||
fans.LoadFans();
|
fans.InitFans();
|
||||||
fans.ResetApplyLabel();
|
fans.InitPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notify && (oldMode != PerformanceMode))
|
if (notify && (oldMode != PerformanceMode))
|
||||||
@@ -967,7 +992,7 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetBatteryChargeLimit(int limit = 100)
|
public void SetBatteryChargeLimit(int limit)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (limit < 40 || limit > 100) return;
|
if (limit < 40 || limit > 100) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user