Example #1
0
        public void Series_GetsPassedCorrectBounds_AllAtOnce_LargeCellSize()
        {
            GraphViewTests.InitFakeDriver();

            var gv = new GraphView();

            gv.ColorScheme = new ColorScheme();
            gv.Bounds      = new Rect(0, 0, 50, 30);

            // the larger the cell size the more condensed (smaller) the graph space is
            gv.CellSize = new PointF(2, 5);

            RectangleF fullGraphBounds   = RectangleF.Empty;
            Rect       graphScreenBounds = Rect.Empty;

            var series = new FakeSeries((v, s, g) => { graphScreenBounds = s; fullGraphBounds = g; });

            gv.Series.Add(series);

            gv.Redraw(gv.Bounds);
            // Since each cell of the console is 2x5 of graph space the graph
            // bounds to be rendered are larger
            Assert.Equal(new RectangleF(0, 0, 100, 150), fullGraphBounds);
            Assert.Equal(new Rect(0, 0, 50, 30), graphScreenBounds);

            // Graph should not spill into the margins

            gv.MarginBottom = 2;
            gv.MarginLeft   = 5;

            // Even with a margin the graph should be drawn from
            // the origin, we just get less visible width/height
            gv.Redraw(gv.Bounds);
            Assert.Equal(new RectangleF(0, 0, 90, 140), fullGraphBounds);

            // The screen space the graph will be rendered into should
            // not overspill the margins
            Assert.Equal(new Rect(5, 0, 45, 28), graphScreenBounds);

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
Example #2
0
        public void Series_GetsPassedCorrectBounds_AllAtOnce()
        {
            GraphViewTests.InitFakeDriver();

            var gv = new GraphView();

            gv.ColorScheme = new ColorScheme();
            gv.Bounds      = new Rect(0, 0, 50, 30);

            RectangleF fullGraphBounds   = RectangleF.Empty;
            Rect       graphScreenBounds = Rect.Empty;

            var series = new FakeSeries((v, s, g) => { graphScreenBounds = s; fullGraphBounds = g; });

            gv.Series.Add(series);


            gv.Redraw(gv.Bounds);
            Assert.Equal(new RectangleF(0, 0, 50, 30), fullGraphBounds);
            Assert.Equal(new Rect(0, 0, 50, 30), graphScreenBounds);

            // Now we put a margin in
            // Graph should not spill into the margins

            gv.MarginBottom = 2;
            gv.MarginLeft   = 5;

            // Even with a margin the graph should be drawn from
            // the origin, we just get less visible width/height
            gv.Redraw(gv.Bounds);
            Assert.Equal(new RectangleF(0, 0, 45, 28), fullGraphBounds);

            // The screen space the graph will be rendered into should
            // not overspill the margins
            Assert.Equal(new Rect(5, 0, 45, 28), graphScreenBounds);

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }