async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            fileName = e.SelectedItem.ToString();
            var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, fileName);

            editor.Source = ImageSource.FromStream(() => new MemoryStream(imageData));
            //deleteButton.IsEnabled = true;
        }
        public TextFileBrowserPageCS()
        {
            var getFilesButton = new Button {
                Text = "Get Text File List"
            };

            getFilesButton.Clicked += OnGetFileListButtonClicked;


            listView = new ListView();
            listView.ItemSelected += async(sender, e) =>
            {
                fileName = e.SelectedItem.ToString();
                var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, fileName);

                editor.Source          = ImageSource.FromStream(() => new MemoryStream(imageData));
                deleteButton.IsEnabled = true;
            };

            deleteButton = new Button
            {
                Text      = "Delete",
                IsEnabled = false
            };
            deleteButton.Clicked += async(sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(fileName))
                {
                    bool isDeleted = await AzureStorage.DeleteFileAsync(ContainerType.Text, fileName);

                    if (isDeleted)
                    {
                        OnGetFileListButtonClicked(sender, e);
                    }
                }
            };

            Title = "Text File Browser";
            Icon  = "csharp.png";

            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Label {
                        Text = "Text File Browser", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center
                    },
                    getFilesButton,
                    listView,
                    new Label {
                        Text = "Text file contents:"
                    },
                    editor,
                    deleteButton
                }
            };
        }
Example #3
0
        async void OnListViewItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            fileName = e.SelectedItem.ToString();
            var byteData = await AzureStorage.GetFileAsync(ContainerType.Text, fileName);

            var text = Encoding.UTF8.GetString(byteData);

            editor.Text            = text;
            deleteButton.IsEnabled = true;
        }
        async void Handle_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (pickerList.SelectedIndex > -1)
            {
                DialogService.ShowLoading(Strings.Loading);
                fileName = pickerList.Items[pickerList.SelectedIndex];
                var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, fileName);

                editor.Source = ImageSource.FromStream(() => new MemoryStream(imageData));
                DialogService.HideLoading();
            }
        }
Example #5
0
        async void OnDownloadImageButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(uploadedFilename))
            {
                activityIndicator.IsRunning = true;

                var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, uploadedFilename);

                downloadedImage.Source = ImageSource.FromStream(() => new MemoryStream(imageData));

                activityIndicator.IsRunning = false;
            }
        }
        async void OnDownloadButtonClicked(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(uploadedFilename))
            {
                activityIndicator.IsRunning = true;

                var byteData = await AzureStorage.GetFileAsync(ContainerType.Text, uploadedFilename);

                var text = Encoding.UTF8.GetString(byteData);
                downloadEditor.Text = text;

                activityIndicator.IsRunning = false;
            }
        }
        public ImageFileUploaderPageCS()
        {
            var imageToUpload     = new Image();
            var downloadedImage   = new Image();
            var activityIndicator = new ActivityIndicator();

            var downloadButton = new Button {
                Text = "Download Image", IsEnabled = false
            };

            downloadButton.Clicked += async(sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(uploadedFilename))
                {
                    activityIndicator.IsRunning = true;

                    var imageData = await AzureStorage.GetFileAsync(ContainerType.Image, uploadedFilename);

                    downloadedImage.Source = ImageSource.FromStream(() => new MemoryStream(imageData));

                    activityIndicator.IsRunning = false;
                }
            };

            var uploadButton = new Button {
                Text = "Upload Image"
            };

            uploadButton.Clicked += async(sender, e) =>
            {
                activityIndicator.IsRunning = true;

                uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Image, new MemoryStream(byteData));

                uploadButton.IsEnabled      = false;
                downloadButton.IsEnabled    = true;
                activityIndicator.IsRunning = false;
            };

#if __IOS__
            byteData = Convert.ToByteArray("FileUploader.iOS.waterfront.jpg");
#endif
#if __ANDROID__
            byteData = Convert.ToByteArray("FileUploader.Droid.waterfront.jpg");
#endif
#if WINDOWS_UWP
            byteData = Convert.ToByteArray("FileUploader.UWP.waterfront.jpg");
#endif

            imageToUpload.Source = ImageSource.FromStream(() => new MemoryStream(byteData));

            Title = "Upload Image";
            Icon  = "csharp.png";

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Margin   = new Thickness(20),
                    Children =
                    {
                        new Label {
                            Text = "Image Upload and Download", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center
                        },
                        imageToUpload,
                        uploadButton,
                        activityIndicator,
                        downloadButton,
                        downloadedImage
                    }
                }
            };
        }
Example #8
0
        public TextFileUploaderPageCS()
        {
            var uploadEditor = new Editor {
                HeightRequest = 100
            };
            var downloadEditor = new Editor {
                HeightRequest = 100, IsEnabled = false
            };
            var activityIndicator = new ActivityIndicator();

            var downloadButton = new Button {
                Text = "Download", IsEnabled = false
            };

            downloadButton.Clicked += async(sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(uploadedFilename))
                {
                    activityIndicator.IsRunning = true;

                    var byteData = await AzureStorage.GetFileAsync(ContainerType.Text, uploadedFilename);

                    var text = Encoding.UTF8.GetString(byteData);
                    downloadEditor.Text = text;

                    activityIndicator.IsRunning = false;
                }
            };

            var uploadButton = new Button {
                Text = "Upload"
            };

            uploadButton.Clicked += async(sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(uploadEditor.Text))
                {
                    activityIndicator.IsRunning = true;

                    var byteData = Encoding.UTF8.GetBytes(uploadEditor.Text);
                    uploadedFilename = await AzureStorage.UploadFileAsync(ContainerType.Text, new MemoryStream(byteData), "");

                    downloadButton.IsEnabled    = true;
                    activityIndicator.IsRunning = false;
                }
            };

            Title = "Upload Text";
            Icon  = "csharp.png";

            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    new Label {
                        Text = "Text Upload and Download", FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.Center
                    },
                    new Label {
                        Text = "Enter text:"
                    },
                    uploadEditor,
                    uploadButton,
                    activityIndicator,
                    downloadButton,
                    downloadEditor
                }
            };
        }