/// <summary>
        /// Paints the signal.
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="r">The r.</param>
        /// <param name="st">The st.</param>
        /// <param name="c">The c.</param>
        private void PaintSignal(Graphics g, Rectangle r, SignalType st, Color c)
        {
            float X1 = InitialLocation[0];
            float Y1 = InitialLocation[1];

            float X2 = X1 + r.Width;
            float Y2 = Y1 + r.Height;

            float Xw = r.Width;
            float Yh = r.Height;

            float Xm = X1 + Xw / 2;                                                      // X possition of middle point.
            float Ym = Y1 + Yh / 2;                                                      // Y possition of middle point.

            float Nper = Periods;                                                        // Number of periodes that schud be shown.
            float Xpw  = Xw / Nper;                                                      // One Periode length in pixel.
            float Yah  = AmplitudeHeight * Yh / (AmplitudeTension * (GetSum / Maximum)); // Signal amplitude height in picel.

            // Create a custom pen:


            if (ShowGridLines)
            {
                //Draw vertical grid lines:
                for (int i = 1; i < GridLines * Nper; i++)
                {
                    g.DrawLine(GridPen, X1 + (Xpw / GridLines) * i, Y1, X1 + (Xpw / GridLines) * i, Y2);
                }

                //Draw horisontal grid lines:
                g.DrawLine(GridPen, X1, Ym - Yah, X2, Ym - Yah);
                g.DrawLine(GridPen, X1, Ym, X2, Ym);
                g.DrawLine(GridPen, X1, Ym + Yah, X2, Ym + Yah);
            }

            // Create requider signal generator:
            SignalGenerate sg = new SignalGenerate(st);

            // Adjust aignal generator:

            sg.Frequency = 1 / Xpw;
            sg.Phase     = 0f;
            sg.Amplitude = Yah;
            sg.Offset    = 0f;
            sg.Invert    = false;

            // Generate signal and draw it:
            float Xold = 0f;
            float Yold = 0f;
            float Xnew = 0f;
            float Ynew = 0f;


            //signalPen.Color = c;
            //signalPen.DashStyle = DashStyle.Solid;
            //signalPen.Width = 2;
            for (int i = 0; i < Xw; i++)
            {
                Xnew = i;
                Ynew = (float)sg.GetValue(i); // NOTE: Only for debug, not for release configuration!
                if (i > 0)
                {
                    g.DrawLine(SignalPen, X1 + Xold, Ym - Yold, X1 + Xnew, Ym - Ynew);
                }
                Xold = Xnew; Yold = Ynew;
            }

            // Draw the name of signal form:
            StringFormat format = new StringFormat();


            format.Alignment = StringAlignment.Center;

            if (ShowText)
            {
                g.DrawString(st.ToString(),
                             Font,
                             new SolidBrush(ForeColor),
                             X2 - Xpw / 4, 10, format);
            }


            if (ShowBorder)
            {
                // Draw border rectangle:
                g.DrawRectangle(BorderColor, X1 + 1, Y1 + 1, Xw - 2, Yh - 2);
            }
        }
 /// <summary>
 /// Synchronizes the specified instance.
 /// </summary>
 /// <param name="instance">The instance.</param>
 public void Synchronize(SignalGenerate instance)
 {
     startTime      = instance.startTime;
     ticksPerSecond = instance.ticksPerSecond;
 }