예제 #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);
                    }
                }
            }
        }
예제 #2
0
 private void UnhideDeviceBtn_Click(object sender, EventArgs e)
 {
     if (HiddenDevicesListBox.SelectedIndex != -1)
     {
         string hid = HiddenDevicesListBox.SelectedItem.ToString().Split(':')[1];
         HIDGuardianAPI.UnhideDevice(hid);
         MoveSelectedListBoxItem(HiddenDevicesListBox, AvailableDevicesListBox);
         HIDGuardianAPI.ReplugHID(hid);
     }
 }
예제 #3
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.
     }
 }
예제 #4
0
        private void UnhideDevices()
        {
            string prevaffecteddevices = HIDGuardianAPI.GetAffectedDevicesList(); // Get a list of available hidden devices from last run.

            foreach (string prevaffecteddevice in prevaffecteddevices.Split(';'))
            {
                HIDGuardianAPI.UnhideDevice(prevaffecteddevice);
                HIDGuardianAPI.ReplugHID(prevaffecteddevice); // Iterate over the list of affected devices from the last run and replug them (to refresh them).
            }
        }
예제 #5
0
 private void UnhideAllBtn_Click(object sender, EventArgs e)
 {
     HIDGuardianAPI.UnhideAllDevices();
     foreach (var device in HiddenDevicesListBox.Items)
     {
         string hid = device.ToString().Split(':')[1];
         HIDGuardianAPI.UnhideDevice(hid);
         HIDGuardianAPI.ReplugHID(hid);
     }
     MoveListBoxItems(HiddenDevicesListBox, AvailableDevicesListBox);
 }