public virtual void AddMarkersPosition(CommonElements common, ChartArea area) { if (this.smartLabelsPositions.Count == 0 && area != null) { ChartTypeRegistry chartTypeRegistry = common.ChartTypeRegistry; foreach (Series item in common.DataManager.Series) { if (item.ChartArea == area.Name && item.SmartLabels.Enabled && !item.SmartLabels.MarkerOverlapping) { IChartType chartType = chartTypeRegistry.GetChartType(item.ChartTypeName); chartType.AddSmartLabelMarkerPositions(common, area, item, this.smartLabelsPositions); } } Axis[] axes = area.Axes; foreach (Axis axis in axes) { if (axis.ScaleBreakStyle.Spacing > 0.0 && axis.ScaleSegments.Count > 0) { 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 (this.smartLabelsPositions == null) { this.smartLabelsPositions = new ArrayList(); } this.smartLabelsPositions.Add(breakLinePosition); } } } } }
public override void AddMarkersPosition(CommonElements common, ChartArea area) { if (base.smartLabelsPositions.Count == 0 && common != null && common.Chart != null) { foreach (Annotation annotation in common.Chart.Annotations) { annotation.AddSmartLabelMarkerPositions(common, base.smartLabelsPositions); } } }
private double ConvertValue(object value) { if (value == null) { return(0.0); } if (value is double) { return((double)value); } if (value is float) { return((double)(float)value); } if (value is decimal) { return((double)(decimal)value); } if (value is int) { return((double)(int)value); } if (value is uint) { return((double)(uint)value); } if (value is long) { return((double)(long)value); } if (value is ulong) { return((double)(ulong)value); } if (value is byte) { return((double)(int)(byte)value); } if (value is sbyte) { return((double)(sbyte)value); } if (value is bool) { if (!(bool)value) { return(0.0); } return(1.0); } string text = ""; text = value.ToString(); return(CommonElements.ParseDouble(text)); }
public DataPoint(double xValue, string yValues) : base(null, true) { string[] array = yValues.Split(','); this.yValue = new double[array.Length]; for (int i = 0; i < array.Length; i++) { this.yValue[i] = CommonElements.ParseDouble(array[i]); } this.xValue = xValue; }
public void SetAttributes(CommonElements common, Series series) { IChartType chartType = common.ChartTypeRegistry.GetChartType(series.ChartTypeName); this.style = chartType.GetLegendImageStyle(series); this.seriesName = series.Name; this.shadowOffset = series.ShadowOffset; this.shadowColor = series.ShadowColor; bool enable3D = common.Chart.ChartAreas[series.ChartArea].Area3DStyle.Enable3D; this.SetAttributes(series, enable3D); }
public 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 flag = false; bool flag2 = this.smartLabelsPositions.Count == 0; this.AddMarkersPosition(common, area); if (flag2) { this.markersCount = this.smartLabelsPositions.Count; } if (this.IsSmartLabelCollide(common, graph, area, smartLabelsStyle, labelPosition, labelSize, markerPosition, format, labelAlignment, checkCalloutLineOverlapping) && (this.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) { this.DrawCallout(common, graph, area, smartLabelsStyle, labelPosition, labelSize, format, markerPosition, markerSize, labelAlignment); } this.AddSmartLabelPosition(graph, area, labelPosition, labelSize, format); } return(labelPosition); }
public 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 = base.GetLabelPosition(graph, position, size, format, false); bool flag = (byte)((labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? 1 : 0) != 0; if (base.checkAllCollisions) { flag = false; } foreach (RectangleF smartLabelsPosition in base.smartLabelsPositions) { if (smartLabelsPosition.IntersectsWith(labelPosition)) { if (!flag) { return(true); } flag = false; } } return(result); }
private void InitAnimation(CommonElements common, PointF point, ChartGraphics graph, int numberOfElements, int index) { }
private void DrawGrid(ChartGraphics graph, double current, int numberOfElements, int index) { CommonElements common = this.axis.Common; PointF point = PointF.Empty; PointF empty = PointF.Empty; PointF empty2 = PointF.Empty; RectangleF rectangleF = this.axis.PlotAreaPosition.ToRectangleF(); if (this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right) { empty.X = rectangleF.X; empty2.X = rectangleF.Right; empty.Y = (float)this.axis.GetLinearPosition(current); empty2.Y = empty.Y; point = empty; } if (this.axis.AxisPosition == AxisPosition.Top || this.axis.AxisPosition == AxisPosition.Bottom) { empty.Y = rectangleF.Y; empty2.Y = rectangleF.Bottom; empty.X = (float)this.axis.GetLinearPosition(current); empty2.X = empty.X; point = empty2; } if (common.ProcessModeRegions) { if (this.axis.chartArea.Area3DStyle.Enable3D && !this.axis.chartArea.chartAreaIsCurcular) { graph.Draw3DGridLine(this.axis.chartArea, this.borderColor, this.borderWidth, this.borderStyle, empty, empty2, this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right, common, this); } else if (!this.axis.chartArea.chartAreaIsCurcular) { GraphicsPath graphicsPath = new GraphicsPath(); if (Math.Abs(empty.X - empty2.X) > Math.Abs(empty.Y - empty2.Y)) { graphicsPath.AddLine(empty.X, (float)(empty.Y - 1.0), empty2.X, (float)(empty2.Y - 1.0)); graphicsPath.AddLine(empty2.X, (float)(empty2.Y + 1.0), empty.X, (float)(empty.Y + 1.0)); graphicsPath.CloseAllFigures(); } else { graphicsPath.AddLine((float)(empty.X - 1.0), empty.Y, (float)(empty2.X - 1.0), empty2.Y); graphicsPath.AddLine((float)(empty2.X + 1.0), empty2.Y, (float)(empty.X + 1.0), empty.Y); graphicsPath.CloseAllFigures(); } common.HotRegionsList.AddHotRegion(graphicsPath, true, graph, ChartElementType.Gridlines, this); } } if (common.ProcessModePaint) { if (this.axis.chartArea.chartAreaIsCurcular) { this.InitAnimation(this.axis.Common, point, graph, numberOfElements, index); graph.StartAnimation(); if (this.axis.axisType == AxisName.Y) { this.axis.DrawCircularLine(this, graph, this.borderColor, this.borderWidth, this.borderStyle, empty.Y); } if (this.axis.axisType == AxisName.X) { ICircularChartType circularChartType = this.axis.chartArea.GetCircularChartType(); if (circularChartType != null && circularChartType.RadialGridLinesSupported()) { this.axis.DrawRadialLine(this, graph, this.borderColor, this.borderWidth, this.borderStyle, current); } } graph.StopAnimation(); } else if (!this.axis.chartArea.Area3DStyle.Enable3D || this.axis.chartArea.chartAreaIsCurcular) { this.InitAnimation(this.axis.Common, point, graph, numberOfElements, index); graph.StartAnimation(); graph.DrawLineRel(this.borderColor, this.borderWidth, this.borderStyle, empty, empty2); graph.StopAnimation(); } else { graph.Draw3DGridLine(this.axis.chartArea, this.borderColor, this.borderWidth, this.borderStyle, empty, empty2, this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right, this.axis.Common, this, numberOfElements, index); } } }
public ChartAreaCollection(CommonElements common) { this.common = common; common.chartAreaCollection = this; }
public override void DrawCallout(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { }
public PointF AdjustSmartLabelPosition(CommonElements common, ChartGraphics graph, ChartArea area, SmartLabelsStyle smartLabelsStyle, PointF labelPosition, SizeF labelSize, ref StringFormat format, PointF markerPosition, SizeF markerSize, LabelAlignmentTypes labelAlignment) { return(this.AdjustSmartLabelPosition(common, graph, area, smartLabelsStyle, labelPosition, labelSize, ref format, markerPosition, markerSize, labelAlignment, false)); }
private void InitAnimation3D(CommonElements common, RectangleF position, float positionZ, float depth, Matrix3D matrix, ChartGraphics graph, Axis axis) { }
public ChartPaintEventArgs(ChartGraphics chartGraph, CommonElements common, ElementPosition position) { this.chartGraph = chartGraph; this.common = common; this.position = position; }
public 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(this.GetLabelPosition(graph, labelPosition, labelSize, format, true)); Pen pen = new Pen(smartLabelsStyle.CalloutLineColor, (float)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((float)(pen.Width + 2.0), (float)(pen.Width + 3.0), 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); }
public void Paint(ChartGraphics chartGraph) { if (this.IsVisible()) { CommonElements common = this.chart.chartPicture.common; string text = this.Text; if (this.chart != null && this.chart.LocalizeTextHandler != null) { text = this.chart.LocalizeTextHandler(this, text, 0, ChartElementType.Title); } RectangleF rectangleF = this.Position.ToRectangleF(); if (!this.Position.Auto && this.chart != null && this.chart.chartPicture != null && (rectangleF.Width == 0.0 || rectangleF.Height == 0.0)) { SizeF sizeF = new SizeF((rectangleF.Width == 0.0) ? ((float)this.chart.chartPicture.Width) : rectangleF.Width, (rectangleF.Height == 0.0) ? ((float)this.chart.chartPicture.Height) : rectangleF.Height); if (this.IsTextVertical) { float width = sizeF.Width; sizeF.Width = sizeF.Height; sizeF.Height = width; } sizeF = chartGraph.GetAbsoluteSize(sizeF); SizeF size = chartGraph.MeasureString(text.Replace("\\n", "\n"), this.Font, sizeF, new StringFormat(), this.GetTextOrientation()); if (this.BackGroundIsVisible) { size.Width += (float)this.titleBorderSpacing; size.Height += (float)this.titleBorderSpacing; } if (this.IsTextVertical) { float width2 = size.Width; size.Width = size.Height; size.Height = width2; } size = chartGraph.GetRelativeSize(size); if (rectangleF.Width == 0.0) { rectangleF.Width = size.Width; if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight) { rectangleF.X -= rectangleF.Width; } else if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.TopCenter) { rectangleF.X -= (float)(rectangleF.Width / 2.0); } } if (rectangleF.Height == 0.0) { rectangleF.Height = size.Height; if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft) { rectangleF.Y -= rectangleF.Height; } else if (this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.MiddleRight) { rectangleF.Y -= (float)(rectangleF.Height / 2.0); } } } RectangleF rectangleF2 = new RectangleF(rectangleF.Location, rectangleF.Size); rectangleF2 = chartGraph.GetAbsoluteRectangle(rectangleF2); if (this.BackGroundIsVisible && common.ProcessModePaint) { chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.StartAnimation(); chartGraph.FillRectangleRel(rectangleF, this.BackColor, this.BackHatchStyle, this.BackImage, this.BackImageMode, this.BackImageTransparentColor, this.BackImageAlign, this.BackGradientType, this.BackGradientEndColor, this.BorderColor, this.BorderWidth, this.BorderStyle, this.ShadowColor, this.ShadowOffset, PenAlignment.Inset); chartGraph.StopAnimation(); chartGraph.EndHotRegion(); } else { chartGraph.StartHotRegion(this.href, this.toolTip); SizeF absoluteSize = chartGraph.GetAbsoluteSize(rectangleF.Size); SizeF size2 = chartGraph.MeasureString(text.Replace("\\n", "\n"), this.Font, absoluteSize, new StringFormat(), this.GetTextOrientation()); size2 = chartGraph.GetRelativeSize(size2); RectangleF rectF = new RectangleF(rectangleF.X, rectangleF.Y, size2.Width, size2.Height); if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.BottomRight) { rectF.Y = rectangleF.Bottom - rectF.Height; } else if (this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.MiddleRight) { rectF.Y = (float)(rectangleF.Y + rectangleF.Height / 2.0 - rectF.Height / 2.0); } if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight) { rectF.X = rectangleF.Right - rectF.Width; } else if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.MiddleCenter || this.Alignment == ContentAlignment.TopCenter) { rectF.X = (float)(rectangleF.X + rectangleF.Width / 2.0 - rectF.Width / 2.0); } if (true) { chartGraph.FillRectangleRel(rectF, Color.FromArgb(0, Color.White), ChartHatchStyle.None, string.Empty, ChartImageWrapMode.Tile, this.BackImageTransparentColor, this.BackImageAlign, GradientType.None, this.BackGradientEndColor, Color.Transparent, 0, this.BorderStyle, Color.Transparent, 0, PenAlignment.Inset); } chartGraph.EndHotRegion(); } if (this.BackGroundIsVisible) { rectangleF2.Width -= (float)this.titleBorderSpacing; rectangleF2.Height -= (float)this.titleBorderSpacing; rectangleF2.X += (float)((float)this.titleBorderSpacing / 2.0); rectangleF2.Y += (float)((float)this.titleBorderSpacing / 2.0); } StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; if (this.Alignment == ContentAlignment.BottomCenter || this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.BottomRight) { stringFormat.LineAlignment = StringAlignment.Far; } else if (this.Alignment == ContentAlignment.TopCenter || this.Alignment == ContentAlignment.TopLeft || this.Alignment == ContentAlignment.TopRight) { stringFormat.LineAlignment = StringAlignment.Near; } if (this.Alignment == ContentAlignment.BottomLeft || this.Alignment == ContentAlignment.MiddleLeft || this.Alignment == ContentAlignment.TopLeft) { stringFormat.Alignment = StringAlignment.Near; } else if (this.Alignment == ContentAlignment.BottomRight || this.Alignment == ContentAlignment.MiddleRight || this.Alignment == ContentAlignment.TopRight) { stringFormat.Alignment = StringAlignment.Far; } Color gradientColor = ChartGraphics.GetGradientColor(this.Color, Color.Black, 0.8); int num = 1; TextStyle textStyle = this.Style; if ((textStyle == TextStyle.Default || textStyle == TextStyle.Shadow) && !this.BackGroundIsVisible && this.ShadowOffset != 0) { textStyle = TextStyle.Shadow; gradientColor = this.ShadowColor; num = this.ShadowOffset; } text = text.Replace("\\n", "\n"); Matrix matrix = null; if (this.IsTextVertical) { if (this.GetTextOrientation() == TextOrientation.Rotated270) { stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical); matrix = chartGraph.Transform.Clone(); PointF empty = PointF.Empty; empty.X = (float)(rectangleF2.X + rectangleF2.Width / 2.0); empty.Y = (float)(rectangleF2.Y + rectangleF2.Height / 2.0); Matrix matrix2 = chartGraph.Transform.Clone(); matrix2.RotateAt(180f, empty); chartGraph.Transform = matrix2; } else if (this.GetTextOrientation() == TextOrientation.Rotated90) { stringFormat.FormatFlags |= (StringFormatFlags.DirectionRightToLeft | StringFormatFlags.DirectionVertical); } } if (text.Length > 0) { chartGraph.StartAnimation(); switch (textStyle) { case TextStyle.Default: chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation()); chartGraph.EndHotRegion(); break; case TextStyle.Frame: { GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddString(ChartGraphics.GetStackedText(text), this.Font.FontFamily, (int)this.Font.Style, (float)(this.Font.Size * 1.2999999523162842), rectangleF2, stringFormat); graphicsPath.CloseAllFigures(); chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.DrawPath(new Pen(this.Color, 1f), graphicsPath); chartGraph.EndHotRegion(); break; } case TextStyle.Embed: { RectangleF rect3 = new RectangleF(rectangleF2.Location, rectangleF2.Size); rect3.X -= 1f; rect3.Y -= 1f; chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect3, stringFormat, this.GetTextOrientation()); rect3.X += 2f; rect3.Y += 2f; Color gradientColor3 = ChartGraphics.GetGradientColor(Color.White, this.Color, 0.3); chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor3), rect3, stringFormat, this.GetTextOrientation()); chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation()); chartGraph.EndHotRegion(); break; } case TextStyle.Emboss: { RectangleF rect2 = new RectangleF(rectangleF2.Location, rectangleF2.Size); rect2.X += 1f; rect2.Y += 1f; chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect2, stringFormat, this.GetTextOrientation()); rect2.X -= 2f; rect2.Y -= 2f; Color gradientColor2 = ChartGraphics.GetGradientColor(Color.White, this.Color, 0.3); chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor2), rect2, stringFormat, this.GetTextOrientation()); chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.GetTextOrientation()); chartGraph.EndHotRegion(); break; } case TextStyle.Shadow: { RectangleF rect = new RectangleF(rectangleF2.Location, rectangleF2.Size); rect.X += (float)num; rect.Y += (float)num; chartGraph.DrawString(text, this.Font, new SolidBrush(gradientColor), rect, stringFormat, this.GetTextOrientation()); chartGraph.StartHotRegion(this.href, this.toolTip); chartGraph.DrawString(text, this.Font, new SolidBrush(this.Color), rectangleF2, stringFormat, this.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, this.ToolTip, this.Href, this.MapAreaAttributes, this, ChartElementType.Title, string.Empty); } } }
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((float)(markerSize.Width + num * (relativeSize.Width * 2.0)), (float)(markerSize.Height + num * (relativeSize.Height * 2.0))); for (i = 0; i < array.Length; i++) { if ((array[i] != LabelAlignmentTypes.Center || num == num3) && (smartLabelsStyle.MovingDirection & array[i]) == array[i]) { pointF = this.CalculatePosition(array[i], markerPosition, sizeF, labelSize, ref format); if (!this.IsSmartLabelCollide(common, null, area, smartLabelsStyle, pointF, labelSize, markerPosition, format, array[i], checkCalloutLineOverlapping)) { flag2 = true; flag = ((byte)((num != 0.0) ? 1 : 0) != 0); break; } } } num += num2; } if (flag2) { markerSize = sizeF; labelPosition = pointF; labelAlignment = array[i]; } if (!flag2 && smartLabelsStyle.HideOverlapped) { labelPosition = PointF.Empty; } if (flag && flag2) { return(true); } return(false); }
public void Reset(CommonElements common, ChartArea area) { this.smartLabelsPositions = new ArrayList(); }
public void PaintCustom(ChartGraphics graph) { CommonElements common = this.axis.Common; PointF empty = PointF.Empty; PointF empty2 = PointF.Empty; RectangleF rectangleF = this.axis.PlotAreaPosition.ToRectangleF(); foreach (CustomLabel customLabel in this.axis.CustomLabels) { if ((customLabel.GridTicks & GridTicks.Gridline) == GridTicks.Gridline) { double num = (customLabel.To + customLabel.From) / 2.0; if (num >= this.axis.GetViewMinimum() && num <= this.axis.GetViewMaximum()) { if (this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right) { empty.X = rectangleF.X; empty2.X = rectangleF.Right; empty.Y = (float)this.axis.GetLinearPosition(num); empty2.Y = empty.Y; } if (this.axis.AxisPosition == AxisPosition.Top || this.axis.AxisPosition == AxisPosition.Bottom) { empty.Y = rectangleF.Y; empty2.Y = rectangleF.Bottom; empty.X = (float)this.axis.GetLinearPosition(num); empty2.X = empty.X; } if (common.ProcessModeRegions) { if (!this.axis.chartArea.Area3DStyle.Enable3D || this.axis.chartArea.chartAreaIsCurcular) { GraphicsPath graphicsPath = new GraphicsPath(); if (Math.Abs(empty.X - empty2.X) > Math.Abs(empty.Y - empty2.Y)) { graphicsPath.AddLine(empty.X, (float)(empty.Y - 1.0), empty2.X, (float)(empty2.Y - 1.0)); graphicsPath.AddLine(empty2.X, (float)(empty2.Y + 1.0), empty.X, (float)(empty.Y + 1.0)); graphicsPath.CloseAllFigures(); } else { graphicsPath.AddLine((float)(empty.X - 1.0), empty.Y, (float)(empty2.X - 1.0), empty2.Y); graphicsPath.AddLine((float)(empty2.X + 1.0), empty2.Y, (float)(empty.X + 1.0), empty.Y); graphicsPath.CloseAllFigures(); } common.HotRegionsList.AddHotRegion(graphicsPath, true, graph, ChartElementType.Gridlines, this); } else { graph.Draw3DGridLine(this.axis.chartArea, this.borderColor, this.borderWidth, this.borderStyle, empty, empty2, this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right, common, this); } } if (common.ProcessModePaint) { if (!this.axis.chartArea.Area3DStyle.Enable3D || this.axis.chartArea.chartAreaIsCurcular) { graph.DrawLineRel(this.borderColor, this.borderWidth, this.borderStyle, empty, empty2); } else { graph.Draw3DGridLine(this.axis.chartArea, this.borderColor, this.borderWidth, this.borderStyle, empty, empty2, this.axis.AxisPosition == AxisPosition.Left || this.axis.AxisPosition == AxisPosition.Right, this.axis.Common, this); } } } } } }
public void SetValueY(params object[] yValue) { if (yValue.Length != 0 && (base.series == null || yValue.Length <= base.series.YValuesPerPoint)) { for (int i = 0; i < yValue.Length; i++) { if (yValue[i] == null || yValue[i] is DBNull) { yValue[i] = 0.0; if (i == 0) { this.Empty = true; } } } Type type = yValue[0].GetType(); if (base.series != null) { base.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 (base.series != null && base.series.chart == null && base.series.serviceContainer != null) { base.series.chart = (Chart)base.series.serviceContainer.GetService(typeof(Chart)); } if (base.series != null && base.series.chart != null && base.series.chart.chartPicture.SuppressExceptions) { this.Empty = true; for (int k = 0; k < yValue.Length; k++) { yValue[k] = 0.0; } goto end_IL_00ee; } throw new ArgumentException(SR.ExceptionDataPointYValueStringFormat); end_IL_00ee :; } } 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] = this.ConvertValue(yValue[m]); } } if (base.series != null) { for (int n = 0; n < yValue.Length; n++) { if (yValue[n] == null || (yValue[n] is double && (double)yValue[n] == 0.0)) { if (base.series.YValueType == ChartValueTypes.Date) { this.yValue[n] = Math.Floor(this.yValue[n]); } else if (base.series.YValueType == ChartValueTypes.Time) { this.yValue[n] = this.xValue - Math.Floor(this.yValue[n]); } } else if (base.series.YValueType == ChartValueTypes.Date) { DateTime dateTime = (!(yValue[n] is DateTime)) ? ((!(yValue[n] is double)) ? Convert.ToDateTime(yValue[n], CultureInfo.InvariantCulture) : DateTime.FromOADate((double)yValue[n])) : ((DateTime)yValue[n]); DateTime dateTime2 = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, 0, 0, 0, 0); this.yValue[n] = dateTime2.ToOADate(); } else if (base.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(); } } } return; } throw new ArgumentOutOfRangeException("yValue", SR.ExceptionDataPointYValuesSettingCountMismatch(base.series.YValuesPerPoint.ToString(CultureInfo.InvariantCulture))); }
public void Paint(ChartGraphics graph, CommonElements common, bool drawLinesOnly) { if (!this.axis.chartArea.chartAreaIsCurcular) { RectangleF rect = this.axis.chartArea.PlotAreaPosition.ToRectangleF(); bool flag = true; if (this.axis.AxisPosition == AxisPosition.Bottom || this.axis.AxisPosition == AxisPosition.Top) { flag = false; } Series series = null; if (this.axis.axisType == AxisName.X || this.axis.axisType == AxisName.X2) { ArrayList xAxesSeries = this.axis.chartArea.GetXAxesSeries((AxisType)((this.axis.axisType != 0) ? 1 : 0), this.axis.SubAxisName); if (xAxesSeries.Count > 0) { series = this.axis.Common.DataManager.Series[xAxesSeries[0]]; if (series != null && !series.XValueIndexed) { series = null; } } } double num = this.axis.GetViewMinimum(); if (!this.axis.chartArea.chartAreaIsCurcular || this.axis.axisType == AxisName.Y || this.axis.axisType == AxisName.Y2) { double num2 = this.Interval; if (this.interlaced) { num2 /= 2.0; } num = this.axis.AlignIntervalStart(num, num2, this.IntervalType, series); } if (this.Interval != 0.0 && (this.axis.GetViewMaximum() - this.axis.GetViewMinimum()) / this.axis.GetIntervalSize(num, this.interval, this.intervalType, series, 0.0, DateTimeIntervalType.Number, false) > 10000.0) { return; } DateTimeIntervalType type = (this.IntervalOffsetType == DateTimeIntervalType.Auto) ? this.IntervalType : this.IntervalOffsetType; if (this.Interval == 0.0) { num = this.IntervalOffset; } else if (this.IntervalOffset > 0.0) { num += this.axis.GetIntervalSize(num, this.IntervalOffset, type, series, 0.0, DateTimeIntervalType.Number, false); } else if (this.IntervalOffset < 0.0) { num -= this.axis.GetIntervalSize(num, 0.0 - this.IntervalOffset, type, series, 0.0, DateTimeIntervalType.Number, false); } int num3 = 0; while (num3++ <= 10000) { if (this.StripWidth > 0.0 && !drawLinesOnly) { double num5 = num + this.axis.GetIntervalSize(num, this.StripWidth, this.StripWidthType, series, this.IntervalOffset, type, false); if (num5 > this.axis.GetViewMinimum() && num < this.axis.GetViewMaximum()) { RectangleF empty = RectangleF.Empty; double val = (double)(float)this.axis.GetLinearPosition(num); double val2 = (double)(float)this.axis.GetLinearPosition(num5); 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 > 0.0 && empty.Height > 0.0) { graph.StartHotRegion(this.href, this.toolTip); if (!this.axis.chartArea.Area3DStyle.Enable3D) { graph.StartAnimation(); graph.FillRectangleRel(empty, this.BackColor, this.BackHatchStyle, this.BackImage, this.BackImageMode, this.BackImageTransparentColor, this.BackImageAlign, this.BackGradientType, this.BackGradientEndColor, this.BorderColor, this.BorderWidth, this.BorderStyle, Color.Empty, 0, PenAlignment.Inset); graph.StopAnimation(); } else { this.Draw3DStrip(graph, empty, flag); } graph.EndHotRegion(); this.PaintTitle(graph, empty); if (common.ProcessModeRegions && !this.axis.chartArea.Area3DStyle.Enable3D) { common.HotRegionsList.AddHotRegion(graph, empty, this.ToolTip, this.Href, this.MapAreaAttributes, this, ChartElementType.StripLines, string.Empty); } } } } else if (this.StripWidth == 0.0 && drawLinesOnly && num > this.axis.GetViewMinimum() && num < this.axis.GetViewMaximum()) { PointF empty2 = PointF.Empty; PointF empty3 = PointF.Empty; if (flag) { empty2.X = rect.X; empty2.Y = (float)this.axis.GetLinearPosition(num); empty3.X = rect.Right; empty3.Y = empty2.Y; } else { empty2.X = (float)this.axis.GetLinearPosition(num); empty2.Y = rect.Y; empty3.X = empty2.X; empty3.Y = rect.Bottom; } graph.StartHotRegion(this.href, this.toolTip); if (!this.axis.chartArea.Area3DStyle.Enable3D) { graph.DrawLineRel(this.BorderColor, this.BorderWidth, this.BorderStyle, empty2, empty3); } else { graph.Draw3DGridLine(this.axis.chartArea, this.borderColor, this.borderWidth, this.borderStyle, empty2, empty3, flag, this.axis.Common, this); } graph.EndHotRegion(); this.PaintTitle(graph, empty2, empty3); if (common.ProcessModeRegions) { SizeF size = new SizeF((float)(this.BorderWidth + 1), (float)(this.BorderWidth + 1)); size = graph.GetRelativeSize(size); RectangleF empty4 = RectangleF.Empty; if (flag) { empty4.X = empty2.X; empty4.Y = (float)(empty2.Y - size.Height / 2.0); empty4.Width = empty3.X - empty2.X; empty4.Height = size.Height; } else { empty4.X = (float)(empty2.X - size.Width / 2.0); empty4.Y = empty2.Y; empty4.Width = size.Width; empty4.Height = empty3.Y - empty2.Y; } common.HotRegionsList.AddHotRegion(graph, empty4, this.ToolTip, this.Href, this.MapAreaAttributes, this, ChartElementType.StripLines, string.Empty); } } if (this.Interval > 0.0) { num += this.axis.GetIntervalSize(num, this.Interval, this.IntervalType, series, this.IntervalOffset, type, false); } if (!(this.Interval > 0.0)) { break; } if (!(num <= this.axis.GetViewMaximum())) { break; } } } }
public HotRegionsList(CommonElements common) { this.common = common; }
public LegendCollection(CommonElements common) { this.common = common; }
public 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 = this.GetLabelPosition(graph, position, size, format, false); if (labelPosition.X < 0.0 || labelPosition.Y < 0.0 || labelPosition.Bottom > 100.0 || labelPosition.Right > 100.0) { 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((float)(labelPosition.X + labelPosition.Width / 2.0), (float)(labelPosition.Y + labelPosition.Height / 2.0)); 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((float)(labelPosition.X + labelPosition.Width / 2.0), (float)(labelPosition.Y + labelPosition.Height / 2.0)); if (!area.PlotAreaPosition.ToRectangleF().Contains(pt)) { flag = true; } } else if (smartLabelsStyle.AllowOutsidePlotArea == LabelOutsidePlotAreaStyle.No && !area.PlotAreaPosition.ToRectangleF().Contains(labelPosition)) { flag = true; } } bool flag2 = (byte)((labelAlignment == LabelAlignmentTypes.Center && !smartLabelsStyle.MarkerOverlapping) ? 1 : 0) != 0; if (this.checkAllCollisions) { flag2 = false; } if (!flag && this.smartLabelsPositions != null) { int num = -1; { foreach (RectangleF smartLabelsPosition in this.smartLabelsPositions) { num++; bool flag3 = smartLabelsPosition.IntersectsWith(labelPosition); if (!flag3 && checkCalloutLineOverlapping && num >= this.markersCount) { PointF point2 = new PointF((float)(labelPosition.X + labelPosition.Width / 2.0), (float)(labelPosition.Y + labelPosition.Height / 2.0)); if (this.LineIntersectRectangle(smartLabelsPosition, markerPosition, point2)) { flag3 = true; } } if (flag3) { if (!flag2) { return(true); } flag2 = false; } } return(flag); } } return(flag); }