Supressed crash on failed battery charge limit setting

This commit is contained in:
seerge
2023-02-19 21:52:01 +01:00
parent 15112cb5c8
commit cc96ca9946
3 changed files with 15 additions and 3 deletions

View File

@@ -596,6 +596,8 @@ namespace GHelper
settingsForm.Show();
settingsForm.Activate();
}
trayIcon.Icon = trayIcon.Icon; // refreshing icon as it get's blurred when screen resolution changes
}
}

1
Settings.Designer.cs generated
View File

@@ -488,6 +488,7 @@
this.comboKeyboard.Name = "comboKeyboard";
this.comboKeyboard.Size = new System.Drawing.Size(198, 40);
this.comboKeyboard.TabIndex = 24;
this.comboKeyboard.TabStop = false;
//
// buttonKeyboardColor
//

View File

@@ -55,6 +55,8 @@ namespace GHelper
checkScreen.CheckedChanged += checkScreen_CheckedChanged;
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
comboKeyboard.SelectedIndex = 0;
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
buttonKeyboardColor.Click += ButtonKeyboardColor_Click;
@@ -114,6 +116,7 @@ namespace GHelper
public void SetAuraMode (int mode = 0, bool apply = true)
{
if (mode > 3) mode = 0;
if (Aura.Mode == mode) return; // same mode
@@ -123,7 +126,7 @@ namespace GHelper
if (apply)
Aura.ApplyAura();
else
comboKeyboard.SelectedIndex = mode;
}
@@ -569,7 +572,13 @@ namespace GHelper
labelBatteryLimit.Text = limit.ToString() + "%";
trackBattery.Value = limit;
try
{
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
} catch
{
Debug.WriteLine("Can't set battery charge limit");
}
Program.config.setConfig("charge_limit", limit);
}