Ejemplo n.º 1
0
        public void Draw(ScaledGraphics g)
        {
            //Try to be fast
            g.Target.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            g.Target.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighSpeed;
            g.Target.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;

            if (_PositionY == 0)
            {
                return;
            }

            _Image.UnlockBits(_LockedData);

            try
            {
                var empty = DrawBitmapSection(g.Target, g.Rect, 0, _PositionY);
                if (_WrapImage)
                {
                    DrawBitmapSection(g.Target, empty, _PositionY, _Image.Height);
                }
            }
            finally
            {
                _LockedData = _Image.LockBits(new Rectangle(0, 0, _Image.Width, _Image.Height),
                                              ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            }
        }
Ejemplo n.º 2
0
 public void Draw(ScaledGraphics g)
 {
     if (Source2 != null)
     {
         Source2(out var d1, out var d2);
         RenderInternal(g, d1, d2);
     }
     else
     {
         RenderInternal(g, Source());
     }
 }
Ejemplo n.º 3
0
        private void RenderInternal(ScaledGraphics g, float[] val, float[] val2 = null)
        {
            if (val.Length < 2)
            {
                return;
            }

            if (ScaleX == null)
            {
                ScaleX = DefaultScale;
            }
            if (ScaleY == null)
            {
                ScaleY = DefaultScale;
            }

            if (_PointBuffer == null || _PointBuffer.Length == 0)
            {
                ResizeBuffer(val.Length);
            }

            var left   = g.Rect.X;
            var top    = g.Rect.Y;
            var width  = g.Rect.Width;
            var height = g.Rect.Height;

            var y0    = top;
            var ystep = height;

            CalculatePoints(val, left, width / (val.Length - 1), y0, ystep);

            //Record
            foreach (var w in DataReceivers)
            {
                w.WriteData(g.Rect, _PointBuffer, val2);
            }

            //X axis
            g.Target.DrawLine(Pens.Gray, left, y0 + ystep, left + width, y0 + ystep);

            //Draw
            try
            {
                //In case of NaN/Inf
                g.Target.DrawLines(Pens.Black, _PointBuffer);
            }
            catch
            {
            }
        }
Ejemplo n.º 4
0
        private void Target_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;

            g.Clear(Color.White);

            var scaled = new ScaledGraphics {
                Target = g
            };

            var region = Target.ClientRectangle;

            scaled.Rect.X      = region.Left + MarginLeft;
            scaled.Rect.Y      = region.Top + MarginTop;
            scaled.Rect.Width  = region.Width - MarginLeft - MarginRight;
            scaled.Rect.Height = region.Height - MarginTop - MarginBottom;

            foreach (var layer in Layers)
            {
                layer.Draw(scaled);
            }
        }
Ejemplo n.º 5
0
 public void Draw(ScaledGraphics g)
 {
     this.g = g;
     DrawAll();
 }