private async void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e) { if (e.IsIntermediate) { return; } // Use width instead of height in vertical mode if (Data.UseVerticalReader) { if (ScrollViewer.CurrentAnchor is ReaderImage image) { var index = ReaderVertical.GetElementIndex(ScrollViewer.CurrentAnchor); Data.ReaderIndex = index; var width = (int)Math.Round(ScrollViewer.ExtentWidth); await image.ResizeWidth(width); (ReaderVertical.TryGetElement(index + 1) as ReaderImage)?.ResizeWidth(width); (ReaderVertical.TryGetElement(index + 2) as ReaderImage)?.ResizeWidth(width); } } else { await ReaderImage.ResizeHeight((int)Math.Round(ScrollViewer.ExtentHeight)); } }
private async Task ChangePage() { if (Data.UseVerticalReader) { return; } await ReaderImage.ChangePage(Data.ReaderContent); ReaderImage.FadeInPage(); Preload(Data.ArchiveImagesReader.ElementAtOrDefault(Data.ReaderIndex + 1)); Preload(Data.ArchiveImagesReader.ElementAtOrDefault(Data.ReaderIndex + 2)); Preload(Data.ArchiveImagesReader.ElementAtOrDefault(Data.ReaderIndex + 3)); }
private async Task GoLeft() { if (Data.UseVerticalReader) { return; } if (Data.ReaderIndex > 0) { --Data.ReaderIndex; await ReaderImage.FadeOutPage(); ScrollViewer.ChangeView(null, 0, null, true); await ChangePage(); } }
private async Task GoRight() { if (Data.UseVerticalReader) { return; } if (Service.Settings.OpenNextArchive && Data.ReaderContent.Page + 1 >= Data.Pages) { await NextArchive(); return; } if (Data.ReaderIndex < Data.ArchiveImagesReader.Count() - 1) { ++Data.ReaderIndex; await ReaderImage.FadeOutPage(); ScrollViewer.ChangeView(null, 0, null, true); await ChangePage(); } }
public async void CloseReader() { if (_transition) { return; } _transition = true; var animate = Service.Platform.AnimationsEnabled; ConnectedAnimation animLeft = null, animRight = null; if (!Data.UseVerticalReader) { var left = ReaderImage.FindDescendant("LeftImage"); var right = ReaderImage.FindDescendant("RightImage"); ReaderImage.disableAnimation = true; if (animate) { if (Data.ReaderContent.LeftImage != null && !(left.ActualWidth == 0 || left.ActualHeight == 0)) { animLeft = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("closeL", left); animLeft.Configuration = new BasicConnectedAnimationConfiguration(); } if (Data.ReaderContent.RightImage != null && !(right.ActualWidth == 0 || right.ActualHeight == 0)) { animRight = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("closeR", right); animRight.Configuration = new BasicConnectedAnimationConfiguration(); } } } _focus = false; int currentPage = Data.ReaderContent.Page; int count = Data.Pages; int leftTarget = currentPage; int rightTarget = currentPage; if (Data.ReaderContent.TwoPages) { leftTarget--; if (Data.ReadRTL) { int tmp = leftTarget; leftTarget = rightTarget; rightTarget = tmp; } } leftTarget = leftTarget.Clamp(0, count - 1); rightTarget = rightTarget.Clamp(0, count - 1); if (animate) { if (Data.ReaderContent.LeftImage != null && animLeft != null && Data.ArchiveImages.Count > leftTarget) { animLeft.TryStart(ImagesGrid.ContainerFromIndex(leftTarget).FindDescendant("Thumbnail")); } if (Data.ReaderContent.RightImage != null & animRight != null && Data.ArchiveImages.Count > rightTarget) { animRight.TryStart(ImagesGrid.ContainerFromIndex(rightTarget).FindDescendant("Thumbnail")); } FadeOut.Start(ReaderBackground); await FadeOut.StartAsync(ScrollViewer); await Task.Delay(200); // Give it a sec } else { ReaderBackground.SetVisualOpacity(0); ScrollViewer.SetVisualOpacity(0); } Data.ShowReader = false; _wasNew = await Data.SaveReaderData(_wasNew); _transition = false; }