本文整理汇总了C#中IEasingFunction类的典型用法代码示例。如果您正苦于以下问题:C# IEasingFunction类的具体用法?C# IEasingFunction怎么用?C# IEasingFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEasingFunction类属于命名空间,在下文中一共展示了IEasingFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimateDoubleProperty
/// <summary>
/// Animates specified property of the object.
/// </summary>
/// <param name="target">The target object to animate.</param>
/// <param name="propertyPath">Property path, e.g. Canvas.Top.</param>
/// <param name="from">Animation's starting value.</param>
/// <param name="to">Animation's ending value.</param>
/// <param name="milliseconds">Duration of the animation in milliseconds.</param>
/// <param name="easingFunction">Easing function applied to the animation.</param>
/// <param name="completed">Event handler called when animation completed.</param>
/// <returns>Returns started storyboard.</returns>
public static Storyboard AnimateDoubleProperty(this DependencyObject target, string propertyPath, double? from, double? to, double milliseconds,
IEasingFunction easingFunction = null, EventHandler completed = null)
{
Duration duration = new Duration(TimeSpan.FromMilliseconds(milliseconds));
DoubleAnimation doubleAnimation = new DoubleAnimation()
{
From = from,
To = to,
Duration = duration,
EasingFunction = easingFunction
};
Storyboard storyboard = new Storyboard();
storyboard.Duration = duration;
storyboard.Children.Add(doubleAnimation);
Storyboard.SetTarget(doubleAnimation, target);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath(propertyPath));
if (completed != null)
storyboard.Completed += completed;
storyboard.Begin();
return storyboard;
}
示例2: EasingByteKeyFrame
/// <summary>
/// Creates a new EasingByteKeyFrame.
/// </summary>
public EasingByteKeyFrame(Byte value, KeyTime keyTime, IEasingFunction easingFunction)
: this()
{
Value = value;
KeyTime = keyTime;
EasingFunction = easingFunction;
}
示例3: GetAnimation
public static Storyboard GetAnimation(AnimationDirection? animationDirection, bool isInAnimation, int animationTimeMS, IEasingFunction easingFunction = null)
{
var xAxis = "RenderTransform.(TranslateTransform.X)";
var yAxis = "RenderTransform.(TranslateTransform.Y)";
var easing = easingFunction != null ? easingFunction : new QuadraticEase();
var opac = GetOpac(isInAnimation, animationTimeMS);
var story = new Storyboard();
(story as IAddChild).AddChild(opac);
DoubleAnimation anim = null;
if (animationDirection != null)
{
if (isInAnimation)
{
anim = new DoubleAnimation(animationDirection == AnimationDirection.Left || animationDirection == AnimationDirection.Top ? -30 : 30, 0, new Duration(new TimeSpan(0, 0, 0, 0, animationTimeMS))) { EasingFunction = easing };
}
else
{
anim = new DoubleAnimation(0, animationDirection == AnimationDirection.Left || animationDirection == AnimationDirection.Top ? -30 : 30, new Duration(new TimeSpan(0, 0, 0, 0, animationTimeMS))) { EasingFunction = easing };
}
if (anim != null)
{
anim.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(animationDirection == AnimationDirection.Left || animationDirection == AnimationDirection.Right ? xAxis : yAxis));
(story as IAddChild).AddChild(anim);
}
}
return story;
}
示例4: EasingThicknessKeyFrame
/// <summary>
/// Creates a new EasingThicknessKeyFrame.
/// </summary>
public EasingThicknessKeyFrame(Thickness value, KeyTime keyTime, IEasingFunction easingFunction)
: this()
{
Value = value;
KeyTime = keyTime;
EasingFunction = easingFunction;
}
示例5: Animate
public static void Animate(this DependencyObject target, double from, double to, object propertyPath, int duration, int startTime, IEasingFunction easing = null, Action completed = null)
{
if (easing == null)
easing = new SineEase();
var db = new DoubleAnimation();
db.To = to;
db.From = from;
db.EasingFunction = easing;
db.Duration = TimeSpan.FromMilliseconds(duration);
Storyboard.SetTarget(db, target);
Storyboard.SetTargetProperty(db, new PropertyPath(propertyPath));
var sb = new Storyboard();
sb.BeginTime = TimeSpan.FromMilliseconds(startTime);
if (completed != null)
{
sb.Completed += (s, e) => completed();
}
sb.Children.Add(db);
sb.Begin();
}
示例6: CreateAnim
public static DoubleAnimationUsingKeyFrames CreateAnim(this Storyboard sb, DependencyObject target,
string propertyPath, IEasingFunction easing, double value, TimeSpan keyTime)
{
var doubleAnim = (from anim in sb.Children.OfType<DoubleAnimationUsingKeyFrames>()
where GetSBExtTarget(anim) == target
let prop = Storyboard.GetTargetProperty(anim)
where prop.Path == propertyPath
select anim).FirstOrDefault();
if (doubleAnim == null)
{
doubleAnim = new DoubleAnimationUsingKeyFrames();
SetSBExtTarget(doubleAnim, target);
Storyboard.SetTarget(doubleAnim, target);
Storyboard.SetTargetProperty(doubleAnim, new System.Windows.PropertyPath(propertyPath));
sb.Children.Add(doubleAnim);
}
EasingDoubleKeyFrame kf = new EasingDoubleKeyFrame();
kf.EasingFunction = easing;
kf.KeyTime = keyTime;
kf.Value = value;
doubleAnim.KeyFrames.Add(kf);
return doubleAnim;
}
示例7: AddDouble
///
/// <summary>
/// Helper to create double animation</summary>
///
public static Storyboard AddDouble(
this Storyboard sb,
int durationMs,
DependencyObject element,
PropertyPath path,
double from,
double to,
IEasingFunction easing = null
)
{
DoubleAnimation da;
da = new DoubleAnimation();
da.Duration = new Duration(TimeSpan.FromMilliseconds(durationMs));
da.From = from;
da.To = to;
if (easing != null)
{
da.EasingFunction = easing;
}
Storyboard.SetTarget(da, element);
Storyboard.SetTargetProperty(da, path);
sb.Children.Add(da);
return sb;
}
示例8: AccordionPanel
static AccordionPanel()
{
var animationDuration = new Duration (TimeSpan.FromMilliseconds(400));
IEasingFunction animationEase = new ExponentialEase
{
EasingMode = EasingMode.EaseInOut,
};
s_animationDuration = animationDuration;
s_animationEase = animationEase;
Initialize (ref animationDuration, ref animationEase);
s_animationDuration = animationDuration;
s_animationEase = animationEase;
s_animationClock = new DoubleAnimation(
0 ,
1 ,
s_animationDuration ,
FillBehavior.Stop
)
.FreezeObject ()
;
}
示例9: BeginAnimation
public static void BeginAnimation(ChartArea seriesHost, string propertyName, object currentValue, object targetValue, Action<object, object> propertyUpdateAction, Dictionary<string, StoryboardInfo> storyboards, TimeSpan timeSpan, IEasingFunction easingFunction)
{
if (timeSpan == TimeSpan.Zero)
propertyUpdateAction(currentValue, targetValue);
else
DependencyPropertyAnimationHelper.CreateAnimation(seriesHost, propertyName, currentValue, targetValue, propertyUpdateAction, storyboards, timeSpan, easingFunction).Begin();
}
示例10: Animate
public static void Animate(this DependencyObject target, double? from, double? to, object propertyPath,
int duration, int startTime,
IEasingFunction easing = null, Action completed = null)
{
if (easing == null)
easing = new SineEase();
var animation = new DoubleAnimation
{
To = to,
From = @from,
EasingFunction = easing,
Duration = TimeSpan.FromMilliseconds(duration)
};
Storyboard.SetTarget(animation, target);
Storyboard.SetTargetProperty(animation, new PropertyPath(propertyPath));
var storyBoard = new Storyboard {BeginTime = TimeSpan.FromMilliseconds(startTime)};
if (completed != null)
storyBoard.Completed += (sender, args) => completed();
storyBoard.Children.Add(animation);
storyBoard.Begin();
}
示例11: AnimateTranslateTransform
/// <summary>
/// Animates the translate transform object, responsible for displacement of the target.
/// </summary>
/// <param name="target">The target object.</param>
/// <param name="storyboard">The storyboard.</param>
/// <param name="to">Animation's ending value.</param>
/// <param name="seconds">Duration of the animation in seconds.</param>
/// <param name="easingFunction">Easing function applied to the animation.</param>
public static void AnimateTranslateTransform(this DependencyObject target, Storyboard storyboard, Point to,
double seconds, IEasingFunction easingFunction = null)
{
Duration duration = new Duration(TimeSpan.FromSeconds(seconds));
DoubleAnimation doubleAnimationX = new DoubleAnimation()
{
To = to.X,
Duration = duration,
EasingFunction = easingFunction
};
DoubleAnimation doubleAnimationY = new DoubleAnimation()
{
To = to.Y,
Duration = duration,
EasingFunction = easingFunction
};
storyboard.Stop();
storyboard.Children.Clear();
storyboard.Duration = duration;
storyboard.Children.Add(doubleAnimationX);
storyboard.Children.Add(doubleAnimationY);
Storyboard.SetTarget(doubleAnimationX, target);
Storyboard.SetTarget(doubleAnimationY, target);
Storyboard.SetTargetProperty(doubleAnimationX, (target as UIElement).GetPropertyPathForTranslateTransformX());
Storyboard.SetTargetProperty(doubleAnimationY, (target as UIElement).GetPropertyPathForTranslateTransformY());
storyboard.Begin();
}
示例12: CreateAnimation
public static Storyboard CreateAnimation(this DependencyObject target, Dictionary<string, StoryboardInfo> storyboards, DependencyProperty animatingDependencyProperty, string propertyPath, string propertyKey, object initialValue, object targetValue, TimeSpan timeSpan, IEasingFunction easingFunction, Action releaseAction)
{
StoryboardInfo storyboardInfo;
storyboards.TryGetValue(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey), out storyboardInfo);
if (storyboardInfo != null)
{
DependencyObject storyboardTarget = storyboardInfo.StoryboardTarget;
storyboardInfo.Storyboard.Stop();
storyboards.Remove(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey));
if (storyboardInfo.ReleaseAction != null)
{
storyboardInfo.ReleaseAction();
storyboardInfo.ReleaseAction = (Action)null;
}
}
storyboardInfo = new StoryboardInfo();
storyboardInfo.Storyboard = DependencyPropertyAnimationHelper.CreateStoryboard(target, animatingDependencyProperty, propertyPath, propertyKey, ref targetValue, timeSpan, easingFunction);
storyboardInfo.ReleaseAction = releaseAction;
storyboardInfo.StoryboardTarget = target;
storyboardInfo.AnimateFrom = initialValue;
storyboardInfo.Storyboard.Completed += (EventHandler)((source, args) =>
{
storyboards.Remove(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey));
if (storyboardInfo.ReleaseAction == null)
return;
storyboardInfo.ReleaseAction();
storyboardInfo.ReleaseAction = (Action)null;
});
storyboards.Add(DependencyPropertyAnimationHelper.GetStoryboardKey(propertyKey), storyboardInfo);
return storyboardInfo.Storyboard;
}
示例13: AnimationInfo
public AnimationInfo(DependencyObject target, PropertyPath propertyPath, double startValue, double endValue, IEasingFunction easingFunction = null)
{
Target = target;
PropertyPath = propertyPath;
StartValue = startValue;
EndValue = endValue;
EasingFunction = easingFunction;
}
示例14: RangeAnimation
public RangeAnimation(Range from, Range to, Duration duration, FillBehavior fillBehavior = FillBehavior.Stop, IEasingFunction easingFunction = null)
{
From = from;
To = to;
Duration = duration;
FillBehavior = fillBehavior;
EasingFunction = easingFunction;
}
示例15: CreateDoubleAnimation
public static DoubleAnimation CreateDoubleAnimation(string targetName, DependencyProperty targetProperty, double toValue, double fromValue = 0.0, TimeSpan? beginTimeSpan = null, TimeSpan? durationSpan = null, IEasingFunction easingFuction = null)
{
var animation = CreateDoubleAnimation(toValue, fromValue, beginTimeSpan, durationSpan, easingFuction);
Storyboard.SetTargetName(animation, targetName);
Storyboard.SetTargetProperty(animation, new PropertyPath(targetProperty));
return animation;
}