Ejemplo n.º 1
0
        /// <summary>
        /// Clones the signal, including the samples
        /// </summary>
        /// <returns></returns>
        public Signal Clone()
        {
            var signal = (Signal)MemberwiseClone();

            signal.Samples = (double[])Samples.Clone();
            return(signal);
        }
Ejemplo n.º 2
0
        public void Draw(Samples samples, Graphics gr, Rectangle bounds, bool normalize = false)
        {
            var kx = bounds.Width / samples.Values.Length;
            var ky = bounds.Height / 2;
            var cy = bounds.Top + bounds.Height / 2;
            var cx = bounds.Left;

            var values = samples.Values;

            if (normalize)
            {
                var s = samples.Clone();
                s.Normalize();
                values = s.Values;
            }

            using (var pen = new Pen(ForeColor))
                for (int i = 0; i < values.Length; i++)
                {
                    var x = i * kx;
                    var y = values[i];
                    if (y > 1)
                    {
                        y = 1;
                    }
                    if (y < -1)
                    {
                        y = -1;
                    }
                    y = y * ky;
                    gr.DrawLine(pen, cx + x, cy + y, cx + x, cy - y);
                }
        }