summaryrefslogtreecommitdiff
path: root/grapher/Models/Serialized
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-01-07 23:11:24 -0800
committerJacob Palecki <[email protected]>2021-01-07 23:11:24 -0800
commit8273ecf0c22876f0f4e9dfa9eb29b9d491614faa (patch)
tree089cb8e024722781670433502e1452a59456cc6a /grapher/Models/Serialized
parentrough GUI integration of "Device Hardware ID" (diff)
downloadrawaccel-8273ecf0c22876f0f4e9dfa9eb29b9d491614faa.tar.xz
rawaccel-8273ecf0c22876f0f4e9dfa9eb29b9d491614faa.zip
Refactor
Diffstat (limited to 'grapher/Models/Serialized')
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs73
1 files changed, 7 insertions, 66 deletions
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index 3adbc8b..4dbf7bf 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -4,6 +4,7 @@ using System.Windows.Forms;
using System.Threading;
using System.Text;
using System.Drawing;
+using grapher.Models.Devices;
namespace grapher.Models.Serialized
{
@@ -16,17 +17,17 @@ namespace grapher.Models.Serialized
Field dpiField,
Field pollRateField,
ToolStripMenuItem autoWrite,
- ToolStripMenuItem useSpecificDevice,
ToolStripMenuItem showLastMouseMove,
- ToolStripMenuItem showVelocityAndGain)
+ ToolStripMenuItem showVelocityAndGain,
+ DeviceIDManager deviceIDManager)
{
ActiveAccel = activeAccel;
DpiField = dpiField;
PollRateField = pollRateField;
AutoWriteMenuItem = autoWrite;
- UseSpecificDeviceMenuItem = useSpecificDevice;
ShowLastMouseMoveMenuItem = showLastMouseMove;
ShowVelocityAndGainMoveMenuItem = showVelocityAndGain;
+ DeviceIDManager = deviceIDManager;
}
#endregion Constructors
@@ -43,12 +44,12 @@ namespace grapher.Models.Serialized
private ToolStripMenuItem AutoWriteMenuItem { get; set; }
- private ToolStripMenuItem UseSpecificDeviceMenuItem { get; set; }
-
private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; }
private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; }
+ private DeviceIDManager DeviceIDManager { get; }
+
#endregion Properties
#region Methods
@@ -66,66 +67,6 @@ namespace grapher.Models.Serialized
return errors;
}
- private void SpecificDeviceClickHnadler(Object o, EventArgs a, string hwid)
- {
- var item = (ToolStripMenuItem)o;
- foreach (ToolStripMenuItem i in UseSpecificDeviceMenuItem.DropDownItems)
- {
- i.Checked = false;
- }
- item.Checked = true;
- if (hwid == null || hwid == "")
- {
- UseSpecificDeviceMenuItem.Checked = false;
- } else
- {
- UseSpecificDeviceMenuItem.Checked = true;
- }
- RawAccelSettings.AccelerationSettings.deviceHardwareID = hwid;
-
- TryUpdateActiveSettings(RawAccelSettings.AccelerationSettings);
-
- }
- private void UpdateUseSpecificDeviceMenu()
- {
- var hwid = RawAccelSettings.AccelerationSettings.deviceHardwareID;
- if (hwid == null) { hwid = ""; }
-
- UseSpecificDeviceMenuItem.Checked = hwid.Length > 0;
- UseSpecificDeviceMenuItem.DropDownItems.Clear();
-
- var any_device = new ToolStripMenuItem();
- any_device.Text = "";
- any_device.Checked = hwid.Length == 0;
- any_device.Click += new EventHandler(delegate(Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, ""); });
- UseSpecificDeviceMenuItem.DropDownItems.Add(any_device);
-
- var hwid_not_found = true;
-
- foreach (Tuple<string,string> device in Models.Devices.DeviceList.GetDeviceHardwareIDs())
- {
- if (hwid == device.Item2)
- {
- hwid_not_found = false;
- }
- var dev = new ToolStripMenuItem();
- dev.Text = device.Item1;
- dev.Checked = device.Item2 == RawAccelSettings.AccelerationSettings.deviceHardwareID;
- dev.Click += new EventHandler(delegate (Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, device.Item2); });
- UseSpecificDeviceMenuItem.DropDownItems.Add(dev);
- }
-
- if (hwid.Length > 0 && hwid_not_found)
- {
- var current_hwid = new ToolStripMenuItem();
- current_hwid.Text = "Disconnected (" + hwid + ")";
- current_hwid.ForeColor = Color.DarkGray;
- current_hwid.Checked = true;
- current_hwid.Click += new EventHandler(delegate (Object o, EventArgs a) { SpecificDeviceClickHnadler(o, a, hwid); });
- UseSpecificDeviceMenuItem.DropDownItems.Add(current_hwid);
- }
- }
-
public void UpdateFieldsFromGUISettings()
{
DpiField.SetToEntered(RawAccelSettings.GUISettings.DPI);
@@ -133,6 +74,7 @@ namespace grapher.Models.Serialized
ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove;
ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain;
AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
+ DeviceIDManager.OnStartup(RawAccelSettings.AccelerationSettings.deviceHardwareID);
}
public SettingsErrors TryUpdateAccel(DriverSettings settings)
@@ -175,7 +117,6 @@ namespace grapher.Models.Serialized
{
RawAccelSettings = RawAccelSettings.Load(() => MakeGUISettingsFromFields());
UpdateFieldsFromGUISettings();
- UpdateUseSpecificDeviceMenu();
if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup)
{
TryUpdateAccel(RawAccelSettings.AccelerationSettings);