public override void Initialize(InitializeParameters p) { if (EnableTrace) { this.trace = new List <Tuple <double, double> >(2048); } if (!string.IsNullOrEmpty(this.From)) { // Use the From/To properties this.CreateSubcomponents(); this.Subcomponents.Add(new XKeyFrame() { Time = "0", Value = this.From, Smoothing = this.Smoothing }); this.Subcomponents.Add(new XKeyFrame() { Time = this.Duration, Value = this.To, Smoothing = this.Smoothing }); } base.Initialize(p); PerfMon.Start("Other-Ani"); // get targets GenerateTargets(); startValues = new List <double?>(new double?[targets.Count]); // collect keyFrames and check for consistency keyFrames = this.GetComponents <XKeyFrame>().ToList(); if (keyFrames.Any(k => k.CurveKeys.Count != targets.Count)) { throw new InvalidOperationException("Number of values in key frames must match number of targets."); } if (keyFrames.Count < 2) { throw new InvalidOperationException("Number of key frames must be 2 or more."); } lastFrame = keyFrames[keyFrames.Count - 1]; // create curves curves = new List <TimeCurve>(targets.Count); for (int i = 0; i < targets.Count; i++) { var curve = new TimeCurve(); curve.PostLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; curve.PreLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; for (int j = 0; j < keyFrames.Count; j++) { curve.Keys.Add(keyFrames[j].CurveKeys[i]); } curves.Add(curve); } PerfMon.Stop("Other-Ani"); }
public override void Initialize(InitializeParameters p) { if (EnableTrace) this.trace = new List<Tuple<double, double>>(2048); if (!string.IsNullOrEmpty(this.From)) { // Use the From/To properties this.CreateSubcomponents(); this.Subcomponents.Add(new XKeyFrame() { Time = "0", Value = this.From, Smoothing = this.Smoothing }); this.Subcomponents.Add(new XKeyFrame() { Time = this.Duration, Value = this.To, Smoothing = this.Smoothing }); } base.Initialize(p); PerfMon.Start("Other-Ani"); // get targets GenerateTargets(); startValues = new List<double?>(new double?[targets.Count]); // collect keyFrames and check for consistency keyFrames = this.GetComponents<XKeyFrame>().ToList(); if (keyFrames.Any(k => k.CurveKeys.Count != targets.Count)) throw new InvalidOperationException("Number of values in key frames must match number of targets."); if (keyFrames.Count < 2) throw new InvalidOperationException("Number of key frames must be 2 or more."); lastFrame = keyFrames[keyFrames.Count - 1]; // create curves curves = new List<TimeCurve>(targets.Count); for (int i = 0; i < targets.Count; i++) { var curve = new TimeCurve(); curve.PostLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; curve.PreLoop = this.Autoreverse ? CurveLoopType.Oscillate : CurveLoopType.Cycle; for (int j = 0; j < keyFrames.Count; j++) { curve.Keys.Add(keyFrames[j].CurveKeys[i]); } curves.Add(curve); } PerfMon.Stop("Other-Ani"); }