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;
|
||||
FormClosing += AsusMouseSettings_FormClosing;
|
||||
|
||||
mouse.Disconnect += Mouse_Disconnect;
|
||||
mouse.BatteryUpdated += Mouse_BatteryUpdated;
|
||||
comboProfile.DropDownClosed += ComboProfile_DropDownClosed;
|
||||
|
||||
sliderDPI.ValueChanged += SliderDPI_ValueChanged;
|
||||
@@ -83,7 +81,8 @@ namespace GHelper
|
||||
comboBoxAutoPowerOff.DropDownClosed += ComboBoxAutoPowerOff_DropDownClosed;
|
||||
|
||||
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)
|
||||
@@ -104,7 +103,7 @@ namespace GHelper
|
||||
private void ComboProfile_DropDownClosed(object? sender, EventArgs e)
|
||||
{
|
||||
mouse.SetProfile(comboProfile.SelectedIndex);
|
||||
RefreshMouseData();
|
||||
Task task = Task.Run((Action)RefreshMouseData);
|
||||
}
|
||||
|
||||
private void ComboBoxPollingRate_DropDownClosed(object? sender, EventArgs e)
|
||||
@@ -194,6 +193,11 @@ namespace GHelper
|
||||
|
||||
private void ComboBoxLightingMode_DropDownClosed(object? sender, EventArgs e)
|
||||
{
|
||||
if (!mouse.HasRGB())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LightingMode lm = supportedLightingModes[comboBoxLightingMode.SelectedIndex];
|
||||
|
||||
LightingSetting? ls = mouse.LightingSetting;
|
||||
@@ -316,8 +320,11 @@ namespace GHelper
|
||||
private void RefreshMouseData()
|
||||
{
|
||||
mouse.SynchronizeDevice();
|
||||
|
||||
Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Mouse data synchronized");
|
||||
if (!mouse.IsDeviceReady)
|
||||
{
|
||||
Logger.WriteLine(mouse.GetDisplayName() + " (GUI): Mouse is not ready. Closing view.");
|
||||
this.Invoke(delegate
|
||||
{
|
||||
this.Close();
|
||||
@@ -325,9 +332,11 @@ namespace GHelper
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
VisualizeMouseSettings();
|
||||
VisualizeBatteryState();
|
||||
this.Invoke(delegate
|
||||
{
|
||||
VisualizeMouseSettings();
|
||||
VisualizeBatteryState();
|
||||
});
|
||||
}
|
||||
|
||||
private void InitMouseCapabilities()
|
||||
@@ -586,20 +595,20 @@ namespace GHelper
|
||||
|
||||
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];
|
||||
if (mouse.HasDPIColors())
|
||||
{
|
||||
AsusMouseDPI dpi = mouse.DpiSettings[i];
|
||||
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].Text = "DPI " + (i + 1) + "\n" + dpi.DPI;
|
||||
}
|
||||
dpiButtons[i].Activated = (mouse.DpiProfile - 1) == i;
|
||||
dpiButtons[i].Text = "DPI " + (i + 1) + "\n" + dpi.DPI;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void VisualizeCurrentDPIProfile()
|
||||
{
|
||||
AsusMouseDPI dpi = mouse.DpiSettings[mouse.DpiProfile - 1];
|
||||
@@ -620,11 +629,15 @@ namespace GHelper
|
||||
}
|
||||
|
||||
Left = Program.settingsForm.Left - Width - 5;
|
||||
|
||||
|
||||
mouse.Disconnect += Mouse_Disconnect;
|
||||
mouse.BatteryUpdated += Mouse_BatteryUpdated;
|
||||
}
|
||||
|
||||
private void ButtonSync_Click(object sender, EventArgs e)
|
||||
{
|
||||
RefreshMouseData();
|
||||
Task task = Task.Run((Action)RefreshMouseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user