From 47f86d222f6b4f97bcfb550b6f558f1501e51404 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:54:09 +0200 Subject: [PATCH] Minior tweaks --- app/AnimeMatrix/AniMatrixControl.cs | 8 ++++- app/Fans.cs | 50 +++++++++++++++++++++++++---- app/Input/InputDispatcher.cs | 16 +++++++-- app/Mode/ModeControl.cs | 4 +-- 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/app/AnimeMatrix/AniMatrixControl.cs b/app/AnimeMatrix/AniMatrixControl.cs index 3b4ca4439..54e236c91 100644 --- a/app/AnimeMatrix/AniMatrixControl.cs +++ b/app/AnimeMatrix/AniMatrixControl.cs @@ -65,7 +65,13 @@ public void SetMatrix(bool wakeUp = false) StopMatrixTimer(); StopMatrixAudio(); - mat.SetProvider(); + try + { + mat.SetProvider(); + } catch (Exception ex) { + Logger.WriteLine(ex.Message); + return; + } if (wakeUp && AppConfig.ContainsModel("401")) mat.WakeUp(); diff --git a/app/Fans.cs b/app/Fans.cs index 4240652bd..83dc42a7b 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -21,6 +21,7 @@ public partial class Fans : RForm static int MinRPM, MaxRPM; static bool gpuVisible = true; + static bool fanRpm = true; const int fansMax = 100; @@ -87,6 +88,11 @@ public Fans() chartXGM.MouseMove += (sender, e) => ChartCPU_MouseMove(sender, e, AsusFan.XGM); chartXGM.MouseUp += ChartCPU_MouseUp; + chartCPU.MouseClick += ChartCPU_MouseClick; + chartGPU.MouseClick += ChartCPU_MouseClick; + chartMid.MouseClick += ChartCPU_MouseClick; + chartXGM.MouseClick += ChartCPU_MouseClick; + buttonReset.Click += ButtonReset_Click; trackA0.Maximum = AsusACPI.MaxTotal; @@ -195,6 +201,24 @@ public Fans() } + private void ChartCPU_MouseClick(object? sender, MouseEventArgs e) + { + if (sender is null) return; + Chart chart = (Chart)sender; + + HitTestResult result = chart.HitTest(e.X, e.Y); + + if ((result.ChartElementType == ChartElementType.AxisLabels || result.ChartElementType == ChartElementType.Axis) && result.Axis == chart.ChartAreas[0].AxisY) + { + fanRpm = !fanRpm; + SetAxis(chartCPU, AsusFan.CPU); + SetAxis(chartGPU, AsusFan.GPU); + if (chartMid.Visible) SetAxis(chartMid, AsusFan.Mid); + if (chartXGM.Visible) SetAxis(chartXGM, AsusFan.XGM); + } + + } + private void Fans_FormClosed(object? sender, FormClosedEventArgs e) { //Because windows charts seem to eat a lot of memory :( @@ -548,7 +572,24 @@ static string ChartPercToRPM(int percentage, AsusFan device, string unit = "") int Max = MaxRPM; if (device == AsusFan.XGM) Max = 72; - return (200 * Math.Round((float)(MinRPM * 100 + (Max - MinRPM) * percentage) / 200)).ToString() + unit; + if (fanRpm) + return (200 * Math.Round((float)(MinRPM * 100 + (Max - MinRPM) * percentage) / 200)).ToString() + unit; + else + return percentage + "%"; + } + + void SetAxis(Chart chart, AsusFan device) + { + + chart.ChartAreas[0].AxisY.CustomLabels.Clear(); + + for (int i = 0; i <= fansMax - 10; i += 10) + { + chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i, device)); + } + + chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax - 2, fansMax + 2, Properties.Strings.RPM); + chart.ChartAreas[0].AxisY.Interval = 10; } void SetChart(Chart chart, AsusFan device) @@ -588,12 +629,7 @@ void SetChart(Chart chart, AsusFan device) chart.ChartAreas[0].AxisX.LineColor = chartGrid; chart.ChartAreas[0].AxisY.LineColor = chartGrid; - for (int i = 0; i <= fansMax - 10; i += 10) - chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i, device)); - - chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax - 2, fansMax + 2, Properties.Strings.RPM); - - chart.ChartAreas[0].AxisY.Interval = 10; + SetAxis(chart, device); if (chart.Legends.Count > 0) chart.Legends[0].Enabled = false; diff --git a/app/Input/InputDispatcher.cs b/app/Input/InputDispatcher.cs index 96ace32d7..a49d76ccc 100644 --- a/app/Input/InputDispatcher.cs +++ b/app/Input/InputDispatcher.cs @@ -103,7 +103,12 @@ public void RegisterKeys() string actionM1 = AppConfig.GetString("m1"); string actionM2 = AppConfig.GetString("m2"); - if (keyProfile != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyProfile); + if (keyProfile != Keys.None) + { + hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyProfile); + hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, keyProfile); + } + if (keyApp != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyApp); if (!AppConfig.Is("skip_hotkeys")) @@ -280,6 +285,11 @@ public void KeyPressed(object sender, KeyPressedEventArgs e) if (e.Key == Keys.F20) KeyProcess("m3"); } + if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt)) + { + if (e.Key == keyProfile) modeControl.CyclePerformanceMode(true); + } + if (e.Modifier == (ModifierKeys.Control)) { switch (e.Key) @@ -354,7 +364,7 @@ public static void KeyProcess(string name = "m3") Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode); break; case "performance": - modeControl.CyclePerformanceMode(); + modeControl.CyclePerformanceMode(Control.ModifierKeys == Keys.Shift); break; case "ghelper": Program.settingsForm.BeginInvoke(delegate @@ -470,7 +480,7 @@ static void HandleEvent(int EventID) KeyProcess("fne"); return; case 174: // FN+F5 - modeControl.CyclePerformanceMode(); + modeControl.CyclePerformanceMode(Control.ModifierKeys == Keys.Shift); return; case 179: // FN+F4 case 178: // FN+F4 diff --git a/app/Mode/ModeControl.cs b/app/Mode/ModeControl.cs index 5909177b2..912d43d4a 100644 --- a/app/Mode/ModeControl.cs +++ b/app/Mode/ModeControl.cs @@ -116,9 +116,9 @@ public void SetPerformanceMode(int mode = -1, bool notify = false) } - public void CyclePerformanceMode() + public void CyclePerformanceMode(bool back = false) { - SetPerformanceMode(Modes.GetNext(Control.ModifierKeys == Keys.Shift), true); + SetPerformanceMode(Modes.GetNext(back), true); } public void AutoFans(bool force = false)