// Methods private void DisplayModeChanged(DisplayMode obj) { if (_lastDisplayNode.PresentationDisplayMode != obj.PresentationDisplayMode) { _displayManager.StopPolling(); var configNode = _configuration.Nodes.FirstOrDefault(x => x.PresentationDisplayMode == obj.PresentationDisplayMode); _audioDeviceManager.SwitchToDevice(configNode?.AudioDeviceId); _lastDisplayNode = obj; _displayManager.StartPolling(500); } }
// Constructors public DefaultAudioSwitch(IDisplayManager displayManager, IAudioDeviceManager audioDeviceManager, IConfigurationReader configurationReader, IConfigurationWriter configurationWriter) { _displayManager = displayManager; _audioDeviceManager = audioDeviceManager; _configurationReader = configurationReader; _configurationWriter = configurationWriter; _configuration = CreateDefaultConfigurationIfNecessary(displayManager); _lastDisplayNode = _displayManager.GetCurrentDisplayMode(); _displayManager.DisplayModeChanged += DisplayModeChanged; _displayManager.StartPolling(1000); }