Пример #1
2
 /// <summary/>
 protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    var duration = TimeSpan.Zero;
    if (_hasCenterDifference) {
       var timeline = new VectorInterpolation(Interpolator, FromCenter, ToCenter, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    var fromX = _getValue(From, FromScaleX);
    var toX = _getValue(To, ToScaleX);
    if (fromX.CertainlyDifferent(toX)) {
       var timeline = new DoubleInterpolation(Interpolator, fromX, toX, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    var fromY = _getValue(From, FromScaleY);
    var toY = _getValue(To, ToScaleY);
    if (fromY.CertainlyDifferent(toY)) {
       var timeline = new DoubleInterpolation(Interpolator, fromY, toY, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    return duration;
 }
Пример #2
1
      /// <summary>Creates a new <see cref="EffectController"/> instance.</summary>
      internal EffectController(Effect effect, EffectCallback effectCallback) {
         SourceEffect = effect;
         SourceEffect.Validate();
         RuntimeEffect = SourceEffect.Decompose();
         State  = EffectState.Playing;

         _rootTimeline = new ParallelTimeline();
         RuntimeEffect.DefineTimeline(_rootTimeline, TimeSpan.Zero);
         if (!GlobalSpeedRatio.IsOne()) {
            _rootTimeline.SpeedRatio = GlobalSpeedRatio;
         }
         _rootTimeline.CurrentStateInvalidated += _rootClockStateChanged;
         _rootTimeline.Completed += _rootClockCompleted;
         _effectCallback = effectCallback;

         _rootClock = _rootTimeline.CreateClock();
         var count = RuntimeEffect.ApplyClocks(_rootClock, 0);
         if (count > 0) {
            _rootClock.Controller.Begin();
         } else {
            State = EffectState.Completed;
            _rootClock.Controller.Remove();
            if (effectCallback != null) {
               GuiTimer.StartAfterRender(t => effectCallback(this));
            }
         }
      }
Пример #3
1
 public ReusableFollowTracker()
 {
     _timeline = new ParallelTimeline(null, Duration.Forever);
     _timeClock = _timeline.CreateClock();
     _timeClock.Controller?.Begin();
     _lastTime = TimeSpan.FromSeconds(0);
 }
Пример #4
1
      /// <summary/>
      protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
         var timeline = new DoubleAnimation();
         var trigger  = new ActionTrigger(Action);
         timeline.CurrentTimeInvalidated += (sender, e) => trigger.Tick((Clock)sender);

         parentTimeline.Children.Add(timeline);
         return DefineTimelineCore(timeline, parentOffset);
      }
Пример #5
1
 /// <summary/>
 protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    var duration = TimeSpan.Zero;
    if (_hasRectDifference) {
       var timeline = new RectInterpolation(Interpolator, From, To, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    return duration;
 }
Пример #6
1
      /// <summary/>
      protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
         var timeline = new ParallelTimeline();
         parentTimeline.Children.Add(timeline);

         var totalDuration = TimeSpan.Zero;
         foreach (var childEffect in Children) {
            var childDuration = childEffect.DefineTimeline(timeline, totalDuration);
            totalDuration += childDuration;
         }

         return DefineTimelineCore(timeline, parentOffset, totalDuration);
      }
Пример #7
1
 /// <summary/>
 protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    var duration = TimeSpan.Zero;
    if (_hasValueDifference) {
       Timeline timeline = null;
       if (Property.PropertyType.IsA(typeof(double))) {
          timeline = new DoubleInterpolation(Interpolator, From, To, IsRelative, IsCumulative);
       } else if (Property.PropertyType.IsA(typeof(int))) {
          timeline = new Int32Interpolation(Interpolator, (int?)From, (int?)To, IsRelative, IsCumulative);
       }
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    return duration;
 }
Пример #8
1
      /// <summary/>
      protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
         var timeline = new DoubleAnimation();
         var trigger  = new PropertyTrigger((DependencyObject)Target, Property, Values);
         timeline.CurrentTimeInvalidated += (sender, e) => trigger.Tick((Clock)sender);

         parentTimeline.Children.Add(timeline);
         if (!RepeatCount.HasValue) {
            RepeatCount = Values.Length;
            var totalDuration = DefineTimelineCore(timeline, parentOffset);
            RepeatCount = null;
            return totalDuration;
         } else {
            return DefineTimelineCore(timeline, parentOffset);
         }
      }
Пример #9
1
 /// <summary>
 /// Creates a time manager object in the stopped state.
 /// </summary>
 /// <param name="clock">
 /// An interface to an object that provides real-time clock values to the time
 /// manager. The manager will query this interface whenever it needs to know the
 /// current time. This parameter may be null.
 /// </param>
 /// <remarks>
 /// If the clock parameter is null, the time manager uses a default system clock
 /// to drive the timing engine. To start the clock moving, call the
 /// <see cref="TimeManager.Start"/> method.
 /// </remarks>
 public TimeManager(IClock clock)
 {
     _eventQueue = new Queue<WeakReference>();
     Clock = clock;
     _timeState = TimeState.Stopped;
     _lastTimeState = TimeState.Stopped;
     _globalTime = new TimeSpan(-1);
     _lastTickTime = new TimeSpan(-1);
     _nextTickTimeQueried = false;
     _isInTick = false;
     ParallelTimeline timeManagerTimeline = new ParallelTimeline(new TimeSpan(0), Duration.Forever);
     timeManagerTimeline.Freeze();
     _timeManagerClock = new ClockGroup(timeManagerTimeline);
     _timeManagerClock.MakeRoot(this);
 }
Пример #10
1
 public ParallelTimelineClock(ParallelTimeline parallelTimeline, IEnumerable<TimelineClock> children)
     : base(new ParallelClock(children), parallelTimeline, children)
 {
     //
 }
Пример #11
1
        /// <summary>
        /// Starts the particle running or restarts the particle if it has expired
        /// </summary>
        /// <param name="rerun"></param>
        private void Run(bool rerun)
        {
            // only init the particle if it hasn't been run yet
            if (!rerun)
            {
                NameScope.SetNameScope(this, new NameScope());
                this.Name = String.Format("p{0}", Particle.ParticleNo++);
                this.RegisterName(this.Name, this);
                this.Width = ParticleSystem.random.NextDouble(Owner.MinParticleWidth, Owner.MaxParticleWidth);
                this.Height = ParticleSystem.random.NextDouble(Owner.MinParticleHeight, Owner.MaxParticleHeight);
                this.particleSolidColorBrush = new SolidColorBrush(Colors.White);
                this.RegisterName(String.Format("{0}Brush", this.Name), particleSolidColorBrush);
                this.Background = particleSolidColorBrush;
            }

            // create the storyboard for this particle and hold its end behavior
            mStoryboard = new Storyboard();
            mStoryboard.FillBehavior = FillBehavior.HoldEnd; 

            // create a parallel timeline for the the opacity and background changes.
            ParallelTimeline pt = new ParallelTimeline(TimeSpan.FromSeconds(0));

            // the timeline for the opacity change using the particle Start and End Opacity
            DoubleAnimation daOpacity = new DoubleAnimation(StartOpacity, EndOpacity, 
                                                            new Duration(TimeSpan.FromSeconds(this.LifeSpan)));
            Storyboard.SetTargetName(daOpacity, this.Name);
            Storyboard.SetTargetProperty(daOpacity, new PropertyPath(Particle.OpacityProperty));

            // the timeline for the background color change using a colorkeyframecollection
            ColorAnimationUsingKeyFrames daBackground = new ColorAnimationUsingKeyFrames();
            daBackground.Duration = new Duration(TimeSpan.FromSeconds(this.LifeSpan));
            daBackground.KeyFrames = BackgroundColors;
            Storyboard.SetTargetName(daBackground, String.Format("{0}Brush", this.Name));
            Storyboard.SetTargetProperty(daBackground, new PropertyPath(SolidColorBrush.ColorProperty));
            pt.Children.Add(daOpacity);
            pt.Children.Add(daBackground);
            mStoryboard.Children.Add(pt);

            // the first time this is run begin the storyboard on load.
            if (!rerun)
            {
                this.Loaded += delegate(object sender, RoutedEventArgs args)
                                   {
                                       mStoryboard.Begin(this, true);
                                   };
            }            
                        
            mIsAlive = true;
        }
Пример #12
1
 /// <summary/>
 protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    var duration = TimeSpan.Zero;
    var fromW = _getWidth(From, FromWidth);
    var toW = _getWidth(To, ToWidth);
    if (fromW.CertainlyDifferent(toW)) {
       var timeline = new DoubleInterpolation(Interpolator, fromW, toW, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    var fromH = _getHeight(From, FromHeight);
    var toH = _getHeight(To, ToHeight);
    if (fromH.CertainlyDifferent(toH)) {
       var timeline = new DoubleInterpolation(Interpolator, fromH, toH, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    return duration;
 }
Пример #13
1
        public void AnimateShift(double deltaX, double deltaY, Action<SquareItem> action)
        {
            DoubleAnimation shiftX = new DoubleAnimation();
            shiftX.From = 0;
            shiftX.To = deltaX;
            shiftX.Duration = new Duration(TimeSpan.FromSeconds(0.6));

            DoubleAnimation shiftY = new DoubleAnimation();
            shiftY.From = 0;
            shiftY.To = deltaY;
            shiftY.Duration = shiftX.Duration;

            ParallelTimeline timeline = new ParallelTimeline();
            timeline.Children.Add(shiftX);
            timeline.Children.Add(shiftY);

            Storyboard storyboard = new Storyboard();
            storyboard.Children.Add(timeline);

            Storyboard.SetTarget(shiftX, this);
            Storyboard.SetTarget(shiftY, this);

            Storyboard.SetTargetProperty(shiftX, new PropertyPath("DeltaXTransform"));
            Storyboard.SetTargetProperty(shiftY, new PropertyPath("DeltaYTransform"));

            storyboard.Completed += new EventHandler((sender, e) => action(this));

            storyboard.Begin();
        }
Пример #14
1
 /// <summary/>
 protected internal override TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    var duration = TimeSpan.Zero;
    if (_hasCenterDifference) {
       var timeline = new VectorInterpolation(Interpolator, FromCenter, ToCenter, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    if (_hasSkewXDifference) {
       var timeline = new DoubleInterpolation(Interpolator, FromSkewX, ToSkewX, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    if (_hasSkewYDifference) {
       var timeline = new DoubleInterpolation(Interpolator, FromSkewY, ToSkewY, IsRelative, IsCumulative);
       parentTimeline.Children.Add(timeline);
       duration = DefineTimelineCore(timeline, parentOffset);
    }
    return duration;
 }
Пример #15
1
        public TraditionalClock()
        {
            //http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard.aspx
            // Create a name scope for the window.
            NameScope.SetNameScope(this, new NameScope());

            this.Name = "clockWindow";
            this.AllowsTransparency=true;
            this.Background=Brushes.Transparent;
            this.WindowStyle=WindowStyle.None;
            this.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.LeftButtonDown);

            //this.RegisterName(this.Name, this);

            Storyboard clockHandStoryboard = new Storyboard();

            //// create the parallel timeline which contains the clockhand animations
            ParallelTimeline pt = new ParallelTimeline(TimeSpan.FromSeconds(0));

            //<DoubleAnimation From="-9" To="351" Duration="00:01:00" RepeatBehavior="Forever"
            //                    Storyboard.TargetProperty="Angle" Storyboard.TargetName="secondHandAngle"/>
            DoubleAnimation secondHandAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(0, 1, 0)));
            Storyboard.SetTargetName(secondHandAnimation, "secondHandAngle");
            Storyboard.SetTargetProperty(secondHandAnimation, new PropertyPath(RotateTransform.AngleProperty));
            secondHandAnimation.RepeatBehavior = RepeatBehavior.Forever;

            //<DoubleAnimation From="-9" To="351" Duration="12:00:00" RepeatBehavior="Forever"
            //                    Storyboard.TargetProperty="Angle" Storyboard.TargetName="hourHandAngle" />
            DoubleAnimation hourHandAngleAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(12, 0, 0)));
            Storyboard.SetTargetName(hourHandAngleAnimation, "hourHandAngle");
            Storyboard.SetTargetProperty(hourHandAngleAnimation, new PropertyPath(RotateTransform.AngleProperty));
            hourHandAngleAnimation.RepeatBehavior = RepeatBehavior.Forever;

            //<DoubleAnimation From="-9" To="351" Duration="01:00:00" RepeatBehavior="Forever"
            //                    Storyboard.TargetProperty="Angle" Storyboard.TargetName="minuteHandAnimation" />
            DoubleAnimation minuteHandAnimation = new DoubleAnimation(-9, 351, new Duration(new TimeSpan(1, 0, 0)));
            Storyboard.SetTargetName(minuteHandAnimation, "minuteHandAngle");
            Storyboard.SetTargetProperty(minuteHandAnimation, new PropertyPath(RotateTransform.AngleProperty));
            minuteHandAnimation.RepeatBehavior = RepeatBehavior.Forever;

            //// add the animations to the timeline
            pt.Children.Add(secondHandAnimation);
            pt.Children.Add(hourHandAngleAnimation);
            pt.Children.Add(minuteHandAnimation);

            //// add the timeline to the storyboard
            clockHandStoryboard.Children.Add(pt);

            this.Resources.Add("clockHandStoryboard", clockHandStoryboard);
            this.RegisterName("clockHandStoryboard", clockHandStoryboard);

            ////<Canvas Name="clockCanvas" Width="292" Height="493"  >
            clockCanvas.Name = "clockCanvas";
            clockCanvas.Width = 292;
            clockCanvas.Height = 493;

            //<EventTrigger RoutedEvent="Canvas.Loaded">
            EventTrigger canvasTrigger = new EventTrigger();
            canvasTrigger.RoutedEvent = Canvas.LoadedEvent;

            //<BeginStoryboard Name ="clockHandStoryboard" Storyboard="{StaticResource clockHandStoryboard}" />
            BeginStoryboard beginStory = new BeginStoryboard();
            beginStory.Name = "clockHandStoryboard";
            beginStory.Storyboard = clockHandStoryboard;

            canvasTrigger.Actions.Add(beginStory);
            clockCanvas.Triggers.Add(canvasTrigger);

            /** Clock Hands */
            //<Image Source="TradClock.png" Loaded="SetTime" />
            Image tradClock = new Image();
            BitmapImage bi3 = new BitmapImage();
            bi3.BeginInit();
            bi3.UriSource = new Uri("TradClock.png", UriKind.Relative);
            bi3.EndInit();
            tradClock.Source = bi3;
            tradClock.Loaded += new RoutedEventHandler(this.SetTime);
            clockCanvas.Children.Add(tradClock);

            //<Polygon Name="hourHand" Canvas.Top="214" Canvas.Left="173"	Points="0,5 3,0 4,0 8,5 8,50 0,50">
            Polygon hourHand = new Polygon();
            //http://msdn.microsoft.com/en-us/library/system.windows.shapes.polygon.points.aspx
            Point hPoint1 = new Point(0, 5);
            Point hPoint2 = new Point(3, 0);
            Point hPoint3 = new Point(4, 0);
            Point hPoint4 = new Point(8, 5);
            Point hPoint5 = new Point(8, 50);
            Point hPoint6 = new Point(0, 50);
            PointCollection myPointCollection = new PointCollection();
            myPointCollection.Add(hPoint1);
            myPointCollection.Add(hPoint2);
            myPointCollection.Add(hPoint3);
            myPointCollection.Add(hPoint4);
            myPointCollection.Add(hPoint5);
            myPointCollection.Add(hPoint6);
            hourHand.Points = myPointCollection;
            //<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
            //http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.fill.aspx
            LinearGradientBrush hourHandBrush = new LinearGradientBrush();
            hourHandBrush.StartPoint = new Point(0, 0);
            hourHandBrush.EndPoint = new Point(1, 0);
            //<LinearGradientBrush.GradientStops>
            //<GradientStop Offset="0" Color="White" />
            //<GradientStop Offset="1" Color="DarkGray" />
            //http://msdn.microsoft.com/en-us/library/system.windows.media.lineargradientbrush.aspx
            hourHandBrush.GradientStops.Add(new GradientStop(Colors.White, 0));
            hourHandBrush.GradientStops.Add(new GradientStop(Colors.DarkGray, 1));
            hourHand.Fill = hourHandBrush;
            hourHand.Name = "hourHand";
            //<Polygon.RenderTransform>
            //<RotateTransform x:Name="hourHandAngle" CenterX="4" CenterY="45" />
            //http://msdn.microsoft.com/en-us/library/ms752357.aspx
            RotateTransform hourHandAngle = new RotateTransform();
            this.RegisterName("hourHandAngle", hourHandAngle);
            hourHandAngle.CenterX = 4;
            hourHandAngle.CenterY = 45;
            hourHand.RenderTransform = hourHandAngle;
            //http://msdn.microsoft.com/en-us/library/system.windows.controls.canvas.top.aspx
            Canvas.SetTop(hourHand, 214);
            Canvas.SetLeft(hourHand, 173);
            clockCanvas.Children.Add(hourHand);

            //<Polygon Name="minuteHand" Canvas.Top="183" Canvas.Left="173"	Points="0,5 1,0 2,0 4,5 4,80 0,80">
            Polygon minuteHand = new Polygon();
            Point mPoint1 = new Point(0, 5);
            Point mPoint2 = new Point(1, 0);
            Point mPoint3 = new Point(2, 0);
            Point mPoint4 = new Point(4, 5);
            Point mPoint5 = new Point(4, 80);
            Point mPoint6 = new Point(0, 80);
            PointCollection myPointCollection2 = new PointCollection();
            myPointCollection2.Add(mPoint1);
            myPointCollection2.Add(mPoint2);
            myPointCollection2.Add(mPoint3);
            myPointCollection2.Add(mPoint4);
            myPointCollection2.Add(mPoint5);
            myPointCollection2.Add(mPoint6);
            minuteHand.Points = myPointCollection2;
            minuteHand.Fill = hourHandBrush;
            minuteHand.Name = "minuteHand";
            //<RotateTransform x:Name="minuteHandAnimation" CenterX="2" CenterY="75"/>
            RotateTransform minuteHandAngle = new RotateTransform();
            this.RegisterName("minuteHandAngle", minuteHandAngle);
            minuteHandAngle.CenterX = 2;
            minuteHandAngle.CenterY = 75;
            minuteHand.RenderTransform = minuteHandAngle;

            Canvas.SetTop(minuteHand, 183);
            Canvas.SetLeft(minuteHand, 173);
            clockCanvas.Children.Add(minuteHand);

            //<Polygon Name="secondHand" Canvas.Top="170" Canvas.Left="175" Points="0,0 2,0 2,95 0,95" >
            Polygon secondHand = new Polygon();
            Point sPoint1 = new Point(0, 0);
            Point sPoint2 = new Point(2, 0);
            Point sPoint3 = new Point(2, 95);
            Point sPoint4 = new Point(0, 95);
            PointCollection myPointCollection3 = new PointCollection();
            myPointCollection3.Add(sPoint1);
            myPointCollection3.Add(sPoint2);
            myPointCollection3.Add(sPoint3);
            myPointCollection3.Add(sPoint4);
            secondHand.Points = myPointCollection3;
            secondHand.Fill = hourHandBrush;
            secondHand.Name = "minuteHand";
            //<RotateTransform x:Name="secondHandAngle" CenterX="0" CenterY="90"/>
            RotateTransform secondHandAngle = new RotateTransform();
            this.RegisterName("secondHandAngle", secondHandAngle);
            secondHandAngle.CenterX = 0;
            secondHandAngle.CenterY = 90;
            secondHand.RenderTransform = secondHandAngle;

            Canvas.SetTop(secondHand, 170);
            Canvas.SetLeft(secondHand, 175);
            clockCanvas.Children.Add(secondHand);

            //<!--Center circles-->
            //<Ellipse Canvas.Top="248" Canvas.Left="168" Width="18" Height="20" Stroke="DarkGray">
            Ellipse outerEllipse = new Ellipse();
            Canvas.SetTop(outerEllipse, 248);
            Canvas.SetLeft(outerEllipse, 168);
            outerEllipse.Width = 18;
            outerEllipse.Height = 20;
            outerEllipse.Stroke = Brushes.DarkGray;
            //<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            LinearGradientBrush outerEllipseBrush = new LinearGradientBrush();
            outerEllipseBrush.StartPoint = new Point(0, 0);
            outerEllipseBrush.EndPoint = new Point(1, 0);
            //<LinearGradientBrush.GradientStops>
            //<GradientStop Offset="0" Color="LightCoral"/>
            //<GradientStop Offset="1" Color="Red"/>
            outerEllipseBrush.GradientStops.Add(new GradientStop(Colors.LightCoral, 0));
            outerEllipseBrush.GradientStops.Add(new GradientStop(Colors.Red, 1));
            outerEllipse.Fill = outerEllipseBrush;
            clockCanvas.Children.Add(outerEllipse);

            //<Ellipse Canvas.Top="254" Canvas.Left="174" Width="6" Height="8" Fill="DarkGray" Stroke="Black"  />
            Ellipse innerEllipse = new Ellipse();
            Canvas.SetTop(innerEllipse, 254);
            Canvas.SetLeft(innerEllipse, 174);
            innerEllipse.Width = 6;
            innerEllipse.Height = 8;
            innerEllipse.Fill = Brushes.DarkGray;
            innerEllipse.Stroke = Brushes.Black;
            clockCanvas.Children.Add(innerEllipse);

            this.Content = clockCanvas;
        }
Пример #16
1
        public void BeginAnimation(FrameworkElement element)
        {
            rower.GotoCatch(TheData.Edgevalues);

            sb = new Storyboard();

            ParallelTimeline animationTimeline = new ParallelTimeline();

            DoubleAnimation time = new DoubleAnimation(0, TheData.Timing.TotalTime, new Duration(TimeSpan.FromSeconds(TheData.Timing.TotalTime)));
            time.BeginTime = TimeSpan.FromSeconds(0.0);
            Storyboard.SetTargetName(time, "rower1");
            Storyboard.SetTargetProperty(time, new PropertyPath("Time"));
            animationTimeline.Children.Add(time);

            driveTime = new ParallelTimeline();
            foreach (Segment segment in TheData.StrokeSegments)
            {
                DoubleAnimation stroke = new DoubleAnimation(segment.From, segment.To, new Duration(TimeSpan.FromSeconds(segment.Duration)));
                stroke.BeginTime = TimeSpan.FromSeconds(segment.T0);
                stroke.AccelerationRatio = segment.AccelerationRatio;
                if (segment.AccelerationRatio + segment.DecelerationRatio > 1)
                {
                    stroke.DecelerationRatio = 1 - stroke.AccelerationRatio;
                }
                else
                {
                    stroke.DecelerationRatio = segment.DecelerationRatio;
                }
                Storyboard.SetTargetName(stroke, "rower1");
                Storyboard.SetTargetProperty(stroke, segment.Parameter.Property);
                driveTime.Children.Add(stroke);
            }
            driveTime.Duration = TimeSpan.FromSeconds(TheData.Timing.DriveTime);
            animationTimeline.Children.Add(driveTime);

            ParallelTimeline releaseTime = new ParallelTimeline();
            releaseTime.BeginTime = TimeSpan.FromSeconds(TheData.Timing.DriveTime);
            releaseTime.Duration = TimeSpan.FromSeconds(TheData.Timing.RecoverTime);
            foreach (Segment segment in TheData.RecoverSegments)
            {
                DoubleAnimation stroke = new DoubleAnimation(segment.From, segment.To, new Duration(TimeSpan.FromSeconds(segment.Duration)));
                stroke.BeginTime = TimeSpan.FromSeconds(segment.T0);
                stroke.AccelerationRatio = segment.AccelerationRatio;
                if (segment.AccelerationRatio + segment.DecelerationRatio > 1)
                {
                    stroke.DecelerationRatio = 1 - stroke.AccelerationRatio;
                }
                else
                {
                    stroke.DecelerationRatio = segment.DecelerationRatio;
                }
                releaseTime.Children.Add(stroke);
                Storyboard.SetTargetName(stroke, "rower1");
                Storyboard.SetTargetProperty(stroke, segment.Parameter.Property);
            }
            animationTimeline.Children.Add(releaseTime);
            animationTimeline.RepeatBehavior = AutoRepeat ? RepeatBehavior.Forever : new RepeatBehavior(1);
            try
            {
                sb.SpeedRatio = SpeedRatio;
            }
            catch (Exception)
            {
                // When SpeedRatio is not yet set we take the default of sb
            }
            sb.Children.Add(animationTimeline);
            sb.Completed += new EventHandler(storyboard_CurrentTimeInvalidated);
            sb.Begin(element, true);
        }
Пример #17
1
 /// <summary>Override this method to add the animations required for implementing this effect to the parent timeline.</summary>
 /// <param name="parentTimeline">The parent timeline to which the animations will be added.</param>
 /// <param name="parentOffset">The current offset into the parent timeline.</param>
 /// <returns>The total duration required for all the animations that were added by this method.</returns>
 protected internal virtual TimeSpan DefineTimeline(ParallelTimeline parentTimeline, TimeSpan parentOffset) {
    return TimeSpan.Zero;
 }
Пример #18
0
        /// <summary>
        /// Creates a time manager object in the stopped state.
        /// </summary>
        /// <param name="clock">
        /// An interface to an object that provides real-time clock values to the time
        /// manager. The manager will query this interface whenever it needs to know the
        /// current time. This parameter may be null.
        /// </param>
        /// <remarks>
        /// If the clock parameter is null, the time manager uses a default system clock
        /// to drive the timing engine. To start the clock moving, call the
        /// <see cref="TimeManager.Start"/> method.
        /// </remarks>
        public TimeManager(IClock clock)
        {
            _eventQueue          = new Queue <WeakReference>();
            Clock                = clock;
            _timeState           = TimeState.Stopped;
            _lastTimeState       = TimeState.Stopped;
            _globalTime          = new TimeSpan(-1);
            _lastTickTime        = new TimeSpan(-1);
            _nextTickTimeQueried = false;
            _isInTick            = false;
            ParallelTimeline timeManagerTimeline = new ParallelTimeline(new TimeSpan(0), Duration.Forever);

            timeManagerTimeline.Freeze();
            _timeManagerClock = new ClockGroup(timeManagerTimeline);
            _timeManagerClock.MakeRoot(this);
        }
Пример #19
0
 public ParallelTimelineClock(ParallelTimeline parallelTimeline, IEnumerable <TimelineClock> children) :
     base(new ParallelClock(children), parallelTimeline, children)
 {
     //
 }