public void ForeverBlinkerLoaded(object sender, RoutedEventArgs e) { FrameworkElement fe = sender as FrameworkElement; if (fe != null) { System.Windows.Media.Animation.QuadraticEase QEaseOut = new System.Windows.Media.Animation.QuadraticEase() { EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut }; System.Windows.Media.Animation.Storyboard SB = new System.Windows.Media.Animation.Storyboard(); SB.RepeatBehavior = RepeatBehavior.Forever; SB.Duration = System.TimeSpan.FromMilliseconds(500 * SpeedRatio); System.Windows.Media.Animation.DoubleAnimation fadeout = new System.Windows.Media.Animation.DoubleAnimation(0, System.TimeSpan.FromMilliseconds(100 * SpeedRatio)); fadeout.BeginTime = new System.TimeSpan(0, 0, 0, 0, 0); fadeout.EasingFunction = QEaseOut; System.Windows.Media.Animation.Storyboard.SetTarget(fadeout, fe); System.Windows.Media.Animation.Storyboard.SetTargetProperty(fadeout, new PropertyPath(TextBlock.OpacityProperty)); SB.Children.Add(fadeout); System.Windows.Media.Animation.DoubleAnimation fadein = new System.Windows.Media.Animation.DoubleAnimation(1, System.TimeSpan.FromMilliseconds(100 * SpeedRatio)); fadein.BeginTime = new System.TimeSpan(0, 0, 0, 0, 200); fadein.EasingFunction = QEaseOut; System.Windows.Media.Animation.Storyboard.SetTarget(fadein, fe); System.Windows.Media.Animation.Storyboard.SetTargetProperty(fadein, new PropertyPath(TextBlock.OpacityProperty)); SB.Children.Add(fadein); SB.Begin(); } }
/// <summary> /// Initializes a new instance of the HybridOrientationChangesFrame class. /// </summary> public HybridOrientationChangesFrame() { // Set up animations Storyboard.SetTargetProperty(_beforeOpacityAnimation, new PropertyPath(UIElement.OpacityProperty)); _storyboard.Children.Add(_beforeOpacityAnimation); Storyboard.SetTargetProperty(_afterOpacityAnimation, new PropertyPath(UIElement.OpacityProperty)); _storyboard.Children.Add(_afterOpacityAnimation); Storyboard.SetTargetProperty(_beforeRotationAnimation, new PropertyPath(RotateTransform.AngleProperty)); _storyboard.Children.Add(_beforeRotationAnimation); Storyboard.SetTargetProperty(_afterRotationAnimation, new PropertyPath(RotateTransform.AngleProperty)); _storyboard.Children.Add(_afterRotationAnimation); _storyboard.Completed += new EventHandler(HandleStoryboardCompleted); // Initialize variables EasingFunction = new QuadraticEase(); // Initialized here to avoid a single shared instance // Add custom transform to end of existing group var transformGroup = RenderTransform as TransformGroup; if (null != transformGroup) { transformGroup.Children.Add(_afterRotateTransform); } // Hook events OrientationChanged += new EventHandler<OrientationChangedEventArgs>(HandleOrientationChanged); }
/// <summary> /// Initializes a new instance of the FadeOrientationChangesFrame class. /// </summary> public FadeOrientationChangesFrame() { // Set up animation Storyboard.SetTargetProperty(_animation, new PropertyPath(UIElement.OpacityProperty)); _storyboard.Children.Add(_animation); _storyboard.Completed += new EventHandler(HandleStoryboardCompleted); // Initialize variables EasingFunction = new QuadraticEase(); // Initialized here to avoid a single shared instance // Hook events OrientationChanged += new EventHandler<OrientationChangedEventArgs>(HandleOrientationChanged); }
private IEasingFunction ObterFuncaoDaAnimacao() { EasingFunctionBase funcaoDaAnimacao = null; switch (FuncaoDaAnimacao.SelectedValue.ToString()) { case "BackEase": funcaoDaAnimacao = new BackEase(); break; case "BounceEase": funcaoDaAnimacao = new BounceEase(); break; case "CircleEase": funcaoDaAnimacao = new CircleEase(); break; case "CubicEase": funcaoDaAnimacao = new CubicEase(); break; case "ElasticEase": funcaoDaAnimacao = new ElasticEase(); break; case "ExponentialEase": funcaoDaAnimacao = new ExponentialEase(); break; case "PowerEase": funcaoDaAnimacao = new PowerEase(); break; case "QuadraticEase": funcaoDaAnimacao = new QuadraticEase(); break; case "QuarticEase": funcaoDaAnimacao = new QuarticEase(); break; case "QuinticEase": funcaoDaAnimacao = new QuinticEase(); break; case "SineEase": funcaoDaAnimacao = new SineEase(); break; } funcaoDaAnimacao.EasingMode = ObterModoDaAnimacao(); return funcaoDaAnimacao; }
private void LongListSelector_GroupViewOpened(object sender, GroupViewOpenedEventArgs e) { //Hold a reference to the active long list selector. currentSelector = sender as LongListSelector; //Construct and begin a swivel animation to pop in the group view. IEasingFunction quadraticEase = new QuadraticEase { EasingMode = EasingMode.EaseOut }; Storyboard _swivelShow = new Storyboard(); ItemsControl groupItems = e.ItemsControl; foreach (var item in groupItems.Items) { UIElement container = groupItems.ItemContainerGenerator.ContainerFromItem(item) as UIElement; if (container != null) { Border content = VisualTreeHelper.GetChild(container, 0) as Border; if (content != null) { DoubleAnimationUsingKeyFrames showAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame showKeyFrame1 = new EasingDoubleKeyFrame(); showKeyFrame1.KeyTime = TimeSpan.FromMilliseconds(0); showKeyFrame1.Value = -60; showKeyFrame1.EasingFunction = quadraticEase; EasingDoubleKeyFrame showKeyFrame2 = new EasingDoubleKeyFrame(); showKeyFrame2.KeyTime = TimeSpan.FromMilliseconds(85); showKeyFrame2.Value = 0; showKeyFrame2.EasingFunction = quadraticEase; showAnimation.KeyFrames.Add(showKeyFrame1); showAnimation.KeyFrames.Add(showKeyFrame2); Storyboard.SetTargetProperty(showAnimation, new PropertyPath(PlaneProjection.RotationXProperty)); Storyboard.SetTarget(showAnimation, content.Projection); _swivelShow.Children.Add(showAnimation); } } } _swivelShow.Begin(); }
private void Button_Click1(object sender, RoutedEventArgs e) { RadMoveAnimation animation = new RadMoveAnimation(); EasingFunctionBase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); if (a == 0) { endPoint.X = 321; endPoint.Y = 0; a = 1; CControl.Focus(); //boton_menu.IsEnabled = false; } shield.Visibility = Visibility.Visible; animation.EndPoint = endPoint; animation.Easing = ease; RadAnimationManager.Play(CControl, animation); }
private void LongListSelector_GroupViewOpened(object sender, GroupViewOpenedEventArgs e) { this.currentSelector = sender as LongListSelector; QuadraticEase ease = new QuadraticEase { EasingMode = EasingMode.EaseOut }; IEasingFunction function = ease; Storyboard storyboard = new Storyboard(); ItemsControl itemsControl = e.ItemsControl; foreach (object obj2 in itemsControl.Items) { UIElement reference = itemsControl.ItemContainerGenerator.ContainerFromItem(obj2) as UIElement; if (reference != null) { Border child = VisualTreeHelper.GetChild(reference, 0) as Border; if (child != null) { DoubleAnimationUsingKeyFrames element = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame frame = new EasingDoubleKeyFrame { KeyTime = System.TimeSpan.FromMilliseconds(0.0), Value = -60.0, EasingFunction = function }; EasingDoubleKeyFrame frame2 = new EasingDoubleKeyFrame { KeyTime = System.TimeSpan.FromMilliseconds(85.0), Value = 0.0, EasingFunction = function }; element.KeyFrames.Add(frame); element.KeyFrames.Add(frame2); Storyboard.SetTargetProperty(element, new PropertyPath(PlaneProjection.RotationXProperty)); Storyboard.SetTarget(element, child.Projection); storyboard.Children.Add(element); } } } storyboard.Begin(); }
private void LongListSelector_GroupViewClosing(object sender, GroupViewClosingEventArgs e) { e.Cancel = true; if (e.SelectedGroup != null) { this.currentSelector.ScrollToGroup(e.SelectedGroup); } base.Dispatcher.BeginInvoke(delegate { QuadraticEase ease = new QuadraticEase { EasingMode = EasingMode.EaseOut }; IEasingFunction function = ease; Storyboard storyboard = new Storyboard(); ItemsControl itemsControl = e.ItemsControl; foreach (object obj2 in itemsControl.Items) { UIElement reference = itemsControl.ItemContainerGenerator.ContainerFromItem(obj2) as UIElement; if (reference != null) { Border child = VisualTreeHelper.GetChild(reference, 0) as Border; if (child != null) { DoubleAnimationUsingKeyFrames element = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame frame = new EasingDoubleKeyFrame { KeyTime = System.TimeSpan.FromMilliseconds(0.0), Value = 0.0, EasingFunction = function }; EasingDoubleKeyFrame frame2 = new EasingDoubleKeyFrame { KeyTime = System.TimeSpan.FromMilliseconds(125.0), Value = 90.0, EasingFunction = function }; element.KeyFrames.Add(frame); element.KeyFrames.Add(frame2); Storyboard.SetTargetProperty(element, new PropertyPath(PlaneProjection.RotationXProperty)); Storyboard.SetTarget(element, child.Projection); storyboard.Children.Add(element); } } } storyboard.Completed += new System.EventHandler(this._swivelHide_Completed); storyboard.Begin(); }); }
private void GEN_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { bool leavePage = false; if (((UserControl)sender).Visibility == System.Windows.Visibility.Collapsed) { leavePage = true; } if (leavePage) { if (this._CKinect.isStart) { this._CKinect.stop(); } ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-1000, 0, 1000, 0), new Duration(TimeSpan.FromMilliseconds(900))); QuadraticEase qe = new QuadraticEase(); qe.EasingMode = EasingMode.EaseOut; ta.EasingFunction = qe; ta.Completed += taExitPage_Completed; this.GameBoard.BeginAnimation(MarginProperty, ta); } }
public void Move_EaseInAndOut(Canvas control) { var ease = new QuadraticEase { EasingMode = EasingMode.EaseInOut }; AnimationUtil.Move(element, new Point(0, 0), new Point(250, 400), 0.5, ease, null); }
/// <summary> /// Provides the feathered animation for items /// when the Expander View goes from collapsed to expanded. /// </summary> internal void AnimateContainerDropDown() { for (int i = 0; i < Items.Count; i++) { FrameworkElement container = ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement; if (container == null) { break; } Storyboard itemDropDown = new Storyboard(); IEasingFunction quadraticEase = new QuadraticEase { EasingMode = EasingMode.EaseOut }; int initialKeyTime = InitialKeyTime + (KeyTimeStep * i); int finalKeyTime = FinalKeyTime + (KeyTimeStep * i); TranslateTransform translation = new TranslateTransform(); container.RenderTransform = translation; DoubleAnimationUsingKeyFrames transAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame transKeyFrame_1 = new EasingDoubleKeyFrame(); transKeyFrame_1.EasingFunction = quadraticEase; transKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); transKeyFrame_1.Value = -150.0; EasingDoubleKeyFrame transKeyFrame_2 = new EasingDoubleKeyFrame(); transKeyFrame_2.EasingFunction = quadraticEase; transKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime); transKeyFrame_2.Value = 0.0; EasingDoubleKeyFrame transKeyFrame_3 = new EasingDoubleKeyFrame(); transKeyFrame_3.EasingFunction = quadraticEase; transKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); transKeyFrame_3.Value = 0.0; transAnimation.KeyFrames.Add(transKeyFrame_1); transAnimation.KeyFrames.Add(transKeyFrame_2); transAnimation.KeyFrames.Add(transKeyFrame_3); Storyboard.SetTarget(transAnimation, translation); Storyboard.SetTargetProperty(transAnimation, new PropertyPath(TranslateTransform.YProperty)); itemDropDown.Children.Add(transAnimation); DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame opacityKeyFrame_1 = new EasingDoubleKeyFrame(); opacityKeyFrame_1.EasingFunction = quadraticEase; opacityKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); opacityKeyFrame_1.Value = 0.0; EasingDoubleKeyFrame opacityKeyFrame_2 = new EasingDoubleKeyFrame(); opacityKeyFrame_2.EasingFunction = quadraticEase; opacityKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime - 150); opacityKeyFrame_2.Value = 0.0; EasingDoubleKeyFrame opacityKeyFrame_3 = new EasingDoubleKeyFrame(); opacityKeyFrame_3.EasingFunction = quadraticEase; opacityKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); opacityKeyFrame_3.Value = 1.0; opacityAnimation.KeyFrames.Add(opacityKeyFrame_1); opacityAnimation.KeyFrames.Add(opacityKeyFrame_2); opacityAnimation.KeyFrames.Add(opacityKeyFrame_3); Storyboard.SetTarget(opacityAnimation, container); Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(FrameworkElement.OpacityProperty)); itemDropDown.Children.Add(opacityAnimation); itemDropDown.Begin(); } }
private void bBarra_TecnologiasR_Click(object sender, RoutedEventArgs e) { LosingFocus = false; RadResizeAnimation resizeAnimation = new RadResizeAnimation(); EasingFunctionBase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseInOut; RadMoveAnimation animation2 = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint2 = new Point(); endPoint2.X = 0; endPoint2.Y = 2 * sz; animation2.EndPoint = endPoint2; animation2.Easing = ease; RadMoveAnimation animation3 = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint3 = new Point(); endPoint3.X = 0; endPoint3.Y = 3 * sz; animation3.EndPoint = endPoint3; animation3.Easing = ease; sz = 290; if (wtecnologiasr == 0) //tecnologias Cerrado { resizeAnimation.StartSize = new Size(321, 0); Size size = new Size(321, sz); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = sz; animation.EndPoint = endPoint; animation.Easing = ease; wtecnologiasr = 1; if (wmarcon == 1 && wmetodosa == 1) { endPoint2.Y = 140 + sz; animation2.EndPoint = endPoint2; pA(animation2, 2); endPoint.Y = 140 + 220 + sz; animation.EndPoint = endPoint; pA(animation, 3); } else { if (wmetodosa == 1) { endPoint.Y = sz; animation.EndPoint = endPoint; pA(animation, 2); endPoint2.Y = 220 + sz; animation2.EndPoint = endPoint2; pA(animation2, 3); } else { if (wmarcon == 1) { endPoint.Y = sz + 140; animation.EndPoint = endPoint; pA(animation, 2); endPoint2.Y = sz + 140; animation2.EndPoint = endPoint2; pA(animation2, 3); } else { endPoint.Y = sz; animation.EndPoint = endPoint; pA(animation, 2); pA(animation, 3); } } } } else //TecnologiasR Abierto. { resizeAnimation.StartSize = new Size(321, sz); Size size = new Size(321, 0); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = 0; animation.EndPoint = endPoint; animation.Easing = ease; wtecnologiasr = 0; if (wmarcon == 1 && wmetodosa == 1) { endPoint2.Y = 140; animation2.EndPoint = endPoint2; pA(animation2, 2); endPoint.Y = 220 + 140; animation.EndPoint = endPoint; pA(animation, 3); } else { if (wmetodosa == 1) { endPoint.Y = 0 * sz; animation.EndPoint = endPoint; pA(animation, 2); endPoint2.Y = 220; animation2.EndPoint = endPoint2; pA(animation2, 3); } else { if (wmarcon == 1) { endPoint.Y = 140; animation.EndPoint = endPoint; pA(animation, 2); endPoint2.Y = 140; animation2.EndPoint = endPoint2; pA(animation2, 3); } else { endPoint.Y = 0; animation.EndPoint = endPoint; pA(animation, 2); pA(animation, 3); } } } } RadAnimationManager.Play(grid_TecnologiasR, resizeAnimation); }
private void listHotspotNav_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!_noHotspots) { SurfaceListBoxItem item; int index; if (listHotspotNav.SelectedIndex != -1) { Hotspot selectedHotspot = m_hotspotCollection.Hotspots[listHotspotNav.SelectedIndex]; if (m_hotspotOnOff == true) { { if (m_currentSelectedHotspotIndex != -1) { item = (SurfaceListBoxItem)listHotspotNav.Items.GetItemAt(m_currentSelectedHotspotIndex); index = (int)item.Tag; m_hotspotCollection.HotspotIcons[index].changeToNormal(); } item = (SurfaceListBoxItem)listHotspotNav.Items.GetItemAt(listHotspotNav.SelectedIndex); index = (int)item.Tag; m_hotspotCollection.HotspotIcons[index].changeToHighLighted(); } } else { m_hotspotCollection.unloadAllHotspotsIcon(); item = (SurfaceListBoxItem)listHotspotNav.Items.GetItemAt(listHotspotNav.SelectedIndex); index = (int)item.Tag; m_hotspotCollection.loadHotspotIcon(index, HotspotOverlay, MSIScatterView, msi); m_hotspotCollection.HotspotIcons[index].changeToHighLighted(); } m_currentSelectedHotspotIndex = listHotspotNav.SelectedIndex; // pan to the current selected hotspot: Double[] size = this.findImageSize(m_hotspotCollection.Hotspots[index].artworkName); Point dest = new Point(m_hotspotCollection.Hotspots[index].PositionX * size[0], m_hotspotCollection.Hotspots[index].PositionY * size[1]); Point targetOffset = new Point(dest.X * msi.GetZoomableCanvas.Scale - msi.GetZoomableCanvas.ActualWidth * 0.5, dest.Y * msi.GetZoomableCanvas.Scale - msi.GetZoomableCanvas.ActualHeight * 0.5); var duration = TimeSpan.FromMilliseconds(0.5 * 1000); var easing = new QuadraticEase(); msi.GetZoomableCanvas.BeginAnimation(ZoomableCanvas.OffsetProperty, new PointAnimation(targetOffset, duration) { EasingFunction = easing }, HandoffBehavior.Compose); } } }
private void aa_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //FrameworkElement container = sender as FrameworkElement; FrameworkElement container = bb as FrameworkElement; if (container == null) { return; } if (container.Visibility == Visibility.Collapsed) { Storyboard itemDropDown = new Storyboard(); IEasingFunction quadraticEase = new QuadraticEase { EasingMode = EasingMode.EaseOut }; int initialKeyTime = InitialKeyTime; int finalKeyTime = FinalKeyTime; TranslateTransform translation = new TranslateTransform(); container.RenderTransform = translation; DoubleAnimationUsingKeyFrames transAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame transKeyFrame_1 = new EasingDoubleKeyFrame(); transKeyFrame_1.EasingFunction = quadraticEase; transKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); transKeyFrame_1.Value = -150.0; EasingDoubleKeyFrame transKeyFrame_2 = new EasingDoubleKeyFrame(); transKeyFrame_2.EasingFunction = quadraticEase; transKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime); transKeyFrame_2.Value = 0.0; EasingDoubleKeyFrame transKeyFrame_3 = new EasingDoubleKeyFrame(); transKeyFrame_3.EasingFunction = quadraticEase; transKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); transKeyFrame_3.Value = 0.0; transAnimation.KeyFrames.Add(transKeyFrame_1); transAnimation.KeyFrames.Add(transKeyFrame_2); transAnimation.KeyFrames.Add(transKeyFrame_3); Storyboard.SetTarget(transAnimation, translation); Storyboard.SetTargetProperty(transAnimation, new PropertyPath(TranslateTransform.YProperty)); itemDropDown.Children.Add(transAnimation); DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame opacityKeyFrame_1 = new EasingDoubleKeyFrame(); opacityKeyFrame_1.EasingFunction = quadraticEase; opacityKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); opacityKeyFrame_1.Value = 0.0; EasingDoubleKeyFrame opacityKeyFrame_2 = new EasingDoubleKeyFrame(); opacityKeyFrame_2.EasingFunction = quadraticEase; opacityKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime - 150); opacityKeyFrame_2.Value = 0.0; EasingDoubleKeyFrame opacityKeyFrame_3 = new EasingDoubleKeyFrame(); opacityKeyFrame_3.EasingFunction = quadraticEase; opacityKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); opacityKeyFrame_3.Value = 1.0; opacityAnimation.KeyFrames.Add(opacityKeyFrame_1); opacityAnimation.KeyFrames.Add(opacityKeyFrame_2); opacityAnimation.KeyFrames.Add(opacityKeyFrame_3); Storyboard.SetTarget(opacityAnimation, container); Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(FrameworkElement.OpacityProperty)); itemDropDown.Children.Add(opacityAnimation); itemDropDown.Begin(); container.Visibility = Visibility.Visible; } else { Storyboard itemFold = new Storyboard(); IEasingFunction quadraticEase = new QuadraticEase { EasingMode = EasingMode.EaseOut }; int initialKeyTime = InitialKeyTime; int finalKeyTime = FinalKeyTime; TranslateTransform translation = new TranslateTransform(); container.RenderTransform = translation; DoubleAnimationUsingKeyFrames transAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame transKeyFrame_1 = new EasingDoubleKeyFrame(); transKeyFrame_1.EasingFunction = quadraticEase; transKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); transKeyFrame_1.Value = 0.0; EasingDoubleKeyFrame transKeyFrame_2 = new EasingDoubleKeyFrame(); transKeyFrame_2.EasingFunction = quadraticEase; transKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime); transKeyFrame_2.Value = 0.0; EasingDoubleKeyFrame transKeyFrame_3 = new EasingDoubleKeyFrame(); transKeyFrame_3.EasingFunction = quadraticEase; transKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); transKeyFrame_3.Value = -150.0; transAnimation.KeyFrames.Add(transKeyFrame_1); transAnimation.KeyFrames.Add(transKeyFrame_2); transAnimation.KeyFrames.Add(transKeyFrame_3); Storyboard.SetTarget(transAnimation, translation); Storyboard.SetTargetProperty(transAnimation, new PropertyPath(TranslateTransform.YProperty)); itemFold.Children.Add(transAnimation); DoubleAnimationUsingKeyFrames opacityAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame opacityKeyFrame_1 = new EasingDoubleKeyFrame(); opacityKeyFrame_1.EasingFunction = quadraticEase; opacityKeyFrame_1.KeyTime = TimeSpan.FromMilliseconds(0.0); opacityKeyFrame_1.Value = 1.0; EasingDoubleKeyFrame opacityKeyFrame_2 = new EasingDoubleKeyFrame(); opacityKeyFrame_2.EasingFunction = quadraticEase; opacityKeyFrame_2.KeyTime = TimeSpan.FromMilliseconds(initialKeyTime - 150); opacityKeyFrame_2.Value = 0.5; EasingDoubleKeyFrame opacityKeyFrame_3 = new EasingDoubleKeyFrame(); opacityKeyFrame_3.EasingFunction = quadraticEase; opacityKeyFrame_3.KeyTime = TimeSpan.FromMilliseconds(finalKeyTime); opacityKeyFrame_3.Value = 0.0; opacityAnimation.KeyFrames.Add(opacityKeyFrame_1); opacityAnimation.KeyFrames.Add(opacityKeyFrame_2); opacityAnimation.KeyFrames.Add(opacityKeyFrame_3); Storyboard.SetTarget(opacityAnimation, container); Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(FrameworkElement.OpacityProperty)); itemFold.Children.Add(opacityAnimation); itemFold.Begin(); itemFold.Completed += itemFold_Completed; } }
/// <summary> /// Animates the tiles using the supplied entrance mode, Y direction, Z direction and duration. /// </summary> /// <param name="mode">The entrance mode (Enter or Exit).</param> /// <param name="yDirection">The direction of the animation in the vertical axis (TopToBottom or BottomToTop)</param> /// <param name="zDirection">The direction of the animation in the depth axis (FrontToBack or BackToFront)</param> /// <param name="duration">The duration of the animation for each tile</param> public void AnimateTiles(EnterMode mode, YDirection yDirection, ZDirection zDirection, TimeSpan duration) { // If the control has not been rendered, cancel the animation if (ActualWidth <= 0 || ActualHeight <= 0) { return; } // If the control it's empty, after position calculation is ran, cancel the animation CalculateElementPositions(); if (_positions == null || _positions.Count <= 0) { return; } // Calculates start and end heights double startHeight = 0; double endHeight = ActualHeight; startHeight = 0; endHeight = _scrollViewer.ViewportHeight; // Get the visible tiles for the current configuration // Tiles that are partially visible are also counted var visibleTiles = _positions.Where(x => x.Value.Y + x.Key.ActualHeight >= startHeight && x.Value.Y <= startHeight + endHeight); // No visible tiles, do nothing var visibleCount = visibleTiles.Count(); if (visibleCount <= 0) { return; } // The Y coordinate of the lowest element is useful // when we animate from bottom to top double lowestY = visibleTiles.Max(el => el.Value.Y); // Store the animations to group them in one Storyboard in the end var animations = new List<Timeline>(); var lastAnimations = new List<Timeline>(); foreach (var tilePosition in visibleTiles) { var currentTileAnimationDuration = duration; bool isTileSelected = tilePosition.Key.DataContext == SelectedItem; if (isTileSelected) { currentTileAnimationDuration = currentTileAnimationDuration.Multiply(0.8d); } var tile = tilePosition.Key; var position = tilePosition.Value; var projection = tile.Projection as PlaneProjection; double rotationFrom, rotationTo, opacityTo; // Reset all children's opacity regardless of their animations if (mode == EnterMode.Exit) { tile.Opacity = 1; opacityTo = 0; rotationFrom = 0; rotationTo = zDirection == ZDirection.BackToFront ? -90 : 90; } else { tile.Opacity = 0; opacityTo = 1; rotationFrom = zDirection == ZDirection.BackToFront ? -90 : 90; rotationTo = 0; } // Used to determine begin time - depends if we're moving from bottom or from top double relativeY; if (yDirection == YDirection.BottomToTop) { // The lowest element should have relativeY == 0 relativeY = lowestY - position.Y; } else { relativeY = position.Y; } var easing = new QuadraticEase() { EasingMode = EasingMode.EaseInOut }; var rotationAnimation = new DoubleAnimation { From = rotationFrom, To = rotationTo, EasingFunction = easing }; rotationAnimation.Duration = currentTileAnimationDuration; if (isTileSelected) { //animate tile as it's lower than all others (so it will be later even it's last in the list) rotationAnimation.BeginTime = currentTileAnimationDuration.Multiply(GetBeginTimeFactor(position.X, lowestY * 1.2d, mode)); } else { rotationAnimation.BeginTime = currentTileAnimationDuration.Multiply(GetBeginTimeFactor(position.X, relativeY, mode)); } rotationAnimation.SetTargetAndProperty(projection, PlaneProjection.RotationYProperty); var opacityAnimation = new DoubleAnimation { To = opacityTo, EasingFunction = easing }; // The opacity animation takes the last 60% of the rotation animation opacityAnimation.Duration = currentTileAnimationDuration.Multiply(0.6); opacityAnimation.BeginTime = rotationAnimation.BeginTime; if (mode == EnterMode.Exit) opacityAnimation.BeginTime += currentTileAnimationDuration - opacityAnimation.Duration.TimeSpan; opacityAnimation.SetTargetAndProperty(tile, UIElement.OpacityProperty); animations.Add(rotationAnimation); animations.Add(opacityAnimation); } animations.AddRange(lastAnimations); // Begin all animations var sb = new Storyboard(); foreach (var a in animations) { sb.Children.Add(a); } sb.SpeedRatio = SpeedRatio; sb.Completed += sb_Completed; sb.Begin(); }
public static PlotElementAnimation CreateAnimation(AnimationTransform transform, AnimationOrigin origin, Easing easing, bool indexDelay) { var sb = new Storyboard(); var duration = new Duration(TimeSpan.FromSeconds(0.5)); var style = new Style(); style.TargetType = typeof(PlotElement); style.Setters.Add(new Setter(PlotElement.OpacityProperty, 0.0)); if (transform == AnimationTransform.Scale) style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new ScaleTransform() { ScaleX = 0, ScaleY = 0 })); else if (transform == AnimationTransform.Rotation) style.Setters.Add(new Setter(PlotElement.RenderTransformProperty, new RotateTransform() { Angle = 180 })); var point = new Point(0.5, 0.5); switch (origin) { case AnimationOrigin.Bottom: point = new Point(0.5, 2); break; case AnimationOrigin.Top: point = new Point(0.5, -2); break; case AnimationOrigin.Left: point = new Point(-2, 0.5); break; case AnimationOrigin.Right: point = new Point(2, 0.5); break; case AnimationOrigin.TopLeft: point = new Point(2, -2); break; case AnimationOrigin.TopRight: point = new Point(-2, -2); break; case AnimationOrigin.BottomLeft: point = new Point(2, 2); break; case AnimationOrigin.BottomRight: point = new Point(-2, 2); break; default: break; } style.Setters.Add(new Setter(PlotElement.RenderTransformOriginProperty, point)); var da = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da, new PropertyPath("Opacity")); sb.Children.Add(da); if (transform == AnimationTransform.Scale) { var da2 = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).ScaleX")); var da3 = new DoubleAnimation() { From = 0, To = 1, Duration = duration }; Storyboard.SetTargetProperty(da3, new PropertyPath("(RenderTransform).ScaleY")); sb.Children.Add(da2); sb.Children.Add(da3); } else if (transform == AnimationTransform.Rotation) { var da2 = new DoubleAnimation() { To = 0, Duration = duration }; Storyboard.SetTargetProperty(da2, new PropertyPath("(RenderTransform).Angle")); sb.Children.Add(da2); } if (indexDelay) { foreach (var anim in sb.Children) PlotElementAnimation.SetIndexDelay(anim, 0.5); } #if CLR40 if (easing != Easing.None) { IEasingFunction ef = null; switch (easing) { case Easing.BackEase: ef = new BackEase(); break; case Easing.BounceEase: ef = new BounceEase(); break; case Easing.CircleEase: ef = new CircleEase(); break; case Easing.CubicEase: ef = new CubicEase(); break; case Easing.ElasticEase: ef = new ElasticEase(); break; case Easing.ExponentialEase: ef = new ExponentialEase(); break; case Easing.PowerEase: ef = new PowerEase(); break; case Easing.QuadraticEase: ef = new QuadraticEase(); break; case Easing.QuarticEase: ef = new QuarticEase(); break; case Easing.QuinticEase: ef = new QuinticEase(); break; case Easing.SineEase: ef = new SineEase(); break; default: break; } foreach (DoubleAnimation anim in sb.Children) anim.EasingFunction = ef; } #endif return new PlotElementAnimation() { Storyboard = sb, SymbolStyle = style }; }
private void LongListSelector_GroupViewClosing(object sender, GroupViewClosingEventArgs e) { //Cancelling automatic closing and scrolling to do it manually. e.Cancel = true; if (e.SelectedGroup != null) { currentSelector.ScrollToGroup(e.SelectedGroup); } //Dispatch the swivel animation for performance on the UI thread. Dispatcher.BeginInvoke(() => { //Construct and begin a swivel animation to pop out the group view. IEasingFunction quadraticEase = new QuadraticEase { EasingMode = EasingMode.EaseOut }; Storyboard _swivelHide = new Storyboard(); ItemsControl groupItems = e.ItemsControl; foreach (var item in groupItems.Items) { UIElement container = groupItems.ItemContainerGenerator.ContainerFromItem(item) as UIElement; if (container != null) { Border content = VisualTreeHelper.GetChild(container, 0) as Border; if (content != null) { DoubleAnimationUsingKeyFrames showAnimation = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame showKeyFrame1 = new EasingDoubleKeyFrame(); showKeyFrame1.KeyTime = TimeSpan.FromMilliseconds(0); showKeyFrame1.Value = 0; showKeyFrame1.EasingFunction = quadraticEase; EasingDoubleKeyFrame showKeyFrame2 = new EasingDoubleKeyFrame(); showKeyFrame2.KeyTime = TimeSpan.FromMilliseconds(125); showKeyFrame2.Value = 90; showKeyFrame2.EasingFunction = quadraticEase; showAnimation.KeyFrames.Add(showKeyFrame1); showAnimation.KeyFrames.Add(showKeyFrame2); Storyboard.SetTargetProperty(showAnimation, new PropertyPath(PlaneProjection.RotationXProperty)); Storyboard.SetTarget(showAnimation, content.Projection); _swivelHide.Children.Add(showAnimation); } } } _swivelHide.Completed += _swivelHide_Completed; _swivelHide.Begin(); }); }
private void bBarra_MetodosA_Click(object sender, RoutedEventArgs e) { LosingFocus = false; RadResizeAnimation resizeAnimation = new RadResizeAnimation(); EasingFunctionBase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseInOut; sz = 220; if (wmetodosa == 0) // Metodos Abierto { resizeAnimation.StartSize = new Size(321, 0); Size size = new Size(321, sz); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = sz; animation.EndPoint = endPoint; animation.Easing = ease; wmetodosa = 1; if (wtecnologiasr == 1 && wmarcon == 1) // Si tecnologias esta abierto sumar a estigma { endPoint.Y = sz + 290 + 140; animation.EndPoint = endPoint; pA(animation, 3); } else { if (wtecnologiasr == 1) { endPoint.Y = 290 + sz; animation.EndPoint = endPoint; pA(animation, 3); } else { if (wmarcon == 1) { endPoint.Y = 140 + sz; animation.EndPoint = endPoint; pA(animation, 3); } else { endPoint.Y = sz; animation.EndPoint = endPoint; pA(animation, 3); } } } } else // Metodos Cerrado { resizeAnimation.StartSize = new Size(321, sz); Size size = new Size(321, 0); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = 0; animation.EndPoint = endPoint; animation.Easing = ease; wmetodosa = 0; if (wtecnologiasr == 1 && wmarcon == 1) { endPoint.Y = (290 + 140); animation.EndPoint = endPoint; pA(animation, 3); } else { if (wtecnologiasr == 1) { endPoint.Y = 290; animation.EndPoint = endPoint; pA(animation, 3); } else { if (wmarcon == 1) { endPoint.Y = 140; animation.EndPoint = endPoint; pA(animation, 3); } else { endPoint.Y = 0; animation.EndPoint = endPoint; pA(animation, 3); } } } } RadAnimationManager.Play(grid_MetodosA, resizeAnimation); }
void CreateStoryboards() { trans = new TranslateTransform() { X = 0, Y = 0 }; RecoverDialog.RenderTransformOrigin = new Point(0, 0); RecoverDialog.RenderTransform = trans; trans = RecoverDialog.RenderTransform as TranslateTransform; SbShowDialog = new Storyboard(); DoubleAnimation showAnim = new DoubleAnimation(); showAnim.Duration = TimeSpan.FromMilliseconds(400); showAnim.To = -480; var easing = new QuadraticEase(); easing.EasingMode = EasingMode.EaseOut; showAnim.EasingFunction = easing; Storyboard.SetTarget(showAnim, RecoverDialog); Storyboard.SetTargetProperty(showAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); SbShowDialog.Children.Add(showAnim); SbShowDialog.Completed += new EventHandler(SbShowDialog_Completed); SbHideDialog = new Storyboard(); DoubleAnimation hideAnim = new DoubleAnimation(); hideAnim.Duration = TimeSpan.FromMilliseconds(400); hideAnim.To = 0; hideAnim.EasingFunction = easing; Storyboard.SetTarget(hideAnim, RecoverDialog); Storyboard.SetTargetProperty(hideAnim, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)")); SbHideDialog.Children.Add(hideAnim); }
private void bBarra_Estigma_Click(object sender, RoutedEventArgs e) { LosingFocus = false; RadResizeAnimation resizeAnimation = new RadResizeAnimation(); EasingFunctionBase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseInOut; sz = 180; if (westigma == 0) { resizeAnimation.StartSize = new Size(321, 0); Size size = new Size(321, sz); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = sz; animation.EndPoint = endPoint; animation.Easing = ease; westigma = 1; } else { resizeAnimation.StartSize = new Size(321, sz); Size size = new Size(321, 0); resizeAnimation.EndSize = size; resizeAnimation.Easing = ease; RadMoveAnimation animation = new RadMoveAnimation(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = 0; animation.EndPoint = endPoint; animation.Easing = ease; westigma = 0; } RadAnimationManager.Play(grid_Estigma, resizeAnimation); }
public void Switch(UIElement eIn, UIElement eOut, double duration) { // create storyboard var sb = new Storyboard(); // initialize parameters var ts = duration / 2; // rotate eOut from zero to 90 if (eOut != null) { var da = CreateAnimation(eOut, _property, 0, 90, ts, 0); sb.Children.Add(da); var qe = new QuadraticEase(); qe.EasingMode = EasingMode.EaseIn; da.EasingFunction = qe; } // rotate eIn from 90 to zero if (eIn != null) { var da = CreateAnimation(eIn, _property, -90, 0, ts, eOut != null ? ts : 0); sb.Children.Add(da); var qe = new QuadraticEase(); qe.EasingMode = EasingMode.EaseOut; da.EasingFunction = qe; } // do it sb.Begin(); }
private void CControl_LostFocus(object sender, RoutedEventArgs e) { bool fg = LosingFocus; if (LosingFocus == true) { RadMoveAnimation animation = new RadMoveAnimation(); EasingFunctionBase ease = new QuadraticEase(); ease.EasingMode = EasingMode.EaseInOut; Point endPoint = new Point(); endPoint.X = 0; endPoint.Y = 0; a = 0; animation.EndPoint = endPoint; animation.Easing = ease; shield.Visibility = Visibility.Collapsed; //boton_menu.IsEnabled = true; RadAnimationManager.Play(CControl, animation); } else { LosingFocus = true; } }
private void ConstructDragInertiaAnimation(double animationEndingValue, TimeSpan animationDuration) { _dragInertiaAnimation = new Storyboard(); _dragInertiaAnimationTranslation = new DoubleAnimation(); Storyboard.SetTarget(_dragInertiaAnimationTranslation, _mediaStripCompositeTransform); Storyboard.SetTargetProperty(_dragInertiaAnimationTranslation, new PropertyPath(CompositeTransform.TranslateXProperty)); QuadraticEase easingFunction = new QuadraticEase(); easingFunction.EasingMode = EasingMode.EaseOut; _dragInertiaAnimationTranslation.From = ScrollOffset; _dragInertiaAnimationTranslation.To = animationEndingValue; _dragInertiaAnimationTranslation.Duration = animationDuration; _dragInertiaAnimationTranslation.EasingFunction = easingFunction; _dragInertiaAnimation.Children.Add(_dragInertiaAnimationTranslation); _dragInertiaAnimation.Completed += DragInertiaAnimationComplete; _dragInertiaAnimation.FillBehavior = FillBehavior.HoldEnd; }
private void AnimateTiles(EnterMode mode, XDirection xDirection, ZDirection zDirection, TimeSpan duration, Action callback) { // If the control has not been rendered or it's empty, cancel the animation if (this.ActualWidth <= 0 || this.ActualHeight <= 0 || this._positions == null || this._positions.Count <= 0) return; // Get the visible tiles for the current configuration // Tiles that are partially visible are also counted var visibleitems = this._positions.Where(x => x.Value.X + x.Key.ActualWidth >= 0 && x.Value.X <= this.ActualWidth && x.Value.Y + x.Key.ActualHeight >= 0 && x.Value.Y <= this.ActualHeight); // No visible tiles, do nothing if (visibleitems.Count() <= 0) return; // The Y coordinate of the lowest element is useful // when we animate from bottom to top double lowestX = visibleitems.Max(el => el.Value.X); // Store the animations to group them in one Storyboard in the end var animations = new List<Timeline>(); foreach (var tilePosition in visibleitems) { // To make syntax lighter var tile = tilePosition.Key; var position = tilePosition.Value; var projection = tile.Projection as PlaneProjection; double rotationFrom, rotationTo, opacityTo; // Reset all children's opacity regardless of their animations if (mode == EnterMode.Exit) { tile.Opacity = 1; opacityTo = 0; rotationFrom = 0; rotationTo = zDirection == ZDirection.BackToFront ? -90 : 90; } else { tile.Opacity = 0; opacityTo = 1; rotationFrom = zDirection == ZDirection.BackToFront ? -90 : 90; rotationTo = 0; } // Used to determine begin time - depends if we're moving from bottom or from top double relativeX; if (xDirection == XDirection.LeftToRight) { // The lowest element should have relativeY == 0 relativeX = lowestX - position.X; } else { relativeX = position.X; } var easing = new QuadraticEase() { EasingMode = EasingMode.EaseInOut }; var rotationAnimation = new DoubleAnimation { From = rotationFrom, To = rotationTo, EasingFunction = easing }; rotationAnimation.Duration = duration; rotationAnimation.BeginTime = duration.Multiply(this.GetBeginTimeFactorFavorite(relativeX, position.Y, mode)); rotationAnimation.SetTargetAndProperty(projection, PlaneProjection.RotationYProperty); var opacityAnimation = new DoubleAnimation { To = opacityTo, EasingFunction = easing }; // The opacity animation takes the last 60% of the rotation animation opacityAnimation.Duration = duration.Multiply(0.6); opacityAnimation.BeginTime = rotationAnimation.BeginTime; if (mode == EnterMode.Exit) opacityAnimation.BeginTime += duration - opacityAnimation.Duration.TimeSpan; opacityAnimation.SetTargetAndProperty(tile, UIElement.OpacityProperty); animations.Add(rotationAnimation); animations.Add(opacityAnimation); } // Begin all animations var sb = new Storyboard(); sb.Completed += (sender, args) => { if (callback != null) { callback(); } }; foreach (var a in animations) sb.Children.Add(a); sb.Begin(); }