Files
ZuneShell.dll/UIX/Microsoft/Iris/Animations/RelativeTo.cs
T

139 lines
4.6 KiB
C#
Raw Normal View History

// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Animations.RelativeTo
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Render;
namespace Microsoft.Iris.Animations
{
internal class RelativeTo
{
private IAnimatable _sourceObject;
private int _sourceId;
private string _sourceProperty;
private SnapshotPolicy _snapshot;
private int _power = 1;
private float _multiply = 1f;
private float _add;
private static RelativeTo s_absolute = new RelativeTo();
private static RelativeTo s_current = new RelativeTo(SnapshotPolicy.Once);
private static RelativeTo s_currentSnapshotOnLoop = new RelativeTo(SnapshotPolicy.OnLoop);
private static RelativeTo s_final = new RelativeTo();
2021-04-02 19:10:51 -05:00
public RelativeTo() => _snapshot = SnapshotPolicy.Continuous;
2021-04-02 19:10:51 -05:00
public RelativeTo(SnapshotPolicy snapshot) => _snapshot = snapshot;
2021-04-02 19:10:51 -05:00
public bool IsRelativeToObject => _sourceObject != null || _sourceId != 0 || this == s_current || this == s_currentSnapshotOnLoop;
public IAnimatable Source
{
2021-04-02 19:10:51 -05:00
get => _sourceObject;
set => _sourceObject = value;
}
public int SourceId
{
2021-04-02 19:10:51 -05:00
get => _sourceId;
set => _sourceId = value;
}
public string Property
{
2021-04-02 19:10:51 -05:00
get => _sourceProperty;
set => _sourceProperty = value;
}
public SnapshotPolicy Snapshot
{
2021-04-02 19:10:51 -05:00
get => _snapshot;
set => _snapshot = value;
}
public int Power
{
2021-04-02 19:10:51 -05:00
get => _power;
set => _power = value;
}
public float Multiply
{
2021-04-02 19:10:51 -05:00
get => _multiply;
set => _multiply = value;
}
public float Add
{
2021-04-02 19:10:51 -05:00
get => _add;
set => _add = value;
}
2021-03-31 17:20:20 -05:00
public static RelativeTo Absolute => s_absolute;
2021-03-31 17:20:20 -05:00
public static RelativeTo Current => s_current;
2021-03-31 17:20:20 -05:00
public static RelativeTo CurrentSnapshotOnLoop => s_currentSnapshotOnLoop;
2021-03-31 17:20:20 -05:00
public static RelativeTo Final => s_final;
public AnimationInput CreateAnimationInput(
IAnimatable defaultSource,
string defaultSourceProperty,
string defaultSourcePropertyMask)
{
2021-03-31 17:15:06 -05:00
IAnimatable sourceObject = null;
string sourcePropertyName = null;
string sourceMaskSpec = null;
bool flag = true;
2021-04-02 19:10:51 -05:00
if (_sourceProperty != null)
{
2021-04-02 19:10:51 -05:00
sourceObject = _sourceId == 0 ? _sourceObject : Application.MapExternalAnimationInput(_sourceId);
if (sourceObject != null)
{
2021-04-02 19:10:51 -05:00
sourcePropertyName = _sourceProperty;
flag = false;
}
}
if (flag)
{
sourceObject = defaultSource;
sourcePropertyName = defaultSourceProperty;
sourceMaskSpec = defaultSourcePropertyMask;
}
AnimationInput animationInput1;
2021-04-02 19:10:51 -05:00
if (Snapshot == SnapshotPolicy.Continuous)
{
2021-03-31 17:15:06 -05:00
animationInput1 = new ContinuousAnimationInput(sourceObject, sourcePropertyName, sourceMaskSpec);
}
else
{
CapturedAnimationInput capturedAnimationInput = new CapturedAnimationInput(sourceObject, sourcePropertyName, sourceMaskSpec);
2021-04-02 19:10:51 -05:00
if (Snapshot == SnapshotPolicy.OnLoop)
capturedAnimationInput.RefreshOnRepeat = true;
2021-03-31 17:15:06 -05:00
animationInput1 = capturedAnimationInput;
}
AnimationInput animationInput2 = animationInput1;
2021-04-02 19:10:51 -05:00
for (int index = 1; index < _power; ++index)
animationInput2 *= animationInput1;
2021-03-31 17:15:06 -05:00
if (_multiply != 1.0)
2021-04-02 19:10:51 -05:00
animationInput2 *= new ConstantAnimationInput(_multiply);
2021-03-31 17:15:06 -05:00
if (_add != 0.0)
2021-04-02 19:10:51 -05:00
animationInput2 += new ConstantAnimationInput(_add);
return animationInput2;
}
public override string ToString()
{
2021-03-31 17:20:20 -05:00
if (this == s_absolute)
return "Absolute";
2021-03-31 17:20:20 -05:00
if (this == s_current)
return "Current";
2021-03-31 17:20:20 -05:00
if (this == s_currentSnapshotOnLoop)
return "CurrentSnapshotOnLoop";
2021-04-02 19:10:51 -05:00
return this == s_final ? "Final" : string.Format("[Object = {0}, Property = {1}]", _sourceObject != null ? _sourceObject : (object)_sourceId, _sourceProperty);
}
}
}