protected static void DrawRectangle(IRenderContext2D renderContext, IPen2D pen, IBrush2D brush, ICoordinateCalculator<double> xcal, ICoordinateCalculator<double> ycal, float xv, float yv, float wv, float hv) { var x1 = xcal.GetCoordinate(xv); var y1 = ycal.GetCoordinate(yv); var x2 = xcal.GetCoordinate(xv + wv); var y2 = ycal.GetCoordinate(yv + hv); var pt1 = new Point(x1, y1); var pt2 = new Point(x2, y2); renderContext.FillRectangle(brush, pt1, pt2); renderContext.DrawQuad(pen, pt1, pt2); }
protected static void DrawRectangle(IRenderContext2D renderContext, IPen2D pen, IBrush2D brush, ICoordinateCalculator <double> xcal, ICoordinateCalculator <double> ycal, float xv, float yv, float wv, float hv) { var x1 = xcal.GetCoordinate(xv); var y1 = ycal.GetCoordinate(yv); var x2 = xcal.GetCoordinate(xv + wv); var y2 = ycal.GetCoordinate(yv + hv); var pt1 = new Point(x1, y1); var pt2 = new Point(x2, y2); renderContext.FillRectangle(brush, pt1, pt2); renderContext.DrawQuad(pen, pt1, pt2); }
public void DrawNodes(IRenderContext2D renderContext, ICoordinateCalculator <double> xc, ICoordinateCalculator <double> yc, Rect area, float pixSizeX, float pixSizeY) { var pen = renderContext.CreatePen(Colors.Brown, false, 1); var nodes = FindNodesWithDecimation(area, pixSizeX, pixSizeY); foreach (var node in nodes) { var p1 = new Point(xc.GetCoordinate(node.HorizontalRange.Min), yc.GetCoordinate(node.VerticalRange.Min)); var p2 = new Point(xc.GetCoordinate(node.HorizontalRange.Max), yc.GetCoordinate(node.VerticalRange.Max)); renderContext.DrawQuad(pen, p1, p2); } pen.Dispose(); }
public override void Draw(IRenderContext2D context, IEnumerable <Point> centers) { TryCasheResources(context); var markerLocations = centers.ToArray(); var prevValue = 0d; for (int i = 0; i < markerLocations.Length; ++i) { var metadata = _dataPointMetadata[_dataPointIndexes[i]] as BudgetPointMetadata; var center = markerLocations[i]; var isGain = metadata.GainLossValue >= prevValue; DrawDiamond(context, center, Width, Height, _strokePen, isGain ? _gainFillBrush : _lossFillBrush); prevValue = metadata.GainLossValue; var gainLossValue = metadata.GainLossValue + "$"; _textBlock.Text = gainLossValue; _textBlock.MeasureArrange(); var xPos = center.X - _textBlock.DesiredSize.Width / 2; xPos = xPos < 0 ? TextIndent : xPos; var marginalRightPos = context.ViewportSize.Width - _textBlock.DesiredSize.Width - TextIndent; xPos = xPos > marginalRightPos ? marginalRightPos : xPos; var yPos = center.Y; var yOffset = isGain ? -_textBlock.DesiredSize.Height - TextIndent : TextIndent; yPos += yOffset; var textRect = new Rect(xPos, yPos, _textBlock.DesiredSize.Width, _textBlock.DesiredSize.Height); context.DrawText(textRect, Stroke, TextSize, gainLossValue, FontFamily, FontWeight, FontStyle); if (metadata.IsCheckPoint) { context.DrawQuad(_strokePen, textRect.TopLeft, textRect.BottomRight); } } }