From 5bf579fec5db62b206485127de3de16dd192d101 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 17:28:08 +0200 Subject: [PATCH 1/3] Imroved handling for mice with only a single lighting zone. --- app/AsusMouseSettings.cs | 18 ++++++++++++++---- app/Peripherals/Mouse/AsusMouse.cs | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/AsusMouseSettings.cs b/app/AsusMouseSettings.cs index ef5c4482..9f1f0b55 100644 --- a/app/AsusMouseSettings.cs +++ b/app/AsusMouseSettings.cs @@ -532,10 +532,20 @@ namespace GHelper if (mouse.HasRGB()) { - buttonLightingZoneLogo.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Logo); - buttonLightingZoneScroll.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Scrollwheel); - buttonLightingZoneUnderglow.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Underglow); - buttonLightingZoneDock.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Dock); + if (mouse.SupportedLightingZones().Length > 1) + { + buttonLightingZoneLogo.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Logo); + buttonLightingZoneScroll.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Scrollwheel); + buttonLightingZoneUnderglow.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Underglow); + buttonLightingZoneDock.Visible = mouse.SupportedLightingZones().Contains(LightingZone.Dock); + } + else + { + buttonLightingZoneLogo.Visible = false; + buttonLightingZoneScroll.Visible = false; + buttonLightingZoneUnderglow.Visible = false; + buttonLightingZoneDock.Visible = false; + } sliderBrightness.Max = mouse.MaxBrightness(); diff --git a/app/Peripherals/Mouse/AsusMouse.cs b/app/Peripherals/Mouse/AsusMouse.cs index 2f89e5e8..abc0819b 100644 --- a/app/Peripherals/Mouse/AsusMouse.cs +++ b/app/Peripherals/Mouse/AsusMouse.cs @@ -174,7 +174,15 @@ namespace GHelper.Peripherals.Mouse this.path = path; this.Wireless = wireless; DpiSettings = new AsusMouseDPI[1]; - LightingSetting = new LightingSetting[SupportedLightingZones().Length]; + if (SupportedLightingZones().Length == 0) + { + LightingSetting = new LightingSetting[1]; + } + else + { + LightingSetting = new LightingSetting[SupportedLightingZones().Length]; + } + } public override bool Equals(object? obj) @@ -1068,7 +1076,7 @@ namespace GHelper.Peripherals.Mouse public virtual LightingZone[] SupportedLightingZones() { - return new LightingZone[] { }; + return new LightingZone[] { LightingZone.Logo }; } public virtual int IndexForZone(LightingZone zone) @@ -1086,6 +1094,11 @@ namespace GHelper.Peripherals.Mouse public virtual bool IsLightingZoned() { + if (LightingSetting.Length < 2) + { + return false; + } + //Check whether all zones are the same or not for (int i = 1; i < LightingSetting.Length; ++i) { From 0da5002804836928db9dab0f792fa0200868330b Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 17:29:26 +0200 Subject: [PATCH 2/3] Only set new mouse profile if it actually changed. --- app/AsusMouseSettings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/AsusMouseSettings.cs b/app/AsusMouseSettings.cs index 9f1f0b55..b6a448ed 100644 --- a/app/AsusMouseSettings.cs +++ b/app/AsusMouseSettings.cs @@ -173,6 +173,11 @@ namespace GHelper private void ComboProfile_DropDownClosed(object? sender, EventArgs e) { + if (mouse.Profile == comboProfile.SelectedIndex) + { + return; + } + mouse.SetProfile(comboProfile.SelectedIndex); Task task = Task.Run((Action)RefreshMouseData); } From 769c490d218038a0d1e68aa0fe3836fb044b42ac Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 17:30:02 +0200 Subject: [PATCH 3/3] Give lighting zone table layout a proper name --- app/AsusMouseSettings.Designer.cs | 56 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/AsusMouseSettings.Designer.cs b/app/AsusMouseSettings.Designer.cs index 01201957..2768bab6 100644 --- a/app/AsusMouseSettings.Designer.cs +++ b/app/AsusMouseSettings.Designer.cs @@ -60,7 +60,7 @@ labelPerformance = new Label(); panelLighting = new Panel(); panelLightingContent = new Panel(); - tableLayoutPanel3 = new TableLayoutPanel(); + tableLayoutLightingZones = new TableLayoutPanel(); buttonLightingZoneScroll = new UI.RButton(); buttonLightingZoneLogo = new UI.RButton(); buttonLightingZoneAll = new UI.RButton(); @@ -111,7 +111,7 @@ ((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit(); panelLighting.SuspendLayout(); panelLightingContent.SuspendLayout(); - tableLayoutPanel3.SuspendLayout(); + tableLayoutLightingZones.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).BeginInit(); panelLightingHeader.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLighting).BeginInit(); @@ -570,7 +570,7 @@ // panelLightingContent // panelLightingContent.AutoSize = true; - panelLightingContent.Controls.Add(tableLayoutPanel3); + panelLightingContent.Controls.Add(tableLayoutLightingZones); panelLightingContent.Controls.Add(comboBoxAnimationDirection); panelLightingContent.Controls.Add(labelAnimationDirection); panelLightingContent.Controls.Add(checkBoxRandomColor); @@ -587,29 +587,29 @@ panelLightingContent.Size = new Size(654, 274); panelLightingContent.TabIndex = 42; // - // tableLayoutPanel3 + // tableLayoutLightingZones // - tableLayoutPanel3.AutoSize = true; - tableLayoutPanel3.AutoSizeMode = AutoSizeMode.GrowAndShrink; - tableLayoutPanel3.ColumnCount = 5; - tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); - tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); - tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); - tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); - tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); - tableLayoutPanel3.Controls.Add(buttonLightingZoneScroll, 0, 0); - tableLayoutPanel3.Controls.Add(buttonLightingZoneLogo, 0, 0); - tableLayoutPanel3.Controls.Add(buttonLightingZoneAll, 0, 0); - tableLayoutPanel3.Controls.Add(buttonLightingZoneUnderglow, 1, 0); - tableLayoutPanel3.Controls.Add(buttonLightingZoneDock, 2, 0); - tableLayoutPanel3.Dock = DockStyle.Top; - tableLayoutPanel3.Location = new Point(0, 0); - tableLayoutPanel3.Margin = new Padding(6, 3, 6, 3); - tableLayoutPanel3.Name = "tableLayoutPanel3"; - tableLayoutPanel3.RowCount = 1; - tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); - tableLayoutPanel3.Size = new Size(654, 60); - tableLayoutPanel3.TabIndex = 56; + tableLayoutLightingZones.AutoSize = true; + tableLayoutLightingZones.AutoSizeMode = AutoSizeMode.GrowAndShrink; + tableLayoutLightingZones.ColumnCount = 5; + tableLayoutLightingZones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutLightingZones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutLightingZones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutLightingZones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutLightingZones.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F)); + tableLayoutLightingZones.Controls.Add(buttonLightingZoneScroll, 0, 0); + tableLayoutLightingZones.Controls.Add(buttonLightingZoneLogo, 0, 0); + tableLayoutLightingZones.Controls.Add(buttonLightingZoneAll, 0, 0); + tableLayoutLightingZones.Controls.Add(buttonLightingZoneUnderglow, 1, 0); + tableLayoutLightingZones.Controls.Add(buttonLightingZoneDock, 2, 0); + tableLayoutLightingZones.Dock = DockStyle.Top; + tableLayoutLightingZones.Location = new Point(0, 0); + tableLayoutLightingZones.Margin = new Padding(6, 3, 6, 3); + tableLayoutLightingZones.Name = "tableLayoutLightingZones"; + tableLayoutLightingZones.RowCount = 1; + tableLayoutLightingZones.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); + tableLayoutLightingZones.Size = new Size(654, 60); + tableLayoutLightingZones.TabIndex = 56; // // buttonLightingZoneScroll // @@ -1179,8 +1179,8 @@ panelLighting.PerformLayout(); panelLightingContent.ResumeLayout(false); panelLightingContent.PerformLayout(); - tableLayoutPanel3.ResumeLayout(false); - tableLayoutPanel3.PerformLayout(); + tableLayoutLightingZones.ResumeLayout(false); + tableLayoutLightingZones.PerformLayout(); ((System.ComponentModel.ISupportInitialize)pictureBoxLightingColor).EndInit(); panelLightingHeader.ResumeLayout(false); panelLightingHeader.PerformLayout(); @@ -1263,7 +1263,7 @@ private UI.RButton buttonSync; private Panel panelBottomButtons; private NumericUpDown numericUpDownCurrentDPI; - private TableLayoutPanel tableLayoutPanel3; + private TableLayoutPanel tableLayoutLightingZones; private UI.RButton buttonLightingZoneScroll; private UI.RButton buttonLightingZoneLogo; private UI.RButton buttonLightingZoneAll;