Пример #1
0
        /// <summary>
        /// Gets a collection of system monitors
        /// </summary>
        /// <returns>Collection of SystemMonitor</returns>
        public IEnumerable <SystemMonitor> GetSystemMonitors()
        {
            Log.Logger.Debug("Getting system monitors");

            var result = new List <SystemMonitor>();

            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 SystemMonitor
                {
                    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);
            }

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Gets a collection of system monitors
        /// </summary>
        /// <returns>Collection of SystemMonitor</returns>
        public IEnumerable <SystemMonitor> GetSystemMonitors()
        {
            Log.Logger.Debug("Getting system monitors");

            List <SystemMonitor> result = new List <SystemMonitor>();

            var devices = DisplayDevices.ReadDisplayDevices().ToArray();

            foreach (var screen in Screen.AllScreens)
            {
                Log.Logger.Verbose($"Screen: {screen.DeviceName}");

                DisplayDeviceData deviceData = GetDeviceMatchingScreen(devices, screen);
                if (deviceData != null)
                {
                    Log.Logger.Verbose($"Matching device: {deviceData.DeviceString}, {deviceData.DeviceId}");

                    result.Add(new SystemMonitor
                    {
                        Monitor     = screen,
                        MonitorName = deviceData.DeviceString,
                        MonitorId   = deviceData.DeviceId
                    });
                }
            }

            return(result);
        }