private void ImageExBase_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var bringIntoViewDistanceX = args.BringIntoViewDistanceX; var bringIntoViewDistanceY = args.BringIntoViewDistanceY; var width = ActualWidth; var height = ActualHeight; if (bringIntoViewDistanceX <= width && bringIntoViewDistanceY <= height) { _isInViewport = true; if (_lazyLoadingSource != null) { var source = _lazyLoadingSource; _lazyLoadingSource = null; SetSource(source); } } else { _isInViewport = false; } }
private void ProgressBar_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (sender is ProgressBar progressBar && progressBar.DataContext is ElementModel element) { SetProgressBarColor(progressBar, element); } }
private async void Block_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { //System.Diagnostics.Debug.WriteLine("Bring into view distance: " + (sender.ActualHeight + args.EffectiveViewport.Y) + " item index: " + Presenter.Children.IndexOf(sender)); if (sender.ActualHeight + args.EffectiveViewport.Y > 100) { await TranslateTokenAsync(sender as LoadingTextBlock); } }
private void Grid_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (!_LoadingCalled && args.BringIntoViewDistanceY <= 0) { _LoadingCalled = true; var vm = (DataContext as LiveInfomationPageViewModel); vm.InitializeIchibaItems(); vm.InitializeLiveRecommend(); } }
private async void Grid_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (sender.DataContext != null && (!(sender.DataContext as ListedItem).ItemPropertiesInitialized) && (args.BringIntoViewDistanceX < sender.ActualHeight)) { await Window.Current.CoreWindow.Dispatcher.RunIdleAsync((e) => { App.CurrentInstance.ViewModel.LoadExtendedItemProperties(sender.DataContext as ListedItem, 80); (sender.DataContext as ListedItem).ItemPropertiesInitialized = true; }); } }
private async void Grid_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (sender.DataContext is ListedItem item && (!item.ItemPropertiesInitialized) && (args.BringIntoViewDistanceX < sender.ActualHeight)) { await Window.Current.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(item, currentIconSize); item.ItemPropertiesInitialized = true; }); sender.CanDrag = FileList.SelectedItems.Contains(item); // Update CanDrag } }
private async void Grid_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (sender.DataContext != null && (!(sender.DataContext as ListedItem).ItemPropertiesInitialized) && (args.BringIntoViewDistanceX < sender.ActualHeight)) { await Window.Current.CoreWindow.Dispatcher.RunIdleAsync((e) => { ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(sender.DataContext as ListedItem, _iconSize); (sender.DataContext as ListedItem).ItemPropertiesInitialized = true; }); (sender as UIElement).CanDrag = FileList.SelectedItems.Contains(sender.DataContext as ListedItem); // Update CanDrag } }
private async void Icon_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var parentRow = Interacts.Interaction.FindParent <DataGridRow>(sender); if ((!(parentRow.DataContext as ListedItem).ItemPropertiesInitialized) && (args.BringIntoViewDistanceX < sender.ActualHeight)) { await Window.Current.CoreWindow.Dispatcher.RunIdleAsync((e) => { App.CurrentInstance.ViewModel.LoadExtendedItemProperties(parentRow.DataContext as ListedItem); (parentRow.DataContext as ListedItem).ItemPropertiesInitialized = true; //sender.EffectiveViewportChanged -= Icon_EffectiveViewportChanged; }); } }
private async void Icon_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var parentRow = Interacts.Interaction.FindParent <DataGridRow>(sender); if (parentRow.DataContext is ListedItem item && !item.ItemPropertiesInitialized && args.BringIntoViewDistanceX < sender.ActualHeight) { await Window.Current.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { ParentShellPageInstance.FilesystemViewModel.LoadExtendedItemProperties(parentRow.DataContext as ListedItem); (parentRow.DataContext as ListedItem).ItemPropertiesInitialized = true; //sender.EffectiveViewportChanged -= Icon_EffectiveViewportChanged; }); } }
Rect IEffectiveViewportChangedEventArgsResolver.MaxViewport(EffectiveViewportChangedEventArgs e) => e.MaxViewport;
private async void IllustrationThumbnailContainerItem_OnEffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var context = sender.GetDataContext <IllustrationViewModel>(); var preloadRows = Math.Clamp(App.AppViewModel.AppSetting.PreLoadRows, 1, 15); if (args.BringIntoViewDistanceY <= sender.ActualHeight * preloadRows) // [preloadRows] element ahead { if (await context.LoadThumbnailIfRequired()) { var transform = (ScaleTransform)sender.RenderTransform; if (sender.IsFullyOrPartiallyVisible(this)) { var scaleXAnimation = transform.CreateDoubleAnimation(nameof(transform.ScaleX), from: 1.1, to: 1, easingFunction: ImageSourceSetEasingFunction, duration: TimeSpan.FromSeconds(2)); var scaleYAnimation = transform.CreateDoubleAnimation(nameof(transform.ScaleY), from: 1.1, to: 1, easingFunction: ImageSourceSetEasingFunction, duration: TimeSpan.FromSeconds(2)); var opacityAnimation = sender.CreateDoubleAnimation(nameof(sender.Opacity), from: 0, to: 1, easingFunction: ImageSourceSetEasingFunction, duration: TimeSpan.FromSeconds(2)); UIHelper.CreateStoryboard(scaleXAnimation, scaleYAnimation, opacityAnimation).Begin(); } else { transform.ScaleX = 1; transform.ScaleY = 1; sender.Opacity = 1; } } return; } // small tricks to reduce memory consumption switch (context) { case { LoadingThumbnail: true } :
private void IllustrationThumbnailContainerItem_OnEffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var context = sender.GetDataContext <IllustrationViewModel>(); if (args.BringIntoViewDistanceY <= sender.ActualHeight) // one element ahead { _ = context.LoadThumbnailIfRequired(); return; } // small tricks to reduce memory consumption switch (context) { case { LoadingThumbnail: true } :
private void UserControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { DistanceX = args.BringIntoViewDistanceX; DistanceY = args.BringIntoViewDistanceY; }
public static bool NeedsLoading(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { return(args.BringIntoViewDistanceY < sender.ActualHeight * 1.5 && sender.DataContext != null); }
double IEffectiveViewportChangedEventArgsResolver.BringIntoViewDistanceY(EffectiveViewportChangedEventArgs e) => e.BringIntoViewDistanceY;
private void Image_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { }
private void CarouselRepeater_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { Viewport = args.MaxViewport; HorizontalSnapPointsChanged?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Gets the sum of translation in the Y-axis that is required to bring the FrameworkElement into view of each viewport containing the element. /// </summary> /// <param name="e">The requested <see cref="EffectiveViewportChangedEventArgs"/>.</param> /// <returns> /// The translation in the Y-axis that is required to bring the FrameworkElement into view of each viewport containing the element. /// </returns> public static double BringIntoViewDistanceY(this EffectiveViewportChangedEventArgs e) => Resolver.BringIntoViewDistanceY(e);
/// <summary> /// Gets the Rect representing the maximum effective viewport with the current viewport sizes. /// </summary> /// <param name="e">The requested <see cref="EffectiveViewportChangedEventArgs"/>.</param> /// <returns>The Rect representing the maximum effective viewport with the current viewport sizes.</returns> public static Rect MaxViewport(this EffectiveViewportChangedEventArgs e) => Resolver.MaxViewport(e);
private void DropShadowControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { AlbumView album = sender.DataContext as AlbumView; if (album == null || album.DontLoad || !ImageHelper.NeedsLoading(sender, args)) { return; } LoadThumbnail(album); }
private async void UserControl_EffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { if (sender.DataContext is GridFolderView data && !data.ThumbnailLoaded && ImageHelper.NeedsLoading(sender, args)) { await data.SetThumbnailAsync(); } }