Beispiel #1
0
        internal virtual void AddMarkersPosition(CommonElements common, ChartArea area)
        {
            if (smartLabelsPositions.Count != 0 || area == null)
            {
                return;
            }
            ChartTypeRegistry chartTypeRegistry = common.ChartTypeRegistry;

            foreach (Series item in common.DataManager.Series)
            {
                if (item.ChartArea == area.Name && item.SmartLabels.Enabled && !item.SmartLabels.MarkerOverlapping)
                {
                    chartTypeRegistry.GetChartType(item.ChartTypeName).AddSmartLabelMarkerPositions(common, area, item, smartLabelsPositions);
                }
            }
            Axis[] axes = area.Axes;
            foreach (Axis axis in axes)
            {
                if (!(axis.ScaleBreakStyle.Spacing > 0.0) || axis.ScaleSegments.Count <= 0)
                {
                    continue;
                }
                for (int j = 0; j < axis.ScaleSegments.Count - 1; j++)
                {
                    RectangleF breakLinePosition = axis.ScaleSegments[j].GetBreakLinePosition(common.graph, axis.ScaleSegments[j + 1]);
                    breakLinePosition = common.graph.GetRelativeRectangle(breakLinePosition);
                    if (smartLabelsPositions == null)
                    {
                        smartLabelsPositions = new ArrayList();
                    }
                    smartLabelsPositions.Add(breakLinePosition);
                }
            }
        }
Beispiel #2
0
 public DataPoint(double xValue, string yValues)
     : base(null, pointAttributes: true)
 {
     string[] array = yValues.Split(',');
     yValue = new double[array.Length];
     for (int i = 0; i < array.Length; i++)
     {
         yValue[i] = CommonElements.ParseDouble(array[i]);
     }
     this.xValue = xValue;
 }
 internal override void AddMarkersPosition(CommonElements common, ChartArea area)
 {
     if (smartLabelsPositions.Count != 0 || common == null || common.Chart == null)
     {
         return;
     }
     foreach (Annotation annotation in common.Chart.Annotations)
     {
         annotation.AddSmartLabelMarkerPositions(common, smartLabelsPositions);
     }
 }
        internal void SetAttributes(CommonElements common, Series series)
        {
            IChartType chartType = common.ChartTypeRegistry.GetChartType(series.ChartTypeName);

            style        = chartType.GetLegendImageStyle(series);
            seriesName   = series.Name;
            shadowOffset = series.ShadowOffset;
            shadowColor  = series.ShadowColor;
            bool enable3D = common.Chart.ChartAreas[series.ChartArea].Area3DStyle.Enable3D;

            SetAttributes(series, enable3D);
        }
Beispiel #5
0
 private double ConvertValue(object value)
 {
     if (value == null)
     {
         return(0.0);
     }
     if (value is double)
     {
         return((double)value);
     }
     if (value is float)
     {
         return((float)value);
     }
     if (value is decimal)
     {
         return((double)(decimal)value);
     }
     if (value is int)
     {
         return((int)value);
     }
     if (value is uint)
     {
         return((uint)value);
     }
     if (value is long)
     {
         return((long)value);
     }
     if (value is ulong)
     {
         return((ulong)value);
     }
     if (value is byte)
     {
         return((int)(byte)value);
     }
     if (value is sbyte)
     {
         return((sbyte)value);
     }
     if (value is bool)
     {
         if (!(bool)value)
         {
             return(0.0);
         }
         return(1.0);
     }
     return(CommonElements.ParseDouble(value.ToString()));
 }
Beispiel #6
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);
 }
        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 #8
0
 public HotRegionsList(CommonElements common)
 {
     this.common = common;
 }
