using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel; using System.Collections.ObjectModel; namespace AiwazAnimator { public class AnimationManager : INotifyPropertyChanged { private float _currentTime; public float CurrentTime { get { return _currentTime; } set { _currentTime = value; OnPropertyChanged("CurrentTime"); } } private bool _animating; public bool Animating { get { return _animating; } set { _animating = value; OnPropertyChanged("Animating"); } } public ObservableCollection Animations { get; set; } public AnimationManager() { _animating = false; _currentTime = 0.0f; Animations = new ObservableCollection(); Animations.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler((o, e) => { OnPropertyChanged("Animations"); }); } public void Start() { Animating = true; } public void Stop() { CurrentTime = 0.0f; Animating = false; } public void Animate(float DeltaTime) { if (!Animating) return; CurrentTime += DeltaTime; foreach (Animation a in Animations) { a.Animate(CurrentTime); } } protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } public event PropertyChangedEventHandler PropertyChanged; } }