示例#1
0
 public void NavigateToEditing(Picture sentPicture)
 {
     currentlyEditing = Editing.Picture;
     ContentGridView.Visibility = Visibility.Collapsed;
     GridViewNav.Visibility = Visibility.Collapsed;
     Edit.Visibility = Visibility.Visible;
     MetaEdit.Visibility = Visibility.Collapsed;
     EditObject.Source = sentPicture.ImageSource;
     editImage = new EditCurrentImage(EditObject, sentPicture.Id, sentPicture.ImageSource);
     EditObject.Clip = null;
     EditObject.RenderTransformOrigin = new Point(0.5, 0.5);
     EditObject.RenderTransform = new RotateTransform() { CenterX = 0.5, CenterY = 0.5, Angle = 0 };
     ApplyEdit.IsEnabled = false;
     CropButton.IsEnabled = true;
     ApplyEdit.Label = "Lagre";
     ImagePopup.IsOpen = false;
     Header.header.ResetEditButton();
 }
示例#2
0
        private async void GridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Picture sentPicture = (Picture)e.ClickedItem;
            if (sentPicture.ImageSource == null)
            {
                sentPicture.ImageSource = await Pictures.getFullImage(sentPicture.Id);
            }

            if (clickedExport)
            {
                var imageString = await SharedFunctions.RunHttpRequestWithStringReturn(new Uri("http://" + serverIP + "/server/requestHandler.php?operation=getImage&id=" + sentPicture.Id));
                var data = Convert.FromBase64String(imageString);
                var file = await (new PicturePicker()).saveFile(".jpg");
                if (file != null)
                {
                    using (var targetStream = await file.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        await targetStream.AsStreamForWrite().WriteAsync(data, 0, data.Length);
                        await targetStream.FlushAsync();
                    }
                }
                clickedExport = false;
                Header.header.ResetExportButton();
            }
            else
            {
                if (currentlyEditing == Editing.None)
                {
                    if (Header.header.GetEditTag() == "1")
                    {
                        NavigateToEditing(sentPicture);
                    }
                    else if (Header.header.GetEditMetaTag() == "1")
                    {
                        NavigateToMetaEditing(sentPicture);
                    }
                    else
                    {
                        // Display popup with image and non-editable data
                        currentlyEditing = Editing.None;
                        PopupImage.Source = sentPicture.ImageSource;
                        currentlyViewing = sentPicture;
                        
                        PopupImage.MaxHeight = 0.9 * ContentGridView.ActualHeight;
                        PopupImage.MaxWidth = 0.9 * ContentGridView.ActualWidth;

                        PopupImage.Height = sentPicture.ImageSource.PixelHeight;

                        try { PopupCityBlock.Text = sentPicture.City; }
                        catch (ArgumentNullException) { PopupCityBlock.Text = "Ingen by funnet"; }
                        try { PopupCountryBlock.Text = sentPicture.Country; }
                        catch (ArgumentNullException) { PopupCountryBlock.Text = "Ingen land funnet"; }
                        try
                        {
                            PopupRatingBlock.Text = "Rating: ";
                            PopupRatingBlock.Text += sentPicture.Rating.Value;
                            PopupRatingBlock.Text += "/6";
                        }
                        catch (Exception) { PopupRatingBlock.Text = "Rating: 0/6"; }
                        try { PopupDateBlock.Text = sentPicture.Date.Value.ToString("yyyy-MM-dd"); }
                        catch (Exception) { PopupDateBlock.Text = "Ingen dato funnet"; }
                        try { PopupTagsBlock.Text = sentPicture.Tags; }
                        catch (ArgumentNullException) { PopupTagsBlock.Text = "Ingen tags funnet"; }
                        ImagePopup.IsOpen = false;
                        ImagePopup.IsOpen = true;
                    }
                }
                else
                {
                    if (Header.header.GetEditTag() == "1")
                    {
                        NavigateToEditing(sentPicture);
                    }
                    else if (Header.header.GetEditMetaTag() == "1")
                    {
                        NavigateToMetaEditing(sentPicture);
                    }
                    else
                    {
                        if (currentlyEditing == Editing.Picture)
                        {
                            NavigateToEditing(sentPicture);
                        }
                        else
                        {
                            NavigateToMetaEditing(sentPicture);
                        }
                    }
                }
            }
        }
示例#3
0
 public void NavigateToMetaEditing(Picture sentPicture)
 {
     currentlyEditing = Editing.Metadata;
     ContentGridView.Visibility = Visibility.Collapsed;
     GridViewNav.Visibility = Visibility.Collapsed;
     Edit.Visibility = Visibility.Collapsed;
     MetaEdit.Visibility = Visibility.Visible;
     try { MetaEditTags.Text = sentPicture.Tags; }
     catch (ArgumentNullException) { MetaEditTags.Text = ""; }
     try { MetaEditCity.Text = sentPicture.City; }
     catch (ArgumentNullException) { MetaEditCity.Text = ""; }
     try { MetaEditCountry.Text = sentPicture.Country; }
     catch (ArgumentNullException) { MetaEditCountry.Text = ""; }
     try { MetaEditDate.Date = (DateTime)sentPicture.Date; }
     catch (Exception) { MetaEditDate.Date = DateTime.Now; }
     try { MetaEditAlbum.Text = sentPicture.Album; }
     catch (ArgumentNullException) { MetaEditAlbum.Text = ""; }
     try { MetaEditRating.Value = (double)sentPicture.Rating; }
     catch (Exception) { MetaEditRating.Value = 0; }
     try { MetaEditEvent.Text = sentPicture.Event; }
     catch (ArgumentNullException) { MetaEditEvent.Text = ""; }
     MetaEditObject.Source = sentPicture.ImageSource;
     MetaEditSaveButton.Tag = sentPicture.Id;
     ImagePopup.IsOpen = false;
     Header.header.ResetMetaEditButton();
 }