コード例 #1
0
        private async void SelectUploadButton_Clicked(object sender, EventArgs e)
        {
            //TODO: Will throw exception if no image was uploaded, need to add warning to UploadPage.xaml
            View[]     allImages     = ImagePreview.Children.ToArray <View>();
            string[][] megatags      = new string[5][];
            string[]   albums        = Array.Empty <string>();
            string     text_entNotes = "";

            //TODO: See if there's a more elegant solution to checking if each entry is null before assinging string[]
            string[] text_entPeople = Array.Empty <string>();
            if (entPeople.Text != null)
            {
                text_entPeople = await FormatTagsAlbums(entPeople.Text).ConfigureAwait(false);
            }
            string[] text_entPlaces = Array.Empty <string>();
            if (entPlaces.Text != null)
            {
                text_entPlaces = await FormatTagsAlbums(entPlaces.Text).ConfigureAwait(false);
            }
            string[] text_entEvents = Array.Empty <string>();
            if (entEvents.Text != null)
            {
                text_entEvents = await FormatTagsAlbums(entEvents.Text).ConfigureAwait(false);
            }
            string[] text_entCustom = Array.Empty <string>();
            if (entCustom.Text != null)
            {
                text_entCustom = await FormatTagsAlbums(entCustom.Text).ConfigureAwait(false);
            }
            string[] text_entRelationships = Array.Empty <string>();
            if (entRelationships.Text != null)
            {
                text_entRelationships = await FormatTagsAlbums(entRelationships.Text).ConfigureAwait(false);
            }
            string[] text_entAlbums = Array.Empty <string>();
            int      albumId        = 0;

            if (albumsViewModel.Albums != null && albumsViewModel.Albums.Count > 0 && entAlbums.SelectedIndex > -1)
            {
                albumId = albumsViewModel.Albums.Where(s => s.Name == (string)entAlbums.SelectedItem).Select(s => s.Id).SingleOrDefault();
            }
            if (entNotes.Text != null)
            {
                text_entNotes = entNotes.Text;
            }

            megatags = new string[][] { text_entPeople, text_entPlaces, text_entEvents, text_entCustom, text_entRelationships };
            albums   = text_entAlbums;
            await picRep.HandleImageCommit(userId, Streams, megatags, albumId, (string)Privacy.SelectedItem, text_entNotes).ConfigureAwait(false);

            await ClearPagePics().ConfigureAwait(false);
        }
コード例 #2
0
        private async void btnSave_Clicked(object sender, EventArgs e)
        {
            if (ImagePreview.Children.Count == 0)
            {
                await DisplayAlert("Error", "No image selected", "Ok").ConfigureAwait(false);

                return;
            }

            string[][] megatags = new string[5][];

            string[] text_entPeople        = FormatTagsAlbums(entPeople.Text);
            string[] text_entPlaces        = FormatTagsAlbums(entPlaces.Text);
            string[] text_entEvents        = FormatTagsAlbums(entEvents.Text);
            string[] text_entRelationships = FormatTagsAlbums(entRelationships.Text);
            string[] text_entCustom        = FormatTagsAlbums(entCustom.Text);


            string text_entNotes = !string.IsNullOrWhiteSpace(entNotes.Text)? entNotes.Text.Trim():string.Empty;

            megatags = new string[][] { text_entPeople, text_entPlaces, text_entEvents, text_entCustom, text_entRelationships };
            int albumId = 0;

            if (albumsViewModel.Albums != null && albumsViewModel.Albums.Count > 0 && entAlbums.SelectedIndex > -1)
            {
                albumId = albumsViewModel.Albums.Where(s => s.Name == (string)entAlbums.SelectedItem).Select(s => s.Id).SingleOrDefault();
            }
            try
            {
                await picRep.HandleImageCommit(this.UserId, Streams, megatags, albumId, (string)Privacy.SelectedItem, text_entNotes).ConfigureAwait(false);

                DisplayAlert("Success", "Your pictures saved successfully!", "Ok");
                ResetControls();
            }
            catch (Exception)
            {
                await DisplayAlert("Error", "An error occured while processing your request", "Ok").ConfigureAwait(false);
            }
        }