Beispiel #1
0
 private void base_bt_conn_Click(object sender, EventArgs e)
 {
     if (GameMac == null)
     {
         try
         {
             CNGPI.CNGPIGameMachine box = new CNGPI.CNGPIGameMachine(Devinfo, base_comname.Text.ToString());
             box.OnIODebug   += Box_OnIODebug;
             box.OnReviceMsg += Box_OnReviceMsg;
             if (box.Connect())
             {
                 GameMac = box;
             }
         }
         catch (Exception ex)
         {
             event_txt.AppendText(ex.ToString());
         }
         if (GameMac != null)
         {
             base_bt_conn.Text = "断开连接";
         }
     }
     else
     {
         GameMac.Dispose();
         GameMac           = null;
         base_bt_conn.Text = "连接并握手";
     }
     grp_gift.Enabled = GameMac != null;
 }
Beispiel #2
0
        private void base_bt_conn_Click(object sender, EventArgs e)
        {
            if (GameMac == null)
            {
                try
                {
                    Devinfo            = new CNGPI.DeviceInfo((uint)Int32.Parse(textBox2.Text, System.Globalization.NumberStyles.HexNumber));
                    Devinfo.DeviceType = 0x0004;
                    Devinfo.ID         = CNGPI.Utility.ByteToHex(Guid.NewGuid().ToByteArray());
                    Devinfo.SoftVer    = 120;
                    Devinfo.CNGPIVer   = 119;

                    CNGPI.CNGPIGameMachine box = new CNGPI.CNGPIGameMachine(Devinfo, base_comname.Text.ToString());
                    box.OnIODebug   += Box_OnIODebug;
                    box.OnReviceMsg += Box_OnReviceMsg;
                    if (box.Connect())
                    {
                        GameMac = box;
                    }
                }
                catch (Exception ex)
                {
                    event_txt.AppendText(ex.ToString());
                }
                if (GameMac != null)
                {
                    base_bt_conn.Text = "断开连接";
                }
            }
            else
            {
                GameMac.Dispose();
                GameMac           = null;
                base_bt_conn.Text = "连接并握手";
            }
        }