// When form is closing private void frmServer_FormClosing(object sender, FormClosingEventArgs e) { if (myServer != null) { myServer.Stop(); myServer = null; } }
// When form loads private void frmServer_Load(object sender, EventArgs e) { lblServer.Text = "Intelligent Path Planning Algorithm Server takes path " + "planning requests over the network. Requests will be " + "queued and processed sequentially. Eacah request includes " + "a matrix representing the probability distribution, the " + "starting position, (optionally) the ending position, " + "and the flight duration (in seconds), together with the " + "UAV type (fix-wing or copter) and detection type (" + "fixed amount, fixed amount in percentage, or fixed percentage)."; myServer = new PathPlanningServer(this); }
// When Start Server/Stop Server button is pressed private void btnServerSwitch_Click(object sender, EventArgs e) { if (!blnServerRunning) { btnServerSwitch.Text = "Stop Server"; btnServerSwitch.BackColor = Color.Red; blnServerRunning = true; myServer = new PathPlanningServer(this); } else { btnServerSwitch.Text = "Start Server"; btnServerSwitch.BackColor = Color.White; blnServerRunning = false; //TODO shutting down all connections myServer.Stop(); myServer = null; } }