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) { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.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; }