This commit is contained in:
Serge
2023-10-01 13:12:49 +02:00
parent 9f836ff356
commit 6375586ff9
5 changed files with 93 additions and 9 deletions

View File

@@ -3,6 +3,15 @@
internal class BatteryControl internal class BatteryControl
{ {
public static void SetBatteryLimitFull()
{
AppConfig.Set("charge_full", 1);
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, 100, "BatteryLimit");
Program.settingsForm.VisualiseBatteryFull();
}
public static void SetBatteryChargeLimit(int limit = -1) public static void SetBatteryChargeLimit(int limit = -1)
{ {
@@ -10,10 +19,11 @@
if (limit < 40 || limit > 100) return; if (limit < 40 || limit > 100) return;
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit"); Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit");
Program.settingsForm.VisualiseBattery(limit);
AppConfig.Set("charge_limit", limit); AppConfig.Set("charge_limit", limit);
AppConfig.Set("charge_full", 0);
Program.settingsForm.VisualiseBattery(limit);
} }
} }

View File

@@ -465,6 +465,15 @@ namespace GHelper.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to One time charge to 100%.
/// </summary>
internal static string BatteryLimitFull {
get {
return ResourceManager.GetString("BatteryLimitFull", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to BIOS and Driver Updates. /// Looks up a localized string similar to BIOS and Driver Updates.
/// </summary> /// </summary>

View File

@@ -252,6 +252,9 @@
<data name="BatteryHealth" xml:space="preserve"> <data name="BatteryHealth" xml:space="preserve">
<value>Battery Health</value> <value>Battery Health</value>
</data> </data>
<data name="BatteryLimitFull" xml:space="preserve">
<value>One time charge to 100%</value>
</data>
<data name="BiosAndDriverUpdates" xml:space="preserve"> <data name="BiosAndDriverUpdates" xml:space="preserve">
<value>BIOS and Driver Updates</value> <value>BIOS and Driver Updates</value>
</data> </data>

View File

@@ -40,6 +40,7 @@ namespace GHelper
labelMatrix = new Label(); labelMatrix = new Label();
checkMatrix = new CheckBox(); checkMatrix = new CheckBox();
panelBattery = new Panel(); panelBattery = new Panel();
buttonBatteryFull = new RButton();
sliderBattery = new Slider(); sliderBattery = new Slider();
panelBatteryTitle = new Panel(); panelBatteryTitle = new Panel();
labelBattery = new Label(); labelBattery = new Label();
@@ -278,6 +279,7 @@ namespace GHelper
// //
panelBattery.AutoSize = true; panelBattery.AutoSize = true;
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelBattery.Controls.Add(buttonBatteryFull);
panelBattery.Controls.Add(sliderBattery); panelBattery.Controls.Add(sliderBattery);
panelBattery.Controls.Add(panelBatteryTitle); panelBattery.Controls.Add(panelBatteryTitle);
panelBattery.Dock = DockStyle.Top; panelBattery.Dock = DockStyle.Top;
@@ -285,19 +287,39 @@ namespace GHelper
panelBattery.Margin = new Padding(0); panelBattery.Margin = new Padding(0);
panelBattery.Name = "panelBattery"; panelBattery.Name = "panelBattery";
panelBattery.Padding = new Padding(20, 20, 20, 10); panelBattery.Padding = new Padding(20, 20, 20, 10);
panelBattery.Size = new Size(827, 114); panelBattery.Size = new Size(827, 119);
panelBattery.TabIndex = 5; panelBattery.TabIndex = 5;
// //
// buttonBatteryFull
//
buttonBatteryFull.Activated = false;
buttonBatteryFull.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonBatteryFull.BackColor = SystemColors.ControlLight;
buttonBatteryFull.BorderColor = Color.Transparent;
buttonBatteryFull.BorderRadius = 2;
buttonBatteryFull.FlatAppearance.BorderSize = 0;
buttonBatteryFull.FlatStyle = FlatStyle.Flat;
buttonBatteryFull.Font = new Font("Segoe UI", 7.125F, FontStyle.Bold, GraphicsUnit.Point);
buttonBatteryFull.ForeColor = SystemColors.ControlDark;
buttonBatteryFull.Location = new Point(730, 66);
buttonBatteryFull.Margin = new Padding(0);
buttonBatteryFull.Name = "buttonBatteryFull";
buttonBatteryFull.Secondary = true;
buttonBatteryFull.Size = new Size(73, 36);
buttonBatteryFull.TabIndex = 41;
buttonBatteryFull.Text = "100%";
buttonBatteryFull.UseVisualStyleBackColor = false;
//
// sliderBattery // sliderBattery
// //
sliderBattery.AccessibleName = "Battery Charge Limit"; sliderBattery.AccessibleName = "Battery Charge Limit";
sliderBattery.Dock = DockStyle.Top; sliderBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
sliderBattery.Location = new Point(20, 64); sliderBattery.Location = new Point(20, 65);
sliderBattery.Margin = new Padding(4); sliderBattery.Margin = new Padding(4);
sliderBattery.Max = 100; sliderBattery.Max = 100;
sliderBattery.Min = 40; sliderBattery.Min = 40;
sliderBattery.Name = "sliderBattery"; sliderBattery.Name = "sliderBattery";
sliderBattery.Size = new Size(787, 40); sliderBattery.Size = new Size(716, 40);
sliderBattery.Step = 5; sliderBattery.Step = 5;
sliderBattery.TabIndex = 20; sliderBattery.TabIndex = 20;
sliderBattery.Text = "sliderBattery"; sliderBattery.Text = "sliderBattery";
@@ -354,7 +376,7 @@ namespace GHelper
panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelFooter.Controls.Add(tableButtons); panelFooter.Controls.Add(tableButtons);
panelFooter.Dock = DockStyle.Top; panelFooter.Dock = DockStyle.Top;
panelFooter.Location = new Point(11, 1435); panelFooter.Location = new Point(11, 1440);
panelFooter.Margin = new Padding(0); panelFooter.Margin = new Padding(0);
panelFooter.Name = "panelFooter"; panelFooter.Name = "panelFooter";
panelFooter.Padding = new Padding(20); panelFooter.Padding = new Padding(20);
@@ -1232,7 +1254,7 @@ namespace GHelper
panelVersion.Controls.Add(labelCharge); panelVersion.Controls.Add(labelCharge);
panelVersion.Controls.Add(checkStartup); panelVersion.Controls.Add(checkStartup);
panelVersion.Dock = DockStyle.Top; panelVersion.Dock = DockStyle.Top;
panelVersion.Location = new Point(11, 1379); panelVersion.Location = new Point(11, 1384);
panelVersion.Margin = new Padding(4); panelVersion.Margin = new Padding(4);
panelVersion.Name = "panelVersion"; panelVersion.Name = "panelVersion";
panelVersion.Size = new Size(827, 56); panelVersion.Size = new Size(827, 56);
@@ -1550,5 +1572,6 @@ namespace GHelper
private RButton buttonUpdates; private RButton buttonUpdates;
private Label labelCharge; private Label labelCharge;
private RButton buttonFnLock; private RButton buttonFnLock;
private RButton buttonBatteryFull;
} }
} }

