Esempio n. 1
0
        private void TryCasheResources(IRenderContext2D context)
        {
            _strokePen = _strokePen ?? context.CreatePen(Stroke, AntiAliasing, (float)StrokeThickness, Opacity);

            _gainFillBrush = _gainFillBrush ?? context.CreateBrush(GainMarkerFill);
            _lossFillBrush = _lossFillBrush ?? context.CreateBrush(LossMarkerFill);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 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);
 }
        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);
        }
Esempio n. 7
0
        private void DrawDiamond(IRenderContext2D context, Point center, double width, double height, IPen2D stroke, IBrush2D fill)
        {
            double top    = center.Y - height;
            double bottom = center.Y + height;
            double left   = center.X - width;
            double right  = center.X + width;

            var diamondPoints = new[]
            {
                // Points drawn like this:
                //
                //      x0      (x4 in same location as x0)
                //
                // x3        x1
                //
                //      x2
                new Point(center.X, top),
                new Point(right, center.Y),
                new Point(center.X, bottom),
                new Point(left, center.Y),
                new Point(center.X, top),
            };

            context.FillPolygon(fill, diamondPoints);
            context.DrawLines(stroke, diamondPoints);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 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);
 }