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