private void AddNewSocketInfoWithSave(string ip, int port, string signName, int deviceNumber, string deviceHeader, IoTSocketType iotSocketType) { var iotSocketInfo = new IoTSocketInfo(ip, port, signName, iotSocketType); IoTSocketInfos.Add(iotSocketInfo); var deviceSettings = IoTDeviceSettings.GetIoTDeviceSettings(); deviceSettings.SocketSettings.Add(new IoTSocketSettings(ip, port, signName, iotSocketType)); if (IoTDeviceService.SaveSettings()) { iotSocketInfo.AddIoTDeviceInfoWithSave(deviceNumber, deviceHeader); } }
private void InitRemoveIpAddressCommand() { RemoveIpAddressCommand = new RelayCommand(() => { var dialog = new RemoveItemsView("删除IP地址", IoTSocketInfos.Select(s => s.SignName).ToList()); if (dialog.ShowDialog() == true) { var removeSignName = dialog.SelectedItems; foreach (var signName in removeSignName) { var serialPortInfo = IoTSocketInfos.FirstOrDefault(s => s.SignName == signName); if (serialPortInfo != null) { serialPortInfo.Cleanup(); IoTSocketInfos.Remove(serialPortInfo); } } IoTDeviceService.SaveSettings(); } }); }
public static IoTDeviceSettings GetIoTDeviceSettings() { return((IoTDeviceSettings)IoTDeviceService.GetIoTDeviceService().DeviceSettings); }