Example #1
0
        public GammaService(SettingsService settingsService)
        {
            _settingsService = settingsService;

            // If display settings change, invalidate the device context
            _systemEventRegistration = Disposable.Aggregate(
                SystemEvent.TryRegister(SystemEventType.DisplaySettingsChanged, () => _isDeviceContextValid = false),
                SystemEvent.TryRegister(SystemEventType.DisplayStateChanged, () => _isDeviceContextValid    = false)
                );
        }
Example #2
0
        public GammaService(SettingsService settingsService)
        {
            _settingsService = settingsService;

            // Register for all system events that may indicate that device context or gamma has changed from outside
            _eventRegistration = Disposable.Aggregate(
                PowerSettingNotification.TryRegister(
                    PowerSettingNotification.ConsoleDisplayStateId,
                    InvalidateGamma
                    ) ?? Disposable.Null,
                PowerSettingNotification.TryRegister(
                    PowerSettingNotification.PowerSavingStatusId,
                    InvalidateGamma
                    ) ?? Disposable.Null,
                PowerSettingNotification.TryRegister(
                    PowerSettingNotification.SessionDisplayStatusId,
                    InvalidateGamma
                    ) ?? Disposable.Null,
                PowerSettingNotification.TryRegister(
                    PowerSettingNotification.MonitorPowerOnId,
                    InvalidateGamma
                    ) ?? Disposable.Null,
                PowerSettingNotification.TryRegister(
                    PowerSettingNotification.AwayModeId,
                    InvalidateGamma
                    ) ?? Disposable.Null,

                SystemEvent.Register(
                    SystemEvent.DisplayChangedId,
                    InvalidateDeviceContext
                    ),
                SystemEvent.Register(
                    SystemEvent.PaletteChangedId,
                    InvalidateDeviceContext
                    ),
                SystemEvent.Register(
                    SystemEvent.SettingsChangedId,
                    InvalidateDeviceContext
                    ),
                SystemEvent.Register(
                    SystemEvent.SystemColorsChangedId,
                    InvalidateDeviceContext
                    )
                );
        }