private void CalcIntesectionsWithLayers(ProfileLine selectedLine, ProfileSession profileSession)
        {
            var allIntersectionLines = new List <IntersectionsInLayer>();
            var layers           = View.GetLayers();
            var spatialReference = ArcMap.Document.FocusMap.SpatialReference;

            List <IPolyline>    polylines;
            List <ProfilePoint> pointsFrom;

            profileSession.Layers = new List <string>();

            if (selectedLine == null)
            {
                return;
            }

            if (selectedLine.Line.SpatialReference != spatialReference)
            {
                selectedLine.Line.Project(spatialReference);
            }

            var lineSurface    = profileSession.ProfileSurfaces.First(surface => surface.LineId == selectedLine.Id);
            var profileSegment = profileSession.Segments.First(segment => segment.LineId == selectedLine.Id);
            var distance       = 0.0;

            if (profileSegment.IsPrimitive)
            {
                polylines  = ProfileLinesConverter.ConvertLineToPrimitivePolylines(lineSurface, selectedLine.Line.SpatialReference);
                pointsFrom = profileSegment.Vertices;
            }
            else
            {
                polylines = new List <IPolyline> {
                    selectedLine.Line
                };
                pointsFrom = new List <ProfilePoint> {
                    selectedLine.PointFrom
                };
            }

            int j = 0;

            for (int n = 0; n < polylines.Count; n++)
            {
                var intersectionLines = new List <IntersectionsInLayer>();

                for (int i = 0; i < layers.Count; i++)
                {
                    if (!string.IsNullOrEmpty(layers[i]))
                    {
                        var layer = EsriTools.GetLayer(layers[i], ArcMap.Document.FocusMap);
                        var lines = EsriTools.GetIntersections(polylines[n], layer);

                        var layerFullName = $"Path/{layer.Name}";

                        if (!profileSession.Layers.Exists(sessionLayer => sessionLayer == layerFullName))
                        {
                            profileSession.Layers.Add(layerFullName);
                        }

                        if (lines != null && lines.Count() > 0)
                        {
                            var layerType        = (LayersEnum)Enum.GetValues(typeof(LayersEnum)).GetValue(i);
                            var intersectionLine = new IntersectionsInLayer
                            {
                                Lines = ProfileLinesConverter.ConvertEsriPolylineToIntersectionLines(lines, pointsFrom[j], layerType, distance),
                                Type  = layerType,
                            };

                            intersectionLine.SetDefaultColor();
                            intersectionLines.Add(intersectionLine);
                            SetLayersForPoints(intersectionLine, lineSurface);
                        }
                    }
                }

                allIntersectionLines.AddRange(intersectionLines);

                if (polylines.Count > 1)
                {
                    j++;

                    if (n < polylines.Count - 1)
                    {
                        distance += EsriTools.CreatePolylineFromPoints(polylines[n].FromPoint, polylines[n + 1].FromPoint).Length;
                    }
                }
            }

            graphsController.SetIntersections(allIntersectionLines, selectedLine.Id);
        }