From cc96ca99466d02fe31a891933942cd32afedd251 Mon Sep 17 00:00:00 2001 From: seerge Date: Sun, 19 Feb 2023 21:52:01 +0100 Subject: [PATCH] Supressed crash on failed battery charge limit setting --- Program.cs | 2 ++ Settings.Designer.cs | 1 + Settings.cs | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Program.cs b/Program.cs index 1dd0ae15..eacaf52b 100644 --- a/Program.cs +++ b/Program.cs @@ -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 } } diff --git a/Settings.Designer.cs b/Settings.Designer.cs index ab022867..39efda82 100644 --- a/Settings.Designer.cs +++ b/Settings.Designer.cs @@ -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 // diff --git a/Settings.cs b/Settings.cs index a469724d..6690fd25 100644 --- a/Settings.cs +++ b/Settings.cs @@ -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,8 +126,8 @@ namespace GHelper if (apply) Aura.ApplyAura(); - - comboKeyboard.SelectedIndex = mode; + else + comboKeyboard.SelectedIndex = mode; } public void CycleAuraMode () @@ -569,7 +572,13 @@ namespace GHelper labelBatteryLimit.Text = limit.ToString() + "%"; trackBattery.Value = limit; - Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit); + try + { + Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit); + } catch + { + Debug.WriteLine("Can't set battery charge limit"); + } Program.config.setConfig("charge_limit", limit); }