public void Dispose() { TextPaint?.Dispose(); LegendBoxBorderPaint?.Dispose(); LegendBoxPaint?.Dispose(); TitlePaint?.Dispose(); ChartItemFillPaint?.Dispose(); ChartItemOutlinePaint?.Dispose(); }
/// <summary> /// Vykreslení popisu grafu /// </summary> /// <param name="label"></param> internal void DrawTitle(string label) { Name = label; if (!string.IsNullOrEmpty(label)) { SKRect bounds = new SKRect(); TitlePaint.MeasureText(label, ref bounds); var x = Width / 2 - bounds.MidX; var y = -bounds.Top; _canvas.DrawText(label, x, y, TitlePaint); } }
/// <summary> /// Vykreslení osy Y /// </summary> /// <param name="yAsixs"></param> internal void DrawYAsixs(List <CMLChartYAsix> yAsixs) { foreach (var yAsix in yAsixs) { // Vykreslení osy int asixStartPointX; int asixEndPointX; if (yAsix.Location == Location.Left) { asixStartPointX = Width - (int)Math.Floor(Width * offsetX); asixEndPointX = Width - (int)Math.Floor(Width * offsetX); } else { asixStartPointX = (int)Math.Floor(Width * offsetX); asixEndPointX = (int)Math.Floor(Width * offsetX); } var asixStartPointY = (int)Math.Floor(Height * offsetYTop);; var asixEndPointY = (int)Math.Floor(Height * offsetYBottom); _canvas.DrawLine(new SKPoint(asixStartPointX, asixStartPointY), new SKPoint(asixEndPointX, asixEndPointY), AsixYPaint); if (yAsix.ZoroValueMark && yAsix.MinValue < 0) { const int separatorLength = 5; var koef = (0 - yAsix.MinValue) / (yAsix.MaxValue - yAsix.MinValue); var length = (int)Math.Floor(Height * (offsetYBottom - offsetYTop)); var zeroAsixStartPointX = Width - (int)Math.Floor(Width * offsetX) - separatorLength; var zeroAsixStartPointY = (int)Math.Floor(Height * offsetYBottom) - (int)(koef * length); var zeroAsixEndPointX = (int)Math.Floor(Width * offsetX); var zeroAsixEndPointY = zeroAsixStartPointY; DrawDashedLine(new SKPoint(zeroAsixStartPointX, zeroAsixStartPointY), new SKPoint(zeroAsixEndPointX, zeroAsixEndPointY), 5, 5); } var minIndex = 0; var maxIndex = 4; for (int i = minIndex; i <= maxIndex; i++) { const int separatorLength = 5; var koef = i * 0.25; int asixDescStartPointX; int asixDescEndPointX; if (yAsix.Location == Location.Left) { asixDescStartPointX = Width - (int)Math.Floor(Width * offsetX) - separatorLength; asixDescEndPointX = Width - (int)Math.Floor(Width * offsetX); } else { asixDescStartPointX = (int)Math.Floor(Width * offsetX); asixDescEndPointX = (int)Math.Floor(Width * offsetX) + separatorLength; } var length = (int)Math.Floor(Height * (offsetYBottom - offsetYTop)); var asixDescStartPointY = (int)Math.Floor(Height * offsetYBottom) - (int)(koef * length); var asixDescEndPointY = (int)Math.Floor(Height * offsetYBottom) - (int)(koef * length); _canvas.DrawLine(new SKPoint(asixDescStartPointX, asixDescStartPointY), new SKPoint(asixDescEndPointX, asixDescEndPointY), AsixYPaint); // Popisky var lengthDesc = yAsix.MaxValue - yAsix.MinValue; var label = (yAsix.MinValue + koef * lengthDesc).ToString("#0"); int x; int y; SKRect bounds = new SKRect(); AsixYPaint.TextSize = (i == minIndex || i == maxIndex) ? AsixYTextSizeBig : AsixYTextSize; AsixYPaint.MeasureText(label, ref bounds); if (yAsix.Location == Location.Left) { x = asixDescStartPointX - (int)(bounds.Width); y = asixDescStartPointY - (int)bounds.Top + separatorLength; } else { x = asixDescEndPointX; y = asixDescStartPointY - (int)bounds.Top + separatorLength; } _canvas.DrawText(label, x, y, AsixYPaint); } // Popiska osy if (!string.IsNullOrEmpty(yAsix.Label)) { _canvas.Save(); int x; int y; SKRect bounds = new SKRect(); TitlePaint.MeasureText(yAsix.Label, ref bounds); if (yAsix.Location == Location.Left) { x = (int)-bounds.Top; y = (Height / 2) + (int)bounds.Width / 2; _canvas.RotateDegrees(270, x, y); } else { x = Width + (int)bounds.Top;; y = (Height / 2) - (int)bounds.Width / 2; _canvas.RotateDegrees(90, x, y); } _canvas.DrawText(yAsix.Label, x, y, TitlePaint); _canvas.Restore(); } } }