Beispiel #1
0
 /// <summary>
 /// 有设备改变运行状态
 /// </summary>
 /// <param name="state"></param>
 /// <param name="data"></param>
 public void OnDeviceChangeStateHandler(int state, byte[] data)
 {
     if (state == 203)
     {
         string token      = ClassStatic.GetString(data);
         string stateDrive = token.Substring(token.Length - 2, 2);
         token = token.Substring(0, token.Length - 2);
         this.Invoke(new Action(() => {
             if (controlDeviceOnline.ContainsKey(token))
             {
                 ControlDevice temp = controlDeviceOnline[token];
                 temp.Status        = (stateDrive == "在线" ? 0 : 1);
             }
         }));
     }
 }
Beispiel #2
0
        /// <summary>
        /// 获取设备列表回调函数
        /// </summary>
        /// <param name="state"></param>
        /// <param name="data"></param>
        private void GetDeviceList_Callback(bool state, byte[] data)
        {
            if (state)
            {
                this.Invoke(new Action(() => {
                    ClassStatic.ListDriveData listDriveData = ClassStatic.GetListDriveData(data);
                    if (listDriveData != null)
                    {
                        DeviceOnlineCount = 1;
                        foreach (ClassStatic.ListDrive drive in listDriveData.list)
                        {
                            ControlDevice temp = new ControlDevice();
                            temp.DeviceId      = drive.mac;
                            temp.Title         = drive.name;
                            temp.Mac           = drive.mac;
                            temp.Portrait      = Convert.ToInt32(drive.pid);
                            temp.Status        = drive.state;
                            if (drive.token != "" && drive.token != null)
                            {
                                DeviceOnlineCount++;
                                controlDeviceOnline.Add(drive.token, temp);
                                flowLayoutPanelList.Controls.Add(temp);
                            }
                            else
                            {
                                controlDeviceOffline.Add(temp.Mac, temp);
                            }
                        }
                        foreach (ControlDevice temp in controlDeviceOffline.Values)
                        {
                            flowLayoutPanelList.Controls.Add(temp);
                        }

                        labelListNum.Text = "我的设备(" + DeviceOnlineCount + "/" + (listDriveData.list.Count + 1) + ")";
                    }
                }));
            }
        }