Beispiel #1
0
        private void OnStopClicked(object sender, RoutedEventArgs e)
        {
            this.dataCheckBoxes = null;

            this.startButton.IsEnabled  = true;
            this.stopButton.IsEnabled   = false;
            this.listView.IsEnabled     = true;
            this.rescanButton.IsEnabled = true;

            this.rtb.Document.Blocks.Clear();
            this.layersWrapPanel.Children.Clear();
            this.Title = ApplicationInfo.AppNameVersion;
            this.reader.Dispose();
            this.reader = null;
        }
Beispiel #2
0
        private void UpdateDeviceList()
        {
            if (!this.listView.IsEnabled)
            {
                return;
            }

            var devices = new List <IIinputDevice>();

            devices.Add(VirtualKeyboard.Instance);
            devices.AddRange(DeviceScanner.GetHidKeyboards());
            devices.AddRange(DeviceScanner.GetHidMice());
            devices.AddRange(DeviceScanner.GetUsbGamepads());
            devices.AddRange(DeviceScanner.GetOtherHidDevices());
            var devicesToRemove = new List <IIinputDevice>();

            foreach (var device in devices)
            {
                if (device.DeviceType != DeviceType.Other)
                {
                    continue;
                }

                ushort vid        = Convert.ToUInt16(device.Vendor, 16);
                ushort pid        = Convert.ToUInt16(device.Product, 16);
                var    rawDevices = HidDataReader.GetDevices().Where(d => d.ProductId == pid && d.VendorId == vid);

                if (rawDevices.Count() == 0)
                {
                    devicesToRemove.Add(device);
                }
            }

            foreach (var deviceToRemove in devicesToRemove)
            {
                devices.Remove(deviceToRemove);
            }

            this.listView.ItemsSource   = devices;
            this.listView.SelectedIndex = -1;
            var view             = (CollectionView)CollectionViewSource.GetDefaultView(this.listView.ItemsSource);
            var groupDescription = new PropertyGroupDescription("DeviceType");

            view.GroupDescriptions.Add(groupDescription);

            this.lastData = new byte[0];
        }
Beispiel #3
0
        private void OnStartClicked(object sender, RoutedEventArgs e)
        {
            if (this.listView.SelectedIndex == -1)
            {
                MessageBox.Show("Please choose device first", "No device selected", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            int pid = 0;
            int vid = 0;

            try
            {
                pid = Convert.ToInt32(this.pid.Text, 16);
                vid = Convert.ToInt32(this.vid.Text, 16);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error, while parsing pid or vid: " + ex.Message);
                return;
            }

            if (pid < 0 || vid < 0)
            {
                MessageBox.Show("Error! Negative pid or vid are not accepted!");
                return;
            }

            this.reader                  = new HidDataReader(this);
            this.reader.Device           = (this.listView.SelectedItem as Device);
            this.reader.HidDataReceived += this.OnHidDataReceived;

            this.startButton.IsEnabled  = false;
            this.stopButton.IsEnabled   = true;
            this.listView.IsEnabled     = false;
            this.rescanButton.IsEnabled = false;
            this.Title = ApplicationInfo.AppName + " - " + (this.listView.SelectedItem as Device).FriendlyName;
        }
Beispiel #4
0
        private void UpdateDeviceList()
        {
            if (!this.listView.IsEnabled)
            {
                return;
            }

            var devices = HidDataReader.GetDevices();

            foreach (var d in devices)
            {
                ushort vid = d.VendorId;
                ushort pid = d.ProductId;
            }

            this.listView.ItemsSource   = devices;
            this.listView.SelectedIndex = -1;
            var view             = (CollectionView)CollectionViewSource.GetDefaultView(this.listView.ItemsSource);
            var groupDescription = new PropertyGroupDescription("DeviceType");

            view.GroupDescriptions.Add(groupDescription);

            this.lastData = new byte[0];
        }