async void EnumerateDeviceInterfaces(object sender, RoutedEventArgs eventArgs) { FocusState focusState = EnumerateInterfacesButton.FocusState; EnumerateInterfacesButton.IsEnabled = false; DeviceInterfacesOutputList.Items.Clear(); try { var selector = "System.Devices.InterfaceClassGuid:=\"" + InterfaceClassGuid.Text + "\""; var interfaces = await DeviceInformation.FindAllAsync(selector, null); rootPage.NotifyUser(interfaces.Count + " device interface(s) found\n\n", NotifyType.StatusMessage); foreach (DeviceInformation deviceInterface in interfaces) { DeviceThumbnail thumbnail = await deviceInterface.GetThumbnailAsync(); DeviceThumbnail glyph = await deviceInterface.GetGlyphThumbnailAsync(); DeviceInterfacesOutputList.Items.Add(new DisplayItem(deviceInterface, thumbnail, glyph)); } } catch (ArgumentException) { //The ArgumentException gets thrown by FindAllAsync when the GUID isn't formatted properly //The only reason we're catching it here is because the user is allowed to enter GUIDs without validation //In normal usage of the API, this exception handling probably wouldn't be necessary when using known-good GUIDs rootPage.NotifyUser("Caught ArgumentException. Verify that you've entered a valid interface class GUID.", NotifyType.ErrorMessage); } EnumerateInterfacesButton.IsEnabled = true; EnumerateInterfacesButton.Focus(focusState); }
private async void UpdateGlyphBitmapImage() { DeviceThumbnail deviceThumbnail = await DeviceInformation.GetGlyphThumbnailAsync(); var glyphBitmapImage = new BitmapImage(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); GlyphBitmapImage = glyphBitmapImage; OnPropertyChanged("GlyphBitmapImage"); }
public DisplayItem(DeviceInformation deviceInterface, DeviceThumbnail thumbnail, DeviceThumbnail glyph) { name = (string)deviceInterface.Properties["System.ItemNameDisplay"]; id = "ID: " + deviceInterface.Id; isEnabled = "IsEnabled: " + deviceInterface.IsEnabled; thumb = thumbnail; glyphThumb = glyph; }
private async void UpdateGlyphBitmapImage() { DeviceThumbnail deviceThumbnail = await deviceInfo.GetGlyphThumbnailAsync(); BitmapImage glyphBitmapImage = new BitmapImage(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); GlyphBitmapImage = glyphBitmapImage; RaisePropertyChanged("GlyphBitmapImage"); }
/// <summary> /// Load the glyph for this device /// </summary> private async void LoadGlyph() { await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { DeviceThumbnail deviceThumbnail = await DeviceInfo.GetGlyphThumbnailAsync(); BitmapImage glyphBitmapImage = new BitmapImage(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); Glyph = glyphBitmapImage; }); }
private async void BluetoothWatcher_Added(DeviceWatcher sender, DeviceInformation args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { using (DeviceThumbnail Thumbnail = await args.GetGlyphThumbnailAsync()) { BitmapImage Image = new BitmapImage(); BluetoothDeviceCollection.Add(new BluetoothDeivceData(args, Image)); await Image.SetSourceAsync(Thumbnail); } }); }
private async void GetThumbnail() { DeviceThumbnail thumb = await _information.GetGlyphThumbnailAsync(); Stream s = thumb.AsStreamForRead(); MemoryStream ms = new MemoryStream(); await s.CopyToAsync(ms); ms.Seek(0, SeekOrigin.Begin); WriteableBitmap wb = new WriteableBitmap(1, 1); await wb.SetSourceAsync(ms.AsRandomAccessStream()); _thumbnail = wb; OnPropertyChanged("Thumbnail"); }
/// <summary> /// Load the glyph for this device /// </summary> private async void LoadGlyph() { try { DeviceThumbnail deviceThumbnail = await DeviceInfo.GetGlyphThumbnailAsync(); BitmapImage glyphBitmapImage = new BitmapImage(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); Glyph = glyphBitmapImage; } catch (Exception) { Glyph = null; } }
private async void UpdateGlyphBitmapImage() { BitmapImage glyphBitmapImage; #if NOT_IOT_CORE glyphBitmapImage = new BitmapImage(); DeviceThumbnail deviceThumbnail = await deviceInfo.GetGlyphThumbnailAsync(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); #else string path = "ms-appx:///Assets/AAA.png"; glyphBitmapImage = new BitmapImage(new Uri(path, UriKind.Absolute)); #endif GlyphBitmapImage = glyphBitmapImage; OnPropertyChanged("GlyphBitmapImage"); }
private async void UpdateGlyphBitmapImage() { var glyphBitmapImage = new BitmapImage(); try { DeviceThumbnail deviceThumbnail = await DeviceInformation.GetGlyphThumbnailAsync(); await glyphBitmapImage.SetSourceAsync(deviceThumbnail); } catch (Exception ex) { // this means the device didn't have a device Glyph, which at this time I believe to be a problem with // the device's package. // in this case, we display a default bitmap } GlyphBitmapImage = glyphBitmapImage; OnPropertyChanged("GlyphBitmapImage"); }