mirror of
https://github.com/RawAccelOfficial/rawaccel.git
synced 2025-05-15 13:59:05 +02:00
dependency changes - Newtonsoft.JSON + System.Windows.Forms.DataVisualization + System.Data.SqlClient (indirect, but was not added automatically by NuGet) added ARM64 target
63 lines
1.7 KiB
C#
63 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Forms;
|
|
|
|
namespace grapher.Models.Devices
|
|
{
|
|
public class DeviceIDManager
|
|
{
|
|
public DeviceIDManager(ToolStripMenuItem deviceIDs)
|
|
{
|
|
DeviceIDsMenuItem = deviceIDs;
|
|
DeviceIDsMenuItem.Checked = false;
|
|
}
|
|
|
|
public ToolStripMenuItem DeviceIDsMenuItem { get; }
|
|
|
|
public string ID { get => SelectedDeviceID.ID; }
|
|
|
|
public DeviceIDItem SelectedDeviceID { get; private set; }
|
|
|
|
public Dictionary<string, DeviceIDItem> DeviceIDs { get; private set; }
|
|
|
|
public void SetActive(DeviceIDItem deviceIDItem)
|
|
{
|
|
if (SelectedDeviceID != null)
|
|
{
|
|
SelectedDeviceID.SetDeactivated();
|
|
}
|
|
|
|
SelectedDeviceID = deviceIDItem;
|
|
SelectedDeviceID.SetActivated();
|
|
}
|
|
|
|
public void Update(string devID)
|
|
{
|
|
DeviceIDsMenuItem.DropDownItems.Clear();
|
|
|
|
bool found = string.IsNullOrEmpty(devID);
|
|
|
|
var anyDevice = new DeviceIDItem("Any", string.Empty, this);
|
|
|
|
if (found) SetActive(anyDevice);
|
|
|
|
/* foreach (string id in RawInputInterop.GetDeviceIDs())
|
|
{
|
|
var deviceItem = new DeviceIDItem(string.Empty, id, this);
|
|
if (!found && deviceItem.ID.Equals(devID))
|
|
{
|
|
SetActive(deviceItem);
|
|
found = true;
|
|
}
|
|
}*/
|
|
|
|
if (!found)
|
|
{
|
|
var deviceItem = new DeviceIDItem(string.Empty, devID, this);
|
|
deviceItem.SetDisconnected();
|
|
SetActive(deviceItem);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|