public ImageView() { InitializeComponent(); _compositor = Window.Current.Compositor; VisualExtensions.GetVisual(RepeaterScroll).Clip = _compositor.CreateInsetClip(); }
private void SetupInteractionTracker() { // Setup the HitTest visual of the InteractionTracker. _hitTestVisual = VisualExtensions.GetVisual(Card); _hitTestVisual.Size = Card.RenderSize.ToVector2(); // TODO: Why this doesn't work? //_hitTestVisual.RelativeSizeAdjustment = Vector2.One; // In this sample, we only want interactions happening on the Y-axis. _interactionSource = VisualInteractionSource.Create(_hitTestVisual); _interactionSource.PositionYSourceMode = InteractionSourceMode.EnabledWithInertia; _tracker.InteractionSources.Add(_interactionSource); // Setup max position of the InteractionTracker. var distanceFromTop = (float)Card.RelativePosition(this).Y; _maxDistance = distanceFromTop + _hitTestVisual.Size.Y; _tracker.MaxPosition = new Vector3(_maxDistance); // Initialize the manipulation progress. // Note: In this simple demo, we could have used the trackerNode.Position.Y to manipulate the offset // directly. But we use the manipulation progress here so we could control more things such as the // scale or opacity of the "copy" in the future. _progress.InsertScalar("Progress", 0); // Create an animation that tracks the progress of the manipulation and stores it in a the PropertySet _progress. var trackerNode = _tracker.GetReference(); // Note here we don't want to EF.Clamp the value 'cause we want the overpan which gives a more natural feel // when you pan it. _progress.StartAnimation("Progress", trackerNode.Position.Y / _tracker.MaxPosition.Y); ConfigureRestingPoints(); void ConfigureRestingPoints() { // Setup a possible inertia endpoint (snap point) for the InteractionTracker's minimum position. var endpoint1 = InteractionTrackerInertiaRestingValue.Create(_compositor); // Use this endpoint when the natural resting position of the interaction is less than the halfway point. var trackerTarget = ExpressionValues.Target.CreateInteractionTrackerTarget(); endpoint1.SetCondition(trackerTarget.NaturalRestingPosition.Y < (trackerTarget.MaxPosition.Y - trackerTarget.MinPosition.Y) / 2); // Set the result for this condition to make the InteractionTracker's y position the minimum y position. endpoint1.SetRestingValue(trackerTarget.MinPosition.Y); // Setup a possible inertia endpoint (snap point) for the InteractionTracker's maximum position. var endpoint2 = InteractionTrackerInertiaRestingValue.Create(_compositor); // Use this endpoint when the natural resting position of the interaction is more than the halfway point. endpoint2.SetCondition(trackerTarget.NaturalRestingPosition.Y >= (trackerTarget.MaxPosition.Y - trackerTarget.MinPosition.Y) / 2); // Set the result for this condition to make the InteractionTracker's y position the maximum y position. endpoint2.SetRestingValue(trackerTarget.MaxPosition.Y); _tracker.ConfigurePositionYInertiaModifiers(new InteractionTrackerInertiaModifier[] { endpoint1, endpoint2 }); } }
private void ShowTextShimmingAsync() { _redLight = CreatePointLightAndStartAnimation(_redColor, TimeSpan.Zero); _blueLight = CreatePointLightAndStartAnimation(_blueColor, TimeSpan.FromSeconds(0.5)); var backgroundVisual = VisualExtensions.GetVisual(BackgroundElement); _redLight.Targets.Add(backgroundVisual); _blueLight.Targets.Add(backgroundVisual); }
public OutlineTextView() { this.InitializeComponent(); OnIsInPomodoroChanged(); Loaded += OnLoaded; ViewModel.IsInPomodoroChanged += (s, e) => OnIsInPomodoroChanged(); var footBackgroundVisual = VisualExtensions.GetVisual(FootBackground); footBackgroundVisual.Opacity = 0; }
private void ShowTextShimmingAsync() { _redLight = CreatePointLightAndStartAnimation(_redColor, TimeSpan.Zero); _blueLight = CreatePointLightAndStartAnimation(_blueColor, TimeSpan.FromSeconds(0.25)); var focusVisual = VisualExtensions.GetVisual(FocusPanel); var relayVisual = VisualExtensions.GetVisual(RelaxPanel); _redLight.Targets.Add(focusVisual); _blueLight.Targets.Add(focusVisual); _redLight.Targets.Add(relayVisual); _blueLight.Targets.Add(relayVisual); }
private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { var containerVisual = VisualExtensions.GetVisual(args.ItemContainer); if (args.InRecycleQueue) { containerVisual.ImplicitAnimations = null; } else { Implicit.SetAnimations(args.ItemContainer, OffsetImplicitAnimations); } }
private void ShowTextShimming() { if (_inworkPointLight != null) { return; } var compositor = Window.Current.Compositor; if (_inworkPointLight == null) { var titleVisual = VisualExtensions.GetVisual(InworkShadow); _inworkPointLight = compositor.CreatePointLight(); _inworkPointLight.Color = Color.FromArgb(255, 217, 17, 83); _inworkPointLight.CoordinateSpace = titleVisual; _inworkPointLight.Targets.Add(titleVisual); _inworkPointLight.Offset = new Vector3(-(float)PomodoroPanel.ActualWidth * 3, (float)PomodoroPanel.ActualHeight / 2, 300.0f); } var offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1.0f, (float)PomodoroPanel.ActualWidth * 3, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromMilliseconds(10000); offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; _inworkPointLight.StartAnimation("Offset.X", offsetAnimation); if (_breakPointLight == null) { var titleVisual = VisualExtensions.GetVisual(BreakShadow); _breakPointLight = compositor.CreatePointLight(); _breakPointLight.Color = Color.FromArgb(255, 217, 17, 83); _breakPointLight.CoordinateSpace = titleVisual; _breakPointLight.Targets.Add(titleVisual); _breakPointLight.Offset = new Vector3(-(float)PomodoroPanel.ActualWidth * 3, (float)PomodoroPanel.ActualHeight / 2, 300.0f); } offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1.0f, (float)PomodoroPanel.ActualWidth * 3, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromMilliseconds(10000); offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; _breakPointLight.StartAnimation("Offset.X", offsetAnimation); }
private async void OnCardChromeHolding(object sender, HoldingRoutedEventArgs e) { if (e.PointerDeviceType == PointerDeviceType.Touch && e.HoldingState == HoldingState.Started) { // To create a continuous video playing experience, let's pause it here. _mediaElement.Pause(); // Record the location as we want to resume from here on another device. _mediaPlayedPosition = _mediaElement.Position; // We don't want to visually move the video player. Instead, we want to create the illusion that // a "copy" of it is being dragged down to another device. So here we use RenderTargetBitmap to // create such visual. var bitmap = new RenderTargetBitmap(); await bitmap.RenderAsync(Card); MediaCopy.Source = bitmap; MediaContainer.IsHitTestVisible = false; // Create animations to show that a "copy" of the video player is popped up and ready to be dragged up. Card.Fade(0.3f).Start(); MediaCopy .Fade(0.7f, 1) .Then() .Scale(0.975f, 0.975f, (float)Card.ActualWidth / 2, (float)Card.ActualHeight / 2, 300d) .Then() .Offset(offsetY: -24.0f, duration: 400d) .Start(); // Create an animation that changes the offset of the "copy" based on the manipulation progress. _mediaCopyVisual = VisualExtensions.GetVisual(MediaCopy); var progressExpressionNode = _progress.GetReference().GetScalarProperty("Progress"); _mediaCopyVisual.StartAnimation("Offset.Y", progressExpressionNode * -_maxDistance); try { // Let InteractionTracker to handle the swipe gesture. _interactionSource.TryRedirectForManipulation(_pressedPoint); // Send the card json and media played position over using Remote Sessions API. await RomeShare.SendMediaDataAsync(_cardJson, _mediaPlayedPosition, MediaUrl); } catch (UnauthorizedAccessException) { } } }
private void ShowTextShimmingAsync() { var width = 1920; _redLight = CreatePointLightAndStartAnimation(_redColor, -width * 1, width * 2); _blueLight = CreatePointLightAndStartAnimation(_blueColor, width * 2, -width * 1); _greenLight = CreateAmbientLightAndStartAnimation(); var focusVisual = VisualExtensions.GetVisual(FocusPanel); var relayVisual = VisualExtensions.GetVisual(RelaxPanel); _redLight.Targets.Add(focusVisual); _blueLight.Targets.Add(focusVisual); _redLight.Targets.Add(relayVisual); _blueLight.Targets.Add(relayVisual); _greenLight.Targets.Add(focusVisual); _greenLight.Targets.Add(relayVisual); }
private void ShowTextShimming() { var compositor = Window.Current.Compositor; var titleVisual = VisualExtensions.GetVisual(Title); var pointLight = compositor.CreatePointLight(); pointLight.Color = Colors.White; pointLight.CoordinateSpace = titleVisual; pointLight.Targets.Add(titleVisual); pointLight.Offset = new Vector3(-(float)Title.ActualWidth * 5, (float)Title.ActualHeight / 2, 100.0f); var offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1.0f, (float)Title.ActualWidth * 5, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromMilliseconds(5000); offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; pointLight.StartAnimation("Offset.X", offsetAnimation); }
private void HideBackgroundLight() { if (_backgroundLight == null) { return; } var compositor = Window.Current.Compositor; var scalarAnimation = compositor.CreateScalarKeyFrameAnimation(); scalarAnimation.InsertKeyFrame(1.0f, 0, compositor.CreateLinearEasingFunction()); scalarAnimation.Duration = TimeSpan.FromSeconds(1); _backgroundLight.StartAnimation(nameof(AmbientLight.Intensity), scalarAnimation); _buttonLight.StartAnimation(nameof(AmbientLight.Intensity), scalarAnimation); var footBackgroundVisual = VisualExtensions.GetVisual(FootBackground); footBackgroundVisual.StartAnimation(nameof(footBackgroundVisual.Opacity), scalarAnimation); }
private void CreateBackgroundLight() { var compositor = Window.Current.Compositor; var buttonVisual = VisualExtensions.GetVisual(ButtonPanel); var focusVisual = VisualExtensions.GetVisual(FocusPanel); var relayVisual = VisualExtensions.GetVisual(RelaxPanel); var footVisual = VisualExtensions.GetVisual(FootBackground); _backgroundLight = compositor.CreateAmbientLight(); _backgroundLight.Color = ViewModel.IsInPomodoro ? _lightRedColor : _lightBlueColor; _backgroundLight.Intensity = 0; _backgroundLight.Targets.Add(focusVisual); _backgroundLight.Targets.Add(relayVisual); _backgroundLight.Targets.Add(footVisual); _buttonLight = compositor.CreateAmbientLight(); _buttonLight.Color = Colors.White; _buttonLight.Intensity = 0; _buttonLight.Targets.Add(buttonVisual); }
private PointLight CreatePointLightAndStartAnimation(Color color, float startOffsetX, float endOffsetX, float height) { var compositor = Window.Current.Compositor; var rootVisual = VisualExtensions.GetVisual(Root); var pointLight = compositor.CreatePointLight(); pointLight.Color = color; pointLight.CoordinateSpace = rootVisual; pointLight.Offset = new Vector3(startOffsetX, height, 300.0f); var offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1.0f, endOffsetX, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromSeconds(10); offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; pointLight.StartAnimation("Offset.X", offsetAnimation); return(pointLight); }
private AmbientLight CreateAmbientLightAndStartAnimation() { var compositor = Window.Current.Compositor; var rootVisual = VisualExtensions.GetVisual(Root); var ambientLight = compositor.CreateAmbientLight(); ambientLight.Intensity = 0; ambientLight.Color = _greenColor; var offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(0.25f, 0, compositor.CreateLinearEasingFunction()); offsetAnimation.InsertKeyFrame(0.5f, 0.20f, compositor.CreateLinearEasingFunction()); offsetAnimation.InsertKeyFrame(0.75f, 0, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromSeconds(10); offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; ambientLight.StartAnimation(nameof(AmbientLight.Intensity), offsetAnimation); return(ambientLight); }
private PointLight CreatePointLightAndStartAnimation(Color color, TimeSpan delay) { var width = 1920f; var height = 1050f; var compositor = Window.Current.Compositor; var rootVisual = VisualExtensions.GetVisual(this); var pointLight = compositor.CreatePointLight(); pointLight.Color = color; pointLight.CoordinateSpace = rootVisual; pointLight.Offset = new Vector3(-width * 3, height / 2, 150.0f); var offsetAnimation = compositor.CreateScalarKeyFrameAnimation(); offsetAnimation.InsertKeyFrame(1.0f, width * 4, compositor.CreateLinearEasingFunction()); offsetAnimation.Duration = TimeSpan.FromSeconds(10); offsetAnimation.DelayTime = delay; offsetAnimation.IterationBehavior = AnimationIterationBehavior.Forever; pointLight.StartAnimation("Offset.X", offsetAnimation); return(pointLight); }
private void SetupExpressionAnimationsForCard() { _cardVisual = VisualExtensions.GetVisual(Card); _cardVisual.RelativeSizeAdjustment = Vector2.One; _cardVisual.CenterPoint = new Vector3(Card.RenderSize.ToVector2() / 2, 0.0f); var initialPositionY = (float)ActualHeight; _cardVisual.Offset = new Vector3(0.0f, initialPositionY, 0.0f); _progress.InsertScalar("Progress", 0); var progressExpressionNode = _progress.GetReference().GetScalarProperty("Progress"); // Scale the card visual based on the progress. _cardVisual.StartAnimation("Scale", EF.Vector3(1.0f, 1.0f, 1.0f) * EF.Lerp(0.6f, 1.0f, progressExpressionNode)); // Fade in the card visual based on the progress. _cardVisual.StartAnimation("Opacity", EF.Lerp(0.0f, 1.0f, progressExpressionNode)); // Move the card visual based on the progress. var offset = initialPositionY * (1.0f - progressExpressionNode); _cardVisual.StartAnimation("Offset.Y", offset); }
public NotificationDialog() { InitializeComponent(); InitializeCardRenderer(); // Set the initial state. VisualStateManager.GoToState(this, "EmptyState", false); // Clip the top-level panel so nothing goes outside will be visible. VisualExtensions.GetVisual(LayoutRoot).Clip = Window.Current.Compositor.CreateInsetClip(); Loaded += async(s, e) => { if (App.IsDeepLink) { return; } // Simulate a network request so the message dialog will appear after 2.5s. await Task.Delay(2500); // Show the message dialog on the bottom right of the screen. VisualStateManager.GoToState(this, "MinimizedState", true); }; AddDummyAdjusters(); ShowMapAndPolyline(); void AddDummyAdjusters() { Adjusters.Add(new Adjuster("Emma", 7, GenderType.Female)); Adjusters.Add(new Adjuster("Max", 3.4, GenderType.Male, StatusType.Busy)); Adjusters.Add(new Adjuster("Charlotte", 1.2, GenderType.Female)); Adjusters.Add(new Adjuster("Chloe", 8.9, GenderType.Female)); Adjusters.Add(new Adjuster("Giselle", 15.6, GenderType.Female, StatusType.Busy)); } void ShowMapAndPolyline() { Map.LoadingStatusChanged += ActivityMapLoadingStatusChanged; async void ActivityMapLoadingStatusChanged(MapControl sender, object args) { Map.LoadingStatusChanged -= ActivityMapLoadingStatusChanged; await ShowMapContents(); async Task ShowMapContents() { var spaceNeedlePoint = new Geopoint(new BasicGeoposition() { Latitude = 47.6204, Longitude = -122.3491 }); MapScene spaceNeedleScene = MapScene.CreateFromLocationAndRadius(spaceNeedlePoint, 240, /* show this many meters around */ 45, /* looking at it to the south east*/ 75 /* degrees pitch */); await Map.TrySetSceneAsync(spaceNeedleScene); var ownerAddressPoint = new Button { Style = (Style)App.Current.Resources["ButtonMapPinStyle"] }; Map.Children.Add(ownerAddressPoint); MapControl.SetLocation(ownerAddressPoint, new Geopoint(new BasicGeoposition { Latitude = 47.6204, Longitude = -122.3491 })); MapControl.SetNormalizedAnchorPoint(ownerAddressPoint, new Point(0.5, 0.5)); var branchPoint1 = new Button { Style = (Style)App.Current.Resources["ButtonMapBuildingStyle"] }; Map.Children.Add(branchPoint1); MapControl.SetLocation(branchPoint1, new Geopoint(new BasicGeoposition { Latitude = 47.6208148, Longitude = -122.350805 })); MapControl.SetNormalizedAnchorPoint(branchPoint1, new Point(0.5, 0.5)); var branchPoint2 = new Button { Style = (Style)App.Current.Resources["ButtonMapBuildingStyle"] }; Map.Children.Add(branchPoint2); MapControl.SetLocation(branchPoint2, new Geopoint(new BasicGeoposition { Latitude = 47.619535, Longitude = -122.349163 })); MapControl.SetNormalizedAnchorPoint(branchPoint2, new Point(0.5, 0.5)); } } } }
/// <summary> /// Prepares the specified element to display the specified item. /// </summary> /// <param name="obj">The element that's used to display the specified item.</param> /// <param name="item">The item to display.</param> protected override void PrepareContainerForItemOverride(DependencyObject obj, object item) { base.PrepareContainerForItemOverride(obj, item); if (!(obj is FrameworkElement element)) { return; } var heightBinding = new Binding { Source = this, Path = new PropertyPath(nameof(ItemHeight)), Mode = BindingMode.TwoWay }; var widthBinding = new Binding { Source = this, Path = new PropertyPath(nameof(ItemWidth)), Mode = BindingMode.TwoWay }; element.SetBinding(HeightProperty, heightBinding); element.SetBinding(WidthProperty, widthBinding); // First populate our local variable for referencing ItemsWrapGrid for the first time. if (!_monitorFirstItemContainerLoadedEvent && _virtualizedPanel == null) { _virtualizedPanel = ItemsPanelRoot as ItemsWrapGrid; } // Then decide if we should run the animation. if (_virtualizedPanel == null || _isAnimated) { return; } Opacity = 0; if (!_monitorFirstItemContainerLoadedEvent) { _monitorFirstItemContainerLoadedEvent = true; element.Loaded += OnContainerLoaded; // At this point, the index values are all ready to use. async void OnContainerLoaded(object sender, RoutedEventArgs e) { element.Loaded -= OnContainerLoaded; for (var i = _virtualizedPanel.FirstVisibleIndex; i <= _virtualizedPanel.LastVisibleIndex; i++) { var numberOfColumns = GetNumberOfColumns(); var rowIndex = i % numberOfColumns; var colIndex = i / numberOfColumns; if (ContainerFromIndex(i) is FrameworkElement container) { container.Opacity = 0; if (_visibleItemContainers.ContainsKey(container)) { _visibleItemContainers.Remove(container); } _visibleItemContainers.Add(container, new Position(rowIndex, colIndex)); } Opacity = 1; } _isAnimated = true; await Task.Delay(InitialDelay); RunStaggeredDiagonalAnimationOnVisibleItemContainers(); void RunStaggeredDiagonalAnimationOnVisibleItemContainers() { var numberOfColumns = GetNumberOfColumns(); var numberOfRows = Math.Ceiling(ActualHeight / ItemHeight); var last = (numberOfRows - 1) + (numberOfColumns - 1); for (var i = 0; i <= last; i++) { var sum = i; var containers = _visibleItemContainers.Where(c => c.Value.Row + c.Value.Column == sum).Select(k => k.Key); foreach (var container in containers) { var containerVisual = VisualExtensions.GetVisual(container); _scaleAnimation.DelayTime = TimeSpan.FromMilliseconds(AnimationDelay * i); containerVisual.CenterPoint = new Vector3((float)ItemWidth, (float)ItemHeight, 0) * 0.5f; containerVisual.StartAnimation(nameof(Visual.Scale), _scaleAnimation); container.Fade(1.0f, AnimationDuration, AnimationDelay * i).Start(); } } } } } }