Beispiel #9
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 #10
0
        public void SetValueY(params object[] yValue)
        {
            if (yValue.Length == 0 || (series != null && yValue.Length > series.YValuesPerPoint))
            {
                throw new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesSettingCountMismatch(series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture)));
            }
            for (int i = 0; i < yValue.Length; i++)
            {
                if (yValue[i] == null || yValue[i] is DBNull)
                {
                    yValue[i] = 0.0;
                    if (i == 0)
                    {
                        Empty = true;
                    }
                }
            }
            Type type = yValue[0].GetType();

            if (series != null)
            {
                series.CheckSupportedTypes(type);
            }
            if (this.yValue.Length < yValue.Length)
            {
                this.yValue = new double[yValue.Length];
            }
            if (type == typeof(string))
            {
                try
                {
                    for (int j = 0; j < yValue.Length; j++)
                    {
                        this.yValue[j] = CommonElements.ParseDouble((string)yValue[j]);
                    }
                }
                catch
                {
                    if (series != null && series.chart == null && series.serviceContainer != null)
                    {
                        series.chart = (Chart)series.serviceContainer.GetService(typeof(Chart));
                    }
                    if (series == null || series.chart == null || !series.chart.chartPicture.SuppressExceptions)
                    {
                        throw new ArgumentException(SR.ExceptionDataPointYValueStringFormat);
                    }
                    Empty = true;
                    for (int k = 0; k < yValue.Length; k++)
                    {
                        yValue[k] = 0.0;
                    }
                }
            }
            else if (type == typeof(DateTime))
            {
                for (int l = 0; l < yValue.Length; l++)
                {
                    if (yValue[l] == null || (yValue[l] is double && (double)yValue[l] == 0.0))
                    {
                        this.yValue[l] = DateTime.Now.ToOADate();
                    }
                    else
                    {
                        this.yValue[l] = ((DateTime)yValue[l]).ToOADate();
                    }
                }
            }
            else
            {
                for (int m = 0; m < yValue.Length; m++)
                {
                    this.yValue[m] = ConvertValue(yValue[m]);
                }
            }
            if (series == null)
            {
                return;
            }
            for (int n = 0; n < yValue.Length; n++)
            {
                if (yValue[n] == null || (yValue[n] is double && (double)yValue[n] == 0.0))
                {
                    if (series.YValueType == ChartValueTypes.Date)
                    {
                        this.yValue[n] = Math.Floor(this.yValue[n]);
                    }
                    else if (series.YValueType == ChartValueTypes.Time)
                    {
                        this.yValue[n] = xValue - Math.Floor(this.yValue[n]);
                    }
                }
                else if (series.YValueType == ChartValueTypes.Date)
                {
                    DateTime dateTime  = (yValue[n] is DateTime) ? ((DateTime)yValue[n]) : ((!(yValue[n] is double)) ? Convert.ToDateTime(yValue[n], CultureInfo.InvariantCulture) : DateTime.FromOADate((double)yValue[n]));
                    DateTime dateTime2 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, 0);
                    this.yValue[n] = dateTime2.ToOADate();
                }
                else if (series.YValueType == ChartValueTypes.Time)
                {
                    DateTime dateTime3;
                    if (yValue[n] is DateTime)
                    {
                        dateTime3 = (DateTime)yValue[n];
                    }
                    dateTime3 = ((!(yValue[n] is double)) ? Convert.ToDateTime(yValue[n], CultureInfo.InvariantCulture) : DateTime.FromOADate((double)yValue[n]));
                    DateTime dateTime4 = new DateTime(1899, 12, 30, dateTime3.Hour, dateTime3.Minute, dateTime3.Second, dateTime3.Millisecond);
                    this.yValue[n] = dateTime4.ToOADate();
                }
            }
        }
 internal ChartAreaCollection(CommonElements common)
 {
     this.common = common;
     common.chartAreaCollection = this;
 }
Beispiel #12
0
 private void InitAnimation3D(CommonElements common, RectangleF position, float positionZ, float depth, Matrix3D matrix, ChartGraphics graph, Axis axis)
 {
 }
