public void AddSameAddress() { DeviceTest d1 = new DeviceTest(DeviceTest2.DD,"dt"); DeviceTest2 d2 = new DeviceTest2("dt2"); DeviceCollection ds = new DeviceCollection(); ds.Add(d1); ds.Add(d2); }
public RawDevicesManager(InputProvider inputProvider) { virtualScreen = SystemInformation.VirtualScreen; this.inputProvider = inputProvider; mouseSpeed = SystemInformation.MouseSpeed * 0.15; devices = new DeviceCollection(); contacts = new ContactCollection(); IEnumerable<RawDevice> rawDevices = from device in RawDevice.GetRawDevices() where (device.RawType == RawType.Device && device.GetRawInfo().UsagePage == HID_USAGE_PAGE_DIGITIZER && device.GetRawInfo().Usage == HID_USAGE_DIGITIZER_PEN) || device.RawType == RawType.Mouse select device; foreach (RawDevice mouseDevice in rawDevices) devices.Add(new DeviceStatus(mouseDevice)); Thread inputThread = new Thread(InputWorker); inputThread.IsBackground = true; inputThread.SetApartmentState(ApartmentState.STA); inputThread.Name = "MultipleMice thread"; inputThread.Start(); this.inputProvider.IsRunning = true; }
/// <summary> /// /// </summary> /// <returns></returns> public static DeviceCollection CreateDeviceCollection() { DeviceCollection dc = new DeviceCollection(); DataTable tbl = DeviceDBI.GetDeviceDataView(); foreach (DataRow row in tbl.Rows) { DeviceClass c = CreateDevice(row); dc.Add(c); } return dc; }
/// <summary> /// Add a device to the collection if it is unique /// </summary> /// <param name="deviceToAdd"></param> /// <returns></returns> public bool AddDevice(PlaybackDevice deviceToAdd) { bool deviceUnique = (DeviceCollection.Contains(deviceToAdd) == false); if (deviceUnique == true) { DeviceCollection.Add(deviceToAdd); } return(deviceUnique); }
/// <summary> /// /// </summary> /// <param name="stationID"></param> /// <returns></returns> public static DeviceCollection CreateDeviceCollectionByStationID(int stationID) { DeviceCollection dc = new DeviceCollection(); //int[] devicdIDs = DeviceDBI.GetDeviceIDsByStationID(stationID); //string s = SqlHelper.MakeInQueryCondition(devicdIDs); DataTable tbl = DeviceDBI.GetDeviceDataTableByStationID(stationID); foreach (DataRow row in tbl.Rows) { DeviceClass d = CreateDevice(row); dc.Add(d); } return dc; }
private DeviceCollection Filter(DeviceCollection devices, FluxPlace fluxPlace) { DeviceCollection r = new DeviceCollection(); foreach (IDevice device in devices) { PlaceDeviceBase pd = device as PlaceDeviceBase; if (pd.Place == fluxPlace) { r.Add(pd); } } return(r); }
private void OpenJoysticks(string path) { lock (sync) { foreach (string file in Directory.GetFiles(path)) { LinuxJoystickDetails stick = OpenJoystick(file); if (stick != null) { Sticks.Add(stick.PathIndex, stick); } } } }
public static void LoadFromString(string xml, DeviceCollection devices) { if (xml == null) { throw new ArgumentNullException(nameof(xml)); } if (devices == null) { throw new ArgumentNullException(nameof(devices)); } XmlReaderSettings xmlReaderSettings = new XmlReaderSettings() { IgnoreComments = true, IgnoreWhitespace = true }; XmlSerializer xmlSerializer = new XmlSerializer(typeof(JC2Data)); using (XmlReader xmlReader = XmlReader.Create(new StringReader(xml), xmlReaderSettings)) { JC2Data jc2data = (JC2Data)xmlSerializer.Deserialize(xmlReader); devices.Clear(); foreach (JC2DectDevice jc2dectDevice in jc2data.DectDevices) { devices.Add(new DectDevice(jc2dectDevice)); } foreach (JC2JuisDevice jc2juisDevice in jc2data.JuisDevices) { devices.Add(new JuisDevice(jc2juisDevice)); } devices.Settings.Reset(); foreach (JC2Setting setting in jc2data.Settings) { devices.Settings.Add(setting.Name, setting.Value); } } }
private MouseDevice GetMouse(IntPtr device) { int id = GetId(device); MouseDevice mouse = MouseCandidates.FromHardwareId(id); if (mouse != null) { Mice.Add(id, mouse); } else { Debug.Print("[Input] Mouse {0} does not exist in device list.", id); } return(mouse); }
private KeyboardDevice GetKeyboard(IntPtr device) { int id = GetId(device); KeyboardDevice keyboard = KeyboardCandidates.FromHardwareId(id); if (keyboard != null) { Keyboards.Add(id, keyboard); } else { Debug.Print("[Input] Keyboard {0} does not exist in device list.", id); } return(keyboard); }
public void Add() { DeviceTest d = new DeviceTest(DeviceTest2.DD, "a"); DeviceCollection ds = new DeviceCollection(); Assert.AreEqual(0, ds.Count); ds.Add(d); Assert.AreEqual(1, ds.Count); Assert.AreSame(d.Devices, ds); d.Delete(); Assert.IsNull(d.Devices); Assert.AreEqual(0, ds.Count); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { DeviceCollection cs = GetInOrOutDeviceCollection(); cs.Clear(); foreach (ListItem li in this.clStation.Items) { if (li.Selected) { int id = Convert.ToInt32(li.Value); DeviceClass device = DeviceFactory.CreateDevice(id); cs.Add(device); } } Redirect(); }
/// <summary> /// /// </summary> /// <param name="devices"></param> /// <returns></returns> private DeviceCollection RemoveUnkonwnPlaceDevice(DeviceCollection devices) { DeviceCollection r = new DeviceCollection(); foreach (IDevice d in devices) { if (d is PlaceDeviceBase) { PlaceDeviceBase pd = d as PlaceDeviceBase; if (pd.Place != FluxPlace.Unknown) { r.Add(pd); } } } return(r); }
/// <summary> /// /// </summary> /// <param name="devicesNode"></param> /// <returns></returns> private DeviceCollection BuildDeviceCollection(XmlNode devicesNode) { if (devicesNode == null) { throw new ArgumentNullException("devicesNode"); } DeviceCollection devices = new DeviceCollection(); foreach (XmlNode node in devicesNode.ChildNodes) { if (node.Name == HardwareNodeNames.Device) { Device d = BuildDevice(node); devices.Add(d); } } return(devices); }
private void HandleDeviceAdded(IntPtr context, IntPtr device) { if (LibInput.DeviceHasCapability(device, DeviceCapability.Keyboard)) { KeyboardDevice keyboard = new KeyboardDevice(device, Keyboards.Count); KeyboardCandidates.Add(keyboard.Id, keyboard); Debug.Print("[Input] Added keyboard device {0} '{1}' on '{2}' ('{3}')", keyboard.Id, keyboard.Name, keyboard.LogicalSeatName, keyboard.PhysicalSeatName); } if (LibInput.DeviceHasCapability(device, DeviceCapability.Mouse)) { MouseDevice mouse = new MouseDevice(device, Mice.Count); MouseCandidates.Add(mouse.Id, mouse); Debug.Print("[Input] Added mouse device {0} '{1}' on '{2}' ('{3}')", mouse.Id, mouse.Name, mouse.LogicalSeatName, mouse.PhysicalSeatName); } if (LibInput.DeviceHasCapability(device, DeviceCapability.Touch)) { Debug.Print("[Input] Todo: touch device."); } }
public void RefreshDevices() { // Mark all devices as disconnected. We will check which of those // are connected below. foreach (var device in Devices) { device.SetConnected(false); } // Discover joystick devices int xinput_device_count = 0; foreach (RawInputDeviceList dev in WinRawInput.GetDeviceList()) { // Skip non-joystick devices if (dev.Type != RawInputDeviceType.HID) { continue; } // We use the device handle as the hardware id. // This works, but the handle will change whenever the // device is unplugged/replugged. We compensate for this // by checking device GUIDs, below. // Note: we cannot use the GUID as the hardware id, // because it is costly to query (and we need to query // that every time we process a device event.) IntPtr handle = dev.Device; bool is_xinput = IsXInput(handle); Guid guid = GetDeviceGuid(handle); long hardware_id = handle.ToInt64(); Device device = Devices.FromHardwareId(hardware_id); if (device != null) { // We have already opened this device, mark it as connected device.SetConnected(true); } else { device = new Device(handle, guid, is_xinput, is_xinput ? xinput_device_count++ : 0); // This is a new device, query its capabilities and add it // to the device list if (!QueryDeviceCaps(device) && !is_xinput) { continue; } device.SetConnected(true); // Check if a disconnected device with identical GUID already exists. // If so, replace that device with this instance. Device match = null; foreach (Device candidate in Devices) { if (candidate.GetGuid() == guid && !candidate.GetCapabilities().IsConnected) { match = candidate; } } if (match != null) { Devices.Remove(match.Handle.ToInt64()); } Devices.Add(hardware_id, device); Debug.Print("[{0}] Connected joystick {1} ({2})", GetType().Name, device.GetGuid(), device.GetCapabilities()); } } }
private void ChangeCollection(object obj) { DeviceCollection.Add(new DeviceInformationVM { MyProperty = "TEST" }); }
/// <summary> /// /// </summary> /// <param name="inOrOutTableName"></param> /// <param name="waterUserId"></param> /// <returns></returns> private static DeviceCollection CreateDeviceCollection(string inOrOutTableName, int waterUserId) { DeviceCollection ds = new DeviceCollection(); string s = string.Format( @"select * from tblDevice where deleted = 0 and deviceid in (select deviceid from {0} where waterUserID = {1})", inOrOutTableName, waterUserId); DataTable tbl = DBI.GetDBI().ExecuteDataTable(s); foreach (DataRow row in tbl.Rows) { DeviceClass d = CreateDevice(row); ds.Add(d); } return ds; }
private DeviceCollection Filter(DeviceCollection devices, FluxPlace fluxPlace) { DeviceCollection r = new DeviceCollection(); foreach (IDevice device in devices) { PlaceDeviceBase pd = device as PlaceDeviceBase; if (pd.Place == fluxPlace) { r.Add(pd); } } return r; }
/// <summary> /// /// </summary> /// <param name="devicesNode"></param> /// <returns></returns> private DeviceCollection BuildDeviceCollection(XmlNode devicesNode) { if (devicesNode == null) throw new ArgumentNullException("devicesNode"); DeviceCollection devices = new DeviceCollection(); foreach (XmlNode node in devicesNode.ChildNodes) { if (node.Name == HardwareNodeNames.Device) { Device d = BuildDevice(node); devices.Add(d); } } return devices; }
/// <summary> /// /// </summary> /// <param name="station"></param> /// <returns></returns> public override DeviceCollection BuildDeviceCollection(Station station) { DeviceCollection devices = new DeviceCollection(); string sql = string.Format( "select * from tblDevice where DeviceDeleted = 0 and StationID = {0}", station.ID ); DataTable deviceTable = DBI.ExecuteDataTable(sql); foreach (DataRow row in deviceTable.Rows) { Device device = BuildDevice(row); if (device != null) { devices.Add(device); } } return devices; }
/// <summary> /// /// </summary> /// <param name="devices"></param> /// <returns></returns> private DeviceCollection RemoveUnkonwnPlaceDevice(DeviceCollection devices) { DeviceCollection r = new DeviceCollection(); foreach (IDevice d in devices) { if (d is PlaceDeviceBase) { PlaceDeviceBase pd = d as PlaceDeviceBase; if (pd.Place != FluxPlace.Unknown) { r.Add(pd); } } } return r; }