private void AddNewSerialPortInfoWithSave(SerialPortSettingsInfo serialPortSettingsInfo, PLCSettingsInfo plcSettingsInfo) { var plcSerialPortInfo = new PLCSerialPortInfo(serialPortSettingsInfo.Current.Item1); PLCSerialPortInfos.Add(plcSerialPortInfo); var deviceSettings = PLCDeviceSettings.GetPLCDeviceSettings(); deviceSettings.SerialPortSettings.Add(new PLCSerialPortSettings(serialPortSettingsInfo.Current.Item1)); if (PLCDeviceService.SaveSettings()) { plcSerialPortInfo.AddPLCDeviceInfoWithSave(plcSettingsInfo.Current); } }
private void InitLoadedCommand() { LoadedCommand = new RelayCommand(() => { if (_isLoaded) { return; } _isLoaded = true; var deviceSettings = PLCDeviceSettings.GetPLCDeviceSettings(); foreach (var projectorSerialPortSettings in deviceSettings.SerialPortSettings) { var projectorSerialPortInfo = new PLCSerialPortInfo(projectorSerialPortSettings.GetSerialPortInfo()); foreach (var projectorDetailDeviceSettingse in projectorSerialPortSettings.PLCDetailDevicesSettings) { projectorSerialPortInfo.PLCInfos.Add(new PLCDeviceInfo(projectorDetailDeviceSettingse.GetPLCInfo(), projectorSerialPortSettings.PortName)); } PLCSerialPortInfos.Add(projectorSerialPortInfo); } }); }