// Type: System.Windows.Media.Animation.Animatable
// Assembly: PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationCore.dll
using MS.Internal;
using MS.Internal.PresentationCore;
using MS.Utility;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime;
using System.Security.Permissions;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Composition;
namespace System.Windows.Media.Animation
{
public abstract class Animatable : Freezable, IAnimatable, DUCE.IResource
{
private static readonly UncommonField<WeakReference> StoredWeakReferenceField = new UncommonField<WeakReference>();
public bool HasAnimatedProperties
{
get
{
this.VerifyAccess();
return this.IAnimatable_HasAnimatedProperties;
}
}
static Animatable()
{
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
protected Animatable()
{
}
public Animatable Clone()
{
return (Animatable) base.Clone();
}
internal void PropertyChanged(DependencyProperty dp)
{
IndependentAnimationStorage animationStorage = AnimationStorage.GetStorage((DependencyObject) this, dp) as IndependentAnimationStorage;
if (animationStorage != null)
animationStorage.InvalidateResource();
else
this.RegisterForAsyncUpdateResource();
}
internal virtual void AddRefOnChannelAnimations(DUCE.Channel channel)
{
if (!this.IAnimatable_HasAnimatedProperties)
return;
FrugalMap animatedPropertiesMap = AnimationStorage.GetAnimatedPropertiesMap((DependencyObject) this);
for (int index = 0; index < animatedPropertiesMap.Count; ++index)
{
int key;
object obj;
animatedPropertiesMap.GetKeyValuePair(index, out key, out obj);
DUCE.IResource resource = obj as DUCE.IResource;
if (resource != null)
resource.AddRefOnChannel(channel);
}
}
internal virtual void ReleaseOnChannelAnimations(DUCE.Channel channel)
{
if (!this.IAnimatable_HasAnimatedProperties)
return;
FrugalMap animatedPropertiesMap = AnimationStorage.GetAnimatedPropertiesMap((DependencyObject) this);
for (int index = 0; index < animatedPropertiesMap.Count; ++index)
{
int key;
object obj;
animatedPropertiesMap.GetKeyValuePair(index, out key, out obj);
DUCE.IResource resource = obj as DUCE.IResource;
if (resource != null)
resource.ReleaseOnChannel(channel);
}
}
internal static DependencyProperty RegisterProperty(string name, System.Type propertyType, System.Type ownerType, object defaultValue, PropertyChangedCallback changed, ValidateValueCallback validate, bool isIndependentlyAnimated, CoerceValueCallback coerced)
{
UIPropertyMetadata propertyMetadata = !isIndependentlyAnimated ? new UIPropertyMetadata(defaultValue) : (UIPropertyMetadata) new IndependentlyAnimatedPropertyMetadata(defaultValue);
propertyMetadata.PropertyChangedCallback = changed;
if (coerced != null)
propertyMetadata.CoerceValueCallback = coerced;
return DependencyProperty.Register(name, propertyType, ownerType, (PropertyMetadata) propertyMetadata, validate);
}
internal void AddRefResource(DUCE.IResource resource, DUCE.Channel channel)
{
if (resource == null)
return;
resource.AddRefOnChannel(channel);
}
internal void ReleaseResource(DUCE.IResource resource, DUCE.Channel channel)
{
if (resource == null)
return;
resource.ReleaseOnChannel(channel);
}
protected override bool FreezeCore(bool isChecking)
{
if (!this.IAnimatable_HasAnimatedProperties)
return base.FreezeCore(isChecking);
if (TraceFreezable.IsEnabled)
TraceFreezable.Trace(TraceEventType.Warning, TraceFreezable.UnableToFreezeAnimatedProperties, (object) this);
return false;
}
DUCE.ResourceHandle DUCE.IResource.AddRefOnChannel(DUCE.Channel channel)
{
return DUCE.ResourceHandle.Null;
}
void DUCE.IResource.ReleaseOnChannel(DUCE.Channel channel)
{
}
DUCE.ResourceHandle DUCE.IResource.GetHandle(DUCE.Channel channel)
{
return DUCE.ResourceHandle.Null;
}
int DUCE.IResource.GetChannelCount()
{
return 0;
}
DUCE.Channel DUCE.IResource.GetChannel(int index)
{
return (DUCE.Channel) null;
}
DUCE.ResourceHandle DUCE.IResource.Get3DHandle(DUCE.Channel channel)
{
throw new NotImplementedException();
}
void DUCE.IResource.RemoveChildFromParent(DUCE.IResource parent, DUCE.Channel channel)
{
throw new NotImplementedException();
}
internal DUCE.ResourceHandle GetAnimationResourceHandle(DependencyProperty dp, DUCE.Channel channel)
{
if (channel != null && this.IAnimatable_HasAnimatedProperties)
return IndependentAnimationStorage.GetResourceHandle((DependencyObject) this, dp, channel);
else
return DUCE.ResourceHandle.Null;
}
internal WeakReference GetWeakReference()
{
object obj = (object) Animatable.StoredWeakReferenceField.GetValue((DependencyObject) this);
if (obj == null)
{
obj = (object) new WeakReference((object) this);
Animatable.StoredWeakReferenceField.SetValue((DependencyObject) this, (WeakReference) obj);
}
return (WeakReference) obj;
}
internal bool IsBaseValueDefault(DependencyProperty dp)
{
return this.ReadLocalValue(dp) == DependencyProperty.UnsetValue;
}
internal void RegisterForAsyncUpdateResource()
{
DUCE.IResource resource = (DUCE.IResource) this;
if (resource == null || this.Dispatcher == null || !this.Animatable_IsResourceInvalidationNecessary)
return;
MediaContext mediaContext = MediaContext.From(this.Dispatcher);
if (resource.GetHandle(mediaContext.Channel).IsNull)
return;
mediaContext.ResourcesUpdated += new MediaContext.ResourcesUpdatedHandler(this.UpdateResource);
this.Animatable_IsResourceInvalidationNecessary = false;
}
internal virtual void UpdateResource(DUCE.Channel channel, bool skipOnChannelCheck)
{
this.Animatable_IsResourceInvalidationNecessary = true;
}
internal void InternalWritePreamble()
{
this.WritePreamble();
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool ShouldSerializeStoredWeakReference(DependencyObject target)
{
return false;
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void ApplyAnimationClock(DependencyProperty dp, AnimationClock clock)
{
this.ApplyAnimationClock(dp, clock, HandoffBehavior.SnapshotAndReplace);
}
public void ApplyAnimationClock(DependencyProperty dp, AnimationClock clock, HandoffBehavior handoffBehavior)
{
if (dp == null)
throw new ArgumentNullException("dp");
if (!AnimationStorage.IsPropertyAnimatable((DependencyObject) this, dp))
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_DependencyPropertyIsNotAnimatable", (object) dp.Name, (object) this.GetType()), "dp");
else if (clock != null && !AnimationStorage.IsAnimationValid(dp, clock.Timeline))
{
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_AnimationTimelineTypeMismatch", (object) clock.Timeline.GetType(), (object) dp.Name, (object) dp.PropertyType), "clock");
}
else
{
if (!HandoffBehaviorEnum.IsDefined(handoffBehavior))
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_UnrecognizedHandoffBehavior"));
if (this.IsSealed)
throw new InvalidOperationException(MS.Internal.PresentationCore.SR.Get("IAnimatable_CantAnimateSealedDO", (object) dp, (object) this.GetType()));
else
AnimationStorage.ApplyAnimationClock((DependencyObject) this, dp, clock, handoffBehavior);
}
}
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation)
{
this.BeginAnimation(dp, animation, HandoffBehavior.SnapshotAndReplace);
}
public void BeginAnimation(DependencyProperty dp, AnimationTimeline animation, HandoffBehavior handoffBehavior)
{
if (dp == null)
throw new ArgumentNullException("dp");
if (!AnimationStorage.IsPropertyAnimatable((DependencyObject) this, dp))
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_DependencyPropertyIsNotAnimatable", (object) dp.Name, (object) this.GetType()), "dp");
else if (animation != null && !AnimationStorage.IsAnimationValid(dp, animation))
{
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_AnimationTimelineTypeMismatch", (object) animation.GetType(), (object) dp.Name, (object) dp.PropertyType), "animation");
}
else
{
if (!HandoffBehaviorEnum.IsDefined(handoffBehavior))
throw new ArgumentException(MS.Internal.PresentationCore.SR.Get("Animation_UnrecognizedHandoffBehavior"));
if (this.IsSealed)
throw new InvalidOperationException(MS.Internal.PresentationCore.SR.Get("IAnimatable_CantAnimateSealedDO", (object) dp, (object) this.GetType()));
else
AnimationStorage.BeginAnimation((DependencyObject) this, dp, animation, handoffBehavior);
}
}
public object GetAnimationBaseValue(DependencyProperty dp)
{
if (dp == null)
throw new ArgumentNullException("dp");
else
return this.GetValueEntry(this.LookupEntry(dp.GlobalIndex), dp, (PropertyMetadata) null, RequestFlags.AnimationBaseValue).Value;
}
[UIPermission(SecurityAction.InheritanceDemand, Window = UIPermissionWindow.AllWindows)]
internal override sealed void EvaluateAnimatedValueCore(DependencyProperty dp, PropertyMetadata metadata, ref EffectiveValueEntry entry)
{
if (!this.IAnimatable_HasAnimatedProperties)
return;
AnimationStorage storage = AnimationStorage.GetStorage((DependencyObject) this, dp);
if (storage == null)
return;
storage.EvaluateAnimatedValue(metadata, ref entry);
}
}
}