From 576b92fd82f568572bc4beb125fa0ba0191a602f Mon Sep 17 00:00:00 2001
From: asmrobot <asmrobot@hotmail.com>
Date: Wed, 13 Nov 2019 14:59:52 +0000
Subject: [PATCH] add map editor

---
 src/RichCreator.Editor/Tools/MapEditor.xaml.cs |  670 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 528 insertions(+), 142 deletions(-)

diff --git a/src/RichCreator.Editor/Tools/MapEditor.xaml.cs b/src/RichCreator.Editor/Tools/MapEditor.xaml.cs
index 5ec9536..03c82e1 100644
--- a/src/RichCreator.Editor/Tools/MapEditor.xaml.cs
+++ b/src/RichCreator.Editor/Tools/MapEditor.xaml.cs
@@ -1,5 +1,6 @@
 using Emgu.CV;
 using RichCreator.Utility;
+using RichCreator.Utility.Maps;
 using RichCreator.Utility.PathFinding;
 using RichCreator.Utility.PathFindings;
 using RichCreator.Utility.Structs;
@@ -116,7 +117,7 @@
             //加载障碍物
             for (int i = 0; i < info.Obstacles.Count; i++)
             {
-                Polygon polygon=CreateObstacleUI(info.Obstacles[i]);
+                Polygon polygon = CreateObstacleUI(info.Obstacles[i]);
                 this.HouseInfoLayer.Children.Add(polygon);
             }
 
@@ -135,23 +136,210 @@
                 this.HouseInfoLayer.Children.Add(fp);
             }
 
-            //加载巡逻线
-            for (int i = 0; i < info.LoopLines.Count; i++)
-            {
-                Line llline = CreateLoopLineUI(info.LoopLines[i]);
-                this.HouseInfoLayer.Children.Add(llline);
-            }
-
+            
             //加载寻路线
             for (int i = 0; i < info.FindPathLines.Count; i++)
             {
                 Line fpline = CreateFindPathLineUI(info.FindPathLines[i]);
                 this.HouseInfoLayer.Children.Add(fpline);
             }
-            
+
+            //加载巡逻点
+            if (!info.LoopPoint.Equals(ZTPoint.Empty))
+            {
+                Canvas llline = CreateLoopPointUI(info.LoopPoint);
+                this.HouseInfoLayer.Children.Add(llline);
+            }
+
+
+            //进门点
+            for (int i = 0; i < info.NextGates.Count; i++)
+            {
+                Canvas ng = CreateNextGateUI(info.NextGates[i]);
+                this.HouseInfoLayer.Children.Add(ng);
+            }
+
+
+            //加载导引区域
+            for (int i = 0; i < info.PathGuides.Count; i++)
+            {
+                Polygon pg = CreatePathGuideUI(info.PathGuides[i]);
+                this.PathGuideShapeLayer.Children.Add(pg);
+            }
+
+
 
             this.housePathInfo = info;
         }
