public static void FillDisplayDevice(Models.DisplayDevice model, Models.Native.DisplayDevice native)
 {
     model.Id          = native.DeviceId;
     model.Key         = native.DeviceKey;
     model.Name        = native.DeviceName;
     model.State       = native.StateFlags;
     model.Description = native.DeviceString;
 }
예제 #2
0
        void GetDisplayDevicesForMonitors(List <Models.Monitor> monitors)
        {
            var displayAdapter = new Models.Native.DisplayDevice
            {
                Size = (uint)_marshal.SizeOf <Models.Native.DisplayDevice>()
            };
            uint devId = 0;

            while (_nativeMethods.EnumDisplayDevices(null, devId, ref displayAdapter, 0))
            {
                ++devId;

                var monitor = monitors.Find(m => m.DisplayAdapter.Name == displayAdapter.DeviceName);

                if (monitor == null)
                {
                    continue;
                }

                var displayMonitor = new Models.Native.DisplayDevice
                {
                    Size = (uint)_marshal.SizeOf <Models.Native.DisplayDevice>()
                };
                uint monId = 0;

                monitor.DisplayAdapter = new Models.DisplayDevice();
                Helpers.FillDisplayDevice(monitor.DisplayAdapter, displayAdapter);

                while (_nativeMethods.EnumDisplayDevices(displayAdapter.DeviceName, monId, ref displayMonitor, 0))
                {
                    ++monId;
                    Helpers.FillDisplayDevice(monitor, displayMonitor);
                }

                GetDisplayAdapterInfoForMonitor(monitor);
            }
        }