private void ImageGridView_ItemClick(object sender, ItemClickEventArgs e) { // Prepare the connected animation for navigation to the detail page. persistedItem = e.ClickedItem as ImageFileInfo; ImageGridView.PrepareConnectedAnimation("itemAnimation", e.ClickedItem, "ItemImage"); this.Frame.Navigate(typeof(DetailPage), e.ClickedItem); }
public async static Task <ImageFileInfo> LoadImageInfo(StorageFile file) { var properties = await file.Properties.GetImagePropertiesAsync(); ImageFileInfo info = new ImageFileInfo( properties, file, file.DisplayName, file.DisplayType); return(info); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { item = e.Parameter as ImageFileInfo; canNavigateWithUnsavedChanges = false; ImageSource = await item.GetImageSourceAsync(); if (item != null) { ConnectedAnimation imageAnimation = ConnectedAnimationService.GetForCurrentView().GetAnimation("itemAnimation"); if (imageAnimation != null) { targetImage.Source = ImageSource; imageAnimation.Completed += async(s, e_) => { await LoadBrushAsync(); // This delay prevents a flicker that can happen when // a large image is being loaded to the brush. It gives // the image time to finish loading. (200 is ok, 400 to be safe.) await Task.Delay(400); targetImage.Source = null; }; imageAnimation.TryStart(targetImage); } if (ImageSource.PixelHeight == 0 && ImageSource.PixelWidth == 0) { // There is no editable image loaded. Disable zoom and edit // to prevent other errors. EditButton.IsEnabled = false; ZoomButton.IsEnabled = false; } ; } else { // error } if (this.Frame.CanGoBack) { BackButton.Visibility = Microsoft.UI.Xaml.Visibility.Visible; } else { BackButton.Visibility = Microsoft.UI.Xaml.Visibility.Collapsed; } base.OnNavigatedTo(e); }
private async Task LoadSavedImageAsync(StorageFile imageFile, bool replaceImage) { item.NeedsSaved = false; var newItem = await MainPage.LoadImageInfo(imageFile); ResetEffects(); // Get the index of the original image so we can // insert the saved image in the same place. var index = MainPage.Current.Images.IndexOf(item); item = newItem; this.Bindings.Update(); UnloadObject(imgRect); FindName("imgRect"); await LoadBrushAsync(); // Insert the saved image into the collection. if (replaceImage == true) { MainPage.Current.Images.RemoveAt(index); MainPage.Current.Images.Insert(index, item); } else { MainPage.Current.Images.Insert(index + 1, item); } // Replace the persisted image used for connected animation. MainPage.Current.UpdatePersistedItem(item); // Update BitMapImage used for small picture. ImageSource = await item.GetImageSourceAsync(); SmallImage.Source = ImageSource; }
// If the image is edited and saved in the details page, this method gets called // so that the back navigation connected animation uses the correct image. public void UpdatePersistedItem(ImageFileInfo item) { persistedItem = item; }