private void btnCreatePair_Click(object sender, System.EventArgs e) { if (axVSPortAx1.IsCreated != axVSPortAx2.IsCreated) { MessageBox.Show("One port was create", "Warning", MessageBoxButtons.OK); return; } if (axVSPortAx1.IsCreated) { if (axVSPortAx1.Delete() && axVSPortAx2.Delete()) { btnCreatePair.Text = "Create pair"; btnResetBus.Enabled = true; btnCreatePort.Enabled = true; EnableControl(true); Redirect = false; AddLog("Delete pair " + strPort1.Text + "<->" + strPort2.Text); } else { MessageBox.Show("Pair cannot be deleted: one of the ports is open.", "Warning", MessageBoxButtons.OK); axVSPortAx1.CreatePort(strPort1.Text); axVSPortAx2.CreatePort(strPort2.Text); } } else { //String strUser = checkUser.Checked ? axVSPortAx1.IdUserSession : ""; if ((axVSPortAx1.CreatePort(strPort1.Text) || axVSPortAx1.Attach(strPort1.Text)) && (axVSPortAx2.CreatePort(strPort2.Text) || axVSPortAx2.Attach(strPort2.Text))) { btnResetBus.Enabled = false; btnCreatePort.Enabled = false; btnCreatePair.Text = "Delete pair"; EnableControl(false); Redirect = true; AddLog("Create pair " + strPort1.Text + ("<->") + strPort2.Text); LoadAccessList(); axVSPortAx1.SetWiring(0x20, 0x10, 0, 0); axVSPortAx2.SetWiring(0x20, 0x10, 0, 0); BuildPortSettings(); } else { MessageBox.Show("Cannot create pair", "Warning", MessageBoxButtons.OK); axVSPortAx1.Delete(); axVSPortAx2.Delete(); } } }
private void btnCreatePort_Click(object sender, System.EventArgs e) { if (axVSPortAx1.IsCreated) { if (axVSPortAx1.Delete()) { btnCreatePair.Enabled = true; btnResetBus.Enabled = true; btnCreatePort.Text = "Create port"; EnableControl(true); btnSendFile.Enabled = false; AddLog("Delete port " + strPort1.Text); } else { MessageBox.Show("Port cannot be deleted: the ports is open.", "Warning", MessageBoxButtons.OK); } } else { //String strUser = checkUser.Checked ? axVSPortAx1.IdUserSession : ""; if (axVSPortAx1.CreatePort(strPort1.Text) || axVSPortAx1.Attach(strPort1.Text)) { chkBreak.Checked = false; btnResetBus.Enabled = false; axVSPortAx1.SetStrictBaudrate(chkStrict.Checked); btnCreatePair.Enabled = false; btnCreatePort.Text = "Delete port"; EnableControl(false); btnSendFile.Enabled = true; AddLog("Create port " + strPort1.Text); LoadAccessList(); axVSPortAx1.SetWiring(0x20, 0x10, 0, 0); BuildPortSettings(); } else { MessageBox.Show("Cannot be created port", "Warning", MessageBoxButtons.OK); } } }
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; } }