Click here to Skip to main content
15,891,423 members
Articles / Desktop Programming / WPF

The Time Machine

Rate me:
Please Sign up or sign in to vote.
4.91/5 (13 votes)
9 May 2012CPOL6 min read 34.2K   1.2K   32  
Long time strategy of software design and development
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

using Chart.Drawing.Interfaces;


namespace Chart.Drawing.Painters
{
    public class SimpleSeriesPainter : ISeriesPainter
    {

        #region Fields

        protected Color color;

        protected ChartPerformer performer;

        protected double[,] dSize = new double[2, 2];

        protected int[] pointStart = new int[2];
        protected int[] pointFinish = new int[2];

        protected Pen pen;// = new Pen(Color.Black);


        #endregion

        #region Constructors

        public SimpleSeriesPainter(Color color)
        {
            this.color = color;
            pen = new Pen(color);
        }

        #endregion

        #region ISeriesPainter Members

        public virtual void Draw(ISeries series, Graphics g)
        {
            IList<IPoint> points = series.Points;
            if (points.Count < 2)
            {
                return;
            }
            IPoint xx = points[0];
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    dSize[i, j] = performer[i, j];
                }
            }
            if ((dSize[0, 1] == dSize[1, 1]) | (dSize[0, 0] == dSize[1, 0]))
            {
                return;
            }
            int[] size = performer.CanvasSize;
            performer.Transform(xx.X, xx.Y, pointStart);
            for (int i = 1; i < points.Count; i++)
            {
                xx = points[i];
                performer.Transform(xx.X, xx.Y, pointFinish);
                int dx = Math.Abs(pointStart[0] - pointFinish[0]);
                int dy = Math.Abs(pointStart[1] - pointFinish[1]);
                if ((dx < performer.StepX) | (dy < performer.StepY))
                {
                    continue;
                }
                g.DrawLine(pen, pointStart[0], pointStart[1], pointFinish[0], pointFinish[1]);
                pointStart[0] = pointFinish[0];
                pointStart[1] = pointFinish[1];
            }
        }

        ChartPerformer ISeriesPainter.Performer
        {
            get
            {
                return performer;
            }
            set
            {
                performer = value;
            }
        }

        #endregion

        #region ICloneable Members

        /// <summary>
        /// Clones itself
        /// </summary>
        /// <returns>The clone</returns>
        public virtual object Clone()
        {
            return new SimpleSeriesPainter(color);
        }

        #endregion

        public Color Color
        {
            set
            {
                color = value;
                pen = new Pen(value);
            }
        }

        /*
        #region Overriden Members

        public override int GetHashCode()
        {
            return (int)PainterType.Simple;
        }

        public override bool Equals(object obj)
        {
            SimpleSeriesPainter p = obj as SimpleSeriesPainter;
            if (p == null)
            {
                return false;
            }
            return color == p.color;
        }

        #endregion
*/

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Russian Federation Russian Federation
Ph. D. Petr Ivankov worked as scientific researcher at Russian Mission Control Centre since 1978 up to 2000. Now he is engaged by Aviation training simulators http://dinamika-avia.com/ . His additional interests are:

1) Noncommutative geometry

http://front.math.ucdavis.edu/author/P.Ivankov

2) Literary work (Russian only)

http://zhurnal.lib.ru/editors/3/3d_m/

3) Scientific articles
http://arxiv.org/find/all/1/au:+Ivankov_Petr/0/1/0/all/0/1

Comments and Discussions