public MainViewModel(IUserInterfaceRoot uiRoot, IWindowSystem windowSystem, List <Color> colors, ICommandSenderHostSettable commandSenderHostSettable, ITargetAddressHost targetAddressHost, IMultiLoggerWithStackTrace <int> debugLogger, ILoggerRegistrationPoint loggerRegistrationPoint, INotifySendingEnabledRaisable notifySendingEnabled, IParameterLogger paramLogger, IAinsCounterRaisable ainsCounterRaisable, ICycleThreadHolder cycleThreadHolder, IAinSettingsReader ainSettingsReader, IAinSettingsReadNotify ainSettingsReadNotify, IAinSettingsReadNotifyRaisable ainSettingsReadNotifyRaisable, IAinSettingsWriter ainSettingsWriter, IAinSettingsStorage ainSettingsStorage, IAinSettingsStorageSettable ainSettingsStorageSettable, IAinSettingsStorageUpdatedNotify storageUpdatedNotify, ReadCycleModel bsEthernetReadCycleModel, IEngineSettingsReader engineSettingsReader, IEngineSettingsWriter engineSettingsWriter, IEngineSettingsReadNotify engineSettingsReadNotify, IEngineSettingsReadNotifyRaisable engineSettingsReadNotifyRaisable, IEngineSettingsStorage engineSettingsStorage, IEngineSettingsStorageSettable engineSettingsStorageSettable, IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify) { _uiRoot = uiRoot; _colors = colors; _commandSenderHostSettable = commandSenderHostSettable; _commandSenderHost = commandSenderHostSettable; _targetAddressHost = targetAddressHost; _isPortOpened = false; // Лог программы: _debugLogger = debugLogger; _loggerRegistrationPoint = loggerRegistrationPoint; // разрешение к отправке (COM-порт открыт/закрыт) _notifySendingEnabled = notifySendingEnabled; ProgramLogVm = new ProgramLogViewModel(_uiRoot, _debugLogger, new DateTimeFormatter(" > ")); _logger = new RelayLogger(ProgramLogVm); _loggerRegistrationPoint.RegisterLoggegr(_logger); GetPortsAvailable(); OpenPortCommand = new RelayCommand(OpenPort, () => !_isPortOpened); ClosePortCommand = new RelayCommand(ClosePort, () => _isPortOpened); GetPortsAvailableCommand = new RelayCommand(GetPortsAvailable); _paramLogger = paramLogger; _ainsCounterRaisable = ainsCounterRaisable; _cycleThreadHolder = cycleThreadHolder; _ainSettingsReader = ainSettingsReader; _ainSettingsReadNotify = ainSettingsReadNotify; _ainSettingsWriter = ainSettingsWriter; // Блоки АИН в системе: AinsCountInSystem = new List <int> { 1, 2, 3 }; SelectedAinsCount = AinsCountInSystem.First(); var ainSettingsReadedWriter = new AinSettingsReaderWriter(_ainSettingsReader, _ainSettingsWriter); _engineSettingsReader = engineSettingsReader; _engineSettingsWriter = engineSettingsWriter; _engineSettingsReadNotify = engineSettingsReadNotify; _engineSettingsReadNotifyRaisable = engineSettingsReadNotifyRaisable; _engineSettingsStorage = engineSettingsStorage; _engineSettingsStorageSettable = engineSettingsStorageSettable; _engineSettingsStorageUpdatedNotify = engineSettingsStorageUpdatedNotify; AinCommandAndCommonTelemetryVm = new AinCommandAndCommonTelemetryViewModel( new AinCommandAndMinimalCommonTelemetryViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 0, ainSettingsStorage, storageUpdatedNotify), new TelemetryCommonViewModel(), _commandSenderHost, _targetAddressHost, _uiRoot, _notifySendingEnabled); _cycleThreadHolder.RegisterAsCyclePart(AinCommandAndCommonTelemetryVm); TelemtryVm = new TelemetryViewModel(_uiRoot, _commandSenderHost, _targetAddressHost, _logger, _cycleThreadHolder, _ainsCounterRaisable, _paramLogger, _notifySendingEnabled); SettingsVm = new SettingsViewModel(_uiRoot, _logger, ainSettingsReadedWriter, _ainSettingsReadNotify, ainSettingsReadNotifyRaisable, ainSettingsStorage, ainSettingsStorageSettable, storageUpdatedNotify, _ainsCounterRaisable, _commandSenderHost, _targetAddressHost, _notifySendingEnabled, _engineSettingsReader, _engineSettingsWriter, _engineSettingsReadNotify, _engineSettingsReadNotifyRaisable, _engineSettingsStorage, _engineSettingsStorageSettable, _engineSettingsStorageUpdatedNotify, _debugLogger); // TODO: can be moved to app.xaml.cs if needed ArchiveVm = new ArchivesViewModel( new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 0), new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 1)); MnemonicChemeVm = new MnemonicChemeViewModel(Path.Combine(Environment.CurrentDirectory, "mnemoniccheme.png")); OldLookVm = new OldLookViewModel(_uiRoot, windowSystem, _commandSenderHost, _targetAddressHost, _notifySendingEnabled, this, _logger, _debugLogger, _cycleThreadHolder, _ainsCounterRaisable, _paramLogger, ainSettingsStorage, storageUpdatedNotify); _ain1StateColor = Colors.Gray; _ain2StateColor = Colors.Gray; _ain3StateColor = Colors.Gray; _ain1IsUsed = true; _ain2IsUsed = false; _ain3IsUsed = false; _ainsCounterRaisable.AinsCountInSystemHasBeenChanged += ainsCount => { switch (ainsCount) { case 1: Ain1IsUsed = true; Ain2IsUsed = false; Ain3IsUsed = false; break; case 2: Ain1IsUsed = true; Ain2IsUsed = true; Ain3IsUsed = false; break; case 3: Ain1IsUsed = true; Ain2IsUsed = true; Ain3IsUsed = true; break; default: throw new Exception("Такое число АИН в системе не поддерживается"); } }; AinCommandAndCommonTelemetryVm.AinsLinkInformationHasBeenUpdated += (ain1Error, ain2Error, ain3Error) => { Ain1StateColor = ain1Error.HasValue ? ain1Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; Ain2StateColor = ain2Error.HasValue ? ain2Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; Ain3StateColor = ain3Error.HasValue ? ain3Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; }; _notifySendingEnabled.SendingEnabledChanged += isEnabled => { // TODO: execution in ui thread Ain1StateColor = Colors.Gray; Ain2StateColor = Colors.Gray; Ain3StateColor = Colors.Gray; }; EngineAutoSetupVm = new EngineAutoSetupViewModel( new TableViewModel("Начальные значения:", _logger), new TableViewModel("После тестирования:", _logger), _notifySendingEnabled, _ainSettingsReader, _ainSettingsReadNotify, _ainSettingsWriter, _uiRoot, _logger, _commandSenderHost, _targetAddressHost, bsEthernetReadCycleModel); _logger.Log("Программа загружена"); }