Duration ParallelTimeline::GetNaturalDurationCore (Clock *clock) { TimelineCollection *collection = GetChildren (); Duration d = Duration::Automatic; TimeSpan duration_span = 0; Timeline *timeline; int count = collection->GetCount (); if (count == 0) return Duration::FromSeconds (0); for (int i = 0; i < count; i++) { timeline = collection->GetValueAt (i)->AsTimeline (); Duration duration = timeline->GetNaturalDuration (clock); if (duration.IsAutomatic()) continue; if (duration.IsForever()) return Duration::Forever; TimeSpan span = duration.GetTimeSpan (); RepeatBehavior *repeat = timeline->GetRepeatBehavior (); if (repeat->IsForever()) return Duration::Forever; if (repeat->HasCount ()) span = (TimeSpan) (span * repeat->GetCount ()); if (timeline->GetAutoReverse ()) span *= 2; // If we have duration-base repeat behavior, // clamp/up our span to that. if (repeat->HasDuration ()) span = repeat->GetDuration (); if (span != 0) span = (TimeSpan)(span / timeline->GetSpeedRatio()); span += timeline->GetBeginTime (); if (duration_span <= span) { duration_span = span; d = Duration (duration_span); } } return d; }
void Clock::CalculateFillTime () { if (GetNaturalDuration().HasTimeSpan()) { RepeatBehavior *repeat = timeline->GetRepeatBehavior (); if (repeat->HasDuration ()) { fillTime = (repeat->GetDuration() * timeline->GetSpeedRatio ()); } else if (repeat->HasCount ()) { fillTime = repeat->GetCount() * GetNaturalDuration().GetTimeSpan() * (timeline->GetAutoReverse() ? 2 : 1); } else { fillTime = GetNaturalDuration().GetTimeSpan() * (timeline->GetAutoReverse() ? 2 : 1); } } }