private void UpdateDevices() { SelectQuery query; // Workaround for Win 7 that doesn't has 'PNPClass' property if (Environment.OSVersion.Version < _osVersionSupportsPnP) { query = new SelectQuery("Win32_PnPEntity", "Caption like '%(COM%)'", new[] { "Caption" }); } else { query = new SelectQuery("Win32_PnPEntity", "PNPClass='Ports'", new[] { "Caption" }); } var searcher = new ManagementObjectSearcher(query); Devices.Clear(); foreach (var pnpDevice in searcher.Get()) { var port = Regex.Match((string)pnpDevice["Caption"], @"(?<=\()COM\d+(?=\))"); if (port.Success) { Devices.Add(new SerialDevice { Name = (string)pnpDevice["Caption"], Port = port.Value }); } } DevicesUpdated?.Invoke(this, EventArgs.Empty); }
protected void IntegrateQueryDevices(IAndroidLogcatTaskResult resut) { var deviceIdsResult = ((AndroidLogcatRetrieveDeviceIdsResult)resut); var deviceInfos = deviceIdsResult.deviceInfo; foreach (var d in m_Devices) { d.Value.UpdateState(IAndroidLogcatDevice.DeviceState.Disconnected); } foreach (var info in deviceInfos) { GetOrCreateDevice(info.id).UpdateState(info.state); } // If our selected device was removed, deselect it if (m_SelectedDevice != null && m_SelectedDevice.State != IAndroidLogcatDevice.DeviceState.Connected) { m_SelectedDevice = null; if (deviceIdsResult.notifyListeners) DeviceSelected?.Invoke(m_SelectedDevice); } if (m_SelectedDevice != null) { if (m_SelectedDevice != m_Devices[m_SelectedDevice.Id]) throw new Exception("The selected device is not among our list of devices"); } DevicesUpdated?.Invoke(); }
public void UpdateDevices() { string monikerString = null; if (IsRunning) { monikerString = VideoDevices[SelectedDeviceIndex].MonikerString; } _videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); DevicesUpdated?.Invoke(_videoDevices); if (monikerString == null || _videoDevices.Count == 0) { SelectedDeviceIndex = -1; return; } for (int i = 0; i < _videoDevices.Count; i++) { if (_videoDevices[i].MonikerString == monikerString) { SelectedDeviceIndex = i; return; } } // unreachable }
public void UpdateDevices() { List <DisplayAdapter> oldAdapters = Adapters.ToList(); List <DisplayMonitor> oldMonitors = Monitors.ToList(); NativeMethods.DISPLAY_DEVICE dev = new NativeMethods.DISPLAY_DEVICE(true); uint i = 0; while (NativeMethods.EnumDisplayDevices(null, i++, ref dev, 0)) { var adapter = oldAdapters.FirstOrDefault(a => a.DeviceName == dev.DeviceName); if (adapter != null) { oldAdapters.Remove(adapter); adapter.Init(dev, oldMonitors); } else { adapter = new DisplayAdapter(); adapter.Init(dev, oldMonitors); Adapters.Add(adapter); } } var w = new Stopwatch(); w.Start(); NativeMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref NativeMethods.RECT lprcMonitor, IntPtr dwData) { var mi = new NativeMethods.MONITORINFOEX(true); var success = NativeMethods.GetMonitorInfo(hMonitor, ref mi); if (!success) { return(true); } IList monitors = AttachedMonitors.Where(d => d.Adapter.DeviceName == mi.DeviceName).ToList(); foreach (DisplayMonitor monitor in monitors) { monitor.Init(hMonitor, mi); monitor.Timing = w.ElapsedMilliseconds; w.Restart(); } return(true); }, IntPtr.Zero); DevicesUpdated?.Invoke(this, new EventArgs()); foreach (var monitor in Monitors) { Debug.Print(monitor.DeviceName + "\t" + monitor.Edid.Model + "\t" + monitor.Timing); } }
public RecorderAudio() { _notificationClient.DevicesUpdated += () => DevicesUpdated?.Invoke(); _deviceEnumerator.RegisterEndpointNotificationCallback(_notificationClient); //foreach (var device in devices) //{ // new NAudioItem(device, false); //} }
public void UpdateDevices() { List <DisplayDevice> oldDevices = Devices.ToList(); var device = new DisplayDevice(this); device.Init(null, new NativeMethods.DISPLAY_DEVICE(true) { DeviceID = "ROOT", DeviceName = null }, oldDevices); foreach (var d in oldDevices) { Devices.Remove(d); } NativeMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, delegate(IntPtr hMonitor, IntPtr hdcMonitor, ref NativeMethods.RECT lprcMonitor, IntPtr dwData) { var mi = new NativeMethods.MONITORINFOEX(true); var success = NativeMethods.GetMonitorInfo(hMonitor, ref mi); if (!success) { return(true); } IList monitors = AttachedMonitors.Where(d => d.AttachedDisplay?.DeviceName == mi.DeviceName).ToList(); foreach (Monitor monitor in monitors) { monitor.Init(hMonitor, mi); } return(true); }, IntPtr.Zero); DevicesUpdated?.Invoke(this, new EventArgs()); }
public static void DoneIdentifying() => DevicesUpdated?.Invoke();
void InvokeDevicesUpdated() => DevicesUpdated?.Invoke();
public NAudioSource() { _notificationClient.DevicesUpdated += () => DevicesUpdated?.Invoke(); _deviceEnumerator.RegisterEndpointNotificationCallback(_notificationClient); }