Commit d55d921a3b4a4b2d541b6e12867fdcd09db72268
1 parent
160b9bec85
Exists in
master
2045: Draw Schedule
Showing 4 changed files with 64 additions and 9 deletions Inline Diff
sources/RoboforkApp/DesignerCanvas.cs
| 1 | using System; | 1 | using System; |
| 2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
| 3 | using System.Linq; | 3 | using System.Linq; |
| 4 | using System.Windows; | 4 | using System.Windows; |
| 5 | using System.Windows.Controls; | 5 | using System.Windows.Controls; |
| 6 | using System.Windows.Documents; | 6 | using System.Windows.Documents; |
| 7 | using System.Windows.Input; | 7 | using System.Windows.Input; |
| 8 | using System.Windows.Markup; | 8 | using System.Windows.Markup; |
| 9 | using System.Windows.Media; | 9 | using System.Windows.Media; |
| 10 | using System.Windows.Shapes; | 10 | using System.Windows.Shapes; |
| 11 | using System.Xml; | 11 | using System.Xml; |
| 12 | 12 | ||
| 13 | namespace RoboforkApp | 13 | namespace RoboforkApp |
| 14 | { | 14 | { |
| 15 | public class DesignerCanvas : Canvas | 15 | public class DesignerCanvas : Canvas |
| 16 | { | 16 | { |
| 17 | const double RADIUS_NODE = 25d; //8d; | 17 | const double RADIUS_NODE = 25d; //8d; |
| 18 | const double RADIUS_CURVER_LINE = 130d; | 18 | const double RADIUS_CURVER_LINE = 130d; |
| 19 | const double DISTANCE_AUTO_NODES = 100d; | 19 | const double DISTANCE_AUTO_NODES = 100d; |
| 20 | const double DISTANCE_START_NODES = 30d; | 20 | const double DISTANCE_START_NODES = 30d; |
| 21 | const double DISTANCE_END_NODES = 30d; | 21 | const double DISTANCE_END_NODES = 30d; |
| 22 | const double DISTANCE_FREE_NODES = 40d; | 22 | const double DISTANCE_FREE_NODES = 40d; |
| 23 | const double STROKE_ROOT_LINE = 6d; | 23 | const double STROKE_ROOT_LINE = 6d; |
| 24 | const double STROKE_LINE = 4d; | 24 | const double STROKE_LINE = 4d; |
| 25 | const double STROKE_NODE = 1d; | 25 | const double STROKE_NODE = 1d; |
| 26 | const double DISTANCE_RATIO = 100; | 26 | const double DISTANCE_RATIO = 100; |
| 27 | 27 | ||
| 28 | private List<Rectangle> shapeList = new List<Rectangle>(); | 28 | private List<Rectangle> shapeList = new List<Rectangle>(); |
| 29 | private TextBlock shapePosIndicator; | 29 | private TextBlock shapePosIndicator; |
| 30 | private TextBlock shapeSizeIndicator; | 30 | private TextBlock shapeSizeIndicator; |
| 31 | private int currentLine; | 31 | private int currentLine; |
| 32 | private ucStartEndButton _startPoint; | 32 | private ucStartEndButton _startPoint; |
| 33 | private ucStartEndButton _goalPoint; | 33 | private ucStartEndButton _goalPoint; |
| 34 | private ucDisplayCoordinate _displayAxiPosition; | 34 | private ucDisplayCoordinate _displayAxiPosition; |
| 35 | 35 | ||
| 36 | // Add variable for draw route | 36 | // Add variable for draw route |
| 37 | public Path pLine = new Path(); | 37 | public Path pLine = new Path(); |
| 38 | public Path pRootLine = new Path(); | 38 | public Path pRootLine = new Path(); |
| 39 | public Path pCurverLine = new Path(); | 39 | public Path pCurverLine = new Path(); |
| 40 | public Path pRedNode = new Path(); | 40 | public Path pRedNode = new Path(); |
| 41 | public Path pYellowNode = new Path(); | 41 | public Path pYellowNode = new Path(); |
| 42 | public GeometryGroup gGrpLine = new GeometryGroup(); | 42 | public GeometryGroup gGrpLine = new GeometryGroup(); |
| 43 | public GeometryGroup gGrpRootLine = new GeometryGroup(); | 43 | public GeometryGroup gGrpRootLine = new GeometryGroup(); |
| 44 | public GeometryGroup gGrpCurverLine = new GeometryGroup(); | 44 | public GeometryGroup gGrpCurverLine = new GeometryGroup(); |
| 45 | public GeometryGroup gGrpRedNode = new GeometryGroup(); | 45 | public GeometryGroup gGrpRedNode = new GeometryGroup(); |
| 46 | public GeometryGroup gGrpYellowNode = new GeometryGroup(); | 46 | public GeometryGroup gGrpYellowNode = new GeometryGroup(); |
| 47 | public int currentShape; | 47 | public int currentShape; |
| 48 | public static bool isStartDrawRoute = false; | 48 | public static bool isStartDrawRoute = false; |
| 49 | public static bool isGoalDrawRoute = false; | 49 | public static bool isGoalDrawRoute = false; |
| 50 | 50 | ||
| 51 | public struct NodeInfo | 51 | public struct NodeInfo |
| 52 | { | 52 | { |
| 53 | public double X; | 53 | public double X; |
| 54 | public double Y; | 54 | public double Y; |
| 55 | public String Mode1; | 55 | public String Mode1; |
| 56 | public String Mode2; | 56 | public String Mode2; |
| 57 | public String Mode3; | 57 | public String Mode3; |
| 58 | } | 58 | } |
| 59 | List<NodeInfo> NodeInfo_List = new List<NodeInfo>(); | 59 | List<NodeInfo> NodeInfo_List = new List<NodeInfo>(); |
| 60 | 60 | ||
| 61 | // Add variable for Set Schedule | 61 | // Add variable for Set Schedule |
| 62 | public Path pScheduleNode = new Path(); | 62 | public Path pScheduleNode = new Path(); |
| 63 | public Path pScheduleLine = new Path(); | 63 | public Path pScheduleLine = new Path(); |
| 64 | public GeometryGroup gGrpScheduleNode = new GeometryGroup(); | 64 | public GeometryGroup gGrpScheduleNode = new GeometryGroup(); |
| 65 | public GeometryGroup gGrpScheduleLine = new GeometryGroup(); | 65 | public GeometryGroup gGrpScheduleLine = new GeometryGroup(); |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | //2017/03/04 NAM ADD START | 68 | //2017/03/04 NAM ADD START |
| 69 | public static bool isDrawingNode = false; | 69 | public static bool isDrawingNode = false; |
| 70 | public Path pNewLine = new Path(); | 70 | public Path pNewLine = new Path(); |
| 71 | public GeometryGroup gGrpNewLine = new GeometryGroup(); | 71 | public GeometryGroup gGrpNewLine = new GeometryGroup(); |
| 72 | 72 | ||
| 73 | public struct NewNodeInfo | 73 | public struct NewNodeInfo |
| 74 | { | 74 | { |
| 75 | public double X; | 75 | public double X; |
| 76 | public double Y; | 76 | public double Y; |
| 77 | public String Mode; | 77 | public String Mode; |
| 78 | } | 78 | } |
| 79 | List<NewNodeInfo> NewNodeInfo_List = new List<NewNodeInfo>(); | 79 | List<NewNodeInfo> NewNodeInfo_List = new List<NewNodeInfo>(); |
| 80 | List<TextBlock> NodeNo = new List<TextBlock>(); | 80 | List<TextBlock> NodeNo = new List<TextBlock>(); |
| 81 | List<ucNode> ucNode_Lst = new List<ucNode>(); | 81 | List<ucNode> ucNode_Lst = new List<ucNode>(); |
| 82 | int stt = 1; | 82 | int stt = 1; |
| 83 | //2017/03/04 NAM ADD END | 83 | //2017/03/04 NAM ADD END |
| 84 | 84 | ||
| 85 | 85 | ||
| 86 | public ScheduleCanvas scheduleCanvas; | ||
| 86 | 87 | ||
| 87 | 88 | ||
| 88 | |||
| 89 | // Add variable for Set Auto Nodes | 89 | // Add variable for Set Auto Nodes |
| 90 | public Path pBlueNode = new Path(); | 90 | public Path pBlueNode = new Path(); |
| 91 | private GeometryGroup gGrpBlueNode = new GeometryGroup(); | 91 | private GeometryGroup gGrpBlueNode = new GeometryGroup(); |
| 92 | 92 | ||
| 93 | // Add variable for Set Free Nodes | 93 | // Add variable for Set Free Nodes |
| 94 | public Path pFreeNode = new Path(); | 94 | public Path pFreeNode = new Path(); |
| 95 | //private GeometryGroup gGrpFreeNode = new GeometryGroup(); | 95 | //private GeometryGroup gGrpFreeNode = new GeometryGroup(); |
| 96 | 96 | ||
| 97 | // The part of the rectangle the mouse is over. | 97 | // The part of the rectangle the mouse is over. |
| 98 | private enum HitType | 98 | private enum HitType |
| 99 | { | 99 | { |
| 100 | None, Body, UL, UR, LR, LL, L, R, T, B | 100 | None, Body, UL, UR, LR, LL, L, R, T, B |
| 101 | }; | 101 | }; |
| 102 | public enum OperationState | 102 | public enum OperationState |
| 103 | { | 103 | { |
| 104 | None, DrawObstract, DrawRoute, DrawSetFreeNode, EditNode, NewDrawSetFreeNode | 104 | None, DrawObstract, DrawRoute, DrawSetFreeNode, EditNode, NewDrawSetFreeNode |
| 105 | }; | 105 | }; |
| 106 | public enum MouseState | 106 | public enum MouseState |
| 107 | { | 107 | { |
| 108 | None, Draw, Drag, | 108 | None, Draw, Drag, |
| 109 | } | 109 | } |
| 110 | public OperationState Operation = OperationState.None; | 110 | public OperationState Operation = OperationState.None; |
| 111 | public MouseState mouseState = MouseState.None; | 111 | public MouseState mouseState = MouseState.None; |
| 112 | 112 | ||
| 113 | // The draw start point. | 113 | // The draw start point. |
| 114 | private Point StartDrawPoint; | 114 | private Point StartDrawPoint; |
| 115 | 115 | ||
| 116 | // The drag's last point. | 116 | // The drag's last point. |
| 117 | private Point LastPoint; | 117 | private Point LastPoint; |
| 118 | 118 | ||
| 119 | // The part of the rectangle under the mouse. | 119 | // The part of the rectangle under the mouse. |
| 120 | HitType MouseHitType = HitType.None; | 120 | HitType MouseHitType = HitType.None; |
| 121 | 121 | ||
| 122 | public void Init() { | 122 | public void Init() { |
| 123 | if (shapePosIndicator == null) | 123 | if (shapePosIndicator == null) |
| 124 | { | 124 | { |
| 125 | shapePosIndicator = new TextBlock() | 125 | shapePosIndicator = new TextBlock() |
| 126 | { | 126 | { |
| 127 | Foreground = Brushes.Black, | 127 | Foreground = Brushes.Black, |
| 128 | Background = Brushes.Transparent, | 128 | Background = Brushes.Transparent, |
| 129 | FontSize = 20, | 129 | FontSize = 20, |
| 130 | }; | 130 | }; |
| 131 | } | 131 | } |
| 132 | if (shapeSizeIndicator == null) | 132 | if (shapeSizeIndicator == null) |
| 133 | { | 133 | { |
| 134 | shapeSizeIndicator = new TextBlock() | 134 | shapeSizeIndicator = new TextBlock() |
| 135 | { | 135 | { |
| 136 | Foreground = Brushes.Black, | 136 | Foreground = Brushes.Black, |
| 137 | Background = Brushes.Transparent, | 137 | Background = Brushes.Transparent, |
| 138 | FontSize = 20, | 138 | FontSize = 20, |
| 139 | }; | 139 | }; |
| 140 | } | 140 | } |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | // Return a HitType value to indicate what is at the point. | 143 | // Return a HitType value to indicate what is at the point. |
| 144 | private HitType SetHitType(Point point) | 144 | private HitType SetHitType(Point point) |
| 145 | { | 145 | { |
| 146 | if (shapeList.Count == 0) | 146 | if (shapeList.Count == 0) |
| 147 | { | 147 | { |
| 148 | currentShape = 0; | 148 | currentShape = 0; |
| 149 | return HitType.None; | 149 | return HitType.None; |
| 150 | } | 150 | } |
| 151 | for (int i = 0; i < shapeList.Count; i++) | 151 | for (int i = 0; i < shapeList.Count; i++) |
| 152 | { | 152 | { |
| 153 | Rectangle rect = shapeList[i]; | 153 | Rectangle rect = shapeList[i]; |
| 154 | double left = Canvas.GetLeft(rect); | 154 | double left = Canvas.GetLeft(rect); |
| 155 | double top = Canvas.GetTop(rect); | 155 | double top = Canvas.GetTop(rect); |
| 156 | double right = left + rect.Width; | 156 | double right = left + rect.Width; |
| 157 | double bottom = top + rect.Height; | 157 | double bottom = top + rect.Height; |
| 158 | if (point.X < left) continue; | 158 | if (point.X < left) continue; |
| 159 | if (point.X > right) continue; | 159 | if (point.X > right) continue; |
| 160 | if (point.Y < top) continue; | 160 | if (point.Y < top) continue; |
| 161 | if (point.Y > bottom) continue; | 161 | if (point.Y > bottom) continue; |
| 162 | currentShape = i; | 162 | currentShape = i; |
| 163 | 163 | ||
| 164 | const double GAP = 10; | 164 | const double GAP = 10; |
| 165 | if (point.X - left < GAP) | 165 | if (point.X - left < GAP) |
| 166 | { | 166 | { |
| 167 | // Left edge. | 167 | // Left edge. |
| 168 | if (point.Y - top < GAP) return HitType.UL; | 168 | if (point.Y - top < GAP) return HitType.UL; |
| 169 | if (bottom - point.Y < GAP) return HitType.LL; | 169 | if (bottom - point.Y < GAP) return HitType.LL; |
| 170 | return HitType.L; | 170 | return HitType.L; |
| 171 | } | 171 | } |
| 172 | if (right - point.X < GAP) | 172 | if (right - point.X < GAP) |
| 173 | { | 173 | { |
| 174 | // Right edge. | 174 | // Right edge. |
| 175 | if (point.Y - top < GAP) return HitType.UR; | 175 | if (point.Y - top < GAP) return HitType.UR; |
| 176 | if (bottom - point.Y < GAP) return HitType.LR; | 176 | if (bottom - point.Y < GAP) return HitType.LR; |
| 177 | return HitType.R; | 177 | return HitType.R; |
| 178 | } | 178 | } |
| 179 | if (point.Y - top < GAP) return HitType.T; | 179 | if (point.Y - top < GAP) return HitType.T; |
| 180 | if (bottom - point.Y < GAP) return HitType.B; | 180 | if (bottom - point.Y < GAP) return HitType.B; |
| 181 | return HitType.Body; | 181 | return HitType.Body; |
| 182 | } | 182 | } |
| 183 | currentShape = 0; | 183 | currentShape = 0; |
| 184 | return HitType.None; | 184 | return HitType.None; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | // Set a mouse cursor appropriate for the current hit type. | 187 | // Set a mouse cursor appropriate for the current hit type. |
| 188 | private void SetMouseCursor() | 188 | private void SetMouseCursor() |
| 189 | { | 189 | { |
| 190 | // See what cursor we should display. | 190 | // See what cursor we should display. |
| 191 | Cursor desired_cursor = Cursors.Arrow; | 191 | Cursor desired_cursor = Cursors.Arrow; |
| 192 | switch (MouseHitType) | 192 | switch (MouseHitType) |
| 193 | { | 193 | { |
| 194 | case HitType.None: | 194 | case HitType.None: |
| 195 | desired_cursor = Cursors.Arrow; | 195 | desired_cursor = Cursors.Arrow; |
| 196 | break; | 196 | break; |
| 197 | case HitType.Body: | 197 | case HitType.Body: |
| 198 | desired_cursor = Cursors.ScrollAll; | 198 | desired_cursor = Cursors.ScrollAll; |
| 199 | break; | 199 | break; |
| 200 | case HitType.UL: | 200 | case HitType.UL: |
| 201 | case HitType.LR: | 201 | case HitType.LR: |
| 202 | desired_cursor = Cursors.SizeNWSE; | 202 | desired_cursor = Cursors.SizeNWSE; |
| 203 | break; | 203 | break; |
| 204 | case HitType.LL: | 204 | case HitType.LL: |
| 205 | case HitType.UR: | 205 | case HitType.UR: |
| 206 | desired_cursor = Cursors.SizeNESW; | 206 | desired_cursor = Cursors.SizeNESW; |
| 207 | break; | 207 | break; |
| 208 | case HitType.T: | 208 | case HitType.T: |
| 209 | case HitType.B: | 209 | case HitType.B: |
| 210 | desired_cursor = Cursors.SizeNS; | 210 | desired_cursor = Cursors.SizeNS; |
| 211 | break; | 211 | break; |
| 212 | case HitType.L: | 212 | case HitType.L: |
| 213 | case HitType.R: | 213 | case HitType.R: |
| 214 | desired_cursor = Cursors.SizeWE; | 214 | desired_cursor = Cursors.SizeWE; |
| 215 | break; | 215 | break; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | // Display the desired cursor. | 218 | // Display the desired cursor. |
| 219 | if (Cursor != desired_cursor) Cursor = desired_cursor; | 219 | if (Cursor != desired_cursor) Cursor = desired_cursor; |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | // constance | 222 | // constance |
| 223 | int indicatorAligment = 2; | 223 | int indicatorAligment = 2; |
| 224 | 224 | ||
| 225 | /* | 225 | /* |
| 226 | private Point? dragStartPoint = null; | 226 | private Point? dragStartPoint = null; |
| 227 | 227 | ||
| 228 | */ | 228 | */ |
| 229 | public IEnumerable<DesignerItem> SelectedItems | 229 | public IEnumerable<DesignerItem> SelectedItems |
| 230 | { | 230 | { |
| 231 | get | 231 | get |
| 232 | { | 232 | { |
| 233 | var selectedItems = from item in this.Children.OfType<DesignerItem>() | 233 | var selectedItems = from item in this.Children.OfType<DesignerItem>() |
| 234 | where item.IsSelected == true | 234 | where item.IsSelected == true |
| 235 | select item; | 235 | select item; |
| 236 | 236 | ||
| 237 | return selectedItems; | 237 | return selectedItems; |
| 238 | } | 238 | } |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | public void DeselectAll() | 241 | public void DeselectAll() |
| 242 | { | 242 | { |
| 243 | /* | 243 | /* |
| 244 | foreach (DesignerItem item in this.SelectedItems) | 244 | foreach (DesignerItem item in this.SelectedItems) |
| 245 | { | 245 | { |
| 246 | item.IsSelected = false; | 246 | item.IsSelected = false; |
| 247 | }*/ | 247 | }*/ |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | //test | 250 | //test |
| 251 | public void AddNewNode(Point FreeNode, bool RightClick) | 251 | public void AddNewNode(Point FreeNode, bool RightClick) |
| 252 | { | 252 | { |
| 253 | pBlueNode.Stroke = new SolidColorBrush(Colors.Blue); | 253 | pBlueNode.Stroke = new SolidColorBrush(Colors.Blue); |
| 254 | pBlueNode.Fill = new SolidColorBrush(Colors.LightBlue); | 254 | pBlueNode.Fill = new SolidColorBrush(Colors.LightBlue); |
| 255 | pBlueNode.StrokeThickness = STROKE_NODE; | 255 | pBlueNode.StrokeThickness = STROKE_NODE; |
| 256 | pBlueNode.Data = gGrpBlueNode; | 256 | pBlueNode.Data = gGrpBlueNode; |
| 257 | 257 | ||
| 258 | TextBlock textBlock = new TextBlock(); | 258 | TextBlock textBlock = new TextBlock(); |
| 259 | textBlock.Text = "1"; | 259 | textBlock.Text = "1"; |
| 260 | textBlock.FontSize = 15; | 260 | textBlock.FontSize = 15; |
| 261 | textBlock.Foreground = new SolidColorBrush(Colors.White); | 261 | textBlock.Foreground = new SolidColorBrush(Colors.White); |
| 262 | Canvas.SetLeft(textBlock, FreeNode.X-5 ); | 262 | Canvas.SetLeft(textBlock, FreeNode.X-5 ); |
| 263 | Canvas.SetTop(textBlock, FreeNode.Y-8); | 263 | Canvas.SetTop(textBlock, FreeNode.Y-8); |
| 264 | 264 | ||
| 265 | AddNode(FreeNode, gGrpBlueNode); | 265 | AddNode(FreeNode, gGrpBlueNode); |
| 266 | 266 | ||
| 267 | 267 | ||
| 268 | //Ellipse myEllipse = new Ellipse(); | 268 | //Ellipse myEllipse = new Ellipse(); |
| 269 | //SolidColorBrush mySolidColorBrush = new SolidColorBrush(); | 269 | //SolidColorBrush mySolidColorBrush = new SolidColorBrush(); |
| 270 | //mySolidColorBrush.Color = Colors.Blue; | 270 | //mySolidColorBrush.Color = Colors.Blue; |
| 271 | //myEllipse.Fill = mySolidColorBrush; | 271 | //myEllipse.Fill = mySolidColorBrush; |
| 272 | //myEllipse.StrokeThickness = 2; | 272 | //myEllipse.StrokeThickness = 2; |
| 273 | //myEllipse.Stroke = Brushes.White; | 273 | //myEllipse.Stroke = Brushes.White; |
| 274 | //myEllipse.Width = 16d; | 274 | //myEllipse.Width = 16d; |
| 275 | //myEllipse.Height = 16d; | 275 | //myEllipse.Height = 16d; |
| 276 | //Canvas.SetLeft(myEllipse, FreeNode.X); | 276 | //Canvas.SetLeft(myEllipse, FreeNode.X); |
| 277 | //Canvas.SetTop(myEllipse, FreeNode.Y); | 277 | //Canvas.SetTop(myEllipse, FreeNode.Y); |
| 278 | 278 | ||
| 279 | //this.Children.Add(myEllipse); | 279 | //this.Children.Add(myEllipse); |
| 280 | //this.Children.Add(pBlueNode); | 280 | //this.Children.Add(pBlueNode); |
| 281 | this.Children.Add(textBlock); | 281 | this.Children.Add(textBlock); |
| 282 | 282 | ||
| 283 | 283 | ||
| 284 | 284 | ||
| 285 | 285 | ||
| 286 | 286 | ||
| 287 | } | 287 | } |
| 288 | //test | 288 | //test |
| 289 | 289 | ||
| 290 | protected override void OnMouseDown(MouseButtonEventArgs e) | 290 | protected override void OnMouseDown(MouseButtonEventArgs e) |
| 291 | { | 291 | { |
| 292 | base.OnMouseDown(e); | 292 | base.OnMouseDown(e); |
| 293 | 293 | ||
| 294 | MouseHitType = SetHitType(Mouse.GetPosition(this)); | 294 | MouseHitType = SetHitType(Mouse.GetPosition(this)); |
| 295 | SetMouseCursor(); | 295 | SetMouseCursor(); |
| 296 | 296 | ||
| 297 | if (Operation == OperationState.DrawRoute && isStartDrawRoute) | 297 | if (Operation == OperationState.DrawRoute && isStartDrawRoute) |
| 298 | { | 298 | { |
| 299 | if (isGoalDrawRoute) | 299 | if (isGoalDrawRoute) |
| 300 | { | 300 | { |
| 301 | return; | 301 | return; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | // Check state draw | 304 | // Check state draw |
| 305 | if (MouseHitType == HitType.None) | 305 | if (MouseHitType == HitType.None) |
| 306 | { | 306 | { |
| 307 | if (gGrpLine.Children.Count == 1) | 307 | if (gGrpLine.Children.Count == 1) |
| 308 | { | 308 | { |
| 309 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[0]; | 309 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[0]; |
| 310 | lineGeometry.EndPoint = LastPoint; | 310 | lineGeometry.EndPoint = LastPoint; |
| 311 | 311 | ||
| 312 | // Check end route | 312 | // Check end route |
| 313 | if (IsEndRoute(_goalPoint, lineGeometry)) | 313 | if (IsEndRoute(_goalPoint, lineGeometry)) |
| 314 | { | 314 | { |
| 315 | isGoalDrawRoute = true; | 315 | isGoalDrawRoute = true; |
| 316 | ProcessEndRoute(); | 316 | ProcessEndRoute(); |
| 317 | return; | 317 | return; |
| 318 | } | 318 | } |
| 319 | } | 319 | } |
| 320 | else if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 1] | 320 | else if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 1] |
| 321 | , (LineGeometry)gGrpLine.Children[currentLine])) | 321 | , (LineGeometry)gGrpLine.Children[currentLine])) |
| 322 | { | 322 | { |
| 323 | // Set end point to finish draw line | 323 | // Set end point to finish draw line |
| 324 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine]; | 324 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine]; |
| 325 | lineGeometry.EndPoint = LastPoint; | 325 | lineGeometry.EndPoint = LastPoint; |
| 326 | 326 | ||
| 327 | // Add node to curver postion | 327 | // Add node to curver postion |
| 328 | AddNode(lineGeometry.StartPoint, gGrpRedNode); | 328 | AddNode(lineGeometry.StartPoint, gGrpRedNode); |
| 329 | 329 | ||
| 330 | // Check end route | 330 | // Check end route |
| 331 | if (IsEndRoute(_goalPoint, lineGeometry)) | 331 | if (IsEndRoute(_goalPoint, lineGeometry)) |
| 332 | { | 332 | { |
| 333 | isGoalDrawRoute = true; | 333 | isGoalDrawRoute = true; |
| 334 | ProcessEndRoute(); | 334 | ProcessEndRoute(); |
| 335 | return; | 335 | return; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | // Draw curver line | 338 | // Draw curver line |
| 339 | //DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 1], (LineGeometry)gGrpLine.Children[currentLine]); | 339 | //DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 1], (LineGeometry)gGrpLine.Children[currentLine]); |
| 340 | } | 340 | } |
| 341 | else | 341 | else |
| 342 | { | 342 | { |
| 343 | // Remove current line | 343 | // Remove current line |
| 344 | gGrpLine.Children.RemoveAt(currentLine); | 344 | gGrpLine.Children.RemoveAt(currentLine); |
| 345 | // Remove yellow node | 345 | // Remove yellow node |
| 346 | //if (gGrpYellowNode.Children.Count > 0) | 346 | //if (gGrpYellowNode.Children.Count > 0) |
| 347 | //{ | 347 | //{ |
| 348 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); | 348 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); |
| 349 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); | 349 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); |
| 350 | //} | 350 | //} |
| 351 | //// Remove curver line | 351 | //// Remove curver line |
| 352 | //if (gGrpCurverLine.Children.Count > 0) | 352 | //if (gGrpCurverLine.Children.Count > 0) |
| 353 | //{ | 353 | //{ |
| 354 | // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1); | 354 | // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1); |
| 355 | //} | 355 | //} |
| 356 | 356 | ||
| 357 | // Set end point to finish draw line | 357 | // Set end point to finish draw line |
| 358 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine - 1]; | 358 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine - 1]; |
| 359 | lineGeometry.EndPoint = LastPoint; | 359 | lineGeometry.EndPoint = LastPoint; |
| 360 | 360 | ||
| 361 | // Check end route | 361 | // Check end route |
| 362 | if (IsEndRoute(_goalPoint, lineGeometry)) | 362 | if (IsEndRoute(_goalPoint, lineGeometry)) |
| 363 | { | 363 | { |
| 364 | isGoalDrawRoute = true; | 364 | isGoalDrawRoute = true; |
| 365 | ProcessEndRoute(); | 365 | ProcessEndRoute(); |
| 366 | return; | 366 | return; |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | //// Re-draw cuver line | 369 | //// Re-draw cuver line |
| 370 | //if (currentLine > 1) | 370 | //if (currentLine > 1) |
| 371 | //{ | 371 | //{ |
| 372 | // if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 2] | 372 | // if (IsCurverNode((LineGeometry)gGrpLine.Children[currentLine - 2] |
| 373 | // , (LineGeometry)gGrpLine.Children[currentLine - 1])) | 373 | // , (LineGeometry)gGrpLine.Children[currentLine - 1])) |
| 374 | // DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 2], (LineGeometry)gGrpLine.Children[currentLine - 1]); | 374 | // DrawCurver((LineGeometry)gGrpLine.Children[currentLine - 2], (LineGeometry)gGrpLine.Children[currentLine - 1]); |
| 375 | //} | 375 | //} |
| 376 | } | 376 | } |
| 377 | 377 | ||
| 378 | // Draw new line | 378 | // Draw new line |
| 379 | DrawLine(LastPoint, LastPoint, gGrpLine); | 379 | DrawLine(LastPoint, LastPoint, gGrpLine); |
| 380 | // Setting start point for new line | 380 | // Setting start point for new line |
| 381 | StartDrawPoint = LastPoint; | 381 | StartDrawPoint = LastPoint; |
| 382 | 382 | ||
| 383 | mouseState = MouseState.Draw; | 383 | mouseState = MouseState.Draw; |
| 384 | currentLine = gGrpLine.Children.Count - 1; | 384 | currentLine = gGrpLine.Children.Count - 1; |
| 385 | return; | 385 | return; |
| 386 | } | 386 | } |
| 387 | } | 387 | } |
| 388 | else if (Operation == OperationState.DrawSetFreeNode) | 388 | else if (Operation == OperationState.DrawSetFreeNode) |
| 389 | { | 389 | { |
| 390 | bool RightClick = false; | 390 | bool RightClick = false; |
| 391 | if (IsStopDrawRoute(e)) | 391 | if (IsStopDrawRoute(e)) |
| 392 | RightClick = true; | 392 | RightClick = true; |
| 393 | 393 | ||
| 394 | StartDrawPoint = e.MouseDevice.GetPosition(this); | 394 | StartDrawPoint = e.MouseDevice.GetPosition(this); |
| 395 | 395 | ||
| 396 | SetFreeNodes(StartDrawPoint, RightClick); | 396 | SetFreeNodes(StartDrawPoint, RightClick); |
| 397 | } | 397 | } |
| 398 | //2017/03/04 NAM EDT START | 398 | //2017/03/04 NAM EDT START |
| 399 | else if (Operation == OperationState.NewDrawSetFreeNode) | 399 | else if (Operation == OperationState.NewDrawSetFreeNode) |
| 400 | { | 400 | { |
| 401 | bool RightClick = false; | 401 | bool RightClick = false; |
| 402 | bool LeftClick = false; | 402 | bool LeftClick = false; |
| 403 | if (IsStopDrawRoute(e)) | 403 | if (IsStopDrawRoute(e)) |
| 404 | RightClick = true; | 404 | RightClick = true; |
| 405 | 405 | ||
| 406 | StartDrawPoint = e.MouseDevice.GetPosition(this); | 406 | StartDrawPoint = e.MouseDevice.GetPosition(this); |
| 407 | CreateNode(StartDrawPoint,LeftClick, RightClick); | 407 | CreateNode(StartDrawPoint,LeftClick, RightClick); |
| 408 | //NewSetFreeNodes(StartDrawPoint, RightClick); | 408 | //NewSetFreeNodes(StartDrawPoint, RightClick); |
| 409 | } | 409 | } |
| 410 | //2017/03/04 NAM EDT END | 410 | //2017/03/04 NAM EDT END |
| 411 | 411 | ||
| 412 | else if (Operation == OperationState.EditNode) | 412 | else if (Operation == OperationState.EditNode) |
| 413 | { | 413 | { |
| 414 | Point node_edited = e.MouseDevice.GetPosition(this); | 414 | Point node_edited = e.MouseDevice.GetPosition(this); |
| 415 | 415 | ||
| 416 | // start Edit Node Infor | 416 | // start Edit Node Infor |
| 417 | EditNode(node_edited); | 417 | EditNode(node_edited); |
| 418 | 418 | ||
| 419 | } | 419 | } |
| 420 | else if (Operation == OperationState.DrawObstract) | 420 | else if (Operation == OperationState.DrawObstract) |
| 421 | { | 421 | { |
| 422 | if (MouseHitType == HitType.None) | 422 | if (MouseHitType == HitType.None) |
| 423 | { | 423 | { |
| 424 | Rectangle shape = new Rectangle(); | 424 | Rectangle shape = new Rectangle(); |
| 425 | shape.Width = 1; | 425 | shape.Width = 1; |
| 426 | shape.Height = 1; | 426 | shape.Height = 1; |
| 427 | // Create a SolidColorBrush and use it to | 427 | // Create a SolidColorBrush and use it to |
| 428 | // paint the rectangle. | 428 | // paint the rectangle. |
| 429 | shape.Stroke = Brushes.Blue; | 429 | shape.Stroke = Brushes.Blue; |
| 430 | shape.StrokeThickness = 1; | 430 | shape.StrokeThickness = 1; |
| 431 | shape.Fill = new SolidColorBrush(Colors.LightCyan); | 431 | shape.Fill = new SolidColorBrush(Colors.LightCyan); |
| 432 | StartDrawPoint = e.MouseDevice.GetPosition(this); | 432 | StartDrawPoint = e.MouseDevice.GetPosition(this); |
| 433 | shape.SetValue(Canvas.LeftProperty, StartDrawPoint.X); | 433 | shape.SetValue(Canvas.LeftProperty, StartDrawPoint.X); |
| 434 | shape.SetValue(Canvas.TopProperty, StartDrawPoint.Y); | 434 | shape.SetValue(Canvas.TopProperty, StartDrawPoint.Y); |
| 435 | this.Children.Add(shape); | 435 | this.Children.Add(shape); |
| 436 | shapeList.Add(shape); | 436 | shapeList.Add(shape); |
| 437 | 437 | ||
| 438 | mouseState = MouseState.Draw; | 438 | mouseState = MouseState.Draw; |
| 439 | currentShape = shapeList.Count() - 1; | 439 | currentShape = shapeList.Count() - 1; |
| 440 | 440 | ||
| 441 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); | 441 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); |
| 442 | double shapeY = Canvas.GetTop(shapeList[currentShape]); | 442 | double shapeY = Canvas.GetTop(shapeList[currentShape]); |
| 443 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; | 443 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; |
| 444 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); | 444 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); |
| 445 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); | 445 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); |
| 446 | 446 | ||
| 447 | double width = (int)shapeList[currentShape].Width; | 447 | double width = (int)shapeList[currentShape].Width; |
| 448 | double height = (int)shapeList[currentShape].Height; | 448 | double height = (int)shapeList[currentShape].Height; |
| 449 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; | 449 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; |
| 450 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); | 450 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); |
| 451 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); | 451 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); |
| 452 | 452 | ||
| 453 | this.Children.Add(shapePosIndicator); | 453 | this.Children.Add(shapePosIndicator); |
| 454 | this.Children.Add(shapeSizeIndicator); | 454 | this.Children.Add(shapeSizeIndicator); |
| 455 | 455 | ||
| 456 | 456 | ||
| 457 | return; | 457 | return; |
| 458 | } | 458 | } |
| 459 | else | 459 | else |
| 460 | { | 460 | { |
| 461 | if (shapeList.Count() != 0) | 461 | if (shapeList.Count() != 0) |
| 462 | shapeList[currentShape].Fill = new SolidColorBrush(Colors.LightCyan); | 462 | shapeList[currentShape].Fill = new SolidColorBrush(Colors.LightCyan); |
| 463 | 463 | ||
| 464 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); | 464 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); |
| 465 | double shapeY = Canvas.GetTop(shapeList[currentShape]); | 465 | double shapeY = Canvas.GetTop(shapeList[currentShape]); |
| 466 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; | 466 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; |
| 467 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); | 467 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); |
| 468 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); | 468 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); |
| 469 | 469 | ||
| 470 | double width = (int)shapeList[currentShape].Width; | 470 | double width = (int)shapeList[currentShape].Width; |
| 471 | double height = (int)shapeList[currentShape].Height; | 471 | double height = (int)shapeList[currentShape].Height; |
| 472 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; | 472 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; |
| 473 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); | 473 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); |
| 474 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); | 474 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); |
| 475 | 475 | ||
| 476 | this.Children.Add(shapePosIndicator); | 476 | this.Children.Add(shapePosIndicator); |
| 477 | this.Children.Add(shapeSizeIndicator); | 477 | this.Children.Add(shapeSizeIndicator); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | LastPoint = Mouse.GetPosition(this); | 480 | LastPoint = Mouse.GetPosition(this); |
| 481 | mouseState = MouseState.Drag; | 481 | mouseState = MouseState.Drag; |
| 482 | } | 482 | } |
| 483 | e.Handled = true; | 483 | e.Handled = true; |
| 484 | } | 484 | } |
| 485 | 485 | ||
| 486 | protected override void OnMouseMove(MouseEventArgs e) | 486 | protected override void OnMouseMove(MouseEventArgs e) |
| 487 | { | 487 | { |
| 488 | base.OnMouseMove(e); | 488 | base.OnMouseMove(e); |
| 489 | 489 | ||
| 490 | if (mouseState == MouseState.None) | 490 | if (mouseState == MouseState.None) |
| 491 | { | 491 | { |
| 492 | MouseHitType = SetHitType(Mouse.GetPosition(this)); | 492 | MouseHitType = SetHitType(Mouse.GetPosition(this)); |
| 493 | SetMouseCursor(); | 493 | SetMouseCursor(); |
| 494 | } | 494 | } |
| 495 | else if (Operation == OperationState.DrawRoute && isStartDrawRoute) | 495 | else if (Operation == OperationState.DrawRoute && isStartDrawRoute) |
| 496 | { | 496 | { |
| 497 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine]; | 497 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[currentLine]; |
| 498 | 498 | ||
| 499 | // See how much the mouse has moved. | 499 | // See how much the mouse has moved. |
| 500 | Point point = Mouse.GetPosition(this); | 500 | Point point = Mouse.GetPosition(this); |
| 501 | double offset_x = point.X - StartDrawPoint.X; | 501 | double offset_x = point.X - StartDrawPoint.X; |
| 502 | double offset_y = point.Y - StartDrawPoint.Y; | 502 | double offset_y = point.Y - StartDrawPoint.Y; |
| 503 | 503 | ||
| 504 | // Get the line's current position. | 504 | // Get the line's current position. |
| 505 | double new_x = lineGeometry.StartPoint.X; | 505 | double new_x = lineGeometry.StartPoint.X; |
| 506 | double new_y = lineGeometry.StartPoint.Y; | 506 | double new_y = lineGeometry.StartPoint.Y; |
| 507 | 507 | ||
| 508 | if (offset_x != 0 || offset_y != 0) | 508 | if (offset_x != 0 || offset_y != 0) |
| 509 | { | 509 | { |
| 510 | if (Math.Abs(offset_x) >= Math.Abs(offset_y)) | 510 | if (Math.Abs(offset_x) >= Math.Abs(offset_y)) |
| 511 | { | 511 | { |
| 512 | new_x = point.X; | 512 | new_x = point.X; |
| 513 | } | 513 | } |
| 514 | else | 514 | else |
| 515 | { | 515 | { |
| 516 | new_y = point.Y; | 516 | new_y = point.Y; |
| 517 | } | 517 | } |
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | // Set end point of current line | 520 | // Set end point of current line |
| 521 | LastPoint = new Point(new_x, new_y); | 521 | LastPoint = new Point(new_x, new_y); |
| 522 | lineGeometry.EndPoint = LastPoint; | 522 | lineGeometry.EndPoint = LastPoint; |
| 523 | DisplayCoordinate(LastPoint); | 523 | DisplayCoordinate(LastPoint); |
| 524 | } | 524 | } |
| 525 | else if (Operation == OperationState.DrawObstract) | 525 | else if (Operation == OperationState.DrawObstract) |
| 526 | { | 526 | { |
| 527 | if (mouseState == MouseState.Drag) | 527 | if (mouseState == MouseState.Drag) |
| 528 | { | 528 | { |
| 529 | // See how much the mouse has moved. | 529 | // See how much the mouse has moved. |
| 530 | Point point = Mouse.GetPosition(this); | 530 | Point point = Mouse.GetPosition(this); |
| 531 | double offset_x = point.X - LastPoint.X; | 531 | double offset_x = point.X - LastPoint.X; |
| 532 | double offset_y = point.Y - LastPoint.Y; | 532 | double offset_y = point.Y - LastPoint.Y; |
| 533 | 533 | ||
| 534 | // Get the rectangle's current position. | 534 | // Get the rectangle's current position. |
| 535 | double new_x = Canvas.GetLeft(shapeList[currentShape]); | 535 | double new_x = Canvas.GetLeft(shapeList[currentShape]); |
| 536 | double new_y = Canvas.GetTop(shapeList[currentShape]); | 536 | double new_y = Canvas.GetTop(shapeList[currentShape]); |
| 537 | double new_width = shapeList[currentShape].Width; | 537 | double new_width = shapeList[currentShape].Width; |
| 538 | double new_height = shapeList[currentShape].Height; | 538 | double new_height = shapeList[currentShape].Height; |
| 539 | 539 | ||
| 540 | // Update the rectangle. | 540 | // Update the rectangle. |
| 541 | switch (MouseHitType) | 541 | switch (MouseHitType) |
| 542 | { | 542 | { |
| 543 | case HitType.Body: | 543 | case HitType.Body: |
| 544 | new_x += offset_x; | 544 | new_x += offset_x; |
| 545 | new_y += offset_y; | 545 | new_y += offset_y; |
| 546 | break; | 546 | break; |
| 547 | case HitType.UL: | 547 | case HitType.UL: |
| 548 | new_x += offset_x; | 548 | new_x += offset_x; |
| 549 | new_y += offset_y; | 549 | new_y += offset_y; |
| 550 | new_width -= offset_x; | 550 | new_width -= offset_x; |
| 551 | new_height -= offset_y; | 551 | new_height -= offset_y; |
| 552 | break; | 552 | break; |
| 553 | case HitType.UR: | 553 | case HitType.UR: |
| 554 | new_y += offset_y; | 554 | new_y += offset_y; |
| 555 | new_width += offset_x; | 555 | new_width += offset_x; |
| 556 | new_height -= offset_y; | 556 | new_height -= offset_y; |
| 557 | break; | 557 | break; |
| 558 | case HitType.LR: | 558 | case HitType.LR: |
| 559 | new_width += offset_x; | 559 | new_width += offset_x; |
| 560 | new_height += offset_y; | 560 | new_height += offset_y; |
| 561 | break; | 561 | break; |
| 562 | case HitType.LL: | 562 | case HitType.LL: |
| 563 | new_x += offset_x; | 563 | new_x += offset_x; |
| 564 | new_width -= offset_x; | 564 | new_width -= offset_x; |
| 565 | new_height += offset_y; | 565 | new_height += offset_y; |
| 566 | break; | 566 | break; |
| 567 | case HitType.L: | 567 | case HitType.L: |
| 568 | new_x += offset_x; | 568 | new_x += offset_x; |
| 569 | new_width -= offset_x; | 569 | new_width -= offset_x; |
| 570 | break; | 570 | break; |
| 571 | case HitType.R: | 571 | case HitType.R: |
| 572 | new_width += offset_x; | 572 | new_width += offset_x; |
| 573 | break; | 573 | break; |
| 574 | case HitType.B: | 574 | case HitType.B: |
| 575 | new_height += offset_y; | 575 | new_height += offset_y; |
| 576 | break; | 576 | break; |
| 577 | case HitType.T: | 577 | case HitType.T: |
| 578 | new_y += offset_y; | 578 | new_y += offset_y; |
| 579 | new_height -= offset_y; | 579 | new_height -= offset_y; |
| 580 | break; | 580 | break; |
| 581 | } | 581 | } |
| 582 | // Don't use negative width or height. | 582 | // Don't use negative width or height. |
| 583 | if ((new_width > 0) && (new_height > 0)) | 583 | if ((new_width > 0) && (new_height > 0)) |
| 584 | { | 584 | { |
| 585 | // Update the rectangle. | 585 | // Update the rectangle. |
| 586 | Canvas.SetLeft(shapeList[currentShape], new_x); | 586 | Canvas.SetLeft(shapeList[currentShape], new_x); |
| 587 | Canvas.SetTop(shapeList[currentShape], new_y); | 587 | Canvas.SetTop(shapeList[currentShape], new_y); |
| 588 | shapeList[currentShape].Width = new_width; | 588 | shapeList[currentShape].Width = new_width; |
| 589 | shapeList[currentShape].Height = new_height; | 589 | shapeList[currentShape].Height = new_height; |
| 590 | 590 | ||
| 591 | // Save the mouse's new location. | 591 | // Save the mouse's new location. |
| 592 | LastPoint = point; | 592 | LastPoint = point; |
| 593 | 593 | ||
| 594 | } | 594 | } |
| 595 | } | 595 | } |
| 596 | else if (mouseState == MouseState.Draw) | 596 | else if (mouseState == MouseState.Draw) |
| 597 | { | 597 | { |
| 598 | 598 | ||
| 599 | // See how much the mouse has moved. | 599 | // See how much the mouse has moved. |
| 600 | Point point = Mouse.GetPosition(this); | 600 | Point point = Mouse.GetPosition(this); |
| 601 | 601 | ||
| 602 | 602 | ||
| 603 | double offset_x = point.X - StartDrawPoint.X; | 603 | double offset_x = point.X - StartDrawPoint.X; |
| 604 | double offset_y = point.Y - StartDrawPoint.Y; | 604 | double offset_y = point.Y - StartDrawPoint.Y; |
| 605 | 605 | ||
| 606 | // Get the rectangle's current position. | 606 | // Get the rectangle's current position. |
| 607 | double start_x = Canvas.GetLeft(shapeList[currentShape]); | 607 | double start_x = Canvas.GetLeft(shapeList[currentShape]); |
| 608 | double start_y = Canvas.GetTop(shapeList[currentShape]); | 608 | double start_y = Canvas.GetTop(shapeList[currentShape]); |
| 609 | double new_x = Canvas.GetLeft(shapeList[currentShape]); | 609 | double new_x = Canvas.GetLeft(shapeList[currentShape]); |
| 610 | double new_y = Canvas.GetTop(shapeList[currentShape]); | 610 | double new_y = Canvas.GetTop(shapeList[currentShape]); |
| 611 | double new_width = offset_x; | 611 | double new_width = offset_x; |
| 612 | double new_height = offset_y; | 612 | double new_height = offset_y; |
| 613 | if (offset_x < 0) | 613 | if (offset_x < 0) |
| 614 | { | 614 | { |
| 615 | new_x = point.X; | 615 | new_x = point.X; |
| 616 | new_width = -offset_x; | 616 | new_width = -offset_x; |
| 617 | } | 617 | } |
| 618 | if (offset_y < 0) | 618 | if (offset_y < 0) |
| 619 | { | 619 | { |
| 620 | new_y = point.Y; | 620 | new_y = point.Y; |
| 621 | new_height = -offset_y; | 621 | new_height = -offset_y; |
| 622 | } | 622 | } |
| 623 | Canvas.SetLeft(shapeList[currentShape], new_x); | 623 | Canvas.SetLeft(shapeList[currentShape], new_x); |
| 624 | Canvas.SetTop(shapeList[currentShape], new_y); | 624 | Canvas.SetTop(shapeList[currentShape], new_y); |
| 625 | shapeList[currentShape].Width = new_width; | 625 | shapeList[currentShape].Width = new_width; |
| 626 | shapeList[currentShape].Height = new_height; | 626 | shapeList[currentShape].Height = new_height; |
| 627 | 627 | ||
| 628 | } | 628 | } |
| 629 | 629 | ||
| 630 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); | 630 | double shapeX = Canvas.GetLeft(shapeList[currentShape]); |
| 631 | double shapeY = Canvas.GetTop(shapeList[currentShape]); | 631 | double shapeY = Canvas.GetTop(shapeList[currentShape]); |
| 632 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; | 632 | shapePosIndicator.Text = "(" + Math.Round(shapeX, 0) + "," + Math.Round(shapeY, 0) + ")"; |
| 633 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); | 633 | shapePosIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment); |
| 634 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); | 634 | shapePosIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment); |
| 635 | 635 | ||
| 636 | double width = (int)shapeList[currentShape].Width; | 636 | double width = (int)shapeList[currentShape].Width; |
| 637 | double height = (int)shapeList[currentShape].Height; | 637 | double height = (int)shapeList[currentShape].Height; |
| 638 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; | 638 | shapeSizeIndicator.Text = "(" + Math.Round(width, 0) + "," + Math.Round(height, 0) + ")"; |
| 639 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); | 639 | shapeSizeIndicator.SetValue(Canvas.LeftProperty, shapeX + indicatorAligment + width); |
| 640 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); | 640 | shapeSizeIndicator.SetValue(Canvas.TopProperty, shapeY + indicatorAligment + height); |
| 641 | } | 641 | } |
| 642 | e.Handled = true; | 642 | e.Handled = true; |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | protected override void OnMouseUp(MouseButtonEventArgs e) | 645 | protected override void OnMouseUp(MouseButtonEventArgs e) |
| 646 | { | 646 | { |
| 647 | base.OnMouseUp(e); | 647 | base.OnMouseUp(e); |
| 648 | if (Operation == OperationState.DrawObstract) | 648 | if (Operation == OperationState.DrawObstract) |
| 649 | { | 649 | { |
| 650 | if (shapeList.Count() != 0) | 650 | if (shapeList.Count() != 0) |
| 651 | shapeList[currentShape].Fill = new SolidColorBrush(Colors.Blue); | 651 | shapeList[currentShape].Fill = new SolidColorBrush(Colors.Blue); |
| 652 | shapePosIndicator.Text = ""; | 652 | shapePosIndicator.Text = ""; |
| 653 | shapeSizeIndicator.Text = ""; | 653 | shapeSizeIndicator.Text = ""; |
| 654 | this.Children.Remove(shapePosIndicator); | 654 | this.Children.Remove(shapePosIndicator); |
| 655 | this.Children.Remove(shapeSizeIndicator); | 655 | this.Children.Remove(shapeSizeIndicator); |
| 656 | 656 | ||
| 657 | mouseState = MouseState.None; | 657 | mouseState = MouseState.None; |
| 658 | currentShape = 0; | 658 | currentShape = 0; |
| 659 | } | 659 | } |
| 660 | e.Handled = true; | 660 | e.Handled = true; |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | /// <summary> | 663 | /// <summary> |
| 664 | /// On Preview Mouse Down | 664 | /// On Preview Mouse Down |
| 665 | /// </summary> | 665 | /// </summary> |
| 666 | /// <param name="e"></param> | 666 | /// <param name="e"></param> |
| 667 | protected override void OnPreviewMouseDown(MouseButtonEventArgs e) | 667 | protected override void OnPreviewMouseDown(MouseButtonEventArgs e) |
| 668 | { | 668 | { |
| 669 | base.OnPreviewMouseDown(e); | 669 | base.OnPreviewMouseDown(e); |
| 670 | if (Operation != OperationState.NewDrawSetFreeNode) | 670 | if (Operation != OperationState.NewDrawSetFreeNode) |
| 671 | { | 671 | { |
| 672 | return; | 672 | return; |
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | Point currentPoint = e.MouseDevice.GetPosition(this); | 675 | Point currentPoint = e.MouseDevice.GetPosition(this); |
| 676 | //bool _isStart = IsStartEndRoute(_startPoint, currentPoint); | 676 | //bool _isStart = IsStartEndRoute(_startPoint, currentPoint); |
| 677 | 677 | ||
| 678 | if (isDrawingNode == false) | 678 | if (isDrawingNode == false) |
| 679 | { | 679 | { |
| 680 | //double centerY = Canvas.GetTop(_startPoint); | 680 | //double centerY = Canvas.GetTop(_startPoint); |
| 681 | //double centerX = Canvas.GetLeft(_startPoint); | 681 | //double centerX = Canvas.GetLeft(_startPoint); |
| 682 | 682 | ||
| 683 | isDrawingNode = true; | 683 | isDrawingNode = true; |
| 684 | InitDrawRoute(); | 684 | InitDrawRoute(); |
| 685 | //DrawLine(new Point(centerX + 25, centerY + 25), new Point(centerX + 25, centerY + 25), gGrpLine); | 685 | //DrawLine(new Point(centerX + 25, centerY + 25), new Point(centerX + 25, centerY + 25), gGrpLine); |
| 686 | mouseState = MouseState.Draw; | 686 | mouseState = MouseState.Draw; |
| 687 | //currentLine = gGrpLine.Children.Count - 1; | 687 | //currentLine = gGrpLine.Children.Count - 1; |
| 688 | //StartDrawPoint = new Point(centerX + 25, centerY + 25); | 688 | //StartDrawPoint = new Point(centerX + 25, centerY + 25); |
| 689 | 689 | ||
| 690 | //this.Children.Remove(_startPoint); | 690 | //this.Children.Remove(_startPoint); |
| 691 | //this.Children.Add(_startPoint); | 691 | //this.Children.Add(_startPoint); |
| 692 | 692 | ||
| 693 | return; | 693 | return; |
| 694 | } | 694 | } |
| 695 | //2017/03/04 NAM EDT START | 695 | //2017/03/04 NAM EDT START |
| 696 | else | 696 | else |
| 697 | { | 697 | { |
| 698 | 698 | ||
| 699 | bool RightClick = false; | 699 | bool RightClick = false; |
| 700 | bool LeftClick = false; | 700 | bool LeftClick = false; |
| 701 | 701 | ||
| 702 | 702 | ||
| 703 | if (IsMouseLeftClick(e)) | 703 | if (IsMouseLeftClick(e)) |
| 704 | LeftClick = true; | 704 | LeftClick = true; |
| 705 | if (IsStopDrawRoute(e)) | 705 | if (IsStopDrawRoute(e)) |
| 706 | RightClick = true; | 706 | RightClick = true; |
| 707 | 707 | ||
| 708 | StartDrawPoint = e.MouseDevice.GetPosition(this); | 708 | StartDrawPoint = e.MouseDevice.GetPosition(this); |
| 709 | CreateNode(StartDrawPoint, LeftClick, RightClick); | 709 | CreateNode(StartDrawPoint, LeftClick, RightClick); |
| 710 | } | 710 | } |
| 711 | //2017/03/04 NAM EDT END | 711 | //2017/03/04 NAM EDT END |
| 712 | 712 | ||
| 713 | 713 | ||
| 714 | bool _isgoal = IsStartEndRoute(_goalPoint, LastPoint); | 714 | bool _isgoal = IsStartEndRoute(_goalPoint, LastPoint); |
| 715 | if (_isgoal && isGoalDrawRoute == false) | 715 | if (_isgoal && isGoalDrawRoute == false) |
| 716 | { | 716 | { |
| 717 | isGoalDrawRoute = true; | 717 | isGoalDrawRoute = true; |
| 718 | ProcessEndRoute(); | 718 | ProcessEndRoute(); |
| 719 | } | 719 | } |
| 720 | } | 720 | } |
| 721 | 721 | ||
| 722 | #region Functions for draw route | 722 | #region Functions for draw route |
| 723 | 723 | ||
| 724 | /// <summary> | 724 | /// <summary> |
| 725 | /// Check start or end draw route | 725 | /// Check start or end draw route |
| 726 | /// </summary> | 726 | /// </summary> |
| 727 | /// <param name="_ucStartEndButton">Button start</param> | 727 | /// <param name="_ucStartEndButton">Button start</param> |
| 728 | /// <param name="currentPoint">Position for check</param> | 728 | /// <param name="currentPoint">Position for check</param> |
| 729 | /// <returns>true: start, false: not start</returns> | 729 | /// <returns>true: start, false: not start</returns> |
| 730 | private bool IsStartEndRoute(ucStartEndButton _ucStartEndButton, Point currentPoint) | 730 | private bool IsStartEndRoute(ucStartEndButton _ucStartEndButton, Point currentPoint) |
| 731 | { | 731 | { |
| 732 | if(_ucStartEndButton == null) | 732 | if(_ucStartEndButton == null) |
| 733 | { | 733 | { |
| 734 | return false; | 734 | return false; |
| 735 | } | 735 | } |
| 736 | 736 | ||
| 737 | double centerX = Canvas.GetLeft(_ucStartEndButton); | 737 | double centerX = Canvas.GetLeft(_ucStartEndButton); |
| 738 | double centerY = Canvas.GetTop(_ucStartEndButton); | 738 | double centerY = Canvas.GetTop(_ucStartEndButton); |
| 739 | 739 | ||
| 740 | if (currentPoint.X < centerX + 50 && currentPoint.X > centerX | 740 | if (currentPoint.X < centerX + 50 && currentPoint.X > centerX |
| 741 | && currentPoint.Y < centerY + 50 && currentPoint.Y > centerY) | 741 | && currentPoint.Y < centerY + 50 && currentPoint.Y > centerY) |
| 742 | { | 742 | { |
| 743 | return true; | 743 | return true; |
| 744 | } | 744 | } |
| 745 | return false; | 745 | return false; |
| 746 | } | 746 | } |
| 747 | 747 | ||
| 748 | /// <summary> | 748 | /// <summary> |
| 749 | /// Process when end draw route | 749 | /// Process when end draw route |
| 750 | /// </summary> | 750 | /// </summary> |
| 751 | private void ProcessEndRoute() | 751 | private void ProcessEndRoute() |
| 752 | { | 752 | { |
| 753 | Operation = OperationState.None; | 753 | Operation = OperationState.None; |
| 754 | AutoEditLine(); | 754 | AutoEditLine(); |
| 755 | this.Children.Remove(_displayAxiPosition); | 755 | this.Children.Remove(_displayAxiPosition); |
| 756 | this.Children.Remove(_goalPoint); | 756 | this.Children.Remove(_goalPoint); |
| 757 | this.Children.Add(_goalPoint); | 757 | this.Children.Add(_goalPoint); |
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | /// <summary> | 760 | /// <summary> |
| 761 | /// Check end draw route | 761 | /// Check end draw route |
| 762 | /// </summary> | 762 | /// </summary> |
| 763 | /// <param name="_ucStartEndButton">Button end</param> | 763 | /// <param name="_ucStartEndButton">Button end</param> |
| 764 | /// <param name="currentPoint">Position for check</param> | 764 | /// <param name="currentPoint">Position for check</param> |
| 765 | /// <returns>true: end, false: not end</returns> | 765 | /// <returns>true: end, false: not end</returns> |
| 766 | private bool IsEndRoute(ucStartEndButton _ucStartEndButton, LineGeometry lineGeometry) | 766 | private bool IsEndRoute(ucStartEndButton _ucStartEndButton, LineGeometry lineGeometry) |
| 767 | { | 767 | { |
| 768 | if (_ucStartEndButton == null) | 768 | if (_ucStartEndButton == null) |
| 769 | { | 769 | { |
| 770 | return false; | 770 | return false; |
| 771 | } | 771 | } |
| 772 | 772 | ||
| 773 | double centerX = Canvas.GetLeft(_ucStartEndButton); | 773 | double centerX = Canvas.GetLeft(_ucStartEndButton); |
| 774 | double centerY = Canvas.GetTop(_ucStartEndButton); | 774 | double centerY = Canvas.GetTop(_ucStartEndButton); |
| 775 | Point startPoint = lineGeometry.StartPoint; | 775 | Point startPoint = lineGeometry.StartPoint; |
| 776 | Point endPoint = lineGeometry.EndPoint; | 776 | Point endPoint = lineGeometry.EndPoint; |
| 777 | 777 | ||
| 778 | if(IsVerticalLine(lineGeometry)) | 778 | if(IsVerticalLine(lineGeometry)) |
| 779 | { | 779 | { |
| 780 | if(endPoint.X < centerX || endPoint.X > centerX + 50) | 780 | if(endPoint.X < centerX || endPoint.X > centerX + 50) |
| 781 | return false; | 781 | return false; |
| 782 | 782 | ||
| 783 | if (startPoint.Y > centerY + 50 && endPoint.Y > centerY + 50) | 783 | if (startPoint.Y > centerY + 50 && endPoint.Y > centerY + 50) |
| 784 | return false; | 784 | return false; |
| 785 | 785 | ||
| 786 | if (startPoint.Y < centerY && endPoint.Y < centerY) | 786 | if (startPoint.Y < centerY && endPoint.Y < centerY) |
| 787 | return false; | 787 | return false; |
| 788 | }else | 788 | }else |
| 789 | { | 789 | { |
| 790 | if (endPoint.Y < centerY || endPoint.Y > centerY + 50) | 790 | if (endPoint.Y < centerY || endPoint.Y > centerY + 50) |
| 791 | return false; | 791 | return false; |
| 792 | 792 | ||
| 793 | if (startPoint.X > centerX + 50 && endPoint.X > centerX + 50) | 793 | if (startPoint.X > centerX + 50 && endPoint.X > centerX + 50) |
| 794 | return false; | 794 | return false; |
| 795 | 795 | ||
| 796 | if (startPoint.X < centerX && endPoint.X < centerX) | 796 | if (startPoint.X < centerX && endPoint.X < centerX) |
| 797 | return false; | 797 | return false; |
| 798 | } | 798 | } |
| 799 | 799 | ||
| 800 | return true; | 800 | return true; |
| 801 | } | 801 | } |
| 802 | 802 | ||
| 803 | /// <summary> | 803 | /// <summary> |
| 804 | /// Make root | 804 | /// Make root |
| 805 | /// </summary> | 805 | /// </summary> |
| 806 | public void MakeRoot() | 806 | public void MakeRoot() |
| 807 | { | 807 | { |
| 808 | //LineGeometry lineGeometry; | 808 | //LineGeometry lineGeometry; |
| 809 | //EllipseGeometry ellipseGeometry; | 809 | //EllipseGeometry ellipseGeometry; |
| 810 | //Point startPoint; | 810 | //Point startPoint; |
| 811 | //Point endPoint; | 811 | //Point endPoint; |
| 812 | 812 | ||
| 813 | // If still not route | 813 | // If still not route |
| 814 | if (gGrpLine.Children.Count == 0) | 814 | if (gGrpLine.Children.Count == 0) |
| 815 | return; | 815 | return; |
| 816 | 816 | ||
| 817 | pLine.Stroke = new SolidColorBrush(Colors.Red); | 817 | pLine.Stroke = new SolidColorBrush(Colors.Red); |
| 818 | pLine.StrokeThickness = STROKE_ROOT_LINE; | 818 | pLine.StrokeThickness = STROKE_ROOT_LINE; |
| 819 | 819 | ||
| 820 | //// Setting for path line | 820 | //// Setting for path line |
| 821 | //pRootLine.Stroke = new SolidColorBrush(Colors.Red); | 821 | //pRootLine.Stroke = new SolidColorBrush(Colors.Red); |
| 822 | //pRootLine.StrokeThickness = STROKE_ROOT_LINE; | 822 | //pRootLine.StrokeThickness = STROKE_ROOT_LINE; |
| 823 | //pRootLine.Data = gGrpRootLine; | 823 | //pRootLine.Data = gGrpRootLine; |
| 824 | //this.Children.Add(pRootLine); | 824 | //this.Children.Add(pRootLine); |
| 825 | 825 | ||
| 826 | // Setting for path curver line | 826 | // Setting for path curver line |
| 827 | //pCurverLine.StrokeThickness = STROKE_ROOT_LINE; | 827 | //pCurverLine.StrokeThickness = STROKE_ROOT_LINE; |
| 828 | 828 | ||
| 829 | //// Get start point | 829 | //// Get start point |
| 830 | //lineGeometry = (LineGeometry)gGrpLine.Children[0]; | 830 | //lineGeometry = (LineGeometry)gGrpLine.Children[0]; |
| 831 | //startPoint = lineGeometry.StartPoint; | 831 | //startPoint = lineGeometry.StartPoint; |
| 832 | 832 | ||
| 833 | //for (int i = 0; i < gGrpYellowNode.Children.Count; i = i + 2) | 833 | //for (int i = 0; i < gGrpYellowNode.Children.Count; i = i + 2) |
| 834 | //{ | 834 | //{ |
| 835 | // ellipseGeometry = (EllipseGeometry)gGrpYellowNode.Children[i]; | 835 | // ellipseGeometry = (EllipseGeometry)gGrpYellowNode.Children[i]; |
| 836 | // endPoint = ellipseGeometry.Center; | 836 | // endPoint = ellipseGeometry.Center; |
| 837 | 837 | ||
| 838 | // DrawLine(startPoint, endPoint, gGrpRootLine); | 838 | // DrawLine(startPoint, endPoint, gGrpRootLine); |
| 839 | 839 | ||
| 840 | // ellipseGeometry = (EllipseGeometry)gGrpYellowNode.Children[i + 1]; | 840 | // ellipseGeometry = (EllipseGeometry)gGrpYellowNode.Children[i + 1]; |
| 841 | // startPoint = ellipseGeometry.Center; | 841 | // startPoint = ellipseGeometry.Center; |
| 842 | //} | 842 | //} |
| 843 | 843 | ||
| 844 | //lineGeometry = (LineGeometry)gGrpLine.Children[gGrpLine.Children.Count - 1]; | 844 | //lineGeometry = (LineGeometry)gGrpLine.Children[gGrpLine.Children.Count - 1]; |
| 845 | //endPoint = lineGeometry.EndPoint; | 845 | //endPoint = lineGeometry.EndPoint; |
| 846 | 846 | ||
| 847 | //DrawLine(startPoint, endPoint, gGrpRootLine); | 847 | //DrawLine(startPoint, endPoint, gGrpRootLine); |
| 848 | 848 | ||
| 849 | //this.Children.Remove(pYellowNode); | 849 | //this.Children.Remove(pYellowNode); |
| 850 | //this.Children.Remove(pBlueNode); | 850 | //this.Children.Remove(pBlueNode); |
| 851 | //this.Children.Remove(_startPoint); | 851 | //this.Children.Remove(_startPoint); |
| 852 | //this.Children.Remove(_goalPoint); | 852 | //this.Children.Remove(_goalPoint); |
| 853 | //this.Children.Add(pYellowNode); | 853 | //this.Children.Add(pYellowNode); |
| 854 | //this.Children.Add(pBlueNode); | 854 | //this.Children.Add(pBlueNode); |
| 855 | //this.Children.Add(_startPoint); | 855 | //this.Children.Add(_startPoint); |
| 856 | //this.Children.Add(_goalPoint); | 856 | //this.Children.Add(_goalPoint); |
| 857 | } | 857 | } |
| 858 | 858 | ||
| 859 | /// <summary> | 859 | /// <summary> |
| 860 | /// Auto edit leght of line | 860 | /// Auto edit leght of line |
| 861 | /// </summary> | 861 | /// </summary> |
| 862 | private void AutoEditLine() | 862 | private void AutoEditLine() |
| 863 | { | 863 | { |
| 864 | double temp; | 864 | double temp; |
| 865 | int index = gGrpLine.Children.Count - 1; | 865 | int index = gGrpLine.Children.Count - 1; |
| 866 | double centerY = Canvas.GetTop(_goalPoint) + 25; | 866 | double centerY = Canvas.GetTop(_goalPoint) + 25; |
| 867 | double centerX = Canvas.GetLeft(_goalPoint) + 25; | 867 | double centerX = Canvas.GetLeft(_goalPoint) + 25; |
| 868 | LineGeometry lastLine = (LineGeometry)gGrpLine.Children[index]; | 868 | LineGeometry lastLine = (LineGeometry)gGrpLine.Children[index]; |
| 869 | LineGeometry beforeLastLine = (LineGeometry)gGrpLine.Children[index]; | 869 | LineGeometry beforeLastLine = (LineGeometry)gGrpLine.Children[index]; |
| 870 | 870 | ||
| 871 | if(gGrpLine.Children.Count > 1) | 871 | if(gGrpLine.Children.Count > 1) |
| 872 | { | 872 | { |
| 873 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; | 873 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; |
| 874 | 874 | ||
| 875 | if (!IsCurverNode(beforeLastLine, lastLine)) | 875 | if (!IsCurverNode(beforeLastLine, lastLine)) |
| 876 | { | 876 | { |
| 877 | beforeLastLine.EndPoint = lastLine.EndPoint; | 877 | beforeLastLine.EndPoint = lastLine.EndPoint; |
| 878 | gGrpLine.Children.RemoveAt(index); | 878 | gGrpLine.Children.RemoveAt(index); |
| 879 | //// Remove yellow node | 879 | //// Remove yellow node |
| 880 | //if (gGrpYellowNode.Children.Count > 0) | 880 | //if (gGrpYellowNode.Children.Count > 0) |
| 881 | //{ | 881 | //{ |
| 882 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); | 882 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); |
| 883 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); | 883 | // gGrpYellowNode.Children.RemoveAt(gGrpYellowNode.Children.Count - 1); |
| 884 | //} | 884 | //} |
| 885 | //// Remove curver line | 885 | //// Remove curver line |
| 886 | //if (gGrpCurverLine.Children.Count > 0) | 886 | //if (gGrpCurverLine.Children.Count > 0) |
| 887 | //{ | 887 | //{ |
| 888 | // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1); | 888 | // gGrpCurverLine.Children.RemoveAt(gGrpCurverLine.Children.Count - 1); |
| 889 | //} | 889 | //} |
| 890 | index = index - 1; | 890 | index = index - 1; |
| 891 | lastLine = (LineGeometry)gGrpLine.Children[index]; | 891 | lastLine = (LineGeometry)gGrpLine.Children[index]; |
| 892 | } | 892 | } |
| 893 | } | 893 | } |
| 894 | 894 | ||
| 895 | if (index == gGrpRedNode.Children.Count + 1) | 895 | if (index == gGrpRedNode.Children.Count + 1) |
| 896 | { | 896 | { |
| 897 | AddNode(lastLine.StartPoint, gGrpRedNode); | 897 | AddNode(lastLine.StartPoint, gGrpRedNode); |
| 898 | } | 898 | } |
| 899 | 899 | ||
| 900 | if (lastLine.EndPoint.X == centerX && lastLine.EndPoint.Y == centerY) | 900 | if (lastLine.EndPoint.X == centerX && lastLine.EndPoint.Y == centerY) |
| 901 | return; | 901 | return; |
| 902 | 902 | ||
| 903 | if(IsVerticalLine(lastLine)) | 903 | if(IsVerticalLine(lastLine)) |
| 904 | { | 904 | { |
| 905 | temp = lastLine.StartPoint.Y; | 905 | temp = lastLine.StartPoint.Y; |
| 906 | lastLine.StartPoint = new Point(centerX, temp); | 906 | lastLine.StartPoint = new Point(centerX, temp); |
| 907 | lastLine.EndPoint = new Point(centerX, centerY); | 907 | lastLine.EndPoint = new Point(centerX, centerY); |
| 908 | 908 | ||
| 909 | if(gGrpLine.Children.Count > 1){ | 909 | if(gGrpLine.Children.Count > 1){ |
| 910 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; | 910 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; |
| 911 | temp = beforeLastLine.EndPoint.Y; | 911 | temp = beforeLastLine.EndPoint.Y; |
| 912 | beforeLastLine.EndPoint = new Point(centerX, temp); | 912 | beforeLastLine.EndPoint = new Point(centerX, temp); |
| 913 | } | 913 | } |
| 914 | }else | 914 | }else |
| 915 | { | 915 | { |
| 916 | temp = lastLine.StartPoint.X; | 916 | temp = lastLine.StartPoint.X; |
| 917 | lastLine.StartPoint = new Point(temp, centerY); | 917 | lastLine.StartPoint = new Point(temp, centerY); |
| 918 | lastLine.EndPoint = new Point(centerX, centerY); | 918 | lastLine.EndPoint = new Point(centerX, centerY); |
| 919 | if (gGrpLine.Children.Count > 1) | 919 | if (gGrpLine.Children.Count > 1) |
| 920 | { | 920 | { |
| 921 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; | 921 | beforeLastLine = (LineGeometry)gGrpLine.Children[index - 1]; |
| 922 | temp = beforeLastLine.EndPoint.X; | 922 | temp = beforeLastLine.EndPoint.X; |
| 923 | beforeLastLine.EndPoint = new Point(temp, centerY); | 923 | beforeLastLine.EndPoint = new Point(temp, centerY); |
| 924 | } | 924 | } |
| 925 | } | 925 | } |
| 926 | 926 | ||
| 927 | // Draw curver line | 927 | // Draw curver line |
| 928 | if (IsCurverNode(beforeLastLine, lastLine)) | 928 | if (IsCurverNode(beforeLastLine, lastLine)) |
| 929 | { | 929 | { |
| 930 | EllipseGeometry ellipseGeometry = (EllipseGeometry)gGrpRedNode.Children[gGrpRedNode.Children.Count - 1]; | 930 | EllipseGeometry ellipseGeometry = (EllipseGeometry)gGrpRedNode.Children[gGrpRedNode.Children.Count - 1]; |
| 931 | ellipseGeometry.Center = lastLine.StartPoint; | 931 | ellipseGeometry.Center = lastLine.StartPoint; |
| 932 | // | 932 | // |
| 933 | //if (GetDistance(lastLine.StartPoint, lastLine.EndPoint) > RADIUS_CURVER_LINE + 25) | 933 | //if (GetDistance(lastLine.StartPoint, lastLine.EndPoint) > RADIUS_CURVER_LINE + 25) |
| 934 | //{ | 934 | //{ |
| 935 | //DrawCurver(beforeLastLine, lastLine); | 935 | //DrawCurver(beforeLastLine, lastLine); |
| 936 | //} | 936 | //} |
| 937 | } | 937 | } |
| 938 | } | 938 | } |
| 939 | 939 | ||
| 940 | /// <summary> | 940 | /// <summary> |
| 941 | /// Check draw curver node | 941 | /// Check draw curver node |
| 942 | /// </summary> | 942 | /// </summary> |
| 943 | /// <param name="oldLine">Old line</param> | 943 | /// <param name="oldLine">Old line</param> |
| 944 | /// <param name="newLine">New line</param> | 944 | /// <param name="newLine">New line</param> |
| 945 | /// <returns>true:is curver, fasle: not curver</returns> | 945 | /// <returns>true:is curver, fasle: not curver</returns> |
| 946 | private bool IsCurverNode(LineGeometry oldLine, LineGeometry newLine) | 946 | private bool IsCurverNode(LineGeometry oldLine, LineGeometry newLine) |
| 947 | { | 947 | { |
| 948 | if (oldLine.StartPoint.Y == oldLine.EndPoint.Y && oldLine.StartPoint.Y == newLine.EndPoint.Y) | 948 | if (oldLine.StartPoint.Y == oldLine.EndPoint.Y && oldLine.StartPoint.Y == newLine.EndPoint.Y) |
| 949 | { | 949 | { |
| 950 | return false; | 950 | return false; |
| 951 | } | 951 | } |
| 952 | 952 | ||
| 953 | if (oldLine.StartPoint.X == oldLine.EndPoint.X && oldLine.StartPoint.X == newLine.EndPoint.X) | 953 | if (oldLine.StartPoint.X == oldLine.EndPoint.X && oldLine.StartPoint.X == newLine.EndPoint.X) |
| 954 | { | 954 | { |
| 955 | return false; | 955 | return false; |
| 956 | } | 956 | } |
| 957 | 957 | ||
| 958 | return true; | 958 | return true; |
| 959 | } | 959 | } |
| 960 | 960 | ||
| 961 | /// <summary> | 961 | /// <summary> |
| 962 | /// Check timming to stop draw route | 962 | /// Check timming to stop draw route |
| 963 | /// </summary> | 963 | /// </summary> |
| 964 | /// <param name="e"></param> | 964 | /// <param name="e"></param> |
| 965 | /// <returns>true:stop; false:continue</returns> | 965 | /// <returns>true:stop; false:continue</returns> |
| 966 | private bool IsStopDrawRoute(MouseEventArgs e) | 966 | private bool IsStopDrawRoute(MouseEventArgs e) |
| 967 | { | 967 | { |
| 968 | if(e.RightButton == MouseButtonState.Pressed) | 968 | if(e.RightButton == MouseButtonState.Pressed) |
| 969 | { | 969 | { |
| 970 | return true; | 970 | return true; |
| 971 | } | 971 | } |
| 972 | 972 | ||
| 973 | return false; | 973 | return false; |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | //2017/03/05 NAM ADD START | 976 | //2017/03/05 NAM ADD START |
| 977 | private bool IsMouseLeftClick(MouseEventArgs e) | 977 | private bool IsMouseLeftClick(MouseEventArgs e) |
| 978 | { | 978 | { |
| 979 | if (e.LeftButton == MouseButtonState.Pressed) | 979 | if (e.LeftButton == MouseButtonState.Pressed) |
| 980 | { | 980 | { |
| 981 | return true; | 981 | return true; |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | return false; | 984 | return false; |
| 985 | } | 985 | } |
| 986 | //2017/03/05 NAM ADD END | 986 | //2017/03/05 NAM ADD END |
| 987 | 987 | ||
| 988 | /// <summary> | 988 | /// <summary> |
| 989 | /// Draw curver line and yellow node | 989 | /// Draw curver line and yellow node |
| 990 | /// </summary> | 990 | /// </summary> |
| 991 | /// <param name="oldLine">Old line</param> | 991 | /// <param name="oldLine">Old line</param> |
| 992 | /// <param name="newLine">New line</param> | 992 | /// <param name="newLine">New line</param> |
| 993 | private void DrawCurver(LineGeometry oldLine, LineGeometry newLine) | 993 | private void DrawCurver(LineGeometry oldLine, LineGeometry newLine) |
| 994 | { | 994 | { |
| 995 | double radius = RADIUS_CURVER_LINE; | 995 | double radius = RADIUS_CURVER_LINE; |
| 996 | 996 | ||
| 997 | Point startPoint ; | 997 | Point startPoint ; |
| 998 | Point endPoint ; | 998 | Point endPoint ; |
| 999 | 999 | ||
| 1000 | // Get postion of yellow node on old line | 1000 | // Get postion of yellow node on old line |
| 1001 | if(IsVerticalLine(oldLine)) | 1001 | if(IsVerticalLine(oldLine)) |
| 1002 | { | 1002 | { |
| 1003 | if (oldLine.StartPoint.Y > oldLine.EndPoint.Y) | 1003 | if (oldLine.StartPoint.Y > oldLine.EndPoint.Y) |
| 1004 | startPoint = new Point(oldLine.EndPoint.X, oldLine.EndPoint.Y + radius); | 1004 | startPoint = new Point(oldLine.EndPoint.X, oldLine.EndPoint.Y + radius); |
| 1005 | else | 1005 | else |
| 1006 | startPoint = new Point(oldLine.EndPoint.X, oldLine.EndPoint.Y - radius); | 1006 | startPoint = new Point(oldLine.EndPoint.X, oldLine.EndPoint.Y - radius); |
| 1007 | }else | 1007 | }else |
| 1008 | { | 1008 | { |
| 1009 | if (oldLine.StartPoint.X > oldLine.EndPoint.X) | 1009 | if (oldLine.StartPoint.X > oldLine.EndPoint.X) |
| 1010 | startPoint = new Point(oldLine.EndPoint.X + radius, oldLine.EndPoint.Y); | 1010 | startPoint = new Point(oldLine.EndPoint.X + radius, oldLine.EndPoint.Y); |
| 1011 | else | 1011 | else |
| 1012 | startPoint = new Point(oldLine.EndPoint.X - radius, oldLine.EndPoint.Y); | 1012 | startPoint = new Point(oldLine.EndPoint.X - radius, oldLine.EndPoint.Y); |
| 1013 | } | 1013 | } |
| 1014 | 1014 | ||
| 1015 | // Get postion of yellow node on new line | 1015 | // Get postion of yellow node on new line |
| 1016 | if (IsVerticalLine(newLine)) | 1016 | if (IsVerticalLine(newLine)) |
| 1017 | { | 1017 | { |
| 1018 | if (newLine.StartPoint.Y > newLine.EndPoint.Y) | 1018 | if (newLine.StartPoint.Y > newLine.EndPoint.Y) |
| 1019 | endPoint = new Point(newLine.StartPoint.X, newLine.StartPoint.Y - radius); | 1019 | endPoint = new Point(newLine.StartPoint.X, newLine.StartPoint.Y - radius); |
| 1020 | else | 1020 | else |
| 1021 | endPoint = new Point(newLine.StartPoint.X, newLine.StartPoint.Y + radius); | 1021 | endPoint = new Point(newLine.StartPoint.X, newLine.StartPoint.Y + radius); |
| 1022 | } | 1022 | } |
| 1023 | else | 1023 | else |
| 1024 | { | 1024 | { |
| 1025 | if (newLine.StartPoint.X > newLine.EndPoint.X) | 1025 | if (newLine.StartPoint.X > newLine.EndPoint.X) |
| 1026 | endPoint = new Point(newLine.StartPoint.X - radius, newLine.StartPoint.Y); | 1026 | endPoint = new Point(newLine.StartPoint.X - radius, newLine.StartPoint.Y); |
| 1027 | else | 1027 | else |
| 1028 | endPoint = new Point(newLine.StartPoint.X + radius, newLine.StartPoint.Y); | 1028 | endPoint = new Point(newLine.StartPoint.X + radius, newLine.StartPoint.Y); |
| 1029 | } | 1029 | } |
| 1030 | 1030 | ||
| 1031 | //// Setting sweep direction | 1031 | //// Setting sweep direction |
| 1032 | //SweepDirection sweepDirection = SweepDirection.Clockwise; | 1032 | //SweepDirection sweepDirection = SweepDirection.Clockwise; |
| 1033 | //if (IsVerticalLine(oldLine) && ((startPoint.Y - endPoint.Y) * (startPoint.X - endPoint.X)) > 0) | 1033 | //if (IsVerticalLine(oldLine) && ((startPoint.Y - endPoint.Y) * (startPoint.X - endPoint.X)) > 0) |
| 1034 | //{ | 1034 | //{ |
| 1035 | // sweepDirection = SweepDirection.Counterclockwise; | 1035 | // sweepDirection = SweepDirection.Counterclockwise; |
| 1036 | //} | 1036 | //} |
| 1037 | 1037 | ||
| 1038 | //if (!IsVerticalLine(oldLine) && ((startPoint.Y - endPoint.Y) * (startPoint.X - endPoint.X)) < 0) | 1038 | //if (!IsVerticalLine(oldLine) && ((startPoint.Y - endPoint.Y) * (startPoint.X - endPoint.X)) < 0) |
| 1039 | //{ | 1039 | //{ |
| 1040 | // sweepDirection = SweepDirection.Counterclockwise; | 1040 | // sweepDirection = SweepDirection.Counterclockwise; |
| 1041 | //} | 1041 | //} |
| 1042 | 1042 | ||
| 1043 | //// Add curver line | 1043 | //// Add curver line |
| 1044 | //DrawCurverLine(startPoint, endPoint, sweepDirection, gGrpCurverLine); | 1044 | //DrawCurverLine(startPoint, endPoint, sweepDirection, gGrpCurverLine); |
| 1045 | 1045 | ||
| 1046 | // Add node to postion distance 1300mm | 1046 | // Add node to postion distance 1300mm |
| 1047 | if (GetDistance(oldLine.StartPoint, oldLine.EndPoint) > RADIUS_CURVER_LINE) | 1047 | if (GetDistance(oldLine.StartPoint, oldLine.EndPoint) > RADIUS_CURVER_LINE) |
| 1048 | { | 1048 | { |
| 1049 | AddNode(startPoint, gGrpYellowNode); | 1049 | AddNode(startPoint, gGrpYellowNode); |
| 1050 | } | 1050 | } |
| 1051 | 1051 | ||
| 1052 | if (GetDistance(newLine.StartPoint, newLine.EndPoint) > RADIUS_CURVER_LINE) | 1052 | if (GetDistance(newLine.StartPoint, newLine.EndPoint) > RADIUS_CURVER_LINE) |
| 1053 | { | 1053 | { |
| 1054 | AddNode(endPoint, gGrpYellowNode); | 1054 | AddNode(endPoint, gGrpYellowNode); |
| 1055 | } | 1055 | } |
| 1056 | } | 1056 | } |
| 1057 | 1057 | ||
| 1058 | /// <summary> | 1058 | /// <summary> |
| 1059 | /// Init data for draw route | 1059 | /// Init data for draw route |
| 1060 | /// </summary> | 1060 | /// </summary> |
| 1061 | private void InitDrawRoute() | 1061 | private void InitDrawRoute() |
| 1062 | { | 1062 | { |
| 1063 | //2017/03/04 NAM ADD START | 1063 | //2017/03/04 NAM ADD START |
| 1064 | pNewLine.Stroke = new SolidColorBrush(Colors.Red); | 1064 | pNewLine.Stroke = new SolidColorBrush(Colors.Red); |
| 1065 | pNewLine.StrokeThickness = STROKE_LINE; | 1065 | pNewLine.StrokeThickness = STROKE_LINE; |
| 1066 | pNewLine.Data = gGrpNewLine; | 1066 | pNewLine.Data = gGrpNewLine; |
| 1067 | //2017/03/04 NAM ADD END | 1067 | //2017/03/04 NAM ADD END |
| 1068 | 1068 | ||
| 1069 | pScheduleLine.Stroke = new SolidColorBrush(Colors.Red); | 1069 | pScheduleLine.Stroke = new SolidColorBrush(Colors.Red); |
| 1070 | pScheduleLine.StrokeThickness = STROKE_LINE; | 1070 | pScheduleLine.StrokeThickness = STROKE_LINE; |
| 1071 | pScheduleLine.Data = gGrpScheduleLine; | 1071 | pScheduleLine.Data = gGrpScheduleLine; |
| 1072 | 1072 | ||
| 1073 | // Setting for path line | 1073 | // Setting for path line |
| 1074 | pLine.Stroke = new SolidColorBrush(Colors.Blue); | 1074 | pLine.Stroke = new SolidColorBrush(Colors.Blue); |
| 1075 | pLine.StrokeThickness = STROKE_LINE; | 1075 | pLine.StrokeThickness = STROKE_LINE; |
| 1076 | pLine.Data = gGrpLine; | 1076 | pLine.Data = gGrpLine; |
| 1077 | 1077 | ||
| 1078 | // Setting for path of curver line | 1078 | // Setting for path of curver line |
| 1079 | pCurverLine.Stroke = Brushes.Red; | 1079 | pCurverLine.Stroke = Brushes.Red; |
| 1080 | pCurverLine.StrokeThickness = STROKE_LINE; | 1080 | pCurverLine.StrokeThickness = STROKE_LINE; |
| 1081 | pCurverLine.Data = gGrpCurverLine; | 1081 | pCurverLine.Data = gGrpCurverLine; |
| 1082 | 1082 | ||
| 1083 | // Setting for path of red node | 1083 | // Setting for path of red node |
| 1084 | pRedNode.Stroke = new SolidColorBrush(Colors.Blue); | 1084 | pRedNode.Stroke = new SolidColorBrush(Colors.Blue); |
| 1085 | pRedNode.Fill = new SolidColorBrush(Colors.Red); | 1085 | pRedNode.Fill = new SolidColorBrush(Colors.Red); |
| 1086 | pRedNode.StrokeThickness = STROKE_NODE; | 1086 | pRedNode.StrokeThickness = STROKE_NODE; |
| 1087 | pRedNode.Data = gGrpRedNode; | 1087 | pRedNode.Data = gGrpRedNode; |
| 1088 | 1088 | ||
| 1089 | // Setting for path of yellow node | 1089 | // Setting for path of yellow node |
| 1090 | pYellowNode.Stroke = new SolidColorBrush(Colors.Blue); | 1090 | pYellowNode.Stroke = new SolidColorBrush(Colors.Blue); |
| 1091 | pYellowNode.Fill = new SolidColorBrush(Colors.Yellow); | 1091 | pYellowNode.Fill = new SolidColorBrush(Colors.Yellow); |
| 1092 | pYellowNode.StrokeThickness = STROKE_NODE; | 1092 | pYellowNode.StrokeThickness = STROKE_NODE; |
| 1093 | pYellowNode.Data = gGrpYellowNode; | 1093 | pYellowNode.Data = gGrpYellowNode; |
| 1094 | 1094 | ||
| 1095 | // Setting for path of Blue node | 1095 | // Setting for path of Blue node |
| 1096 | pBlueNode.Stroke = new SolidColorBrush(Colors.Blue); | 1096 | pBlueNode.Stroke = new SolidColorBrush(Colors.Blue); |
| 1097 | pBlueNode.Fill = new SolidColorBrush(Colors.LightBlue); | 1097 | pBlueNode.Fill = new SolidColorBrush(Colors.LightBlue); |
| 1098 | pBlueNode.StrokeThickness = STROKE_NODE; | 1098 | pBlueNode.StrokeThickness = STROKE_NODE; |
| 1099 | pBlueNode.Data = gGrpBlueNode; | 1099 | pBlueNode.Data = gGrpBlueNode; |
| 1100 | 1100 | ||
| 1101 | // Setting for path of Free node | 1101 | // Setting for path of Free node |
| 1102 | //pFreeNode.Stroke = new SolidColorBrush(Colors.Blue); | 1102 | //pFreeNode.Stroke = new SolidColorBrush(Colors.Blue); |
| 1103 | //pFreeNode.Fill = new SolidColorBrush(Colors.LightBlue); | 1103 | //pFreeNode.Fill = new SolidColorBrush(Colors.LightBlue); |
| 1104 | //pFreeNode.StrokeThickness = STROKE_NODE; | 1104 | //pFreeNode.StrokeThickness = STROKE_NODE; |
| 1105 | //pFreeNode.Data = gGrpFreeNode; | 1105 | //pFreeNode.Data = gGrpFreeNode; |
| 1106 | 1106 | ||
| 1107 | // Add paths to canvas | 1107 | // Add paths to canvas |
| 1108 | this.Children.Add(pLine); | 1108 | this.Children.Add(pLine); |
| 1109 | this.Children.Add(pCurverLine); | 1109 | this.Children.Add(pCurverLine); |
| 1110 | this.Children.Add(pRedNode); | 1110 | this.Children.Add(pRedNode); |
| 1111 | this.Children.Add(pYellowNode); | 1111 | this.Children.Add(pYellowNode); |
| 1112 | 1112 | ||
| 1113 | //this.Children.Add(pBlueNode); | 1113 | //this.Children.Add(pBlueNode); |
| 1114 | //2017/03/04 NAM ADD START | 1114 | //2017/03/04 NAM ADD START |
| 1115 | this.Children.Add(pNewLine); | 1115 | this.Children.Add(pNewLine); |
| 1116 | this.Children.Add(pScheduleLine); | 1116 | //this.Children.Add(pScheduleLine); |
| 1117 | scheduleCanvas.Children.Add(pScheduleLine); | ||
| 1117 | //2017/03/04 NAM ADD END | 1118 | //2017/03/04 NAM ADD END |
| 1118 | } | 1119 | } |
| 1119 | 1120 | ||
| 1120 | /// <summary> | 1121 | /// <summary> |
| 1121 | /// Clear all route | 1122 | /// Clear all route |
| 1122 | /// </summary> | 1123 | /// </summary> |
| 1123 | public void ClearRoute() | 1124 | public void ClearRoute() |
| 1124 | { | 1125 | { |
| 1125 | isStartDrawRoute = false; | 1126 | isStartDrawRoute = false; |
| 1126 | isGoalDrawRoute = false; | 1127 | isGoalDrawRoute = false; |
| 1127 | 1128 | ||
| 1128 | gGrpLine.Children.Clear(); | 1129 | gGrpLine.Children.Clear(); |
| 1129 | gGrpRootLine.Children.Clear(); | 1130 | gGrpRootLine.Children.Clear(); |
| 1130 | gGrpCurverLine.Children.Clear(); | 1131 | gGrpCurverLine.Children.Clear(); |
| 1131 | gGrpRedNode.Children.Clear(); | 1132 | gGrpRedNode.Children.Clear(); |
| 1132 | gGrpYellowNode.Children.Clear(); | 1133 | gGrpYellowNode.Children.Clear(); |
| 1133 | gGrpBlueNode.Children.Clear(); | 1134 | gGrpBlueNode.Children.Clear(); |
| 1134 | 1135 | ||
| 1135 | this.Children.Remove(pLine); | 1136 | this.Children.Remove(pLine); |
| 1136 | this.Children.Remove(pRootLine); | 1137 | this.Children.Remove(pRootLine); |
| 1137 | this.Children.Remove(pCurverLine); | 1138 | this.Children.Remove(pCurverLine); |
| 1138 | this.Children.Remove(pRedNode); | 1139 | this.Children.Remove(pRedNode); |
| 1139 | this.Children.Remove(pYellowNode); | 1140 | this.Children.Remove(pYellowNode); |
| 1140 | this.Children.Remove(pBlueNode); | 1141 | this.Children.Remove(pBlueNode); |
| 1141 | } | 1142 | } |
| 1142 | 1143 | ||
| 1143 | /// <summary> | 1144 | /// <summary> |
| 1144 | /// Draw line for route | 1145 | /// Draw line for route |
| 1145 | /// </summary> | 1146 | /// </summary> |
| 1146 | /// <param name="startPoint">Start point</param> | 1147 | /// <param name="startPoint">Start point</param> |
| 1147 | /// <param name="endPoint">End point</param> | 1148 | /// <param name="endPoint">End point</param> |
| 1148 | /// <param name="geometryGroup">Geometry Group</param> | 1149 | /// <param name="geometryGroup">Geometry Group</param> |
| 1149 | private void DrawLine(Point startPoint, Point endPoint, GeometryGroup geometryGroup) | 1150 | private void DrawLine(Point startPoint, Point endPoint, GeometryGroup geometryGroup) |
| 1150 | { | 1151 | { |
| 1151 | LineGeometry lineGeometry = new LineGeometry(); | 1152 | LineGeometry lineGeometry = new LineGeometry(); |
| 1152 | lineGeometry.StartPoint = startPoint; | 1153 | lineGeometry.StartPoint = startPoint; |
| 1153 | lineGeometry.EndPoint = endPoint; | 1154 | lineGeometry.EndPoint = endPoint; |
| 1154 | geometryGroup.Children.Add(lineGeometry); | 1155 | geometryGroup.Children.Add(lineGeometry); |
| 1155 | } | 1156 | } |
| 1156 | 1157 | ||
| 1157 | /// <summary> | 1158 | /// <summary> |
| 1158 | /// Draw curver line | 1159 | /// Draw curver line |
| 1159 | /// </summary> | 1160 | /// </summary> |
| 1160 | /// <param name="startPoint">Point start curver line</param> | 1161 | /// <param name="startPoint">Point start curver line</param> |
| 1161 | /// <param name="endPoint">Point end curver line</param> | 1162 | /// <param name="endPoint">Point end curver line</param> |
| 1162 | /// <param name="radius">Radius</param> | 1163 | /// <param name="radius">Radius</param> |
| 1163 | /// <param name="geometryGroup">Geometry Group</param> | 1164 | /// <param name="geometryGroup">Geometry Group</param> |
| 1164 | private void DrawCurverLine(Point startPoint, Point endPoint, SweepDirection sweepDirection, GeometryGroup geometryGroup) | 1165 | private void DrawCurverLine(Point startPoint, Point endPoint, SweepDirection sweepDirection, GeometryGroup geometryGroup) |
| 1165 | { | 1166 | { |
| 1166 | PathGeometry pathGeometry = new PathGeometry(); | 1167 | PathGeometry pathGeometry = new PathGeometry(); |
| 1167 | PathFigure figure = new PathFigure(); | 1168 | PathFigure figure = new PathFigure(); |
| 1168 | figure.StartPoint = startPoint; | 1169 | figure.StartPoint = startPoint; |
| 1169 | figure.Segments.Add(new ArcSegment(endPoint, new Size(RADIUS_CURVER_LINE, RADIUS_CURVER_LINE), 90, false, sweepDirection, true)); | 1170 | figure.Segments.Add(new ArcSegment(endPoint, new Size(RADIUS_CURVER_LINE, RADIUS_CURVER_LINE), 90, false, sweepDirection, true)); |
| 1170 | pathGeometry.Figures.Add(figure); | 1171 | pathGeometry.Figures.Add(figure); |
| 1171 | geometryGroup.Children.Add(pathGeometry); | 1172 | geometryGroup.Children.Add(pathGeometry); |
| 1172 | } | 1173 | } |
| 1173 | 1174 | ||
| 1174 | /// <summary> | 1175 | /// <summary> |
| 1175 | /// Setting node | 1176 | /// Setting node |
| 1176 | /// </summary> | 1177 | /// </summary> |
| 1177 | /// <param name="centerPoit">Position of center node</param> | 1178 | /// <param name="centerPoit">Position of center node</param> |
| 1178 | /// <param name="geometryGroup">Geometry Group</param> | 1179 | /// <param name="geometryGroup">Geometry Group</param> |
| 1179 | private void AddNode(Point centerPoit, GeometryGroup geometryGroup) | 1180 | private void AddNode(Point centerPoit, GeometryGroup geometryGroup) |
| 1180 | { | 1181 | { |
| 1181 | double radius = RADIUS_NODE; | 1182 | double radius = RADIUS_NODE; |
| 1182 | geometryGroup.Children.Add(new EllipseGeometry(centerPoit, radius, radius)); | 1183 | geometryGroup.Children.Add(new EllipseGeometry(centerPoit, radius, radius)); |
| 1183 | } | 1184 | } |
| 1184 | 1185 | ||
| 1185 | /// <summary> | 1186 | /// <summary> |
| 1186 | /// Check line is vertical or horizontal | 1187 | /// Check line is vertical or horizontal |
| 1187 | /// </summary> | 1188 | /// </summary> |
| 1188 | /// <param name="line"></param> | 1189 | /// <param name="line"></param> |
| 1189 | /// <returns>true:Vertical, false:Horizontal</returns> | 1190 | /// <returns>true:Vertical, false:Horizontal</returns> |
| 1190 | private bool IsVerticalLine(LineGeometry line) | 1191 | private bool IsVerticalLine(LineGeometry line) |
| 1191 | { | 1192 | { |
| 1192 | if (line.StartPoint.X == line.EndPoint.X) | 1193 | if (line.StartPoint.X == line.EndPoint.X) |
| 1193 | { | 1194 | { |
| 1194 | // Vertical line | 1195 | // Vertical line |
| 1195 | return true; | 1196 | return true; |
| 1196 | } | 1197 | } |
| 1197 | 1198 | ||
| 1198 | // Horizontal line | 1199 | // Horizontal line |
| 1199 | return false; | 1200 | return false; |
| 1200 | } | 1201 | } |
| 1201 | 1202 | ||
| 1202 | /// <summary> | 1203 | /// <summary> |
| 1203 | /// Get distance between two point | 1204 | /// Get distance between two point |
| 1204 | /// </summary> | 1205 | /// </summary> |
| 1205 | /// <param name="point1">Point 1</param> | 1206 | /// <param name="point1">Point 1</param> |
| 1206 | /// <param name="point2">Point 2</param> | 1207 | /// <param name="point2">Point 2</param> |
| 1207 | /// <returns>Distance between two point</returns> | 1208 | /// <returns>Distance between two point</returns> |
| 1208 | private double GetDistance(Point point1, Point point2) | 1209 | private double GetDistance(Point point1, Point point2) |
| 1209 | { | 1210 | { |
| 1210 | //pythagorean theorem c^2 = a^2 + b^2 | 1211 | //pythagorean theorem c^2 = a^2 + b^2 |
| 1211 | //thus c = square root(a^2 + b^2) | 1212 | //thus c = square root(a^2 + b^2) |
| 1212 | double a = (double)(point2.X - point1.X); | 1213 | double a = (double)(point2.X - point1.X); |
| 1213 | double b = (double)(point2.Y - point1.Y); | 1214 | double b = (double)(point2.Y - point1.Y); |
| 1214 | 1215 | ||
| 1215 | return Math.Sqrt(a * a + b * b); | 1216 | return Math.Sqrt(a * a + b * b); |
| 1216 | } | 1217 | } |
| 1217 | 1218 | ||
| 1218 | /// <summary> | 1219 | /// <summary> |
| 1219 | /// Check point is valid for draw | 1220 | /// Check point is valid for draw |
| 1220 | /// </summary> | 1221 | /// </summary> |
| 1221 | /// <param name="point">Poit need check</param> | 1222 | /// <param name="point">Poit need check</param> |
| 1222 | /// <returns>true:Valid, false:Invalid</returns> | 1223 | /// <returns>true:Valid, false:Invalid</returns> |
| 1223 | private bool IsValidPoint(Point point) | 1224 | private bool IsValidPoint(Point point) |
| 1224 | { | 1225 | { |
| 1225 | return true; | 1226 | return true; |
| 1226 | } | 1227 | } |
| 1227 | 1228 | ||
| 1228 | /// <summary> | 1229 | /// <summary> |
| 1229 | /// Display coordinate position | 1230 | /// Display coordinate position |
| 1230 | /// </summary> | 1231 | /// </summary> |
| 1231 | /// <param name="point">Position to display</param> | 1232 | /// <param name="point">Position to display</param> |
| 1232 | private void DisplayCoordinate(Point point) | 1233 | private void DisplayCoordinate(Point point) |
| 1233 | { | 1234 | { |
| 1234 | if (_displayAxiPosition == null) | 1235 | if (_displayAxiPosition == null) |
| 1235 | { | 1236 | { |
| 1236 | _displayAxiPosition = new ucDisplayCoordinate(); | 1237 | _displayAxiPosition = new ucDisplayCoordinate(); |
| 1237 | this.Children.Add(_displayAxiPosition); | 1238 | this.Children.Add(_displayAxiPosition); |
| 1238 | } | 1239 | } |
| 1239 | _displayAxiPosition.Display(point); | 1240 | _displayAxiPosition.Display(point); |
| 1240 | } | 1241 | } |
| 1241 | 1242 | ||
| 1242 | #endregion | 1243 | #endregion |
| 1243 | 1244 | ||
| 1244 | #region Functions for Set Auto Nodes | 1245 | #region Functions for Set Auto Nodes |
| 1245 | 1246 | ||
| 1246 | /// <summary> | 1247 | /// <summary> |
| 1247 | /// SetAutoNodes | 1248 | /// SetAutoNodes |
| 1248 | /// </summary> | 1249 | /// </summary> |
| 1249 | public void SetAutoNodes() | 1250 | public void SetAutoNodes() |
| 1250 | { | 1251 | { |
| 1251 | double radiusStart = DISTANCE_START_NODES; | 1252 | double radiusStart = DISTANCE_START_NODES; |
| 1252 | double radiusEnd = DISTANCE_END_NODES; | 1253 | double radiusEnd = DISTANCE_END_NODES; |
| 1253 | double radiusCurver = RADIUS_CURVER_LINE; | 1254 | double radiusCurver = RADIUS_CURVER_LINE; |
| 1254 | 1255 | ||
| 1255 | Point startNode; | 1256 | Point startNode; |
| 1256 | Point endNode; | 1257 | Point endNode; |
| 1257 | 1258 | ||
| 1258 | gGrpBlueNode.Children.Clear(); | 1259 | gGrpBlueNode.Children.Clear(); |
| 1259 | 1260 | ||
| 1260 | if (gGrpLine.Children.Count == 1) | 1261 | if (gGrpLine.Children.Count == 1) |
| 1261 | radiusCurver = radiusEnd; | 1262 | radiusCurver = radiusEnd; |
| 1262 | 1263 | ||
| 1263 | if (gGrpLine.Children.Count > 0) | 1264 | if (gGrpLine.Children.Count > 0) |
| 1264 | { | 1265 | { |
| 1265 | for (int i = 0; i < gGrpLine.Children.Count; i++) | 1266 | for (int i = 0; i < gGrpLine.Children.Count; i++) |
| 1266 | { | 1267 | { |
| 1267 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[i]; | 1268 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[i]; |
| 1268 | if (i == 0) | 1269 | if (i == 0) |
| 1269 | { | 1270 | { |
| 1270 | startNode = lineGeometry.EndPoint; | 1271 | startNode = lineGeometry.EndPoint; |
| 1271 | endNode = lineGeometry.StartPoint; | 1272 | endNode = lineGeometry.StartPoint; |
| 1272 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusStart); | 1273 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusStart); |
| 1273 | } | 1274 | } |
| 1274 | else if (i == gGrpLine.Children.Count - 1 && i > 0) | 1275 | else if (i == gGrpLine.Children.Count - 1 && i > 0) |
| 1275 | { | 1276 | { |
| 1276 | startNode = lineGeometry.StartPoint; | 1277 | startNode = lineGeometry.StartPoint; |
| 1277 | endNode = lineGeometry.EndPoint; | 1278 | endNode = lineGeometry.EndPoint; |
| 1278 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusEnd); | 1279 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusEnd); |
| 1279 | } | 1280 | } |
| 1280 | else | 1281 | else |
| 1281 | { | 1282 | { |
| 1282 | startNode = lineGeometry.StartPoint; | 1283 | startNode = lineGeometry.StartPoint; |
| 1283 | endNode = lineGeometry.EndPoint; | 1284 | endNode = lineGeometry.EndPoint; |
| 1284 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusCurver); | 1285 | DrawAutoNodes(startNode, endNode, radiusCurver, radiusCurver); |
| 1285 | } | 1286 | } |
| 1286 | } | 1287 | } |
| 1287 | } | 1288 | } |
| 1288 | } | 1289 | } |
| 1289 | 1290 | ||
| 1290 | 1291 | ||
| 1291 | /// <summary> | 1292 | /// <summary> |
| 1292 | /// DrawAutoNodes | 1293 | /// DrawAutoNodes |
| 1293 | /// </summary> | 1294 | /// </summary> |
| 1294 | /// <param name="startNode"></param> | 1295 | /// <param name="startNode"></param> |
| 1295 | /// <param name="endNode"></param> | 1296 | /// <param name="endNode"></param> |
| 1296 | /// <param name="radiusStart"></param> | 1297 | /// <param name="radiusStart"></param> |
| 1297 | /// <param name="radiusEnd"></param> | 1298 | /// <param name="radiusEnd"></param> |
| 1298 | private void DrawAutoNodes(Point startNode, Point endNode, double radiusStart, double radiusEnd) | 1299 | private void DrawAutoNodes(Point startNode, Point endNode, double radiusStart, double radiusEnd) |
| 1299 | { | 1300 | { |
| 1300 | double distance = DISTANCE_AUTO_NODES; | 1301 | double distance = DISTANCE_AUTO_NODES; |
| 1301 | double i; | 1302 | double i; |
| 1302 | 1303 | ||
| 1303 | Point node; | 1304 | Point node; |
| 1304 | 1305 | ||
| 1305 | // Get postion of blue node on line | 1306 | // Get postion of blue node on line |
| 1306 | if (startNode.X == endNode.X) | 1307 | if (startNode.X == endNode.X) |
| 1307 | { | 1308 | { |
| 1308 | if (startNode.Y > endNode.Y) | 1309 | if (startNode.Y > endNode.Y) |
| 1309 | { | 1310 | { |
| 1310 | i = startNode.Y - radiusStart; | 1311 | i = startNode.Y - radiusStart; |
| 1311 | if (i - distance > endNode.Y + radiusEnd) | 1312 | if (i - distance > endNode.Y + radiusEnd) |
| 1312 | { | 1313 | { |
| 1313 | do | 1314 | do |
| 1314 | { | 1315 | { |
| 1315 | i = i - distance; | 1316 | i = i - distance; |
| 1316 | node = new Point(endNode.X, i); | 1317 | node = new Point(endNode.X, i); |
| 1317 | // Add node to postion distance 1000mm | 1318 | // Add node to postion distance 1000mm |
| 1318 | AddNode(node, gGrpBlueNode); | 1319 | AddNode(node, gGrpBlueNode); |
| 1319 | 1320 | ||
| 1320 | } while (i > endNode.Y + radiusEnd + distance); | 1321 | } while (i > endNode.Y + radiusEnd + distance); |
| 1321 | } | 1322 | } |
| 1322 | } | 1323 | } |
| 1323 | else | 1324 | else |
| 1324 | { | 1325 | { |
| 1325 | i = startNode.Y + radiusStart; | 1326 | i = startNode.Y + radiusStart; |
| 1326 | if (i + distance < endNode.Y - radiusEnd) | 1327 | if (i + distance < endNode.Y - radiusEnd) |
| 1327 | { | 1328 | { |
| 1328 | do | 1329 | do |
| 1329 | { | 1330 | { |
| 1330 | i = i + distance; | 1331 | i = i + distance; |
| 1331 | node = new Point(endNode.X, i); | 1332 | node = new Point(endNode.X, i); |
| 1332 | // Add node to postion distance 1000mm | 1333 | // Add node to postion distance 1000mm |
| 1333 | AddNode(node, gGrpBlueNode); | 1334 | AddNode(node, gGrpBlueNode); |
| 1334 | } while (i < endNode.Y - radiusEnd - distance); | 1335 | } while (i < endNode.Y - radiusEnd - distance); |
| 1335 | } | 1336 | } |
| 1336 | } | 1337 | } |
| 1337 | } | 1338 | } |
| 1338 | else | 1339 | else |
| 1339 | { | 1340 | { |
| 1340 | if (startNode.X > endNode.X) | 1341 | if (startNode.X > endNode.X) |
| 1341 | { | 1342 | { |
| 1342 | i = startNode.X - radiusStart; | 1343 | i = startNode.X - radiusStart; |
| 1343 | if (i - distance > endNode.X + radiusEnd) | 1344 | if (i - distance > endNode.X + radiusEnd) |
| 1344 | { | 1345 | { |
| 1345 | do | 1346 | do |
| 1346 | { | 1347 | { |
| 1347 | i = i - distance; | 1348 | i = i - distance; |
| 1348 | node = new Point(i, endNode.Y); | 1349 | node = new Point(i, endNode.Y); |
| 1349 | // Add node to postion distance 1000mm | 1350 | // Add node to postion distance 1000mm |
| 1350 | AddNode(node, gGrpBlueNode); | 1351 | AddNode(node, gGrpBlueNode); |
| 1351 | } while (i > endNode.X + radiusEnd + distance); | 1352 | } while (i > endNode.X + radiusEnd + distance); |
| 1352 | } | 1353 | } |
| 1353 | } | 1354 | } |
| 1354 | else | 1355 | else |
| 1355 | { | 1356 | { |
| 1356 | i = startNode.X + radiusStart; | 1357 | i = startNode.X + radiusStart; |
| 1357 | if (i + distance < endNode.X - radiusEnd) | 1358 | if (i + distance < endNode.X - radiusEnd) |
| 1358 | { | 1359 | { |
| 1359 | do | 1360 | do |
| 1360 | { | 1361 | { |
| 1361 | i = i + distance; | 1362 | i = i + distance; |
| 1362 | node = new Point(i, endNode.Y); | 1363 | node = new Point(i, endNode.Y); |
| 1363 | // Add node to postion distance 1000mm | 1364 | // Add node to postion distance 1000mm |
| 1364 | AddNode(node, gGrpBlueNode); | 1365 | AddNode(node, gGrpBlueNode); |
| 1365 | } while (i < endNode.X - radiusEnd - distance); | 1366 | } while (i < endNode.X - radiusEnd - distance); |
| 1366 | } | 1367 | } |
| 1367 | } | 1368 | } |
| 1368 | } | 1369 | } |
| 1369 | 1370 | ||
| 1370 | } | 1371 | } |
| 1371 | 1372 | ||
| 1372 | #endregion | 1373 | #endregion |
| 1373 | 1374 | ||
| 1374 | #region Functions for Set Free Nodes | 1375 | #region Functions for Set Free Nodes |
| 1375 | /// <summary> | 1376 | /// <summary> |
| 1376 | /// Draw Auto Blue node | 1377 | /// Draw Auto Blue node |
| 1377 | /// </summary> | 1378 | /// </summary> |
| 1378 | 1379 | ||
| 1379 | public void SetFreeNodes(Point FreeNode, bool RightClick) | 1380 | public void SetFreeNodes(Point FreeNode, bool RightClick) |
| 1380 | { | 1381 | { |
| 1381 | double radiusStart = DISTANCE_START_NODES; | 1382 | double radiusStart = DISTANCE_START_NODES; |
| 1382 | double radiusEnd = DISTANCE_END_NODES; | 1383 | double radiusEnd = DISTANCE_END_NODES; |
| 1383 | double radiusNode = RADIUS_NODE; | 1384 | double radiusNode = RADIUS_NODE; |
| 1384 | double radiusCurver = RADIUS_CURVER_LINE + RADIUS_NODE; | 1385 | double radiusCurver = RADIUS_CURVER_LINE + RADIUS_NODE; |
| 1385 | 1386 | ||
| 1386 | EllipseGeometry ellipseGeometry; | 1387 | EllipseGeometry ellipseGeometry; |
| 1387 | Point node; | 1388 | Point node; |
| 1388 | bool deleteFlag = false; | 1389 | bool deleteFlag = false; |
| 1389 | 1390 | ||
| 1390 | 1391 | ||
| 1391 | if (RightClick) | 1392 | if (RightClick) |
| 1392 | { | 1393 | { |
| 1393 | if (gGrpBlueNode.Children.Count > 0) | 1394 | if (gGrpBlueNode.Children.Count > 0) |
| 1394 | { | 1395 | { |
| 1395 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 1396 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 1396 | { | 1397 | { |
| 1397 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 1398 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 1398 | node = ellipseGeometry.Center; | 1399 | node = ellipseGeometry.Center; |
| 1399 | if (FreeNode.X == node.X) | 1400 | if (FreeNode.X == node.X) |
| 1400 | { | 1401 | { |
| 1401 | if (CheckIsNode(FreeNode, node, radiusNode)) | 1402 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 1402 | { | 1403 | { |
| 1403 | deleteFlag = true; | 1404 | deleteFlag = true; |
| 1404 | } | 1405 | } |
| 1405 | } | 1406 | } |
| 1406 | else | 1407 | else |
| 1407 | { | 1408 | { |
| 1408 | if (CheckIsNode(FreeNode, node, radiusNode)) | 1409 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 1409 | { | 1410 | { |
| 1410 | deleteFlag = true; | 1411 | deleteFlag = true; |
| 1411 | } | 1412 | } |
| 1412 | } | 1413 | } |
| 1413 | if (deleteFlag) | 1414 | if (deleteFlag) |
| 1414 | { | 1415 | { |
| 1415 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); | 1416 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); |
| 1416 | if (result == MessageBoxResult.OK) | 1417 | if (result == MessageBoxResult.OK) |
| 1417 | { | 1418 | { |
| 1418 | gGrpBlueNode.Children.RemoveAt(i); | 1419 | gGrpBlueNode.Children.RemoveAt(i); |
| 1419 | 1420 | ||
| 1420 | this.Children.Remove(NodeNo[i]); | 1421 | this.Children.Remove(NodeNo[i]); |
| 1421 | return; | 1422 | return; |
| 1422 | } | 1423 | } |
| 1423 | else | 1424 | else |
| 1424 | { | 1425 | { |
| 1425 | return; | 1426 | return; |
| 1426 | } | 1427 | } |
| 1427 | } | 1428 | } |
| 1428 | } | 1429 | } |
| 1429 | } | 1430 | } |
| 1430 | } | 1431 | } |
| 1431 | else | 1432 | else |
| 1432 | { | 1433 | { |
| 1433 | 1434 | ||
| 1434 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 1435 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 1435 | { | 1436 | { |
| 1436 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 1437 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 1437 | node = ellipseGeometry.Center; | 1438 | node = ellipseGeometry.Center; |
| 1438 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); | 1439 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); |
| 1439 | 1440 | ||
| 1440 | if (isEditNode) | 1441 | if (isEditNode) |
| 1441 | { | 1442 | { |
| 1442 | EditNode(node); | 1443 | EditNode(node); |
| 1443 | return; | 1444 | return; |
| 1444 | } | 1445 | } |
| 1445 | } | 1446 | } |
| 1446 | 1447 | ||
| 1447 | 1448 | ||
| 1448 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); | 1449 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); |
| 1449 | if (result == MessageBoxResult.OK) | 1450 | if (result == MessageBoxResult.OK) |
| 1450 | { | 1451 | { |
| 1451 | AddNode(FreeNode, gGrpBlueNode); | 1452 | AddNode(FreeNode, gGrpBlueNode); |
| 1452 | 1453 | ||
| 1453 | TextBlock textBlock = new TextBlock(); | 1454 | TextBlock textBlock = new TextBlock(); |
| 1454 | textBlock.Text = stt.ToString(); | 1455 | textBlock.Text = stt.ToString(); |
| 1455 | textBlock.FontSize = 17; | 1456 | textBlock.FontSize = 17; |
| 1456 | textBlock.Foreground = new SolidColorBrush(Colors.Red); | 1457 | textBlock.Foreground = new SolidColorBrush(Colors.Red); |
| 1457 | Canvas.SetLeft(textBlock, FreeNode.X - RADIUS_NODE / 2); | 1458 | Canvas.SetLeft(textBlock, FreeNode.X - RADIUS_NODE / 2); |
| 1458 | Canvas.SetTop(textBlock, FreeNode.Y - 1.5 * RADIUS_NODE); | 1459 | Canvas.SetTop(textBlock, FreeNode.Y - 1.5 * RADIUS_NODE); |
| 1459 | 1460 | ||
| 1460 | this.Children.Add(textBlock); | 1461 | this.Children.Add(textBlock); |
| 1461 | NodeNo.Add(textBlock); | 1462 | NodeNo.Add(textBlock); |
| 1462 | 1463 | ||
| 1463 | if (stt > 1) | 1464 | if (stt > 1) |
| 1464 | { | 1465 | { |
| 1465 | int tmp = gGrpBlueNode.Children.Count; | 1466 | int tmp = gGrpBlueNode.Children.Count; |
| 1466 | 1467 | ||
| 1467 | EllipseGeometry elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; | 1468 | EllipseGeometry elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; |
| 1468 | Point node1 = elip.Center; | 1469 | Point node1 = elip.Center; |
| 1469 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; | 1470 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; |
| 1470 | Point node2 = elip.Center; | 1471 | Point node2 = elip.Center; |
| 1471 | DrawLine(node1, node2, gGrpCurverLine); | 1472 | DrawLine(node1, node2, gGrpCurverLine); |
| 1472 | } | 1473 | } |
| 1473 | 1474 | ||
| 1474 | 1475 | ||
| 1475 | stt++; | 1476 | stt++; |
| 1476 | } | 1477 | } |
| 1477 | } | 1478 | } |
| 1478 | 1479 | ||
| 1479 | if (gGrpLine.Children.Count > 0) | 1480 | if (gGrpLine.Children.Count > 0) |
| 1480 | { | 1481 | { |
| 1481 | for (int i = 0; i < gGrpLine.Children.Count; i++) | 1482 | for (int i = 0; i < gGrpLine.Children.Count; i++) |
| 1482 | { | 1483 | { |
| 1483 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[i]; | 1484 | LineGeometry lineGeometry = (LineGeometry)gGrpLine.Children[i]; |
| 1484 | 1485 | ||
| 1485 | // Get postion of node on line | 1486 | // Get postion of node on line |
| 1486 | if (IsVerticalLine(lineGeometry)) | 1487 | if (IsVerticalLine(lineGeometry)) |
| 1487 | { | 1488 | { |
| 1488 | if (FreeNode.X < lineGeometry.EndPoint.X + radiusNode && FreeNode.X > lineGeometry.EndPoint.X - radiusNode) | 1489 | if (FreeNode.X < lineGeometry.EndPoint.X + radiusNode && FreeNode.X > lineGeometry.EndPoint.X - radiusNode) |
| 1489 | { | 1490 | { |
| 1490 | FreeNode.X = lineGeometry.EndPoint.X; | 1491 | FreeNode.X = lineGeometry.EndPoint.X; |
| 1491 | 1492 | ||
| 1492 | if (i == 0) | 1493 | if (i == 0) |
| 1493 | { | 1494 | { |
| 1494 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusStart, radiusCurver)) | 1495 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusStart, radiusCurver)) |
| 1495 | { | 1496 | { |
| 1496 | 1497 | ||
| 1497 | AddNode(FreeNode, gGrpBlueNode); | 1498 | AddNode(FreeNode, gGrpBlueNode); |
| 1498 | } | 1499 | } |
| 1499 | } | 1500 | } |
| 1500 | else if (i == gGrpLine.Children.Count - 1 && i > 0) | 1501 | else if (i == gGrpLine.Children.Count - 1 && i > 0) |
| 1501 | { | 1502 | { |
| 1502 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusEnd)) | 1503 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusEnd)) |
| 1503 | { | 1504 | { |
| 1504 | 1505 | ||
| 1505 | AddNode(FreeNode, gGrpBlueNode); | 1506 | AddNode(FreeNode, gGrpBlueNode); |
| 1506 | } | 1507 | } |
| 1507 | } | 1508 | } |
| 1508 | else | 1509 | else |
| 1509 | { | 1510 | { |
| 1510 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusCurver)) | 1511 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusCurver)) |
| 1511 | { | 1512 | { |
| 1512 | 1513 | ||
| 1513 | AddNode(FreeNode, gGrpBlueNode); | 1514 | AddNode(FreeNode, gGrpBlueNode); |
| 1514 | } | 1515 | } |
| 1515 | } | 1516 | } |
| 1516 | 1517 | ||
| 1517 | } | 1518 | } |
| 1518 | } | 1519 | } |
| 1519 | else | 1520 | else |
| 1520 | { | 1521 | { |
| 1521 | if (FreeNode.Y < lineGeometry.EndPoint.Y + radiusNode && FreeNode.Y > lineGeometry.EndPoint.Y - radiusNode) | 1522 | if (FreeNode.Y < lineGeometry.EndPoint.Y + radiusNode && FreeNode.Y > lineGeometry.EndPoint.Y - radiusNode) |
| 1522 | { | 1523 | { |
| 1523 | FreeNode.Y = lineGeometry.EndPoint.Y; | 1524 | FreeNode.Y = lineGeometry.EndPoint.Y; |
| 1524 | if (i == 0) | 1525 | if (i == 0) |
| 1525 | { | 1526 | { |
| 1526 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusStart, radiusCurver)) | 1527 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusStart, radiusCurver)) |
| 1527 | { | 1528 | { |
| 1528 | 1529 | ||
| 1529 | AddNode(FreeNode, gGrpBlueNode); | 1530 | AddNode(FreeNode, gGrpBlueNode); |
| 1530 | } | 1531 | } |
| 1531 | } | 1532 | } |
| 1532 | else if (i == gGrpLine.Children.Count - 1 && i > 0) | 1533 | else if (i == gGrpLine.Children.Count - 1 && i > 0) |
| 1533 | { | 1534 | { |
| 1534 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusEnd)) | 1535 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusEnd)) |
| 1535 | { | 1536 | { |
| 1536 | 1537 | ||
| 1537 | AddNode(FreeNode, gGrpBlueNode); | 1538 | AddNode(FreeNode, gGrpBlueNode); |
| 1538 | } | 1539 | } |
| 1539 | } | 1540 | } |
| 1540 | else | 1541 | else |
| 1541 | { | 1542 | { |
| 1542 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusCurver)) | 1543 | if (CheckFreeNodes(lineGeometry, FreeNode, radiusCurver, radiusCurver)) |
| 1543 | { | 1544 | { |
| 1544 | 1545 | ||
| 1545 | AddNode(FreeNode, gGrpBlueNode); | 1546 | AddNode(FreeNode, gGrpBlueNode); |
| 1546 | } | 1547 | } |
| 1547 | } | 1548 | } |
| 1548 | 1549 | ||
| 1549 | } | 1550 | } |
| 1550 | } | 1551 | } |
| 1551 | } | 1552 | } |
| 1552 | } | 1553 | } |
| 1553 | } | 1554 | } |
| 1554 | 1555 | ||
| 1555 | 1556 | ||
| 1556 | public bool CheckFreeNodes(LineGeometry lineNode, Point Freenode, double radiusStart, double radiusEnd) | 1557 | public bool CheckFreeNodes(LineGeometry lineNode, Point Freenode, double radiusStart, double radiusEnd) |
| 1557 | { | 1558 | { |
| 1558 | 1559 | ||
| 1559 | double distanceFreeNode = DISTANCE_FREE_NODES; | 1560 | double distanceFreeNode = DISTANCE_FREE_NODES; |
| 1560 | double radiusNode = RADIUS_NODE; | 1561 | double radiusNode = RADIUS_NODE; |
| 1561 | EllipseGeometry ellipseGeometry; | 1562 | EllipseGeometry ellipseGeometry; |
| 1562 | Point node; | 1563 | Point node; |
| 1563 | 1564 | ||
| 1564 | if (IsVerticalLine(lineNode)) | 1565 | if (IsVerticalLine(lineNode)) |
| 1565 | { | 1566 | { |
| 1566 | if (lineNode.StartPoint.Y < lineNode.EndPoint.Y) | 1567 | if (lineNode.StartPoint.Y < lineNode.EndPoint.Y) |
| 1567 | { | 1568 | { |
| 1568 | if (Freenode.Y < lineNode.StartPoint.Y + radiusStart || Freenode.Y > lineNode.EndPoint.Y - radiusEnd) | 1569 | if (Freenode.Y < lineNode.StartPoint.Y + radiusStart || Freenode.Y > lineNode.EndPoint.Y - radiusEnd) |
| 1569 | { | 1570 | { |
| 1570 | return false; | 1571 | return false; |
| 1571 | } | 1572 | } |
| 1572 | } | 1573 | } |
| 1573 | else | 1574 | else |
| 1574 | { | 1575 | { |
| 1575 | if (Freenode.Y > lineNode.StartPoint.Y - radiusStart || Freenode.Y < lineNode.EndPoint.Y + radiusEnd) | 1576 | if (Freenode.Y > lineNode.StartPoint.Y - radiusStart || Freenode.Y < lineNode.EndPoint.Y + radiusEnd) |
| 1576 | { | 1577 | { |
| 1577 | return false; | 1578 | return false; |
| 1578 | } | 1579 | } |
| 1579 | } | 1580 | } |
| 1580 | } | 1581 | } |
| 1581 | else | 1582 | else |
| 1582 | { | 1583 | { |
| 1583 | if (lineNode.StartPoint.X < lineNode.EndPoint.X) | 1584 | if (lineNode.StartPoint.X < lineNode.EndPoint.X) |
| 1584 | { | 1585 | { |
| 1585 | if (Freenode.X < lineNode.StartPoint.X + radiusStart || Freenode.X > lineNode.EndPoint.X - radiusEnd) | 1586 | if (Freenode.X < lineNode.StartPoint.X + radiusStart || Freenode.X > lineNode.EndPoint.X - radiusEnd) |
| 1586 | { | 1587 | { |
| 1587 | return false; | 1588 | return false; |
| 1588 | } | 1589 | } |
| 1589 | } | 1590 | } |
| 1590 | else | 1591 | else |
| 1591 | { | 1592 | { |
| 1592 | if (Freenode.X > lineNode.StartPoint.X - radiusStart || Freenode.X < lineNode.EndPoint.X + radiusEnd) | 1593 | if (Freenode.X > lineNode.StartPoint.X - radiusStart || Freenode.X < lineNode.EndPoint.X + radiusEnd) |
| 1593 | { | 1594 | { |
| 1594 | return false; | 1595 | return false; |
| 1595 | } | 1596 | } |
| 1596 | } | 1597 | } |
| 1597 | } | 1598 | } |
| 1598 | 1599 | ||
| 1599 | if (gGrpBlueNode.Children.Count > 0) | 1600 | if (gGrpBlueNode.Children.Count > 0) |
| 1600 | { | 1601 | { |
| 1601 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 1602 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 1602 | { | 1603 | { |
| 1603 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 1604 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 1604 | node = ellipseGeometry.Center; | 1605 | node = ellipseGeometry.Center; |
| 1605 | if (Freenode.X == node.X) | 1606 | if (Freenode.X == node.X) |
| 1606 | { | 1607 | { |
| 1607 | if (CheckIsNode(Freenode, node, radiusNode)) | 1608 | if (CheckIsNode(Freenode, node, radiusNode)) |
| 1608 | { | 1609 | { |
| 1609 | return false; | 1610 | return false; |
| 1610 | } | 1611 | } |
| 1611 | else if (Freenode.Y < node.Y + distanceFreeNode && Freenode.Y > node.Y - distanceFreeNode) | 1612 | else if (Freenode.Y < node.Y + distanceFreeNode && Freenode.Y > node.Y - distanceFreeNode) |
| 1612 | { | 1613 | { |
| 1613 | return false; | 1614 | return false; |
| 1614 | } | 1615 | } |
| 1615 | } | 1616 | } |
| 1616 | else if (Freenode.Y == node.Y) | 1617 | else if (Freenode.Y == node.Y) |
| 1617 | { | 1618 | { |
| 1618 | if (CheckIsNode(Freenode, node, radiusNode)) | 1619 | if (CheckIsNode(Freenode, node, radiusNode)) |
| 1619 | { | 1620 | { |
| 1620 | return false; | 1621 | return false; |
| 1621 | } | 1622 | } |
| 1622 | else if (Freenode.X < node.X + distanceFreeNode && Freenode.X > node.X - distanceFreeNode) | 1623 | else if (Freenode.X < node.X + distanceFreeNode && Freenode.X > node.X - distanceFreeNode) |
| 1623 | { | 1624 | { |
| 1624 | return false; | 1625 | return false; |
| 1625 | } | 1626 | } |
| 1626 | } | 1627 | } |
| 1627 | } | 1628 | } |
| 1628 | } | 1629 | } |
| 1629 | 1630 | ||
| 1630 | return true; | 1631 | return true; |
| 1631 | } | 1632 | } |
| 1632 | 1633 | ||
| 1633 | public bool CheckIsNode(Point FreeNode, Point Node, double radiusNode) | 1634 | public bool CheckIsNode(Point FreeNode, Point Node, double radiusNode) |
| 1634 | { | 1635 | { |
| 1635 | if (FreeNode.X < Node.X + radiusNode && FreeNode.X > Node.X - radiusNode && FreeNode.Y < Node.Y + radiusNode && FreeNode.Y > Node.Y - radiusNode) | 1636 | if (FreeNode.X < Node.X + radiusNode && FreeNode.X > Node.X - radiusNode && FreeNode.Y < Node.Y + radiusNode && FreeNode.Y > Node.Y - radiusNode) |
| 1636 | { | 1637 | { |
| 1637 | return true; | 1638 | return true; |
| 1638 | } | 1639 | } |
| 1639 | return false; | 1640 | return false; |
| 1640 | } | 1641 | } |
| 1641 | 1642 | ||
| 1642 | #endregion | 1643 | #endregion |
| 1643 | 1644 | ||
| 1644 | #region Edit Node | 1645 | #region Edit Node |
| 1645 | public void InitNodeInfo_List() | 1646 | public void InitNodeInfo_List() |
| 1646 | { | 1647 | { |
| 1647 | //Reset List | 1648 | //Reset List |
| 1648 | NodeInfo_List = new List<NodeInfo>(); | 1649 | NodeInfo_List = new List<NodeInfo>(); |
| 1649 | 1650 | ||
| 1650 | if (gGrpBlueNode.Children.Count > 0) | 1651 | if (gGrpBlueNode.Children.Count > 0) |
| 1651 | { | 1652 | { |
| 1652 | // Get start point | 1653 | // Get start point |
| 1653 | LineGeometry lineGeometry = (LineGeometry)gGrpNewLine.Children[0]; | 1654 | LineGeometry lineGeometry = (LineGeometry)gGrpNewLine.Children[0]; |
| 1654 | Point startPoint = lineGeometry.StartPoint; | 1655 | Point startPoint = lineGeometry.StartPoint; |
| 1655 | 1656 | ||
| 1656 | NodeInfo n1 = new NodeInfo(); | 1657 | NodeInfo n1 = new NodeInfo(); |
| 1657 | n1.X = startPoint.X; | 1658 | n1.X = startPoint.X; |
| 1658 | n1.Y = startPoint.Y; | 1659 | n1.Y = startPoint.Y; |
| 1659 | n1.Mode1 = ""; | 1660 | n1.Mode1 = ""; |
| 1660 | n1.Mode2 = ""; | 1661 | n1.Mode2 = ""; |
| 1661 | n1.Mode3 = ""; | 1662 | n1.Mode3 = ""; |
| 1662 | NodeInfo_List.Add(n1); | 1663 | NodeInfo_List.Add(n1); |
| 1663 | 1664 | ||
| 1664 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 1665 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 1665 | { | 1666 | { |
| 1666 | Point point; | 1667 | Point point; |
| 1667 | EllipseGeometry eGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 1668 | EllipseGeometry eGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 1668 | point = eGeometry.Center; | 1669 | point = eGeometry.Center; |
| 1669 | 1670 | ||
| 1670 | NodeInfo Ninfo = new NodeInfo(); | 1671 | NodeInfo Ninfo = new NodeInfo(); |
| 1671 | Ninfo.X = point.X; | 1672 | Ninfo.X = point.X; |
| 1672 | Ninfo.Y = point.Y; | 1673 | Ninfo.Y = point.Y; |
| 1673 | 1674 | ||
| 1674 | Ninfo.Mode1 = ""; | 1675 | Ninfo.Mode1 = ""; |
| 1675 | Ninfo.Mode2 = ""; | 1676 | Ninfo.Mode2 = ""; |
| 1676 | Ninfo.Mode3 = ""; | 1677 | Ninfo.Mode3 = ""; |
| 1677 | 1678 | ||
| 1678 | NodeInfo_List.Add(Ninfo); | 1679 | NodeInfo_List.Add(Ninfo); |
| 1679 | } | 1680 | } |
| 1680 | 1681 | ||
| 1681 | // Get end point | 1682 | // Get end point |
| 1682 | lineGeometry = (LineGeometry)gGrpLine.Children[gGrpLine.Children.Count -1]; | 1683 | lineGeometry = (LineGeometry)gGrpLine.Children[gGrpLine.Children.Count -1]; |
| 1683 | Point endPoint = lineGeometry.EndPoint; | 1684 | Point endPoint = lineGeometry.EndPoint; |
| 1684 | 1685 | ||
| 1685 | NodeInfo n2 = new NodeInfo(); | 1686 | NodeInfo n2 = new NodeInfo(); |
| 1686 | n2.X = startPoint.X; | 1687 | n2.X = startPoint.X; |
| 1687 | n2.Y = startPoint.Y; | 1688 | n2.Y = startPoint.Y; |
| 1688 | n2.Mode1 = ""; | 1689 | n2.Mode1 = ""; |
| 1689 | n2.Mode2 = ""; | 1690 | n2.Mode2 = ""; |
| 1690 | n2.Mode3 = ""; | 1691 | n2.Mode3 = ""; |
| 1691 | NodeInfo_List.Add(n2); | 1692 | NodeInfo_List.Add(n2); |
| 1692 | 1693 | ||
| 1693 | //Resort NodeInfo_List From Start to Goal | 1694 | //Resort NodeInfo_List From Start to Goal |
| 1694 | LineGeometry firstLine = (LineGeometry)gGrpLine.Children[0]; | 1695 | LineGeometry firstLine = (LineGeometry)gGrpLine.Children[0]; |
| 1695 | Point startNode = firstLine.StartPoint; | 1696 | Point startNode = firstLine.StartPoint; |
| 1696 | Point endNode = firstLine.EndPoint; | 1697 | Point endNode = firstLine.EndPoint; |
| 1697 | 1698 | ||
| 1698 | 1699 | ||
| 1699 | List<NodeInfo> tmpLst = new List<NodeInfo>(); | 1700 | List<NodeInfo> tmpLst = new List<NodeInfo>(); |
| 1700 | 1701 | ||
| 1701 | // Create temp List | 1702 | // Create temp List |
| 1702 | if(startNode.X == endNode.X) | 1703 | if(startNode.X == endNode.X) |
| 1703 | { | 1704 | { |
| 1704 | for (int i = 1; i < NodeInfo_List.Count; i++) | 1705 | for (int i = 1; i < NodeInfo_List.Count; i++) |
| 1705 | { | 1706 | { |
| 1706 | if (NodeInfo_List[i].X != endNode.X) | 1707 | if (NodeInfo_List[i].X != endNode.X) |
| 1707 | { | 1708 | { |
| 1708 | break; | 1709 | break; |
| 1709 | } | 1710 | } |
| 1710 | else | 1711 | else |
| 1711 | { | 1712 | { |
| 1712 | tmpLst.Add(NodeInfo_List[i]); | 1713 | tmpLst.Add(NodeInfo_List[i]); |
| 1713 | } | 1714 | } |
| 1714 | } | 1715 | } |
| 1715 | } | 1716 | } |
| 1716 | 1717 | ||
| 1717 | if (startNode.Y == endNode.Y) | 1718 | if (startNode.Y == endNode.Y) |
| 1718 | { | 1719 | { |
| 1719 | for (int i = 1; i < NodeInfo_List.Count; i++) | 1720 | for (int i = 1; i < NodeInfo_List.Count; i++) |
| 1720 | { | 1721 | { |
| 1721 | if (NodeInfo_List[i].Y != endNode.Y) | 1722 | if (NodeInfo_List[i].Y != endNode.Y) |
| 1722 | { | 1723 | { |
| 1723 | break; | 1724 | break; |
| 1724 | } | 1725 | } |
| 1725 | else | 1726 | else |
| 1726 | { | 1727 | { |
| 1727 | tmpLst.Add(NodeInfo_List[i]); | 1728 | tmpLst.Add(NodeInfo_List[i]); |
| 1728 | } | 1729 | } |
| 1729 | } | 1730 | } |
| 1730 | } | 1731 | } |
| 1731 | 1732 | ||
| 1732 | // Sort NodeInfo_List | 1733 | // Sort NodeInfo_List |
| 1733 | for (int i = 0; i < tmpLst.Count; i++) | 1734 | for (int i = 0; i < tmpLst.Count; i++) |
| 1734 | { | 1735 | { |
| 1735 | NodeInfo_List[i + 1] = tmpLst[tmpLst.Count -1 - i]; | 1736 | NodeInfo_List[i + 1] = tmpLst[tmpLst.Count -1 - i]; |
| 1736 | } | 1737 | } |
| 1737 | 1738 | ||
| 1738 | } | 1739 | } |
| 1739 | } | 1740 | } |
| 1740 | 1741 | ||
| 1741 | 1742 | ||
| 1742 | public void EditNode(Point node_edited) | 1743 | public void EditNode(Point node_edited) |
| 1743 | { | 1744 | { |
| 1744 | EllipseGeometry ellipseGeometry; | 1745 | EllipseGeometry ellipseGeometry; |
| 1745 | Point node; | 1746 | Point node; |
| 1746 | double radiusNode = RADIUS_NODE; | 1747 | double radiusNode = RADIUS_NODE; |
| 1747 | 1748 | ||
| 1748 | bool flag = false; | 1749 | bool flag = false; |
| 1749 | 1750 | ||
| 1750 | if (gGrpBlueNode.Children.Count > 0) | 1751 | if (gGrpBlueNode.Children.Count > 0) |
| 1751 | { | 1752 | { |
| 1752 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 1753 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 1753 | { | 1754 | { |
| 1754 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 1755 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 1755 | node = ellipseGeometry.Center; | 1756 | node = ellipseGeometry.Center; |
| 1756 | 1757 | ||
| 1757 | if (CheckIsNode(node_edited, node, radiusNode)) | 1758 | if (CheckIsNode(node_edited, node, radiusNode)) |
| 1758 | { | 1759 | { |
| 1759 | flag = true; | 1760 | flag = true; |
| 1760 | } | 1761 | } |
| 1761 | 1762 | ||
| 1762 | if (flag) | 1763 | if (flag) |
| 1763 | { | 1764 | { |
| 1764 | node_edited.X = node.X; | 1765 | node_edited.X = node.X; |
| 1765 | node_edited.Y = node.Y; | 1766 | node_edited.Y = node.Y; |
| 1766 | 1767 | ||
| 1767 | // show form edit node | 1768 | // show form edit node |
| 1768 | EditNodeWindow edtNodeWindow = new EditNodeWindow(); | 1769 | EditNodeWindow edtNodeWindow = new EditNodeWindow(); |
| 1769 | edtNodeWindow.ShowDialog(); | 1770 | edtNodeWindow.ShowDialog(); |
| 1770 | 1771 | ||
| 1771 | string result1 = edtNodeWindow._txtMode1; | 1772 | string result1 = edtNodeWindow._txtMode1; |
| 1772 | string result2 = edtNodeWindow._txtMode2; | 1773 | string result2 = edtNodeWindow._txtMode2; |
| 1773 | string result3 = edtNodeWindow._txtMode3; | 1774 | string result3 = edtNodeWindow._txtMode3; |
| 1774 | bool exit = edtNodeWindow._ExitFlg; | 1775 | bool exit = edtNodeWindow._ExitFlg; |
| 1775 | 1776 | ||
| 1776 | if (!exit) { | 1777 | if (!exit) { |
| 1777 | SaveChanged(node_edited.X, node_edited.Y, result1, result2, result3); | 1778 | SaveChanged(node_edited.X, node_edited.Y, result1, result2, result3); |
| 1778 | } | 1779 | } |
| 1779 | 1780 | ||
| 1780 | return; | 1781 | return; |
| 1781 | } | 1782 | } |
| 1782 | } | 1783 | } |
| 1783 | } | 1784 | } |
| 1784 | } | 1785 | } |
| 1785 | 1786 | ||
| 1786 | public void SaveChanged(double x, double y, string st1, string st2, string st3) | 1787 | public void SaveChanged(double x, double y, string st1, string st2, string st3) |
| 1787 | { | 1788 | { |
| 1788 | for (int i = 0; i < NodeInfo_List.Count; i++) | 1789 | for (int i = 0; i < NodeInfo_List.Count; i++) |
| 1789 | { | 1790 | { |
| 1790 | NodeInfo ni = new NodeInfo(); | 1791 | NodeInfo ni = new NodeInfo(); |
| 1791 | ni = NodeInfo_List[i]; | 1792 | ni = NodeInfo_List[i]; |
| 1792 | 1793 | ||
| 1793 | if (ni.X == x && ni.Y == y) | 1794 | if (ni.X == x && ni.Y == y) |
| 1794 | { | 1795 | { |
| 1795 | 1796 | ||
| 1796 | ni.Mode1 = st1; | 1797 | ni.Mode1 = st1; |
| 1797 | ni.Mode2 = st2; | 1798 | ni.Mode2 = st2; |
| 1798 | ni.Mode3 = st3; | 1799 | ni.Mode3 = st3; |
| 1799 | 1800 | ||
| 1800 | NodeInfo_List[i] = ni; | 1801 | NodeInfo_List[i] = ni; |
| 1801 | return; | 1802 | return; |
| 1802 | } | 1803 | } |
| 1803 | } | 1804 | } |
| 1804 | } | 1805 | } |
| 1805 | 1806 | ||
| 1806 | 1807 | ||
| 1807 | #endregion | 1808 | #endregion |
| 1808 | 1809 | ||
| 1809 | #region Display RouteInfo | 1810 | #region Display RouteInfo |
| 1810 | 1811 | ||
| 1811 | public void DspRouteInfo() | 1812 | public void DspRouteInfo() |
| 1812 | { | 1813 | { |
| 1813 | //Clear Route Info Table | 1814 | //Clear Route Info Table |
| 1814 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Clear(); | 1815 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Clear(); |
| 1815 | 1816 | ||
| 1816 | if (NodeInfo_List.Count != 0) | 1817 | if (NodeInfo_List.Count != 0) |
| 1817 | { | 1818 | { |
| 1818 | int _RowIdx = 0; | 1819 | int _RowIdx = 0; |
| 1819 | string _Content = ""; | 1820 | string _Content = ""; |
| 1820 | 1821 | ||
| 1821 | for (int i = 0; i < NodeInfo_List.Count; i++) | 1822 | for (int i = 0; i < NodeInfo_List.Count; i++) |
| 1822 | { | 1823 | { |
| 1823 | 1824 | ||
| 1824 | NodeInfo ni = new NodeInfo(); | 1825 | NodeInfo ni = new NodeInfo(); |
| 1825 | ni = NodeInfo_List[i]; | 1826 | ni = NodeInfo_List[i]; |
| 1826 | 1827 | ||
| 1827 | //column 1 | 1828 | //column 1 |
| 1828 | if (i == 0) | 1829 | if (i == 0) |
| 1829 | { | 1830 | { |
| 1830 | _Content = "S"; | 1831 | _Content = "S"; |
| 1831 | } | 1832 | } |
| 1832 | else if (i == NodeInfo_List.Count - 1) | 1833 | else if (i == NodeInfo_List.Count - 1) |
| 1833 | { | 1834 | { |
| 1834 | _Content = "G"; | 1835 | _Content = "G"; |
| 1835 | } | 1836 | } |
| 1836 | else | 1837 | else |
| 1837 | { | 1838 | { |
| 1838 | _Content = i.ToString(); | 1839 | _Content = i.ToString(); |
| 1839 | } | 1840 | } |
| 1840 | AddLabeltoGrid(_RowIdx, 0, _Content); | 1841 | AddLabeltoGrid(_RowIdx, 0, _Content); |
| 1841 | 1842 | ||
| 1842 | //column 2 | 1843 | //column 2 |
| 1843 | // Display Node's Position | 1844 | // Display Node's Position |
| 1844 | _Content = ni.X + ", " + ni.Y; | 1845 | _Content = ni.X + ", " + ni.Y; |
| 1845 | AddLabeltoGrid(_RowIdx, 1, _Content); | 1846 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 1846 | 1847 | ||
| 1847 | // Display Node's Field | 1848 | // Display Node's Field |
| 1848 | if (ni.Mode1 != "" && ni.Mode1 != null) | 1849 | if (ni.Mode1 != "" && ni.Mode1 != null) |
| 1849 | { | 1850 | { |
| 1850 | char delimiterChars = '_'; | 1851 | char delimiterChars = '_'; |
| 1851 | string[] tmp = ni.Mode1.Split(delimiterChars); | 1852 | string[] tmp = ni.Mode1.Split(delimiterChars); |
| 1852 | foreach (string s in tmp) | 1853 | foreach (string s in tmp) |
| 1853 | { | 1854 | { |
| 1854 | _RowIdx++; | 1855 | _RowIdx++; |
| 1855 | delimiterChars = ':'; | 1856 | delimiterChars = ':'; |
| 1856 | 1857 | ||
| 1857 | if (s.Split(delimiterChars)[0] == "Mode") | 1858 | if (s.Split(delimiterChars)[0] == "Mode") |
| 1858 | { | 1859 | { |
| 1859 | double distance = 0; | 1860 | double distance = 0; |
| 1860 | if (i == NodeInfo_List.Count - 1) | 1861 | if (i == NodeInfo_List.Count - 1) |
| 1861 | { | 1862 | { |
| 1862 | distance = 0; | 1863 | distance = 0; |
| 1863 | } | 1864 | } |
| 1864 | else | 1865 | else |
| 1865 | { | 1866 | { |
| 1866 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); | 1867 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); |
| 1867 | } | 1868 | } |
| 1868 | _Content = "MOVE " + distance.ToString() + "mm"; | 1869 | _Content = "MOVE " + distance.ToString() + "mm"; |
| 1869 | } | 1870 | } |
| 1870 | else | 1871 | else |
| 1871 | { | 1872 | { |
| 1872 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; | 1873 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; |
| 1873 | } | 1874 | } |
| 1874 | 1875 | ||
| 1875 | AddLabeltoGrid(_RowIdx, 1, _Content); | 1876 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 1876 | } | 1877 | } |
| 1877 | } | 1878 | } |
| 1878 | 1879 | ||
| 1879 | if (ni.Mode2 != "" && ni.Mode2 != null) | 1880 | if (ni.Mode2 != "" && ni.Mode2 != null) |
| 1880 | { | 1881 | { |
| 1881 | char delimiterChars = '_'; | 1882 | char delimiterChars = '_'; |
| 1882 | string[] tmp = ni.Mode2.Split(delimiterChars); | 1883 | string[] tmp = ni.Mode2.Split(delimiterChars); |
| 1883 | foreach (string s in tmp) | 1884 | foreach (string s in tmp) |
| 1884 | { | 1885 | { |
| 1885 | _RowIdx++; | 1886 | _RowIdx++; |
| 1886 | delimiterChars = ':'; | 1887 | delimiterChars = ':'; |
| 1887 | 1888 | ||
| 1888 | if (s.Split(delimiterChars)[0] == "Mode") | 1889 | if (s.Split(delimiterChars)[0] == "Mode") |
| 1889 | { | 1890 | { |
| 1890 | double distance = 0; | 1891 | double distance = 0; |
| 1891 | if (i == NodeInfo_List.Count - 1) | 1892 | if (i == NodeInfo_List.Count - 1) |
| 1892 | { | 1893 | { |
| 1893 | distance = 0; | 1894 | distance = 0; |
| 1894 | } | 1895 | } |
| 1895 | else | 1896 | else |
| 1896 | { | 1897 | { |
| 1897 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); | 1898 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); |
| 1898 | } | 1899 | } |
| 1899 | _Content = "MOVE " + distance.ToString() + "mm"; | 1900 | _Content = "MOVE " + distance.ToString() + "mm"; |
| 1900 | } | 1901 | } |
| 1901 | else | 1902 | else |
| 1902 | { | 1903 | { |
| 1903 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; | 1904 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; |
| 1904 | } | 1905 | } |
| 1905 | 1906 | ||
| 1906 | AddLabeltoGrid(_RowIdx, 1, _Content); | 1907 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 1907 | } | 1908 | } |
| 1908 | } | 1909 | } |
| 1909 | 1910 | ||
| 1910 | if (ni.Mode3 != "" && ni.Mode3 != null) | 1911 | if (ni.Mode3 != "" && ni.Mode3 != null) |
| 1911 | { | 1912 | { |
| 1912 | char delimiterChars = '_'; | 1913 | char delimiterChars = '_'; |
| 1913 | string[] tmp = ni.Mode3.Split(delimiterChars); | 1914 | string[] tmp = ni.Mode3.Split(delimiterChars); |
| 1914 | foreach (string s in tmp) | 1915 | foreach (string s in tmp) |
| 1915 | { | 1916 | { |
| 1916 | _RowIdx++; | 1917 | _RowIdx++; |
| 1917 | delimiterChars = ':'; | 1918 | delimiterChars = ':'; |
| 1918 | 1919 | ||
| 1919 | if (s.Split(delimiterChars)[0] == "Mode") | 1920 | if (s.Split(delimiterChars)[0] == "Mode") |
| 1920 | { | 1921 | { |
| 1921 | double distance = 0; | 1922 | double distance = 0; |
| 1922 | if (i == NodeInfo_List.Count - 1) | 1923 | if (i == NodeInfo_List.Count - 1) |
| 1923 | { | 1924 | { |
| 1924 | distance = 0; | 1925 | distance = 0; |
| 1925 | } | 1926 | } |
| 1926 | else | 1927 | else |
| 1927 | { | 1928 | { |
| 1928 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); | 1929 | distance = DistanceCalculate(NodeInfo_List[i].X, NodeInfo_List[i].Y, NodeInfo_List[i + 1].X, NodeInfo_List[i + 1].Y); |
| 1929 | } | 1930 | } |
| 1930 | _Content = "MOVE " + distance.ToString() + "mm"; | 1931 | _Content = "MOVE " + distance.ToString() + "mm"; |
| 1931 | } | 1932 | } |
| 1932 | else | 1933 | else |
| 1933 | { | 1934 | { |
| 1934 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; | 1935 | _Content = s.Split(delimiterChars)[0] + " " + s.Split(delimiterChars)[1]; |
| 1935 | } | 1936 | } |
| 1936 | 1937 | ||
| 1937 | AddLabeltoGrid(_RowIdx, 1, _Content); | 1938 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 1938 | } | 1939 | } |
| 1939 | } | 1940 | } |
| 1940 | _RowIdx++; | 1941 | _RowIdx++; |
| 1941 | } | 1942 | } |
| 1942 | } | 1943 | } |
| 1943 | } | 1944 | } |
| 1944 | 1945 | ||
| 1945 | public double DistanceCalculate(double _X1, double _Y1, double _X2, double _Y2) | 1946 | public double DistanceCalculate(double _X1, double _Y1, double _X2, double _Y2) |
| 1946 | { | 1947 | { |
| 1947 | double dist = 0; | 1948 | double dist = 0; |
| 1948 | 1949 | ||
| 1949 | if (_X1 == _X2) | 1950 | if (_X1 == _X2) |
| 1950 | { | 1951 | { |
| 1951 | dist = System.Math.Abs(_Y1 - _Y2) * DISTANCE_RATIO; | 1952 | dist = System.Math.Abs(_Y1 - _Y2) * DISTANCE_RATIO; |
| 1952 | } | 1953 | } |
| 1953 | else if (_Y1 == _Y2) | 1954 | else if (_Y1 == _Y2) |
| 1954 | { | 1955 | { |
| 1955 | dist = System.Math.Abs(_X1 - _X2) * DISTANCE_RATIO; | 1956 | dist = System.Math.Abs(_X1 - _X2) * DISTANCE_RATIO; |
| 1956 | } | 1957 | } |
| 1957 | return dist; | 1958 | return dist; |
| 1958 | } | 1959 | } |
| 1959 | 1960 | ||
| 1960 | public void AddLabeltoGrid(int RowIdx, int ColIdx, string Content) | 1961 | public void AddLabeltoGrid(int RowIdx, int ColIdx, string Content) |
| 1961 | { | 1962 | { |
| 1962 | //Add Row to Grid | 1963 | //Add Row to Grid |
| 1963 | RowDefinition _rd = new RowDefinition(); | 1964 | RowDefinition _rd = new RowDefinition(); |
| 1964 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.RowDefinitions.Add(_rd); | 1965 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.RowDefinitions.Add(_rd); |
| 1965 | 1966 | ||
| 1966 | // Add data to Grid | 1967 | // Add data to Grid |
| 1967 | Label dynamicLabel = new Label(); | 1968 | Label dynamicLabel = new Label(); |
| 1968 | 1969 | ||
| 1969 | dynamicLabel.Content = Content; | 1970 | dynamicLabel.Content = Content; |
| 1970 | dynamicLabel.Margin = new Thickness(0, 0, 0, 0); | 1971 | dynamicLabel.Margin = new Thickness(0, 0, 0, 0); |
| 1971 | dynamicLabel.Foreground = new SolidColorBrush(Colors.Black); | 1972 | dynamicLabel.Foreground = new SolidColorBrush(Colors.Black); |
| 1972 | dynamicLabel.Background = new SolidColorBrush(Colors.White); | 1973 | dynamicLabel.Background = new SolidColorBrush(Colors.White); |
| 1973 | dynamicLabel.BorderBrush = new SolidColorBrush(Colors.LightGray); | 1974 | dynamicLabel.BorderBrush = new SolidColorBrush(Colors.LightGray); |
| 1974 | dynamicLabel.BorderThickness = new Thickness(1); | 1975 | dynamicLabel.BorderThickness = new Thickness(1); |
| 1975 | 1976 | ||
| 1976 | Grid.SetRow(dynamicLabel, RowIdx); | 1977 | Grid.SetRow(dynamicLabel, RowIdx); |
| 1977 | Grid.SetColumn(dynamicLabel, ColIdx); | 1978 | Grid.SetColumn(dynamicLabel, ColIdx); |
| 1978 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Add(dynamicLabel); | 1979 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Add(dynamicLabel); |
| 1979 | } | 1980 | } |
| 1980 | #endregion | 1981 | #endregion |
| 1981 | 1982 | ||
| 1982 | 1983 | ||
| 1983 | public void CreateGoalPoint() | 1984 | public void CreateGoalPoint() |
| 1984 | { | 1985 | { |
| 1985 | if (isGoalDrawRoute) | 1986 | if (isGoalDrawRoute) |
| 1986 | { | 1987 | { |
| 1987 | return; | 1988 | return; |
| 1988 | } | 1989 | } |
| 1989 | 1990 | ||
| 1990 | isStartDrawRoute = false; | 1991 | isStartDrawRoute = false; |
| 1991 | if (_goalPoint == null) | 1992 | if (_goalPoint == null) |
| 1992 | { | 1993 | { |
| 1993 | _goalPoint = new ucStartEndButton(); | 1994 | _goalPoint = new ucStartEndButton(); |
| 1994 | _goalPoint.btnWidth = 50.0; | 1995 | _goalPoint.btnWidth = 50.0; |
| 1995 | _goalPoint.btnHeight = 50.0; | 1996 | _goalPoint.btnHeight = 50.0; |
| 1996 | _goalPoint.buttText = "G"; | 1997 | _goalPoint.buttText = "G"; |
| 1997 | Canvas.SetLeft(_goalPoint, 675); | 1998 | Canvas.SetLeft(_goalPoint, 675); |
| 1998 | Canvas.SetTop(_goalPoint, 75); | 1999 | Canvas.SetTop(_goalPoint, 75); |
| 1999 | this.Children.Add(_goalPoint); | 2000 | this.Children.Add(_goalPoint); |
| 2000 | } | 2001 | } |
| 2001 | } | 2002 | } |
| 2002 | 2003 | ||
| 2003 | public void CreateStartPoint() | 2004 | public void CreateStartPoint() |
| 2004 | { | 2005 | { |
| 2005 | if (isGoalDrawRoute) | 2006 | if (isGoalDrawRoute) |
| 2006 | { | 2007 | { |
| 2007 | return; | 2008 | return; |
| 2008 | } | 2009 | } |
| 2009 | 2010 | ||
| 2010 | isStartDrawRoute = false; | 2011 | isStartDrawRoute = false; |
| 2011 | if (_startPoint == null) | 2012 | if (_startPoint == null) |
| 2012 | { | 2013 | { |
| 2013 | _startPoint = new ucStartEndButton(); | 2014 | _startPoint = new ucStartEndButton(); |
| 2014 | _startPoint.btnWidth = 50.0; | 2015 | _startPoint.btnWidth = 50.0; |
| 2015 | _startPoint.btnHeight = 50.0; | 2016 | _startPoint.btnHeight = 50.0; |
| 2016 | _startPoint.buttText = "S"; | 2017 | _startPoint.buttText = "S"; |
| 2017 | Canvas.SetLeft(_startPoint, 75); | 2018 | Canvas.SetLeft(_startPoint, 75); |
| 2018 | Canvas.SetTop(_startPoint, 675); | 2019 | Canvas.SetTop(_startPoint, 675); |
| 2019 | this.Children.Add(_startPoint); | 2020 | this.Children.Add(_startPoint); |
| 2020 | } | 2021 | } |
| 2021 | } | 2022 | } |
| 2022 | 2023 | ||
| 2023 | 2024 | ||
| 2024 | 2025 | ||
| 2025 | 2026 | ||
| 2026 | 2027 | ||
| 2027 | 2028 | ||
| 2028 | 2029 | ||
| 2029 | #region Draw New FreeNode | 2030 | #region Draw New FreeNode |
| 2030 | 2031 | ||
| 2031 | /// <summary> | 2032 | /// <summary> |
| 2032 | /// Draw Auto Blue node | 2033 | /// Draw Auto Blue node |
| 2033 | /// </summary> | 2034 | /// </summary> |
| 2034 | 2035 | ||
| 2035 | 2036 | ||
| 2036 | public void NewSetFreeNodes(Point FreeNode, bool RightClick) | 2037 | public void NewSetFreeNodes(Point FreeNode, bool RightClick) |
| 2037 | { | 2038 | { |
| 2038 | double radiusNode = RADIUS_NODE; | 2039 | double radiusNode = RADIUS_NODE; |
| 2039 | 2040 | ||
| 2040 | EllipseGeometry ellipseGeometry; | 2041 | EllipseGeometry ellipseGeometry; |
| 2041 | Point node; | 2042 | Point node; |
| 2042 | bool deleteFlag = false; | 2043 | bool deleteFlag = false; |
| 2043 | 2044 | ||
| 2044 | 2045 | ||
| 2045 | if (RightClick) | 2046 | if (RightClick) |
| 2046 | { | 2047 | { |
| 2047 | if (gGrpBlueNode.Children.Count > 0) | 2048 | if (gGrpBlueNode.Children.Count > 0) |
| 2048 | { | 2049 | { |
| 2049 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2050 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2050 | { | 2051 | { |
| 2051 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2052 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2052 | node = ellipseGeometry.Center; | 2053 | node = ellipseGeometry.Center; |
| 2053 | if (FreeNode.X == node.X) | 2054 | if (FreeNode.X == node.X) |
| 2054 | { | 2055 | { |
| 2055 | if (CheckIsNode(FreeNode, node, radiusNode)) | 2056 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 2056 | { | 2057 | { |
| 2057 | deleteFlag = true; | 2058 | deleteFlag = true; |
| 2058 | } | 2059 | } |
| 2059 | } | 2060 | } |
| 2060 | else | 2061 | else |
| 2061 | { | 2062 | { |
| 2062 | if (CheckIsNode(FreeNode, node, radiusNode)) | 2063 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 2063 | { | 2064 | { |
| 2064 | deleteFlag = true; | 2065 | deleteFlag = true; |
| 2065 | } | 2066 | } |
| 2066 | } | 2067 | } |
| 2067 | if (deleteFlag) | 2068 | if (deleteFlag) |
| 2068 | { | 2069 | { |
| 2069 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); | 2070 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); |
| 2070 | if (result == MessageBoxResult.OK) | 2071 | if (result == MessageBoxResult.OK) |
| 2071 | { | 2072 | { |
| 2072 | 2073 | ||
| 2073 | //Call Function Delete Node | 2074 | //Call Function Delete Node |
| 2074 | DeleteNode(i); | 2075 | DeleteNode(i); |
| 2075 | 2076 | ||
| 2076 | //gGrpBlueNode.Children.RemoveAt(i); | 2077 | //gGrpBlueNode.Children.RemoveAt(i); |
| 2077 | 2078 | ||
| 2078 | //this.Children.Remove(NodeNo[i]); | 2079 | //this.Children.Remove(NodeNo[i]); |
| 2079 | return; | 2080 | return; |
| 2080 | } | 2081 | } |
| 2081 | else | 2082 | else |
| 2082 | { | 2083 | { |
| 2083 | return; | 2084 | return; |
| 2084 | } | 2085 | } |
| 2085 | } | 2086 | } |
| 2086 | } | 2087 | } |
| 2087 | } | 2088 | } |
| 2088 | } | 2089 | } |
| 2089 | else | 2090 | else |
| 2090 | { | 2091 | { |
| 2091 | //Check EditNode State | 2092 | //Check EditNode State |
| 2092 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2093 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2093 | { | 2094 | { |
| 2094 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2095 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2095 | node = ellipseGeometry.Center; | 2096 | node = ellipseGeometry.Center; |
| 2096 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); | 2097 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); |
| 2097 | 2098 | ||
| 2098 | if (isEditNode) | 2099 | if (isEditNode) |
| 2099 | { | 2100 | { |
| 2100 | NewEditNode(node); | 2101 | NewEditNode(node); |
| 2101 | NewDspRouteInfo(); | 2102 | NewDspRouteInfo(); |
| 2102 | return; | 2103 | return; |
| 2103 | } | 2104 | } |
| 2104 | } | 2105 | } |
| 2105 | 2106 | ||
| 2106 | 2107 | ||
| 2107 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); | 2108 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); |
| 2108 | if (result == MessageBoxResult.OK) | 2109 | if (result == MessageBoxResult.OK) |
| 2109 | { | 2110 | { |
| 2110 | AddNode(FreeNode, gGrpBlueNode); | 2111 | AddNode(FreeNode, gGrpBlueNode); |
| 2111 | 2112 | ||
| 2112 | TextBlock textBlock = new TextBlock(); | 2113 | TextBlock textBlock = new TextBlock(); |
| 2113 | textBlock.Text = stt.ToString(); | 2114 | textBlock.Text = stt.ToString(); |
| 2114 | textBlock.FontSize = 35; | 2115 | textBlock.FontSize = 35; |
| 2115 | textBlock.VerticalAlignment = VerticalAlignment.Center; | 2116 | textBlock.VerticalAlignment = VerticalAlignment.Center; |
| 2116 | textBlock.HorizontalAlignment = HorizontalAlignment.Center; | 2117 | textBlock.HorizontalAlignment = HorizontalAlignment.Center; |
| 2117 | textBlock.Foreground = new SolidColorBrush(Colors.Red); | 2118 | textBlock.Foreground = new SolidColorBrush(Colors.Red); |
| 2118 | 2119 | ||
| 2119 | Canvas.SetLeft(textBlock, FreeNode.X - RADIUS_NODE / 2); | 2120 | Canvas.SetLeft(textBlock, FreeNode.X - RADIUS_NODE / 2); |
| 2120 | Canvas.SetTop(textBlock, FreeNode.Y - 1.5 * RADIUS_NODE); | 2121 | Canvas.SetTop(textBlock, FreeNode.Y - 1.5 * RADIUS_NODE); |
| 2121 | 2122 | ||
| 2122 | 2123 | ||
| 2123 | this.Children.Add(textBlock); | 2124 | this.Children.Add(textBlock); |
| 2124 | NodeNo.Add(textBlock); | 2125 | NodeNo.Add(textBlock); |
| 2125 | 2126 | ||
| 2126 | if (stt > 1) | 2127 | if (stt > 1) |
| 2127 | { | 2128 | { |
| 2128 | int tmp = gGrpBlueNode.Children.Count; | 2129 | int tmp = gGrpBlueNode.Children.Count; |
| 2129 | 2130 | ||
| 2130 | EllipseGeometry elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; | 2131 | EllipseGeometry elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; |
| 2131 | Point node1 = elip.Center; | 2132 | Point node1 = elip.Center; |
| 2132 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; | 2133 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; |
| 2133 | Point node2 = elip.Center; | 2134 | Point node2 = elip.Center; |
| 2134 | DrawLine(node1, node2, gGrpNewLine); | 2135 | DrawLine(node1, node2, gGrpNewLine); |
| 2135 | 2136 | ||
| 2136 | 2137 | ||
| 2137 | this.Children.Remove(pBlueNode); | 2138 | this.Children.Remove(pBlueNode); |
| 2138 | for (int i = 0; i < tmp; i++) | 2139 | for (int i = 0; i < tmp; i++) |
| 2139 | { | 2140 | { |
| 2140 | this.Children.Remove(NodeNo[i]); | 2141 | this.Children.Remove(NodeNo[i]); |
| 2141 | } | 2142 | } |
| 2142 | 2143 | ||
| 2143 | this.Children.Add(pBlueNode); | 2144 | this.Children.Add(pBlueNode); |
| 2144 | for (int i = 0; i < tmp; i++) | 2145 | for (int i = 0; i < tmp; i++) |
| 2145 | { | 2146 | { |
| 2146 | this.Children.Add(NodeNo[i]); | 2147 | this.Children.Add(NodeNo[i]); |
| 2147 | } | 2148 | } |
| 2148 | } | 2149 | } |
| 2149 | 2150 | ||
| 2150 | stt++; | 2151 | stt++; |
| 2151 | NewInitNodeInfo_List(); | 2152 | NewInitNodeInfo_List(); |
| 2152 | NewDspRouteInfo(); | 2153 | NewDspRouteInfo(); |
| 2153 | } | 2154 | } |
| 2154 | } | 2155 | } |
| 2155 | } | 2156 | } |
| 2156 | 2157 | ||
| 2157 | public void DeleteNode(int i) | 2158 | public void DeleteNode(int i) |
| 2158 | { | 2159 | { |
| 2159 | //DrawLine(Point startPoint, Point endPoint, GeometryGroup geometryGroup) | 2160 | //DrawLine(Point startPoint, Point endPoint, GeometryGroup geometryGroup) |
| 2160 | 2161 | ||
| 2161 | LineGeometry lineGeometry = new LineGeometry(); | 2162 | LineGeometry lineGeometry = new LineGeometry(); |
| 2162 | EllipseGeometry ellip; | 2163 | EllipseGeometry ellip; |
| 2163 | 2164 | ||
| 2164 | 2165 | ||
| 2165 | if (i == gGrpBlueNode.Children.Count - 1) | 2166 | if (i == gGrpBlueNode.Children.Count - 1) |
| 2166 | { | 2167 | { |
| 2167 | // delete line | 2168 | // delete line |
| 2168 | if (gGrpNewLine.Children.Count > 0) | 2169 | if (gGrpNewLine.Children.Count > 0) |
| 2169 | { | 2170 | { |
| 2170 | gGrpNewLine.Children.RemoveAt(i - 1); | 2171 | gGrpNewLine.Children.RemoveAt(i - 1); |
| 2171 | } | 2172 | } |
| 2172 | 2173 | ||
| 2173 | // delete ucNode | 2174 | // delete ucNode |
| 2174 | ucNode _ucNode = new ucNode(); | 2175 | ucNode _ucNode = new ucNode(); |
| 2175 | _ucNode = ucNode_Lst[i]; | 2176 | _ucNode = ucNode_Lst[i]; |
| 2176 | this.Children.Remove(_ucNode); | 2177 | this.Children.Remove(_ucNode); |
| 2177 | ucNode_Lst.RemoveAt(i); | 2178 | ucNode_Lst.RemoveAt(i); |
| 2178 | 2179 | ||
| 2179 | // delete node | 2180 | // delete node |
| 2180 | gGrpBlueNode.Children.RemoveAt(i); | 2181 | gGrpBlueNode.Children.RemoveAt(i); |
| 2181 | NewNodeInfo_List.RemoveAt(i); | 2182 | NewNodeInfo_List.RemoveAt(i); |
| 2182 | 2183 | ||
| 2183 | } | 2184 | } |
| 2184 | else | 2185 | else |
| 2185 | { | 2186 | { |
| 2186 | // remove last Node | 2187 | // remove last Node |
| 2187 | int lastIdx = gGrpBlueNode.Children.Count - 1; | 2188 | int lastIdx = gGrpBlueNode.Children.Count - 1; |
| 2188 | 2189 | ||
| 2189 | NewNodeInfo_List.RemoveAt(lastIdx); | 2190 | NewNodeInfo_List.RemoveAt(lastIdx); |
| 2190 | gGrpBlueNode.Children.RemoveAt(lastIdx); | 2191 | gGrpBlueNode.Children.RemoveAt(lastIdx); |
| 2191 | gGrpNewLine.Children.RemoveAt(lastIdx - 1); | 2192 | gGrpNewLine.Children.RemoveAt(lastIdx - 1); |
| 2192 | 2193 | ||
| 2193 | ucNode _ucNode = new ucNode(); | 2194 | ucNode _ucNode = new ucNode(); |
| 2194 | _ucNode = ucNode_Lst[lastIdx]; | 2195 | _ucNode = ucNode_Lst[lastIdx]; |
| 2195 | this.Children.Remove(_ucNode); | 2196 | this.Children.Remove(_ucNode); |
| 2196 | 2197 | ||
| 2197 | ucNode_Lst.RemoveAt(lastIdx); | 2198 | ucNode_Lst.RemoveAt(lastIdx); |
| 2198 | 2199 | ||
| 2199 | 2200 | ||
| 2200 | 2201 | ||
| 2201 | 2202 | ||
| 2202 | // ellip = (EllipseGeometry)gGrpBlueNode.Children[i - 1]; | 2203 | // ellip = (EllipseGeometry)gGrpBlueNode.Children[i - 1]; |
| 2203 | //Point p1 = ellip.Center; | 2204 | //Point p1 = ellip.Center; |
| 2204 | //ellip = (EllipseGeometry)gGrpBlueNode.Children[i + 1]; | 2205 | //ellip = (EllipseGeometry)gGrpBlueNode.Children[i + 1]; |
| 2205 | //Point p2 = ellip.Center; | 2206 | //Point p2 = ellip.Center; |
| 2206 | 2207 | ||
| 2207 | //gGrpNewLine.Children.RemoveAt(i); | 2208 | //gGrpNewLine.Children.RemoveAt(i); |
| 2208 | //gGrpNewLine.Children.RemoveAt(i - 1); | 2209 | //gGrpNewLine.Children.RemoveAt(i - 1); |
| 2209 | 2210 | ||
| 2210 | 2211 | ||
| 2211 | //lineGeometry.StartPoint = p1; | 2212 | //lineGeometry.StartPoint = p1; |
| 2212 | //lineGeometry.EndPoint = p2; | 2213 | //lineGeometry.EndPoint = p2; |
| 2213 | //gGrpNewLine.Children.Add(lineGeometry); | 2214 | //gGrpNewLine.Children.Add(lineGeometry); |
| 2214 | 2215 | ||
| 2215 | ////gGrpNewLine.Children.Clear(); | 2216 | ////gGrpNewLine.Children.Clear(); |
| 2216 | 2217 | ||
| 2217 | //this.Children.Remove(pNewLine); | 2218 | //this.Children.Remove(pNewLine); |
| 2218 | //this.Children.Add(pNewLine); | 2219 | //this.Children.Add(pNewLine); |
| 2219 | 2220 | ||
| 2220 | //gGrpBlueNode.Children.RemoveAt(i); | 2221 | //gGrpBlueNode.Children.RemoveAt(i); |
| 2221 | } | 2222 | } |
| 2222 | 2223 | ||
| 2223 | 2224 | ||
| 2224 | 2225 | ||
| 2225 | //NewInitNodeInfo_List(); | 2226 | //NewInitNodeInfo_List(); |
| 2226 | 2227 | ||
| 2227 | 2228 | ||
| 2228 | NewDspRouteInfo(); | 2229 | NewDspRouteInfo(); |
| 2229 | stt--; | 2230 | stt--; |
| 2230 | 2231 | ||
| 2231 | 2232 | ||
| 2232 | } | 2233 | } |
| 2233 | 2234 | ||
| 2234 | 2235 | ||
| 2235 | 2236 | ||
| 2236 | 2237 | ||
| 2237 | public void NewInitNodeInfo_List() | 2238 | public void NewInitNodeInfo_List() |
| 2238 | { | 2239 | { |
| 2239 | //Reset List | 2240 | //Reset List |
| 2240 | //NewNodeInfo_List = new List<NewNodeInfo>(); | 2241 | //NewNodeInfo_List = new List<NewNodeInfo>(); |
| 2241 | 2242 | ||
| 2242 | if (gGrpBlueNode.Children.Count > 0) | 2243 | if (gGrpBlueNode.Children.Count > 0) |
| 2243 | { | 2244 | { |
| 2244 | //for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2245 | //for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2245 | //{ | 2246 | //{ |
| 2246 | int i = gGrpBlueNode.Children.Count - 1; | 2247 | int i = gGrpBlueNode.Children.Count - 1; |
| 2247 | Point point; | 2248 | Point point; |
| 2248 | EllipseGeometry eGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2249 | EllipseGeometry eGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2249 | point = eGeometry.Center; | 2250 | point = eGeometry.Center; |
| 2250 | 2251 | ||
| 2251 | NewNodeInfo Ninfo = new NewNodeInfo(); | 2252 | NewNodeInfo Ninfo = new NewNodeInfo(); |
| 2252 | Ninfo.X = point.X; | 2253 | Ninfo.X = point.X; |
| 2253 | Ninfo.Y = point.Y; | 2254 | Ninfo.Y = point.Y; |
| 2254 | 2255 | ||
| 2255 | Ninfo.Mode = ""; | 2256 | Ninfo.Mode = ""; |
| 2256 | 2257 | ||
| 2257 | NewNodeInfo_List.Add(Ninfo); | 2258 | NewNodeInfo_List.Add(Ninfo); |
| 2258 | //} | 2259 | //} |
| 2259 | 2260 | ||
| 2260 | } | 2261 | } |
| 2261 | } | 2262 | } |
| 2262 | 2263 | ||
| 2263 | public void NewEditNode(Point node_edited) | 2264 | public void NewEditNode(Point node_edited) |
| 2264 | { | 2265 | { |
| 2265 | EllipseGeometry ellipseGeometry; | 2266 | EllipseGeometry ellipseGeometry; |
| 2266 | Point node; | 2267 | Point node; |
| 2267 | double radiusNode = RADIUS_NODE; | 2268 | double radiusNode = RADIUS_NODE; |
| 2268 | 2269 | ||
| 2269 | bool flag = false; | 2270 | bool flag = false; |
| 2270 | 2271 | ||
| 2271 | if (gGrpBlueNode.Children.Count > 0) | 2272 | if (gGrpBlueNode.Children.Count > 0) |
| 2272 | { | 2273 | { |
| 2273 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2274 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2274 | { | 2275 | { |
| 2275 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2276 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2276 | node = ellipseGeometry.Center; | 2277 | node = ellipseGeometry.Center; |
| 2277 | 2278 | ||
| 2278 | if (CheckIsNode(node_edited, node, radiusNode)) | 2279 | if (CheckIsNode(node_edited, node, radiusNode)) |
| 2279 | { | 2280 | { |
| 2280 | flag = true; | 2281 | flag = true; |
| 2281 | } | 2282 | } |
| 2282 | 2283 | ||
| 2283 | if (flag) | 2284 | if (flag) |
| 2284 | { | 2285 | { |
| 2285 | node_edited.X = node.X; | 2286 | node_edited.X = node.X; |
| 2286 | node_edited.Y = node.Y; | 2287 | node_edited.Y = node.Y; |
| 2287 | 2288 | ||
| 2288 | // show form edit node | 2289 | // show form edit node |
| 2289 | EditNodeWindow edtNodeWindow = new EditNodeWindow(); | 2290 | EditNodeWindow edtNodeWindow = new EditNodeWindow(); |
| 2290 | edtNodeWindow.ShowDialog(); | 2291 | edtNodeWindow.ShowDialog(); |
| 2291 | 2292 | ||
| 2292 | string result = edtNodeWindow._txtMode; | 2293 | string result = edtNodeWindow._txtMode; |
| 2293 | bool exit = edtNodeWindow._ExitFlg; | 2294 | bool exit = edtNodeWindow._ExitFlg; |
| 2294 | 2295 | ||
| 2295 | if (!exit) | 2296 | if (!exit) |
| 2296 | { | 2297 | { |
| 2297 | NewSaveChanged(node_edited.X, node_edited.Y, result); | 2298 | NewSaveChanged(node_edited.X, node_edited.Y, result); |
| 2298 | } | 2299 | } |
| 2299 | 2300 | ||
| 2300 | return; | 2301 | return; |
| 2301 | } | 2302 | } |
| 2302 | } | 2303 | } |
| 2303 | } | 2304 | } |
| 2304 | } | 2305 | } |
| 2305 | 2306 | ||
| 2306 | //Save Node's Data Edited | 2307 | //Save Node's Data Edited |
| 2307 | public void NewSaveChanged(double x, double y, string st) | 2308 | public void NewSaveChanged(double x, double y, string st) |
| 2308 | { | 2309 | { |
| 2309 | for (int i = 0; i < NewNodeInfo_List.Count; i++) | 2310 | for (int i = 0; i < NewNodeInfo_List.Count; i++) |
| 2310 | { | 2311 | { |
| 2311 | NewNodeInfo ni = new NewNodeInfo(); | 2312 | NewNodeInfo ni = new NewNodeInfo(); |
| 2312 | ni = NewNodeInfo_List[i]; | 2313 | ni = NewNodeInfo_List[i]; |
| 2313 | 2314 | ||
| 2314 | if (ni.X == x && ni.Y == y) | 2315 | if (ni.X == x && ni.Y == y) |
| 2315 | { | 2316 | { |
| 2316 | ni.Mode = st; | 2317 | ni.Mode = st; |
| 2317 | 2318 | ||
| 2318 | NewNodeInfo_List[i] = ni; | 2319 | NewNodeInfo_List[i] = ni; |
| 2319 | return; | 2320 | return; |
| 2320 | } | 2321 | } |
| 2321 | } | 2322 | } |
| 2322 | } | 2323 | } |
| 2323 | 2324 | ||
| 2324 | public void NewDspRouteInfo() | 2325 | public void NewDspRouteInfo() |
| 2325 | { | 2326 | { |
| 2326 | //Clear Route Info Table | 2327 | //Clear Route Info Table |
| 2327 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Clear(); | 2328 | ((RoboforkMenu)System.Windows.Application.Current.MainWindow).grdRouteInfo.Children.Clear(); |
| 2328 | 2329 | ||
| 2329 | if (NewNodeInfo_List.Count != 0) | 2330 | if (NewNodeInfo_List.Count != 0) |
| 2330 | { | 2331 | { |
| 2331 | int _RowIdx = 0; | 2332 | int _RowIdx = 0; |
| 2332 | string _Content = ""; | 2333 | string _Content = ""; |
| 2333 | 2334 | ||
| 2334 | for (int i = 0; i < NewNodeInfo_List.Count; i++) | 2335 | for (int i = 0; i < NewNodeInfo_List.Count; i++) |
| 2335 | { | 2336 | { |
| 2336 | 2337 | ||
| 2337 | NewNodeInfo ni = new NewNodeInfo(); | 2338 | NewNodeInfo ni = new NewNodeInfo(); |
| 2338 | ni = NewNodeInfo_List[i]; | 2339 | ni = NewNodeInfo_List[i]; |
| 2339 | 2340 | ||
| 2340 | //column 1 | 2341 | //column 1 |
| 2341 | _Content = (i +1).ToString(); | 2342 | _Content = (i +1).ToString(); |
| 2342 | AddLabeltoGrid(_RowIdx, 0, _Content); | 2343 | AddLabeltoGrid(_RowIdx, 0, _Content); |
| 2343 | 2344 | ||
| 2344 | //column 2 | 2345 | //column 2 |
| 2345 | // Display Node's Position | 2346 | // Display Node's Position |
| 2346 | _Content = "LAT " + ni.X; | 2347 | _Content = "LAT " + ni.X; |
| 2347 | AddLabeltoGrid(_RowIdx, 1, _Content); | 2348 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 2348 | _RowIdx++; | 2349 | _RowIdx++; |
| 2349 | 2350 | ||
| 2350 | _Content = "LOC " + ni.Y; | 2351 | _Content = "LOC " + ni.Y; |
| 2351 | AddLabeltoGrid(_RowIdx, 1, _Content); | 2352 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 2352 | 2353 | ||
| 2353 | // Display Node's Field | 2354 | // Display Node's Field |
| 2354 | if (ni.Mode != "" && ni.Mode != null) | 2355 | if (ni.Mode != "" && ni.Mode != null) |
| 2355 | { | 2356 | { |
| 2356 | char delimiterChars = '_'; | 2357 | char delimiterChars = '_'; |
| 2357 | string[] tmp = ni.Mode.Split(delimiterChars); | 2358 | string[] tmp = ni.Mode.Split(delimiterChars); |
| 2358 | foreach (string s in tmp) | 2359 | foreach (string s in tmp) |
| 2359 | { | 2360 | { |
| 2360 | _RowIdx++; | 2361 | _RowIdx++; |
| 2361 | delimiterChars = ':'; | 2362 | delimiterChars = ':'; |
| 2362 | 2363 | ||
| 2363 | if (s.Split(delimiterChars)[0] == "Speed") | 2364 | if (s.Split(delimiterChars)[0] == "Speed") |
| 2364 | { | 2365 | { |
| 2365 | _Content = "SPD " + s.Split(delimiterChars)[1]; | 2366 | _Content = "SPD " + s.Split(delimiterChars)[1]; |
| 2366 | AddLabeltoGrid(_RowIdx, 1, _Content); | 2367 | AddLabeltoGrid(_RowIdx, 1, _Content); |
| 2367 | } | 2368 | } |
| 2368 | } | 2369 | } |
| 2369 | } | 2370 | } |
| 2370 | _RowIdx++; | 2371 | _RowIdx++; |
| 2371 | } | 2372 | } |
| 2372 | } | 2373 | } |
| 2373 | } | 2374 | } |
| 2374 | 2375 | ||
| 2375 | 2376 | ||
| 2376 | private void CreateNode(Point FreeNode, bool LeftClick, bool RightClick) | 2377 | private void CreateNode(Point FreeNode, bool LeftClick, bool RightClick) |
| 2377 | { | 2378 | { |
| 2378 | double radiusNode = RADIUS_NODE; | 2379 | double radiusNode = RADIUS_NODE; |
| 2379 | 2380 | ||
| 2380 | EllipseGeometry ellipseGeometry; | 2381 | EllipseGeometry ellipseGeometry; |
| 2381 | Point node; | 2382 | Point node; |
| 2382 | bool deleteFlag = false; | 2383 | bool deleteFlag = false; |
| 2383 | 2384 | ||
| 2384 | //Su kien bam chuot phai | 2385 | //Su kien bam chuot phai |
| 2385 | if (RightClick) | 2386 | if (RightClick) |
| 2386 | { | 2387 | { |
| 2387 | if (gGrpBlueNode.Children.Count > 0) | 2388 | if (gGrpBlueNode.Children.Count > 0) |
| 2388 | { | 2389 | { |
| 2389 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2390 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2390 | { | 2391 | { |
| 2391 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2392 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2392 | node = ellipseGeometry.Center; | 2393 | node = ellipseGeometry.Center; |
| 2393 | if (FreeNode.X == node.X) | 2394 | if (FreeNode.X == node.X) |
| 2394 | { | 2395 | { |
| 2395 | if (CheckIsNode(FreeNode, node, radiusNode)) | 2396 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 2396 | { | 2397 | { |
| 2397 | deleteFlag = true; | 2398 | deleteFlag = true; |
| 2398 | } | 2399 | } |
| 2399 | } | 2400 | } |
| 2400 | else | 2401 | else |
| 2401 | { | 2402 | { |
| 2402 | if (CheckIsNode(FreeNode, node, radiusNode)) | 2403 | if (CheckIsNode(FreeNode, node, radiusNode)) |
| 2403 | { | 2404 | { |
| 2404 | deleteFlag = true; | 2405 | deleteFlag = true; |
| 2405 | } | 2406 | } |
| 2406 | } | 2407 | } |
| 2407 | if (deleteFlag) | 2408 | if (deleteFlag) |
| 2408 | { | 2409 | { |
| 2409 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); | 2410 | MessageBoxResult result = MessageBox.Show("Do You Delete This Node?", "Delete Node", MessageBoxButton.OKCancel); |
| 2410 | if (result == MessageBoxResult.OK) | 2411 | if (result == MessageBoxResult.OK) |
| 2411 | { | 2412 | { |
| 2412 | 2413 | ||
| 2413 | DeleteNode(i); | 2414 | DeleteNode(i); |
| 2414 | 2415 | ||
| 2415 | return; | 2416 | return; |
| 2416 | } | 2417 | } |
| 2417 | else | 2418 | else |
| 2418 | { | 2419 | { |
| 2419 | return; | 2420 | return; |
| 2420 | } | 2421 | } |
| 2421 | } | 2422 | } |
| 2422 | } | 2423 | } |
| 2423 | } | 2424 | } |
| 2424 | } | 2425 | } |
| 2425 | 2426 | ||
| 2426 | // them nut | 2427 | // them nut |
| 2427 | else | 2428 | else |
| 2428 | { | 2429 | { |
| 2429 | //Check EditNode State | 2430 | //Check EditNode State |
| 2430 | if(LeftClick) | 2431 | if(LeftClick) |
| 2431 | { | 2432 | { |
| 2432 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2433 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2433 | { | 2434 | { |
| 2434 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2435 | ellipseGeometry = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2435 | node = ellipseGeometry.Center; | 2436 | node = ellipseGeometry.Center; |
| 2436 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); | 2437 | bool isEditNode = CheckIsNode(FreeNode, node, RADIUS_NODE); |
| 2437 | 2438 | ||
| 2438 | if (isEditNode) | 2439 | if (isEditNode) |
| 2439 | { | 2440 | { |
| 2440 | NewEditNode(node); | 2441 | NewEditNode(node); |
| 2441 | NewDspRouteInfo(); | 2442 | NewDspRouteInfo(); |
| 2442 | return; | 2443 | return; |
| 2443 | } | 2444 | } |
| 2444 | } | 2445 | } |
| 2445 | } | 2446 | } |
| 2446 | 2447 | ||
| 2447 | 2448 | ||
| 2448 | // them nut | 2449 | // them nut |
| 2449 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); | 2450 | MessageBoxResult result = MessageBox.Show("Do You Want To Add This Node?", "Add Node", MessageBoxButton.OKCancel); |
| 2450 | if (result == MessageBoxResult.OK) | 2451 | if (result == MessageBoxResult.OK) |
| 2451 | { | 2452 | { |
| 2452 | ucNode _ucNode = new ucNode(); | 2453 | ucNode _ucNode = new ucNode(); |
| 2453 | _ucNode.btnWidth = 50.0; | 2454 | _ucNode.btnWidth = 50.0; |
| 2454 | _ucNode.btnHeight = 50.0; | 2455 | _ucNode.btnHeight = 50.0; |
| 2455 | _ucNode.txtNode = stt.ToString(); | 2456 | _ucNode.txtNode = stt.ToString(); |
| 2456 | Canvas.SetLeft(_ucNode, FreeNode.X); | 2457 | Canvas.SetLeft(_ucNode, FreeNode.X); |
| 2457 | Canvas.SetTop(_ucNode, FreeNode.Y); | 2458 | Canvas.SetTop(_ucNode, FreeNode.Y); |
| 2458 | this.Children.Add(_ucNode); | 2459 | this.Children.Add(_ucNode); |
| 2459 | ucNode_Lst.Add(_ucNode); | 2460 | ucNode_Lst.Add(_ucNode); |
| 2460 | 2461 | ||
| 2461 | double XXX = FreeNode.X + _ucNode.btnWidth / 2; | 2462 | double XXX = FreeNode.X + _ucNode.btnWidth / 2; |
| 2462 | double YYY = FreeNode.Y + _ucNode.btnWidth / 2; | 2463 | double YYY = FreeNode.Y + _ucNode.btnWidth / 2; |
| 2463 | FreeNode.X = XXX; | 2464 | FreeNode.X = XXX; |
| 2464 | FreeNode.Y = YYY; | 2465 | FreeNode.Y = YYY; |
| 2465 | AddNode(FreeNode, gGrpBlueNode); | 2466 | AddNode(FreeNode, gGrpBlueNode); |
| 2466 | 2467 | ||
| 2467 | //ve line | 2468 | //ve line |
| 2468 | if (stt > 1) | 2469 | if (stt > 1) |
| 2469 | { | 2470 | { |
| 2470 | int tmp = ucNode_Lst.Count; | 2471 | int tmp = ucNode_Lst.Count; |
| 2471 | 2472 | ||
| 2472 | EllipseGeometry elip = new EllipseGeometry(); | 2473 | EllipseGeometry elip = new EllipseGeometry(); |
| 2473 | 2474 | ||
| 2474 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; | 2475 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 2]; |
| 2475 | Point node1 = elip.Center; | 2476 | Point node1 = elip.Center; |
| 2476 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; | 2477 | elip = (EllipseGeometry)gGrpBlueNode.Children[tmp - 1]; |
| 2477 | Point node2 = elip.Center; | 2478 | Point node2 = elip.Center; |
| 2478 | DrawLine(node1, node2, gGrpNewLine); | 2479 | DrawLine(node1, node2, gGrpNewLine); |
| 2479 | 2480 | ||
| 2480 | } | 2481 | } |
| 2481 | 2482 | ||
| 2482 | stt++; | 2483 | stt++; |
| 2483 | NewInitNodeInfo_List(); | 2484 | NewInitNodeInfo_List(); |
| 2484 | NewDspRouteInfo(); | 2485 | NewDspRouteInfo(); |
| 2485 | } | 2486 | } |
| 2486 | } | 2487 | } |
| 2487 | 2488 | ||
| 2488 | } | 2489 | } |
| 2489 | #endregion | 2490 | #endregion |
| 2490 | 2491 | ||
| 2491 | #region Schedule | 2492 | #region Schedule |
| 2492 | 2493 | ||
| 2493 | public void SetScheduleRoute() | 2494 | public void SetScheduleRoute() |
| 2494 | { | 2495 | { |
| 2495 | 2496 | ||
| 2496 | EllipseGeometry ellipseGeometry_1; | 2497 | EllipseGeometry ellipseGeometry_1; |
| 2497 | EllipseGeometry ellipseGeometry_2; | 2498 | EllipseGeometry ellipseGeometry_2; |
| 2498 | Point node_1; | 2499 | Point node_1; |
| 2499 | Point node_2; | 2500 | Point node_2; |
| 2500 | Point node_Schedule = new Point(); | 2501 | Point node_Schedule = new Point(); |
| 2501 | 2502 | ||
| 2502 | 2503 | ||
| 2503 | gGrpScheduleNode.Children.Clear(); | 2504 | gGrpScheduleNode.Children.Clear(); |
| 2504 | gGrpScheduleLine.Children.Clear(); | 2505 | gGrpScheduleLine.Children.Clear(); |
| 2505 | 2506 | ||
| 2506 | double Totaldistance = 1000; | 2507 | double Totaldistance = 1000; |
| 2507 | 2508 | ||
| 2508 | List<double> distance = new List<double>(); | 2509 | List<double> distance = new List<double>(); |
| 2509 | double addDistance; | 2510 | double addDistance; |
| 2510 | 2511 | ||
| 2511 | if (gGrpBlueNode.Children.Count > 0) | 2512 | if (gGrpBlueNode.Children.Count > 0) |
| 2512 | { | 2513 | { |
| 2513 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) | 2514 | for (int i = 0; i < gGrpBlueNode.Children.Count; i++) |
| 2514 | { | 2515 | { |
| 2515 | ellipseGeometry_2 = (EllipseGeometry)gGrpBlueNode.Children[i]; | 2516 | ellipseGeometry_2 = (EllipseGeometry)gGrpBlueNode.Children[i]; |
| 2516 | node_2 = ellipseGeometry_2.Center; | 2517 | node_2 = ellipseGeometry_2.Center; |
| 2517 | 2518 | ||
| 2518 | if (i >= 1) | 2519 | if (i >= 1) |
| 2519 | { | 2520 | { |
| 2520 | ellipseGeometry_1 = (EllipseGeometry)gGrpBlueNode.Children[i - 1]; | 2521 | ellipseGeometry_1 = (EllipseGeometry)gGrpBlueNode.Children[i - 1]; |
| 2521 | node_1 = ellipseGeometry_1.Center; | 2522 | node_1 = ellipseGeometry_1.Center; |
| 2522 | if (node_1.X == node_2.X) | 2523 | if (node_1.X == node_2.X) |
| 2523 | { | 2524 | { |
| 2524 | addDistance = Math.Abs(node_1.Y - node_2.Y); | 2525 | addDistance = Math.Abs(node_1.Y - node_2.Y); |
| 2525 | distance.Add(addDistance); | 2526 | distance.Add(addDistance); |
| 2526 | } | 2527 | } |
| 2527 | else if (node_1.Y == node_2.Y) | 2528 | else if (node_1.Y == node_2.Y) |
| 2528 | { | 2529 | { |
| 2529 | addDistance = Math.Abs(node_1.X - node_2.X); | 2530 | addDistance = Math.Abs(node_1.X - node_2.X); |
| 2530 | distance.Add(addDistance); | 2531 | distance.Add(addDistance); |
| 2531 | } | 2532 | } |
| 2532 | else | 2533 | else |
| 2533 | { | 2534 | { |
| 2534 | var a = (double)(node_2.X - node_1.X); | 2535 | var a = (double)(node_2.X - node_1.X); |
| 2535 | var b = (double)(node_2.Y - node_1.Y); | 2536 | var b = (double)(node_2.Y - node_1.Y); |
| 2536 | addDistance = Math.Sqrt(a * a + b * b); | 2537 | addDistance = Math.Sqrt(a * a + b * b); |
| 2537 | distance.Add(addDistance); | 2538 | distance.Add(addDistance); |
| 2538 | } | 2539 | } |
| 2539 | } | 2540 | } |
| 2540 | } | 2541 | } |
| 2541 | } | 2542 | } |
| 2542 | if (distance.Count > 0) | 2543 | if (distance.Count > 0) |
| 2543 | { | 2544 | { |
| 2544 | double total = 0; | 2545 | double total = 0; |
| 2545 | double distance_i; | 2546 | double distance_i; |
| 2546 | 2547 | ||
| 2547 | for (int i = 0; i < distance.Count; i++) | 2548 | for (int i = 0; i < distance.Count; i++) |
| 2548 | { | 2549 | { |
| 2549 | total = total + distance[i]; | 2550 | total = total + distance[i]; |
| 2550 | } | 2551 | } |
| 2551 | 2552 | ||
| 2552 | for (int i = 0; i < distance.Count; i++) | 2553 | for (int i = 0; i < distance.Count; i++) |
| 2553 | { | 2554 | { |
| 2554 | distance_i = distance[i] * (Totaldistance / total); | 2555 | distance_i = distance[i] * (Totaldistance / total); |
| 2555 | distance[i] = distance_i; | 2556 | distance[i] = distance_i; |
| 2556 | } | 2557 | } |
| 2557 | } | 2558 | } |
| 2558 | 2559 | ||
| 2559 | node_Schedule.X = 0; | 2560 | node_Schedule.X = 50; |
| 2560 | node_Schedule.Y = 100; | 2561 | node_Schedule.Y = 100; |
| 2561 | AddNode(node_Schedule, gGrpScheduleNode); | 2562 | AddNode(node_Schedule, gGrpScheduleNode); |
| 2562 | 2563 | ||
| 2563 | addDistance = 0; | 2564 | addDistance = 0; |
| 2564 | for (int i = 0; i < distance.Count; i++) | 2565 | for (int i = 0; i < distance.Count; i++) |
| 2565 | { | 2566 | { |
| 2566 | 2567 | ||
| 2567 | node_Schedule.Y = 100; | 2568 | node_Schedule.Y = 100; |
| 2568 | addDistance = addDistance + distance[i]; | 2569 | addDistance = addDistance + distance[i]; |
| 2569 | node_Schedule.X = addDistance; | 2570 | node_Schedule.X = addDistance; |
| 2570 | AddNode(node_Schedule, gGrpScheduleNode); | 2571 | AddNode(node_Schedule, gGrpScheduleNode); |
| 2571 | } | 2572 | } |
| 2572 | 2573 | ||
| 2573 | if (gGrpScheduleNode.Children.Count > 0) | 2574 | if (gGrpScheduleNode.Children.Count > 0) |
| 2574 | { | 2575 | { |
| 2575 | for (int i = 0; i < gGrpScheduleNode.Children.Count; i++) | 2576 | for (int i = 0; i < gGrpScheduleNode.Children.Count; i++) |
| 2576 | { | 2577 | { |
| 2577 | ellipseGeometry_1 = (EllipseGeometry)gGrpScheduleNode.Children[i]; | 2578 | ellipseGeometry_1 = (EllipseGeometry)gGrpScheduleNode.Children[i]; |
| 2578 | node_1 = ellipseGeometry_1.Center; | 2579 | node_1 = ellipseGeometry_1.Center; |
| 2579 | if (i > 0) | 2580 | if (i > 0) |
| 2580 | { | 2581 | { |
| 2581 | ellipseGeometry_2 = (EllipseGeometry)gGrpScheduleNode.Children[i -1]; | 2582 | ellipseGeometry_2 = (EllipseGeometry)gGrpScheduleNode.Children[i -1]; |
| 2582 | node_2 = ellipseGeometry_2.Center; | 2583 | node_2 = ellipseGeometry_2.Center; |
| 2583 | DrawLine(node_1, node_2, gGrpScheduleLine); | 2584 | DrawLine(node_1, node_2, gGrpScheduleLine); |
| 2584 | } | 2585 | } |
| 2585 | CreateNode(node_1, i + 1); | 2586 | CreateScheduleNode(node_1, i + 1); |
| 2586 | } | 2587 | } |
| 2587 | } | 2588 | } |
| 2588 | } | 2589 | } |
| 2589 | 2590 | ||
| 2590 | 2591 | ||
| 2591 | private void CreateNode(Point point, int indexNode) | 2592 | private void CreateNode(Point point, int indexNode) |
| 2592 | { | 2593 | { |
| 2593 | ucNode _ucNode = new ucNode(); | 2594 | ucNode _ucNode = new ucNode(); |
| 2594 | _ucNode.btnWidth = 20.0; | 2595 | _ucNode.btnWidth = 20.0; |
| 2595 | _ucNode.btnHeight = 20.0; | 2596 | _ucNode.btnHeight = 20.0; |
| 2596 | _ucNode.txtNode = indexNode.ToString(); | 2597 | _ucNode.txtNode = indexNode.ToString(); |
| 2597 | Canvas.SetLeft(_ucNode, point.X); | 2598 | Canvas.SetLeft(_ucNode, point.X); |
| 2598 | Canvas.SetTop(_ucNode, point.Y); | 2599 | Canvas.SetTop(_ucNode, point.Y); |
| 2599 | this.Children.Add(_ucNode); | 2600 | this.Children.Add(_ucNode); |
| 2601 | } | ||
| 2602 | |||
| 2603 | private void CreateScheduleNode(Point point, int indexNode) | ||
| 2604 | { | ||
| 2605 | ucNode _ucNode = new ucNode(); | ||
| 2606 | _ucNode.btnWidth = 20.0; | ||
| 2607 | _ucNode.btnHeight = 20.0; | ||
| 2608 | _ucNode.txtNode = indexNode.ToString(); | ||
| 2609 | Canvas.SetLeft(_ucNode, point.X - 25); | ||
| 2610 | Canvas.SetTop(_ucNode, point.Y - 25); | ||
| 2611 | scheduleCanvas.Children.Add(_ucNode); | ||
| 2600 | } | 2612 | } |
| 2601 | 2613 | ||
| 2602 | #endregion | 2614 | #endregion |
| 2603 | 2615 | ||
| 2604 | } | 2616 | } |
| 2605 | } | 2617 | } |
sources/RoboforkApp/RoboforkMenu.xaml
| 1 | <Window x:Class="RoboforkApp.RoboforkMenu" | 1 | <Window x:Class="RoboforkApp.RoboforkMenu" |
| 2 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | 2 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | 3 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | xmlns:s="clr-namespace:RoboforkApp" | 4 | xmlns:s="clr-namespace:RoboforkApp" |
| 5 | Title="Robofork App" | 5 | Title="Robofork App" |
| 6 | ResizeMode="NoResize" | 6 | ResizeMode="NoResize" |
| 7 | WindowStartupLocation="CenterScreen" | 7 | WindowStartupLocation="CenterScreen" |
| 8 | Height="1000" Width="1300"> | 8 | Height="1000" Width="1300"> |
| 9 | <Grid ShowGridLines="False" Margin="20,20,20,20"> | 9 | <Grid ShowGridLines="False" Margin="20,20,20,20"> |
| 10 | 10 | ||
| 11 | <Grid.RowDefinitions> | 11 | <Grid.RowDefinitions> |
| 12 | <RowDefinition Height="0.8*"/> | 12 | <RowDefinition Height="0.8*"/> |
| 13 | <RowDefinition Height="10*"/> | 13 | <RowDefinition Height="10*"/> |
| 14 | </Grid.RowDefinitions> | 14 | </Grid.RowDefinitions> |
| 15 | <Border Grid.Row="0" BorderThickness="1" BorderBrush="Gray" Margin="0,0,0,5"> | 15 | <Border Grid.Row="0" BorderThickness="1" BorderBrush="Gray" Margin="0,0,0,5"> |
| 16 | <Grid ShowGridLines="False"> | 16 | <Grid ShowGridLines="False"> |
| 17 | <Grid.RowDefinitions> | 17 | <Grid.RowDefinitions> |
| 18 | <RowDefinition Height="*"/> | 18 | <RowDefinition Height="*"/> |
| 19 | <RowDefinition Height="*"/> | 19 | <RowDefinition Height="*"/> |
| 20 | </Grid.RowDefinitions> | 20 | </Grid.RowDefinitions> |
| 21 | <Label Grid.Row="0" Content="Autonomous Planning Tool" Margin="10,0,0,0" | 21 | <Label Grid.Row="0" Content="Autonomous Planning Tool" Margin="10,0,0,0" |
| 22 | FontSize="16"/> | 22 | FontSize="16"/> |
| 23 | </Grid> | 23 | </Grid> |
| 24 | </Border> | 24 | </Border> |
| 25 | 25 | ||
| 26 | <Grid ShowGridLines="False" Grid.Row="1"> | 26 | <Grid ShowGridLines="False" Grid.Row="1"> |
| 27 | 27 | ||
| 28 | <Grid.ColumnDefinitions> | 28 | <Grid.ColumnDefinitions> |
| 29 | <ColumnDefinition Width="1.2*"/> | 29 | <ColumnDefinition Width="1.2*"/> |
| 30 | <ColumnDefinition Width="20"/> | 30 | <ColumnDefinition Width="20"/> |
| 31 | <ColumnDefinition Width="3*"/> | 31 | <ColumnDefinition Width="3*"/> |
| 32 | </Grid.ColumnDefinitions> | 32 | </Grid.ColumnDefinitions> |
| 33 | 33 | ||
| 34 | <Grid ShowGridLines="False" Grid.Column="0"> | 34 | <Grid ShowGridLines="False" Grid.Column="0"> |
| 35 | <Grid.RowDefinitions> | 35 | <Grid.RowDefinitions> |
| 36 | <RowDefinition Height="3*"/> | 36 | <RowDefinition Height="3*"/> |
| 37 | <RowDefinition Height="1*"/> | 37 | <RowDefinition Height="1*"/> |
| 38 | </Grid.RowDefinitions> | 38 | </Grid.RowDefinitions> |
| 39 | <Border Grid.Row="0" BorderThickness="1" BorderBrush="White" Margin="0,0,0,5"> | 39 | <Border Grid.Row="0" BorderThickness="1" BorderBrush="White" Margin="0,0,0,5"> |
| 40 | <TreeView > | 40 | <TreeView > |
| 41 | <TreeViewItem IsExpanded="True" Header="Project [AAA工場]" FontSize="17" > | 41 | <TreeViewItem IsExpanded="True" Header="Project [AAA工場]" FontSize="17" > |
| 42 | <TreeViewItem IsExpanded="True" Header="MAP" FontSize="17"> | 42 | <TreeViewItem IsExpanded="True" Header="MAP" FontSize="17"> |
| 43 | <TreeViewItem Header="Pass plan" FontSize="17" Name="PassplanTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="PassplanTree"> | 43 | <TreeViewItem Header="Pass plan" FontSize="17" Name="PassplanTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="PassplanTree"> |
| 44 | <TreeViewItem Header="Set Start" FontSize="17" Name="btnSetStart" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetStart"></TreeViewItem> | 44 | <TreeViewItem Header="Set Start" FontSize="17" Name="btnSetStart" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetStart"></TreeViewItem> |
| 45 | <TreeViewItem Header="Set Goal" FontSize="17" Name="btnSetGoal" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetGoal"></TreeViewItem> | 45 | <TreeViewItem Header="Set Goal" FontSize="17" Name="btnSetGoal" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetGoal"></TreeViewItem> |
| 46 | <TreeViewItem Header="Set Route" FontSize="17" Name="btnSetRoute" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetupRoute"></TreeViewItem> | 46 | <TreeViewItem Header="Set Route" FontSize="17" Name="btnSetRoute" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="SetupRoute"></TreeViewItem> |
| 47 | <TreeViewItem Header="Make Root" FontSize="17" Name="btnMakeRoot" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="MakeRoot"></TreeViewItem> | 47 | <TreeViewItem Header="Make Root" FontSize="17" Name="btnMakeRoot" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="MakeRoot"></TreeViewItem> |
| 48 | <TreeViewItem Header="Delete Route" FontSize="17" Name="btnDeleteRoute" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="DeleteRoute"></TreeViewItem> | 48 | <TreeViewItem Header="Delete Route" FontSize="17" Name="btnDeleteRoute" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="DeleteRoute"></TreeViewItem> |
| 49 | </TreeViewItem> | 49 | </TreeViewItem> |
| 50 | <TreeViewItem IsExpanded="True" Header="Node" FontSize="17" Name="NodeTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="NodeTree"> | 50 | <TreeViewItem IsExpanded="True" Header="Node" FontSize="17" Name="NodeTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="NodeTree"> |
| 51 | </TreeViewItem> | 51 | </TreeViewItem> |
| 52 | <TreeViewItem Header="--------------------" FontSize="17"> | 52 | <TreeViewItem Header="--------------------" FontSize="17"> |
| 53 | </TreeViewItem> | 53 | </TreeViewItem> |
| 54 | </TreeViewItem> | 54 | </TreeViewItem> |
| 55 | 55 | ||
| 56 | <TreeViewItem Header="Vehicle" FontSize="17"> | 56 | <TreeViewItem Header="Vehicle" FontSize="17"> |
| 57 | <TreeViewItem Header="FK15_#1" | 57 | <TreeViewItem Header="FK15_#1" |
| 58 | FontSize="17" | 58 | FontSize="17" |
| 59 | Name="FK15Tree" | 59 | Name="FK15Tree" |
| 60 | Selected="GetFK15Tree" | 60 | Selected="GetFK15Tree" |
| 61 | Unselected="SetFK15Tree"> | 61 | Unselected="SetFK15Tree"> |
| 62 | </TreeViewItem> | 62 | </TreeViewItem> |
| 63 | <TreeViewItem Header="[+]" | 63 | <TreeViewItem Header="[+]" |
| 64 | FontSize="17" | 64 | FontSize="17" |
| 65 | Name="VehicleAddTree" | 65 | Name="VehicleAddTree" |
| 66 | Selected="GetVehicleAddTree" | 66 | Selected="GetVehicleAddTree" |
| 67 | Unselected="SetVehicleAddTree"> | 67 | Unselected="SetVehicleAddTree"> |
| 68 | </TreeViewItem> | 68 | </TreeViewItem> |
| 69 | <TreeViewItem Header="--------------------"> | 69 | <TreeViewItem Header="--------------------"> |
| 70 | </TreeViewItem> | 70 | </TreeViewItem> |
| 71 | </TreeViewItem> | 71 | </TreeViewItem> |
| 72 | 72 | ||
| 73 | <TreeViewItem Header="Work" | 73 | <TreeViewItem Header="Work" |
| 74 | FontSize="17"> | 74 | FontSize="17"> |
| 75 | <TreeViewItem Header="Task patterm [FK15_#1]" | 75 | <TreeViewItem Header="Task patterm [FK15_#1]" |
| 76 | FontSize="17" | 76 | FontSize="17" |
| 77 | Name="TaskpattermTree" | 77 | Name="TaskpattermTree" |
| 78 | Selected="GetTaskpattermTree" | 78 | Selected="GetTaskpattermTree" |
| 79 | Unselected="SetTaskpattermTree"> | 79 | Unselected="SetTaskpattermTree"> |
| 80 | </TreeViewItem> | 80 | </TreeViewItem> |
| 81 | <TreeViewItem Header="[+]" | 81 | <TreeViewItem Header="[+]" |
| 82 | FontSize="17" | 82 | FontSize="17" |
| 83 | Name="WorkAddTree" | 83 | Name="WorkAddTree" |
| 84 | Selected="GetWorkAddTree" | 84 | Selected="GetWorkAddTree" |
| 85 | Unselected="SetWorkAddTree"> | 85 | Unselected="SetWorkAddTree"> |
| 86 | </TreeViewItem> | 86 | </TreeViewItem> |
| 87 | <TreeViewItem Header="--------------------" | 87 | <TreeViewItem Header="--------------------" |
| 88 | FontSize="17"> | 88 | FontSize="17"> |
| 89 | </TreeViewItem> | 89 | </TreeViewItem> |
| 90 | </TreeViewItem> | 90 | </TreeViewItem> |
| 91 | 91 | ||
| 92 | <TreeViewItem Header="Setting" | 92 | <TreeViewItem Header="Setting" |
| 93 | FontSize="17"> | 93 | FontSize="17"> |
| 94 | <TreeViewItem Header="Connect [Wi-Fi]" | 94 | <TreeViewItem Header="Connect [Wi-Fi]" |
| 95 | FontSize="17" | 95 | FontSize="17" |
| 96 | Name="ConnectTree" | 96 | Name="ConnectTree" |
| 97 | Selected="GetConnectTree" | 97 | Selected="GetConnectTree" |
| 98 | Unselected="SetConnectTree"> | 98 | Unselected="SetConnectTree"> |
| 99 | </TreeViewItem> | 99 | </TreeViewItem> |
| 100 | <TreeViewItem Header="Parameter" | 100 | <TreeViewItem Header="Parameter" |
| 101 | FontSize="17" | 101 | FontSize="17" |
| 102 | Name="ParameterTree" | 102 | Name="ParameterTree" |
| 103 | Selected="GetParameterTree" | 103 | Selected="GetParameterTree" |
| 104 | Unselected="SetParameterTree"> | 104 | Unselected="SetParameterTree"> |
| 105 | </TreeViewItem> | 105 | </TreeViewItem> |
| 106 | <TreeViewItem Header="--------------------" | 106 | <TreeViewItem Header="--------------------" |
| 107 | FontSize="17"> | 107 | FontSize="17"> |
| 108 | </TreeViewItem> | 108 | </TreeViewItem> |
| 109 | </TreeViewItem> | 109 | </TreeViewItem> |
| 110 | <TreeViewItem Header="Schedule" FontSize="17" Name="ScheduleTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="ScheduleRoute"></TreeViewItem> | 110 | <TreeViewItem Header="Schedule" FontSize="17" Name="ScheduleTree" Selected="btnMenu_Selected" Unselected="btnMenu_UnselectedSet" Tag="ScheduleRoute"></TreeViewItem> |
| 111 | <TreeViewItem Header="Logging" | 111 | <TreeViewItem Header="Logging" |
| 112 | FontSize="17" | 112 | FontSize="17" |
| 113 | Name="LoggingTree" | 113 | Name="LoggingTree" |
| 114 | Selected="GetLoggingTree" | 114 | Selected="GetLoggingTree" |
| 115 | Unselected="SetLoggingTree"> | 115 | Unselected="SetLoggingTree"> |
| 116 | </TreeViewItem> | 116 | </TreeViewItem> |
| 117 | <TreeViewItem Header=" --------------------"> | 117 | <TreeViewItem Header=" --------------------"> |
| 118 | </TreeViewItem> | 118 | </TreeViewItem> |
| 119 | </TreeViewItem> | 119 | </TreeViewItem> |
| 120 | <TreeViewItem Header="Alert" | 120 | <TreeViewItem Header="Alert" |
| 121 | FontSize="17" | 121 | FontSize="17" |
| 122 | Name="AlertTree" | 122 | Name="AlertTree" |
| 123 | Selected="GetAlertTree" | 123 | Selected="GetAlertTree" |
| 124 | Unselected="SetAlertTree"> | 124 | Unselected="SetAlertTree"> |
| 125 | </TreeViewItem> | 125 | </TreeViewItem> |
| 126 | <TreeViewItem Header="Help" | 126 | <TreeViewItem Header="Help" |
| 127 | FontSize="17" | 127 | FontSize="17" |
| 128 | Name="HelpTree" | 128 | Name="HelpTree" |
| 129 | Selected="GetHelpTree" | 129 | Selected="GetHelpTree" |
| 130 | Unselected="SetHelpTree"> | 130 | Unselected="SetHelpTree"> |
| 131 | </TreeViewItem> | 131 | </TreeViewItem> |
| 132 | <TreeViewItem Header="[+New Project]" | 132 | <TreeViewItem Header="[+New Project]" |
| 133 | FontSize="17" | 133 | FontSize="17" |
| 134 | Name="NewProjectTree" | 134 | Name="NewProjectTree" |
| 135 | Selected="GetNewProjectTree" | 135 | Selected="GetNewProjectTree" |
| 136 | Unselected="SetNewProjectTree"> | 136 | Unselected="SetNewProjectTree"> |
| 137 | </TreeViewItem> | 137 | </TreeViewItem> |
| 138 | </TreeView> | 138 | </TreeView> |
| 139 | </Border> | 139 | </Border> |
| 140 | <Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray" Margin="0,5,0,0"> | 140 | <Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray" Margin="0,5,0,0"> |
| 141 | 141 | ||
| 142 | <Grid ShowGridLines="False"> | 142 | <Grid ShowGridLines="False"> |
| 143 | <Grid.RowDefinitions> | 143 | <Grid.RowDefinitions> |
| 144 | <RowDefinition Height="1*"/> | 144 | <RowDefinition Height="1*"/> |
| 145 | <RowDefinition Height="5*"/> | 145 | <RowDefinition Height="5*"/> |
| 146 | </Grid.RowDefinitions> | 146 | </Grid.RowDefinitions> |
| 147 | <Label Grid.Row="0" Content="Viewer" Margin="10,0,0,0" | 147 | <Label Grid.Row="0" Content="Viewer" Margin="10,0,0,0" |
| 148 | FontSize="17"/> | 148 | FontSize="17"/> |
| 149 | </Grid> | 149 | </Grid> |
| 150 | </Border> | 150 | </Border> |
| 151 | </Grid> | 151 | </Grid> |
| 152 | <TabControl x:Name="MainTab" | 152 | <TabControl x:Name="MainTab" |
| 153 | Margin="0,0,0,0" | 153 | Margin="0,0,0,0" |
| 154 | Grid.Column="2" > | 154 | Grid.Column="2" > |
| 155 | <TabItem x:Name="TabMap" > | 155 | <TabItem x:Name="TabMap" > |
| 156 | <TabItem.Header> | 156 | <TabItem.Header> |
| 157 | <StackPanel Orientation="Horizontal"> | 157 | <StackPanel Orientation="Horizontal"> |
| 158 | <TextBlock Text="MAP " VerticalAlignment="Center" FontSize="17"></TextBlock> | 158 | <TextBlock Text="MAP " VerticalAlignment="Center" FontSize="17"></TextBlock> |
| 159 | </StackPanel> | 159 | </StackPanel> |
| 160 | </TabItem.Header> | 160 | </TabItem.Header> |
| 161 | <Grid ShowGridLines="False"> | 161 | <Grid ShowGridLines="False"> |
| 162 | <Grid.RowDefinitions> | 162 | <Grid.RowDefinitions> |
| 163 | <RowDefinition Height="5*"/> | 163 | <RowDefinition Height="5*"/> |
| 164 | <RowDefinition Height="1*"/> | 164 | <RowDefinition Height="1*"/> |
| 165 | <RowDefinition Height="1*"/> | 165 | <RowDefinition Height="1*"/> |
| 166 | </Grid.RowDefinitions> | 166 | </Grid.RowDefinitions> |
| 167 | 167 | ||
| 168 | <Grid ShowGridLines="False" Grid.Row="0" Name="GridMap"> | 168 | <Grid ShowGridLines="False" Grid.Row="0" Name="GridMap"> |
| 169 | <Grid > | 169 | <Grid > |
| 170 | <Grid.ColumnDefinitions> | 170 | <Grid.ColumnDefinitions> |
| 171 | <ColumnDefinition Width="{Binding ActualHeight, ElementName=GridMap}"/> | 171 | <ColumnDefinition Width="{Binding ActualHeight, ElementName=GridMap}"/> |
| 172 | <ColumnDefinition Width="*"/> | 172 | <ColumnDefinition Width="*"/> |
| 173 | </Grid.ColumnDefinitions> | 173 | </Grid.ColumnDefinitions> |
| 174 | <Border Grid.Column="0" BorderThickness="1" BorderBrush="Red" Margin="5,5,5,5"> | 174 | <Border Grid.Column="0" BorderThickness="1" BorderBrush="Red" Margin="5,5,5,5"> |
| 175 | 175 | ||
| 176 | <s:DesignerCanvas x:Name="MyDesignerCanvas" | 176 | <s:DesignerCanvas x:Name="MyDesignerCanvas" |
| 177 | AllowDrop="True" | 177 | AllowDrop="True" |
| 178 | Background="White" HorizontalAlignment="Stretch"> | 178 | Background="White" HorizontalAlignment="Stretch"> |
| 179 | <Canvas.LayoutTransform> | 179 | <Canvas.LayoutTransform> |
| 180 | <!--Adjust ScaleX and ScaleY in lock-step to zoom--> | 180 | <!--Adjust ScaleX and ScaleY in lock-step to zoom--> |
| 181 | <ScaleTransform ScaleX=".57" ScaleY=".57" CenterX=".57" CenterY=".57" /> | 181 | <ScaleTransform ScaleX=".57" ScaleY=".57" CenterX=".57" CenterY=".57" /> |
| 182 | </Canvas.LayoutTransform> | 182 | </Canvas.LayoutTransform> |
| 183 | <Grid Name="MCGrid" Background="White" ShowGridLines="True" | 183 | <Grid Name="MCGrid" Background="White" ShowGridLines="True" |
| 184 | Width="{Binding ActualWidth, ElementName=MyDesignerCanvas}" | 184 | Width="{Binding ActualWidth, ElementName=MyDesignerCanvas}" |
| 185 | Height="{Binding ActualHeight, ElementName=MyDesignerCanvas}"> | 185 | Height="{Binding ActualHeight, ElementName=MyDesignerCanvas}"> |
| 186 | 186 | ||
| 187 | <Grid.RowDefinitions> | 187 | <Grid.RowDefinitions> |
| 188 | <RowDefinition Height="1*"/> | 188 | <RowDefinition Height="1*"/> |
| 189 | <RowDefinition Height="1*"/> | 189 | <RowDefinition Height="1*"/> |
| 190 | <RowDefinition Height="1*"/> | 190 | <RowDefinition Height="1*"/> |
| 191 | <RowDefinition Height="1*"/> | 191 | <RowDefinition Height="1*"/> |
| 192 | <RowDefinition Height="1*"/> | 192 | <RowDefinition Height="1*"/> |
| 193 | <RowDefinition Height="1*"/> | 193 | <RowDefinition Height="1*"/> |
| 194 | <RowDefinition Height="1*"/> | 194 | <RowDefinition Height="1*"/> |
| 195 | <RowDefinition Height="1*"/> | 195 | <RowDefinition Height="1*"/> |
| 196 | <RowDefinition Height="1*"/> | 196 | <RowDefinition Height="1*"/> |
| 197 | <RowDefinition Height="1*"/> | 197 | <RowDefinition Height="1*"/> |
| 198 | </Grid.RowDefinitions> | 198 | </Grid.RowDefinitions> |
| 199 | <Grid.ColumnDefinitions> | 199 | <Grid.ColumnDefinitions> |
| 200 | <ColumnDefinition Width="*"/> | 200 | <ColumnDefinition Width="*"/> |
| 201 | <ColumnDefinition Width="*"/> | 201 | <ColumnDefinition Width="*"/> |
| 202 | <ColumnDefinition Width="*"/> | 202 | <ColumnDefinition Width="*"/> |
| 203 | <ColumnDefinition Width="*"/> | 203 | <ColumnDefinition Width="*"/> |
| 204 | <ColumnDefinition Width="*"/> | 204 | <ColumnDefinition Width="*"/> |
| 205 | <ColumnDefinition Width="*"/> | 205 | <ColumnDefinition Width="*"/> |
| 206 | <ColumnDefinition Width="*"/> | 206 | <ColumnDefinition Width="*"/> |
| 207 | <ColumnDefinition Width="*"/> | 207 | <ColumnDefinition Width="*"/> |
| 208 | <ColumnDefinition Width="*"/> | 208 | <ColumnDefinition Width="*"/> |
| 209 | <ColumnDefinition Width="*"/> | 209 | <ColumnDefinition Width="*"/> |
| 210 | </Grid.ColumnDefinitions> | 210 | </Grid.ColumnDefinitions> |
| 211 | <TextBlock Grid.Row="0" Grid.Column="1" Foreground="SkyBlue">100</TextBlock> | 211 | <TextBlock Grid.Row="0" Grid.Column="1" Foreground="SkyBlue">100</TextBlock> |
| 212 | <TextBlock Grid.Row="0" Grid.Column="2" Foreground="SkyBlue">200</TextBlock> | 212 | <TextBlock Grid.Row="0" Grid.Column="2" Foreground="SkyBlue">200</TextBlock> |
| 213 | <TextBlock Grid.Row="0" Grid.Column="3" Foreground="SkyBlue">300</TextBlock> | 213 | <TextBlock Grid.Row="0" Grid.Column="3" Foreground="SkyBlue">300</TextBlock> |
| 214 | <TextBlock Grid.Row="0" Grid.Column="4" Foreground="SkyBlue">400</TextBlock> | 214 | <TextBlock Grid.Row="0" Grid.Column="4" Foreground="SkyBlue">400</TextBlock> |
| 215 | <TextBlock Grid.Row="0" Grid.Column="5" Foreground="SkyBlue">500</TextBlock> | 215 | <TextBlock Grid.Row="0" Grid.Column="5" Foreground="SkyBlue">500</TextBlock> |
| 216 | <TextBlock Grid.Row="0" Grid.Column="6" Foreground="SkyBlue">600</TextBlock> | 216 | <TextBlock Grid.Row="0" Grid.Column="6" Foreground="SkyBlue">600</TextBlock> |
| 217 | <TextBlock Grid.Row="0" Grid.Column="7" Foreground="SkyBlue">700</TextBlock> | 217 | <TextBlock Grid.Row="0" Grid.Column="7" Foreground="SkyBlue">700</TextBlock> |
| 218 | <TextBlock Grid.Row="0" Grid.Column="8" Foreground="SkyBlue">800</TextBlock> | 218 | <TextBlock Grid.Row="0" Grid.Column="8" Foreground="SkyBlue">800</TextBlock> |
| 219 | <TextBlock Grid.Row="0" Grid.Column="9" Foreground="SkyBlue">900</TextBlock> | 219 | <TextBlock Grid.Row="0" Grid.Column="9" Foreground="SkyBlue">900</TextBlock> |
| 220 | 220 | ||
| 221 | <TextBlock Grid.Row="1" Grid.Column="0" Foreground="SkyBlue">100</TextBlock> | 221 | <TextBlock Grid.Row="1" Grid.Column="0" Foreground="SkyBlue">100</TextBlock> |
| 222 | <TextBlock Grid.Row="2" Grid.Column="0" Foreground="SkyBlue">200</TextBlock> | 222 | <TextBlock Grid.Row="2" Grid.Column="0" Foreground="SkyBlue">200</TextBlock> |
| 223 | <TextBlock Grid.Row="3" Grid.Column="0" Foreground="SkyBlue">300</TextBlock> | 223 | <TextBlock Grid.Row="3" Grid.Column="0" Foreground="SkyBlue">300</TextBlock> |
| 224 | <TextBlock Grid.Row="4" Grid.Column="0" Foreground="SkyBlue">400</TextBlock> | 224 | <TextBlock Grid.Row="4" Grid.Column="0" Foreground="SkyBlue">400</TextBlock> |
| 225 | <TextBlock Grid.Row="5" Grid.Column="0" Foreground="SkyBlue">500</TextBlock> | 225 | <TextBlock Grid.Row="5" Grid.Column="0" Foreground="SkyBlue">500</TextBlock> |
| 226 | <TextBlock Grid.Row="6" Grid.Column="0" Foreground="SkyBlue">600</TextBlock> | 226 | <TextBlock Grid.Row="6" Grid.Column="0" Foreground="SkyBlue">600</TextBlock> |
| 227 | <TextBlock Grid.Row="7" Grid.Column="0" Foreground="SkyBlue">700</TextBlock> | 227 | <TextBlock Grid.Row="7" Grid.Column="0" Foreground="SkyBlue">700</TextBlock> |
| 228 | <TextBlock Grid.Row="8" Grid.Column="0" Foreground="SkyBlue">800</TextBlock> | 228 | <TextBlock Grid.Row="8" Grid.Column="0" Foreground="SkyBlue">800</TextBlock> |
| 229 | <TextBlock Grid.Row="9" Grid.Column="0" Foreground="SkyBlue">900</TextBlock> | 229 | <TextBlock Grid.Row="9" Grid.Column="0" Foreground="SkyBlue">900</TextBlock> |
| 230 | </Grid> | 230 | </Grid> |
| 231 | 231 | ||
| 232 | </s:DesignerCanvas> | 232 | </s:DesignerCanvas> |
| 233 | 233 | ||
| 234 | </Border> | 234 | </Border> |
| 235 | 235 | ||
| 236 | <Border Grid.Column="1" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> | 236 | <Border Grid.Column="1" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> |
| 237 | 237 | ||
| 238 | <DockPanel > | 238 | <DockPanel > |
| 239 | <ScrollViewer> | 239 | <ScrollViewer> |
| 240 | <Grid Name="grdRouteInfo"> | 240 | <Grid Name="grdRouteInfo"> |
| 241 | <Grid.RowDefinitions> | 241 | <Grid.RowDefinitions> |
| 242 | <RowDefinition Height="1*"/> | 242 | <RowDefinition Height="1*"/> |
| 243 | <RowDefinition Height="1*"/> | 243 | <RowDefinition Height="1*"/> |
| 244 | <RowDefinition Height="1*"/> | 244 | <RowDefinition Height="1*"/> |
| 245 | <RowDefinition Height="1*"/> | 245 | <RowDefinition Height="1*"/> |
| 246 | <RowDefinition Height="1*"/> | 246 | <RowDefinition Height="1*"/> |
| 247 | <RowDefinition Height="1*"/> | 247 | <RowDefinition Height="1*"/> |
| 248 | <RowDefinition Height="1*"/> | 248 | <RowDefinition Height="1*"/> |
| 249 | <RowDefinition Height="1*"/> | 249 | <RowDefinition Height="1*"/> |
| 250 | <RowDefinition Height="1*"/> | 250 | <RowDefinition Height="1*"/> |
| 251 | <RowDefinition Height="1*"/> | 251 | <RowDefinition Height="1*"/> |
| 252 | <RowDefinition Height="1*"/> | 252 | <RowDefinition Height="1*"/> |
| 253 | <RowDefinition Height="1*"/> | 253 | <RowDefinition Height="1*"/> |
| 254 | <RowDefinition Height="1*"/> | 254 | <RowDefinition Height="1*"/> |
| 255 | <RowDefinition Height="1*"/> | 255 | <RowDefinition Height="1*"/> |
| 256 | <RowDefinition Height="1*"/> | 256 | <RowDefinition Height="1*"/> |
| 257 | 257 | ||
| 258 | </Grid.RowDefinitions> | 258 | </Grid.RowDefinitions> |
| 259 | <Grid.ColumnDefinitions> | 259 | <Grid.ColumnDefinitions> |
| 260 | <ColumnDefinition Width="0.5*"/> | 260 | <ColumnDefinition Width="0.5*"/> |
| 261 | <ColumnDefinition Width="6*"/> | 261 | <ColumnDefinition Width="6*"/> |
| 262 | </Grid.ColumnDefinitions> | 262 | </Grid.ColumnDefinitions> |
| 263 | <Border Grid.Row="0" Grid.Column="0" BorderThickness="1" /> | 263 | <Border Grid.Row="0" Grid.Column="0" BorderThickness="1" /> |
| 264 | <Border Grid.Row="1" Grid.Column="0" BorderThickness="1" /> | 264 | <Border Grid.Row="1" Grid.Column="0" BorderThickness="1" /> |
| 265 | <Border Grid.Row="2" Grid.Column="0" BorderThickness="1" /> | 265 | <Border Grid.Row="2" Grid.Column="0" BorderThickness="1" /> |
| 266 | <Border Grid.Row="3" Grid.Column="0" BorderThickness="1" /> | 266 | <Border Grid.Row="3" Grid.Column="0" BorderThickness="1" /> |
| 267 | <Border Grid.Row="4" Grid.Column="0" BorderThickness="1" /> | 267 | <Border Grid.Row="4" Grid.Column="0" BorderThickness="1" /> |
| 268 | <Border Grid.Row="5" Grid.Column="0" BorderThickness="1" /> | 268 | <Border Grid.Row="5" Grid.Column="0" BorderThickness="1" /> |
| 269 | <Border Grid.Row="6" Grid.Column="0" BorderThickness="1" /> | 269 | <Border Grid.Row="6" Grid.Column="0" BorderThickness="1" /> |
| 270 | <Border Grid.Row="7" Grid.Column="0" BorderThickness="1" /> | 270 | <Border Grid.Row="7" Grid.Column="0" BorderThickness="1" /> |
| 271 | <Border Grid.Row="8" Grid.Column="0" BorderThickness="1" /> | 271 | <Border Grid.Row="8" Grid.Column="0" BorderThickness="1" /> |
| 272 | <Border Grid.Row="9" Grid.Column="0" BorderThickness="1" /> | 272 | <Border Grid.Row="9" Grid.Column="0" BorderThickness="1" /> |
| 273 | <Border Grid.Row="10" Grid.Column="0" BorderThickness="1" /> | 273 | <Border Grid.Row="10" Grid.Column="0" BorderThickness="1" /> |
| 274 | <Border Grid.Row="11" Grid.Column="0" BorderThickness="1" /> | 274 | <Border Grid.Row="11" Grid.Column="0" BorderThickness="1" /> |
| 275 | <Border Grid.Row="12" Grid.Column="0" BorderThickness="1" /> | 275 | <Border Grid.Row="12" Grid.Column="0" BorderThickness="1" /> |
| 276 | <Border Grid.Row="13" Grid.Column="0" BorderThickness="1" /> | 276 | <Border Grid.Row="13" Grid.Column="0" BorderThickness="1" /> |
| 277 | <Border Grid.Row="14" Grid.Column="0" BorderThickness="1" /> | 277 | <Border Grid.Row="14" Grid.Column="0" BorderThickness="1" /> |
| 278 | <Border Grid.Row="15" Grid.Column="0" BorderThickness="1" /> | 278 | <Border Grid.Row="15" Grid.Column="0" BorderThickness="1" /> |
| 279 | 279 | ||
| 280 | 280 | ||
| 281 | 281 | ||
| 282 | <Label Grid.Row="0" Grid.Column="1" Content="Monitor" FontSize="17"/> | 282 | <Label Grid.Row="0" Grid.Column="1" Content="Monitor" FontSize="17"/> |
| 283 | <Label Grid.Row="1" Grid.Column="1" Content="AOR 28249 [kg/h]" FontSize="17"/> | 283 | <Label Grid.Row="1" Grid.Column="1" Content="AOR 28249 [kg/h]" FontSize="17"/> |
| 284 | <Label Grid.Row="2" Grid.Column="1" Content="ABC 4738 [trq]" FontSize="17"/> | 284 | <Label Grid.Row="2" Grid.Column="1" Content="ABC 4738 [trq]" FontSize="17"/> |
| 285 | <Label Grid.Row="3" Grid.Column="1" Content="ATR 49593 [%]" FontSize="17"/> | 285 | <Label Grid.Row="3" Grid.Column="1" Content="ATR 49593 [%]" FontSize="17"/> |
| 286 | <Label Grid.Row="4" Grid.Column="1" Content="DEK 50403 [G]" FontSize="17"/> | 286 | <Label Grid.Row="4" Grid.Column="1" Content="DEK 50403 [G]" FontSize="17"/> |
| 287 | <Label Grid.Row="5" Grid.Column="1" Content="SKG 2739 [kg]" FontSize="17"/> | 287 | <Label Grid.Row="5" Grid.Column="1" Content="SKG 2739 [kg]" FontSize="17"/> |
| 288 | <Label Grid.Row="6" Grid.Column="1" Content="SOC 86 [%]" FontSize="17"/> | 288 | <Label Grid.Row="6" Grid.Column="1" Content="SOC 86 [%]" FontSize="17"/> |
| 289 | <Label Grid.Row="7" Grid.Column="1" Content=" :" FontSize="17"/> | 289 | <Label Grid.Row="7" Grid.Column="1" Content=" :" FontSize="17"/> |
| 290 | <Label Grid.Row="8" Grid.Column="1" Content=" :" FontSize="17"/> | 290 | <Label Grid.Row="8" Grid.Column="1" Content=" :" FontSize="17"/> |
| 291 | <Label Grid.Row="9" Grid.Column="1" Content=" :" FontSize="17"/> | 291 | <Label Grid.Row="9" Grid.Column="1" Content=" :" FontSize="17"/> |
| 292 | <Label Grid.Row="10" Grid.Column="1" Content=" :" FontSize="17"/> | 292 | <Label Grid.Row="10" Grid.Column="1" Content=" :" FontSize="17"/> |
| 293 | <Label Grid.Row="11" Grid.Column="1" Content=" :" FontSize="17"/> | 293 | <Label Grid.Row="11" Grid.Column="1" Content=" :" FontSize="17"/> |
| 294 | </Grid> | 294 | </Grid> |
| 295 | </ScrollViewer> | 295 | </ScrollViewer> |
| 296 | </DockPanel > | 296 | </DockPanel > |
| 297 | </Border> | 297 | </Border> |
| 298 | </Grid> | 298 | </Grid> |
| 299 | 299 | ||
| 300 | </Grid> | 300 | </Grid> |
| 301 | <Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> | 301 | <Border Grid.Row="1" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> |
| 302 | <Grid ShowGridLines="False"> | 302 | <Grid ShowGridLines="False"> |
| 303 | <Grid.ColumnDefinitions> | 303 | <Grid.ColumnDefinitions> |
| 304 | <ColumnDefinition Width="1*"/> | 304 | <ColumnDefinition Width="1*"/> |
| 305 | <ColumnDefinition Width="8*"/> | 305 | <ColumnDefinition Width="8*"/> |
| 306 | </Grid.ColumnDefinitions> | 306 | </Grid.ColumnDefinitions> |
| 307 | <Grid ShowGridLines="False" Grid.Column="0"> | 307 | <Grid ShowGridLines="False" Grid.Column="0"> |
| 308 | <Grid.RowDefinitions> | 308 | <Grid.RowDefinitions> |
| 309 | <RowDefinition Height="1*"/> | 309 | <RowDefinition Height="1*"/> |
| 310 | <RowDefinition Height="1*"/> | 310 | <RowDefinition Height="1*"/> |
| 311 | <RowDefinition Height="1*"/> | 311 | <RowDefinition Height="1*"/> |
| 312 | </Grid.RowDefinitions> | 312 | </Grid.RowDefinitions> |
| 313 | <Label Grid.Row="0" Content="Schedule" Margin="10,0,0,0" FontSize="17"/> | 313 | <Label Grid.Row="0" Content="Schedule" Margin="10,0,0,0" FontSize="17"/> |
| 314 | <Label Grid.Row="1" Content="FK15_#1" Margin="10,0,0,0" FontSize="17"/> | 314 | <Label Grid.Row="1" Content="FK15_#1" Margin="10,0,0,0" FontSize="17"/> |
| 315 | </Grid> | 315 | </Grid> |
| 316 | <Border Grid.Column="1" BorderThickness="1" BorderBrush="Red" Margin="5,5,5,5"> | 316 | <Border Grid.Column="1" BorderThickness="1" BorderBrush="Red" Margin="5,5,5,5"> |
| 317 | 317 | ||
| 318 | <s:DesignerCanvas x:Name="MyDesignerCanvasSchedule" | 318 | <s:ScheduleCanvas x:Name="MyScheduleCanvas" |
| 319 | AllowDrop="True" | 319 | AllowDrop="True" |
| 320 | Background="White" HorizontalAlignment="Stretch"> | 320 | Background="White" HorizontalAlignment="Stretch"> |
| 321 | <Canvas.LayoutTransform> | ||
| 322 | <!--Adjust ScaleX and ScaleY in lock-step to zoom--> | ||
| 323 | <ScaleTransform ScaleX=".57" ScaleY=".57" CenterX=".57" CenterY=".57" /> | ||
| 324 | </Canvas.LayoutTransform> | ||
| 325 | |||
| 321 | <Grid Name="MCGridShedule" Background="White" ShowGridLines="True" | 326 | <Grid Name="MCGridShedule" Background="White" ShowGridLines="True" |
| 322 | Width="{Binding ActualWidth, ElementName=MyDesignerCanvasSchedule}" | 327 | Width="{Binding ActualWidth, ElementName=MyScheduleCanvas}" |
| 323 | Height="{Binding ActualHeight, ElementName=MyDesignerCanvasSchedule}"> | 328 | Height="{Binding ActualHeight, ElementName=MyScheduleCanvas}"> |
| 324 | 329 | ||
| 325 | <Grid.RowDefinitions> | 330 | <Grid.RowDefinitions> |
| 326 | <RowDefinition Height="1*"/> | 331 | <RowDefinition Height="1*"/> |
| 327 | <RowDefinition Height="1*"/> | 332 | <RowDefinition Height="1*"/> |
| 328 | </Grid.RowDefinitions> | 333 | </Grid.RowDefinitions> |
| 329 | <Grid.ColumnDefinitions> | 334 | <Grid.ColumnDefinitions> |
| 330 | <ColumnDefinition Width="*"/> | 335 | <ColumnDefinition Width="*"/> |
| 331 | <ColumnDefinition Width="*"/> | 336 | <ColumnDefinition Width="*"/> |
| 332 | <ColumnDefinition Width="*"/> | 337 | <ColumnDefinition Width="*"/> |
| 333 | <ColumnDefinition Width="*"/> | 338 | <ColumnDefinition Width="*"/> |
| 334 | <ColumnDefinition Width="*"/> | 339 | <ColumnDefinition Width="*"/> |
| 335 | <ColumnDefinition Width="*"/> | 340 | <ColumnDefinition Width="*"/> |
| 336 | <ColumnDefinition Width="*"/> | 341 | <ColumnDefinition Width="*"/> |
| 337 | <ColumnDefinition Width="*"/> | 342 | <ColumnDefinition Width="*"/> |
| 338 | <ColumnDefinition Width="*"/> | 343 | <ColumnDefinition Width="*"/> |
| 339 | <ColumnDefinition Width="*"/> | 344 | <ColumnDefinition Width="*"/> |
| 340 | </Grid.ColumnDefinitions> | 345 | </Grid.ColumnDefinitions> |
| 341 | <TextBlock Grid.Row="0" Grid.Column="1" Foreground="SkyBlue">100</TextBlock> | 346 | <TextBlock Grid.Row="0" Grid.Column="1" Foreground="SkyBlue">100</TextBlock> |
| 342 | <TextBlock Grid.Row="0" Grid.Column="2" Foreground="SkyBlue">200</TextBlock> | 347 | <TextBlock Grid.Row="0" Grid.Column="2" Foreground="SkyBlue">200</TextBlock> |
| 343 | <TextBlock Grid.Row="0" Grid.Column="3" Foreground="SkyBlue">300</TextBlock> | 348 | <TextBlock Grid.Row="0" Grid.Column="3" Foreground="SkyBlue">300</TextBlock> |
| 344 | <TextBlock Grid.Row="0" Grid.Column="4" Foreground="SkyBlue">400</TextBlock> | 349 | <TextBlock Grid.Row="0" Grid.Column="4" Foreground="SkyBlue">400</TextBlock> |
| 345 | <TextBlock Grid.Row="0" Grid.Column="5" Foreground="SkyBlue">500</TextBlock> | 350 | <TextBlock Grid.Row="0" Grid.Column="5" Foreground="SkyBlue">500</TextBlock> |
| 346 | <TextBlock Grid.Row="0" Grid.Column="6" Foreground="SkyBlue">600</TextBlock> | 351 | <TextBlock Grid.Row="0" Grid.Column="6" Foreground="SkyBlue">600</TextBlock> |
| 347 | <TextBlock Grid.Row="0" Grid.Column="7" Foreground="SkyBlue">700</TextBlock> | 352 | <TextBlock Grid.Row="0" Grid.Column="7" Foreground="SkyBlue">700</TextBlock> |
| 348 | <TextBlock Grid.Row="0" Grid.Column="8" Foreground="SkyBlue">800</TextBlock> | 353 | <TextBlock Grid.Row="0" Grid.Column="8" Foreground="SkyBlue">800</TextBlock> |
| 349 | <TextBlock Grid.Row="0" Grid.Column="9" Foreground="SkyBlue">900</TextBlock> | 354 | <TextBlock Grid.Row="0" Grid.Column="9" Foreground="SkyBlue">900</TextBlock> |
| 350 | 355 | ||
| 351 | <TextBlock Grid.Row="1" Grid.Column="0" Foreground="SkyBlue">100</TextBlock> | 356 | <TextBlock Grid.Row="1" Grid.Column="0" Foreground="SkyBlue">100</TextBlock> |
| 352 | <TextBlock Grid.Row="2" Grid.Column="0" Foreground="SkyBlue">200</TextBlock> | 357 | <!--<TextBlock Grid.Row="2" Grid.Column="0" Foreground="SkyBlue">200</TextBlock>--> |
| 353 | </Grid> | 358 | </Grid> |
| 354 | </s:DesignerCanvas> | 359 | </s:ScheduleCanvas> |
| 355 | 360 | ||
| 356 | </Border> | 361 | </Border> |
| 357 | </Grid> | 362 | </Grid> |
| 358 | </Border> | 363 | </Border> |
| 359 | <Border Grid.Row="2" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> | 364 | <Border Grid.Row="2" BorderThickness="1" BorderBrush="Gray" Margin="5,5,5,5"> |
| 360 | <Grid ShowGridLines="False"> | 365 | <Grid ShowGridLines="False"> |
| 361 | <Grid.RowDefinitions> | 366 | <Grid.RowDefinitions> |
| 362 | <RowDefinition Height="1*"/> | 367 | <RowDefinition Height="1*"/> |
| 363 | <RowDefinition Height="2*"/> | 368 | <RowDefinition Height="2*"/> |
| 364 | </Grid.RowDefinitions> | 369 | </Grid.RowDefinitions> |
| 365 | <Label Grid.Row="0" Content="Work [FK15_#1]" Margin="10,0,0,0" FontSize="17"/> | 370 | <Label Grid.Row="0" Content="Work [FK15_#1]" Margin="10,0,0,0" FontSize="17"/> |
| 366 | </Grid> | 371 | </Grid> |
| 367 | </Border> | 372 | </Border> |
| 368 | </Grid> | 373 | </Grid> |
| 369 | </TabItem> | 374 | </TabItem> |
| 370 | <TabItem x:Name="TabWork" > | 375 | <TabItem x:Name="TabWork" > |
| 371 | <TabItem.Header> | 376 | <TabItem.Header> |
| 372 | <StackPanel Orientation="Horizontal"> | 377 | <StackPanel Orientation="Horizontal"> |
| 373 | <TextBlock Text=" Work " VerticalAlignment="Center" FontSize="17"></TextBlock> | 378 | <TextBlock Text=" Work " VerticalAlignment="Center" FontSize="17"></TextBlock> |
| 374 | </StackPanel> | 379 | </StackPanel> |
| 375 | </TabItem.Header> | 380 | </TabItem.Header> |
| 376 | </TabItem> | 381 | </TabItem> |
| 377 | <TabItem x:Name="TabSchedule" > | 382 | <TabItem x:Name="TabSchedule" > |
| 378 | <TabItem.Header> | 383 | <TabItem.Header> |
| 379 | <StackPanel Orientation="Horizontal"> | 384 | <StackPanel Orientation="Horizontal"> |
| 380 | <TextBlock Text=" Schedule " VerticalAlignment="Center" FontSize="17"></TextBlock> | 385 | <TextBlock Text=" Schedule " VerticalAlignment="Center" FontSize="17"></TextBlock> |
| 381 | </StackPanel> | 386 | </StackPanel> |
| 382 | </TabItem.Header> | 387 | </TabItem.Header> |
| 383 | </TabItem> | 388 | </TabItem> |
| 384 | </TabControl> | 389 | </TabControl> |
| 385 | </Grid> | 390 | </Grid> |
| 386 | </Grid> | 391 | </Grid> |
| 387 | </Window> | 392 | </Window> |
| 388 | 393 |
sources/RoboforkApp/RoboforkMenu.xaml.cs
| 1 | using System; | 1 | using System; |
| 2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
| 3 | using System.Linq; | 3 | using System.Linq; |
| 4 | using System.Text; | 4 | using System.Text; |
| 5 | using System.Threading.Tasks; | 5 | using System.Threading.Tasks; |
| 6 | using System.Windows; | 6 | using System.Windows; |
| 7 | using System.Windows.Controls; | 7 | using System.Windows.Controls; |
| 8 | using System.Windows.Data; | 8 | using System.Windows.Data; |
| 9 | using System.Windows.Documents; | 9 | using System.Windows.Documents; |
| 10 | using System.Windows.Input; | 10 | using System.Windows.Input; |
| 11 | using System.Windows.Media; | 11 | using System.Windows.Media; |
| 12 | using System.Windows.Media.Imaging; | 12 | using System.Windows.Media.Imaging; |
| 13 | using System.Windows.Shapes; | 13 | using System.Windows.Shapes; |
| 14 | 14 | ||
| 15 | namespace RoboforkApp | 15 | namespace RoboforkApp |
| 16 | { | 16 | { |
| 17 | /// <summary> | 17 | /// <summary> |
| 18 | /// Interaction logic for RoboforkMenu.xaml | 18 | /// Interaction logic for RoboforkMenu.xaml |
| 19 | /// </summary> | 19 | /// </summary> |
| 20 | public partial class RoboforkMenu : Window | 20 | public partial class RoboforkMenu : Window |
| 21 | { | 21 | { |
| 22 | public RoboforkMenu() | 22 | public RoboforkMenu() |
| 23 | { | 23 | { |
| 24 | InitializeComponent(); | 24 | InitializeComponent(); |
| 25 | Load_Form(); | 25 | Load_Form(); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | private void Load_Form() | 28 | private void Load_Form() |
| 29 | { | 29 | { |
| 30 | //PassplanTree.IsEnabled = false; | 30 | //PassplanTree.IsEnabled = false; |
| 31 | //NodeTree.IsEnabled = false; | 31 | //NodeTree.IsEnabled = false; |
| 32 | 32 | ||
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | private void btnMenu_Selected(object sender, RoutedEventArgs e) | 35 | private void btnMenu_Selected(object sender, RoutedEventArgs e) |
| 36 | { | 36 | { |
| 37 | if (((TreeViewItem)sender) == null) | 37 | if (((TreeViewItem)sender) == null) |
| 38 | { | 38 | { |
| 39 | return; | 39 | return; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | string tag = ((TreeViewItem)sender).Tag.ToString(); | 42 | string tag = ((TreeViewItem)sender).Tag.ToString(); |
| 43 | switch (tag) | 43 | switch (tag) |
| 44 | { | 44 | { |
| 45 | //2017/03/04 NAM ADD START1 | 45 | //2017/03/04 NAM ADD START1 |
| 46 | case "NodeTree": | 46 | case "NodeTree": |
| 47 | NewDoBeginSetFreeNotes(); | 47 | NewDoBeginSetFreeNotes(); |
| 48 | break; | 48 | break; |
| 49 | //2017/03/04 NAM ADD END | 49 | //2017/03/04 NAM ADD END |
| 50 | 50 | ||
| 51 | case "SetupRestriction": | 51 | case "SetupRestriction": |
| 52 | DoBeginSetupRestriction(); | 52 | DoBeginSetupRestriction(); |
| 53 | break; | 53 | break; |
| 54 | 54 | ||
| 55 | case "SetStart": | 55 | case "SetStart": |
| 56 | DoBeginSetStart(); | 56 | DoBeginSetStart(); |
| 57 | break; | 57 | break; |
| 58 | 58 | ||
| 59 | case "SetGoal": | 59 | case "SetGoal": |
| 60 | DoBeginSetGoal(); | 60 | DoBeginSetGoal(); |
| 61 | break; | 61 | break; |
| 62 | 62 | ||
| 63 | case "SetupRoute": | 63 | case "SetupRoute": |
| 64 | DoBeginSetupRoute(); | 64 | DoBeginSetupRoute(); |
| 65 | break; | 65 | break; |
| 66 | 66 | ||
| 67 | case "MakeRoot": | 67 | case "MakeRoot": |
| 68 | DoBeginMakeRoot(); | 68 | DoBeginMakeRoot(); |
| 69 | break; | 69 | break; |
| 70 | 70 | ||
| 71 | case "DeleteRoute": | 71 | case "DeleteRoute": |
| 72 | DoBeginDeleteRoute(); | 72 | DoBeginDeleteRoute(); |
| 73 | break; | 73 | break; |
| 74 | 74 | ||
| 75 | case "SetAutoNodes": | 75 | case "SetAutoNodes": |
| 76 | DoBeginSetAutoNotes(); | 76 | DoBeginSetAutoNotes(); |
| 77 | break; | 77 | break; |
| 78 | 78 | ||
| 79 | case "SetFreeNodes": | 79 | case "SetFreeNodes": |
| 80 | DoBeginSetFreeNotes(); | 80 | DoBeginSetFreeNotes(); |
| 81 | break; | 81 | break; |
| 82 | 82 | ||
| 83 | case "ScheduleRoute": | 83 | case "ScheduleRoute": |
| 84 | 84 | ||
| 85 | DoBeginSetSchedule(); | 85 | DoBeginSetSchedule(); |
| 86 | break; | 86 | break; |
| 87 | default: | 87 | default: |
| 88 | break; | 88 | break; |
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | 92 | ||
| 93 | 93 | ||
| 94 | private void DoBeginSetSchedule() | 94 | private void DoBeginSetSchedule() |
| 95 | { | 95 | { |
| 96 | 96 | ||
| 97 | MyDesignerCanvas.SetScheduleRoute(); | 97 | MyDesignerCanvas.SetScheduleRoute(); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | private void NewDoBeginSetFreeNotes() | 100 | private void NewDoBeginSetFreeNotes() |
| 101 | { | 101 | { |
| 102 | MyDesignerCanvas.Init(); | 102 | MyDesignerCanvas.Init(); |
| 103 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.NewDrawSetFreeNode; | 103 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.NewDrawSetFreeNode; |
| 104 | MyDesignerCanvas.scheduleCanvas = MyScheduleCanvas; | ||
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | private void btnMenu_UnselectedSet(object sender, RoutedEventArgs e) | 107 | private void btnMenu_UnselectedSet(object sender, RoutedEventArgs e) |
| 107 | { | 108 | { |
| 108 | if (((TreeViewItem)sender) == null) | 109 | if (((TreeViewItem)sender) == null) |
| 109 | { | 110 | { |
| 110 | return; | 111 | return; |
| 111 | } | 112 | } |
| 112 | 113 | ||
| 113 | string tag = ((TreeViewItem)sender).Tag.ToString(); | 114 | string tag = ((TreeViewItem)sender).Tag.ToString(); |
| 114 | switch (tag) | 115 | switch (tag) |
| 115 | { | 116 | { |
| 116 | case "SetupRestriction": | 117 | case "SetupRestriction": |
| 117 | //DoBeginSetStart(); | 118 | //DoBeginSetStart(); |
| 118 | break; | 119 | break; |
| 119 | 120 | ||
| 120 | case "SetStart": | 121 | case "SetStart": |
| 121 | //DoBeginSetStart(); | 122 | //DoBeginSetStart(); |
| 122 | break; | 123 | break; |
| 123 | 124 | ||
| 124 | case "SetGoal": | 125 | case "SetGoal": |
| 125 | //DoBeginSetGoal(); | 126 | //DoBeginSetGoal(); |
| 126 | break; | 127 | break; |
| 127 | 128 | ||
| 128 | case "DeleteRoute": | 129 | case "DeleteRoute": |
| 129 | //DoBeginDeleteRoute(); | 130 | //DoBeginDeleteRoute(); |
| 130 | break; | 131 | break; |
| 131 | 132 | ||
| 132 | case "SetupRoute": | 133 | case "SetupRoute": |
| 133 | //DoBeginSetupRoute(); | 134 | //DoBeginSetupRoute(); |
| 134 | break; | 135 | break; |
| 135 | 136 | ||
| 136 | case "MakeRoot": | 137 | case "MakeRoot": |
| 137 | //DoBeginMakeRoot(); | 138 | //DoBeginMakeRoot(); |
| 138 | break; | 139 | break; |
| 139 | 140 | ||
| 140 | default: | 141 | default: |
| 141 | break; | 142 | break; |
| 142 | } | 143 | } |
| 143 | } | 144 | } |
| 144 | 145 | ||
| 145 | private void DoBeginSetAutoNotes() | 146 | private void DoBeginSetAutoNotes() |
| 146 | { | 147 | { |
| 147 | MyDesignerCanvas.SetAutoNodes(); | 148 | MyDesignerCanvas.SetAutoNodes(); |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 150 | private void DoBeginSetFreeNotes() | 151 | private void DoBeginSetFreeNotes() |
| 151 | { | 152 | { |
| 152 | MyDesignerCanvas.Init(); | 153 | MyDesignerCanvas.Init(); |
| 153 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawSetFreeNode; | 154 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawSetFreeNode; |
| 154 | } | 155 | } |
| 155 | 156 | ||
| 156 | private void DoBeginSetupRestriction() | 157 | private void DoBeginSetupRestriction() |
| 157 | { | 158 | { |
| 158 | MyDesignerCanvas.Init(); | 159 | MyDesignerCanvas.Init(); |
| 159 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawObstract; | 160 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawObstract; |
| 160 | MyDesignerCanvas.mouseState = DesignerCanvas.MouseState.None; | 161 | MyDesignerCanvas.mouseState = DesignerCanvas.MouseState.None; |
| 161 | } | 162 | } |
| 162 | 163 | ||
| 163 | private void DoBeginSetStart() | 164 | private void DoBeginSetStart() |
| 164 | { | 165 | { |
| 165 | MyDesignerCanvas.CreateStartPoint(); | 166 | MyDesignerCanvas.CreateStartPoint(); |
| 166 | } | 167 | } |
| 167 | 168 | ||
| 168 | private void DoBeginSetGoal() | 169 | private void DoBeginSetGoal() |
| 169 | { | 170 | { |
| 170 | MyDesignerCanvas.CreateGoalPoint(); | 171 | MyDesignerCanvas.CreateGoalPoint(); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 173 | private void DoBeginSetupRoute() | 174 | private void DoBeginSetupRoute() |
| 174 | { | 175 | { |
| 175 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawRoute; | 176 | MyDesignerCanvas.Operation = DesignerCanvas.OperationState.DrawRoute; |
| 176 | } | 177 | } |
| 177 | 178 | ||
| 178 | private void DoBeginMakeRoot() | 179 | private void DoBeginMakeRoot() |
| 179 | { | 180 | { |
| 180 | MyDesignerCanvas.Children.Remove(MyDesignerCanvas.pRootLine); | 181 | MyDesignerCanvas.Children.Remove(MyDesignerCanvas.pRootLine); |
| 181 | MyDesignerCanvas.MakeRoot(); | 182 | MyDesignerCanvas.MakeRoot(); |
| 182 | } | 183 | } |
| 183 | 184 | ||
| 184 | private void DoBeginDeleteRoute() | 185 | private void DoBeginDeleteRoute() |
| 185 | { | 186 | { |
| 186 | MessageBoxResult result = MessageBox.Show("Do you want delete route?", "Delete route", MessageBoxButton.OKCancel); | 187 | MessageBoxResult result = MessageBox.Show("Do you want delete route?", "Delete route", MessageBoxButton.OKCancel); |
| 187 | if (result == MessageBoxResult.OK) | 188 | if (result == MessageBoxResult.OK) |
| 188 | { | 189 | { |
| 189 | MyDesignerCanvas.ClearRoute(); | 190 | MyDesignerCanvas.ClearRoute(); |
| 190 | } | 191 | } |
| 191 | } | 192 | } |
| 192 | 193 | ||
| 193 | private void GetPassplanTree(object sender, RoutedEventArgs e) | 194 | private void GetPassplanTree(object sender, RoutedEventArgs e) |
| 194 | { | 195 | { |
| 195 | MessageBoxResult result = MessageBox.Show("Selected PassplanTree", "", MessageBoxButton.OKCancel); | 196 | MessageBoxResult result = MessageBox.Show("Selected PassplanTree", "", MessageBoxButton.OKCancel); |
| 196 | } | 197 | } |
| 197 | 198 | ||
| 198 | private void SetPassplanTree(object sender, RoutedEventArgs e) | 199 | private void SetPassplanTree(object sender, RoutedEventArgs e) |
| 199 | { | 200 | { |
| 200 | 201 | ||
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | private void GetNodeTree(object sender, RoutedEventArgs e) | 204 | private void GetNodeTree(object sender, RoutedEventArgs e) |
| 204 | { | 205 | { |
| 205 | MessageBoxResult result = MessageBox.Show("Selected NodeTree", "", MessageBoxButton.OKCancel); | 206 | MessageBoxResult result = MessageBox.Show("Selected NodeTree", "", MessageBoxButton.OKCancel); |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 208 | private void SetNodeTree(object sender, RoutedEventArgs e) | 209 | private void SetNodeTree(object sender, RoutedEventArgs e) |
| 209 | { | 210 | { |
| 210 | 211 | ||
| 211 | } | 212 | } |
| 212 | 213 | ||
| 213 | private void GetFK15Tree(object sender, RoutedEventArgs e) | 214 | private void GetFK15Tree(object sender, RoutedEventArgs e) |
| 214 | { | 215 | { |
| 215 | MessageBoxResult result = MessageBox.Show("Selected FK15Tree", "", MessageBoxButton.OKCancel); | 216 | MessageBoxResult result = MessageBox.Show("Selected FK15Tree", "", MessageBoxButton.OKCancel); |
| 216 | } | 217 | } |
| 217 | 218 | ||
| 218 | private void SetFK15Tree(object sender, RoutedEventArgs e) | 219 | private void SetFK15Tree(object sender, RoutedEventArgs e) |
| 219 | { | 220 | { |
| 220 | 221 | ||
| 221 | } | 222 | } |
| 222 | 223 | ||
| 223 | private void GetVehicleAddTree(object sender, RoutedEventArgs e) | 224 | private void GetVehicleAddTree(object sender, RoutedEventArgs e) |
| 224 | { | 225 | { |
| 225 | MessageBoxResult result = MessageBox.Show("Selected VehicleAddTree", "", MessageBoxButton.OKCancel); | 226 | MessageBoxResult result = MessageBox.Show("Selected VehicleAddTree", "", MessageBoxButton.OKCancel); |
| 226 | } | 227 | } |
| 227 | 228 | ||
| 228 | private void SetVehicleAddTree(object sender, RoutedEventArgs e) | 229 | private void SetVehicleAddTree(object sender, RoutedEventArgs e) |
| 229 | { | 230 | { |
| 230 | 231 | ||
| 231 | } | 232 | } |
| 232 | 233 | ||
| 233 | private void GetTaskpattermTree(object sender, RoutedEventArgs e) | 234 | private void GetTaskpattermTree(object sender, RoutedEventArgs e) |
| 234 | { | 235 | { |
| 235 | 236 | ||
| 236 | } | 237 | } |
| 237 | 238 | ||
| 238 | private void SetTaskpattermTree(object sender, RoutedEventArgs e) | 239 | private void SetTaskpattermTree(object sender, RoutedEventArgs e) |
| 239 | { | 240 | { |
| 240 | 241 | ||
| 241 | } | 242 | } |
| 242 | 243 | ||
| 243 | private void GetWorkAddTree(object sender, RoutedEventArgs e) | 244 | private void GetWorkAddTree(object sender, RoutedEventArgs e) |
| 244 | { | 245 | { |
| 245 | 246 | ||
| 246 | } | 247 | } |
| 247 | 248 | ||
| 248 | private void SetWorkAddTree(object sender, RoutedEventArgs e) | 249 | private void SetWorkAddTree(object sender, RoutedEventArgs e) |
| 249 | { | 250 | { |
| 250 | 251 | ||
| 251 | } | 252 | } |
| 252 | 253 | ||
| 253 | private void GetConnectTree(object sender, RoutedEventArgs e) | 254 | private void GetConnectTree(object sender, RoutedEventArgs e) |
| 254 | { | 255 | { |
| 255 | 256 | ||
| 256 | } | 257 | } |
| 257 | 258 | ||
| 258 | private void SetConnectTree(object sender, RoutedEventArgs e) | 259 | private void SetConnectTree(object sender, RoutedEventArgs e) |
| 259 | { | 260 | { |
| 260 | 261 | ||
| 261 | } | 262 | } |
| 262 | 263 | ||
| 263 | private void GetParameterTree(object sender, RoutedEventArgs e) | 264 | private void GetParameterTree(object sender, RoutedEventArgs e) |
| 264 | { | 265 | { |
| 265 | 266 | ||
| 266 | } | 267 | } |
| 267 | 268 | ||
| 268 | private void SetParameterTree(object sender, RoutedEventArgs e) | 269 | private void SetParameterTree(object sender, RoutedEventArgs e) |
| 269 | { | 270 | { |
| 270 | 271 | ||
| 271 | } | 272 | } |
| 272 | 273 | ||
| 273 | private void GetScheduleTree(object sender, RoutedEventArgs e) | 274 | private void GetScheduleTree(object sender, RoutedEventArgs e) |
| 274 | { | 275 | { |
| 275 | 276 | ||
| 276 | } | 277 | } |
| 277 | 278 | ||
| 278 | private void SetScheduleTree(object sender, RoutedEventArgs e) | 279 | private void SetScheduleTree(object sender, RoutedEventArgs e) |
| 279 | { | 280 | { |
| 280 | 281 | ||
| 281 | } | 282 | } |
| 282 | 283 | ||
| 283 | private void GetLoggingTree(object sender, RoutedEventArgs e) | 284 | private void GetLoggingTree(object sender, RoutedEventArgs e) |
| 284 | { | 285 | { |
| 285 | 286 | ||
| 286 | } | 287 | } |
| 287 | 288 | ||
| 288 | private void SetLoggingTree(object sender, RoutedEventArgs e) | 289 | private void SetLoggingTree(object sender, RoutedEventArgs e) |
| 289 | { | 290 | { |
| 290 | 291 | ||
| 291 | } | 292 | } |
| 292 | 293 | ||
| 293 | private void GetAlertTree(object sender, RoutedEventArgs e) | 294 | private void GetAlertTree(object sender, RoutedEventArgs e) |
| 294 | { | 295 | { |
| 295 | 296 | ||
| 296 | } | 297 | } |
| 297 | 298 | ||
| 298 | private void SetAlertTree(object sender, RoutedEventArgs e) | 299 | private void SetAlertTree(object sender, RoutedEventArgs e) |
| 299 | { | 300 | { |
| 300 | 301 | ||
| 301 | } | 302 | } |
| 302 | 303 | ||
| 303 | private void GetHelpTree(object sender, RoutedEventArgs e) | 304 | private void GetHelpTree(object sender, RoutedEventArgs e) |
| 304 | { | 305 | { |
| 305 | 306 | ||
| 306 | } | 307 | } |
| 307 | 308 | ||
| 308 | private void SetHelpTree(object sender, RoutedEventArgs e) | 309 | private void SetHelpTree(object sender, RoutedEventArgs e) |
| 309 | { | 310 | { |
| 310 | 311 | ||
| 311 | } | 312 | } |
| 312 | 313 | ||
| 313 | private void GetNewProjectTree(object sender, RoutedEventArgs e) | 314 | private void GetNewProjectTree(object sender, RoutedEventArgs e) |
| 314 | { | 315 | { |
| 315 | 316 | ||
| 316 | } | 317 | } |
| 317 | 318 | ||
| 318 | private void SetNewProjectTree(object sender, RoutedEventArgs e) | 319 | private void SetNewProjectTree(object sender, RoutedEventArgs e) |
| 319 | { | 320 | { |
| 320 | 321 | ||
| 321 | } | 322 | } |
| 322 | 323 | ||
| 323 | 324 | ||
| 324 | } | 325 | } |
| 325 | } | 326 | } |
| 326 | 327 |
sources/RoboforkApp/ScheduleCanvas.cs
| File was created | 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.Media; | ||
| 9 | using System.Windows.Shapes; | ||
| 10 | |||
| 11 | namespace RoboforkApp | ||
| 12 | { | ||
| 13 | public class ScheduleCanvas : Canvas | ||
| 14 | { | ||
| 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(); | ||
| 20 | |||
| 21 | public void DrawRoute(List<ucNode> listNode) | ||
| 22 | { | ||
| 23 | //Update after | ||
| 24 | } | ||
| 25 | |||
| 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); | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 |