private void SavePhotoAsync(Action <string> callback = null) { TLFileLocation location = null; var profilePhoto = CurrentItem as TLUserProfilePhoto; if (profilePhoto != null) { location = profilePhoto.PhotoBig as TLFileLocation; } var photo = CurrentItem as TLPhoto; if (photo != null) { TLPhotoSize size = null; var sizes = photo.Sizes.OfType <TLPhotoSize>(); const double width = 640.0; foreach (var photoSize in sizes) { if (size == null || Math.Abs(width - size.W.Value) > Math.Abs(width - photoSize.W.Value)) { size = photoSize; } } if (size == null) { return; } location = size.Location as TLFileLocation; } var chatPhoto = CurrentItem as TLChatPhoto; if (chatPhoto != null) { location = chatPhoto.PhotoBig as TLFileLocation; } if (location == null) { return; } var fileName = String.Format("{0}_{1}_{2}.jpg", location.VolumeId, location.LocalId, location.Secret); Execute.BeginOnThreadPool(() => ImageViewerViewModel.SavePhoto(fileName, callback)); }
private static void SavePhotoAsync(TLDecryptedMessageMediaPhoto mediaPhoto, Action <string> callback = null) { var location = mediaPhoto.Photo as TLEncryptedFile; if (location == null) { return; } var fileName = String.Format("{0}_{1}_{2}.jpg", location.Id, location.DCId, location.AccessHash); Execute.BeginOnThreadPool(() => ImageViewerViewModel.SavePhoto(fileName, callback)); }