/// <summary>
        /// The default constructor.
        /// </summary>
        public RasterControl()
        {
            TheModel = new RasterControlModel(this);

            InitializeComponent();
            ClipToBounds = true;
            // these settings are to improve rendering speed
            RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
            IsHitTestVisible = false;
        }
        /// <summary>
        /// The default constructor.
        /// </summary>
        public RasterControl()
        {
            TheModel = new RasterControlModel(this);

            InitializeComponent();
            ClipToBounds = true;
            // these settings are to improve rendering speed
            RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
            IsHitTestVisible = false;
            
        }
        public void DrawRasterTest()
        {
            IRasterControlView View = MockRepository.GenerateStub<IRasterControlView>();
            View.Resolution = 100;
            View.RasterWidth = 1;
            View.IsCartesian = true;
            View.BB = new Rect(0, 0, 10, 10);
            View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix();

            RasterControlModel target = new RasterControlModel(View);
            List<Point> lstpts = new List<Point>();
            List<double> lstrads = new List<double>();
            Action<Point, Point> LineDrawMethod = (p1,p2)=>lstpts.Add(p1);
            Action<double, double> EllipseDrawMethod = (r1,r2)=>lstrads.Add(r1); 
            target.DrawRaster(LineDrawMethod, EllipseDrawMethod);
            Assert.IsTrue( lstpts.TrueForAll(p=> p.X == Math.Round(p.X) &&   p.Y == Math.Round(p.Y)));
            Assert.AreEqual(0, lstrads.Count);
        }
        public void RasterizePixelToTikzTest()
        {
            IRasterControlView View = MockRepository.GenerateStub<IRasterControlView>();
            View.Resolution = 100;
            View.RasterWidth = 1;
            View.IsCartesian = true;
            View.BB = new Rect(0, 0, 10, 10);
            View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix();

            RasterControlModel target = new RasterControlModel(View);
            Point p = new Point(30, 70);
            Point expected = new Point(0, 1);
            Point actual;
            actual = target.RasterizePixelToTikz(p);
            Assert.AreEqual(expected, actual);
        }
        public void RasterizeTest()
        {
            IRasterControlView View = MockRepository.GenerateStub<IRasterControlView>();
            View.Resolution = 100;
            View.RasterWidth = 1;
            View.IsCartesian = true;
            View.BB = new Rect(0.5, 0.5, 10, 10);
            View.CoordinateTransform = new TikzEdt.Parser.TikzMatrix();

            RasterControlModel target = new RasterControlModel(View);
            Point p = new Point(3, 3); // TODO: Initialize to an appropriate value
            Point expected = new Point(3, 3); // TODO: Initialize to an appropriate value
            Point actual;
            actual = target.Rasterize(p);
            Assert.AreEqual(expected, actual);

            p = new Point(3.2, 3.7);
            expected = new Point(3, 4);
            actual = target.Rasterize(p);
            Assert.AreEqual(expected, actual);

            p = new Point(3.2, 3.5);
            expected = new Point(3, 4);
            actual = target.Rasterize(p);
            Assert.AreEqual(expected, actual);
            
        }