Beispiel #13
0
        internal void Paint(ChartGraphics graph, CommonElements common, bool drawLinesOnly)
        {
            if (axis.chartArea.chartAreaIsCurcular)
            {
                return;
            }
            RectangleF rect = axis.chartArea.PlotAreaPosition.ToRectangleF();
            bool       flag = true;

            if (axis.AxisPosition == AxisPosition.Bottom || axis.AxisPosition == AxisPosition.Top)
            {
                flag = false;
            }
            Series series = null;

            if (axis.axisType == AxisName.X || axis.axisType == AxisName.X2)
            {
                ArrayList xAxesSeries = axis.chartArea.GetXAxesSeries((axis.axisType != 0) ? AxisType.Secondary : AxisType.Primary, axis.SubAxisName);
                if (xAxesSeries.Count > 0)
                {
                    series = axis.Common.DataManager.Series[xAxesSeries[0]];
                    if (series != null && !series.XValueIndexed)
                    {
                        series = null;
                    }
                }
            }
            double num = axis.GetViewMinimum();

            if (!axis.chartArea.chartAreaIsCurcular || axis.axisType == AxisName.Y || axis.axisType == AxisName.Y2)
            {
                double num2 = Interval;
                if (interlaced)
                {
                    num2 /= 2.0;
                }
                num = axis.AlignIntervalStart(num, num2, IntervalType, series);
            }
            if (Interval != 0.0 && (axis.GetViewMaximum() - axis.GetViewMinimum()) / axis.GetIntervalSize(num, interval, intervalType, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: false) > 10000.0)
            {
                return;
            }
            DateTimeIntervalType type = (IntervalOffsetType == DateTimeIntervalType.Auto) ? IntervalType : IntervalOffsetType;

            if (Interval == 0.0)
            {
                num = IntervalOffset;
            }
            else if (IntervalOffset > 0.0)
            {
                num += axis.GetIntervalSize(num, IntervalOffset, type, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: false);
            }
            else if (IntervalOffset < 0.0)
            {
                num -= axis.GetIntervalSize(num, 0.0 - IntervalOffset, type, series, 0.0, DateTimeIntervalType.Number, forceIntIndex: false);
            }
            int num3 = 0;

            while (num3++ <= 10000)
            {
                if (StripWidth > 0.0 && !drawLinesOnly)
                {
                    double num4 = num + axis.GetIntervalSize(num, StripWidth, StripWidthType, series, IntervalOffset, type, forceIntIndex: false);
                    if (num4 > axis.GetViewMinimum() && num < axis.GetViewMaximum())
                    {
                        RectangleF empty = RectangleF.Empty;
                        double     val   = (float)axis.GetLinearPosition(num);
                        double     val2  = (float)axis.GetLinearPosition(num4);
                        if (flag)
                        {
                            empty.X      = rect.X;
                            empty.Width  = rect.Width;
                            empty.Y      = (float)Math.Min(val, val2);
                            empty.Height = (float)Math.Max(val, val2) - empty.Y;
                            empty.Intersect(rect);
                        }
                        else
                        {
                            empty.Y      = rect.Y;
                            empty.Height = rect.Height;
                            empty.X      = (float)Math.Min(val, val2);
                            empty.Width  = (float)Math.Max(val, val2) - empty.X;
                            empty.Intersect(rect);
                        }
                        if (empty.Width > 0f && empty.Height > 0f)
                        {
                            graph.StartHotRegion(href, toolTip);
                            if (!axis.chartArea.Area3DStyle.Enable3D)
                            {
                                graph.StartAnimation();
                                graph.FillRectangleRel(empty, BackColor, BackHatchStyle, BackImage, BackImageMode, BackImageTransparentColor, BackImageAlign, BackGradientType, BackGradientEndColor, BorderColor, BorderWidth, BorderStyle, Color.Empty, 0, PenAlignment.Inset);
                                graph.StopAnimation();
                            }
                            else
                            {
                                Draw3DStrip(graph, empty, flag);
                            }
                            graph.EndHotRegion();
                            PaintTitle(graph, empty);
                            if (common.ProcessModeRegions && !axis.chartArea.Area3DStyle.Enable3D)
                            {
                                common.HotRegionsList.AddHotRegion(graph, empty, ToolTip, Href, MapAreaAttributes, this, ChartElementType.StripLines, string.Empty);
                            }
                        }
                    }
                }
                else if (StripWidth == 0.0 && drawLinesOnly && num > axis.GetViewMinimum() && num < axis.GetViewMaximum())
                {
                    PointF empty2 = PointF.Empty;
                    PointF empty3 = PointF.Empty;
                    if (flag)
                    {
                        empty2.X = rect.X;
                        empty2.Y = (float)axis.GetLinearPosition(num);
                        empty3.X = rect.Right;
                        empty3.Y = empty2.Y;
                    }
                    else
                    {
                        empty2.X = (float)axis.GetLinearPosition(num);
                        empty2.Y = rect.Y;
                        empty3.X = empty2.X;
                        empty3.Y = rect.Bottom;
                    }
                    graph.StartHotRegion(href, toolTip);
                    if (!axis.chartArea.Area3DStyle.Enable3D)
                    {
                        graph.DrawLineRel(BorderColor, BorderWidth, BorderStyle, empty2, empty3);
                    }
                    else
                    {
                        graph.Draw3DGridLine(axis.chartArea, borderColor, borderWidth, borderStyle, empty2, empty3, flag, axis.Common, this);
                    }
                    graph.EndHotRegion();
                    PaintTitle(graph, empty2, empty3);
                    if (common.ProcessModeRegions)
                    {
                        SizeF size = new SizeF(BorderWidth + 1, BorderWidth + 1);
                        size = graph.GetRelativeSize(size);
                        RectangleF empty4 = RectangleF.Empty;
                        if (flag)
                        {
                            empty4.X      = empty2.X;
                            empty4.Y      = empty2.Y - size.Height / 2f;
                            empty4.Width  = empty3.X - empty2.X;
                            empty4.Height = size.Height;
                        }
                        else
                        {
                            empty4.X      = empty2.X - size.Width / 2f;
                            empty4.Y      = empty2.Y;
                            empty4.Width  = size.Width;
                            empty4.Height = empty3.Y - empty2.Y;
                        }
                        common.HotRegionsList.AddHotRegion(graph, empty4, ToolTip, Href, MapAreaAttributes, this, ChartElementType.StripLines, string.Empty);
                    }
                }
                if (Interval > 0.0)
                {
                    num += axis.GetIntervalSize(num, Interval, IntervalType, series, IntervalOffset, type, forceIntIndex: false);
                }
                if (!(Interval > 0.0) || !(num <= axis.GetViewMaximum()))
                {
                    break;
                }
            }
        }
