Exemplo n.º 1
0
        public void Refresh()
        {
            var mi = new MonitorInfo {
                Size = Marshal.SizeOf(typeof(MonitorInfo))
            };

            if (!MonitorWin32.GetMonitorInfo(this.MonitorHandle, ref mi))
            {
                return;
            }
            var deviceInfo = new DevMode {
                dmSize = (short)Marshal.SizeOf(typeof(DevMode))
            };

            if (!MonitorWin32.EnumDisplaySettings(mi.DeviceName, MonitorWin32.ENUM_CURRENT_SETTINGS, ref deviceInfo))
            {
                return;
            }

            var orientation      = (MonitorOrientation)deviceInfo.dmDisplayOrientation;
            var actualResolution = new Rectangle(deviceInfo.dmPositionX, deviceInfo.dmPositionY, deviceInfo.dmPelsWidth, deviceInfo.dmPelsHeight);
            var displayName      = deviceInfo.dmDeviceName;

            this.Orientation = orientation;
            this.Resolution  = actualResolution;
            this.DisplayName = displayName;
        }
Exemplo n.º 2
0
 private void EnumerateWindows() =>
 _monitorCache.Edit(i =>
 {
     var currentMonitors = MonitorWin32.EnumerateDisplayMonitors();
     i.Clear();
     i.AddOrUpdate(currentMonitors);
 });