// Click "Exit" on ContextMenu private static void ExitApplication(object sender, EventArgs e) { if (Configure != null) { Configure.Dispose(); } // if (About != null) { About.Dispose(); } // if (IrdaComPort.isOpen) { IrdaComPort.Close(); } // tmrProgram.Enabled = false; tmrProgram.Dispose(); // IrdaContextMenu.Dispose(); IrdaNotifyIcon.Dispose(); // Application.Exit(); }
// Button Open/Close Click private void btPortOpenClose_MouseClick(object sender, MouseEventArgs e) { if (ComPort.isOpen) { tmrConfigure.Enabled = false; tbReceive.Clear(); ComPort.Close(); btPortOpenClose.Text = "Open"; gbPortName.Enabled = true; } else { ComPort.Open(); if (ComPort.isOpen) { tmrConfigure.Enabled = true; btPortOpenClose.Text = "Close"; gbPortName.Enabled = false; } else { StatusLabel.ForeColor = Color.Red; } } StatusLabel.Text = "Port " + ComPort.Name + " " + ComPort.Status; }