View File

@@ -41,7 +41,9 @@ namespace GHelper
static long lastBatteryRefresh; static long lastBatteryRefresh;
bool isGpuSection = true; bool isGpuSection = true;
bool batteryMouseOver = false; bool batteryMouseOver = false;
bool batteryFullMouseOver = false;
public SettingsForm() public SettingsForm()
{ {
@@ -193,6 +195,10 @@ namespace GHelper
buttonPeripheral2.MouseEnter += ButtonPeripheral_MouseEnter; buttonPeripheral2.MouseEnter += ButtonPeripheral_MouseEnter;
buttonPeripheral3.MouseEnter += ButtonPeripheral_MouseEnter; buttonPeripheral3.MouseEnter += ButtonPeripheral_MouseEnter;
buttonBatteryFull.MouseEnter += ButtonBatteryFull_MouseEnter;
buttonBatteryFull.MouseLeave += ButtonBatteryFull_MouseLeave;
buttonBatteryFull.Click += ButtonBatteryFull_Click;
Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort(); Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort();
TopMost = AppConfig.Is("topmost"); TopMost = AppConfig.Is("topmost");
@@ -206,6 +212,22 @@ namespace GHelper
panelPerformance.Focus(); panelPerformance.Focus();
} }
private void ButtonBatteryFull_Click(object? sender, EventArgs e)
{
BatteryControl.SetBatteryLimitFull();
}
private void ButtonBatteryFull_MouseLeave(object? sender, EventArgs e)
{
batteryFullMouseOver = false;
RefreshSensors(true);
}
private void ButtonBatteryFull_MouseEnter(object? sender, EventArgs e)
{
batteryFullMouseOver = true;
labelCharge.Text = Properties.Strings.BatteryLimitFull;
}
private void SettingsForm_Resize(object? sender, EventArgs e) private void SettingsForm_Resize(object? sender, EventArgs e)
{ {
@@ -906,7 +928,7 @@ namespace GHelper
labelMidFan.Text = "Mid " + HardwareControl.midFan; labelMidFan.Text = "Mid " + HardwareControl.midFan;
labelBattery.Text = battery; labelBattery.Text = battery;
if (!batteryMouseOver) labelCharge.Text = charge; if (!batteryMouseOver && !batteryFullMouseOver) labelCharge.Text = charge;
//panelPerformance.AccessibleName = labelPerf.Text + " " + trayTip; //panelPerformance.AccessibleName = labelPerf.Text + " " + trayTip;
}); });
@@ -1035,7 +1057,8 @@ namespace GHelper
buttonStopGPU.Visible = true; buttonStopGPU.Visible = true;
tableGPU.ColumnCount = 3; tableGPU.ColumnCount = 3;
tableScreen.ColumnCount = 3; tableScreen.ColumnCount = 3;
} else }
else
{ {
buttonStopGPU.Visible = false; buttonStopGPU.Visible = false;
} }
@@ -1164,6 +1187,22 @@ namespace GHelper
{ {
labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%"; labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%";
sliderBattery.Value = limit; sliderBattery.Value = limit;
VisualiseBatteryFull();
}
public void VisualiseBatteryFull()
{
if (AppConfig.Is("charge_full"))
{
buttonBatteryFull.BackColor = colorStandard;
buttonBatteryFull.ForeColor = SystemColors.ControlLightLight;
}
else
{
buttonBatteryFull.BackColor = buttonSecond;
buttonBatteryFull.ForeColor = SystemColors.ControlDark;
}
} }