Example #1
0
File: Form1.cs Project: am1guma/BR
        private void b3_Click(object sender, EventArgs e)
        {
            try
            {
                _id        = "b3";
                b3.Checked = true;
                b1.Checked = false;
                b2.Checked = false;
                b4.Checked = false;
                b5.Checked = false;

                if (_spDefined && _epDefined)
                {
                    PolygonManager.ListOfPolygons = _polygons;
                    SegmentsManager.Segments      = PolygonManager.GetAllPolygonsSegments();
                    var allPoints = PolygonManager.GetAllPoints();
                    for (var i = 0; i < allPoints.Count; i++)
                    {
                        for (var j = 0; j < allPoints.Count; j++)
                        {
                            if (i != j)
                            {
                                var s = new Segment(allPoints[i], allPoints[j]);
                                if (!SegmentsManager.CheckIfSegmentAlreadyExists(s) &&
                                    IntersectieManager.CheckIfASegmentIntersectsAnotherSegment(s) &&
                                    !PolygonManager.CheckIfSegmentIntersectTwoPointsFromAnInternalShape(s))
                                {
                                    _g.DrawLine(new Pen(Color.Black), allPoints[i], allPoints[j]);
                                    SegmentsManager.Segments.Add(s);
                                }
                            }
                        }
                    }
                    DefineTriangles();
                    CreateGraph();
                    FindTheShortestPath();
                }
                else
                {
                    MessageBox.Show(@"StartPoint and EndPoint are not defined!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }