mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
UI fixes for mouse. Only register for events once the view is shown to prevent crashes. Add some additional logging for troubleshooting. Run Mouse sync asynchronously
This commit is contained in:
@@ -51,8 +51,6 @@ namespace GHelper
|
|||||||
Shown += AsusMouseSettings_Shown;
|
Shown += AsusMouseSettings_Shown;
|
||||||
FormClosing += AsusMouseSettings_FormClosing;
|
FormClosing += AsusMouseSettings_FormClosing;
|
||||||
|
|
||||||
mouse.Disconnect += Mouse_Disconnect;
|
|
||||||
mouse.BatteryUpdated += Mouse_BatteryUpdated;
|
|
||||||
comboProfile.DropDownClosed += ComboProfile_DropDownClosed;
|
comboProfile.DropDownClosed += ComboProfile_DropDownClosed;
|
||||||
|
|
||||||
sliderDPI.ValueChanged += SliderDPI_ValueChanged;
|
sliderDPI.ValueChanged += SliderDPI_ValueChanged;
|
||||||
@@ -83,7 +81,8 @@ namespace GHelper
|
|||||||
comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed;
|
comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed;
|
||||||
|
|
||||||
InitMouseCapabilities();
|
InitMouseCapabilities();
|
||||||
RefreshMouseData();
|
Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Initialized capabilities. Synchronizing mouse data");
|
||||||
|
Task task = Task.Run((Action)RefreshMouseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AsusMouseSettings_FormClosing(object? sender, FormClosingEventArgs e)
|
private void AsusMouseSettings_FormClosing(object? sender, FormClosingEventArgs e)
|
||||||
@@ -104,7 +103,7 @@ namespace GHelper
|
|||||||
private void ComboProfile_DropDownClosed(object? sender, EventArgs e)
|
private void ComboProfile_DropDownClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
mouse.SetProfile(comboProfile.SelectedIndex);
|
mouse.SetProfile(comboProfile.SelectedIndex);
|
||||||
RefreshMouseData();
|
Task task = Task.Run((Action)RefreshMouseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboBoxPollingRate_DropDownClosed(object? sender, EventArgs e)
|
private void ComboBoxPollingRate_DropDownClosed(object? sender, EventArgs e)
|
||||||
@@ -194,6 +193,11 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e)
|
private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!mouse.HasRGB())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex];
|
LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex];
|
||||||
|
|
||||||
LightingSetting? ls = mouse.LightingSetting;
|
LightingSetting? ls = mouse.LightingSetting;
|
||||||
@@ -316,8 +320,11 @@ namespace GHelper
|
|||||||
private void RefreshMouseData()
|
private void RefreshMouseData()
|
||||||
{
|
{
|
||||||
mouse.SynchronizeDevice();
|
mouse.SynchronizeDevice();
|
||||||
|
|
||||||
|
Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Mouse data synchronized");
|
||||||
if (!mouse.IsDeviceReady)
|
if (!mouse.IsDeviceReady)
|
||||||
{
|
{
|
||||||
|
Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Mouse is not ready. Closing view.");
|
||||||
this.Invoke(delegate
|
this.Invoke(delegate
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
@@ -325,9 +332,11 @@ namespace GHelper
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Invoke(delegate
|
||||||
|
{
|
||||||
VisualizeMouseSettings();
|
VisualizeMouseSettings();
|
||||||
VisualizeBatteryState();
|
VisualizeBatteryState();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitMouseCapabilities()
|
private void InitMouseCapabilities()
|
||||||
@@ -585,20 +594,20 @@ namespace GHelper
|
|||||||
|
|
||||||
|
|
||||||
private void VisualizeDPIButtons()
|
private void VisualizeDPIButtons()
|
||||||
{
|
|
||||||
if (mouse.HasDPIColors())
|
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mouse.DPIProfileCount() && i < 4; ++i)
|
for (int i = 0; i < mouse.DPIProfileCount() && i < 4; ++i)
|
||||||
{
|
{
|
||||||
AsusMouseDPI dpi = mouse.DpiSettings[i];
|
AsusMouseDPI dpi = mouse.DpiSettings[i];
|
||||||
|
if (mouse.HasDPIColors())
|
||||||
|
{
|
||||||
dpiButtons[i].Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, dpi.Color);
|
dpiButtons[i].Image = ControlHelper.TintImage(Properties.Resources.lighting_dot_24, dpi.Color);
|
||||||
dpiButtons[i].Activated = (mouse.DpiProfile - 1) == i;
|
|
||||||
dpiButtons[i].BorderColor = dpi.Color;
|
dpiButtons[i].BorderColor = dpi.Color;
|
||||||
|
}
|
||||||
|
dpiButtons[i].Activated = (mouse.DpiProfile - 1) == i;
|
||||||
dpiButtons[i].Text = "DPI " + (i + 1) + "\n" + dpi.DPI;
|
dpiButtons[i].Text = "DPI " + (i + 1) + "\n" + dpi.DPI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void VisualizeCurrentDPIProfile()
|
private void VisualizeCurrentDPIProfile()
|
||||||
{
|
{
|
||||||
@@ -620,11 +629,15 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
Left = Program.settingsForm.Left - Width - 5;
|
Left = Program.settingsForm.Left - Width - 5;
|
||||||
|
|
||||||
|
|
||||||
|
mouse.Disconnect += Mouse_Disconnect;
|
||||||
|
mouse.BatteryUpdated += Mouse_BatteryUpdated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonSync_Click(object sender, EventArgs e)
|
private void ButtonSync_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
RefreshMouseData();
|
Task task = Task.Run((Action)RefreshMouseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user