Esempio n. 1
0
        private void DisplayError(object sender, EventArgs e)
        {
            canTrans.ErrorEventArgs args = (canTrans.ErrorEventArgs)e;
            EventHandler            TextBoxDisplayUpdate = delegate
            {
                richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
            };

            try { Invoke(TextBoxDisplayUpdate); } catch { };
        }
Esempio n. 2
0
 void trans_init()
 {
     /* 使用事件委托传参 */
     driverTrans.EventTxFarms += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.FarmsEventArgs args      = (canTrans.FarmsEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.EventRxFarms += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.FarmsEventArgs args      = (canTrans.FarmsEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.EventRxMsgs += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.RxMsgsEventArgs RxMsgs = (canTrans.RxMsgsEventArgs)e1;
         autoResponse(StringToHex(RxMsgs.ToString()));
     }
         );
     driverTrans.EventError += new EventHandler(
         (sender1, e1) =>
     {
         canTrans.ErrorEventArgs args      = (canTrans.ErrorEventArgs)e1;
         EventHandler TextBoxDisplayUpdate = delegate
         {
             richTextBoxDisplay.AppendText(args.ToString() + "\r\n");
         };
         try { Invoke(TextBoxDisplayUpdate); } catch { };
     }
         );
     driverTrans.CanRead  += driver.ReadData;
     driverTrans.CanWrite += driver.WriteData;
 }