using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace RoboforkApp { public class ScheduleCanvas : Canvas { private simulationRobo simulation; public void CreateSimulation() { if(simulation != null || this.Children.Count < 2) { return; } PathGeometry animationPath = new PathGeometry(); PathFigure pFigure = new PathFigure(); pFigure.StartPoint = new Point(50, 65); LineSegment lineSegment = new LineSegment(); lineSegment.Point = new Point(1270, 65); pFigure.Segments.Add(lineSegment); animationPath.Figures.Add(pFigure); // Freeze the PathGeometry for performance benefits. animationPath.Freeze(); // Create a MatrixAnimationUsingPath to move the // button along the path by animating // its MatrixTransform. MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath(); matrixAnimation.PathGeometry = animationPath; matrixAnimation.Duration = TimeSpan.FromSeconds(10); //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever; matrixAnimation.AutoReverse = false; matrixAnimation.DoesRotateWithTangent = true; // Set the animation to target the Matrix property // of the MatrixTransform named "ButtonMatrixTransform". Storyboard.SetTargetName(matrixAnimation, "fl"); Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty)); // Create a Storyboard to contain and apply the animation. Storyboard pathAnimationStoryboard = new Storyboard(); pathAnimationStoryboard.Children.Add(matrixAnimation); simulation = new simulationRobo(); simulation.storyBoard = pathAnimationStoryboard; this.Children.Add(simulation); } } }