Ejemplo n.º 1
0
        //Add Axes and increment lines to the main line batch.
        private void Axes()
        {
            //X-Axis
            for (var i = -graphProperties.StartOffSetX; i <= graphProperties.XRange + graphProperties.IncrementX; i += graphProperties.IncrementX)
            {
                if (!(i / graphProperties.IncrementX * graphProperties.XInterval >= 0) || !(i / graphProperties.IncrementX * graphProperties.XInterval <= graphProperties.CanvasWidth))
                {
                    continue;
                }
                //Setup fo increment lines on the axis.
                var incrementLightLine = new LightLine
                {
                    X1 = i / graphProperties.IncrementX * graphProperties.XInterval,
                    Y1 = graphProperties.Origin.Y + 4,
                    X2 = i / graphProperties.IncrementX * graphProperties.XInterval,
                    Y2 = graphProperties.Origin.Y - 4
                };

                this.Add(incrementLightLine);
            }


            var axesLightLine = new LightLine
            {
                X1 = 0,
                Y1 = graphProperties.Origin.Y,
                X2 = graphProperties.CanvasWidth,
                Y2 = graphProperties.Origin.Y
            };

            this.Add(axesLightLine);


            //Y-Axis

            for (var i = graphProperties.YRange + graphProperties.StartOffSetY; i >= -graphProperties.IncrementY; i -= graphProperties.IncrementY)
            {
                if (!(i / graphProperties.IncrementY * graphProperties.YIncrement >= 0) || !(i / graphProperties.IncrementY * graphProperties.YIncrement <= graphProperties.CanvasHeight))
                {
                    continue;
                }
                //Setup fo increment lines on the axis.
                var incrementLightLine = new LightLine
                {
                    X1 = graphProperties.Origin.X + 4,
                    Y1 = i / graphProperties.IncrementY * graphProperties.YIncrement,
                    X2 = graphProperties.Origin.X - 4,
                    Y2 = i / graphProperties.IncrementY * graphProperties.YIncrement
                };

                this.Add(incrementLightLine);
            }
            var axesLightLineY = new LightLine
            {
                X1 = graphProperties.Origin.X,
                Y1 = 0,
                X2 = graphProperties.Origin.X,
                Y2 = graphProperties.CanvasHeight
            };

            this.Add(axesLightLineY);



            //If the origin is present to be drawn on the canvas a ellipse will be drawn to mark its location.
            if (graphProperties.XStart <= 0 && graphProperties.XEnd >= 0 && graphProperties.YStart <= 0 && graphProperties.YEnd >= 0)
            {
                //Add origin circle to main batch list.
                this.Add(DrawingMethods.Circle(graphProperties.Origin, 10).Content());
            }
        }
Ejemplo n.º 2
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));
            }
        }