public void addPoint(float t, float latitude, float longitude, float coverage)
        {
            statePoint p = new statePoint();

            p.t         = t;
            p.latitude  = latitude;
            p.longitude = longitude;
            p.coverage  = coverage;
            history.Add(p);
            sort();
        }
        private void sort()
        {
            // Bubble-sorts points by time history
            bool sorted = false;

            while (!sorted)
            {
                sorted = true;
                for (int i = 0; i < history.Count - 1; i++)
                {
                    if (history[i].t > history[i + 1].t)
                    {
                        statePoint tmp = history[i];
                        history[i]     = history[i + 1];
                        history[i + 1] = tmp;
                        sorted         = false;
                    }
                }
            }
        }
 public void addPoint(statePoint point)
 {
     history.Add(point);
     sort();
 }
        protected override void OnPaint(PaintEventArgs e)
        {
            for (int j = 0; j < histories.Count; j++)
            {
                stateHistory h       = histories[j];
                Pen          pen     = new Pen(h.color);
                List <Point> points  = new List <Point>();
                int          xOffset = 0;
                for (int i = 0; i < h.history.Count; i++)
                {
                    statePoint p = h.history[i];
                    int        x = Conversion.Longitude2Pixel(p.longitude, Width) + xOffset;
                    int        y = Conversion.Latitude2Pixel(p.latitude, Height);
                    points.Add(new Point(x, y));
                    if (x > Width)
                    {
                        // Draw current points, start new set
                        if (points.Count > 1)
                        {
                            e.Graphics.DrawLines(pen, points.ToArray());
                        }
                        points.Clear();
                        xOffset -= Width;
                    }
                    if (i != h.history.Count - 1 && p.t < CurrTime && CurrTime <= h.history[i + 1].t)
                    {
                        // Draw point for current satellite position
                        int sx = Conversion.Longitude2Pixel(p.longitude, Width) + xOffset;
                        int sy = Conversion.Latitude2Pixel(p.latitude, Height);
                        e.Graphics.DrawEllipse(pen, new Rectangle(sx - satellitePointRadius, sy - satellitePointRadius, 2 * satellitePointRadius, 2 * satellitePointRadius));
                    }
                }
                if (points.Count > 1)
                {
                    e.Graphics.DrawLines(pen, points.ToArray());
                }

                // Draw label
                e.Graphics.DrawString(h.name, Font, pen.Brush, new Point(Width - 100, 20 * (j + 1)));
            }

            // Update
            TimeSpan diff = DateTime.Now - lastRender;
            float    dt   = (float)(diff.Seconds) + (float)(diff.Milliseconds) / 1000.0f;

            CurrTime = CurrTime + dt * speed;
            if (CurrTime == EndTime)
            {
                // Pause at end
                speed = 0;
                updateButton();
            }
            lastRender     = DateTime.Now;
            timeLabel.Text = CurrTime.ToString();

            // Force animation update
            if (speed > 0)
            {
                Invalidate(true);
                timeLabel.Invalidate();
                slideBar1.Invalidate();
            }
            base.OnPaint(e);
        }