Beispiel #14
0
        internal void PaintCustom(ChartGraphics graph)
        {
            CommonElements common     = axis.Common;
            PointF         empty      = PointF.Empty;
            PointF         empty2     = PointF.Empty;
            RectangleF     rectangleF = axis.PlotAreaPosition.ToRectangleF();

            foreach (CustomLabel customLabel in axis.CustomLabels)
            {
                if ((customLabel.GridTicks & GridTicks.Gridline) != GridTicks.Gridline)
                {
                    continue;
                }
                double num = (customLabel.To + customLabel.From) / 2.0;
                if (!(num >= axis.GetViewMinimum()) || !(num <= axis.GetViewMaximum()))
                {
                    continue;
                }
                if (axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right)
                {
                    empty.X  = rectangleF.X;
                    empty2.X = rectangleF.Right;
                    empty.Y  = (float)axis.GetLinearPosition(num);
                    empty2.Y = empty.Y;
                }
                if (axis.AxisPosition == AxisPosition.Top || axis.AxisPosition == AxisPosition.Bottom)
                {
                    empty.Y  = rectangleF.Y;
                    empty2.Y = rectangleF.Bottom;
                    empty.X  = (float)axis.GetLinearPosition(num);
                    empty2.X = empty.X;
                }
                if (common.ProcessModeRegions)
                {
                    if (!axis.chartArea.Area3DStyle.Enable3D || axis.chartArea.chartAreaIsCurcular)
                    {
                        GraphicsPath graphicsPath = new GraphicsPath();
                        if (Math.Abs(empty.X - empty2.X) > Math.Abs(empty.Y - empty2.Y))
                        {
                            graphicsPath.AddLine(empty.X, empty.Y - 1f, empty2.X, empty2.Y - 1f);
                            graphicsPath.AddLine(empty2.X, empty2.Y + 1f, empty.X, empty.Y + 1f);
                            graphicsPath.CloseAllFigures();
                        }
                        else
                        {
                            graphicsPath.AddLine(empty.X - 1f, empty.Y, empty2.X - 1f, empty2.Y);
                            graphicsPath.AddLine(empty2.X + 1f, empty2.Y, empty.X + 1f, empty.Y);
                            graphicsPath.CloseAllFigures();
                        }
                        common.HotRegionsList.AddHotRegion(graphicsPath, relativePath: true, graph, ChartElementType.Gridlines, this);
                    }
                    else
                    {
                        graph.Draw3DGridLine(axis.chartArea, borderColor, borderWidth, borderStyle, empty, empty2, axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right, common, this);
                    }
                }
                if (common.ProcessModePaint)
                {
                    if (!axis.chartArea.Area3DStyle.Enable3D || axis.chartArea.chartAreaIsCurcular)
                    {
                        graph.DrawLineRel(borderColor, borderWidth, borderStyle, empty, empty2);
                    }
                    else
                    {
                        graph.Draw3DGridLine(axis.chartArea, borderColor, borderWidth, borderStyle, empty, empty2, axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right, axis.Common, this);
                    }
                }
            }
        }
