本文整理汇总了C#中System.Windows.Media.ScaleTransform.BeginAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# ScaleTransform.BeginAnimation方法的具体用法?C# ScaleTransform.BeginAnimation怎么用?C# ScaleTransform.BeginAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.ScaleTransform
的用法示例。
在下文中一共展示了ScaleTransform.BeginAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParkHotelExplorer
public static void ParkHotelExplorer(bool restore, double width, Canvas canvas, double top, double left, double scale, double rotate)
{
_canvas = canvas;
var hotelExplorer = HotelExplorer.GetInstance();
hotelExplorer.IsFloating = !restore;
hotelExplorer.HightLight(!restore);
var ypos = restore ? top : Canvas.GetTop(hotelExplorer);
var xpos = restore ? width - left - (hotelExplorer.ActualWidth * scale) : Canvas.GetLeft(hotelExplorer);
var yTo = restore ? 55 : top;
var xTo = restore ? 55 : width - left - (hotelExplorer.ActualWidth / scale);
var zoomFrom = restore ? scale : 1;
var zoomTo = restore ? 1 : scale;
var rotateFrom = restore ? rotate : 0;
var rotateTo = restore ? 0 : rotate;
var yAnimation = new DoubleAnimation
{
From = ypos,
To = yTo,
Duration = new Duration(TimeSpan.FromMilliseconds(500))
};
var xAnimation = new DoubleAnimation
{
From = xpos,
To = xTo,
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
hotelExplorer.BeginAnimation(Canvas.TopProperty, yAnimation);
hotelExplorer.BeginAnimation(Canvas.LeftProperty, xAnimation);
var zoom = new DoubleAnimation
{
From = zoomFrom,
To = zoomTo,
BeginTime = TimeSpan.FromMilliseconds(0),
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
var rotateAnimation = new DoubleAnimation
{
From = rotateFrom,
To = rotateTo,
BeginTime = TimeSpan.FromMilliseconds(0),
Duration = new Duration(TimeSpan.FromMilliseconds(1000))
};
zoom.Completed += HotelZoomCompleted;
var st = new ScaleTransform();
var rt = new RotateTransform(rotateTo, 0, 0);
var group = new TransformGroup();
group.Children.Add(st);
group.Children.Add(rt);
hotelExplorer.Container.WorkingObject.RenderTransform = group;
st.BeginAnimation(ScaleTransform.ScaleXProperty, zoom);
st.BeginAnimation(ScaleTransform.ScaleYProperty, zoom);
st.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
}
示例2: OnVisualChildrenChanged
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
{
base.OnVisualChildrenChanged(visualAdded, visualRemoved);
if (visualAdded != null)
{
var child = (ContentPresenter)visualAdded;
if (((Card)child.DataContext).Controller != Player.LocalPlayer)
{
var scale = new ScaleTransform();
child.RenderTransformOrigin = new Point(0.5, 0.5);
child.RenderTransform = scale;
var anim = new DoubleAnimation()
{
Duration = new Duration(TimeSpan.FromMilliseconds(400)),
AutoReverse = true,
RepeatBehavior = new RepeatBehavior(2.166),
AccelerationRatio = 0.2,
DecelerationRatio = 0.7,
To = 1.2, From = 0.9,
FillBehavior = FillBehavior.Stop
};
scale.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
scale.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
}
}
}
示例3: UIElementCome
/// <summary>
/// 控件窗口弹出动画
/// </summary>
public static void UIElementCome(UIElement uIElement, ScaleTransform _scale)
{
PennerDoubleAnimation da = new PennerDoubleAnimation()
{
From = 0.8,
To = 1,
Equation = Equations.BackEaseOut,
FillBehavior = FillBehavior.Stop,
Duration = TimeSpan.FromSeconds(0.5)
};
da.Completed += delegate
{
_scale.ScaleX = 1;
_scale.ScaleY = 1;
};
DoubleAnimation daO = new DoubleAnimation()
{
From = 0,
To = 1,
FillBehavior = FillBehavior.Stop,
Duration = TimeSpan.FromSeconds(0.7)
};
daO.Completed += delegate
{
uIElement.Opacity = 1;
};
_scale.BeginAnimation(ScaleTransform.ScaleXProperty, da);
_scale.BeginAnimation(ScaleTransform.ScaleYProperty, da);
uIElement.BeginAnimation(UIElement.OpacityProperty, daO);
}
示例4: UserControl_Loaded_1
private void UserControl_Loaded_1(object sender, RoutedEventArgs e)
{
ScaleTransform st = new ScaleTransform(1, 1);
DoubleAnimation cartoonClear = new DoubleAnimation(0.1, 1, new Duration(TimeSpan.FromMilliseconds(500)));
this.RenderTransform = st;
st.BeginAnimation(ScaleTransform.ScaleYProperty, cartoonClear);
st.BeginAnimation(ScaleTransform.ScaleXProperty, cartoonClear);
}
示例5: Wipe
public void Wipe(TransitionerSlide fromSlide, TransitionerSlide toSlide, Point origin, IZIndexController zIndexController)
{
if (fromSlide == null) throw new ArgumentNullException(nameof(fromSlide));
if (toSlide == null) throw new ArgumentNullException(nameof(toSlide));
if (zIndexController == null) throw new ArgumentNullException(nameof(zIndexController));
var horizontalProportion = Math.Max(1.0 - origin.X, 1.0 * origin.X);
var verticalProportion = Math.Max(1.0 - origin.Y, 1.0 * origin.Y);
var radius = Math.Sqrt(Math.Pow(toSlide.ActualWidth * horizontalProportion, 2) + Math.Pow(toSlide.ActualHeight * verticalProportion, 2));
var scaleTransform = new ScaleTransform(0, 0);
var translateTransform = new TranslateTransform(toSlide.ActualWidth * origin.X, toSlide.ActualHeight * origin.Y);
var transformGroup = new TransformGroup();
transformGroup.Children.Add(scaleTransform);
transformGroup.Children.Add(translateTransform);
var ellipseGeomotry = new EllipseGeometry()
{
RadiusX = radius,
RadiusY = radius,
Transform = transformGroup
};
toSlide.SetCurrentValue(UIElement.ClipProperty, ellipseGeomotry);
zIndexController.Stack(toSlide, fromSlide);
var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);
var midKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
var endKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
var opacityAnimation = new DoubleAnimationUsingKeyFrames();
opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, midKeyTime));
opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime));
opacityAnimation.Completed += (sender, args) =>
{
fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
fromSlide.Opacity = 0;
};
fromSlide.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);
var scaleAnimation = new DoubleAnimationUsingKeyFrames();
scaleAnimation.Completed += (sender, args) =>
{
toSlide.SetCurrentValue(UIElement.ClipProperty, null);
fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
fromSlide.Opacity = 0;
};
scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, zeroKeyTime));
scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, endKeyTime));
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
}
示例6: gdMain_MouseDown
void gdMain_MouseDown(object sender, MouseButtonEventArgs e)
{
if (click != null)
{
DoubleAnimation da = new DoubleAnimation(1.0, 0.95, TimeSpan.FromMilliseconds(50));
da.AutoReverse = true;
ScaleTransform rt = new ScaleTransform();
this.RenderTransformOrigin = new Point(0.5, 0.5);
this.RenderTransform = rt;
rt.BeginAnimation(ScaleTransform.ScaleXProperty, da);
rt.BeginAnimation(ScaleTransform.ScaleYProperty, da);
click(this, null);
}
}
示例7: _BeginAnimateContentReplacement
private void _BeginAnimateContentReplacement()
{
var flapTransformTop = new ScaleTransform { CenterY = _rectangleTop.ActualHeight / 2 };
_rectangleTop.RenderTransform = flapTransformTop;
var flapTransformBottom = new ScaleTransform { CenterY = _rectangleBottom.ActualHeight / 2 };
_rectangleBottom.RenderTransform = flapTransformBottom;
_rectangleTop.Visibility = Visibility.Visible;
_rectangleBottom.Visibility = Visibility.Visible;
_rectangleBottomStatic.Visibility = Visibility.Visible;
IEasingFunction ease = null;//new BackEase() { EasingMode = EasingMode.EaseOut };
AnimationTimeline animationTop = AnimateLib.CreateAnimation(1, 0, 0, 0.1, null, (object s, EventArgs e) =>
{
_rectangleTop.Visibility = Visibility.Hidden;
_rectangleBottom.Visibility = Visibility.Visible;
_rectangleBottom.Fill = AnimateLib.CreateBrushFromVisual(_displayBottom, (int)_rectangleBottom.ActualWidth, (int)_rectangleBottom.ActualHeight);
});
AnimationTimeline animationBottom = AnimateLib.CreateAnimation(0, 1, 0.1, 0.1, ease, (object s, EventArgs e) =>
{
_rectangleBottom.Visibility = Visibility.Hidden;
_rectangleBottomStatic.Visibility = Visibility.Hidden;
});
flapTransformTop.BeginAnimation(ScaleTransform.ScaleYProperty, animationTop, HandoffBehavior.SnapshotAndReplace);
flapTransformBottom.BeginAnimation(ScaleTransform.ScaleYProperty, animationBottom, HandoffBehavior.SnapshotAndReplace);
}
示例8: HideInfoBar
private void HideInfoBar()
{
DoubleAnimation dbaOpacity = new DoubleAnimation(0, durationCommon);
dbaOpacity.Completed += (o, e) =>
{
bdrInfo.Visibility = Visibility.Collapsed;
};
DoubleAnimation dbaScale = new DoubleAnimation(0.95, durationCommon);
dbaScale.DecelerationRatio = 1;
ScaleTransform scaleTransform = new ScaleTransform();
bdrInfo.RenderTransform = scaleTransform;
bdrInfo.BeginAnimation(Border.OpacityProperty, dbaOpacity);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, dbaScale);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, dbaScale);
}
示例9: Wipe
public void Wipe(TransitionerSlide fromSlide, TransitionerSlide toSlide, Point origin, IZIndexController zIndexController)
{
if (fromSlide == null) throw new ArgumentNullException(nameof(fromSlide));
if (toSlide == null) throw new ArgumentNullException(nameof(toSlide));
if (zIndexController == null) throw new ArgumentNullException(nameof(zIndexController));
var zeroKeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero);
var midishKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200));
var endKeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(400));
//back out old slide setup
var scaleTransform = new ScaleTransform(1, 1);
fromSlide.RenderTransform = scaleTransform;
var scaleAnimation = new DoubleAnimationUsingKeyFrames();
scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
scaleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(.8, endKeyTime));
scaleAnimation.Completed += (sender, args) =>
{
fromSlide.RenderTransform = null;
};
var opacityAnimation = new DoubleAnimationUsingKeyFrames();
opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(1, zeroKeyTime));
opacityAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime));
opacityAnimation.Completed += (sender, args) =>
{
fromSlide.BeginAnimation(UIElement.OpacityProperty, null);
fromSlide.Opacity = 0;
};
//slide in new slide setup
var translateTransform = new TranslateTransform(0, toSlide.ActualHeight);
toSlide.RenderTransform = translateTransform;
var slideAnimation = new DoubleAnimationUsingKeyFrames();
slideAnimation.KeyFrames.Add(new LinearDoubleKeyFrame(toSlide.ActualHeight, zeroKeyTime));
slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(toSlide.ActualHeight, midishKeyTime) { EasingFunction = _sineEase});
slideAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(0, endKeyTime) { EasingFunction = _sineEase });
//kick off!
translateTransform.BeginAnimation(TranslateTransform.YProperty, slideAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
fromSlide.BeginAnimation(UIElement.OpacityProperty, opacityAnimation);
zIndexController.Stack(toSlide, fromSlide);
}
示例10: ShowDice
public void ShowDice(Dice dice)
{
Rectangle rect = new Rectangle()
{
Fill = new SolidColorBrush(Color.FromArgb(192, 255, 255, 255)),
Stroke = new SolidColorBrush(dice.DiceColor == DiceColor.Red ? Colors.DarkRed : Colors.Black),
Width = 50,
Height = 50,
};
mainCanvas.Children.Add(rect);
Canvas.SetLeft(rect, dice.Position.X - 25);
Canvas.SetTop(rect, dice.Position.Y - 25);
ScaleTransform trans = new ScaleTransform(1.0, 1.0, 25, 25);
rect.RenderTransform = trans;
DoubleAnimation anim = new DoubleAnimation(10.0, 1.0, new Duration(TimeSpan.FromSeconds(0.25)));
trans.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
trans.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
}
示例11: HidePopup
private void HidePopup()
{
if (bdrPopup.Visibility != Visibility.Visible) return;
DoubleAnimation dbaScale = new DoubleAnimation(1, 0.8, durationCommon + durationCommon);
dbaScale.AccelerationRatio = 1;
DoubleAnimation dbaOpacity = new DoubleAnimation(0, durationCommon + durationCommon);
// 防止它捕捉到鼠标
dbaOpacity.Completed += (o, e) =>
{
cavStage.MouseMove -= Popup_FollowMouse;
bdrPopup.Visibility = Visibility.Collapsed;
};
bdrPopup.BeginAnimation(Border.OpacityProperty, dbaOpacity);
ScaleTransform scaleTransform = new ScaleTransform();
bdrPopup.RenderTransform = scaleTransform;
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, dbaScale);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, dbaScale);
}
示例12: OnVisualParentChanged
protected override void OnVisualParentChanged(DependencyObject oldParent)
{
base.OnVisualParentChanged(oldParent);
if (oldParent == null || oldParent as ContentPresenter != null)
{
DoubleAnimation animation = new DoubleAnimation()
{
From = 0,
To = 1,
Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)),
EasingFunction = new QuadraticEase()
};
Point origin = new Point();
switch (Dock)
{
case Dock.Left:
origin.X = 0.0d;
origin.Y = 0.0d;
break;
case Dock.Right:
origin.X = 1.0d;
origin.Y = 0.0d;
break;
case Dock.Bottom:
throw new NotSupportedException();
case Dock.Top:
throw new NotSupportedException();
default:
origin.X = 0.0d;
origin.Y = 0.0d;
break;
}
RenderTransformOrigin = origin;
RenderTransform = new ScaleTransform();
RenderTransform.BeginAnimation(ScaleTransform.ScaleXProperty, animation);
}
}
示例13: BeginPulsatingAnimation
/// <summary>Begins a pulsating effect with the specified parameters.</summary>
/// <param name="element">The element over which to apply the effect.</param>
/// <param name="period">The effect period.</param>
/// <param name="rotation">The horizontal rotation span.</param>
/// <param name="translation">The vertical translation span.</param>
public static void BeginPulsatingAnimation(UIElement element, TimeSpan period, double rotation, double translation) {
if (element == null) return;
StopPulsatingAnimation(element);
var rnd = _pulsatingAnimationRandomizer;
var dur = period.TotalSeconds * (5);
var tx1 = new ScaleTransform();
var anim1 = new DoubleAnimation {
From = 0.975,
To = 1.025,
BeginTime = TimeSpan.FromSeconds(dur * rnd.NextDouble() - dur / 2),
Duration = new Duration(TimeSpan.FromSeconds(dur)),
AutoReverse = true,
RepeatBehavior = RepeatBehavior.Forever
};
tx1.BeginAnimation(ScaleTransform.ScaleXProperty, anim1);
var tx2 = new ScaleTransform();
var anim2 = new DoubleAnimation {
From = 0.975,
To = 1.025,
BeginTime = TimeSpan.FromSeconds(dur * rnd.NextDouble() - dur / 2),
Duration = new Duration(TimeSpan.FromSeconds(dur)),
AutoReverse = true,
RepeatBehavior = RepeatBehavior.Forever
};
tx2.BeginAnimation(ScaleTransform.ScaleYProperty, anim1);
var tg = new TransformGroup();
tg.Children.Add(tx1);
tg.Children.Add(tx2);
element.RenderTransform = tg;
element.RenderTransformOrigin = new Point(0.5, 0.5);
}
示例14: FlipCardRectangle
private void FlipCardRectangle(Rectangle cardRectangle, int from, int to)
{
cardRectangle.RenderTransformOrigin = new Point(0.5, 0.5);
ScaleTransform flipTrans = new ScaleTransform();
flipTrans.ScaleY = 1;
cardRectangle.RenderTransform = flipTrans;
DoubleAnimation da = new DoubleAnimation();
da.From = from;
da.To = to;
da.Duration = TimeSpan.FromMilliseconds(200);
flipTrans.BeginAnimation(ScaleTransform.ScaleYProperty, da);
}
示例15: AnimateNewPerson
/// <summary>
/// Animate the new person that was added to the diagram.
/// </summary>
private void AnimateNewPerson()
{
// The new person is optional, can be null.
if (newPerson == null)
return;
// Get the UI element to animate.
DiagramNode node = logic.GetDiagramNode(newPerson);
if (node != null)
{
// Create the new person animation.
DoubleAnimation anim = new DoubleAnimation(0, 1,
App.GetAnimationDuration(Const.NewPersonAnimationDuration));
// Animate the node.
ScaleTransform transform = new ScaleTransform();
transform.BeginAnimation(ScaleTransform.ScaleXProperty, anim);
transform.BeginAnimation(ScaleTransform.ScaleYProperty, anim);
node.RenderTransform = transform;
}
newPerson = null;
}