private static async Task <bool> PerformMandatoryChecks() { bool available = false; try { var smsDevices = await DeviceInformation.FindAllAsync(SmsDevice2.GetDeviceSelector(), null); foreach (var smsDevice in smsDevices) { try { SmsDevice2 dev = SmsDevice2.FromId(smsDevice.Id); switch (dev.DeviceStatus) { case SmsDeviceStatus.Ready: { return(true); } } } catch { } } } catch { available = false; } return(available); }
// Methods private static async Task <ObservableCollection <CellularLineControl> > GetSmsDevices() { ObservableCollection <CellularLineControl> collection = new ObservableCollection <CellularLineControl>(); var smsDevices = await DeviceInformation.FindAllAsync(SmsDevice2.GetDeviceSelector(), null); foreach (var smsDevice in smsDevices) { try { SmsDevice2 dev = SmsDevice2.FromId(smsDevice.Id); CellularLineControl control = new CellularLineControl(dev); collection.Add(control); } catch { } } return(collection); }
private async void Load() { var smsDevices = await DeviceInformation.FindAllAsync(SmsDevice2.GetDeviceSelector(), null); foreach (var smsDevice in smsDevices) { try { SmsDevice2 dev = SmsDevice2.FromId(smsDevice.Id); CellularLineControl control = new CellularLineControl(dev); cellularlineControls.Add(control); CellularLineComboBox.Items.Add(new ComboBoxItem() { Content = control }); } catch { } } }
private async void btnGetDeviceInfo_Click(object sender, RoutedEventArgs e) { try { var selector = SmsDevice2.GetDeviceSelector(); await new MessageDialog("before").ShowAsync(); var devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(selector); await new MessageDialog("after").ShowAsync(); lbDevices.Items.Clear(); foreach (var device in devices) { lbDevices.Items.Add(device.Id); } } catch (Exception ex) { await new MessageDialog(ex.Message).ShowAsync(); } }