private void StartWatcher() { aqsFilterTextBox.IsEnabled = false; startWatcherButton.IsEnabled = false; resultCollection.Clear(); // Request some additional properties. In this saample, these extra properties are just used in the ResultsListViewTemplate. // Take a look there in the XAML. Also look at the converter used by the XAML GeneralPropertyValueConverter. In general you just use // DeviceInformation.Properties["<property name>"] to get a property. e.g. DeviceInformation.Properties["System.Devices.InterfaceClassGuid"]. string[] requestedProperties = new string[] { "System.Devices.InterfaceClassGuid", "System.ItemNameDisplay" }; // Use AQS string filter from the text box DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher( aqsFilterTextBox.Text, requestedProperties); rootPage.NotifyUser("Starting Watcher...", NotifyType.StatusMessage); deviceWatcherHelper.StartWatcher(deviceWatcher); stopWatcherButton.IsEnabled = true; stopWatcherButton.Focus(FocusState.Keyboard); aqsFilterTextBox.IsEnabled = true; }
private void StartWatcher() { startWatcherButton.IsEnabled = false; resultCollection.Clear(); DeviceWatcher deviceWatcher; // Get the device selector chosen by the UI then add additional constraints for devices that // can be paired or are already paired. DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; string selector = "(" + deviceSelectorInfo.Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; if (deviceSelectorInfo.Kind == DeviceInformationKind.Unknown) { // Kind will be determined by the selector deviceWatcher = DeviceInformation.CreateWatcher( selector, null // don't request additional properties for this sample ); } else { // Kind is specified in the selector info deviceWatcher = DeviceInformation.CreateWatcher( selector, null, // don't request additional properties for this sample deviceSelectorInfo.Kind); } rootPage.NotifyUser("Starting Watcher...", NotifyType.StatusMessage); deviceWatcherHelper.StartWatcher(deviceWatcher); stopWatcherButton.IsEnabled = true; }
private void StartWatcher() { startWatcherButton.IsEnabled = false; resultCollection.Clear(); // First get the device selector chosen by the UI. DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; DeviceWatcher deviceWatcher; if (null == deviceSelectorInfo.Selector) { // If the a pre-canned device class selector was chosen, call the DeviceClass overload deviceWatcher = DeviceInformation.CreateWatcher(deviceSelectorInfo.DeviceClassSelector); } else if (deviceSelectorInfo.Kind == DeviceInformationKind.Unknown) { // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call // Kind will be determined by the selector deviceWatcher = DeviceInformation.CreateWatcher( deviceSelectorInfo.Selector, null // don't request additional properties for this sample ); } else { // Kind is specified in the selector info deviceWatcher = DeviceInformation.CreateWatcher( deviceSelectorInfo.Selector, null, // don't request additional properties for this sample deviceSelectorInfo.Kind); } rootPage.NotifyUser("Starting Watcher...", NotifyType.StatusMessage); deviceWatcherHelper.StartWatcher(deviceWatcher); stopWatcherButton.IsEnabled = true; }
private void StartWatchers() { startWatcherButton.IsEnabled = false; resultCollection.Clear(); // Create a watcher for each DeviceInformationKind selected by the user foreach (DeviceInformationKind deviceInfoKind in ((DeviceInformationKindChoice)kindComboBox.SelectedItem).DeviceInformationKinds) { DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher( "", // AQS Filter string null, // requested properties deviceInfoKind); DeviceWatcherHelper deviceWatcherHelper = new DeviceWatcherHelper(resultCollection, Dispatcher); deviceWatcherHelper.UpdateStatus = false; // we will show our own status messages deviceWatcherHelper.DeviceChanged += OnDeviceListChanged; deviceWatcherHelpers.Add(deviceWatcherHelper); deviceWatcherHelper.StartWatcher(deviceWatcher); } stopWatcherButton.IsEnabled = true; stopWatcherButton.Focus(FocusState.Keyboard); }