public MainForm() { InitializeComponent(); if (axVSPortAx1 == null) { axVSPortAx1 = new AxVSPortAx(); } if (axVSPortAx2 == null) { axVSPortAx2 = new AxVSPortAx(); } }
public MainForm(string title, SerialPort userSerialPort1, SerialPort userSerialPort2) { InitializeComponent(); this.Text = title; if (axVSPortAx1 == null) { axVSPortAx1 = new AxVSPortAx(); } if (axVSPortAx2 == null) { axVSPortAx2 = new AxVSPortAx(); } CreatePair(axVSPortAx3, userSerialPort1, axVSPortAx4, userSerialPort2); }
private void CreatePair(AxVSPortAx VSPort1, SerialPort SPort1, AxVSPortAx VSPort2, SerialPort SPort2) { if (VSPort1.IsCreated != VSPort2.IsCreated) { MessageBox.Show("One port was create", "Warning", MessageBoxButtons.OK); this.ForeColor = Color.Orange; return; } if ((VSPort1.CreatePort(SPort1.PortName) || VSPort1.Attach(SPort1.PortName)) && (VSPort2.CreatePort(SPort2.PortName) || VSPort2.Attach(SPort2.PortName))) { this.ForeColor = Color.Green; } else { MessageBox.Show("Cannot create pair", "Warning", MessageBoxButtons.OK); VSPort1.Delete(); VSPort2.Delete(); this.ForeColor = Color.Orange; } }