From ce128adc4f30f1ca69c2e204266394c1728699d4 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sat, 2 Sep 2023 00:52:15 +0200 Subject: [PATCH] Only open one Mouse settings window and also make it the topmost window. --- app/Settings.cs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/app/Settings.cs b/app/Settings.cs index 416e2e2f..f8b46904 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -25,6 +25,8 @@ namespace GHelper ScreenControl screenControl = new ScreenControl(); AutoUpdateControl updateControl; + AsusMouseSettings? mouseSettings; + public AniMatrixControl matrix; public static System.Timers.Timer sensorTimer = default!; @@ -1187,6 +1189,12 @@ namespace GHelper private void ButtonPeripheral_Click(object? sender, EventArgs e) { + if (mouseSettings is not null) + { + mouseSettings.Close(); + return; + } + int index = 0; if (sender == buttonPeripheral2) index = 1; if (sender == buttonPeripheral3) index = 2; @@ -1207,16 +1215,30 @@ namespace GHelper //Should not happen if all device classes are implemented correctly. But better safe than sorry. return; } - AsusMouseSettings s = new AsusMouseSettings(am); - if (!s.IsDisposed) + mouseSettings = new AsusMouseSettings(am); + mouseSettings.TopMost = true; + mouseSettings.FormClosed += MouseSettings_FormClosed; + mouseSettings.Disposed += MouseSettings_Disposed; + if (!mouseSettings.IsDisposed) { - s.Show(); + mouseSettings.Show(); + } + else + { + mouseSettings = null; } } + } + private void MouseSettings_Disposed(object? sender, EventArgs e) + { + mouseSettings = null; + } - + private void MouseSettings_FormClosed(object? sender, FormClosedEventArgs e) + { + mouseSettings = null; } public void VisualiseFnLock()