/// <summary> /// Removes a given SannerDataItem from the scanner information list /// </summary> /// <param name="removedScannerInfo">ScannerDataItem that is to be removed from the list </param> private void RemoveFromList(ScannerDataItem removedScannerInfo) { // If currently selected scanner is being removed, make sure // to select a different one if (currentScannerDeviceId == removedScannerInfo.Id) { String scannerIdToSelect = (scannerInfoList.Count == 0) ? null : scannerInfoList.ElementAt(0).Id; ChangeCurrentlySelectedScanner(scannerIdToSelect); } scannerInfoList.Remove(removedScannerInfo); OnPropertyChanged("ScannerListSize"); }
/// <summary> /// Event handler a scanner being added /// </summary> /// <param name="sender"></param> /// <param name="deviceInfo">The device info for the device which was added</param> private async void OnScannerAdded(DeviceWatcher sender, DeviceInformation deviceInfo) { await MainPage.Current.Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Normal, () => { MainPage.Current.NotifyUser(String.Format("Scanner with device id {0} has been added", deviceInfo.Id), NotifyType.StatusMessage); // search the device list for a device with a matching device id ScannerDataItem match = FindInList(deviceInfo.Id); // If we found a match then mark it as verified and return if (match != null) { match.Matched = true; return; } // Add the new element to the end of the list of devices AppendToList(deviceInfo); } ); }