コード例 #1
0
ファイル: Form1.cs プロジェクト: nathanial/GLGraph.NET
        void ShowStaticGraph() {
            var textures = new 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(2000);
            _drawTimer.Tick += delegate {
                for (var i = 0; i < 500; i++) {
                    for (var j = 0; j < 3; j++) {
                        var data = new List<GLPoint>();
                        for (var k = 0; k < 100 * 2; k++) {
                            data.Add(new GLPoint(k / 2.0 * 10, random.NextDouble() * 30 - 15));
                        }
                        _graph.Lines.Add(new Line(1.0f, 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 SatisfiedMarker(
                            new GLPoint(random.NextDouble() * 1000, random.NextDouble() * 30 - 15),
                            textures.RedOrb));
                }
            };
            _markerDrawer.Start();

        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: nathanial/GLGraph.NET
        void ShowStaticGraph()
        {
            var textures = new 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(2000);
            _drawTimer.Tick    += delegate {
                for (var i = 0; i < 500; i++)
                {
                    for (var j = 0; j < 3; j++)
                    {
                        var data = new List <GLPoint>();
                        for (var k = 0; k < 100 * 2; k++)
                        {
                            data.Add(new GLPoint(k / 2.0 * 10, random.NextDouble() * 30 - 15));
                        }
                        _graph.Lines.Add(new Line(1.0f, 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 SatisfiedMarker(
                            new GLPoint(random.NextDouble() * 1000, random.NextDouble() * 30 - 15),
                            textures.RedOrb));
                }
            };
            _markerDrawer.Start();
        }