port from perforce
This commit is contained in:
78
aiwaz/AiwazAnimator/AnimationManager.cs
Normal file
78
aiwaz/AiwazAnimator/AnimationManager.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
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<Animation> Animations { get; set; }
|
||||
|
||||
public AnimationManager()
|
||||
{
|
||||
_animating = false;
|
||||
_currentTime = 0.0f;
|
||||
Animations = new ObservableCollection<Animation>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user