static AccordionPanel() { var animationDuration = new Duration (TimeSpan.FromMilliseconds(400)); IEasingFunction animationEase = new ExponentialEase { EasingMode = EasingMode.EaseInOut, }; s_animationDuration = animationDuration; s_animationEase = animationEase; Initialize (ref animationDuration, ref animationEase); s_animationDuration = animationDuration; s_animationEase = animationEase; s_animationClock = new DoubleAnimation( 0 , 1 , s_animationDuration , FillBehavior.Stop ) .FreezeObject () ; }
private void BtnBack_Click(object sender, RoutedEventArgs e) { ThicknessAnimation ta = new ThicknessAnimation(new Thickness(-618, 0, 1003, 0), new Duration(TimeSpan.FromMilliseconds(350))); ExponentialEase ee = new ExponentialEase(); ee.EasingMode = EasingMode.EaseOut; ta.EasingFunction = ee; ta.Completed += ta_Completed; this.OptGrid.BeginAnimation(MarginProperty, ta); }
/// <summary> /// Constructor. /// Create a SessionAnimation with the current SessionViewModel /// </summary> /// <param name="s"></param> public SessionAnimation(SessionViewModel s) : base() { SessionVM = s; Storyboard InitStb = new Storyboard(); DoubleAnimation openingAnimation = new DoubleAnimation(); initWidthAnimation = new DoubleAnimation(); DoubleAnimation initHeightAnimation = new DoubleAnimation(); ExponentialEase ease = new ExponentialEase(); ease.EasingMode = EasingMode.EaseOut; ease.Exponent = 2; openingAnimation.From = 0; openingAnimation.To = 1; openingAnimation.Duration = new Duration(TimeSpan.FromSeconds(.5)); openingAnimation.FillBehavior = FillBehavior.HoldEnd; InitStb.Children.Add(openingAnimation); Storyboard.SetTarget(openingAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(openingAnimation, new PropertyPath(ScatterViewItem.OpacityProperty)); initWidthAnimation.From = s.SessionSVI.Width * 0.8; initWidthAnimation.To = s.SessionSVI.Width; initWidthAnimation.Duration = new Duration(TimeSpan.FromSeconds(.6)); initWidthAnimation.EasingFunction = ease; initWidthAnimation.FillBehavior = FillBehavior.Stop; InitStb.Children.Add(initWidthAnimation); Storyboard.SetTarget(initWidthAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(initWidthAnimation, new PropertyPath(ScatterViewItem.WidthProperty)); initHeightAnimation.From = s.SessionSVI.Height * 0.8; initHeightAnimation.To = s.SessionSVI.Height; initHeightAnimation.Duration = new Duration(TimeSpan.FromSeconds(.6)); initHeightAnimation.EasingFunction = ease; initHeightAnimation.FillBehavior = FillBehavior.Stop; InitStb.Children.Add(initHeightAnimation); Storyboard.SetTarget(initHeightAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(initHeightAnimation, new PropertyPath(ScatterViewItem.HeightProperty)); initWidthAnimation.Completed += new EventHandler(marginAnimation_Completed); SessionVM.SessionSVI.TouchLeave += new EventHandler<System.Windows.Input.TouchEventArgs>(svi_TouchLeave); SessionVM.SessionSVI.TouchEnter += new EventHandler<System.Windows.Input.TouchEventArgs>(SessionSVI_TouchEnter); InitStb.Begin(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (this.tweets.Items.Count <= 0) return; ScrollViewer scrollViewer = this.tweets.Template.FindName("Scroller", (FrameworkElement) this.tweets) as ScrollViewer; DoubleAnimation doubleAnimation1 = new DoubleAnimation(); doubleAnimation1.From = new double?(scrollViewer.VerticalOffset); doubleAnimation1.To = new double?(0.0); DoubleAnimation doubleAnimation2 = doubleAnimation1; ExponentialEase exponentialEase1 = new ExponentialEase(); exponentialEase1.EasingMode = EasingMode.EaseOut; exponentialEase1.Exponent = 6.0; ExponentialEase exponentialEase2 = exponentialEase1; doubleAnimation2.EasingFunction = (IEasingFunction) exponentialEase2; doubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(400.0)); scrollViewer.BeginAnimation(ScrollViewerUtilities.VerticalOffsetProperty, (AnimationTimeline) doubleAnimation1); }
private void Button_Click(object sender, RoutedEventArgs e) { int start_time = 500; DoubleAnimation da = new DoubleAnimation(0, System.Windows.SystemParameters.PrimaryScreenWidth, TimeSpan.FromMilliseconds(start_time)); DoubleAnimation daa = new DoubleAnimation(1, 0.3, TimeSpan.FromMilliseconds(start_time)); ExponentialEase easing = new ExponentialEase(); easing.EasingMode = EasingMode.EaseIn; easing.Exponent = 5; da.EasingFunction = easing; daa.EasingFunction = easing; da.Completed += (oo, ee) => { this.Close(); }; TranslateTransform tt = new TranslateTransform(); this.RenderTransformOrigin = new Point(System.Windows.SystemParameters.PrimaryScreenWidth, 0); this.RenderTransform = tt; tt.BeginAnimation(TranslateTransform.XProperty, da); this.BeginAnimation(OpacityProperty, daa); }
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 ColumnTitle_MouseDown(object sender, MouseButtonEventArgs e) { if (this.tweets.Items.Count <= 0 || e.LeftButton != MouseButtonState.Pressed && e.ClickCount != 2) return; ScrollViewer scrollViewer = this.tweets.Template.FindName("Scroller", (FrameworkElement) this.tweets) as ScrollViewer; DoubleAnimation doubleAnimation1 = new DoubleAnimation(); doubleAnimation1.From = new double?(scrollViewer.VerticalOffset); doubleAnimation1.To = new double?(0.0); DoubleAnimation doubleAnimation2 = doubleAnimation1; ExponentialEase exponentialEase1 = new ExponentialEase(); exponentialEase1.EasingMode = EasingMode.EaseOut; exponentialEase1.Exponent = 6.0; ExponentialEase exponentialEase2 = exponentialEase1; doubleAnimation2.EasingFunction = (IEasingFunction) exponentialEase2; doubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(400.0)); scrollViewer.BeginAnimation(ScrollViewerUtilities.VerticalOffsetProperty, (AnimationTimeline) doubleAnimation1); if (e.ClickCount == 2) (this.DataContext as TweetListViewModel).MarkasReadCommand.Execute((object) null); }
private static DoubleAnimation CreateExponentialAnimation(EasingMode easingMode, double animateTo, double animationDuration, Storyboard enterStoryboard, bool autoReverse) { DoubleAnimation animation = new DoubleAnimation(animateTo, TimeSpan.FromMilliseconds(animationDuration)); animation.AutoReverse = autoReverse; //ElasticEase easeIn = new ElasticEase(); var easeIn = new System.Windows.Media.Animation.ExponentialEase(); easeIn.EasingMode = easingMode; // ElasticEase //easeIn.Oscillations = 1; // BounceEase //easeIn.Bounciness = 10; //easeIn.Bounces = 1; // ExponentialEase easeIn.Exponent = 4; animation.EasingFunction = easeIn; return(animation); }
public static void SetAnyAnimation(Storyboard storyboard, FrameworkElement container, DependencyProperty property, double from, double to, double clock) { if (storyboard == null || container == null || property == null) { return; } DoubleAnimation anyAnimation = new DoubleAnimation(); Storyboard.SetTarget(anyAnimation, container); Storyboard.SetTargetProperty(anyAnimation, new PropertyPath(property)); Duration duration = TimeSpan.FromSeconds(clock); anyAnimation.Duration = duration; IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 4 }; anyAnimation.EasingFunction = easingFunction; anyAnimation.From = from; anyAnimation.To = to; storyboard.Children.Add(anyAnimation); }
public static void SetHeightAnimation(Storyboard storyboard, FrameworkElement container, double to, double clock, bool easing) { if (storyboard == null || container == null) { return; } DoubleAnimation heightAnimation = new DoubleAnimation(); Storyboard.SetTarget(heightAnimation, container); Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(FrameworkElement.HeightProperty)); Duration duration = TimeSpan.FromSeconds(clock); heightAnimation.Duration = duration; if (easing) { IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut, Exponent = 4 }; heightAnimation.EasingFunction = easingFunction; } heightAnimation.From = container.ActualHeight; heightAnimation.To = to; storyboard.Children.Add(heightAnimation); //if (to == AnimationHeightHide) //{ // storyboard.Completed += delegate(object sender, EventArgs e) // { // container.Visibility = Visibility.Collapsed; // }; //} //else //{ // container.Visibility = Visibility.Visible; //} }
private void titleLabel_MouseDown(object sender, MouseButtonEventArgs e) { if (this.activeView == null) return; ScrollViewer scrollViewer1 = (ScrollViewer) null; if (this.activeView is TweetListView && (this.activeView as TweetListView).tweets.Items.Count > 0) scrollViewer1 = (this.activeView as TweetListView).tweets.Template.FindName("Scroller", (FrameworkElement) (this.activeView as TweetListView).tweets) as ScrollViewer; if (this.activeView is ProfileView && (this.activeView as ProfileView).tweets.Items.Count > 0) scrollViewer1 = (this.activeView as ProfileView).tweets.Template.FindName("Scroller", (FrameworkElement) (this.activeView as ProfileView).tweets) as ScrollViewer; ScrollViewer scrollViewer2; if (this.activeView is ListsView) { if ((this.activeView as ListsView).lists.Items.Count <= 0) return; scrollViewer2 = (this.activeView as ListsView).lists.Template.FindName("Scroller", (FrameworkElement) (this.activeView as ListsView).lists) as ScrollViewer; } else if (this.activeView is TrendsView) { if ((this.activeView as TrendsView).trends.Items.Count <= 0) return; scrollViewer2 = (this.activeView as TrendsView).trends.Template.FindName("Scroller", (FrameworkElement) (this.activeView as TrendsView).trends) as ScrollViewer; } else if (scrollViewer1 != null) { DoubleAnimation doubleAnimation1 = new DoubleAnimation(); doubleAnimation1.From = new double?(scrollViewer1.VerticalOffset); doubleAnimation1.To = new double?(0.0); DoubleAnimation doubleAnimation2 = doubleAnimation1; ExponentialEase exponentialEase1 = new ExponentialEase(); exponentialEase1.EasingMode = EasingMode.EaseOut; exponentialEase1.Exponent = 6.0; ExponentialEase exponentialEase2 = exponentialEase1; doubleAnimation2.EasingFunction = (IEasingFunction) exponentialEase2; doubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(200.0)); scrollViewer1.BeginAnimation(ScrollViewerUtilities.VerticalOffsetProperty, (AnimationTimeline) doubleAnimation1); } }
private void PushView(System.Windows.Controls.UserControl newView) { bool flag = this.activeView != null; IPopupViewModel popupViewModel1 = newView.DataContext as IPopupViewModel; string str = popupViewModel1 != null ? popupViewModel1.PopupTitle : string.Empty; if (this.contentContainer.Children.Contains((UIElement) newView)) return; if (flag) { System.Windows.Controls.UserControl userControl = this.activeView; this.contentContainer.Children.Add((UIElement) newView); DoubleAnimation doubleAnimation1 = new DoubleAnimation(); doubleAnimation1.From = new double?(this.scrollViewer.HorizontalOffset); doubleAnimation1.To = new double?((double) (this.contentContainer.Children.IndexOf((UIElement) newView) + 1) * this.contentWidth); DoubleAnimation doubleAnimation2 = doubleAnimation1; ExponentialEase exponentialEase1 = new ExponentialEase(); exponentialEase1.EasingMode = EasingMode.EaseIn; exponentialEase1.Exponent = 6.0; ExponentialEase exponentialEase2 = exponentialEase1; doubleAnimation2.EasingFunction = (IEasingFunction) exponentialEase2; doubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(200.0)); this.scrollViewer.BeginAnimation(ScrollViewerUtilities.HorizontalOffsetProperty, (AnimationTimeline) doubleAnimation1); IPopupViewModel popupViewModel2 = this.activeView.DataContext as IPopupViewModel; this.backButton.Visibility = Visibility.Visible; this.backButton.ToolTip = (object) string.Format("Back to {0}", (object) popupViewModel2.PopupTitle); this.previousViews.Push(userControl); } else this.contentContainer.Children.Add((UIElement) newView); if (popupViewModel1 != null) { this.titleLabel.Text = str; this.pinButton.Visibility = popupViewModel1.AllowPin ? Visibility.Visible : Visibility.Collapsed; } this.activeView = newView; }
private void InternalGoBack(System.Windows.Controls.UserControl viewToGoBackTo = null) { if (this.previousViews.Count <= 0) return; if (viewToGoBackTo == null) viewToGoBackTo = this.previousViews.Pop(); System.Windows.Controls.UserControl currentView = this.activeView; DoubleAnimation doubleAnimation1 = new DoubleAnimation(); doubleAnimation1.From = new double?(this.scrollViewer.HorizontalOffset); doubleAnimation1.To = new double?((double) this.contentContainer.Children.IndexOf((UIElement) viewToGoBackTo) * this.contentWidth); DoubleAnimation doubleAnimation2 = doubleAnimation1; ExponentialEase exponentialEase1 = new ExponentialEase(); exponentialEase1.EasingMode = EasingMode.EaseOut; exponentialEase1.Exponent = 6.0; ExponentialEase exponentialEase2 = exponentialEase1; doubleAnimation2.EasingFunction = (IEasingFunction) exponentialEase2; doubleAnimation1.Duration = new Duration(TimeSpan.FromMilliseconds(400.0)); doubleAnimation1.Completed += (EventHandler) ((s, e2) => { if (this.contentContainer == null) return; this.contentContainer.Children.Remove((UIElement) currentView); }); this.scrollViewer.BeginAnimation(ScrollViewerUtilities.HorizontalOffsetProperty, (AnimationTimeline) doubleAnimation1); this.activeView = viewToGoBackTo; IPopupViewModel popupViewModel = this.activeView.DataContext as IPopupViewModel; if (popupViewModel != null && (this.titleLabel != null && this.pinButton != null)) { if (!string.IsNullOrEmpty(popupViewModel.PopupTitle)) { this.titleLabel.Text = popupViewModel.PopupTitle; this.titleLabel.Visibility = Visibility.Visible; } else this.titleLabel.Visibility = Visibility.Collapsed; this.pinButton.Visibility = popupViewModel.AllowPin ? Visibility.Visible : Visibility.Collapsed; } if (this.previousViews.Count == 0) { if (this.backButton != null) this.backButton.Visibility = Visibility.Collapsed; } else if (this.previousViews.Peek() != null && this.previousViews.Peek().DataContext is IPopupViewModel) this.backButton.ToolTip = (object) string.Format("Back to {0}", (object) (this.previousViews.Peek().DataContext as IPopupViewModel).PopupTitle); }
static AnimatedEntrance() { var parserContext = new ParserContext { XamlTypeMapper = new XamlTypeMapper(new string[0]) }; var type = typeof (AnimatedEntrance); var namespaceName = type.Namespace ?? ""; var assemblyName = type.Assembly.FullName; parserContext.XamlTypeMapper.AddMappingProcessingInstruction("Internal", namespaceName, assemblyName); parserContext.XmlnsDictionary.Add("i", "Internal"); s_defaultStyle = (Style)XamlReader.Parse( DefaultStyle, parserContext ); var transitionDuration = new Duration (TimeSpan.FromMilliseconds(400)); var delayDuration = new Duration (TimeSpan.FromMilliseconds(200)); IEasingFunction transitionEase = new ExponentialEase { EasingMode = EasingMode.EaseInOut, }; s_transitionDuration = transitionDuration ; s_delayDuration = delayDuration ; s_transitionEase = transitionEase ; Initialize (ref transitionDuration, ref delayDuration, ref transitionEase); s_transitionDuration = transitionDuration ; s_delayDuration = delayDuration ; s_transitionEase = transitionEase ; s_transitionClock = new DoubleAnimation( 0 , 1 , s_transitionDuration , FillBehavior.Stop ) .FreezeObject () ; StyleProperty.OverrideMetadata(typeof(AnimatedEntrance), new FrameworkPropertyMetadata(s_defaultStyle)); }
private void TransitionToPage(Int32 index, Int32 duration) { var animationDuration = new Duration(TimeSpan.FromMilliseconds(duration)); var animation = new DoubleAnimation(index * -contentCanvas.ActualWidth, animationDuration); Storyboard.SetTargetProperty(animation, new PropertyPath("(Canvas.Left)")); Storyboard.SetTarget(animation, panorama); var easing = new ExponentialEase {EasingMode = EasingMode.EaseInOut}; animation.EasingFunction = easing; pageTransitionStoryboard = new Storyboard(); pageTransitionStoryboard.Children.Add(animation); activePageIndex = index; pageTransitionStoryboard.Begin(); }
public static void SlideUp(UIElement elem) { int start_time = 500; ExponentialEase easing = new ExponentialEase(); easing.EasingMode = EasingMode.EaseOut; easing.Exponent = 8; DoubleAnimation daaa = new DoubleAnimation(0.3, 1, TimeSpan.FromMilliseconds(start_time)); elem.BeginAnimation(UIElement.OpacityProperty, daaa); DoubleAnimation daa = new DoubleAnimation(System.Windows.SystemParameters.PrimaryScreenHeight, 0, TimeSpan.FromMilliseconds(start_time)); daa.EasingFunction = easing; TranslateTransform tt = new TranslateTransform(); elem.RenderTransformOrigin = new Point(System.Windows.SystemParameters.PrimaryScreenHeight, 0); elem.RenderTransform = tt; tt.BeginAnimation(TranslateTransform.YProperty, daa); }
public static IEasingFunction GetEasingFunction(double stopTime, double friction) { // From above, we have the equation of position // // r = v_0 (mu^t - 1) / ln mu // // IEasingFunction.Ease() is a method that accepts // a normalized time as a parameter // (that is, a number between 0.0 and 1.0 such that // 0.0 represents the beginning of the animation duration and // 1.0 represents the end of the animation duration), // and which returns a normalized progress // (that is, a number between 0.0 and 1.0 such that // 0.0 represents no progress along the animation and // 1.0 represents full progress along the animation). // // In order to get the above equation of position // to work as an easing function, we need two things: // to normalize the LHS such that it varies between 0.0 and 1.0 // (corresponding to its initial position and its final position, respectively), // and to have it accept as a parameter on the RHS a normalized time, // rather than an actual time. // // First, to get a normalized LHS, we divide |r| by |r_max| (the stop distance as above) // to get the normalized position r_n: // // |r| / |r_max| = r_n = (mu^t - 1) / (mu^t_max- 1) // // Now we note that // // t = t_n t_max // // where t_max is the stop time as above and where t_n is the normalized time // to get // // r_n = (mu^(t_n t_max) - 1) / (mu^t_max- 1) // // Finally, we can take advantage of the fact that // // x^y = e^(y ln x) // // where e is Euler's number to put this in the form of // // r_n = (e^(t_n t_max ln mu) - 1) / (e^(t_max ln mu) - 1) // // and if we define a = t_max ln mu, then we have // // r_n = (e^(a t_n) - 1) / (e^a - 1) // // which is precisely the form of the exponential easing function. // So, we can use an exponential easing function here with its // Exponent property set to t_max ln mu, and it will get us what we want. // ExponentialEase ee = new ExponentialEase { Exponent = stopTime*Math.Log(friction), EasingMode = EasingMode.EaseIn }; return ee; }
private void OpenPopup(Point position) { _popupAlignmentPoint = position; InitializeRootVisual(); bool portrait = _rootVisual.Orientation.IsPortrait(); if (portrait) { if (_innerGrid != null) { _innerGrid.MinHeight = 0; } } else { if (_innerGrid != null) { // if landscape to the full height. NOTE: device is rotated so use the ActualWidth _innerGrid.MinHeight = _rootVisual.ActualWidth; } } _overlay = new Canvas { Background = new SolidColorBrush(Colors.Transparent) }; _overlay.MouseLeftButtonUp += OnOverlayMouseButtonUp; if (IsZoomEnabled && (null != _rootVisual)) { // Capture effective width/height double width = portrait ? _rootVisual.ActualWidth : _rootVisual.ActualHeight; double height = portrait ? _rootVisual.ActualHeight : _rootVisual.ActualWidth; // Create a layer for the background brush UIElement backgroundLayer = new Rectangle { Width = width, Height = height, Fill = (Brush)Application.Current.Resources["PhoneBackgroundBrush"], CacheMode = new BitmapCache(), }; _overlay.Children.Insert(0, backgroundLayer); // Hide the owner for the snapshot we will take FrameworkElement ownerElement = _owner as FrameworkElement; if (null != ownerElement) { ownerElement.Opacity = 0; } // Create a layer for the page content WriteableBitmap writeableBitmap = new WriteableBitmap((int)width, (int)height); writeableBitmap.Render(_rootVisual, null); writeableBitmap.Invalidate(); Transform scaleTransform = new ScaleTransform { CenterX = width / 2, CenterY = height / 2, }; UIElement contentLayer = new Image { Source = writeableBitmap, RenderTransform = scaleTransform, CacheMode = new BitmapCache(), }; _overlay.Children.Insert(1, contentLayer); // Create a layer for the background brush UIElement backgroundFadeLayer = new Rectangle { Width = width, Height = height, Fill = (Brush)Application.Current.Resources["PhoneBackgroundBrush"], Opacity = 0, CacheMode = new BitmapCache(), }; _overlay.Children.Insert(2, backgroundFadeLayer); // Create a layer for the owner element and its background if (null != ownerElement) { ((FrameworkElement)Owner).Opacity = 1; // If the owner's flow direction is right-to-left, then (0, 0) is situated at the // top-right corner of the element instead of its top-left corner. // We need for the translated point to be in the top-left corner since we want these elements // to be drawn on top of the owner's position from left to right, // so to achieve that, we'll translate (0, ActualWidth) instead if its flow direction is right-to-left. Point point = SafeTransformToVisual(ownerElement, _rootVisual).Transform(new Point(ownerElement.FlowDirection == System.Windows.FlowDirection.RightToLeft ? ownerElement.ActualWidth : 0, 0)); // Create a layer for the element's background UIElement elementBackground = new Rectangle { Width = ownerElement.ActualWidth, Height = ownerElement.ActualHeight, Fill = new SolidColorBrush(Colors.Transparent), CacheMode = new BitmapCache(), }; Canvas.SetLeft(elementBackground, point.X); Canvas.SetTop(elementBackground, point.Y); _overlay.Children.Insert(3, elementBackground); // Create a layer for the element UIElement element = new Image { Source = new WriteableBitmap(ownerElement, null) }; Canvas.SetLeft(element, point.X); Canvas.SetTop(element, point.Y); _overlay.Children.Insert(4, element); } // Prepare for scale animation double from = 1; double to = 0.94; TimeSpan timespan = TimeSpan.FromSeconds(0.42); IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut }; _backgroundResizeStoryboard = new Storyboard(); // Create an animation for the X scale DoubleAnimation animationX = new DoubleAnimation { From = from, To = to, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationX, scaleTransform); Storyboard.SetTargetProperty(animationX, new PropertyPath(ScaleTransform.ScaleXProperty)); _backgroundResizeStoryboard.Children.Add(animationX); // Create an animation for the Y scale DoubleAnimation animationY = new DoubleAnimation { From = from, To = to, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationY, scaleTransform); Storyboard.SetTargetProperty(animationY, new PropertyPath(ScaleTransform.ScaleYProperty)); _backgroundResizeStoryboard.Children.Add(animationY); if (IsFadeEnabled) { DoubleAnimation animationFade = new DoubleAnimation { From = 0, To = .3, Duration = timespan, EasingFunction = easingFunction }; Storyboard.SetTarget(animationFade, backgroundFadeLayer); Storyboard.SetTargetProperty(animationFade, new PropertyPath(Rectangle.OpacityProperty)); _backgroundResizeStoryboard.Children.Add(animationFade); } } // Create transforms for handling rotation TransformGroup transforms = new TransformGroup(); if (null != _rootVisual) { switch (_rootVisual.Orientation) { case PageOrientation.LandscapeLeft: transforms.Children.Add(new RotateTransform { Angle = 90 }); transforms.Children.Add(new TranslateTransform { X = _rootVisual.ActualWidth }); break; case PageOrientation.LandscapeRight: transforms.Children.Add(new RotateTransform { Angle = -90 }); transforms.Children.Add(new TranslateTransform { Y = _rootVisual.ActualHeight }); break; } } _overlay.RenderTransform = transforms; // Add Click handler for ApplicationBar Buttons if ((null != _page) && (null != _page.ApplicationBar) && (null != _page.ApplicationBar.Buttons)) { foreach (object obj in _page.ApplicationBar.Buttons) { ApplicationBarIconButton button = obj as ApplicationBarIconButton; if (null != button) { button.Click += OnEventThatClosesContextMenu; _applicationBarIconButtons.Add(button); } } } _overlay.Children.Add(this); _popup = new Popup { Child = _overlay }; _popup.Opened += (s, e) => { // When the popup is actually opened, call our OnOpened method OnOpened(new RoutedEventArgs()); }; SizeChanged += OnContextMenuOrRootVisualSizeChanged; if (null != _rootVisual) { _rootVisual.SizeChanged += OnContextMenuOrRootVisualSizeChanged; } UpdateContextMenuPlacement(); if (ReadLocalValue(DataContextProperty) == DependencyProperty.UnsetValue) { DependencyObject dataContextSource = Owner ?? _rootVisual; SetBinding(DataContextProperty, new Binding("DataContext") { Source = dataContextSource }); } _popup.IsOpen = true; Focus(); // Update IsOpen _settingIsOpen = true; IsOpen = true; _settingIsOpen = false; }
/// <summary> /// Event launched when ScatterViewItem's white borders are fully visible. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void stb_border_Completed(object sender, EventArgs e) { MainDesktop.Sessions.Items.Remove(SessionVM.SessionSVI); MainDesktop.Photos.Items.Add(SessionVM.SessionSVI); if (SessionVM.Orientation == "left") MainDesktop.LeftSessionActive = false; if (SessionVM.Orientation == "right") MainDesktop.RightSessionActive = false; MainDesktop.CheckDesktopToDisplay(); Storyboard = new Storyboard(); PointAnimation centerPosAnimation = new PointAnimation(); DoubleAnimation orientationAnimation = new DoubleAnimation(); ExponentialEase ease = new ExponentialEase(); ease.EasingMode = EasingMode.EaseOut; ease.Exponent = 1.5; Random r = new Random(); Point newCenter = new Point(r.Next((int)MainDesktop.Photos.ActualWidth), r.Next((int)MainDesktop.Photos.ActualHeight)); Double newOrientation = r.Next(-180, 180); if (SessionVM.Orientation == "right" && MainDesktop.LeftSessionActive) centerPosAnimation.From = new Point(SessionVM.SessionSVI.ActualCenter.X - 607.5, SessionVM.SessionSVI.ActualCenter.Y); else centerPosAnimation.From = SessionVM.SessionSVI.ActualCenter; centerPosAnimation.To = newCenter; centerPosAnimation.Duration = new Duration(TimeSpan.FromSeconds(5)); centerPosAnimation.DecelerationRatio = .9; centerPosAnimation.EasingFunction = ease; centerPosAnimation.FillBehavior = FillBehavior.Stop; Storyboard.Children.Add(centerPosAnimation); Storyboard.SetTarget(centerPosAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(centerPosAnimation, new PropertyPath(ScatterViewItem.CenterProperty)); orientationAnimation.From = SessionVM.SessionSVI.ActualOrientation; orientationAnimation.To = newOrientation; orientationAnimation.Duration = new Duration(TimeSpan.FromSeconds(5)); orientationAnimation.DecelerationRatio = .9; orientationAnimation.EasingFunction = ease; orientationAnimation.FillBehavior = FillBehavior.Stop; Storyboard.Children.Add(orientationAnimation); Storyboard.SetTarget(orientationAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(orientationAnimation, new PropertyPath(ScatterViewItem.OrientationProperty)); SessionVM.SessionSVI.Center = newCenter; SessionVM.SessionSVI.Orientation = newOrientation; Storyboard.Begin(); SessionVM.SessionSVI.CanMove = true; SessionVM.SessionSVI.CanRotate = true; SessionVM.SessionSVI.CanScale = false; SessionVM.SessionSVI.PreviewTouchDown += new EventHandler<System.Windows.Input.TouchEventArgs>(Session_PreviewTouchDown); SessionVM.Reduced = true; }
/// <summary> /// Delete a session /// </summary> public void DeleteSession() { SessionVM.BeingDeleted = true; Storyboard DeleteStb = new Storyboard(); DoubleAnimation endingAnimation = new DoubleAnimation(); DoubleAnimation endingWidthAnimation = new DoubleAnimation(); DoubleAnimation endingHeightAnimation = new DoubleAnimation(); ExponentialEase ease = new ExponentialEase(); ease.EasingMode = EasingMode.EaseOut; ease.Exponent = 2; endingAnimation.From = 1; endingAnimation.To = 0; endingAnimation.Duration = new Duration(TimeSpan.FromSeconds(.3)); endingAnimation.FillBehavior = FillBehavior.HoldEnd; DeleteStb.Children.Add(endingAnimation); Storyboard.SetTarget(endingAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(endingAnimation, new PropertyPath(ScatterViewItem.OpacityProperty)); endingWidthAnimation.From = SessionVM.SessionSVI.Width; endingWidthAnimation.To = SessionVM.SessionSVI.Width * 0.8; endingWidthAnimation.Duration = new Duration(TimeSpan.FromSeconds(.4)); endingWidthAnimation.EasingFunction = ease; endingWidthAnimation.FillBehavior = FillBehavior.Stop; DeleteStb.Children.Add(endingWidthAnimation); Storyboard.SetTarget(endingWidthAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(endingWidthAnimation, new PropertyPath(ScatterViewItem.WidthProperty)); endingHeightAnimation.From = SessionVM.SessionSVI.Height; endingHeightAnimation.To = SessionVM.SessionSVI.Height * 0.8; endingHeightAnimation.Duration = new Duration(TimeSpan.FromSeconds(.4)); endingHeightAnimation.EasingFunction = ease; endingHeightAnimation.FillBehavior = FillBehavior.Stop; DeleteStb.Children.Add(endingHeightAnimation); Storyboard.SetTarget(endingHeightAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(endingHeightAnimation, new PropertyPath(ScatterViewItem.HeightProperty)); endingWidthAnimation.Completed += new EventHandler(deleteAnimationCompleted); DeleteStb.Begin(); }
private void InitAnimateWindow() { sbIn = new Storyboard(); DoubleAnimation myDoubleAnimationIn = new DoubleAnimation(); myDoubleAnimationIn.Duration = new Duration(new TimeSpan(1000000)); sbIn.Children.Add(myDoubleAnimationIn); sbIn.Duration = new Duration(new TimeSpan(1000000)); Storyboard.SetTarget(myDoubleAnimationIn, this); Storyboard.SetTargetProperty(myDoubleAnimationIn, new PropertyPath("(Window.Opacity)")); myDoubleAnimationIn.From = 0.01; myDoubleAnimationIn.To = 1; ExponentialEase myEaseFunctionIn = new ExponentialEase(); myEaseFunctionIn.EasingMode = EasingMode.EaseOut; myEaseFunctionIn.Exponent = 3; myDoubleAnimationIn.EasingFunction = myEaseFunctionIn; sbOut = new Storyboard(); sbOut.Completed += sbOut_Completed; DoubleAnimation myDoubleAnimationOut = new DoubleAnimation(); myDoubleAnimationOut.Duration = new Duration(new TimeSpan(1000000)); sbOut.Children.Add(myDoubleAnimationOut); sbOut.Duration = new Duration(new TimeSpan(1000000)); Storyboard.SetTarget(myDoubleAnimationOut, this); Storyboard.SetTargetProperty(myDoubleAnimationOut, new PropertyPath("(Window.Opacity)")); myDoubleAnimationOut.From = 1; myDoubleAnimationOut.To = 0.01; ExponentialEase myEaseFunctionOut = new ExponentialEase(); myEaseFunctionOut.EasingMode = EasingMode.EaseIn; myEaseFunctionOut.Exponent = 3; myDoubleAnimationIn.EasingFunction = myEaseFunctionOut; }
private void cc_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { FrameworkElement container = sender as FrameworkElement; if (container != null) { Storyboard storyboard = new Storyboard(); DoubleAnimation heightAnimation = new DoubleAnimation(); Storyboard.SetTarget(heightAnimation, container); Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(FrameworkElement.HeightProperty)); Duration duration = TimeSpan.FromSeconds(0.2); heightAnimation.Duration = duration; IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut, Exponent = 4 }; heightAnimation.EasingFunction = easingFunction; heightAnimation.From = container.ActualHeight; heightAnimation.To = container.ActualHeight * 2; storyboard.Children.Add(heightAnimation); storyboard.Begin(); } }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { try { this.hwndSource = PresentationSource.FromVisual((Visual)sender) as HwndSource; this.hwndSource.AddHook(new HwndSourceHook(this.WndProc)); } catch { } this.InitializeDPI(); double minWidth = System.Windows.Application.Current.MainWindow.MinWidth; double minHeight = System.Windows.Application.Current.MainWindow.MinHeight; if (SettingsData.Instance.Window.Height == 0.0) { SettingsData.Save(); } base.Width = SettingsData.Instance.Window.Width; base.Height = SettingsData.Instance.Window.Height; base.Top = SettingsData.Instance.Window.Top; base.Left = SettingsData.Instance.Window.Left; CommonCommands.GetAvailableUserAccounts(); Screen screen = CommonCommands.CurrentScreen(); if ((((SettingsData.Instance.Window.Left == 0.0) && (SettingsData.Instance.Window.Top == 0.0)) && (SettingsData.Instance.Window.Height == 0.0)) && (SettingsData.Instance.Window.Width == 0.0)) { base.Width = 1024.0; base.Height = 700.0; base.Top = (screen.WorkingArea.Height - (base.Height * App.DpiXfactor)) / 2.0; base.Left = (screen.WorkingArea.Width - (base.Width * App.DpiXfactor)) / 2.0; } else { base.Width = ((base.Width * App.DpiXfactor) > screen.WorkingArea.Width) ? (((double)screen.WorkingArea.Width) / App.DpiXfactor) : ((base.Width < minWidth) ? minWidth : base.Width); base.Height = ((base.Height * App.DpiYfactor) > screen.WorkingArea.Height) ? (((double)screen.WorkingArea.Height) / App.DpiYfactor) : ((base.Height < minHeight) ? minHeight : base.Height); base.Top = ((base.Top >= (screen.WorkingArea.Top + screen.WorkingArea.Height)) || (base.Top < screen.WorkingArea.Top)) ? (screen.WorkingArea.Top + ((screen.WorkingArea.Height - (base.Height * App.DpiXfactor)) / 2.0)) : base.Top; base.Left = ((base.Left >= (screen.WorkingArea.Left + screen.WorkingArea.Width)) || (base.Left < screen.WorkingArea.Left)) ? (screen.WorkingArea.Left + ((screen.WorkingArea.Width - (base.Width * App.DpiYfactor)) / 2.0)) : base.Left; } if (SettingsData.Instance.Window.WindowState == WindowState.Minimized) { (base.DataContext as MainViewModel).MainWindowState = WindowState.Normal; } else { (base.DataContext as MainViewModel).MainWindowState = SettingsData.Instance.Window.WindowState; } Messenger.Default.Register<GenericMessage<Tuple<UserAccountViewModel, bool>>>(this, ViewModelMessages.SetActiveAccount, delegate(GenericMessage<Tuple<UserAccountViewModel, bool>> o) { bool flag = false; ContentPresenter control = this.accountProfilesList.ItemContainerGenerator.ContainerFromItem(o.Content.Item1) as ContentPresenter; VisualStateManager.GoToState(control, "AccountActive", false); foreach (UserAccountViewModel model in App.AppState.Accounts) { if (model != o.Content.Item1) { ContentPresenter presenter2 = this.accountProfilesList.ItemContainerGenerator.ContainerFromItem(model) as ContentPresenter; VisualStateManager.GoToState(presenter2, "AccountInactive", false); } } DataTemplate contentTemplate = control.ContentTemplate; FrameworkElement element = null; if (control.IsLoaded) { FrameworkElement element2; if (App.AppState.ShowCompactAccountPane) { element2 = contentTemplate.FindName("CompactLayout", control) as FrameworkElement; element = element2.FindName("CompactUserAvatar") as FrameworkElement; } else { element2 = contentTemplate.FindName("FullLayout", control) as FrameworkElement; element = element2.FindName("FullUserAvatar") as FrameworkElement; } } if (element != null) { System.Windows.Point point = this.accountProfilesList.PointFromScreen(element.PointToScreen(new System.Windows.Point(0.0, 0.0))); double top = (point.Y + (element.ActualHeight / 2.0)) - (this.accountArrowIndicator.ActualHeight / 2.0); Thickness thickness = new Thickness(0.0, top, 0.0, 0.0); if (thickness.Top > this.accountArrowIndicator.Margin.Top) { flag = true; } else if (thickness.Top <= this.accountArrowIndicator.Margin.Top) { flag = false; } this.accountArrowIndicator.Margin = thickness; this.AccountsScrollViewer.ScrollToVerticalOffset(point.Y); } if (this.twitViewItems.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated) { if (App.AppState.LastActiveAccount != null) { ContentPresenter templatedParent = this.twitViewItems.ItemContainerGenerator.ContainerFromItem(App.AppState.LastActiveAccount.TwitViewModel) as ContentPresenter; DataTemplate template2 = templatedParent.ContentTemplate; FrameworkElement lastActiveTwitView = template2.FindName("twitViewInstance", templatedParent) as FrameworkElement; lastActiveTwitView.CacheMode = new BitmapCache(); Storyboard storyboard = new Storyboard(); DoubleAnimation animation = new DoubleAnimation { From = 1.0, To = 0.0, Duration = new Duration(TimeSpan.FromMilliseconds(300.0)) }; ExponentialEase ease = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 6.0 }; animation.EasingFunction = ease; storyboard.Children.Add(animation); DoubleAnimation animation2 = new DoubleAnimation { From = 0.0, To = new double?(flag ? ((double)50) : ((double)(-50))), Duration = new Duration(TimeSpan.FromMilliseconds(300.0)) }; ExponentialEase ease2 = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 6.0 }; animation2.EasingFunction = ease2; storyboard.Children.Add(animation2); Storyboard.SetTargetProperty(animation, new PropertyPath("(Opacity)", new object[0])); Storyboard.SetTargetProperty(animation2, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)", new object[0])); App.AppState.LastActiveAccount.TwitViewModel.IsActive = false; storyboard.Completed += (s3, e3) => lastActiveTwitView.CacheMode = null; lastActiveTwitView.BeginStoryboard(storyboard, HandoffBehavior.SnapshotAndReplace); } if (o.Content.Item2) { ContentPresenter presenter4 = this.twitViewItems.ItemContainerGenerator.ContainerFromItem(o.Content.Item1.TwitViewModel) as ContentPresenter; DataTemplate template3 = presenter4.ContentTemplate; FrameworkElement newActiveTwitView = template3.FindName("twitViewInstance", presenter4) as FrameworkElement; o.Content.Item1.TwitViewModel.IsActive = true; newActiveTwitView.CacheMode = new BitmapCache(); Storyboard storyboard2 = new Storyboard(); DoubleAnimation animation3 = new DoubleAnimation { From = 0.0, To = 1.0, Duration = new Duration(TimeSpan.FromMilliseconds(300.0)) }; ExponentialEase ease3 = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 6.0 }; animation3.EasingFunction = ease3; storyboard2.Children.Add(animation3); DoubleAnimation animation4 = new DoubleAnimation { From = new double?(flag ? ((double)(-50)) : ((double)50)), To = 0.0, Duration = new Duration(TimeSpan.FromMilliseconds(300.0)) }; ExponentialEase ease4 = new ExponentialEase { EasingMode = EasingMode.EaseOut, Exponent = 6.0 }; animation4.EasingFunction = ease4; storyboard2.Children.Add(animation4); storyboard2.BeginTime = new TimeSpan?(new TimeSpan(150L)); Storyboard.SetTargetProperty(animation3, new PropertyPath("(Opacity)", new object[0])); Storyboard.SetTargetProperty(animation4, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)", new object[0])); storyboard2.Completed += (s3, e3) => newActiveTwitView.CacheMode = null; newActiveTwitView.BeginStoryboard(storyboard2, HandoffBehavior.SnapshotAndReplace); } foreach (UserAccountViewModel model in App.AppState.Accounts) { if ((model != o.Content.Item1) && model.TwitViewModel.IsActive) { model.TwitViewModel.IsActive = false; } } o.Content.Item1.TwitViewModel.IsActive = true; } else { if (App.AppState.LastActiveAccount != null) { App.AppState.LastActiveAccount.TwitViewModel.IsActive = false; } o.Content.Item1.TwitViewModel.IsActive = true; } }); }
public override void Begin(Action completionAction) { Storyboard = new Storyboard(); double liCounter = 0; var listBoxItems = ListBox.GetVisualDescendants().OfType<ListBoxItem>().Where(lbi => IsOnCurrentPage(lbi) && lbi.IsEnabled).ToList(); if (HoldSelectedItem && Direction == Directions.Out && ListBox.SelectedItem != null) { //move selected container to end var selectedContainer = ListBox.ItemContainerGenerator.ContainerFromItem(ListBox.SelectedItem); listBoxItems.Remove(selectedContainer); listBoxItems.Add(selectedContainer); } foreach (ListBoxItem li in listBoxItems) { GeneralTransform gt = li.TransformToVisual(RootElement); Point globalCoords = gt.Transform(new Point(0, 0)); double heightAdjustment = li.Content is FrameworkElement ? ((li.Content as FrameworkElement).ActualHeight / 2) : (li.ActualHeight / 2); //double yCoord = globalCoords.Y + ((((System.Windows.FrameworkElement)(((System.Windows.Controls.ContentControl)(li)).Content)).ActualHeight) / 2); double yCoord = globalCoords.Y + heightAdjustment; double offsetAmount = (RootElement.ActualHeight / 2) - yCoord; PlaneProjection pp = new PlaneProjection(); pp.GlobalOffsetY = offsetAmount * -1; pp.CenterOfRotationX = 0; li.Projection = pp; CompositeTransform ct = new CompositeTransform(); ct.TranslateY = offsetAmount; li.RenderTransform = ct; var beginTime = TimeSpan.FromMilliseconds((FeatherDelay * liCounter) + InitialDelay); if (Direction == Directions.In) { li.Opacity = 0; DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames(); EasingDoubleKeyFrame edkf1 = new EasingDoubleKeyFrame(); edkf1.KeyTime = beginTime; edkf1.Value = Angle; daukf.KeyFrames.Add(edkf1); EasingDoubleKeyFrame edkf2 = new EasingDoubleKeyFrame(); edkf2.KeyTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime); edkf2.Value = 0; ExponentialEase ee = new ExponentialEase(); ee.EasingMode = EasingMode.EaseOut; ee.Exponent = 6; edkf2.EasingFunction = ee; daukf.KeyFrames.Add(edkf2); Storyboard.SetTarget(daukf, li); Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)")); Storyboard.Children.Add(daukf); DoubleAnimation da = new DoubleAnimation(); da.Duration = TimeSpan.FromMilliseconds(0); da.BeginTime = beginTime; da.To = 1; Storyboard.SetTarget(da, li); Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)")); Storyboard.Children.Add(da); } else { li.Opacity = 1; DoubleAnimation da = new DoubleAnimation(); da.BeginTime = beginTime; da.Duration = TimeSpan.FromMilliseconds(Duration); da.To = Angle; ExponentialEase ee = new ExponentialEase(); ee.EasingMode = EasingMode.EaseIn; ee.Exponent = 6; da.EasingFunction = ee; Storyboard.SetTarget(da, li); Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)")); Storyboard.Children.Add(da); da = new DoubleAnimation(); da.Duration = TimeSpan.FromMilliseconds(10); da.To = 0; da.BeginTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime); Storyboard.SetTarget(da, li); Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)")); Storyboard.Children.Add(da); } liCounter++; } base.Begin(completionAction); }
private Storyboard AnimationForElement(FrameworkElement element, int index) { double delay = 30; double duration = (IsOpen) ? 350 : 250; double from = (IsOpen) ? -45 : 0; double to = (IsOpen) ? 0 : 90; ExponentialEase ee = new ExponentialEase() { EasingMode = (IsOpen) ? EasingMode.EaseOut : EasingMode.EaseIn, Exponent = 5, }; DoubleAnimation anim = new DoubleAnimation() { Duration = new Duration(TimeSpan.FromMilliseconds(duration)), From = from, To = to, EasingFunction = ee, }; Storyboard.SetTarget(anim, element); Storyboard.SetTargetProperty(anim, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationX)")); Storyboard board = new Storyboard(); board.BeginTime = TimeSpan.FromMilliseconds(delay * index); board.Children.Add(anim); return board; }
private void IsExpandedChanged() { if (Children.Count != 2) return; Debug.Assert(SplitRatio >= 0 && SplitRatio <= 1.0); EnsureStoryboardsLoaded(); _translateStoryboard.Stop(); if (IsExpanded) { _translateAnimations[0].From = 0; _translateAnimations[0].To = SplitRatio * ActualHeight; _translateAnimations[1].From = 0; _translateAnimations[1].To = SplitRatio * ActualHeight; EasingFunctionBase ease = new ElasticEase() { EasingMode = EasingMode.EaseOut, Oscillations = 3, Springiness = 7 }; TimeSpan duration = TimeSpan.FromMilliseconds(750); _translateAnimations[0].Duration = duration; _translateAnimations[0].EasingFunction = ease; _translateAnimations[1].Duration = duration; _translateAnimations[1].EasingFunction = ease; } else { _fullyExpanded = false; InvalidateArrange(); UpdateLayout(); _translateAnimations[0].From = SplitRatio * ActualHeight; _translateAnimations[0].To = 0; _translateAnimations[1].From = SplitRatio * ActualHeight; _translateAnimations[1].To = 0; EasingFunctionBase ease = new ExponentialEase() { EasingMode = EasingMode.EaseOut }; TimeSpan duration = TimeSpan.FromMilliseconds(150); _translateAnimations[0].Duration = duration; _translateAnimations[0].EasingFunction = ease; _translateAnimations[1].Duration = duration; _translateAnimations[1].EasingFunction = ease; } _translateStoryboard.Begin(); }
private void InitAnimateWindow() { sb = new Storyboard(); sb.Completed += sb_Completed; DoubleAnimation myDoubleAnimation = new DoubleAnimation(); myDoubleAnimation.Duration = new Duration(new TimeSpan(8000000)); sb.Children.Add(myDoubleAnimation); sb.Duration = new Duration(new TimeSpan(8000000)); Storyboard.SetTarget(myDoubleAnimation, this); Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath("(Window.Left)")); myDoubleAnimation.From = this.Width; myDoubleAnimation.To = 0; ExponentialEase myEaseFunction = new ExponentialEase(); myEaseFunction.EasingMode = EasingMode.EaseOut; myEaseFunction.Exponent = 10; myDoubleAnimation.EasingFunction = myEaseFunction; }
/// <summary> /// Animate the scrolling of the list to the specified item. Scrolling speed is capped by MaximumFlickVelocity. /// </summary> /// <param name="item">The item to scroll to.</param> public void AnimateTo(object item) { EnsureData(); UpdateLayout(); ContentPresenter contentPresenter; int itemIndex = GetResolvedIndex(item, out contentPresenter); if (itemIndex != -1) { // The item we are scrolling to has already been resolved, so we can set up an animation directly // to it. double newPosition = GetCoercedScrollPosition(-Canvas.GetTop(contentPresenter), false); double delta = -newPosition + _panningTransform.Y; double seconds = Math.Abs(delta) / MaximumFlickVelocity; IEasingFunction ease = PhysicsConstants.GetEasingFunction(seconds); if (_scrollingTowards != -1) { _scrollingTowards = -1; // This is the termination of an AnimateTo call where the location was // not know. Use a different ease to keep the animation smooth. ease = new ExponentialEase() { EasingMode = EasingMode.EaseOut }; } IsFlicking = true; AnimatePanel(new Duration(TimeSpan.FromSeconds(seconds)), ease, newPosition); return; } itemIndex = GetFlattenedIndex(item); if (itemIndex != -1) { // Since we don't know the pixel position of the item we are scrolling to, we just go // in a direction, and stop when the item is resolved. _scrollingTowards = itemIndex; ScrollTowards(); } }
/// <summary> /// Occurs when Flash's animation is over /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void flash_Completed(object sender, EventArgs e) { #region Animation Settings Storyboard stb = new Storyboard(); DoubleAnimation heightAnimation = new DoubleAnimation(); ReduceWidthAnimation = new DoubleAnimation(); ExponentialEase ease = new ExponentialEase(); ease.EasingMode = EasingMode.EaseInOut; ease.Exponent = 1.5; heightAnimation.From = SessionVM.SessionSVI.ActualHeight; /*if (SessionVM.Orientation == "left" || SessionVM.Orientation == "right") heightAnimation.To = ((MainDesktop.ActualHeight) / 4.0) / 0.5625;*/ heightAnimation.To = (MainDesktop.ActualHeight) / 4.0; heightAnimation.Duration = new Duration(TimeSpan.FromSeconds(1)); heightAnimation.EasingFunction = ease; heightAnimation.AccelerationRatio = .4; heightAnimation.DecelerationRatio = .1; heightAnimation.FillBehavior = FillBehavior.Stop; stb.Children.Add(heightAnimation); Storyboard.SetTarget(heightAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(heightAnimation, new PropertyPath(ScatterViewItem.HeightProperty)); ReduceWidthAnimation.From = SessionVM.SessionSVI.ActualWidth; /*if (SessionVM.Orientation == "left" || SessionVM.Orientation == "right") ReduceWidthAnimation.To = ((MainDesktop.ActualWidth) / 4.0) / 0.5625;*/ ReduceWidthAnimation.To = (MainDesktop.ActualWidth) / 4.0; ReduceWidthAnimation.Duration = new Duration(TimeSpan.FromSeconds(1)); ReduceWidthAnimation.EasingFunction = ease; ReduceWidthAnimation.AccelerationRatio = .4; ReduceWidthAnimation.DecelerationRatio = .1; ReduceWidthAnimation.FillBehavior = FillBehavior.Stop; stb.Children.Add(ReduceWidthAnimation); Storyboard.SetTarget(ReduceWidthAnimation, SessionVM.SessionSVI); Storyboard.SetTargetProperty(ReduceWidthAnimation, new PropertyPath(ScatterViewItem.WidthProperty)); if (SessionVM.Orientation == "left" || SessionVM.Orientation == "right") { SessionVM.SessionSVI.Height = SessionVM.SessionSVI.ActualHeight / 4.0 / 0.5625; SessionVM.SessionSVI.Width = SessionVM.SessionSVI.ActualWidth / 4.0 / 0.5625; } else { SessionVM.SessionSVI.Height = SessionVM.SessionSVI.ActualHeight / 4.0; SessionVM.SessionSVI.Width = SessionVM.SessionSVI.ActualWidth / 4.0; } #endregion ReduceWidthAnimation.Completed += new EventHandler(stb_Completed); stb.Begin(SessionVM.SessionSVI); }
/// <summary> /// Initializes a new instance of the ListPicker class. /// </summary> public ListPicker() { DefaultStyleKey = typeof(ListPicker); Storyboard.SetTargetProperty(_heightAnimation, new PropertyPath(FrameworkElement.HeightProperty)); Storyboard.SetTargetProperty(_translateAnimation, new PropertyPath(TranslateTransform.YProperty)); // Would be nice if these values were customizable (ex: as DependencyProperties or in Template as VSM states) Duration duration = TimeSpan.FromSeconds(0.2); _heightAnimation.Duration = duration; _translateAnimation.Duration = duration; IEasingFunction easingFunction = new ExponentialEase { EasingMode = EasingMode.EaseInOut, Exponent = 4 }; _heightAnimation.EasingFunction = easingFunction; _translateAnimation.EasingFunction = easingFunction; this.RegisterNotification("IsEnabled", OnIsEnabledChanged); Loaded += OnLoaded; Unloaded += OnUnloaded; }
public static void SlideDown(UIElement elem) { int vremeTrajanjaAnim = 500; DoubleAnimation animacijaTrans = new DoubleAnimation(0, System.Windows.SystemParameters.PrimaryScreenHeight, TimeSpan.FromMilliseconds(vremeTrajanjaAnim)); DoubleAnimation animacijaProv = new DoubleAnimation(1, 0.3, TimeSpan.FromMilliseconds(vremeTrajanjaAnim)); ExponentialEase easing = new ExponentialEase(); easing.EasingMode = EasingMode.EaseIn; easing.Exponent = 8; animacijaTrans.EasingFunction = easing; animacijaProv.EasingFunction = easing; animacijaTrans.Completed += (o, eventArg) => { if (elem is TastaturaXAML) { (elem as TastaturaXAML).Close(); } if (elem is Page) { (elem as Page).NavigationService.GoBack(); } }; TranslateTransform translacija = new TranslateTransform(); elem.RenderTransformOrigin = new Point(System.Windows.SystemParameters.PrimaryScreenHeight, 0); elem.RenderTransform = translacija; translacija.BeginAnimation(TranslateTransform.YProperty, animacijaTrans); if(elem is UIElement) elem.BeginAnimation(UIElement.OpacityProperty, animacijaProv); if (elem is Page) elem.BeginAnimation(Page.OpacityProperty, animacijaProv); }