/// <summary> /// Gets a collection of system monitors /// </summary> /// <returns>Collection of MonitorItem</returns> public IEnumerable <MonitorItem> GetSystemMonitors() { Log.Logger.Information("Getting system monitors"); List <MonitorItem> result = new List <MonitorItem>(); var devices = DisplayDevices.ReadDisplayDevices().ToArray(); var displayScreens = GetDisplayScreens(devices); foreach (var screen in Screen.AllScreens) { var displayScreen = displayScreens?.SingleOrDefault(x => x.Item1.Equals(screen)); var deviceData = displayScreen?.Item2; result.Add(new MonitorItem { Monitor = screen, MonitorName = deviceData?.DeviceString ?? SanitizeScreenDeviceName(screen.DeviceName), MonitorId = deviceData?.DeviceId ?? screen.DeviceName }); } return(result); }
/// <summary> /// Gets a collection of system monitors /// </summary> /// <returns>Collection of MonitorItem</returns> public IEnumerable <MonitorItem> GetSystemMonitors() { Log.Logger.Information("Getting system monitors"); List <MonitorItem> result = new List <MonitorItem>(); var devices = DisplayDevices.ReadDisplayDevices().ToArray(); foreach (var screen in Screen.AllScreens) { Log.Logger.Information($"Screen: {screen.DeviceName}"); DisplayDeviceData deviceData = GetDeviceMatchingScreen(devices, screen); if (deviceData != null) { Log.Logger.Information($"Matching device: {deviceData.DeviceString}, {deviceData.DeviceId}"); result.Add(new MonitorItem { Monitor = screen, MonitorName = deviceData.DeviceString, MonitorId = deviceData.DeviceId }); } } return(result); }
/// <summary> /// Gets a collection of system monitors /// </summary> /// <returns>Collection of MonitorItem</returns> public IEnumerable<MonitorItem> GetSystemMonitors() { Log.Logger.Information("Getting system monitors"); List<MonitorItem> result = new List<MonitorItem>(); var devices = DisplayDevices.ReadDisplayDevices().ToArray(); var displayScreens = GetDisplayScreens(devices); foreach (var screen in Screen.AllScreens) { var displayScreen = displayScreens?.SingleOrDefault(x => x.Item1.Equals(screen)); var deviceData = displayScreen?.Item2; var monitor = new MonitorItem { Monitor = screen, MonitorName = deviceData?.DeviceString ?? SanitizeScreenDeviceName(screen.DeviceName), MonitorId = deviceData?.DeviceId ?? screen.DeviceName, FriendlyName = screen.DeviceFriendlyName() }; if (string.IsNullOrEmpty(monitor.FriendlyName)) { monitor.FriendlyName = monitor.MonitorName; } result.Add(monitor); } result.Sort((x, y) => { var rv = string.Compare(x.FriendlyName, y.FriendlyName, StringComparison.InvariantCultureIgnoreCase); if (rv == 0) { rv = string.Compare(x.MonitorId, y.MonitorId, StringComparison.InvariantCultureIgnoreCase); } return rv; }); return result; }
/// <summary> /// Gets a collection of system monitors /// </summary> /// <returns>Collection of MonitorItem</returns> public IEnumerable <MonitorItem> GetSystemMonitors() { List <MonitorItem> result = new List <MonitorItem>(); var devices = DisplayDevices.ReadDisplayDevices().ToArray(); foreach (var screen in Screen.AllScreens) { DisplayDeviceData deviceData = GetDeviceMatchingScreen(devices, screen); if (deviceData != null) { result.Add(new MonitorItem { Monitor = screen, MonitorName = deviceData.DeviceString, MonitorId = deviceData.DeviceId }); } } return(result); }