Beispiel #15
0
        internal void Paint(ChartGraphics chartGraph)
        {
            if (!IsVisible())
            {
                return;
            }
            CommonElements common = chart.chartPicture.common;
            string         text   = Text;

            if (chart != null && chart.LocalizeTextHandler != null)
            {
                text = chart.LocalizeTextHandler(this, text, 0, ChartElementType.Title);
            }
            RectangleF rectangleF = Position.ToRectangleF();

            if (!Position.Auto && chart != null && chart.chartPicture != null && (rectangleF.Width == 0f || rectangleF.Height == 0f))
            {
                SizeF relative = new SizeF((rectangleF.Width == 0f) ? ((float)chart.chartPicture.Width) : rectangleF.Width, (rectangleF.Height == 0f) ? ((float)chart.chartPicture.Height) : rectangleF.Height);
                if (IsTextVertical)
                {
                    float width = relative.Width;
                    relative.Width  = relative.Height;
                    relative.Height = width;
                }
                relative = chartGraph.GetAbsoluteSize(relative);
                SizeF size = chartGraph.MeasureString(text.Replace("\\n", "\n"), Font, relative, new StringFormat(), GetTextOrientation());
                if (BackGroundIsVisible)
                {
                    size.Width  += titleBorderSpacing;
                    size.Height += titleBorderSpacing;
                }
                if (IsTextVertical)
                {
                    float width2 = size.Width;
                    size.Width  = size.Height;
                    size.Height = width2;
                }
                size = chartGraph.GetRelativeSize(size);
                if (rectangleF.Width == 0f)
                {
                    rectangleF.Width = size.Width;
                    if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight)
                    {
                        rectangleF.X -= rectangleF.Width;
                    }
                    else if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.MiddleCenter || Alignment == ContentAlignment.TopCenter)
                    {
                        rectangleF.X -= rectangleF.Width / 2f;
                    }
                }
                if (rectangleF.Height == 0f)
                {
                    rectangleF.Height = size.Height;
                    if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft)
                    {
                        rectangleF.Y -= rectangleF.Height;
                    }
                    else if (Alignment == ContentAlignment.MiddleCenter || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.MiddleRight)
                    {
                        rectangleF.Y -= rectangleF.Height / 2f;
                    }
                }
            }
            RectangleF relative2 = new RectangleF(rectangleF.Location, rectangleF.Size);

            relative2 = chartGraph.GetAbsoluteRectangle(relative2);
            if (BackGroundIsVisible && common.ProcessModePaint)
            {
                chartGraph.StartHotRegion(href, toolTip);
                chartGraph.StartAnimation();
                chartGraph.FillRectangleRel(rectangleF, BackColor, BackHatchStyle, BackImage, BackImageMode, BackImageTransparentColor, BackImageAlign, BackGradientType, BackGradientEndColor, BorderColor, BorderWidth, BorderStyle, ShadowColor, ShadowOffset, PenAlignment.Inset);
                chartGraph.StopAnimation();
                chartGraph.EndHotRegion();
            }
            else
            {
                chartGraph.StartHotRegion(href, toolTip);
                SizeF absoluteSize = chartGraph.GetAbsoluteSize(rectangleF.Size);
                SizeF size2        = chartGraph.MeasureString(text.Replace("\\n", "\n"), Font, absoluteSize, new StringFormat(), GetTextOrientation());
                size2 = chartGraph.GetRelativeSize(size2);
                RectangleF rectF = new RectangleF(rectangleF.X, rectangleF.Y, size2.Width, size2.Height);
                if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight)
                {
                    rectF.Y = rectangleF.Bottom - rectF.Height;
                }
                else if (Alignment == ContentAlignment.MiddleCenter || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.MiddleRight)
                {
                    rectF.Y = rectangleF.Y + rectangleF.Height / 2f - rectF.Height / 2f;
                }
                if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight)
                {
                    rectF.X = rectangleF.Right - rectF.Width;
                }
                else if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.MiddleCenter || Alignment == ContentAlignment.TopCenter)
                {
                    rectF.X = rectangleF.X + rectangleF.Width / 2f - rectF.Width / 2f;
                }
                if (true)
                {
                    chartGraph.FillRectangleRel(rectF, Color.FromArgb(0, Color.White), ChartHatchStyle.None, string.Empty, ChartImageWrapMode.Tile, BackImageTransparentColor, BackImageAlign, GradientType.None, BackGradientEndColor, Color.Transparent, 0, BorderStyle, Color.Transparent, 0, PenAlignment.Inset);
                }
                chartGraph.EndHotRegion();
            }
            if (BackGroundIsVisible)
            {
                relative2.Width  -= titleBorderSpacing;
                relative2.Height -= titleBorderSpacing;
                relative2.X      += (float)titleBorderSpacing / 2f;
                relative2.Y      += (float)titleBorderSpacing / 2f;
            }
            StringFormat stringFormat = new StringFormat();

            stringFormat.Alignment     = StringAlignment.Center;
            stringFormat.LineAlignment = StringAlignment.Center;
            if (Alignment == ContentAlignment.BottomCenter || Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.BottomRight)
            {
                stringFormat.LineAlignment = StringAlignment.Far;
            }
            else if (Alignment == ContentAlignment.TopCenter || Alignment == ContentAlignment.TopLeft || Alignment == ContentAlignment.TopRight)
            {
                stringFormat.LineAlignment = StringAlignment.Near;
            }
            if (Alignment == ContentAlignment.BottomLeft || Alignment == ContentAlignment.MiddleLeft || Alignment == ContentAlignment.TopLeft)
            {
                stringFormat.Alignment = StringAlignment.Near;
            }
            else if (Alignment == ContentAlignment.BottomRight || Alignment == ContentAlignment.MiddleRight || Alignment == ContentAlignment.TopRight)
            {
                stringFormat.Alignment = StringAlignment.Far;
            }
            Color     gradientColor = ChartGraphics.GetGradientColor(Color, Color.Black, 0.8);
            int       num           = 1;
            TextStyle textStyle     = Style;

            if ((textStyle == TextStyle.Default || textStyle == TextStyle.Shadow) && !BackGroundIsVisible && ShadowOffset != 0)
            {
                textStyle     = TextStyle.Shadow;
                gradientColor = ShadowColor;
                num           = ShadowOffset;
            }
            text = text.Replace("\\n", "\n");
            Matrix matrix = null;

            if (IsTextVertical)
            {
                if (GetTextOrientation() == TextOrientation.Rotated270)
                {
                    stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical);
                    matrix = chartGraph.Transform.Clone();
                    PointF empty = PointF.Empty;
                    empty.X = relative2.X + relative2.Width / 2f;
                    empty.Y = relative2.Y + relative2.Height / 2f;
                    Matrix matrix2 = chartGraph.Transform.Clone();
                    matrix2.RotateAt(180f, empty);
                    chartGraph.Transform = matrix2;
                }
                else if (GetTextOrientation() == TextOrientation.Rotated90)
                {
                    stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical);
                }
            }
            if (text.Length > 0)
            {
                chartGraph.StartAnimation();
                switch (textStyle)
                {
                case TextStyle.Default:
                    chartGraph.StartHotRegion(href, toolTip);
                    chartGraph.DrawString(text, Font, new SolidBrush(Color), relative2, stringFormat, GetTextOrientation());
                    chartGraph.EndHotRegion();
                    break;

                case TextStyle.Frame:
                {
                    GraphicsPath graphicsPath = new GraphicsPath();
                    graphicsPath.AddString(ChartGraphics.GetStackedText(text), Font.FontFamily, (int)Font.Style, Font.Size * 1.3f, relative2, stringFormat);
                    graphicsPath.CloseAllFigures();
                    chartGraph.StartHotRegion(href, toolTip);
                    chartGraph.DrawPath(new Pen(Color, 1f), graphicsPath);
                    chartGraph.EndHotRegion();
                    break;
                }

                case TextStyle.Embed:
                {
                    RectangleF rect3 = new RectangleF(relative2.Location, relative2.Size);
                    rect3.X -= 1f;
                    rect3.Y -= 1f;
                    chartGraph.DrawString(text, Font, new SolidBrush(gradientColor), rect3, stringFormat, GetTextOrientation());
                    rect3.X += 2f;
                    rect3.Y += 2f;
                    Color gradientColor3 = ChartGraphics.GetGradientColor(Color.White, Color, 0.3);
                    chartGraph.DrawString(text, Font, new SolidBrush(gradientColor3), rect3, stringFormat, GetTextOrientation());
                    chartGraph.StartHotRegion(href, toolTip);
                    chartGraph.DrawString(text, Font, new SolidBrush(Color), relative2, stringFormat, GetTextOrientation());
                    chartGraph.EndHotRegion();
                    break;
                }

                case TextStyle.Emboss:
                {
                    RectangleF rect2 = new RectangleF(relative2.Location, relative2.Size);
                    rect2.X += 1f;
                    rect2.Y += 1f;
                    chartGraph.DrawString(text, Font, new SolidBrush(gradientColor), rect2, stringFormat, GetTextOrientation());
                    rect2.X -= 2f;
                    rect2.Y -= 2f;
                    Color gradientColor2 = ChartGraphics.GetGradientColor(Color.White, Color, 0.3);
                    chartGraph.DrawString(text, Font, new SolidBrush(gradientColor2), rect2, stringFormat, GetTextOrientation());
                    chartGraph.StartHotRegion(href, toolTip);
                    chartGraph.DrawString(text, Font, new SolidBrush(Color), relative2, stringFormat, GetTextOrientation());
                    chartGraph.EndHotRegion();
                    break;
                }

                case TextStyle.Shadow:
                {
                    RectangleF rect = new RectangleF(relative2.Location, relative2.Size);
                    rect.X += num;
                    rect.Y += num;
                    chartGraph.DrawString(text, Font, new SolidBrush(gradientColor), rect, stringFormat, GetTextOrientation());
                    chartGraph.StartHotRegion(href, toolTip);
                    chartGraph.DrawString(text, Font, new SolidBrush(Color), relative2, stringFormat, GetTextOrientation());
                    chartGraph.EndHotRegion();
                    break;
                }

                default:
                    throw new InvalidOperationException(SR.ExceptionTitleTextDrawingStyleUnknown);
                }
                chartGraph.StopAnimation();
            }
            if (matrix != null)
            {
                chartGraph.Transform = matrix;
            }
            if (common.ProcessModeRegions)
            {
                common.HotRegionsList.AddHotRegion(chartGraph, rectangleF, ToolTip, Href, MapAreaAttributes, this, ChartElementType.Title, string.Empty);
            }
        }
