Commit ec7e1c69981e8cd83d3f3d25df3e52fda2694041
1 parent
2105531904
Exists in
master
2063 : Commit source
Showing 5 changed files with 134 additions and 24 deletions Side-by-side Diff
sources/RoboforkApp/RoboforkMenu.xaml
| ... | ... | @@ -64,19 +64,17 @@ |
| 64 | 64 | FontSize="17" |
| 65 | 65 | Name="VehicleAddTree" |
| 66 | 66 | Selected="GetVehicleAddTree" |
| 67 | - Unselected="SetVehicleAddTree"> | |
| 67 | + Unselected="btnMenu_UnselectedSet" Tag="VehicleAddTree"> | |
| 68 | 68 | </TreeViewItem> |
| 69 | 69 | <TreeViewItem Header="--------------------"> |
| 70 | 70 | </TreeViewItem> |
| 71 | 71 | </TreeViewItem> |
| 72 | 72 | |
| 73 | - <TreeViewItem Header="Work" | |
| 74 | - FontSize="17"> | |
| 75 | - <TreeViewItem Header="Task patterm [FK15_#1]" | |
| 76 | - FontSize="17" | |
| 73 | + <TreeViewItem Header="Work" FontSize="17"> | |
| 74 | + <TreeViewItem Header="Task patterm [FK15_#1]" FontSize="17" | |
| 77 | 75 | Name="TaskpattermTree" |
| 78 | - Selected="GetTaskpattermTree" | |
| 79 | - Unselected="SetTaskpattermTree"> | |
| 76 | + Selected="btnMenu_Selected" | |
| 77 | + Unselected="btnMenu_UnselectedSet" Tag="TaskpattermTree"> | |
| 80 | 78 | </TreeViewItem> |
| 81 | 79 | <TreeViewItem Header="[+]" |
| 82 | 80 | FontSize="17" |
sources/RoboforkApp/RoboforkMenu.xaml.cs
| ... | ... | @@ -84,6 +84,9 @@ |
| 84 | 84 | |
| 85 | 85 | DoBeginSetSchedule(); |
| 86 | 86 | break; |
| 87 | + case "TaskpattermTree": | |
| 88 | + DoBeginTask(); | |
| 89 | + break; | |
| 87 | 90 | default: |
| 88 | 91 | break; |
| 89 | 92 | } |
| ... | ... | @@ -146,6 +149,11 @@ |
| 146 | 149 | default: |
| 147 | 150 | break; |
| 148 | 151 | } |
| 152 | + } | |
| 153 | + | |
| 154 | + private void DoBeginTask() | |
| 155 | + { | |
| 156 | + MyScheduleCanvas.CreateSimulation(); | |
| 149 | 157 | } |
| 150 | 158 | |
| 151 | 159 | private void DoBeginSetAutoNotes() |
sources/RoboforkApp/ScheduleCanvas.cs
| ... | ... | @@ -6,32 +6,55 @@ |
| 6 | 6 | using System.Windows; |
| 7 | 7 | using System.Windows.Controls; |
| 8 | 8 | using System.Windows.Media; |
| 9 | +using System.Windows.Media.Animation; | |
| 9 | 10 | using System.Windows.Shapes; |
| 10 | 11 | |
| 11 | 12 | namespace RoboforkApp |
| 12 | 13 | { |
| 13 | 14 | public class ScheduleCanvas : Canvas |
| 14 | 15 | { |
| 15 | - // Add variable for Set Schedule | |
| 16 | - private Path pScheduleNode = new Path(); | |
| 17 | - private Path pScheduleLine = new Path(); | |
| 18 | - private GeometryGroup gGrpScheduleNode = new GeometryGroup(); | |
| 19 | - private GeometryGroup gGrpScheduleLine = new GeometryGroup(); | |
| 16 | + private simulationRobo simulation; | |
| 20 | 17 | |
| 21 | - public void DrawRoute(List<ucNode> listNode) | |
| 18 | + public void CreateSimulation() | |
| 22 | 19 | { |
| 23 | - //Update after | |
| 24 | - } | |
| 20 | + if(simulation != null || this.Children.Count < 2) | |
| 21 | + { | |
| 22 | + return; | |
| 23 | + } | |
| 25 | 24 | |
| 26 | - private void CreateNode(Point point, int indexNode) | |
| 27 | - { | |
| 28 | - ucNode _ucNode = new ucNode(); | |
| 29 | - _ucNode.btnWidth = 20.0; | |
| 30 | - _ucNode.btnHeight = 20.0; | |
| 31 | - _ucNode.txtNode = indexNode.ToString(); | |
| 32 | - Canvas.SetLeft(_ucNode, point.X); | |
| 33 | - Canvas.SetTop(_ucNode, point.Y); | |
| 34 | - this.Children.Add(_ucNode); | |
| 25 | + PathGeometry animationPath = new PathGeometry(); | |
| 26 | + PathFigure pFigure = new PathFigure(); | |
| 27 | + pFigure.StartPoint = new Point(50, 65); | |
| 28 | + LineSegment lineSegment = new LineSegment(); | |
| 29 | + lineSegment.Point = new Point(1270, 65); | |
| 30 | + pFigure.Segments.Add(lineSegment); | |
| 31 | + animationPath.Figures.Add(pFigure); | |
| 32 | + | |
| 33 | + // Freeze the PathGeometry for performance benefits. | |
| 34 | + animationPath.Freeze(); | |
| 35 | + | |
| 36 | + // Create a MatrixAnimationUsingPath to move the | |
| 37 | + // button along the path by animating | |
| 38 | + // its MatrixTransform. | |
| 39 | + MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath(); | |
| 40 | + matrixAnimation.PathGeometry = animationPath; | |
| 41 | + matrixAnimation.Duration = TimeSpan.FromSeconds(10); | |
| 42 | + //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever; | |
| 43 | + matrixAnimation.AutoReverse = false; | |
| 44 | + matrixAnimation.DoesRotateWithTangent = true; | |
| 45 | + | |
| 46 | + // Set the animation to target the Matrix property | |
| 47 | + // of the MatrixTransform named "ButtonMatrixTransform". | |
| 48 | + Storyboard.SetTargetName(matrixAnimation, "fl"); | |
| 49 | + Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty)); | |
| 50 | + | |
| 51 | + // Create a Storyboard to contain and apply the animation. | |
| 52 | + Storyboard pathAnimationStoryboard = new Storyboard(); | |
| 53 | + pathAnimationStoryboard.Children.Add(matrixAnimation); | |
| 54 | + | |
| 55 | + simulation = new simulationRobo(); | |
| 56 | + simulation.storyBoard = pathAnimationStoryboard; | |
| 57 | + this.Children.Add(simulation); | |
| 35 | 58 | } |
| 36 | 59 | } |
| 37 | 60 | } |
sources/RoboforkApp/UserControls/simulationRobo.xaml
| 1 | +<UserControl x:Class="RoboforkApp.simulationRobo" | |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
| 4 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
| 5 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
| 6 | + mc:Ignorable="d" | |
| 7 | + x:Name="SimulationRobo"> | |
| 8 | + <Path Name="smuliRobo" Stroke="Orange" StrokeThickness="2" Fill="Orange" RenderTransformOrigin="0.5,0.5" Margin="0,0"> | |
| 9 | + <Path.Effect> | |
| 10 | + <DropShadowEffect BlurRadius="20" Opacity="0.5" ShadowDepth="4" /> | |
| 11 | + </Path.Effect> | |
| 12 | + <Path.Data> | |
| 13 | + <PathGeometry> | |
| 14 | + <PathGeometry.Figures> | |
| 15 | + <PathFigure StartPoint="0,0" IsClosed="True"> | |
| 16 | + <LineSegment Point="40,0"/> | |
| 17 | + <LineSegment Point="60,15"/> | |
| 18 | + <LineSegment Point="40,30"/> | |
| 19 | + <LineSegment Point="0,30"/> | |
| 20 | + </PathFigure> | |
| 21 | + </PathGeometry.Figures> | |
| 22 | + </PathGeometry> | |
| 23 | + </Path.Data> | |
| 24 | + | |
| 25 | + <Path.RenderTransform> | |
| 26 | + <TransformGroup> | |
| 27 | + <MatrixTransform x:Name="fl"> | |
| 28 | + <MatrixTransform.Matrix> | |
| 29 | + <Matrix /> | |
| 30 | + </MatrixTransform.Matrix> | |
| 31 | + </MatrixTransform> | |
| 32 | + </TransformGroup> | |
| 33 | + </Path.RenderTransform> | |
| 34 | + | |
| 35 | + <Path.Triggers> | |
| 36 | + <EventTrigger RoutedEvent="FrameworkElement.Loaded"> | |
| 37 | + <BeginStoryboard Storyboard="{Binding storyBoard, ElementName=SimulationRobo}" > | |
| 38 | + </BeginStoryboard> | |
| 39 | + </EventTrigger> | |
| 40 | + </Path.Triggers> | |
| 41 | + </Path> | |
| 42 | +</UserControl> |
sources/RoboforkApp/UserControls/simulationRobo.xaml.cs
| 1 | +using System; | |
| 2 | +using System.Collections.Generic; | |
| 3 | +using System.Linq; | |
| 4 | +using System.Text; | |
| 5 | +using System.Threading.Tasks; | |
| 6 | +using System.Windows; | |
| 7 | +using System.Windows.Controls; | |
| 8 | +using System.Windows.Data; | |
| 9 | +using System.Windows.Documents; | |
| 10 | +using System.Windows.Input; | |
| 11 | +using System.Windows.Media; | |
| 12 | +using System.Windows.Media.Animation; | |
| 13 | +using System.Windows.Media.Imaging; | |
| 14 | +using System.Windows.Navigation; | |
| 15 | +using System.Windows.Shapes; | |
| 16 | + | |
| 17 | +namespace RoboforkApp | |
| 18 | +{ | |
| 19 | + /// <summary> | |
| 20 | + /// Interaction logic for simulationRobo.xaml | |
| 21 | + /// </summary> | |
| 22 | + public partial class simulationRobo : UserControl | |
| 23 | + { | |
| 24 | + public static readonly DependencyProperty storyBoardProperty = | |
| 25 | + DependencyProperty.Register("storyBoard", typeof(Storyboard), | |
| 26 | + typeof(simulationRobo), new FrameworkPropertyMetadata(new Storyboard())); | |
| 27 | + | |
| 28 | + public simulationRobo() | |
| 29 | + { | |
| 30 | + InitializeComponent(); | |
| 31 | + } | |
| 32 | + | |
| 33 | + public Storyboard storyBoard | |
| 34 | + { | |
| 35 | + get { return (Storyboard)GetValue(storyBoardProperty); } | |
| 36 | + set { SetValue(storyBoardProperty, value); } | |
| 37 | + } | |
| 38 | + } | |
| 39 | +} |