internal override void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment)
 {
 }
        internal override bool IsSmartLabelCollide(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF position, SizeF size, PointF markerPosition, StringFormat format, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping)
        {
            bool result = false;

            if (common.Chart != null)
            {
                foreach (ChartArea chartArea in common.Chart.ChartAreas)
                {
                    if (area.Visible)
                    {
                        chartArea.smartLabels.checkAllCollisions = true;
                        if (chartArea.smartLabels.IsSmartLabelCollide(common, graph, area, smartLabelsStyle, position, size, markerPosition, format, labelAlignment, checkCalloutLineOverlapping))
                        {
                            chartArea.smartLabels.checkAllCollisions = false;
                            return(true);
                        }
                        chartArea.smartLabels.checkAllCollisions = false;
                    }
                }
            }
            RectangleF labelPosition = GetLabelPosition(graph, position, size, format, adjustForDrawing: false);
            bool       flag          = (labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? true : false;

            if (checkAllCollisions)
            {
                flag = false;
            }
            foreach (RectangleF smartLabelsPosition in smartLabelsPositions)
            {
                if (smartLabelsPosition.IntersectsWith(labelPosition))
                {
                    if (!flag)
                    {
                        return(true);
                    }
                    flag = false;
                }
            }
            return(result);
        }
Beispiel #3
0
        private bool FindNewPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, ref PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, ref SizeF markerSize, ref LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping)
        {
            SizeF  sizeF  = SizeF.Empty;
            PointF pointF = PointF.Empty;
            int    i      = 0;
            float  num    = 0f;
            bool   flag   = false;

            LabelAlignmentTypes[] array = new LabelAlignmentTypes[9]
            {
                LabelAlignmentTypes.Top,
                LabelAlignmentTypes.Bottom,
                LabelAlignmentTypes.Left,
                LabelAlignmentTypes.Right,
                LabelAlignmentTypes.TopLeft,
                LabelAlignmentTypes.TopRight,
                LabelAlignmentTypes.BottomLeft,
                LabelAlignmentTypes.BottomRight,
                LabelAlignmentTypes.Center
            };
            SizeF relativeSize = graph.GetRelativeSize(new SizeF(1f, 1f));
            bool  flag2        = false;
            float num2         = 2f;
            float num3         = (float)Math.Min(smartLabelsStyle.MinMovingDistance, smartLabelsStyle.MaxMovingDistance);
            float num4         = (float)Math.Max(smartLabelsStyle.MinMovingDistance, smartLabelsStyle.MaxMovingDistance);

            num = num3;
            while (!flag2 && num <= num4)
            {
                sizeF = new SizeF(markerSize.Width + num * (relativeSize.Width * 2f), markerSize.Height + num * (relativeSize.Height * 2f));
                for (i = 0; i < array.Length; i++)
                {
                    if ((array[i] != LabelAlignmentTypes.Center || num == num3) && (smartLabelsStyle.MovingDirection & array[i]) == array[i])
                    {
                        pointF = CalculatePosition(array[i], markerPosition, sizeF, labelSize, ref format);
                        if (!IsSmartLabelCollide(common, null, area, smartLabelsStyle, pointF, labelSize, markerPosition, format, array[i], checkCalloutLineOverlapping))
                        {
                            flag2 = true;
                            flag  = ((num != 0f) ? true : false);
                            break;
                        }
                    }
                }
                num += num2;
            }
            if (flag2)
            {
                markerSize     = sizeF;
                labelPosition  = pointF;
                labelAlignment = array[i];
            }
            if (!flag2 && smartLabelsStyle.HideOverlapped)
            {
                labelPosition = PointF.Empty;
            }
            if (!(flag && flag2))
            {
                return(false);
            }
            return(true);
        }
Beispiel #4
0
 internal PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping)
 {
     if (smartLabelsStyle.Enabled)
     {
         bool num = smartLabelsPositions.Count == 0;
         AddMarkersPosition(common, area);
         if (num)
         {
             markersCount = smartLabelsPositions.Count;
         }
         if (IsSmartLabelCollide(common, graph, area, smartLabelsStyle, labelPosition, labelSize, markerPosition, format, labelAlignment, checkCalloutLineOverlapping) && (FindNewPosition(common, graph, area, smartLabelsStyle, ref labelPosition, labelSize, ref format, markerPosition, ref markerSize, ref labelAlignment, checkCalloutLineOverlapping) || labelAlignment == LabelAlignmentTypes.BottomLeft || labelAlignment == LabelAlignmentTypes.BottomRight || labelAlignment == LabelAlignmentTypes.TopLeft || labelAlignment == LabelAlignmentTypes.TopRight) && !labelPosition.IsEmpty)
         {
             DrawCallout(common, graph, area, smartLabelsStyle, labelPosition, labelSize, format, markerPosition, markerSize, labelAlignment);
         }
         AddSmartLabelPosition(graph, area, labelPosition, labelSize, format);
     }
     return(labelPosition);
 }
Beispiel #5
0
 internal PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment)
 {
     return(AdjustSmartLabelPosition(common, graph, area, smartLabelsStyle, labelPosition, labelSize, ref format, markerPosition, markerSize, labelAlignment, checkCalloutLineOverlapping: false));
 }
