Esempio n. 1
0
 public void DrawWithPen(double x1, double y1, double x2, double y2)
 {
     _penlineChunk.Add(new LightLine {
         X1 = x1, X2 = x2, Y1 = y1, Y2 = y2
     });
     Update();
 }
Esempio n. 2
0
 public void DrawTempLine(double x1, double y1, double x2, double y2)
 {
     _templineChunk.Add(new LightLine {
         X1 = x1, X2 = x2, Y1 = y1, Y2 = y2
     });
     Update();
     ClearTempLineChunk();
 }
Esempio n. 3
0
        //Draws the background gridLightLines on the canvas.
        private void GridLightLines()
        {
            var lineChunk = new LineChunk();

            lineChunk.SetColour(Brushes.LightGray);
            //Draw faint grid LightLines:
            for (double i = 0; i <= _xRange + _incrementX; i += _incrementX)
            {
                if (!((-_startOffSetX + i) / _incrementX * _xInterval >= 0) ||
                    !((-_startOffSetX + i) / _incrementX * _xInterval <= _width))
                {
                    continue;
                }
                var newLightLine = new LightLine
                {
                    X1 = (-_startOffSetX + i) / _incrementX * _xInterval,
                    Y1 = 0,
                    X2 = (-_startOffSetX + i) / _incrementX * _xInterval,
                    Y2 = _height
                };
                lineChunk.Add(newLightLine);
            }
            for (var i = _yRange; i >= -_incrementY; i -= _incrementY)
            {
                if (!((_startOffSetY + i) / _incrementY * _yInterval >= 0) ||
                    !((_startOffSetY + i) / _incrementY * _yInterval <= _height))
                {
                    continue;
                }
                var newLightLine = new LightLine
                {
                    X1 = 0,
                    Y1 = (_startOffSetY + i) / _incrementY * _yInterval,
                    X2 = _width,
                    Y2 = (_startOffSetY + i) / _incrementY * _yInterval
                };
                lineChunk.Add(newLightLine);
            }
            _chunks.Add(lineChunk);
        }
Esempio n. 4
0
        public void PlotData(Point point)
        {
            var line = new LightLine();

            if (_dataLineChunk.ChunkList.Count == 0)
            {
                line.X1 = (point.X - _xStart) / _incrementX * _xInterval;
                line.Y1 = (-point.Y + _yStart + _yRange) / _incrementY * _yInterval;
                line.X2 = (point.X - _xStart) / _incrementX * _xInterval;
                line.Y2 = (-point.Y + _yStart + _yRange) / _incrementY * _yInterval;
            }
            else
            {
                line.X1 = (point.X - _xStart) / _incrementX * _xInterval;
                line.Y1 = (-point.Y + _yStart + _yRange) / _incrementY * _yInterval;
                line.X2 = ((LightLine)_dataLineChunk.ChunkList[_dataLineChunk.ChunkList.Count - 1]).X1;
                line.Y2 = ((LightLine)_dataLineChunk.ChunkList[_dataLineChunk.ChunkList.Count - 1]).Y1;
            }

            _dataLineChunk.Add(line);

            if (line.Y2 > _height || line.Y2 < 0 || line.Y1 > _height || line.Y1 < 0)
            {
                Zoom(1);
            }

            if (!(line.X1 >= _width))
            {
                return;
            }

            Translate(line.X2 - line.X1 * 2, 0);



            if (_dataLineChunk.ChunkList.Count > 1000)
            {
                _dataLineChunk.Clear();
            }

            if (line.Y1 >= 0 && line.Y1 <= _height && line.Y2 >= 0 && line.Y2 <= _height)
            {
                Zoom(-1);
            }
        }
Esempio n. 5
0
        //Draws X and y axes.
        private void Axes()
        {
            //The faint grid is drawn first to minimize overlapping of canvas objects.
            var lineChunk = new LineChunk();

            lineChunk.SetColour(Brushes.Black);

            //Draw increment LightLines and axes for each interval:

            //If the yStart and yEnd Values are both less than zero the  X axis is drawn at the top of the canvas.

            for (var i = -_startOffSetX; i <= _xRange + _incrementX; i += _incrementX)
            {
                if (!(i / _incrementX * _xInterval >= 0) || !(i / _incrementX * _xInterval <= _width))
                {
                    continue;
                }
                var incrementLightLine = new LightLine
                {
                    X1 = i / _incrementX * _xInterval,
                    Y1 = _origin.Y + 4,
                    X2 = i / _incrementX * _xInterval,
                    Y2 = _origin.Y - 4
                };

                lineChunk.Add(incrementLightLine);
            }

            var axesLightLine = new LightLine
            {
                X1 = 0,
                Y1 = _origin.Y,
                X2 = _width,
                Y2 = _origin.Y
            };

            lineChunk.Add(axesLightLine);

            //If the xStart and xEnd Values are both less than zero the y axis is drawn at the right of the canvas.

            for (var i = _yRange + _startOffSetY; i >= -_incrementY; i -= _incrementY)
            {
                if (!(i / _incrementY * _yInterval >= 0) || !(i / _incrementY * _yInterval <= _height))
                {
                    continue;
                }
                var incrementLightLine = new LightLine
                {
                    X1 = _origin.X + 4,
                    Y1 = i / _incrementY * _yInterval,
                    X2 = _origin.X - 4,
                    Y2 = i / _incrementY * _yInterval
                };

                lineChunk.Add(incrementLightLine);
            }
            var axesLightLineY = new LightLine
            {
                X1 = _origin.X,
                Y1 = 0,
                X2 = _origin.X,
                Y2 = _height
            };

            lineChunk.Add(axesLightLineY);

            _chunks.Add(lineChunk);
            //If the origin is present to be drawn on the canvas a ellipse will be drawn to mark its location.
            if (_xStart <= 0 && _xEnd >= 0 && _yStart <= 0 && _yEnd >= 0)
            {
                _chunks.Add(DrawingMethods.Circle(_origin, 10));
            }
        }