+
+        /// <summary>
+        /// 生成定位图片
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void CreateLocationPicture(object sender, RoutedEventArgs e)
+        {
+
+            string dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "numbers");
+            if (!System.IO.Directory.Exists(dir))
+            {
+                System.IO.Directory.CreateDirectory(dir);
+            }
+
+            for (Int32 i = 0; i <= 255; i++)
+            {
+                byte number = (byte)i;
+                System.Drawing.Bitmap image = new System.Drawing.Bitmap(12, 10);
+                //1
+                SetImagePixel(0, 0, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(2, 0, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(5, 0, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(7, 0, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(10, 0, 2, 2, image, System.Drawing.Color.White);
+
+                //2
+                SetImagePixel(0, 2, 2, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(10, 2, 2, 2, image, System.Drawing.Color.Black);
+
+                //3
+                SetImagePixel(0, 4, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(2, 4, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(5, 4, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(7, 4, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(10, 4, 2, 2, image, System.Drawing.Color.White);
+
+                //4
+                SetImagePixel(0, 6, 2, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(10, 6, 2, 2, image, System.Drawing.Color.Black);
+
+                //5
+                SetImagePixel(0, 8, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(2, 8, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(5, 8, 2, 2, image, System.Drawing.Color.White);
+                SetImagePixel(7, 8, 3, 2, image, System.Drawing.Color.Black);
+                SetImagePixel(10, 8, 2, 2, image, System.Drawing.Color.White);
+                Int32 x = 0, y = 0;
+                for (int bit = 0; bit <= 7; bit++)
+                {
+                    GetBitCoordinate(out x, out y, bit);
+                    if (HasValueInBit(number, bit))
+                    {
+                        SetImagePixel(x, y, 2, 2, image, System.Drawing.Color.White);
+                    }
+                    else
+                    {
+                        SetImagePixel(x, y, 2, 2, image, System.Drawing.Color.Black);
+                    }
+
+                }
+
+
+
+                string saveDir = System.IO.Path.Combine(dir, number.ToString() + ".png");
+                image.Save(saveDir, System.Drawing.Imaging.ImageFormat.Png);
+            }
+            MessageBox.Show("数字文件生成成功,生成至程序目录:numbers目录下");
+
+        }
+
+        /// <summary>
+        /// 设置像素
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="width"></param>
+        /// <param name="height"></param>
+        /// <param name="image"></param>
+        /// <param name="color"></param>
+        private void SetImagePixel(Int32 x, Int32 y, Int32 width, Int32 height, System.Drawing.Bitmap image, System.Drawing.Color color)
+        {
+            for (int w = 0; w < width; w++)
+            {
+                for (Int32 h = 0; h < height; h++)
+                {
+                    image.SetPixel(x + w, y + h, color);
+                }
+            }
+        }
+
+        /// <summary>
+        /// 得到指定位坐标
+        /// </summary>
+        /// <param name="x"></param>
+        /// <param name="y"></param>
+        /// <param name="bitIndex"></param>
+        private void GetBitCoordinate(out Int32 x, out Int32 y, Int32 bitIndex)
+        {
+            x = 0;
+            y = 0;
+            switch (bitIndex)
+            {
+                case 0:
+                    x = 8;
+                    y = 6;
+                    break;
+                case 1:
+                    x = 6;
+                    y = 6;
+                    break;
+                case 2:
+                    x = 4;
+                    y = 6;
+                    break;
+                case 3:
+                    x = 2;
+                    y = 6;
+                    break;
+                case 4:
+                    x = 8;
+                    y = 2;
+                    break;
+                case 5:
+                    x = 6;
+                    y = 2;
+                    break;
+                case 6:
+                    x = 4;
+                    y = 2;
+                    break;
+                case 7:
+                    x = 2;
+                    y = 2;
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 得到数字指定位是否有值
+        /// </summary>
+        /// <param name="number"></param>
+        /// <param name="bit"></param>
+        /// <returns></returns>
+        private bool HasValueInBit(byte number, Int32 bit)
+        {
+            switch (bit)
+            {
+                case 0:
+                    return (number & 0b00000001) != 0;
+                case 1:
+                    return (number & 0b00000010) != 0;
+                case 2:
+                    return (number & 0b00000100) != 0;
+                case 3:
+                    return (number & 0b00001000) != 0;
+                case 4:
+                    return (number & 0b00010000) != 0;
+                case 5:
+                    return (number & 0b00100000) != 0;
+                case 6:
+                    return (number & 0b01000000) != 0;
+                case 7:
+                    return (number & 0b10000000) != 0;
+            }
+            return true;
+        }
+
+
 
         /// <summary>
         /// 清理定位点
@@ -200,12 +388,10 @@
             ZTPoint start = this.startEndFindPathPoint[0];
             ZTPoint end = this.startEndFindPathPoint[1];
 
-            DNFPathFinding finder = new DNFPathFinding(this.housePathInfo);
+            HouseInfo house = new HouseInfo(this.housePathInfo);
+            List<ZTPoint> path = house.FindPath(ref start, ref end);
 
-
-            List<ZTPoint> path=finder.FindPath(ref start, ref end);
-            
-            if (path==null||path.Count <= 0)
+            if (path == null || path.Count <= 0)
             {
                 MessageBox.Show("不用寻路");
                 return;
@@ -217,7 +403,7 @@
                 for (int i = 0; i < path.Count; i++)
                 {
 
-                    Line line=GetPathLineUI(lastPoint, path[i]);
+                    Line line = GetPathLineUI(lastPoint, path[i]);
                     this.StartEndPointLayer.Children.Add(line);
                     lastPoint = path[i];
                 }
@@ -238,7 +424,8 @@
             }
             //是否添加障碍物
             OperateActionD op = (OperateActionD)(slOperate.SelectedIndex);
-            Int32 number = TypeConverter.StringToInt(this.tagNumber.Text, 0);
+            Int32 numParameter = TypeConverter.StringToInt(this.tagParameter.Text, 0);
+            string strParameter = this.tagParameter.Text;
 
             if (e.LeftButton == MouseButtonState.Released)
             {
@@ -247,15 +434,10 @@
             Point point = GetPosition(e);
 
 
-            if (op == OperateActionD.Obstacle)
-            {
-                //障碍物
-
-            }
-            else if (op == OperateActionD.LocationPoint)
+            if (op == OperateActionD.LocationPoint)
             {
                 //定位点
-                ParametersPoint lp = new ParametersPoint(new ZTPoint((Int32)point.X, (Int32)point.Y), number);
+                ParametersPoint lp = new ParametersPoint(new ZTPoint((Int32)point.X, (Int32)point.Y), numParameter);
                 if (this.housePathInfo.AddLocationPosition(lp))
                 {
                     Canvas lpControl = CreateLocationPointUI(lp);
@@ -272,17 +454,6 @@
                     this.HouseInfoLayer.Children.Add(fpControl);
                 }
             }
-            else if (op == OperateActionD.LoopLine)
-            {
-                //循环线
-                ZTPoint llPoint = GetFindPathPoint(new ZTPoint((Int32)point.X, (Int32)point.Y));
-                if (!llPoint.Equals(ZTPoint.Empty))
-                {
-                    tempLine = CreateTempLoopLineUI(llPoint);
-                    this.HouseInfoLayer.Children.Add(tempLine);
-                    moveable = true;
-                }
-            }
             else if (op == OperateActionD.FindPathLine)
             {
                 //寻路线
@@ -294,6 +465,19 @@
                     moveable = true;
                 }
             }
+            else if (op == OperateActionD.LoopPoint)
+            {
+                //循环点
+                if (!this.housePathInfo.LoopPoint.Equals(ZTPoint.Empty))
+                {
+                    //删除原来的巡逻点
+                }
+
+                ZTPoint sepoint = new ZTPoint((Int32)point.X, (Int32)point.Y);
+                this.housePathInfo.LoopPoint = sepoint;
+                Canvas lp = CreateLoopPointUI(sepoint);
+                this.HouseInfoLayer.Children.Add(lp);
+            }
             else if (op == OperateActionD.StartEndPoint)
             {
                 //画寻路起始和终点
@@ -302,6 +486,28 @@
                 this.StartEndPointLayer.Children.Add(lseControl);
                 this.startEndFindPathPoint.Add(sepoint);
             }
+            else if (op == OperateActionD.ReadCoordinate)
+            {
+                //读取坐标
+                ZTPoint sepoint = new ZTPoint((Int32)point.X, (Int32)point.Y);
+                this.tagParameter.Text = sepoint.X.ToString() + "," + sepoint.Y.ToString();
+            }
+            else if (op == OperateActionD.NextGate)
+            {
+                //下一关的门
+                if (numParameter < 0 || numParameter > 3)
+                {
+                    MessageBox.Show("参数必须是:0:上1:右2:下3:左");
+                    return;
+                }
+                ParametersPoint ng = new ParametersPoint(new ZTPoint((Int32)point.X, (Int32)point.Y), numParameter);
+                if (this.housePathInfo.AddNextGate(ng))
+                {
+                    Canvas ngControl = CreateNextGateUI(ng);
+                    this.HouseInfoLayer.Children.Add(ngControl);
+                }
+            }
+
         }
 
         /// <summary>
@@ -317,17 +523,7 @@
             }
             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 (op == OperateActionD.FindPathLine)
             {
                 //寻路线
                 if (!moveable)
@@ -337,7 +533,7 @@
                 tempLine.X2 = point.X;
                 tempLine.Y2 = point.Y;
             }
-            else if (op == OperateActionD.Obstacle)
+            else if (op == OperateActionD.Obstacle||op==OperateActionD.PathGuide)
             {
                 //障碍物线
                 if (!moveable)
@@ -363,34 +559,7 @@
             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.Equals(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 (op == OperateActionD.FindPathLine)
             {
                 //寻路线
                 if (!moveable)
@@ -417,9 +586,9 @@
                 this.HouseInfoLayer.Children.Remove(tempLine);
                 tempLine = null;
             }
-            else if (op == OperateActionD.Obstacle)
+            else if (op == OperateActionD.Obstacle|| op == OperateActionD.PathGuide)
             {
-                //绘制障碍物
+                //绘制障碍物或路径指导
                 //判断是否起点
                 if (tempPolyline == null)
                 {
@@ -441,21 +610,39 @@
                         return;
                     }
 
-                    if (IsFirstPoint(point) && this.points.Count > 2)
+                    if (IsComplete(point) && this.points.Count > 2)
                     {
                         //到起点,完成,向houseinfo里添加障碍物 ,画折线,
-                        ZTPoint[] obstaclePoints = new ZTPoint[this.points.Count];
+                        ZTPoint[] points = 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);
+                            points[i] = new ZTPoint((Int32)this.points[i].X, (Int32)this.points[i].Y);
                         }
 
-                        ZTPolygon ztpolygon = new ZTPolygon(obstaclePoints);
-                        this.housePathInfo.AddObstacle(ztpolygon);
+                        ZTPolygon ztpolygon = new ZTPolygon(points);
+                        if (op == OperateActionD.Obstacle)
+                        {
+                            //障碍物
+                            this.housePathInfo.AddObstacle(ztpolygon);
+                            Polygon obstacle = CreateObstacleUI(ztpolygon);
+                            this.HouseInfoLayer.Children.Add(obstacle);
+                        }
+                        else if (op == OperateActionD.PathGuide)
+                        {
+                            //路径导引
+                            string strParameter = this.tagParameter.Text;
+                            string[] sp = strParameter.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
+                            if (sp.Length == 2)
+                            {
+                                ZTPoint targetPoint = new ZTPoint(TypeConverter.StringToInt(sp[0],0), TypeConverter.StringToInt(sp[1], 0));
+                                ZTTargetPolygon targetPolygon = new ZTTargetPolygon(ztpolygon, targetPoint);
 
-                        Polygon polygon = CreateObstacleUI(ztpolygon);
-                        this.HouseInfoLayer.Children.Add(polygon);
-
+                                this.housePathInfo.AddPathGuide(targetPolygon);
+                                var pathGuide = CreatePathGuideUI(targetPolygon);
+                                this.PathGuideShapeLayer.Children.Add(pathGuide);
+                            }
+                        }
+                        
                         this.HouseInfoLayer.Children.Remove(tempPolyline);
                         tempPolyline = null;
                         this.HouseInfoLayer.Children.Remove(tempLine);
@@ -620,60 +807,8 @@
             }
 
         }
-
-        /// <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
@@ -807,7 +942,7 @@
             polygon.Opacity = 0.7f;
             for (int i = 0; i < ztpolygon.Points.Length; i++)
             {
-                polygon.Points.Add(new Point(ztpolygon.Points[i].X,ztpolygon.Points[i].Y));
+                polygon.Points.Add(new Point(ztpolygon.Points[i].X, ztpolygon.Points[i].Y));
             }
 
             return polygon;
@@ -841,6 +976,127 @@
             }
         }
 
+
+
+        /// <summary>
+        /// 创建障碍物UI
+        /// </summary>
+        /// <returns></returns>
+        private Polygon CreatePathGuideUI(ZTTargetPolygon ztpolygon)
+        {
+            Polygon polygon = new Polygon();
+            polygon.Tag = ztpolygon;
+            polygon.MouseRightButtonUp += PathGuide_MouseRightButtonUp;
+            polygon.MouseEnter += PathGuide_MouseEnter;
+            polygon.MouseLeave += PathGuide_MouseLeave;
+            polygon.StrokeThickness = 1;
+            polygon.Stroke = new SolidColorBrush(Colors.Yellow);
+            polygon.Fill = new SolidColorBrush(Colors.Yellow);
+            polygon.Opacity = 0.7f;
+            for (int i = 0; i < ztpolygon.Polygon.Points.Length; i++)
+            {
+                polygon.Points.Add(new Point(ztpolygon.Polygon.Points[i].X, ztpolygon.Polygon.Points[i].Y));
+            }
+
+            return polygon;
+        }
+
+        /// <summary>
+        /// 移出路径指导区域
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PathGuide_MouseLeave(object sender, MouseEventArgs e)
+        {
+            this.PathGuideLayer.Children.Clear();
+        }
+
+        /// <summary>
+        /// 移入路径指导区域
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PathGuide_MouseEnter(object sender, MouseEventArgs e)
+        {
+            Polygon c = sender as Polygon;
+            if (c == null)
+            {
+                return;
+            }
+
+            ZTTargetPolygon ztp = default(ZTTargetPolygon);
+            try
+            {
+                ztp = (ZTTargetPolygon)c.Tag;
+            }
+            catch
+            {
+                return;
+            }
+            this.PathGuideLayer.Children.Clear();
+
+            
+            Canvas main = new Canvas();
+            main.MouseRightButtonUp += NextGate_MouseRightButtonUp;
+            Canvas.SetLeft(main, ztp.Target.X);
+            Canvas.SetTop(main, ztp.Target.Y);
+
+            Rectangle rect = new Rectangle();
+            Canvas.SetLeft(rect, -10);
+            Canvas.SetTop(rect, -10);
+            rect.Width = 20;
+            rect.Height = 20;
+            rect.Stroke = new SolidColorBrush(Colors.Blue);
+            rect.StrokeThickness = 1;
+            rect.Fill = new SolidColorBrush(Colors.Blue);
+            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 = ztp.Target.ToString();
+            tb.FontSize = 9;
+            main.Children.Add(tb);
+
+            this.PathGuideLayer.Children.Add(main);
+        }
+
+        /// <summary>
+        /// 障碍物右键删除
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void PathGuide_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            Polygon c = sender as Polygon;
+            if (c == null)
+            {
+                return;
+            }
+
+            ZTTargetPolygon ztp = default(ZTTargetPolygon);
+            try
+            {
+                ztp = (ZTTargetPolygon)c.Tag;
+            }
+            catch
+            {
+                return;
+            }
+            if (this.housePathInfo.RemovePathGuide(ztp))
+            {
+                this.PathGuideShapeLayer.Children.Remove(c);
+            }
+        }
 
         /// <summary>
         /// 创建临时障碍物线UI
@@ -915,7 +1171,7 @@
             elli.StrokeThickness = 1;
             elli.Fill = new SolidColorBrush(Colors.Black);
             main.Children.Add(elli);
-            
+
 
             return main;
         }
@@ -939,6 +1195,132 @@
 
 
             return edgeLine;
+        }
+
+        /// <summary>
+        /// 创建进入下一关的门UI
+        /// 外方内圆
+        /// </summary>
+        private Canvas CreateNextGateUI(ParametersPoint point)
+        {
+            Canvas main = new Canvas();
+            main.Tag = point;
+            main.MouseRightButtonUp += NextGate_MouseRightButtonUp;
+            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.GreenYellow);
+            rect.StrokeThickness = 1;
+            rect.Fill = new SolidColorBrush(Colors.GreenYellow);
+            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;
+        }
+        
+        private void NextGate_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
+        {
+            Canvas c = sender as Canvas;
+            if (c == null)
+            {
+                return;
+            }
+
+            ParametersPoint fp = default(ParametersPoint);
+            try
+            {
+                fp = (ParametersPoint)c.Tag;
+            }
+            catch
+            {
+                return;
+            }
+            if (this.housePathInfo.RemoveNextGate(fp))
+            {
+                this.HouseInfoLayer.Children.Remove(c);
+            }
+
+        }
+
+        /// <summary>
+        /// 创建循环点界面
+        /// </summary>
+        /// <param name="point"></param>
+        /// <returns></returns>
+        private Canvas CreateLoopPointUI(ZTPoint point)
+        {
+            Canvas main = new Canvas();
+            main.Tag = point;
+            main.MouseRightButtonUp += LoopPoint_MouseRightButtonUp;
+            Canvas.SetLeft(main, point.X);
+            Canvas.SetTop(main, 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.OrangeRed);
+            rect.StrokeThickness = 1;
+            rect.Fill = new SolidColorBrush(Colors.OrangeRed);
+            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);
+            
+            return main;
+        }
+
+
+        private void LoopPoint_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;
+            }
+            this.housePathInfo.LoopPoint = ZTPoint.Empty;
+            this.HouseInfoLayer.Children.Remove(c);
         }
         #endregion
 
@@ -968,7 +1350,7 @@
         /// </summary>
         /// <param name="point"></param>
         /// <returns></returns>
-        private bool IsFirstPoint(Point point)
+        private bool IsComplete(Point point)
         {
             Point temp = this.points[0];
             if (Math.Abs(temp.X - point.X) <= 10 && Math.Abs(temp.Y - point.Y) <= 10)
@@ -1004,10 +1386,14 @@
             Obstacle = 0,//障碍物
             LocationPoint,//定位点
             FindPathPoint,//寻路点
-            LoopLine,//循环线
             FindPathLine,//寻路线
+            LoopPoint,//循环点
+            NextGate,//入门点
+            PathGuide,//路径引导
+            ReadCoordinate,//读取坐标
             StartEndPoint,//测试起终点
         }
 
+
     }
 }

--
Gitblit v1.9.3