Beispiel #16
0
 public ChartPaintEventArgs(ChartGraphics chartGraph, CommonElements common, ElementPosition position)
 {
     this.chartGraph = chartGraph;
     this.common     = common;
     this.position   = position;
 }
Beispiel #17
0
 private void InitAnimation(CommonElements common, PointF point, ChartGraphics graph, int numberOfElements, int index)
 {
 }
 internal override void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment)
 {
 }
Beispiel #19
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);
        }
Beispiel #20
0
 internal void Reset(CommonElements common, ChartArea area)
 {
     smartLabelsPositions = new ArrayList();
 }
Beispiel #21
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 #22
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 #23
0
        private void DrawGrid(ChartGraphics graph, double current, int numberOfElements, int index)
        {
            CommonElements common     = axis.Common;
            PointF         point      = PointF.Empty;
            PointF         empty      = PointF.Empty;
            PointF         empty2     = PointF.Empty;
            RectangleF     rectangleF = axis.PlotAreaPosition.ToRectangleF();

            if (axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right)
            {
                empty.X  = rectangleF.X;
                empty2.X = rectangleF.Right;
                empty.Y  = (float)axis.GetLinearPosition(current);
                empty2.Y = empty.Y;
                point    = empty;
            }
            if (axis.AxisPosition == AxisPosition.Top || axis.AxisPosition == AxisPosition.Bottom)
            {
                empty.Y  = rectangleF.Y;
                empty2.Y = rectangleF.Bottom;
                empty.X  = (float)axis.GetLinearPosition(current);
                empty2.X = empty.X;
                point    = empty2;
            }
            if (common.ProcessModeRegions)
            {
                if (axis.chartArea.Area3DStyle.Enable3D && !axis.chartArea.chartAreaIsCurcular)
                {
                    graph.Draw3DGridLine(axis.chartArea, borderColor, borderWidth, borderStyle, empty, empty2, axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right, common, this);
                }
                else if (!axis.chartArea.chartAreaIsCurcular)
                {
                    GraphicsPath graphicsPath = new GraphicsPath();
                    if (Math.Abs(empty.X - empty2.X) > Math.Abs(empty.Y - empty2.Y))
                    {
                        graphicsPath.AddLine(empty.X, empty.Y - 1f, empty2.X, empty2.Y - 1f);
                        graphicsPath.AddLine(empty2.X, empty2.Y + 1f, empty.X, empty.Y + 1f);
                        graphicsPath.CloseAllFigures();
                    }
                    else
                    {
                        graphicsPath.AddLine(empty.X - 1f, empty.Y, empty2.X - 1f, empty2.Y);
                        graphicsPath.AddLine(empty2.X + 1f, empty2.Y, empty.X + 1f, empty.Y);
                        graphicsPath.CloseAllFigures();
                    }
                    common.HotRegionsList.AddHotRegion(graphicsPath, relativePath: true, graph, ChartElementType.Gridlines, this);
                }
            }
            if (!common.ProcessModePaint)
            {
                return;
            }
            if (axis.chartArea.chartAreaIsCurcular)
            {
                InitAnimation(axis.Common, point, graph, numberOfElements, index);
                graph.StartAnimation();
                if (axis.axisType == AxisName.Y)
                {
                    axis.DrawCircularLine(this, graph, borderColor, borderWidth, borderStyle, empty.Y);
                }
                if (axis.axisType == AxisName.X)
                {
                    ICircularChartType circularChartType = axis.chartArea.GetCircularChartType();
                    if (circularChartType != null && circularChartType.RadialGridLinesSupported())
                    {
                        axis.DrawRadialLine(this, graph, borderColor, borderWidth, borderStyle, current);
                    }
                }
                graph.StopAnimation();
            }
            else if (!axis.chartArea.Area3DStyle.Enable3D || axis.chartArea.chartAreaIsCurcular)
            {
                InitAnimation(axis.Common, point, graph, numberOfElements, index);
                graph.StartAnimation();
                graph.DrawLineRel(borderColor, borderWidth, borderStyle, empty, empty2);
                graph.StopAnimation();
            }
            else
            {
                graph.Draw3DGridLine(axis.chartArea, borderColor, borderWidth, borderStyle, empty, empty2, axis.AxisPosition == AxisPosition.Left || axis.AxisPosition == AxisPosition.Right, axis.Common, this, numberOfElements, index);
            }
        }
Beispiel #24
0
 public LegendCollection(CommonElements common)
 {
     this.common = common;
 }