示例#1
0
        void photoChooseTask_Completed(object sender, PhotoResult e)
        {
            var capturedPicture = new CapturedPictureViewModel(e.OriginalFileName, e.ChosenPhoto);

            //set mode for camera
            TransientState.Set("CapturedPictureViewModel", capturedPicture);
        }
示例#2
0
 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);
     }
 }
示例#3
0
 // 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;
     }
 }
示例#4
0
        /// <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);
                }
            }
        }
示例#5
0
        /// <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);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Save picture to pictures hub.
        /// </summary>
        public void SaveToPicturesHub(CapturedPictureViewModel picture)
        {
            var mediaLibrary = new MediaLibrary();

            mediaLibrary.SavePicture(picture.FileName, picture.ImageBytes);
        }