private LineSegment2D GetLineSegment(int a, int b)
        {
            Point2D first  = CurrentPolygon.GetPoint(a);
            Point2D second = CurrentPolygon.GetPoint(b);

            return(new LineSegment2D(first, second));
        }
        public void Draw(Graphics g)
        {
            //site poligoni veke kompletirani
            foreach (Polygon p in Polygons)
            {
                p.Draw(g);
            }
            Pen pen = new Pen(Color.Black, 1);

            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            //momentalniot poligon dokolku postoi
            if (CurrentPolygon != null)
            {
                CurrentPolygon.Draw(g);
            }
            //momentalen poligon dokolku postoi i isprekinata linija do momentalna tocka
            if (CurrentPolygon != null)
            {
                CurrentPolygon.Draw(g);
                g.DrawLine(pen, CurrentPolygon.LastPoint(), CurrentPoint);
            }
            //
            if (!FirstPoint.IsEmpty && IsHit)
            {
                g.DrawEllipse(pen, FirstPoint.X - 5, FirstPoint.Y - 5, 10, 10);
            }
            pen.Dispose();
        }
示例#3
0
 void ExecuteSelectAll(object o)
 {
     if (CurrentPolygon != null)
     {
         CurrentPolygon.SelectAll();
     }
     FieldView.RefreshView();
 }
示例#4
0
 void ExecuteDeselectAll(object o)
 {
     if (CurrentPolygon != null)
     {
         CurrentPolygon.DeselectAll();
     }
     SelectedField = null;
     FieldView.RefreshView();
 }
        private void StartDrawingPolygon()
        {
            if (Clicks.Count == 1)
            {
                Poligon poligon = new Poligon(Drawing, GuidMapLogic);
                CurrentPolygon = poligon;
                GraphicObjects.Add(poligon.Guid, poligon);
                return;
            }
            var line = new Line(Clicks[Clicks.Count - 2], Clicks.Last(), Width, Drawing, GuidMapLogic, CurrentPolygon);

            CurrentPolygon.AddLine(line);
            line.DrawItself();
        }
        private LineSegment2D ChooseDiviser(LineSegment2D lineSegment)
        {
            for (int i = 0; i < CurrentPolygon.VertexCount; i++)
            {
                LineSegment2D Edge = CurrentPolygon.GetEdge(i);

                if (Edge == lineSegment || Edge.Intersects(lineSegment) || !Edge.LineIntersects(lineSegment))
                {
                    continue;
                }

                Point2D divPoint = lineSegment.ToLine().Intersects(Edge.ToLine());

                if (lineSegment.Contains(divPoint))
                {
                    continue;
                }

                LineSegment2D divLine = new LineSegment2D(lineSegment.LastPoint, divPoint);

                if (divLine.Contains(lineSegment.FirstPoint))
                {
                    //divLine = new LineSegment2D(lineSegment.FirstPoint, divPoint);
                    continue;
                }

                /*if (CurrentPolygon.InflectsEdge(divLine))
                 * {
                 *      int ssi = 0;
                 * }*/
                if (!CurrentPolygon.Contains(divLine))
                {
                    continue;
                }

                if (divPoint == this.LastPoint)
                {
                    ///need trace here
                    return(divLine);
                }

                if (this.isApart(divLine, this.CurrentPointIndex, this.LastPointIndex))
                {
                    return(divLine);
                }
            }

            return(null);
        }
        private bool isApart(LineSegment2D lineSegment, int c, int d)
        {
            double a = CurrentPolygon.OnEdge(lineSegment.FirstPoint) - 0.5;
            double b = CurrentPolygon.OnEdge(lineSegment.LastPoint) - 0.5;

            if (a < 0)
            {
                a += CurrentPolygon.VertexCount;
            }
            if (b < 0)
            {
                b += CurrentPolygon.VertexCount;
            }

            return(isApart(a, b, c, d));
        }
示例#8
0
 void ExecuteDelete(object o)
 {
     if (CurrentPolygon.PointsCount - CurrentPolygon.SelectedPointsCount >= 3)
     {
         CurrentPolygon.RemoveSelected();
         FieldView.RefreshView();
     }
     else
     {
         if (ParentPresenter.MasterView.ShowInfoYesNoMessage("Are you sure", "This operation will delete field"))
         {
             deleteSelectedField();
         }
     }
     FieldView.RefreshView();
 }
示例#9
0
        void ExecuteAddNewImmediately(object o)
        {
            if (CurrentPolygon != null)
            {
                CurrentPolygon.DeselectAll();
            }

            var hSize    = 20;
            var location = FieldView.GetCurrentMousePos();
            var polygon  = new FieldPolygon();

            polygon.AddPoint(new Vector2(location.X - hSize, location.Y - hSize));
            polygon.AddPoint(new Vector2(location.X + hSize, location.Y - hSize));
            polygon.AddPoint(new Vector2(location.X + hSize, location.Y + hSize));
            polygon.AddPoint(new Vector2(location.X - hSize, location.Y + hSize));
            commitPoly(polygon);
            FieldView.RefreshView();
        }
        private void StopDrawPolygon()
        {
            if (Clicks.Count > 2)
            {
                var line = new Line(Clicks.Last(), Clicks.First(), Width, Drawing, GuidMapLogic, CurrentPolygon);
                CurrentPolygon.AddLastLine(line);
                line.DrawItself();

                CurrentPolygon
                .Lines.ForEach(poligonLine => GraphicObjects.Add(poligonLine.Guid, poligonLine));

                CurrentPolygon
                .Verticies.ForEach(poligonVerticle => GraphicObjects.Add(poligonVerticle.Guid, poligonVerticle));

                CurrentPolygon.DrawOnGuidMap();
                //GuidMapLogic.SetOnMap(CurrentPolygon);
            }
            _buttonControl.StopDrawingPoligon();
            Clicks.Clear();
        }
 public void Click(Point Location)
 {
     if (FirstPoint.IsEmpty)
     {
         FirstPoint     = Location;
         CurrentPolygon = new Polygon();
         CurrentPolygon.AddPoint(Location);
     }
     else
     {
         CurrentPolygon.AddPoint(Location);
         if (IsHit)
         {
             CurrentPolygon.isCompleted = true;
             Polygons.Add(CurrentPolygon);
             FirstPoint     = Point.Empty;
             CurrentPolygon = null;
         }
     }
 }
示例#12
0
        void ExecuteAddNew(object o)
        {
            if (CurrentPolygon != null)
            {
                CurrentPolygon.DeselectAll();
            }


            _currentClickableAction             = new NewFieldClickAction();
            _currentClickableAction.ActionDone += (sender, args) =>
            {
                var poly = args.Result as IFieldPolygon;
                if (poly == null)
                {
                    return;
                }
                commitPoly(poly);

                FieldView.RefreshView();
            };
        }
示例#13
0
 void ExecuteMerge(object o)
 {
     CurrentPolygon.MergeSelected();
     FieldView.RefreshView();
 }
示例#14
0
 void ExecuteSplit(object o)
 {
     CurrentPolygon.SplitSelected();
     FieldView.RefreshView();
 }