private bool _AddLocationAttachment() { if (!string.IsNullOrEmpty(App.Current.EntityService.AttachedLatitude) && !string.IsNullOrEmpty(App.Current.EntityService.AttachedLongitude)) { try { string uri = String.Format(AppResources.GeolocationMapUriFormatMessage, App.Current.EntityService.AttachedLatitude.Replace(",", "."), App.Current.EntityService.AttachedLongitude.Replace(",", ".")); var avm = new AttachmentViewModel(-1, -1, -1, AttachmentType.Location, uri, null, null, null, null); _model.Add(avm); string filename = CommonHelper.DoDigest(uri); var photosToLoad = new List <AvatarLoadItem>(); photosToLoad.Add(new AvatarLoadItem(1, uri, filename)); var service = new AsyncAvatarsLoader(); if (photosToLoad.Any()) { service.LoadAvatars(photosToLoad.ToList(), id => { Deployment.Current.Dispatcher.BeginInvoke(() => { try { ImageCache cache = new ImageCache(); BitmapImage image = cache.GetItem(filename); if (image != null && image.PixelHeight > 0 && image.PixelWidth > 0) { avm.AttachPhoto = image; } } catch (Exception ex) { Debug.WriteLine("_AddLocationAttachment failed in AttachmentsPage: " + ex.Message); } }); }, null); } } catch (Exception ex) { Debug.WriteLine("Load attached location photo failed " + ex.Message); } return(true); } return(false); }
private void _LoadPhotos() { try { var service = new AsyncAvatarsLoader(); // From map of attachment view model and load items get collection of avatar load items... var photosToLoad = _photosToLoad.Select(x => x.Value); if (photosToLoad.Any()) { service.LoadAvatars(photosToLoad.ToList(), _UpdatePhoto, null); } } catch (Exception ex) { Debug.WriteLine("LoadPhotos failed " + ex.Message); } }