public void Connect(SerialPortViewModel serialPort) { if (serialPort == null) { throw new ArgumentNullException("serialPort"); } SerialPort = serialPort; _simulationForm = new SimulatedSerialPortForm { SerialPortDescription = string.Format("{0} (DtrEnable: {1})", serialPort.DisplayValue, serialPort.DtrEnable) }; _simulationForm.Show(); }
public MainViewModel() { SerialPort = new SerialPortViewModel(); Receiver = new MessageReceiver(); Sender = new MessageSender(); Messages = new MessagesViewModel(); // hmm Receiver.Messages = Messages; Messages.Sender = Sender; Sender.Messages = Messages; SerialPort.Receiver = Receiver; SerialPort.Sender = Sender; SerialPort.Messages = Messages; Receiver.Port = SerialPort.Port; Sender.Port = SerialPort.Port; }
private void HandleSelectedPortChanged(object sender, System.EventArgs e) { var viewModel = DataContext as SerialPortSelectorViewModel; var viewModelSelection = viewModel.SelectedSerialPortViewModel; var selection = sender as Gtk.TreeSelection; var selectedItemPaths = selection.GetSelectedRows(); SerialPortViewModel newSelectedItem = null; foreach (var path in selectedItemPaths) { Gtk.TreeIter iter; if (selection.TreeView.Model.GetIter(out iter, path)) { var item = selection.TreeView.Model.GetValue(iter, 0) as SerialPortViewModel; newSelectedItem = item; if (newSelectedItem != null) { break; } } } viewModel.SelectedSerialPortViewModel = newSelectedItem; INTV.Shared.ComponentModel.CommandManager.InvalidateRequerySuggested(); }
public SerialPortWindow() { InitializeComponent(); viewModel = new SerialPortViewModel(); }
private void cboSerialPort_SelectedValueChanged(object sender, EventArgs e) { SerialPort = (SerialPortViewModel)cboSerialPort.SelectedValue; chkDtrEnable.Checked = SerialPort.DtrEnable; }
private void cmdConnect_Click(object sender, EventArgs e) { SerialPort = (SerialPortViewModel)cboSerialPort.SelectedValue; SerialPort.DtrEnable = chkDtrEnable.Checked; }
private void InitailizeSerialPort(SerialPortViewModel serialPort) { _serialPortAdapter.Connect(serialPort); LogMessage(string.Format("Connected to {0}", serialPort.DisplayValue)); }