diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Subtree.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Subtree.cs index d126e35b102..c1d948ef54d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Subtree.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Subtree.cs @@ -267,151 +267,4 @@ internal Clock Current #endregion // Data } - - /// - /// An object that enumerates the timelines of a tree of Timeline - /// objects. - /// - internal struct TimelineTreeEnumerator - { - #region Constructor - /// - /// Creates an enumerator that iterates over a subtree of timelines - /// in prefix order. - /// - /// - /// The timeline that is the root of the subtree to enumerate. - /// - /// - /// True to include the root in the enumeration, false otherwise. - /// - internal TimelineTreeEnumerator(Timeline root, bool processRoot) - { - _rootTimeline = root; - _flags = processRoot ? (SubtreeFlag.Reset | SubtreeFlag.ProcessRoot) : SubtreeFlag.Reset; - - // Start with stacks of capacity 10. That's relatively small, yet - // it covers very large trees without reallocation of stack data. - // Note that given the way we use the stacks we need one less entry - // for indices than for timelines, as we don't care what the index - // of the root timeline is. - _indexStack = new Stack(9); - _timelineStack = new Stack(10); - } - #endregion // Constructor - - #region Methods - - /// - /// Causes the enumerator to not enumerate the timelines in the subtree rooted - /// at the current timeline. - /// - internal void SkipSubtree() - { - _flags |= SubtreeFlag.SkipSubtree; - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - /// - /// true if the enumerator was successfully advanced to the next element, - /// false if the enumerator has passed the end of the collection. - /// - public bool MoveNext() - { - TimelineCollection children; - - // Get the iteration started in the right place, if we are just starting - if ((_flags & SubtreeFlag.Reset) != 0) - { - // The reset flag takes effect only once - _flags &= ~SubtreeFlag.Reset; - - // We are just getting started. The first timeline is the root - _timelineStack.Push(_rootTimeline); - - // If we are not supposed to return the root, simply skip it - if ((_flags & SubtreeFlag.ProcessRoot) == 0) - { - MoveNext(); - } - } - else if (_timelineStack.Count > 0) - { - // Only TimelineGroup can have children - TimelineGroup timelineGroup = _timelineStack.Peek() as TimelineGroup; - - // The next timeline is possibly the first child of the current timeline - // If we have children move to the first one, unless we were - // asked to skip the subtree - if ( ((_flags & SubtreeFlag.SkipSubtree) == 0) - && timelineGroup != null - && (children = timelineGroup.Children) != null - && children.Count > 0 - ) - { - _timelineStack.Push(children[0]); - _indexStack.Push((int)0); - } - else - { - // The skip subtree flag takes effect only once - _flags &= ~SubtreeFlag.SkipSubtree; - - // Move to the first ancestor that has unvisited children, - // then move to the first unvisited child. If we get to - // the root it means we are done. - _timelineStack.Pop(); - while (_timelineStack.Count > 0) - { - timelineGroup = _timelineStack.Peek() as TimelineGroup; - - // This has to be non-null since we already went down the tree - children = timelineGroup.Children; - - int index = (int)_indexStack.Pop() + 1; - - if (index < children.Count) - { - // Move to the next child, and we are done - _timelineStack.Push(children[index]); - _indexStack.Push(index); - break; - } - - _timelineStack.Pop(); - } - } - } - - return _timelineStack.Count > 0; - } - - #endregion // Methods - - #region Properties - - /// - /// Gets the current element in the collection. - /// - internal Timeline Current - { - get - { - return _timelineStack.Peek(); - } - } - - #endregion // Properties - - #region Data - - private Timeline _rootTimeline; - private SubtreeFlag _flags; - private Stack _indexStack; - private Stack _timelineStack; - - #endregion // Data - } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineEnumerator.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineEnumerator.cs deleted file mode 100644 index fbc21c5a2bd..00000000000 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/TimelineEnumerator.cs +++ /dev/null @@ -1,151 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -//------------------------------------------------------------------------------ -// -// File: TimelineEnumerator.cs -//------------------------------------------------------------------------------ - -// Allow suppression of certain presharp messages -#pragma warning disable 1634, 1691 - -using System; -using System.Collections; -using MS.Internal; - -using SR=MS.Internal.PresentationCore.SR; - -namespace System.Windows.Media.Animation -{ - /// - /// An enumerator that iterates over the children of a timeline. - /// - internal struct TimelineEnumerator : IEnumerator - { - #region External interface - - #region IEnumerator interface - - #region Properties - - /// - /// Gets the current element in the collection. - /// - /// - /// The current element in the collection. - /// - object IEnumerator.Current - { - get - { - return Current; - } - } - - #endregion // Properties - - #region Methods - - /// - /// Advances the enumerator to the next element of the collection. - /// - /// - /// True if the enumerator was successfully advanced to the next element; - /// false if the enumerator has passed the end of the collection. - /// - public bool MoveNext() - { - VerifyVersion(); - if (_currentIndex < _owner.Count - 1) - { - _currentIndex++; - return true; - } - else - { - return false; - } - } - /// - /// Sets the enumerator to its initial position, which is before the first element - /// in the collection. - /// - public void Reset() - { - VerifyVersion(); - _currentIndex = -1; - } - - #endregion // Methods - - #endregion // IEnumerator interface - - #region Properties - /// - /// The current timeline referenced by this enumerator. - /// - public Timeline Current - { - get - { - VerifyVersion(); - if (_currentIndex < 0 || _currentIndex == _owner.Count) - { -#pragma warning suppress 56503 // Suppress presharp warning: Follows a pattern similar to Nullable. - throw new InvalidOperationException(SR.Timing_EnumeratorOutOfRange); - } - - return _owner[_currentIndex]; - } - } - #endregion // Properties - - #endregion // External interface - - #region Internal implementation - - #region Construction - - /// - /// Creates an enumerator iterates over the children of the specified container. - /// - /// - /// The collection we are enumerating. - /// - internal TimelineEnumerator(TimelineCollection owner) - { - _owner = owner; - _currentIndex = -1; - _version = _owner.Version; - } - - #endregion // Construction - - #region Methods - - /// - /// Verifies that the enumerator is still valid by comparing its initial version - /// with the current version of the collection. - /// - private void VerifyVersion() - { - if (_version != _owner.Version) - { - throw new InvalidOperationException(SR.Timing_EnumeratorInvalidated); - } - } - - #endregion // Methods - - #region Data - - private TimelineCollection _owner; - private int _currentIndex; - private int _version; - - #endregion // Data - - #endregion // Internal implementation - } -}