/// <summary>
        ///     Initializes a new instance of the <see cref="AutoSwitchConfigViewModel" /> class.
        /// </summary>
        /// <param name="autoSwitchConfig">The automatic switch configuration.</param>
        /// <param name="environment"></param>
        public AutoSwitchConfigViewModel(AutoSwitchConfig autoSwitchConfig, IKvmSwitchEnvironment environment)
        {
            this.environment = environment;
            this.Name        = autoSwitchConfig.Name;
            this.Active      = autoSwitchConfig.Active;
            this.ExecuteOnUsbDeviceConnected    = autoSwitchConfig.ExecuteOnUsbDeviceConnected;
            this.ExecuteOnUsbDeviceDisconnected = autoSwitchConfig.ExecuteOnUsbDeviceDisconnected;

            this.InitUsbDevices(autoSwitchConfig);

            // Displays
            var supportedMonitorSources = environment.DisplayDataChannel.GetSupportedSourcesOfMonitors();

            this.MonitorInfos = new List <MonitorInfo>();

            for (var monitorIndex = 0; monitorIndex < supportedMonitorSources.Count; ++monitorIndex)
            {
                var monitorInfo = new MonitorInfo
                {
                    MonitorIndex   = monitorIndex,
                    MonitorSources = supportedMonitorSources[monitorIndex]
                };

                var existingMonitorConfig =
                    autoSwitchConfig.MonitorConfigs?.FirstOrDefault(x => x.Name == monitorInfo.Name);


                MonitorSource monitorSource = null;

                if (existingMonitorConfig != null)
                {
                    monitorSource =
                        monitorInfo.MonitorSources.FirstOrDefault(x => x.Name == existingMonitorConfig.Input);
                    monitorInfo.UseInProfile = true;
                }


                if (monitorSource == null)
                {
                    monitorSource = monitorInfo.MonitorSources.FirstOrDefault();
                }

                monitorInfo.SelectedMonitorSource = monitorSource;
                this.MonitorInfos.Add(monitorInfo);
            }
        }
 private void AssignAutoSwitchConfig()
 {
     this.autoSwitchConfig = this.environment.Config?.AutoSwitchConfigs?.FirstOrDefault(x => x.Active);
 }