public ISessionDto Unwrap(Control obj) { var control = obj as ModbusControl; var dto = new MasterDto { Name = control.Text }; control.FromUI(dto); return(dto); }
public void ToUI(MasterDto dto) { dto.Serial.CopyTo(serial); context.Config = dto.Config.Clone(); timer.Interval = dto.Config.FixedTimer(); pollCheckBox.Checked = dto.PollInputs; comboBoxSerialPortName.Text = dto.SerialPortName; textBoxTcpIP.Text = dto.TcpIP; numericUpDownTcpPort.Value = dto.TcpPort; foreach (var settings in dto.Controls) { AddControl(settings.Get("$Type"), settings); } }
public void FromUI(MasterDto dto) { dto.Serial = serial; dto.Config = context.Config.Clone(); dto.PollInputs = pollCheckBox.Checked; dto.SerialPortName = comboBoxSerialPortName.Text; dto.TcpIP = textBoxTcpIP.Text; dto.TcpPort = (int)numericUpDownTcpPort.Value; foreach (var control in panelContainer.Controls) { var wrapper = (WrapperControl)control; var payload = (IoControl)wrapper.Control; var name = wrapper.ItemName; var settings = payload.GetSettings(); settings.Put("$Type", payload.GetType().Name); settings.Put("$Name", name); dto.Controls.Add(settings); } }