Exemplo n.º 1
0
        protected bool detectLabelOverlap(GraphPane pane, Graphics g, TextObj text, out Region textBoundsRegion, IPointList points, int pointIndex, bool pointsAreSticks)
        {
            string shape, coords;

            text.GetCoords(pane, g, 1.0f, out shape, out coords);
            if (shape != "poly")
            {
                throw new InvalidOperationException("shape must be 'poly'");
            }
            string[] textBoundsPointStrings = coords.Split(",".ToCharArray());
            if (textBoundsPointStrings.Length != 9)
            {
                throw new InvalidOperationException("coords length must be 8");
            }
            Point[] textBoundsPoints = new[]
            {
                new Point(Convert.ToInt32(textBoundsPointStrings[0]), Convert.ToInt32(textBoundsPointStrings[1])),
                new Point(Convert.ToInt32(textBoundsPointStrings[2]), Convert.ToInt32(textBoundsPointStrings[3])),
                new Point(Convert.ToInt32(textBoundsPointStrings[4]), Convert.ToInt32(textBoundsPointStrings[5])),
                new Point(Convert.ToInt32(textBoundsPointStrings[6]), Convert.ToInt32(textBoundsPointStrings[7]))
            };
            byte[] textBoundsPointTypes = new[]
            {
                (byte)PathPointType.Start,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line,
                (byte)PathPointType.Line
            };
            GraphicsPath textBoundsPath = new GraphicsPath(textBoundsPoints, textBoundsPointTypes);

            textBoundsPath.CloseFigure();
            textBoundsRegion = new Region(textBoundsPath);
            textBoundsRegion.Intersect(pane.Chart.Rect);
            RectangleF[] textBoundsRectangles = textBoundsRegion.GetRegionScans(g.Transform);

            for (int j = 0; j < textBoundsRectangles.Length; ++j)
            {
                if (IsVisibleToClip(g, textBoundsRectangles[j]))
                {
                    return(true);
                }
            }
            return(false);
        }