diff options
Diffstat (limited to 'grapher')
| -rw-r--r-- | grapher/Models/Devices/DeviceIDItem.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Devices/DeviceIDManager.cs | 22 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 1 |
3 files changed, 3 insertions, 22 deletions
diff --git a/grapher/Models/Devices/DeviceIDItem.cs b/grapher/Models/Devices/DeviceIDItem.cs index 63c2761..8f1587b 100644 --- a/grapher/Models/Devices/DeviceIDItem.cs +++ b/grapher/Models/Devices/DeviceIDItem.cs @@ -40,7 +40,7 @@ namespace grapher.Models.Devices DeviceIDMenuItem.Checked = false; } - private string MenuItemText() => string.IsNullOrEmpty(ID) ? $"{Name}" : $"{Name}: {ID}"; + private string MenuItemText() => string.IsNullOrEmpty(ID) ? $"{Name}" : ID.Replace("&", "&&"); private string DisconnectedText() => $"Disconnected: {ID}"; diff --git a/grapher/Models/Devices/DeviceIDManager.cs b/grapher/Models/Devices/DeviceIDManager.cs index c50cda8..8592763 100644 --- a/grapher/Models/Devices/DeviceIDManager.cs +++ b/grapher/Models/Devices/DeviceIDManager.cs @@ -25,24 +25,6 @@ namespace grapher.Models.Devices public Dictionary<string, DeviceIDItem> DeviceIDs { get; private set; } - public static IEnumerable<(string, string)> GetDeviceIDs(string PNPClass = "Mouse") - { - ManagementObjectSearcher searcher = new ManagementObjectSearcher(new SelectQuery("Win32_PnPEntity")); - - foreach (ManagementObject obj in searcher.Get()) - { - if (obj["PNPClass"] != null && obj["PNPClass"].ToString().Equals(PNPClass) && obj["DeviceID"] != null) - { - string name = obj["Name"].ToString(); - - string devInstanceID = obj["DeviceID"].ToString(); - string devID = devInstanceID.Remove(devInstanceID.LastIndexOf('\\')); - - yield return (name, devID); - } - } - } - public void SetActive(DeviceIDItem deviceIDItem) { if (SelectedDeviceID != null) @@ -64,9 +46,9 @@ namespace grapher.Models.Devices if (found) SetActive(anyDevice); - foreach (var device in GetDeviceIDs().Distinct()) + foreach (var (name, id) in RawInputInterop.GetDeviceIDs()) { - var deviceItem = new DeviceIDItem(device.Item1, device.Item2, this); + var deviceItem = new DeviceIDItem(name, id, this); if (!found && deviceItem.ID.Equals(devID)) { SetActive(deviceItem); diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 8673325..1160ba8 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -59,7 +59,6 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> - <Reference Include="System.Management" /> <Reference Include="System.Windows.Forms.DataVisualization" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> |