/// <summary> /// Button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStartStop_Click(object sender, EventArgs e) { //if proxy has to start if (btnStartStop.Text.Equals("Start")) { tbPort.Enabled = false; try { AddConsoleLine(string.Format("\n====Starting PortResourceProxy on Port: {0}===\n", tbPort.Text)); _Proxy = new PortResourceProxy(int.Parse(tbPort.Text),this); AddConsoleLine(string.Format("-> Status: Successful started!\n")); } catch (Exception ex) { AddConsoleLine(string.Format("-> Error: {0}", ex.Message)); AddConsoleLine("-> Status: PortResourceProxy not started!\n"); tbPort.Enabled = true; return; } btnStartStop.Text = "Stop"; } //if proxy has to stop else { try { _Proxy.Dispose(); btnStartStop.Text = "Start"; AddConsoleLine("-> Status: PortResourceProxy stoped!"); _Proxy = null; tbPort.Enabled = true; } catch (Exception exc) { AddConsoleLine("-> Error: " + exc.Message); } } }
/// <summary> /// Button click event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStartStop_Click(object sender, EventArgs e) { //if proxy has to start if (btnStartStop.Text.Equals("Start")) { tbPort.Enabled = false; try { AddConsoleLine(string.Format("\n====Starting PortResourceProxy on Port: {0}===\n", tbPort.Text)); _Proxy = new PortResourceProxy(int.Parse(tbPort.Text), this); AddConsoleLine(string.Format("-> Status: Successful started!\n")); } catch (Exception ex) { AddConsoleLine(string.Format("-> Error: {0}", ex.Message)); AddConsoleLine("-> Status: PortResourceProxy not started!\n"); tbPort.Enabled = true; return; } btnStartStop.Text = "Stop"; } //if proxy has to stop else { try { _Proxy.Dispose(); btnStartStop.Text = "Start"; AddConsoleLine("-> Status: PortResourceProxy stoped!"); _Proxy = null; tbPort.Enabled = true; } catch (Exception exc) { AddConsoleLine("-> Error: " + exc.Message); } } }