private void DrawTextAndDot(DrawingContext drawingContext, string text, double distance, Brush brush, bool up) { DoubleAnimation doubleAnimation = new DoubleAnimation(2, 0, new Duration(TimeSpan.FromMilliseconds(800))); doubleAnimation.AutoReverse = true; //doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; Pen ellipsePen = this.GetGuidePen(brush); ellipsePen.Freeze(); //drawingContext.DrawEllipse(brush, ellipsePen, new Point(distance - 0.5, this.RenderSize.Height / 2 - 0.5), 3, 3); drawingContext.DrawEllipse(brush, ellipsePen, new Point(distance, this.RenderSize.Height / 2 - 0.5), null, 2, doubleAnimation.CreateClock(), 2, doubleAnimation.CreateClock()); FormattedText formatted = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 9, brush); //formatted.SetFontWeight(FontWeights.Bold); formatted.TextAlignment = TextAlignment.Left; double position = up ? (this.RenderSize.Height / 2 - 3 - formatted.Height) : (this.RenderSize.Height / 2 + 2); var point = new Point(Math.Max(0, distance - formatted.Width / 2), position); var sub = RenderSize.Width - point.X - formatted.Width; if (sub < 0) { point.Offset(sub, 0); } drawingContext.DrawText(formatted, point); }
public static void ShowWithAnimation(this Window window) { if (showAnimationInProgress) { return; } try { showAnimationInProgress = true; window.Visibility = Visibility.Visible; window.Topmost = false; window.Activate(); var showAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.3)), FillBehavior = FillBehavior.Stop, EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseOut } }; var taskbarPosition = TaskbarService.GetWinTaskbarState().TaskbarPosition; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: showAnimation.To = window.Left; break; default: showAnimation.To = window.Top; break; } showAnimation.From = (taskbarPosition == TaskbarPosition.Top || taskbarPosition == TaskbarPosition.Left) ? showAnimation.To - 60 : showAnimation.To + 60; showAnimation.Completed += (s, e) => { window.Topmost = true; showAnimationInProgress = false; window.Focus(); }; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: window.ApplyAnimationClock(Window.LeftProperty, showAnimation.CreateClock()); break; default: window.ApplyAnimationClock(Window.TopProperty, showAnimation.CreateClock()); break; } } catch { showAnimationInProgress = false; } }
public static void HideWithAnimation(this Window window) { if (hideAnimationInProgress) { return; } try { hideAnimationInProgress = true; var hideAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(0.2)), FillBehavior = FillBehavior.Stop, EasingFunction = new ExponentialEase { EasingMode = EasingMode.EaseIn } }; var taskbarPosition = TaskbarService.GetWinTaskbarState().TaskbarPosition; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: hideAnimation.From = window.Left; break; default: hideAnimation.From = window.Top; break; } hideAnimation.To = (taskbarPosition == TaskbarPosition.Top || taskbarPosition == TaskbarPosition.Left) ? hideAnimation.From - 30 : hideAnimation.From + 30; hideAnimation.Completed += (s, e) => { window.Visibility = Visibility.Hidden; hideAnimationInProgress = false; }; switch (taskbarPosition) { case TaskbarPosition.Left: case TaskbarPosition.Right: window.ApplyAnimationClock(Window.LeftProperty, hideAnimation.CreateClock()); break; default: window.ApplyAnimationClock(Window.TopProperty, hideAnimation.CreateClock()); break; } } catch { hideAnimationInProgress = false; } }
public override void Perform() { //The clock with which to animate the ellipse's center position. AnimationClock centerAnimations = PointAnimationUsingPath.CreateClock(); //The clock with which to animate the ellipse's x-radius. AnimationClock radiusXAnimations = DoubleAnimation.CreateClock(); //The clock with which to animate the ellipse's y-radius. AnimationClock radiusYAnimations = DoubleAnimation.CreateClock(); DrawingContext Target = SetDrawingContext(); if (IsDrawAnimation) { //Draws an ellipse with the specified Brush and Pen and applies the specified animation clocks. Target.DrawEllipse(Brush, Pen, Center, centerAnimations, RadiusX, radiusXAnimations, RadiusY, radiusYAnimations); } else { //Draws an ellipse with the specified Brush and Pen. Target.DrawEllipse(Brush, Pen, Center, RadiusX, RadiusY); } Target.Close(); //Add DrawingGroup to DrawingBrush's Drawing property ((DrawingBrush)(Control.Background)).Drawing = DrawingGroup; }
private void bewegung_Click(object sender, RoutedEventArgs e) { // der Start der Bewegung soll auf Click erfolgen // Bewegungsparameter festlegen DoubleAnimation kundeBewegung = new DoubleAnimation { From = 0, To = raumlaenge, // By = 100, Duration = TimeSpan.Parse("0:0:59") }; DoubleAnimation kundeBewegungQuer = new DoubleAnimation { From = 0, To = raumbreite, AutoReverse = true, Duration = TimeSpan.Parse("0:0:10") }; _taktgeberRunter = kundeBewegung.CreateClock(); _taktgeberQuer = kundeBewegungQuer.CreateClock(); kunde.ApplyAnimationClock(Canvas.TopProperty, _taktgeberRunter); kunde.ApplyAnimationClock(Canvas.LeftProperty, _taktgeberQuer); _taktgeberQuer.Controller.Pause(); _taktgeberRunter.Completed += taktgeberRunterCompleted; // event, der am Ende einmal .... _taktgeberRunter.CurrentTimeInvalidated += taktgeberRunterTickt; EventHandler weiterRunter = (s, x) => _taktgeberRunter.Controller.Resume(); _taktgeberQuer.Completed += weiterRunter; }
public override void Perform() { //The clock with which to animate the rectangle's size and dimensions. AnimationClock rectangleAnimations = RectAnimation.CreateClock(); //The clock with which to animate the rectangle's radiusX value. AnimationClock radiusXAnimations = DoubleAnimation.CreateClock(); //The clock with which to animate the rectangle's radiusY value. AnimationClock radiusYAnimations = DoubleAnimation.CreateClock(); DrawingContext Target = SetDrawingContext(); if (IsDrawAnimation) { //Draws a rounded rectangle with the specified Brush and Pen and applies the specified animation clocks. Target.DrawRoundedRectangle(Brush, Pen, Rectangle, rectangleAnimations, RadiusX, radiusXAnimations, RadiusY, radiusYAnimations); } else { //Draws a rounded rectangle with the specified Brush and Pen. Target.DrawRoundedRectangle(Brush, Pen, Rectangle, RadiusX, RadiusY); } Target.Close(); //Add DrawingGroup to DrawingBrush's Drawing property ((DrawingBrush)(Control.Background)).Drawing = DrawingGroup; }
/********************************* Biu Biu Biu ***********************************/ #endregion #region Methods /// <summary> /// 播放指示条动画 /// </summary> /// <param name="Angle"></param> void BeginIndicatorValueChangedAnimation(double Angle) { if (Angle < 5) // 如果EndAngle小于5度,则直接显示角度值,QuinticEase会造成过冲,EndAngle会变成负值,造成闪动 { /* 如果上一个动画还在执行中,则先停止动画 * 否则执行中的动画可能再次更改EndAngle */ if (animationclock != null && animationclock.CurrentState != ClockState.Stopped) { animationclock.Controller.Stop(); } IndicatorBar.EndAngle = Angle; } else { animation = new DoubleAnimation(); animation.Duration = new Duration(TimeSpan.FromMilliseconds(500)); animation.To = Angle; // QuinticEase ease = new QuinticEase(); ElasticEase ease = new ElasticEase() { Oscillations = 2, Springiness = 5 }; ease.EasingMode = EasingMode.EaseOut; animation.EasingFunction = ease; animationclock = animation.CreateClock(); animationclock.Completed += animationclock_Completed; IndicatorBar.ApplyAnimationClock(Arc.EndAngleProperty, animationclock, HandoffBehavior.SnapshotAndReplace); animationclock.Controller.Begin(); } }
protected override void OnRender(DrawingContext dc) // переопределяем метод OnRender { DoubleAnimation anima = new DoubleAnimation(); // создаём объект класса, предназначенного для изменения таких свойств, как длина, ширина, которые представляют тип double // свойства управления анимацией anima.From = 0; // начальное значение, с которого будет начинается анимация anima.To = 100; // конечное значение anima.Duration = new Duration(TimeSpan.FromSeconds(1)); // время анимации в виде объекта TimeSpan//TimeSpan - структура, представляющая интервал времени anima.AutoReverse = true; // при значении true анимация выполняется в противоположную сторону anima.RepeatBehavior = RepeatBehavior.Forever; // позволяет установить, как анимация будет повторяться AnimationClock clock = anima.CreateClock(); // создаем часы AnimationClock на основе AnimationTimeline() // AnimationTimeline определяет интервал времени, в течение которого создаются выходные значения. // Эти значения используются для анимации целевого свойства. // рисует эллипс заданными Brush и Pen и применяет заданные часы анимации dc.DrawEllipse(Brushes.Blue /*кисть для рисования эллипса*/, new Pen(Brushes.Red, 3) /*перо для обводки эллипса*/, new Point(125, 125) /*местоположение центра эллипса*/, null, /*часы, с использованием которых следует анимировать позицию центра эллипса, или null, чтобы анимация не выполнялась*/ 0, /*горизонтальный радиус эллипса*/ clock, /*часы, с использованием которых следует анимировать x-радиус эллипса, или null, чтобы анимация не выполнялась*/ 0, /*вертикальный радиус эллипса*/ clock); /*часы, с использованием которых следует анимировать y-радиус эллипса, или null, чтобы анимация не выполнялась*/ }
private void durchdengang() { double rorl = 1600; ersterGang = ersterGang + MainWindow.gangbei[0].Height * 3; Point aufenthalt = kunde.Bild.TransformToAncestor(Application.Current.MainWindow).Transform(new Point(0, 0)); if (aufenthalt.X > 1500) { rorl = MainWindow.gangbeiX[0]; nachRechts = false; } else { rorl = MainWindow.gangbeiX[1]; nachRechts = true; } DoubleAnimation quer = new DoubleAnimation(); quer.To = rorl; quer.Duration = TimeSpan.Parse("0:0:25"); _taktquer = quer.CreateClock(); _taktquer.CurrentTimeInvalidated += _taktquer_CurrentTimeInvalidated; _taktquer.Completed += _taktquer_Completed; //(s, x) => _taktgeber.Controller.Resume(); kunde.Bild.ApplyAnimationClock(Canvas.LeftProperty, _taktquer); }
void AnimateIn(object sender, RoutedEventArgs e) { var animation = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(EASE_IN_TIME))); var clock = animation.CreateClock(); ApplyAnimationClock(Grid.OpacityProperty, clock); }
private void ApplyAnimationClockTest(DoubleAnimation animation) { FrameworkElement element = new FrameworkElement(); TestRootClock rootClock = new TestRootClock(); rootClock.Tick(TimeSpan.FromSeconds(0)); AnimationTimelineClock clock = (AnimationTimelineClock)animation.CreateClock(); clock.Begin(rootClock); element.Width = 10; Assert.AreEqual(10, element.Width); element.ApplyAnimationClock(FrameworkElement.WidthProperty, clock); Assert.AreEqual(10, element.Width); rootClock.Tick(TimeSpan.FromSeconds(0.5)); Assert.AreEqual(15, element.Width); rootClock.Tick(TimeSpan.FromSeconds(1)); Assert.AreEqual(20, element.Width); clock.Stop(); element.Width = 30; Assert.AreEqual(30, element.Width); }
/// <summary> /// 弹簧式缩小 /// </summary> /// <param name="element"></param> public static void ScaleEasingOutAnimation(this FrameworkElement element) { ScaleTransform scale = new ScaleTransform(); if (element.RenderTransform is TransformGroup) { TransformGroup group = element.RenderTransform as TransformGroup; var item = group.Children.SingleOrDefault(entity => entity is ScaleTransform); group.Children.Remove(item); RotateTransform itemRotate = group.Children.SingleOrDefault(entity => entity is RotateTransform) as RotateTransform; scale.CenterX = itemRotate.CenterX; scale.CenterY = itemRotate.CenterY; group.Children.Add(scale); } else { element.RenderTransform = scale; element.RenderTransformOrigin = new Point(0.5, 0.5); } DoubleAnimation scaleAnimation = new DoubleAnimation() { To = 1, Duration = new TimeSpan(0, 0, 0, 1, 0) }; AnimationClock clock = scaleAnimation.CreateClock(); scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock, HandoffBehavior.Compose); scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock, HandoffBehavior.Compose); }
public void AnimationExpressionFillBehaviorStopTest() { DoubleAnimation animation = new DoubleAnimation { From = 10, To = 20, FillBehavior = FillBehavior.Stop }; TestRootClock rootClock = new TestRootClock(); rootClock.Tick(TimeSpan.FromSeconds(1)); FrameworkElement element = new FrameworkElement(); Assert.AreEqual(Double.NaN, element.Width); AnimationTimelineClock animationClock = (AnimationTimelineClock)animation.CreateClock(); element.ApplyAnimationClock(FrameworkElement.WidthProperty, animationClock); animationClock.Begin(rootClock); rootClock.Tick(TimeSpan.FromSeconds(1)); Assert.AreEqual(10, element.Width); rootClock.Tick(TimeSpan.FromSeconds(2)); Assert.AreEqual(Double.NaN, element.Width); }
private void beginFadeOutIn() { animationState = FADE_OUT_IN; var duration = new Duration(TimeSpan.FromSeconds(1.5)); var animFadeOut = new DoubleAnimation(1, 0, duration); var animFadeIn = new DoubleAnimation(0, 1, duration); animFadeIn.Completed += new EventHandler(endFadeOutIn); AnimationClock fadeInClock = animFadeIn.CreateClock(); AnimationClock fadeOutClock = animFadeOut.CreateClock(); currentClocks.Clear(); currentClocks.Add(fadeInClock); currentClocks.Add(fadeOutClock); transformImage(otherImage, slides[nextSlideIndex].keys[0]); if (currentImage == image1) { currentImage = image2; otherImage = image1; frame1.ApplyAnimationClock(OpacityProperty, fadeOutClock); frame2.ApplyAnimationClock(OpacityProperty, fadeInClock); } else { currentImage = image1; otherImage = image2; frame2.ApplyAnimationClock(OpacityProperty, fadeOutClock); frame1.ApplyAnimationClock(OpacityProperty, fadeInClock); } }
/// <summary> /// 缓动缩放动画 (提升效率)Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = 20 }); /// </summary> /// <param name="element">缩放控件</param> /// <param name="aTime">缩放时间</param> /// <param name="dFrom">缩放起始值(推荐1)</param> /// <param name="dTo">缩放结束值(推荐1.5)</param> /// <param name="aOscillations">滑过动画目标的次数(推荐5)</param> /// <param name="aSpringiness">弹簧刚度(推荐10)</param> /// <returns>返回动画对象</returns> public static AnimationClock ScaleEasingAnimation(FrameworkElement element, TimeSpan aTime, double dFrom, double dTo, int aOscillations, int aSpringiness) { ScaleTransform scale = new ScaleTransform(); element.RenderTransform = scale; element.RenderTransformOrigin = new Point(0.5, 0.5);//定义圆心位置 EasingFunctionBase easing = new ElasticEase() { EasingMode = EasingMode.EaseOut, //公式 Oscillations = aOscillations, //滑过动画目标的次数 Springiness = aSpringiness //弹簧刚度 }; DoubleAnimation scaleAnimation = new DoubleAnimation() { From = dFrom, //起始值 To = dTo, //结束值 EasingFunction = easing, //缓动函数 Duration = aTime //动画播放时间 }; AnimationClock clock = scaleAnimation.CreateClock(); scale.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock); scale.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock); return(clock); }
private void CreateCanvasAnimationClock(Canvas canvas, double fromValue, double toValue, Duration duration) { chartAnimation = new DoubleAnimation(fromValue, toValue, duration, FillBehavior.HoldEnd); chartAnimation.BeginTime = null; _chartClock = (AnimationClock)chartAnimation.CreateClock(); canvas.ApplyAnimationClock(Canvas.LeftProperty, _chartClock, HandoffBehavior.SnapshotAndReplace); }
// instead of using content named parts, it is possible to anime a property // then bound in the content file (see Button3D.PressEffect). //public double FrameRingAngle //{ // get { return (double)GetValue(FrameRingAngleProperty); } // set { SetValue(FrameRingAngleProperty, value); } //} //// Using a DependencyProperty as the backing store for FrameRingAngle. This enables animation, styling, binding, etc... //public static readonly DependencyProperty FrameRingAngleProperty = // DependencyProperty.Register( // "FrameRingAngle", // typeof(double), // typeof(Gyroscope3D), // new UIPropertyMetadata(0.0)); /// <summary> /// Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element. /// </summary> /// <param name="e">The MouseButtonEventArgs that contains the event data.</param> protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e) { if (!_isAnimated) { // Initialization of the animation objects : on 360 degrees after the current angle // _frameRingAngleAnimation.To = FrameRingAngle + 360.0; _frameRingAngleAnimation.To = _frameRingRotation.Angle + 360.0; _ringModelAngleAnimation.To = _ringModelRotation.Angle + 360.0; _rotorAngleAnimation.To = _rotorRotation.Angle - 360.0; // Triggers the animation on the FrameRingAngle property //this.ApplyAnimationClock( // FrameRingAngleProperty, // _frameRingAngleAnimation.CreateClock()); // Triggers the animation on the _frameRingAngleAnimation.Angle property _frameRingRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, _frameRingAngleAnimation.CreateClock()); // Triggers the animation on the _ringModelRotation.Angle property _ringModelRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, _ringModelAngleAnimation.CreateClock()); // Triggers the animation on the _rotorRotation.Angle property _rotorRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, _rotorAngleAnimation.CreateClock()); } else { // current angle memorization // double frameRingAngle = FrameRingAngle; double frameRingAngle = _frameRingRotation.Angle; double ringModelRotationAngle = _ringModelRotation.Angle; double rotorRotationAngle = _rotorRotation.Angle; // Halts the animations // this.ApplyAnimationClock(FrameRingAngleProperty, null); _frameRingRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, null); _ringModelRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, null); _rotorRotation.ApplyAnimationClock( AxisAngleRotation3D.AngleProperty, null); // Reassignment of the angle (which otherwise resumes its initial value) _rotorRotation.Angle = rotorRotationAngle; _ringModelRotation.Angle = ringModelRotationAngle; _frameRingRotation.Angle = frameRingAngle; // FrameRingAngle = frameRingAngle; } _isAnimated = !_isAnimated; base.OnMouseLeftButtonDown(e); }
public void ClockPlay() { DoubleAnimation tmp = new DoubleAnimation(1, 1, TimeSpan.FromMinutes(3)); tmp.RepeatBehavior = RepeatBehavior.Forever; mainClock = tmp.CreateClock(); mainClock.CurrentTimeInvalidated += mainClock_CurrentTimeInvalidated; demoTxt.ApplyAnimationClock(OpacityProperty, clock); }
private void Box3D_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { // Initialization of the animation object : on 360 degrees after the current angle DoubleAnimation da = new DoubleAnimation(boxRotation.Angle + 360.0, new Duration(TimeSpan.FromSeconds(5.0))); da.RepeatBehavior = RepeatBehavior.Forever; // Trigger the animation on the boxRotation's Angle property boxRotation.ApplyAnimationClock(AxisAngleRotation3D.AngleProperty, da.CreateClock()); }
/// <summary> /// Animate a path's <see cref="Shape.StrokeDashOffset"/> property to a given value. /// </summary> private void ChangePathDashOffset(Path path, double to, int ms) { DoubleAnimation anim = new DoubleAnimation(path.StrokeDashOffset, to, new Duration(TimeSpan.FromMilliseconds(ms))) { EasingFunction = new CubicEase() }; path.ApplyAnimationClock(Shape.StrokeDashOffsetProperty, anim.CreateClock()); }
/// <summary> /// Flashes the control's wheel display. /// </summary> public void FlashWheel() { DoubleAnimation opacityAnimation = new DoubleAnimation( 0.5, 0, new Duration(TimeSpan.FromSeconds(1))); AnimationClock opacityClock = opacityAnimation.CreateClock(); this.mouseFill.ApplyAnimationClock(Path.OpacityProperty, opacityClock); }
void Game_NewDraw(object sender, DrawingArgs e) { Add2DWall(e); //Animate 2D Viewport double angle = 0; switch (e.Direction) { case Direction.Down: angle = 180; break; case Direction.Left: angle = 90; break; case Direction.Right: angle = 270; break; case Direction.Up: angle = 0; break; } double animatedAngle = canvasRotation.Angle; double tmp = Math.Floor(animatedAngle / 360); angle = angle + (tmp * 360); if (angle > animatedAngle) { if (Math.Abs(animatedAngle - angle) > 180) { angle -= 360; } } else { if (Math.Abs(animatedAngle - angle) > 180) { angle += 360; } } DoubleAnimation animRotation = new DoubleAnimation(angle, new Duration(new TimeSpan(0, 0, 0, 0, 300))); canvasRotation.ApplyAnimationClock(RotateTransform.AngleProperty, animRotation.CreateClock()); //3D display AddWall(e); }
/// <summary> /// The main drawing builder. /// </summary> /// <returns>Drawing.</returns> public Drawing BuildDrawing() { double toOffsetX = (1 - (this.model.Camera.Center.X * this.TileSize)) + (this.TileSize * this.model.Camera.AngleWidthTile / 2); double toOffsetY = (1 - (this.model.Camera.Center.Y * this.TileSize)) + (this.TileSize * this.model.Camera.AngleHeightTile / 2); double fromOffsetX = (1 - (this.model.Camera.CenterOld.X * this.TileSize)) + (this.TileSize * this.model.Camera.AngleWidthTile / 2); double fromOffsetY = (1 - (this.model.Camera.CenterOld.Y * this.TileSize)) + (this.TileSize * this.model.Camera.AngleHeightTile / 2); if (this.cropTrans == null) { this.cropTrans = new TranslateTransform(toOffsetX, toOffsetY); } RenderOptions.SetBitmapScalingMode(this.mainDrGr, BitmapScalingMode.NearestNeighbor); if (!this.model.Camera.Center.Equals(this.model.Camera.CenterOld)) { Duration durX = new Duration(TimeSpan.FromMilliseconds(this.moveTime * 6)); Duration durY = new Duration(TimeSpan.FromMilliseconds(this.moveTime * 3)); DoubleAnimation cropAnimX = new DoubleAnimation(this.cropTrans == null ? fromOffsetX : (double)this.cropTrans.GetValue(TranslateTransform.XProperty), toOffsetX, durX); DoubleAnimation cropAnimY = new DoubleAnimation(this.cropTrans == null ? fromOffsetY : (double)this.cropTrans.GetValue(TranslateTransform.YProperty), toOffsetY, durY); cropAnimX.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 1.3 }; cropAnimY.EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseInOut, Power = 1.3 }; this.clockX = cropAnimX.CreateClock(); this.clockY = cropAnimY.CreateClock(); this.cropTrans.ApplyAnimationClock(TranslateTransform.XProperty, this.clockX); this.cropTrans.ApplyAnimationClock(TranslateTransform.YProperty, this.clockY); } this.mainDrGr.Transform = this.cropTrans; this.mainDrGr.Children = new DrawingCollection(); this.mainDrGr.Children.Add(this.GetBackGroundDrawing()); this.mainDrGr.Children.Add(this.titaniums); this.mainDrGr.Children.Add(this.GetWallsDrawing()); this.mainDrGr.Children.Add(this.GetDirtsDrawing()); this.mainDrGr.Children.Add(this.GetFirefliesDrawing()); this.mainDrGr.Children.Add(this.GetButterfliesDrawing()); this.mainDrGr.Children.Add(this.GetDiamondsDrawing()); this.mainDrGr.Children.Add(this.GetExitDrawing()); this.mainDrGr.Children.Add(this.GetBouldersDrawing()); if (!this.model.GameOver) { this.mainDrGr.Children.Add(this.GetRockfordDrawing()); } this.mainDrGr.Children.Add(this.GetExplodeDrawing(this.animatedVisualBrushes[nameof(Properties.Resources.Explode)])); return(this.mainDrGr); // TODO minimalize new calls }
protected override void OnRender(DrawingContext dc) { var da = new DoubleAnimation(100, 10, TimeSpan.FromSeconds(5)); da.AutoReverse = true; var ac = da.CreateClock(); dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 5), new Point(200, 200), null, 100, ac, 100, ac); }
public Window1() { InitializeComponent(); DoubleAnimation animate = new DoubleAnimation(); animate.To = 300; animate.Duration = new Duration(TimeSpan.FromSeconds(5)); animate.RepeatBehavior = RepeatBehavior.Forever; clock = animate.CreateClock(); }
private void CloseEditGrid() { EditProgramItemGrid.Children.Clear(); DisplayProgramItemGrid.Visibility = Visibility.Visible; DoubleAnimation fade = new DoubleAnimation(1.0, 0.0, TimeSpan.FromMilliseconds(fadeTime)); fade.Completed += (send, args) => { EditProgramItemGrid.Visibility = Visibility.Hidden; }; EditProgramItemGrid.ApplyAnimationClock(OpacityProperty, fade.CreateClock()); }
protected override void OnRender(DrawingContext dc) { DoubleAnimation da = new DoubleAnimation(100, 10, TimeSpan.FromSeconds(5)); da.AutoReverse = true; //da.RepeatBehavior = RepeatBehavior.Forever; AnimationClock anim = da.CreateClock(); dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 5), new Point(200, 200), null, 100, anim, 100, anim); }
/// <summary> /// Animate the <see cref="ScaleTransform.ScaleX"/> and <see cref="ScaleTransform.ScaleY"/> /// properties of the main button to a given value. /// </summary> private void ChangeScale(double to) { DoubleAnimation anim = new DoubleAnimation(ButtonScaleTransform.ScaleX, to, new Duration(TimeSpan.FromMilliseconds(500 * to))) { EasingFunction = new ExponentialEase() }; AnimationClock clock = anim.CreateClock(); ButtonScaleTransform.ApplyAnimationClock(ScaleTransform.ScaleXProperty, clock); ButtonScaleTransform.ApplyAnimationClock(ScaleTransform.ScaleYProperty, clock); }
void ShowContent() { if (!m_bitmapSources.Any(bs => bs.IsDownloading)) { Buzy.IsWaiting = false; Buzy.Visibility = Visibility.Collapsed; Cnt.IsHitTestVisible = true; m_clock = m_opacityAnimation.CreateClock(); m_clock.Completed += clock_Completed; Cnt.ApplyAnimationClock(OpacityProperty, m_clock); } }
void AnimateOut() { var animation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(EASE_IN_TIME))); var clock = animation.CreateClock(); ApplyAnimationClock(Grid.OpacityProperty, clock); clock.Completed += (s, e2) => { var args = new RoutedEventArgs(DoneEvent); RaiseEvent(args); }; HideTouchKeyboard(); }