private async Task LoadPhoto([NotNull] StudentEntity student) { var path = await _photoService.DownloadPhoto(StudentEntity.CardUidToId(student.CardUid)); var image = _photoService.GetImage(path); RunInUiThread(() => this.StudentPhoto = image); }
private async Task <BitmapImage> LoadStudentPhoto(StudentEntity entity) { if (entity == null) { return(null); } try { var photoPath = await this.PhotoService.DownloadPhoto(StudentEntity.CardUidToId(entity.CardUid)); return(photoPath == null ? null : this.PhotoService.GetImage(photoPath)); } catch (Exception e) { Debug.WriteLine(e); throw; } }
private void UpdatePhoto(StudentEntity entity) { if (entity == null) { return; } this.StudentPhoto = null; Task.Run(async() => { var photoPath = await this.PhotoService.DownloadPhoto(StudentEntity.CardUidToId(entity.CardUid)); if (photoPath == null) { return; } var image = this.PhotoService.GetImage(photoPath); RunInUiThread(() => this.StudentPhoto = image); } ); }
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (Popup.IsOpen) { Popup.IsOpen = false; return; } if (!(this.DataContext is StudentLessonViewModel view)) { return; } var service = view.ServiceLocator.Locate <PhotoService>(); var path = await service.DownloadPhoto(StudentEntity.CardUidToId(view.Model.CardUid)); if (string.IsNullOrWhiteSpace(path)) { return; } Image.Source = service.GetImage(path); Popup.IsOpen = true; }
private Task <string[]> LoadImages(IEnumerable <StudentEntity> students) { return(Task.WhenAll(students.Select(entity => this.PhotoService.DownloadPhoto(StudentEntity.CardUidToId(entity.CardUid))))); }