Example #1
0
        private Mapping CreateDefaultConfigurationIfNecessary(IDisplayManager displayManager)
        {
            var configuration = _configurationReader.Read();

            if (configuration == null || configuration.Nodes == null)
            {
                configuration.Nodes.Clear();
                var allDisplayModes    = displayManager.GetAllDisplayModes();
                var defaultAudioDevice = _audioDeviceManager.GetAllDevices().FirstOrDefault(x => x.CurrentlyDefault);
                foreach (var current in allDisplayModes)
                {
                    var newNode = new MappingNode(defaultAudioDevice, current);
                    configuration.Nodes.Add(newNode);
                }

                _configurationWriter.Write(configuration);
            }
            return(configuration);
        }
Example #2
0
        // Constructors

        public MainViewModel(IDisplayManager displayManager,
                             IAudioDeviceManager audioDeviceManager,
                             IAudioSwitch audioSwitch)
        {
            _audioSwitch             = audioSwitch;
            _selectorPanelViewModels = new ObservableCollection <SelectorPanelViewModel>();

            _displayManager = displayManager;
            var audioDevices = audioDeviceManager.GetAllDevices();

            UndoCommand         = new RelayCommand <Object>(UndoChanges);
            ApplyChangesCommand = new RelayCommand <Object>(ApplyChanges);


            var mapping = _audioSwitch.GetConfigMapping();

            foreach (var current in _displayManager.GetAllDisplayModes())
            {
                var currentAudioDeviceId = mapping[current.PresentationDisplayMode];
                var selectorViewModel    = new SelectorPanelViewModel(current, audioDevices.ToArray(), audioDevices.First(x => currentAudioDeviceId.AudioDeviceId == x.DeviceId));
                selectorViewModel.IsDirtyChanged += CheckIfAnySelectorIsDirty;
                _selectorPanelViewModels.Add(selectorViewModel);
            }
        }