public void TurnPage(int nAnimationDuration) { this.SetValue(BookPage.StatusPropertyKey, (object)PageStatus.TurnAnimation); this.CornerPoint = this.m_ptCornerPoint; this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)null); Point toValue = this.OriginToOppositePoint(this.m_refCornerOrigin); if (this.m_refAnimation != null) { this.m_refAnimation.CurrentTimeInvalidated -= new EventHandler(this.OnAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated -= new EventHandler(this.OnAnimationCurrentStateInvalidated); } this.m_refAnimation = (PointAnimationBase)new PointAnimation(toValue, new Duration(TimeSpan.FromMilliseconds((double)nAnimationDuration))); this.m_refAnimation.AccelerationRatio = 0.6; this.m_refAnimation.CurrentTimeInvalidated += new EventHandler(this.OnAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated += new EventHandler(this.OnAnimationCurrentStateInvalidated); this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)this.m_refAnimation); }
public void TurnPageFromCorner(CornerOrigin refStarterCornerOrigin, int nAnimationDuration) { if (this.Status != PageStatus.Idle) return; this.SetValue(BookPage.StatusPropertyKey, (object)PageStatus.TurnAnimation); this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)null); this.DisableManipulation(); Point point1 = this.OriginToPoint(refStarterCornerOrigin); if (refStarterCornerOrigin == CornerOrigin.BottomRight || refStarterCornerOrigin == CornerOrigin.BottomLeft) point1.Y -= BookPage.s_dOFFSET_TO_AVOID_GLITCH; Point point3 = this.OriginToOppositePoint(refStarterCornerOrigin); this.m_ptCornerPoint = this.CornerPoint = point1; this.m_refCornerOrigin = refStarterCornerOrigin; BezierSegment bezierSegment = new BezierSegment(point1, new Point(point3.X + (point1.X - point3.X) / 3.0, 250.0), point3, true); PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(new PathFigure() { StartPoint = point1, Segments = { (PathSegment) bezierSegment }, IsClosed = false }); if (this.m_refAnimation != null) { this.m_refAnimation.CurrentTimeInvalidated -= new EventHandler(this.OnAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated -= new EventHandler(this.OnAnimationCurrentStateInvalidated); } this.m_refAnimation = (PointAnimationBase)new PointAnimationUsingPath(); (this.m_refAnimation as PointAnimationUsingPath).PathGeometry = pathGeometry; this.m_refAnimation.Duration = new Duration(TimeSpan.FromMilliseconds((double)nAnimationDuration)); this.m_refAnimation.AccelerationRatio = 0.6; this.m_refAnimation.CurrentTimeInvalidated += new EventHandler(this.OnAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated += new EventHandler(this.OnAnimationCurrentStateInvalidated); this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)this.m_refAnimation); }
public void ExecuteIdleAnimation(int corner) { Path path = (Path)null; switch (corner) { case 1: if (this.IsRightPage) { path = this.m_refPART_IdleAnimationPathTopRight; this.m_refCornerOrigin = CornerOrigin.TopRight; break; } else { path = this.m_refPART_IdleAnimationPathTopLeft; this.m_refCornerOrigin = CornerOrigin.TopLeft; break; } case 2: if (this.IsRightPage) { path = this.m_refPART_IdleAnimationPathBottomRight; this.m_refCornerOrigin = CornerOrigin.BottomRight; break; } else { path = this.m_refPART_IdleAnimationPathBottomLeft; this.m_refCornerOrigin = CornerOrigin.BottomLeft; break; } } if (this.Status != PageStatus.Idle || path == null) return; Geometry renderedGeometry = path.RenderedGeometry; if (renderedGeometry == null) return; if (this.m_refPART_ShadowCanvas != null) this.m_refPART_ShadowCanvas.Visibility = Visibility.Visible; if (this.m_refPART_ReflectionCanvas != null) this.m_refPART_ReflectionCanvas.Visibility = Visibility.Visible; this.m_ptCornerPoint = this.CornerPoint = this.OriginToPoint(this.m_refCornerOrigin); PageParameters? page = BookPageComputeHelper.ComputePage(this, this.m_ptCornerPoint, this.m_refCornerOrigin); if (page.HasValue) this.ApplyParameters(page.Value); this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)null); if (this.m_refAnimation != null) { this.m_refAnimation.CurrentTimeInvalidated -= new EventHandler(this.OnAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated -= new EventHandler(this.OnAnimationCurrentStateInvalidated); } this.m_refAnimation = (PointAnimationBase)new PointAnimationUsingPath(); this.m_refAnimation.AccelerationRatio = 0.1; this.m_refAnimation.DecelerationRatio = 0.9; this.m_refAnimation.Duration = (Duration)TimeSpan.FromMilliseconds((double)BookPage.s_nIDLE_ANIMATION_DURATION); PathGeometry pathGeometry = new PathGeometry((IEnumerable<PathFigure>)PathFigureCollection.Parse(new GeometryValueSerializer().ConvertToString((object)renderedGeometry, (IValueSerializerContext)null))); pathGeometry.Transform = (Transform)this.TransformToVisual((Visual)path).Inverse; pathGeometry.Freeze(); (this.m_refAnimation as PointAnimationUsingPath).PathGeometry = pathGeometry; this.m_refAnimation.CurrentTimeInvalidated += new EventHandler(this.OnIdleAnimationCurrentTimeInvalidated); this.m_refAnimation.CurrentStateInvalidated += new EventHandler(this.OnIdleAnimationCurrentStateInvalidated); this.BeginAnimation(BookPage.CornerPointProperty, (AnimationTimeline)this.m_refAnimation); }