diff --git a/app/Battery/BatteryControl.cs b/app/Battery/BatteryControl.cs index 6698de62..82559ad6 100644 --- a/app/Battery/BatteryControl.cs +++ b/app/Battery/BatteryControl.cs @@ -3,6 +3,15 @@ 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) { @@ -10,10 +19,11 @@ if (limit < 40 || limit > 100) return; Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit"); - Program.settingsForm.VisualiseBattery(limit); AppConfig.Set("charge_limit", limit); + AppConfig.Set("charge_full", 0); + Program.settingsForm.VisualiseBattery(limit); } } diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 1c7968d8..52582931 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -465,6 +465,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to One time charge to 100%. + /// + internal static string BatteryLimitFull { + get { + return ResourceManager.GetString("BatteryLimitFull", resourceCulture); + } + } + /// /// Looks up a localized string similar to BIOS and Driver Updates. /// diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 9f2e9ca5..929abd3a 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -252,6 +252,9 @@ Battery Health + + One time charge to 100% + BIOS and Driver Updates diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 429298f7..e2be7490 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -40,6 +40,7 @@ namespace GHelper labelMatrix = new Label(); checkMatrix = new CheckBox(); panelBattery = new Panel(); + buttonBatteryFull = new RButton(); sliderBattery = new Slider(); panelBatteryTitle = new Panel(); labelBattery = new Label(); @@ -278,6 +279,7 @@ namespace GHelper // panelBattery.AutoSize = true; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelBattery.Controls.Add(buttonBatteryFull); panelBattery.Controls.Add(sliderBattery); panelBattery.Controls.Add(panelBatteryTitle); panelBattery.Dock = DockStyle.Top; @@ -285,19 +287,39 @@ namespace GHelper panelBattery.Margin = new Padding(0); panelBattery.Name = "panelBattery"; panelBattery.Padding = new Padding(20, 20, 20, 10); - panelBattery.Size = new Size(827, 114); + panelBattery.Size = new Size(827, 119); 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.AccessibleName = "Battery Charge Limit"; - sliderBattery.Dock = DockStyle.Top; - sliderBattery.Location = new Point(20, 64); + sliderBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + sliderBattery.Location = new Point(20, 65); sliderBattery.Margin = new Padding(4); sliderBattery.Max = 100; sliderBattery.Min = 40; sliderBattery.Name = "sliderBattery"; - sliderBattery.Size = new Size(787, 40); + sliderBattery.Size = new Size(716, 40); sliderBattery.Step = 5; sliderBattery.TabIndex = 20; sliderBattery.Text = "sliderBattery"; @@ -354,7 +376,7 @@ namespace GHelper panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelFooter.Controls.Add(tableButtons); panelFooter.Dock = DockStyle.Top; - panelFooter.Location = new Point(11, 1435); + panelFooter.Location = new Point(11, 1440); panelFooter.Margin = new Padding(0); panelFooter.Name = "panelFooter"; panelFooter.Padding = new Padding(20); @@ -1232,7 +1254,7 @@ namespace GHelper panelVersion.Controls.Add(labelCharge); panelVersion.Controls.Add(checkStartup); panelVersion.Dock = DockStyle.Top; - panelVersion.Location = new Point(11, 1379); + panelVersion.Location = new Point(11, 1384); panelVersion.Margin = new Padding(4); panelVersion.Name = "panelVersion"; panelVersion.Size = new Size(827, 56); @@ -1550,5 +1572,6 @@ namespace GHelper private RButton buttonUpdates; private Label labelCharge; private RButton buttonFnLock; + private RButton buttonBatteryFull; } } \ No newline at end of file diff --git a/app/Settings.cs b/app/Settings.cs index 1c56a191..4fbd9a0d 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -41,7 +41,9 @@ namespace GHelper static long lastBatteryRefresh; bool isGpuSection = true; + bool batteryMouseOver = false; + bool batteryFullMouseOver = false; public SettingsForm() { @@ -193,6 +195,10 @@ namespace GHelper buttonPeripheral2.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(); TopMost = AppConfig.Is("topmost"); @@ -206,6 +212,22 @@ namespace GHelper 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) { @@ -906,7 +928,7 @@ namespace GHelper labelMidFan.Text = "Mid " + HardwareControl.midFan; labelBattery.Text = battery; - if (!batteryMouseOver) labelCharge.Text = charge; + if (!batteryMouseOver && !batteryFullMouseOver) labelCharge.Text = charge; //panelPerformance.AccessibleName = labelPerf.Text + " " + trayTip; }); @@ -1035,7 +1057,8 @@ namespace GHelper buttonStopGPU.Visible = true; tableGPU.ColumnCount = 3; tableScreen.ColumnCount = 3; - } else + } + else { buttonStopGPU.Visible = false; } @@ -1164,6 +1187,22 @@ namespace GHelper { labelBatteryTitle.Text = Properties.Strings.BatteryChargeLimit + ": " + limit.ToString() + "%"; 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; + } + }