protected override void DrawInternal(IRenderContext2D context, IEnumerable<Point> centers, IPen2D pen, IBrush2D brush) { double halfWidth = Width / 2; double halfHeight = Height / 2; foreach (var center in centers) { double top = center.Y - halfHeight; double bottom = center.Y + halfHeight; double left = center.X - halfWidth; double right = center.X + halfWidth; // x0 // //x1 x2 var points = new[] { new Point(right,top), new Point(right,bottom), new Point(left,bottom), new Point(right,top) }; context.FillPolygon(brush, points); context.DrawLines(pen, points); } }
protected override void DrawInternal(IRenderContext2D context, IEnumerable<Point> centers, IPen2D pen, IBrush2D brush) { float width2 = (float)(Width * 0.5); float height2 = (float)(Height * 0.5); foreach (var center in centers) { double top = center.Y - height2; double bottom = center.Y + height2; double left = center.X - width2; double right = center.X + width2; var diamondPoints = new[] { // Points drawn like this: // // x0 (x4 in same location as x0) // // x3 x1 // // x2 new Point(center.X, top), // x0 new Point(right, center.Y), // x1 new Point(center.X, bottom), // x2 new Point(left, center.Y), // x3 new Point(center.X, top), // x4 == x0 }; context.FillPolygon(brush, diamondPoints); context.DrawLines(pen, diamondPoints); } }
public override void BeginBatch(IRenderContext2D context, Color?strokeColor, Color?fillColor) { _dataPointMetadata = _dataPointMetadata ?? RenderableSeries.DataSeries.Metadata; _dataPointIndexes = new List <int>(); base.BeginBatch(context, strokeColor, fillColor); }
protected override void RenderToCache(IRenderContext2D context, IPen2D strokePen, IBrush2D fillBrush) { var offset = 2d; var polygon = new Point[] { new Point(Width / 2, 0), new Point(Width / 2 + offset, Height / 2 - offset), new Point(Width, Height / 2), new Point(Width / 2 + offset, Height / 2 + offset), new Point(Width / 2, Height), new Point(Width / 2 - offset, Height / 2 + offset), new Point(0, Height / 2), new Point(Width / 2 - offset, Height / 2 - offset), new Point(Width / 2, 0) }; context.FillPolygon(fillBrush, polygon); context.DrawLines(strokePen, polygon); }
public override void Update(IRenderContext2D context) { base.Update(context); if (bitmapChanged) { LoadBitmap(context, ImageStream); bitmapChanged = false; } }
protected override void OnRender(IRenderContext2D context) { if (Background != null) { context.DeviceContext.FillRectangle(LayoutBound, Background); } UpdateTextLayout(); context.DeviceContext.DrawTextLayout(new Vector2(LayoutBound.Left, LayoutBound.Top), textLayout, Foreground, DrawingOptions); }
/// <summary> /// Render2s the d. /// </summary> /// <param name="context">The context.</param> /// <param name="renderables">The renderables.</param> /// <param name="parameter">The parameter.</param> public virtual void RenderScene2D(IRenderContext2D context, List <SceneNode2D> renderables, ref RenderParameter2D parameter) { int count = renderables.Count; for (int i = 0; i < count; ++i) { renderables[i].Render(context); } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance CustomDraw(renderContext, renderPassData); }
public override void MoveTo(IRenderContext2D context, double x, double y, int index) { if (IsInBounds(x, y)) { _dataPointIndexes.Add(index); } base.MoveTo(context, x, y, index); }
protected override void OnUpdate(IRenderContext2D context) { base.OnUpdate(context); if (strokeChanged) { (SceneNode as BorderNode2D).BorderBrush = BorderBrush.ToD2DBrush(context.DeviceContext); strokeChanged = false; } }
protected override void DrawInternal(IRenderContext2D context, double x, double y, IPen2D pen, IBrush2D brush) { List<Point> lst = new List<Point>(); lst.Add(new Point { X = x, Y = y }); DrawInternal(context, lst, pen, brush); }
/// <summary> /// <para>Renders the element in the specified context. To override Render, please override <see cref="OnRender"/></para> /// <para>Uses <see cref="CanRender"/> to call OnRender or not. </para> /// </summary> /// <param name="context">The context.</param> public void Render(IRenderContext2D context) { if (!IsRenderable) { return; } if (IsTransformDirty) { RelativeMatrix = Matrix3x2.Translation(-RenderSize * RenderTransformOrigin) * ModelMatrix * Matrix3x2.Translation(RenderSize * RenderTransformOrigin) * LayoutTranslate; TotalModelMatrix = RelativeMatrix * ParentMatrix; IsTransformDirty = false; InvalidateVisual(); } LayoutBoundWithTransform = LayoutBound.Translate(TotalModelMatrix.TranslationVector); #if DISABLEBITMAPCACHE IsBitmapCacheValid = false; #else EnsureBitmapCache(context, new Size2((int)Math.Ceiling(LayoutClipBound.Width), (int)Math.Ceiling(LayoutClipBound.Height)), context.DeviceContext.MaximumBitmapSize); #endif if (EnableBitmapCache && IsBitmapCacheValid) { if (IsVisualDirty) { #if DEBUGDRAWING Debug.WriteLine("Redraw bitmap cache"); #endif context.PushRenderTarget(bitmapCache, true); context.DeviceContext.Transform = Matrix3x2.Identity; context.PushRelativeTransform(Matrix3x2.Identity); RenderCore.Transform = context.RelativeTransform; OnRender(context); context.PopRelativeTransform(); context.PopRenderTarget(); IsVisualDirty = false; } if (context.HasTarget) { context.DeviceContext.Transform = context.RelativeTransform * RelativeMatrix; context.DeviceContext.DrawImage(bitmapCache, new Vector2(0, 0), LayoutClipBound, InterpolationMode.Linear, global::SharpDX.Direct2D1.CompositeMode.SourceOver); } } else if (context.HasTarget) { context.PushRelativeTransform(context.RelativeTransform * RelativeMatrix); RenderCore.Transform = context.RelativeTransform; OnRender(context); context.PopRelativeTransform(); IsVisualDirty = false; } }
protected override void OnRender(IRenderContext2D context) { if (FillBrush != null) { context.DeviceContext.FillRectangle(LayoutBound, FillBrush); } if (StrokeBrush != null && StrokeStyle != null) { context.DeviceContext.DrawRectangle(LayoutBound, StrokeBrush, StrokeWidth, StrokeStyle); } }
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); }
/// <summary> /// Draws the series using the <see cref="IRenderContext2D" /> and the <see cref="IRenderPassData" /> passed in /// </summary> /// <param name="renderContext">The render context. This is a graphics object which has methods to draw lines, quads and polygons to the screen</param> /// <param name="renderPassData">The render pass data. Contains a resampled /// <see cref="IPointSeries" />, the /// <see cref="IndexRange" /> of points on the screen /// and the current YAxis and XAxis /// <see cref="ICoordinateCalculator{T}" /> to convert data-points to screen points</param> protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Get the data from RenderPassData. See CustomRenderableSeries article which describes PointSeries relationship to DataSeries if (renderPassData.PointSeries.Count == 0) { return; } // Convert to Spline Series _splineSeries = ComputeSplineSeries(renderPassData.PointSeries, IsSplineEnabled, UpSampleFactor); // Get the coordinates of the first dataPoint var point = GetCoordinatesFor(_splineSeries[0].X, _splineSeries[0].Y); // Create a pen to draw the spline line. Make sure you dispose it! using (var linePen = renderContext.CreatePen(this.Stroke, this.AntiAliasing, this.StrokeThickness)) { // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance using (var lineDrawingContext = renderContext.BeginLine(linePen, point.X, point.Y)) { for (int i = 1; i < _splineSeries.Count; i++) { point = GetCoordinatesFor(_splineSeries[i].X, _splineSeries[i].Y); lineDrawingContext.MoveTo(point.X, point.Y); } } } // Get the optional PointMarker to draw at original points var pointMarker = this.GetPointMarker(); if (pointMarker != null) { var originalPointSeries = renderPassData.PointSeries; pointMarker.BeginBatch(renderContext, pointMarker.Stroke, pointMarker.Fill); // Iterate over points and draw the point marker for (int i = 0; i < originalPointSeries.Count; i++) { point = GetCoordinatesFor(originalPointSeries[i].X, originalPointSeries[i].Y); pointMarker.MoveTo(renderContext, point.X, point.Y, originalPointSeries.Indexes[i]); } pointMarker.EndBatch(renderContext); } }
/// <summary> /// Renders the bitmap cache to a render target only. /// </summary> /// <param name="context">The context.</param> public void RenderBitmapCache(IRenderContext2D context) { if (IsRenderable && EnableBitmapCache && IsBitmapCacheValid && !IsVisualDirty && context.HasTarget) { context.DeviceContext.Transform = RelativeMatrix; context.DeviceContext.DrawImage(bitmapCache, new Vector2(0, 0), new RectangleF(0, 0, RenderSize.X, RenderSize.Y), InterpolationMode.Linear, global::SharpDX.Direct2D1.CompositeMode.SourceOver); } else { Render(context); } }
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(); }
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); }
/// <summary> /// Called when [render]. /// </summary> /// <param name="context">The context.</param> protected override void OnRender(IRenderContext2D context) { ellipse.Point = LayoutBound.Center; ellipse.RadiusX = LayoutBound.Width / 2; ellipse.RadiusY = LayoutBound.Height / 2; if (FillBrush != null) { context.DeviceContext.FillEllipse(ellipse, FillBrush); } if (StrokeBrush != null && StrokeStyle != null) { context.DeviceContext.DrawEllipse(ellipse, StrokeBrush, StrokeWidth, StrokeStyle); } }
protected override void OnUpdate(IRenderContext2D context) { base.OnUpdate(context); if (fillChanged) { (SceneNode as ShapeNode2D).Fill = Fill.ToD2DBrush(context.DeviceContext); fillChanged = false; } if (strokeChanged) { (SceneNode as ShapeNode2D).Stroke = Stroke.ToD2DBrush(context.DeviceContext); strokeChanged = false; } }
protected virtual Bitmap OnLoadImage(IRenderContext2D context, Stream stream) { stream.Position = 0; using (var decoder = new BitmapDecoder(context.DeviceResources.WICImgFactory, stream, DecodeOptions.CacheOnLoad)) { using (var frame = decoder.GetFrame(0)) { using (var converter = new FormatConverter(context.DeviceResources.WICImgFactory)) { converter.Initialize(frame, global::SharpDX.WIC.PixelFormat.Format32bppPBGRA); return(Bitmap1.FromWicBitmap(context.DeviceContext, converter)); } } } }
protected override void OnUpdate(IRenderContext2D context) { base.OnUpdate(context); if (foregroundChanged) { (SceneNode as FrameStatisticsNode2D).Foreground = Foreground != null?Foreground.ToD2DBrush(context.DeviceContext) : null; foregroundChanged = false; } if (backgroundChanged) { (SceneNode as FrameStatisticsNode2D).Background = Background != null?Background.ToD2DBrush(context.DeviceContext) : null; backgroundChanged = false; } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Do the drawing for our timeline here // // Input data is type XyzPointSeries so must be cast var inputData = renderPassData.PointSeries as XyzPointSeries; // Get X,Y axis calculators var xCalc = renderPassData.XCoordinateCalculator; var yCalc = renderPassData.YCoordinateCalculator; // Compute some constants double yMid = YOffset; double halfHeight = Height * 0.5; // Iterate over the data for (int i = 0; i < inputData.Count; i++) { // Now compute the bounds of the box to draw for one data-points // XStart = X, XEnd = XStart + Y (we use Y for the length of the box) // YTop, YBottom defined by Height + YOffset properties double xStartCoord = xCalc.GetCoordinate(inputData.XValues[i]); double xEndCoord = xStartCoord + xCalc.GetCoordinate(inputData.YValues[i]); double yTop = yCalc.GetCoordinate(yMid + halfHeight); double yBottom = yCalc.GetCoordinate(yMid - halfHeight); // Get the color for this block int iColor = (int)inputData.ZPoints[i]; Color fill = iColor.ToColor(); // Brush creation can be expensive, cache brushes keyed on int color if you find this using (var scichartBrush = renderContext.CreateBrush(fill)) { // Draw a rectangle renderContext.FillRectangle(scichartBrush, new Point(xStartCoord, yBottom), new Point(xEndCoord, yTop)); // NOTE: // You can draw fill, stroke, and fills can be linear gradient brushes if you want. // Extra data can be passed through the Metadata parameter in XyzDataSeries } } }
/// <summary> /// Called when [render]. /// </summary> /// <param name="context">The context.</param> protected override void OnRender(IRenderContext2D context) { var str = statistics.GetDetailString(); if (str != previousStr) { previousStr = str; RemoveAndDispose(ref textLayout); textLayout = Collect(new TextLayout(factory, str, format, float.MaxValue, float.MaxValue)); } var metrices = textLayout.Metrics; renderBound.Width = Math.Max(metrices.Width, renderBound.Width); renderBound.Height = metrices.Height; context.DeviceContext.Transform = Matrix3x2.Translation((float)context.ActualWidth - renderBound.Width, 0); context.DeviceContext.FillRectangle(renderBound, background); context.DeviceContext.DrawTextLayout(Vector2.Zero, textLayout, foreground); }
public override void Update(IRenderContext2D context) { base.Update(context); if (strokeStyleChanged) { (RenderCore as BorderRenderCore2D).StrokeStyle = new StrokeStyle(context.DeviceResources.Factory2D, new StrokeStyleProperties() { DashCap = StrokeDashCap, StartCap = StrokeStartLineCap, EndCap = StrokeEndLineCap, DashOffset = StrokeDashOffset, LineJoin = StrokeLineJoin, MiterLimit = Math.Max(1, StrokeMiterLimit), DashStyle = StrokeDashStyle }); strokeStyleChanged = false; } }
private void CustomDraw(IRenderContext2D renderContext) { foreach (var s in segmentList) { Point initialPoint = GetRenderingPoint(new Point(s.Segment.X1, s.Segment.Y1)); Point endPoint = GetRenderingPoint(new Point(s.Segment.X2, s.Segment.Y2)); System.Windows.Media.Color segmentColor = System.Windows.Media.Color.FromArgb(s.Color.A, s.Color.R, s.Color.G, s.Color.B); /// Create a pen to draw. Make sure you dispose it! using (var linePen = renderContext.CreatePen(segmentColor, this.AntiAliasing, (float)s.Width, s.Opacity, s.DashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { lineDrawingContext.MoveTo(endPoint.X, endPoint.Y); lineDrawingContext.End(); } } } }
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); } } }
public override void Update(IRenderContext2D context) { base.Update(context); if (strokeStyleChanged) { shapeRenderable.StrokeStyle = new StrokeStyle(context.DeviceContext.Factory, new StrokeStyleProperties() { DashCap = this.StrokeDashCap, StartCap = StrokeStartLineCap, EndCap = StrokeEndLineCap, DashOffset = StrokeDashOffset, LineJoin = StrokeLineJoin, MiterLimit = Math.Max(1, (float)StrokeMiterLimit), DashStyle = StrokeDashStyle }, StrokeDashArray == null ? new float[0] : StrokeDashArray); strokeStyleChanged = false; } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Create a line drawing context. Make sure you dispose it! // NOTE: You can create mutliple line drawing contexts to draw segments if you want // You can also call renderContext.DrawLine() and renderContext.DrawLines(), but the lineDrawingContext is higher performance foreach (var p in polygonList) { Polygon polygon = p.Value.polygon; if (polygon.Points.Count > 0) { Point initialPoint = GetRenderingPoint(polygon.Points[0]); System.Windows.Media.Color backgroundColor = System.Windows.Media.Color.FromArgb(p.Value.backgroundColor.A, p.Value.backgroundColor.R, p.Value.backgroundColor.G, p.Value.backgroundColor.B); using (var brush = renderContext.CreateBrush(backgroundColor)) { //IEnumerable<Point> points; // define your points renderContext.FillPolygon(brush, GetRenderingPoints(polygon.Points)); } //// Create a pen to draw. Make sure you dispose it! System.Windows.Media.Color borderColor = System.Windows.Media.Color.FromArgb(p.Value.borderColor.A, p.Value.borderColor.R, p.Value.borderColor.G, p.Value.borderColor.B); using (var linePen = renderContext.CreatePen(borderColor, this.AntiAliasing, p.Value.borderWidth, p.Value.borderOpacity, p.Value.borderDashPattern)) { using (var lineDrawingContext = renderContext.BeginLine(linePen, initialPoint.X, initialPoint.Y)) { for (int i = 1; i < polygon.Points.Count; i++) { lineDrawingContext.MoveTo(GetRenderingPoint(polygon.Points[i]).X, GetRenderingPoint(polygon.Points[i]).Y); } lineDrawingContext.End(); } } } } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var xcal = renderPassData.XCoordinateCalculator; var ycal = renderPassData.YCoordinateCalculator; var surf = GetParentSurface(); var xrange = surf.XAxis.VisibleRange.AsDoubleRange(); var yrange = surf.YAxis.VisibleRange.AsDoubleRange(); var area = new Rect(xrange.Min, yrange.Min, xrange.Diff, yrange.Diff); var found = DataSeries.FindInArea(area); var brush = renderContext.CreateBrush(new SolidColorBrush(Colors.BlueViolet)); var pen = renderContext.CreatePen(Colors.Black, false, 1); foreach (var index in found) { var xv = DataSeries.XValues[index]; var yv = DataSeries.YValues[index]; var wv = DataSeries.WidthValues[index]; var hv = DataSeries.HeightValues[index]; DrawRectangle(renderContext, pen, brush, xcal, ycal, xv, yv, wv, hv); } brush.Dispose(); pen.Dispose(); }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { base.Draw(renderContext, renderPassData); // Get the CustomPointRenderableSeries.PointMarker to draw at original points // Assumes you have declared one in XAML or code // // e.g. CustomPointRenderableSeries.PointMarker = new EllipsePointMarker(); // var pointMarker = base.GetPointMarker(); if (pointMarker != null) { // The resampled data for this render pass var dataPointSeries = renderPassData.PointSeries; var xCalc = renderPassData.XCoordinateCalculator; var yCalc = renderPassData.YCoordinateCalculator; // Begin a batched PointMarker draw operation pointMarker.BeginBatch(renderContext, pointMarker.Stroke, pointMarker.Fill); // Iterate over the data for (int i = 0; i < dataPointSeries.Count; i++) { // Convert data to coords double xCoord = xCalc.GetCoordinate(dataPointSeries.XValues[i]); double yCoord = yCalc.GetCoordinate(dataPointSeries.YValues[i]); int dataIndex = dataPointSeries.Indexes[i]; // Draw at current location pointMarker.MoveTo(renderContext, xCoord, yCoord, dataIndex); } // End the batch // Note: To change point color, start a new batch pointMarker.EndBatch(renderContext); } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var xcal = renderPassData.XCoordinateCalculator; var ycal = renderPassData.YCoordinateCalculator; var surf = GetParentSurface(); var xrange = surf.XAxis.VisibleRange.AsDoubleRange(); var yrange = surf.YAxis.VisibleRange.AsDoubleRange(); var area = new Rect(xrange.Min, yrange.Min, xrange.Diff, yrange.Diff); var found = DataSeries.FindInArea(area); var brush = renderContext.CreateBrush(new SolidColorBrush(Colors.BlueViolet)); var pen = renderContext.CreatePen(Colors.Black, false, 1); foreach (var index in found) { var xv = DataSeries.XValues[index]; var yv = DataSeries.YValues[index]; var wv = DataSeries.WidthValues[index]; var hv = DataSeries.HeightValues[index]; DrawRectangle(renderContext, pen, brush, xcal, ycal, xv, yv, wv, hv); } brush.Dispose(); pen.Dispose(); }
public override void Draw(IRenderContext2D context, IEnumerable <Point> centers) { var fill = context.CreateBrush(Fill); var stroke = context.CreatePen(Stroke, AntiAliasing, (float)StrokeThickness); float width2 = (float)(Width * 0.5); float height2 = (float)(Height * 0.5); foreach (var center in centers) { double top = center.Y - height2; double bottom = center.Y + height2; double left = center.X - width2; double right = center.X + width2; var diamondPoints = new[] { // Points drawn like this: // // x0 (x4 in same location as x0) // // x3 x1 // // x2 new Point(center.X, top), // x0 new Point(right, center.Y), // x1 new Point(center.X, bottom), // x2 new Point(left, center.Y), // x3 new Point(center.X, top), // x4 == x0 }; context.FillPolygon(fill, diamondPoints); context.DrawLines(stroke, diamondPoints); } }
protected override void Draw(IRenderContext2D renderContext, IRenderPassData renderPassData) { var xcal = renderPassData.XCoordinateCalculator; var ycal = renderPassData.YCoordinateCalculator; var surf = GetParentSurface(); var xrange = surf.XAxis.VisibleRange.AsDoubleRange(); var yrange = surf.YAxis.VisibleRange.AsDoubleRange(); var area = new Rect(xrange.Min, yrange.Min, xrange.Diff, yrange.Diff); var pixTakeCare = 3; var pixSizeX = (TReal)Math.Abs(xcal.GetDataValue(pixTakeCare) - xcal.GetDataValue(0.0)); var pixSizeY = (TReal)Math.Abs(ycal.GetDataValue(0.0) - ycal.GetDataValue(pixTakeCare)); var found = DataSeries.FindInArea(area, pixSizeX, pixSizeY); var brush = renderContext.CreateBrush(new SolidColorBrush(Colors.BlueViolet)); var pen = renderContext.CreatePen(Colors.Black, false, 1); foreach (var rect in found) { DrawRectangle(renderContext, pen, brush, xcal, ycal, (TReal)rect.X, (TReal)rect.Y, (TReal)rect.Width, (TReal)rect.Height); } brush.Dispose(); pen.Dispose(); var sdbg = DataSeries as Series4; //sdbg.DrawNodes(renderContext, xcal, ycal, area, pixSizeX, pixSizeY); }
/// <summary> /// Called when [render]. /// </summary> /// <param name="matrices">The matrices.</param> protected override void OnRender(IRenderContext2D matrices) { }
protected override bool CanRender(IRenderContext2D context) { return(base.CanRender(context) && Foreground != null); }
protected override void DrawInternal(IRenderContext2D context, double x, double y, IPen2D pen, IBrush2D brush) { List<Point> center = new List<Point>(); center.Add(new Point(x, y)); DrawInternal(context, center, pen, brush); }