public void OnNavigatedTo(INavigationParameters parameters)
 {
     if (parameters.ContainsKey(nameof(Picture)))
     {
         var param = parameters[nameof(Picture)] as Picture;
         MyPictures.Add(param);
     }
     ;
 }
예제 #2
0
 private void paste(IEnumerable <MyPicture> newPictures)
 {
     MyPictures.Clear();
     pictureLocations = new Dictionary <string, string>();
     foreach (var item in newPictures)
     {
         MyPictures.Add(item);
         pictureLocations.Add(item.Title, item.Url.LocalPath);
     }
 }
예제 #3
0
        public async void UploadAction()
        {
            string fileName = string.Format("{0}_{1}"
                                            , Guid.NewGuid()
                                            , selectedFileName);
            var picture = new Picture {
                Name    = fileName
                , Title = PhotoTitle
            };
            await App.MobileService.GetTable <Picture>().InsertAsync(picture);

            string container = "instashots";
            string imageUrl  = string.Format("http://{0}.blob.core.windows.net/{1}/{2}"
                                             , "splcricket"
                                             , container
                                             , fileName);
            StorageCredentials cred = new StorageCredentials(picture.sasQueryString);
            var imageUri            = new Uri(picture.Imageurl);
            // Instantiate a Blob store container based on the info in the returned item.
            CloudBlobContainer cloudcontainer = new CloudBlobContainer(
                new Uri(string.Format("https://{0}/{1}"
                                      , imageUri.Host
                                      , container))
                , cred);
            CloudBlockBlob blobFromSASCredential =
                cloudcontainer.GetBlockBlobReference(fileName);

            //Save File to local folder.
            await EditedImage.SaveToFile(
                ApplicationData.Current.LocalFolder,
                fileName,
                CreationCollisionOption.GenerateUniqueName);

            var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            var savedFile   = await localFolder.GetFileAsync(fileName);

            using (var fileStream = await savedFile.OpenStreamForReadAsync())
            {
                await blobFromSASCredential.UploadFromStreamAsync(fileStream.AsInputStream());
            }
            MyPictures.Add(picture);
        }