void photoChooseTask_Completed(object sender, PhotoResult e) { var capturedPicture = new CapturedPictureViewModel(e.OriginalFileName, e.ChosenPhoto); //set mode for camera TransientState.Set("CapturedPictureViewModel", capturedPicture); }
private void cameraTask_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { // Get the image temp file from e.OriginalFileName. // Get the image temp stream from e.ChosenPhoto. // Don't keep either the temp stream or file name. var capturedPicture = new CapturedPictureViewModel(e.OriginalFileName, e.ChosenPhoto); //set mode for camera TransientState.Set("CapturedPictureViewModel", capturedPicture); } }
// private private void ResolvePictureAddress(CapturedPictureViewModel picture) { if (GpsHelper.Instance.Watcher.Status == GeoPositionStatus.Ready) { picture.Position = GpsHelper.Instance.Watcher.Position.Location; GeocodeHelper.ReverseGeocodeAddress( Dispatcher, _credentialsProvider, picture.Position, result => picture.Address = result.Address.FormattedAddress); } else { picture.Position = GeoCoordinate.Unknown; } }
/// <summary> /// Load picture from application's isolated storage. /// </summary> public CapturedPictureViewModel LoadFromLocalStorage(string fileName, string directory) { var isoFile = IsolatedStorageFile.GetUserStoreForApplication(); string filePath = System.IO.Path.Combine(directory, fileName); using (var fileStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read)) { using (var reader = new BinaryReader(fileStream)) { var capturedPicture = new CapturedPictureViewModel(); capturedPicture.Deserialize(reader); return(capturedPicture); } } }
/// <summary> /// Save picture to application's isolated storage. /// </summary> public void SaveToLocalStorage(CapturedPictureViewModel capturedPicture, string directory) { var isoFile = IsolatedStorageFile.GetUserStoreForApplication(); isoFile.EnsureDirectory(directory); string filePath = System.IO.Path.Combine(directory, capturedPicture.FileName); using (var fileStream = isoFile.CreateFile(filePath)) { using (var writer = new BinaryWriter(fileStream)) { capturedPicture.Serialize(writer); } } }
/// <summary> /// Save picture to pictures hub. /// </summary> public void SaveToPicturesHub(CapturedPictureViewModel picture) { var mediaLibrary = new MediaLibrary(); mediaLibrary.SavePicture(picture.FileName, picture.ImageBytes); }