Пример #1
0
 private void ClosePort()
 {
     if (_access != null)
     {
         _access.Close();
         _access = null;
     }
     SerialPortOperate.ClosePort();
 }
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     if (CanClose)
     {
         base.OnFormClosing(e);
     }
     else
     {
         if (!Para.StationGrade.Contains("台站"))
         {
             return;
         }
         if (e.CloseReason == CloseReason.UserClosing)
         {
             e.Cancel = true;
         }
         else
         {
             _serialPort?.ClosePort();
         }
     }
 }