示例#1
0
 private void 启用ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (DGVUSBList.CurrentRow != null)
     {
         string id = DGVUSBList.CurrentRow.Cells["DGVUSBList_InstanceID"].Value.ToString();
         R.Toast.Show("启用 USB", DGVUSBList.CurrentRow.Index + " : " + id);
         if (USBTool.Enable(id))
         {
             DGVUSBList_Refresh();
         }
     }
 }
示例#2
0
        /// <summary>
        /// 禁用设备列表
        /// </summary>
        /// <param name="host"></param>
        /// <param name="model"></param>
        public static void Disable(string host, TcpDataModel model)
        {
            List <USBDeviceModel> list = Json.Byte2Object <List <USBDeviceModel> >(model.Data);

            if (Ls.Ok(list))
            {
                foreach (var item in list)
                {
                    if (USBTool.Disable(item.ID))
                    {
                        item.Running = false;
                    }
                }
            }
            R.Tx.TcppServer.Write(host, 20003001, Json.Object2Byte(list));
        }
示例#3
0
        /// <summary>
        /// 刷新 USB 设备列表信息
        /// </summary>
        public void Refresh()
        {
            if ((DateTime.Now - __RefreshTime).TotalSeconds > 1)
            {
                __InsertDevice = new List <USBDeviceModel>();
                __RemoveDevice = new List <USBDeviceModel>();

                var temp = USBTool.All().OrderBy(x => x.VID).OrderBy(x => x.PID).ToList();
                USBDictionary.Bind(ref temp);
                USBStorageTool.Bind(ref temp);
                if (__AllDevice != null)
                {
                    //对比插入的设备列表
                    __InsertDevice = Except(temp, __AllDevice);
                    //对比移除的设备列表
                    __RemoveDevice = Except(__AllDevice, temp);
                }
                //更新当前最新USB列表
                __AllDevice = temp;

                __RefreshTime = DateTime.Now;
            }
        }