예제 #1
0
        /// <summary>
        /// Event for draw polygon button.
        /// Gets all root points in treelistview and creates a
        /// polygon if more than 2 points, a line if exactly
        /// 2 points, and nothing if there is 1 or less.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnDrawPolygon_Click(object sender, EventArgs e)
        {
            List <PointItem> list = new List <PointItem>();
            object           item;

            foreach (var o in treeListView1.Objects)
            {
                if (o is PointItem)
                {
                    list.Add((PointItem)o);
                }
            }

            if (list.Count > 1)
            {
                if (list.Count == 2)
                {
                    item = new LineItem(list, 1);
                    ((LineItem)item).DrawOnMap(map, polygons, markers);
                }
                else
                {
                    item = new PolygonItem(list, 1);
                    ((PolygonItem)item).DrawOnMap(map, polygons, markers);
                }
                treeListView1.AddObject(item);
                CenterMapToPoint(map.Position);
                treeListView1.RemoveObjects(list);
            }
        }
        /// <summary>
        /// Resizes the flight line to the given polygon (usually parent).
        /// Find if trigger points are over polygon. If they are then the
        /// previous trigger and next trigger will be kept. Removes any
        /// that are not over polygon or not next to one that is over polygon.
        /// </summary>
        /// <param name="p"></param>
        public void ResizeToPoly(PolygonItem p)
        {
            bool       mem1            = false;
            bool       mem2            = true;
            List <int> indexesToRemove = new List <int>();

            for (int i = Triggers.Count - 1; i > -1; i--)
            {
                if (Triggers[i].IsOverPolygon(p))
                {
                    mem2 = mem1;
                    mem1 = true;
                }
                else
                {
                    if (!mem1 && !mem2)
                    {
                        Triggers.RemoveAt(i + 1);
                    }
                    mem2 = mem1;
                    mem1 = false;
                }
            }
            if (!mem1 && !mem2)
            {
                Triggers.RemoveAt(0);
            }
            if (Triggers.Count != 0)
            {
                Line.PointItems[0] = Triggers[0].Point;
                Line.PointItems[1] = Triggers.Last().Point;
                Line.CreateGMapPolygon();
            }
            RefreshChildren();
        }
예제 #3
0
 public bool IsOverPolygon(PolygonItem p)
 {
     return(p.Poly.IsInside(Point.Coords));
 }