Example #1
0
        public App()
        {
            InitializeComponent();
            pp = new PhotosPage();
            np = new NavigationPage(pp);

            MainPage = np;
            //MainPage = new PhotosPage();
        }
Example #2
0
        public async Task getCommentBlob(PhotosPage page)
        {
            CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();

            CloudBlobContainer container = blobClient.GetContainerReference("xamarincommentcontainer");

            await container.CreateIfNotExistsAsync();

            BlobContinuationToken token = null;

            var s = await container.ListBlobsSegmentedAsync(token);

            PictureComment pc;

            foreach (IListBlobItem item in s.Results)
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    var            PictureId   = "";
                    var            Id          = "";
                    var            PictureDate = "";
                    CloudBlockBlob blob        = (CloudBlockBlob)item;
                    //byte[] blobBytes = new byte[blob.Properties.Length];
                    Debug.WriteLine("Block blob of length {0}: {1}", blob.Properties.Length, blob.Uri);
                    var comment = await blob.DownloadTextAsync();

                    foreach (var metadataItem in blob.Metadata)
                    {
                        if (metadataItem.Key == "PictureId")
                        {
                            PictureId = metadataItem.Value.ToString();
                        }
                        else if (metadataItem.Key == "Id")
                        {
                            Id = metadataItem.Value.ToString();
                        }
                        else if (metadataItem.Key == "PictureDate")
                        {
                            PictureDate = metadataItem.Value.ToString();
                        }
                    }
                    Debug.WriteLine("Block blob of length {0}: {1}", PictureId, comment);

                    pc = new PictureComment(comment, PictureId, Id, PictureDate);
                    page.comment.Add(pc);
                }
            }
        }
Example #3
0
        public async Task getPictureBlob(PhotosPage page)
        {
            CloudBlobClient blobClient = _storageAccount.CreateCloudBlobClient();

            CloudBlobContainer container = blobClient.GetContainerReference("xamarinphotocontainer");

            await container.CreateIfNotExistsAsync();

            BlobContinuationToken token = null;

            var s = await container.ListBlobsSegmentedAsync(token);

            UserPicture up;


            foreach (IListBlobItem item in s.Results)
            {
                if (item.GetType() == typeof(CloudBlockBlob))
                {
                    var            Id        = "0";
                    CloudBlockBlob blob      = (CloudBlockBlob)item;
                    byte[]         blobBytes = new byte[blob.Properties.Length];
                    Debug.WriteLine("Block blob of length {0}: {1}", blob.Properties.Length, blob.Uri);
                    await blob.DownloadToByteArrayAsync(blobBytes, 0);

                    foreach (var metadataItem in blob.Metadata)
                    {
                        if (metadataItem.Key == "Id")
                        {
                            Id = metadataItem.Value.ToString();
                        }
                    }

                    p.BytePicture = blobBytes;
                    p.Picture     = ImageSource.FromStream(() => new MemoryStream(blobBytes));

                    up = new UserPicture(p.Picture, Id, p.BytePicture);
                    page.pic.Add(up);
                }
            }
        }