Exemple #1
0
 void ShowDynamicGraph()
 {
     new Thread(() => {
         var line = new Line(1.0f, Color.Black.ToGLColor(), new GLPoint[] { })
         {
             IsDynamic = true
         };
         var i = 0;
         _graph.Display(new GLRect(i - 60, -20, 120, 50), false);
         BeginInvoke((Action) delegate {
             _graph.Lines.Add(line);
         });
         while (true)
         {
             var point = new GLPoint(i++, Math.Sin(i / 100.0) * 10 - 5);
             int i1    = i;
             BeginInvoke((Action) delegate {
                 if (line.Points.Count > 3000)
                 {
                     line.RemovePoint(0, update: false);
                 }
                 line.AddPoint(point);
                 if (Math.Abs((i1 / 100.0) % 1.0) < 0.001)
                 {
                     _graph.Markers.Clear();
                     _graph.Markers.Add(new GraphText(i1, Math.Sin(i1 / 100.0) * 10 - 5, i1.ToString()));
                 }
                 _graph.Display(new GLRect(i1 - 60, -20, 120, 50), false);
             });
             Thread.Sleep(10);
         }
     }).Start();
 }
Exemple #2
0
        void ShowStaticGraph()
        {
            var line = new Line(1.0f, new GLColor(1.0, 0.0, 1.0, 0.0), new[] {
                new GLPoint(0, 0),
                new GLPoint(1, 1),
                new GLPoint(2, 2),
                new GLPoint(3, 3),
                new GLPoint(4, 4),
                new GLPoint(5, 4),
                new GLPoint(6, 3),
                new GLPoint(7, 2),
                new GLPoint(8, 1),
            });

            _graph.Lines.Add(line);
            _graph.Display(new GLRect(0, 0, 10, 10), true);

            _timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(0.1)
            };
            _timer.Tick += delegate {
                var c = line.Color;
                line.Color = new GLColor(c.A, Adjust(c.R), Adjust(c.G), Adjust(c.B));
                _graph.Draw();
            };
            _timer.Start();
        }
 void ShowStaticGraph()
 {
     _graph.Lines.Add(new Line(1.0f, Colors.Black.ToGLColor(), new[] {
         new GLPoint(0, 0),
         new GLPoint(1, 5),
         new GLPoint(2, 0),
         new GLPoint(3, 5),
         new GLPoint(4, 0),
         new GLPoint(5, 5),
         new GLPoint(6, 0),
         new GLPoint(7, 5),
         new GLPoint(8, 0),
         new GLPoint(9, 5),
         new GLPoint(10, 0),
     }));
     _graph.Display(new GLRect(0, 0, 10, 10), true);
 }
Exemple #4
0
        void ShowStaticGraph()
        {
            var data   = new List <GLPoint>();
            var random = new Random();

            for (var i = 0; i < 100; i++)
            {
                data.Add(new GLPoint(i, random.NextDouble() * 30 - 15));
            }
            _graph.Lines.Add(new Line(1.0f, Color.Black.ToGLColor(), data.ToArray()));
            _graph.Display(new GLRect(0, -20, 120, 50), true);
        }
        void ShowScaledGraph()
        {
            _graph.Display(new GLRect(-50, -50, 100, 100), true);

            var random             = new Random();
            var dataInMilliseconds = new GLPoint[] {
                new GLPoint(0, 0),
                new GLPoint(3000, random.NextDouble()),
                new GLPoint(6000, random.NextDouble()),
                new GLPoint(9000, random.NextDouble()),
                new GLPoint(12000, random.NextDouble()),
                new GLPoint(15000, random.NextDouble()),
                new GLPoint(18000, random.NextDouble()),
                new GLPoint(21000, random.NextDouble()),
            };

            var dataInSeconds = dataInMilliseconds.Select(p => new GLPoint(p.X / 1000, p.Y)).ToArray();



            _graph.Lines.Add(new Line(1.0f, System.Drawing.Color.Blue.ToGLColor(), dataInSeconds));
        }
        void ShowStaticGraph()
        {
            var textures = new Form1.PersistentTextures();

            _graph.Display(new GLRect(0, -20, 1000, 50), true);
            var random = new Random();

            _clearTimer          = new DispatcherTimer();
            _clearTimer.Interval = TimeSpan.FromMilliseconds(100);
            _clearTimer.Tick    += delegate {
                var count = _graph.Lines.Count;
                if (count > 0)
                {
                    for (var i = 0; i < count / 2; i++)
                    {
                        _graph.Lines.RemoveAt(0);
                    }
                }
                count = _graph.Markers.Count;
                if (count > 0)
                {
                    for (var i = 0; i < count / 2; i++)
                    {
                        _graph.Markers.RemoveAt(0);
                    }
                }
                _graph.Draw();
            };
            _clearTimer.Start();

            _drawTimer          = new DispatcherTimer();
            _drawTimer.Interval = TimeSpan.FromMilliseconds(10);
            _drawTimer.Tick    += delegate {
                var data = new List <GLPoint>();
                for (var i = 0; i < 1000; i++)
                {
                    data.Add(new GLPoint(i, random.NextDouble() * 30 - 15));
                }
                _graph.Lines.Add(new Line(1.0f, System.Drawing.Color.Black.ToGLColor(), data.ToArray()));
                _graph.Draw();
            };
            _drawTimer.Start();

            _rectangleDrawer          = new DispatcherTimer();
            _rectangleDrawer.Interval = TimeSpan.FromMilliseconds(10);
            _rectangleDrawer.Tick    += delegate {
                for (var i = 0; i < 10; i++)
                {
                    _graph.Markers.Add(new Rectangle(new GLColor(1, 0.5, 0.5, 0.5), true,
                                                     new GLPoint(random.NextDouble() * 1000,
                                                                 random.NextDouble() * 30 - 15),
                                                     new GLSize(random.NextDouble() * 10, 1)));
                }
            };
            _rectangleDrawer.Start();

            _markerDrawer          = new DispatcherTimer();
            _markerDrawer.Interval = TimeSpan.FromMilliseconds(10);
            _markerDrawer.Tick    += delegate {
                for (var i = 0; i < 10; i++)
                {
                    _graph.Markers.Add(
                        new Form1.SatisfiedMarker(
                            new GLPoint(random.NextDouble() * 1000, random.NextDouble() * 30 - 15),
                            textures.RedOrb));
                }
            };
            _markerDrawer.Start();
        }