Beispiel #6
0
        internal virtual bool IsSmartLabelCollide(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF position, SizeF size, PointF markerPosition, StringFormat format, LabelAlignmentTypes labelAlignment, bool checkCalloutLineOverlapping)
        {
            bool       flag          = false;
            RectangleF labelPosition = GetLabelPosition(graph, position, size, format, adjustForDrawing: false);

            if (labelPosition.X < 0f || labelPosition.Y < 0f || labelPosition.Bottom > 100f || labelPosition.Right > 100f)
            {
                flag = true;
            }
            if (!flag && area != null)
            {
                if (area.chartAreaIsCurcular)
                {
                    using (GraphicsPath graphicsPath = new GraphicsPath())
                    {
                        graphicsPath.AddEllipse(area.PlotAreaPosition.ToRectangleF());
                        if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.Partial)
                        {
                            PointF point = new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f);
                            if (!graphicsPath.IsVisible(point))
                            {
                                flag = true;
                            }
                        }
                        else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.No && (!graphicsPath.IsVisible(labelPosition.Location) || !graphicsPath.IsVisible(new PointF(labelPosition.Right, labelPosition.Y)) || !graphicsPath.IsVisible(new PointF(labelPosition.Right, labelPosition.Bottom)) || !graphicsPath.IsVisible(new PointF(labelPosition.X, labelPosition.Bottom))))
                        {
                            flag = true;
                        }
                    }
                }
                else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.Partial)
                {
                    PointF pt = new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f);
                    if (!area.PlotAreaPosition.ToRectangleF().Contains(pt))
                    {
                        flag = true;
                    }
                }
                else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.No && !area.PlotAreaPosition.ToRectangleF().Contains(labelPosition))
                {
                    flag = true;
                }
            }
            bool flag2 = (labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? true : false;

            if (checkAllCollisions)
            {
                flag2 = false;
            }
            if (!flag && smartLabelsPositions != null)
            {
                int num = -1;
                {
                    foreach (RectangleF smartLabelsPosition in smartLabelsPositions)
                    {
                        num++;
                        bool flag3 = smartLabelsPosition.IntersectsWith(labelPosition);
                        if (!flag3 && checkCalloutLineOverlapping && num >= markersCount && LineIntersectRectangle(point2: new PointF(labelPosition.X + labelPosition.Width / 2f, labelPosition.Y + labelPosition.Height / 2f), rect: smartLabelsPosition, point1: markerPosition))
                        {
                            flag3 = true;
                        }
                        if (flag3)
                        {
                            if (!flag2)
                            {
                                return(true);
                            }
                            flag2 = false;
                        }
                    }
                    return(flag);
                }
            }
            return(flag);
        }
Beispiel #7
0
        internal virtual void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment)
        {
            RectangleF absoluteRectangle = graph.GetAbsoluteRectangle(GetLabelPosition(graph, labelPosition, labelSize, format, adjustForDrawing: true));
            Pen        pen = new Pen(smartLabelsStyle.CalloutLineColor, smartLabelsStyle.CalloutLineWidth);

            pen.DashStyle = graph.GetPenStyle(smartLabelsStyle.CalloutLineStyle);
            if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Box)
            {
                if (smartLabelsStyle.CalloutBackColor != Color.Transparent)
                {
                    Brush brush = new SolidBrush(smartLabelsStyle.CalloutBackColor);
                    graph.FillRectangle(brush, absoluteRectangle);
                }
                graph.DrawRectangle(pen, absoluteRectangle.X, absoluteRectangle.Y, absoluteRectangle.Width, absoluteRectangle.Height);
            }
            else if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Underlined)
            {
                switch (labelAlignment)
                {
                case LabelAlignmentTypes.Right:
                    graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Top, absoluteRectangle.X, absoluteRectangle.Bottom);
                    break;

                case LabelAlignmentTypes.Left:
                    graph.DrawLine(pen, absoluteRectangle.Right, absoluteRectangle.Top, absoluteRectangle.Right, absoluteRectangle.Bottom);
                    break;

                case LabelAlignmentTypes.Bottom:
                    graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Top, absoluteRectangle.Right, absoluteRectangle.Top);
                    break;

                default:
                    graph.DrawLine(pen, absoluteRectangle.X, absoluteRectangle.Bottom, absoluteRectangle.Right, absoluteRectangle.Bottom);
                    break;
                }
            }
            PointF absolutePoint = graph.GetAbsolutePoint(labelPosition);

            switch (labelAlignment)
            {
            case LabelAlignmentTypes.Top:
                absolutePoint.Y = absoluteRectangle.Bottom;
                break;

            case LabelAlignmentTypes.Bottom:
                absolutePoint.Y = absoluteRectangle.Top;
                break;
            }
            if (smartLabelsStyle.CalloutStyle == LabelCalloutStyle.Underlined && (labelAlignment == LabelAlignmentTypes.TopLeft || labelAlignment == LabelAlignmentTypes.TopRight || labelAlignment == LabelAlignmentTypes.BottomLeft || labelAlignment == LabelAlignmentTypes.BottomRight))
            {
                absolutePoint.Y = absoluteRectangle.Bottom;
            }
            if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Arrow)
            {
                pen.StartCap       = LineCap.Custom;
                pen.CustomStartCap = new AdjustableArrowCap(pen.Width + 2f, pen.Width + 3f, isFilled: true);
            }
            else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Diamond)
            {
                pen.StartCap = LineCap.DiamondAnchor;
            }
            else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Round)
            {
                pen.StartCap = LineCap.RoundAnchor;
            }
            else if (smartLabelsStyle.CalloutLineAnchorCap == LineAnchorCap.Square)
            {
                pen.StartCap = LineCap.SquareAnchor;
            }
            PointF absolutePoint2 = graph.GetAbsolutePoint(markerPosition);

            graph.DrawLine(pen, absolutePoint2.X, absolutePoint2.Y, absolutePoint.X, absolutePoint.Y);
        }