Ejemplo n.º 1
0
        private void HandleDevices() // Add available and hidden devices from previous time, that the application stored in the file (settings.ini). All hidden devices are stored on application exit.
        {
            string devices = HIDGuardianAPI.GetDevicesList().TrimEnd(';');

            if (AffectedDevices != "") // Add affected hidden devices from last time acquired from the settings.ini
            {
                foreach (string affecteddevice in AffectedDevices.Split(';'))
                {
                    if (affecteddevice.Contains(":"))
                    {
                        HIDGuardianAPI.HideDevice(affecteddevice.Split(':')[1]);
                        HIDGuardianAPI.ReplugHID(affecteddevice.Split(':')[1]);
                        HiddenDevicesListBox.Items.Add(affecteddevice);
                    }
                }
            }

            if (devices != "") // Add all (available) devices excluding the ones from the last segment.
            {
                foreach (string device in devices.Split(';'))
                {
                    if (!AffectedDevices.Contains(device))
                    {
                        AvailableDevicesListBox.Items.Add(device);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void HideDeviceBtn_Click(object sender, EventArgs e)
 {
     if (AvailableDevicesListBox.SelectedIndex != -1)
     {
         string hid = AvailableDevicesListBox.SelectedItem.ToString().Split(':')[1];
         HIDGuardianAPI.HideDevice(hid);
         MoveSelectedListBoxItem(AvailableDevicesListBox, HiddenDevicesListBox);
         HIDGuardianAPI.ReplugHID(hid); // ReplugHID is used to fresh the devices so the user does not have to restart or unplug/replug the devices.
     }
 }