Blame view

sources/RoboforkApp/ScheduleCanvas.cs 2.18 KB
d55d921a3   toan   2045: Draw Schedule
1
2
3
4
5
6
7
8
  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;
ec7e1c699   toan   2063 : Commit source
9
  using System.Windows.Media.Animation;
d55d921a3   toan   2045: Draw Schedule
10
11
12
13
14
15
  using System.Windows.Shapes;
  
  namespace RoboforkApp
  {
      public class ScheduleCanvas : Canvas
      {
ec7e1c699   toan   2063 : Commit source
16
          private simulationRobo simulation;
d55d921a3   toan   2045: Draw Schedule
17

ec7e1c699   toan   2063 : Commit source
18
          public void CreateSimulation()
d55d921a3   toan   2045: Draw Schedule
19
          {
ec7e1c699   toan   2063 : Commit source
20
21
22
23
              if(simulation != null || this.Children.Count < 2)
              {
                  return;
              }
d55d921a3   toan   2045: Draw Schedule
24

ec7e1c699   toan   2063 : Commit source
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
              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);
d55d921a3   toan   2045: Draw Schedule
58
59
60
          }
      }
  }