예제 #1
0
 public static void Add(this TimelineCollection timelines, params Timeline[] items)
 {
     foreach (var item in items)
     {
         timelines.Add(item);
     }
 }
예제 #2
0
            internal Enumerator(TimelineCollection list)
            {
                Debug.Assert(list != null, "list may not be null.");

                _list    = list;
                _version = list._version;
                _index   = -1;
                _current = default(Timeline);
            }
예제 #3
0
        /// <summary>
        /// Implementation of Freezable.GetCurrentValueAsFrozenCore()
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            TimelineCollection sourceTimelineCollection = (TimelineCollection)source;

            base.GetCurrentValueAsFrozenCore(source);

            int count = sourceTimelineCollection._collection.Count;

            _collection = new FrugalStructList <Timeline>(count);

            for (int i = 0; i < count; i++)
            {
                Timeline newValue = (Timeline)sourceTimelineCollection._collection[i].GetCurrentValueAsFrozen();
                OnFreezablePropertyChanged(/* oldValue = */ null, newValue);
                _collection.Add(newValue);
            }
        }
예제 #4
0
파일: Timeline.cs 프로젝트: beda2280/wpf-1
        /// <summary>
        /// Dumps the description of the subtree rooted at this timeline.
        /// </summary>
        /// <param name="builder">
        /// A StringBuilder that accumulates the description text.
        /// </param>
        /// <param name="depth">
        /// The depth of recursion for this timeline.
        /// </param>
        internal void BuildInfoRecursive(System.Text.StringBuilder builder, int depth)
        {
            // Add the info for this timeline
            BuildInfo(builder, depth, true);

            // Recurse into the children
            depth++;
            TimelineGroup timelineGroup = this as TimelineGroup;

            if (timelineGroup != null)
            {
                TimelineCollection children = timelineGroup.Children;
                if (children != null)
                {
                    for (int childIndex = 0; childIndex < children.Count; childIndex++)
                    {
                        children.Internal_GetItem(childIndex).BuildInfoRecursive(builder, depth);
                    }
                }
            }
        }
예제 #5
0
        internal override void BuildClockSubTreeFromTimeline(
            Timeline timeline,
            bool hasControllableRoot)
        {
            // This is not currently necessary
            //base.BuildClockSubTreeFromTimeline(timeline);

            // Only TimelineGroup has children
            TimelineGroup timelineGroup = timeline as TimelineGroup;

            // Only a TimelineGroup should have allocated a ClockGroup.
            Debug.Assert(timelineGroup != null);

            // Create a clock for each of the children of the timeline
            TimelineCollection timelineChildren = timelineGroup.Children;

            if (timelineChildren != null && timelineChildren.Count > 0)
            {
                Clock childClock;

                // Create a collection for the children of the clock
                _children = new List <Clock>();

                // Create clocks for the children
                for (int index = 0; index < timelineChildren.Count; index++)
                {
                    childClock         = AllocateClock(timelineChildren[index], hasControllableRoot);
                    childClock._parent = this;  // We connect the child to the subtree before calling BuildClockSubtreeFromTimeline
                    childClock.BuildClockSubTreeFromTimeline(timelineChildren[index], hasControllableRoot);
                    _children.Add(childClock);
                    childClock._childIndex = index;
                }

                // If we have SlipBehavior, check if we have any childen with which to slip.
                if (_timeline is ParallelTimeline &&
                    ((ParallelTimeline)_timeline).SlipBehavior == SlipBehavior.Slip)
                {
                    // Verify that we only use SlipBehavior in supported scenarios
                    if (!IsRoot ||
                        (_timeline.RepeatBehavior.HasDuration) ||
                        (_timeline.AutoReverse == true) ||
                        (_timeline.AccelerationRatio > 0) ||
                        (_timeline.DecelerationRatio > 0))
                    {
                        throw new NotSupportedException(SR.Get(SRID.Timing_SlipBehavior_SlipOnlyOnSimpleTimelines));
                    }

                    for (int index = 0; index < _children.Count; index++)
                    {
                        Clock child = _children[index];
                        if (child.CanSlip)
                        {
                            Duration duration = child.ResolvedDuration;

                            // A sync clock with duration of zero or no begin time has no effect, so do skip it
                            if ((!duration.HasTimeSpan || duration.TimeSpan > TimeSpan.Zero) &&
                                child._timeline.BeginTime.HasValue)
                            {
                                _syncData       = new SyncData(child);
                                child._syncData = null;  // The child will no longer self-sync
                            }

                            break;  // We only want the first child with CanSlip
                        }
                    }
                }
            }
        }
예제 #6
0
 /// <summary>
 /// Creates an enumerator iterates over the children of the specified container.
 /// </summary>
 /// <param name="owner">
 /// The collection we are enumerating.
 /// </param>
 internal TimelineEnumerator(TimelineCollection owner)
 {
     _owner        = owner;
     _currentIndex = -1;
     _version      = _owner.Version;
 }
예제 #7
0
		public void RemoveChildThenStart4 ()
		{
			Canvas c = CreateStoryboard ();
			Storyboard sb = (Storyboard) c.Resources ["Storyboard"];
			Storyboard child = (Storyboard) sb.Children [1];
			sb.Children.RemoveAt (1);
			c.Resources.Clear ();

			TimelineCollection collection = new TimelineCollection();
			Storyboard storyboard = new Storyboard ();
			storyboard.Children.Add (child);
			Storyboard.SetTargetName (child, null);
			Storyboard.SetTarget (child, c.Children[0]);

			CreateAsyncTest (c,
					 delegate { Console.WriteLine (1); storyboard.Begin (); },
				delegate { Console.WriteLine (2); storyboard.Stop (); },
				delegate { Console.WriteLine (3); collection.Add (storyboard); },
				delegate { Console.WriteLine (4); storyboard.Begin (); },
				delegate { Console.WriteLine (5); storyboard.Stop (); },
				delegate { Console.WriteLine (6); collection.Remove (storyboard); },
				delegate { Console.WriteLine (7); sb.Children.Add (storyboard); },
				delegate { Console.WriteLine (8); sb.Children.Remove (storyboard); },
				delegate { Console.WriteLine (9); Assert.Throws<InvalidOperationException> (delegate { storyboard.Begin (); }); }
			);
		}
예제 #8
0
        private Timeline FindObjectByName(TimelineCollection objs, String name)
        {
            foreach (var o in objs)
            {
                if (o.Name == name)
                {
                    return o;
                }
            }

            return null;
        }