o
asmrobot
2019-10-27 c4bd9d8c587bd1401f0fb2f60c34a4964d7afe20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
using Emgu.CV;
using RichCreator.Utility;
using RichCreator.Utility.PathFindings;
using RichCreator.Utility.Structs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ZTImage;
 
namespace RichCreator.Editor.Tools
{
    /// <summary>
    /// AStarTools.xaml 的交互逻辑
    /// </summary>
    public partial class MapEditor : Window
    {
        public MapEditor()
        {
            InitializeComponent();
        }
 
        // 寻路信息
        private HousePathInfo housePathInfo = null;
        private bool moveable = false;//可移动的
        private Line tempLine = null;
        private Polyline tempPolyline = null;
 
        // 当前图像
        private System.Drawing.Image image;
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
 
        }
 
        /// <summary>
        /// 加载图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenFromFile_Click(object sender, RoutedEventArgs e)
        {
            string imagePath = string.Empty;
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.DefaultExt = ".jpg";
            ofd.Filter = "image file|*.jpg;*.png;";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == true)
            {
                imagePath = ofd.FileName;
            }
            else
            {
                return;
            }
 
            Mat source = CvInvoke.Imread(imagePath, Emgu.CV.CvEnum.ImreadModes.Color);
            this.image = source.Bitmap;
            SetImage();
        }
        
        /// <summary>
        /// 复制JSON
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CopyJSON_Click(object sender, RoutedEventArgs e)
        {
            string json = this.housePathInfo.ToJsonString();
            Clipboard.SetDataObject(json, true);
        }
 
        /// <summary>
        /// 从JSON创建
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CreateFromJSON_Click(object sender, RoutedEventArgs e)
        {
            //SerializeInput input = new SerializeInput();
            //if (input.ShowDialog() != true)
            //{
            //    return;
            //}
 
            //FindPathInfo pi = FindPathInfo.FromJsonString(input.ColorString);
 
 
 
            ////生成网格
            //this.rectWidth.Text = pi.Width.ToString();
            //this.rectHeight.Text = pi.Height.ToString();
            //GenericRect(pi.Width, pi.Height, pi.RowCount, pi.ColCount);
 
 
            ////生成顶点
            //for (int i = 0; i < pi.Vertexs.Count; i++)
            //{
            //    SetVertexUI(pi.Vertexs[i]);
            //}
 
            ////生成连线
            //for (int i = 0; i < pi.Edges.Count; i++)
            //{
            //    GenericEdge(pi.Edges[i].StartIndex);
            //    SetEdge(pi.Edges[i].EndIndex);
            //}
 
 
            //this.PositionOverflowLayer.Children.Clear();
 
            ////生成定位点
            //for (int i = 0; i < pi.Positions.Count; i++)
            //{
            //    AddLocationPoint(pi.Positions[i].X, pi.Positions[i].Y, pi.Positions[i].Parameter);
            //}
        }
 
        /// <summary>
        /// 清理定位点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClearPosition_Click(object sender, RoutedEventArgs e)
        {
            this.LocationPointLayer.Children.Clear();
            this.housePathInfo.ClearLocationPosiltion();
        }
 
 
        /// <summary>
        /// 鼠标按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SourceImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //是否添加障碍物
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Int32 number = TypeConverter.StringToInt(this.tagNumber.Text, 0);
 
            if (e.LeftButton == MouseButtonState.Released)
            {
                return;
            }
            Point point = GetPosition(e);
 
 
            if (op == OperateActionD.Obstacle)
            {
                //障碍物
 
            }
            else if (op == OperateActionD.LocationPoint)
            {
                //定位点
                ParametersPoint lp = new ParametersPoint(new ZTPoint((Int32)point.X, (Int32)point.Y), number);
                if (this.housePathInfo.AddLocationPosition(lp))
                {
                    Canvas lpControl = CreateLocationPointUI(lp);
                    this.LocationPointLayer.Children.Add(lpControl);
                }
            }
            else if (op == OperateActionD.FindPathPoint)
            {
                //寻路点
                ZTPoint fp = new ZTPoint((Int32)point.X, (Int32)point.Y);
                if (this.housePathInfo.AddFindPathPoint(fp))
                {
                    Canvas fpControl = CreateFindPathPointUI(fp);
                    this.HouseInfoLayer.Children.Add(fpControl);
                }
            }
            else if (op == OperateActionD.LoopLine)
            {
                //循环线
                ZTPoint llPoint = GetFindPathPoint(new ZTPoint((Int32)point.X,(Int32)point.Y));
                if (llPoint != ZTPoint.Empty)
                {
                    tempLine = CreateTempLoopLineUI(llPoint);
                    this.HouseInfoLayer.Children.Add(tempLine);
                    moveable = true;
                }                
            }
            else if (op == OperateActionD.FindPathLine)
            {
                //寻路线
                ZTPoint fpPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (fpPoint != ZTPoint.Empty)
                {
                    tempLine = CreateTempFindPathLineUI(fpPoint);
                    this.HouseInfoLayer.Children.Add(tempLine);
                    moveable = true;
                }
            }
 
            
            
        }
 
        /// <summary>
        /// 鼠标移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SourceImage_MouseMove(object sender, MouseEventArgs e)
        {
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Point point = GetPosition(e);
            if (op == OperateActionD.LoopLine)
            {
                //巡逻线
                if (!moveable)
                {
                    return;
                }
                tempLine.X2 = point.X;
                tempLine.Y2 = point.Y;
            }
            else if (op == OperateActionD.FindPathLine)
            {
                //寻路线
                if (!moveable)
                {
                    return;
                }
                tempLine.X2 = point.X;
                tempLine.Y2 = point.Y;
            }
            else if (op == OperateActionD.Obstacle)
            {
                //障碍物线
                if (!moveable)
                {
                    return;
                }
                tempLine.X2 = point.X;
                tempLine.Y2 = point.Y;
            }
        }
        
        /// <summary>
        /// 鼠标提起
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SourceImage_MouseUp(object sender, MouseButtonEventArgs e)
        {
            OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
            Point point = GetPosition(e);
 
            if (op == OperateActionD.LoopLine)
            {
                //巡逻线
                if (!moveable)
                {
                    return;
                }
                moveable = false;
                if (tempLine == null)
                {
                    return;
                }
                ZTPoint startPoint = (ZTPoint)tempLine.Tag;
                ZTPoint centerPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (centerPoint != ZTPoint.Empty)
                {
                    ZTLinePoint ll = new ZTLinePoint(startPoint, centerPoint);
                    if (this.housePathInfo.AddLoopLine(ll))
                    {
                        Line llline = CreateLoopLineUI(ll);
                        this.HouseInfoLayer.Children.Add(llline);
                    }
                }
 
                this.HouseInfoLayer.Children.Remove(tempLine);
                tempLine = null;
            }
            else if (op == OperateActionD.FindPathLine)
            {
                //寻路线
                if (!moveable)
                {
                    return;
                }
                moveable = false;
                if (tempLine == null)
                {
                    return;
                }
                ZTPoint startPoint = (ZTPoint)tempLine.Tag;
                ZTPoint centerPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
                if (centerPoint != ZTPoint.Empty)
                {
                    ZTLinePoint fp = new ZTLinePoint(startPoint, centerPoint);
                    if (this.housePathInfo.AddFindPathLine(fp))
                    {
                        Line fpline = CreateFindPathLineUI(fp);
                        this.HouseInfoLayer.Children.Add(fpline);
                    }
                }
 
                this.HouseInfoLayer.Children.Remove(tempLine);
                tempLine = null;
            }
            else if (op == OperateActionD.Obstacle)
            {
                //绘制障碍物
                //判断是否起点
                if (tempPolyline == null)
                {
                    //首次画
                    this.points.Add(point);
                    this.tempPolyline=CreateTempObstacleUI(point);
                    this.tempLine = CreateObstacleLineUI(new ZTPoint((Int32)point.X, (Int32)point.Y));
 
                    moveable = true;
                    this.HouseInfoLayer.Children.Add(this.tempPolyline);
                    this.HouseInfoLayer.Children.Add(this.tempLine);
                }
                else
                {
                    if (IsLastPoint(point))
                    {
                        //判断是否跟最后一个点重合,如果重合则不处理
                        return;
                    }
 
                    if (IsFirstPoint(point))
                    {
                        //到起点,完成,画折线,向houseinfo里添加障碍物                        
                        Polygon polygon = CreateObstacleUI();
                        this.HouseInfoLayer.Children.Add(polygon);
 
                        ZTPoint[] obstaclePoints = new ZTPoint[this.points.Count];
                        for (int i = 0; i < this.points.Count; i++)
                        {
                            obstaclePoints[i] = new ZTPoint((Int32)this.points[i].X, (Int32)this.points[i].Y);
                        }
                        this.housePathInfo.AddObstacle(new ZTPolygon(obstaclePoints));
 
 
                        this.HouseInfoLayer.Children.Remove(tempPolyline);
                        tempPolyline = null;
                        this.HouseInfoLayer.Children.Remove(tempLine);
                        tempLine = null;
                        this.points.Clear();
                        moveable = false;
                    }
                    else
                    {
                        //向points里添加障碍点,画折线,更新tempLine,
                        this.points.Add(point);
                        //画折线
                        this.tempPolyline.Points.Add(point);
                        //更新tempLine
                        tempLine.X1 = point.X;
                        tempLine.Y1 = point.Y;
                        tempLine.X2 = point.X;
                        tempLine.Y2 = point.Y;
                    }
                }
 
            }
        }
 
        
        /// <summary>
        /// 计算当前鼠标位置和颜色
        /// </summary>
        /// <param name="e"></param>
        /// <param name="point"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private Point GetPosition(MouseEventArgs e)
        {
            Point point = e.GetPosition(this.scrollViewer);
 
            Int32 x = (Int32)Math.Round(this.scrollViewer.HorizontalOffset + point.X);
            Int32 y = (Int32)Math.Round(this.scrollViewer.VerticalOffset + point.Y);
 
            return new Point(x, y);
        }
 
 
        private List<Point> points = new List<Point>();
        /// <summary>
        /// 是否第一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsFirstPoint(Point point)
        {
            Point temp =this.points[0];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
 
            return false;
        }
 
        /// <summary>
        /// 是否最后一个点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private bool IsLastPoint(Point point)
        {
            Point temp = this.points[this.points.Count-1];
            if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
            {
                return true;
            }
 
            return false;
        }
 
 
        /// <summary>
        /// 操作类型
        /// </summary>
        public enum OperateActionD
        {
            Obstacle = 0,//障碍物
            LocationPoint,//定位点
            FindPathPoint,//寻路点
            LoopLine,//循环线
            FindPathLine,//寻路线
        }
 
 
        #region createUI
 
        /// <summary>
        /// 设置图像
        /// </summary>
        /// <param name="control"></param>
        /// <param name="image"></param>
        private void SetImage()
        {
            BitmapImage t = ImageHelper.BitmapToImageSource(image);
            this.SourceImage.Source = t;
            mainContainer.Width = image.Width;
            mainContainer.Height = image.Height;
            this.housePathInfo = new HousePathInfo();
        }
 
 
        /// <summary>
        /// 创建定位点UI
        /// 外方内圆
        /// </summary>
        private Canvas CreateLocationPointUI(ParametersPoint point)
        {
            //<Canvas Canvas.Left="point.x" Canvas.Top="point.y">
            //    <Rectangle Canvas.Left="-10" Canvas.Top="-10" Width="20" Height="20"  Stroke="Red" StrokeThickness="1"   />
            //    <Ellipse Canvas.Left="-2" Canvas.Top="-2" Width="4" Height="4" Fill="Red" StrokeThickness="1"  />
            //</Canvas>
 
            Canvas main = new Canvas();
            main.Tag = point;
            Canvas.SetLeft(main,point.Point.X);
            Canvas.SetTop(main, point.Point.Y);
            
            Rectangle rect = new Rectangle();
            Canvas.SetLeft(rect, -10);
            Canvas.SetTop(rect, -10);
            rect.Width = 20;
            rect.Height = 20;
            rect.Stroke = new SolidColorBrush(Colors.Red);
            rect.StrokeThickness = 1;
            rect.Fill = new SolidColorBrush(Colors.Red);
            rect.Opacity = 0.5f;
            main.Children.Add(rect);
            
            Ellipse elli = new Ellipse();
            Canvas.SetLeft(elli, -2);
            Canvas.SetTop(elli, -2);
            elli.Width = 4;
            elli.Height = 4;
            elli.Stroke = new SolidColorBrush(Colors.Black);
            elli.StrokeThickness = 1;
            elli.Fill = new SolidColorBrush(Colors.Black);
            main.Children.Add(elli);
            
            TextBlock tb = new TextBlock();
            tb.Text = point.Parameter.ToString();
            tb.FontSize = 9;
            main.Children.Add(tb);
 
 
            return main;
        }
        
        /// <summary>
        /// 创建寻路点UI
        /// </summary>
        private Canvas CreateFindPathPointUI(ZTPoint findPathPoint)
        {
            //<Canvas Canvas.Left="point.x" Canvas.Top="point.y">
            //    <Ellipse Canvas.Left="-10" Canvas.Top="-10" Width="20" Height="20"  Stroke="Red" StrokeThickness="1"  HorizontalAlignment="Center" VerticalAlignment="Center" />
            //    <Rectangle Canvas.Left="-2" Canvas.Top="-2" Width="4" Height="4" Fill="Red" StrokeThickness="1"  HorizontalAlignment="Center" VerticalAlignment="Center" />
            //</Canvas>
 
            Canvas main = new Canvas();
            main.Tag = findPathPoint;
            main.MouseRightButtonUp += FindPathPoint_MouseRightButtonUp;
            Canvas.SetLeft(main, findPathPoint.X);
            Canvas.SetTop(main, findPathPoint.Y);
 
 
            Ellipse elli = new Ellipse();
            Canvas.SetLeft(elli, -10);
            Canvas.SetTop(elli, -10);
            elli.Width = 20;
            elli.Height = 20;
            elli.Stroke = new SolidColorBrush(Colors.Red);
            elli.StrokeThickness = 1;
            elli.Fill = new SolidColorBrush(Colors.Red);
            elli.Opacity = 0.5f;
            main.Children.Add(elli);
 
 
            Rectangle rect = new Rectangle();
            Canvas.SetLeft(rect, -2);
            Canvas.SetTop(rect, -2);
            rect.Width = 4;
            rect.Height = 4;
            rect.Stroke = new SolidColorBrush(Colors.Black);
            rect.StrokeThickness = 1;
            rect.Fill = new SolidColorBrush(Colors.Black);
            rect.StrokeThickness = 1;
            main.Children.Add(rect);
 
            return main;
        }
        
        /// <summary>
        /// 寻路点右击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FindPathPoint_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            Canvas c = sender as Canvas;
            if (c == null)
            {
                return;
            }
 
            ZTPoint fp = default(ZTPoint);
            try
            {
                fp = (ZTPoint)c.Tag;
            }
            catch
            {
                return;
            }
            if (this.housePathInfo.RemoveFindPathPoint(fp))
            {
                this.HouseInfoLayer.Children.Remove(c);
            }
            
        }
        
        /// <summary>
        /// 创建巡逻线UI
        /// </summary>
        private Line CreateLoopLineUI(ZTLinePoint linePoint)
        {
            Line edgeLine = new Line();
            edgeLine.Tag = linePoint;
            edgeLine.MouseRightButtonUp += LoopLine_MouseRightButtonUp;
            edgeLine.Stroke = new SolidColorBrush(Colors.Red);
            edgeLine.StrokeThickness = 6;
            edgeLine.X1 = linePoint.X1;
            edgeLine.Y1 = linePoint.Y1;
 
            edgeLine.X2 = linePoint.X2;
            edgeLine.Y2 = linePoint.Y2;
 
            edgeLine.StrokeDashArray = new DoubleCollection() { 2, 3 };
            edgeLine.StrokeDashCap = PenLineCap.Triangle;
            edgeLine.StrokeEndLineCap = PenLineCap.Square;
            edgeLine.StrokeStartLineCap = PenLineCap.Round;
 
            
            return edgeLine;
        }
 
        /// <summary>
        /// 巡逻线右击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoopLine_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            Line c = sender as Line;
            if (c == null)
            {
                return;
            }
 
            ZTLinePoint fp = default(ZTLinePoint);
            try
            {
                fp = (ZTLinePoint)c.Tag;
            }
            catch
            {
                return;
            }
            if (this.housePathInfo.RemoveLoopLine(fp))
            {
                this.HouseInfoLayer.Children.Remove(c);
            }
 
        }
 
        /// <summary>
        /// 创建临时巡逻线UI
        /// </summary>
        /// <param name="linePoint"></param>
        /// <returns></returns>
        private Line CreateTempLoopLineUI(ZTPoint point)
        {
            Line edgeLine = new Line();
            edgeLine.Tag = point;
            edgeLine.Stroke = new SolidColorBrush(Colors.Red);
            edgeLine.StrokeThickness = 3;
            edgeLine.X1 = point.X;
            edgeLine.Y1 = point.Y;
 
            edgeLine.X2 = point.X;
            edgeLine.Y2 = point.Y;
 
            edgeLine.StrokeDashArray = new DoubleCollection() { 2, 3 };
            edgeLine.StrokeDashCap = PenLineCap.Triangle;
            edgeLine.StrokeEndLineCap = PenLineCap.Square;
            edgeLine.StrokeStartLineCap = PenLineCap.Round;
            
            return edgeLine;
        }
 
 
        /// <summary>
        /// 创建寻路线UI
        /// </summary>
        private Line CreateFindPathLineUI(ZTLinePoint linePoint)
        {
            Line edgeLine = new Line();
            edgeLine.Tag = linePoint;
            edgeLine.MouseRightButtonUp += FindPathLine_MouseRightButtonUp; ;
            edgeLine.Stroke = new SolidColorBrush(Colors.Red);
            edgeLine.StrokeThickness = 3;
            edgeLine.X1 = linePoint.X1;
            edgeLine.Y1 = linePoint.Y1;
 
            edgeLine.X2 = linePoint.X2;
            edgeLine.Y2 = linePoint.Y2;
            
            
            return edgeLine;
        }
 
        /// <summary>
        /// 寻路线右键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FindPathLine_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            Line c = sender as Line;
            if (c == null)
            {
                return;
            }
 
            ZTLinePoint fp = default(ZTLinePoint);
            try
            {
                fp = (ZTLinePoint)c.Tag;
            }
            catch
            {
                return;
            }
            if (this.housePathInfo.RemoveFindPathLine(fp))
            {
                this.HouseInfoLayer.Children.Remove(c);
            }
        }
 
 
        /// <summary>
        /// 创建临时寻路线UI
        /// </summary>
        /// <param name="linePoint"></param>
        /// <returns></returns>
        private Line CreateTempFindPathLineUI(ZTPoint point)
        {
            Line edgeLine = new Line();
            edgeLine.Tag = point;
            edgeLine.Stroke = new SolidColorBrush(Colors.Red);
            edgeLine.StrokeThickness = 3;
            edgeLine.X1 = point.X;
            edgeLine.Y1 = point.Y;
 
            edgeLine.X2 = point.X;
            edgeLine.Y2 = point.Y;
            
            
            return edgeLine;
        }
 
        /// <summary>
        /// 创建临时障碍物UI
        /// </summary>
        /// <returns></returns>
        private Polyline CreateTempObstacleUI(Point point)
        {
            //<!--<Polygon StrokeThickness="1" Stroke="Black"    Opacity="0.5">
            //        <Polygon.Points>10,50 180,50 180,150 </Polygon.Points>
            //    </Polygon>-->
            Polyline polyline = new Polyline();
            polyline.StrokeThickness = 1;
            polyline.Stroke = new SolidColorBrush(Colors.Black);
            polyline.Opacity = 0.5f;
            polyline.Points.Add(point);
            return polyline;
        }
 
 
        /// <summary>
        /// 创建障碍物UI
        /// </summary>
        /// <returns></returns>
        private Polygon CreateObstacleUI()
        {
            //<!--<Polygon StrokeThickness="1" Stroke="Black"    Opacity="0.5">
            //        <Polygon.Points>10,50 180,50 180,150 </Polygon.Points>
            //    </Polygon>-->
            Polygon polygon = new Polygon();
            polygon.StrokeThickness = 1;
            polygon.Stroke = new SolidColorBrush(Colors.Black);
            polygon.Fill= new SolidColorBrush(Colors.Black);
            polygon.Opacity = 0.7f;
            for (int i = 0; i < this.points.Count; i++)
            {
                polygon.Points.Add(this.points[i]);
            }
            
            return polygon;
        }
 
 
        /// <summary>
        /// 创建临时障碍物线UI
        /// </summary>
        /// <param name="linePoint"></param>
        /// <returns></returns>
        private Line CreateObstacleLineUI(ZTPoint point)
        {
            Line edgeLine = new Line();
            edgeLine.Tag = point;
            edgeLine.Stroke = new SolidColorBrush(Colors.Black);
            edgeLine.StrokeThickness = 1;
            edgeLine.X1 = point.X;
            edgeLine.Y1 = point.Y;
 
            edgeLine.X2 = point.X;
            edgeLine.Y2 = point.Y;
 
 
            return edgeLine;
        }
 
        /// <summary>
        /// 获取当前位置点
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        private ZTPoint GetFindPathPoint(ZTPoint point)
        {
            ZTPoint temp = ZTPoint.Empty;
            for (int i = 0; i < this.housePathInfo.FindPathPoints.Count; i++)
            {
                temp = this.housePathInfo.FindPathPoints[i];
                if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
                {
                    return temp;
                }
            }
            return default(ZTPoint);
        }
        #endregion
 
 
 
 
        #region Tools
        //private bool PointInRang(Point)
        #endregion
    }
}