Exemple #1
0
        public void LegendNormalUsage_WithBorder()
        {
            var gv     = GraphViewTests.GetGraph();
            var legend = new LegendAnnotation(new Rect(2, 0, 5, 3));

            legend.AddEntry(new GraphCellToRender('A'), "Ant");
            legend.AddEntry(new GraphCellToRender('B'), "Bat");

            gv.Annotations.Add(legend);
            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │┌───┐
 ┤│AAn│
 ┤└───┘
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }
Exemple #2
0
        public void TestTextAnnotation_GraphUnits()
        {
            var gv = GraphViewTests.GetGraph();

            gv.Annotations.Add(new TextAnnotation()
            {
                Text          = "hey!",
                GraphPosition = new PointF(2, 2)
            });

            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │
 ┤ hey!
 ┤
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);

            // user scrolls up one unit of graph space
            gv.ScrollOffset = new PointF(0, 1f);
            gv.Redraw(gv.Bounds);

            // we expect the text annotation to go down one line since
            // the scroll offset means that that point of graph space is
            // lower down in the view.  Note the 1 on the axis too, our viewport
            // (excluding margins) now shows y of 1 to 4 (previously 0 to 5)
            expected =
                @"
 │
 ┤ 
 ┤ hey!
1┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }
Exemple #3
0
        public void TestTextAnnotation_ScreenUnits()
        {
            var gv = GraphViewTests.GetGraph();

            gv.Annotations.Add(new TextAnnotation()
            {
                Text           = "hey!",
                ScreenPosition = new Point(3, 1)
            });

            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │
 ┤ hey!
 ┤
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);

            // user scrolls up one unit of graph space
            gv.ScrollOffset = new PointF(0, 1f);
            gv.Redraw(gv.Bounds);

            // we expect no change in the location of the annotation (only the axis label changes)
            // this is because screen units are constant and do not change as the viewport into
            // graph space scrolls to different areas of the graph
            expected =
                @"
 │
 ┤ hey!
 ┤
1┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }
Exemple #4
0
        public void TestTextAnnotation_Offscreen()
        {
            var gv = GraphViewTests.GetGraph();

            gv.Annotations.Add(new TextAnnotation()
            {
                Text          = "hey there partner hows it going boy its great",
                GraphPosition = new PointF(9, 2)
            });

            gv.Redraw(gv.Bounds);

            // Text is off the screen (graph x axis runs to 8 not 9)
            var expected =
                @"
 │
 ┤
 ┤
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }
Exemple #5
0
        public void LegendNormalUsage_WithoutBorder()
        {
            var gv     = GraphViewTests.GetGraph();
            var legend = new LegendAnnotation(new Rect(2, 0, 5, 3));

            legend.AddEntry(new GraphCellToRender('A'), "Ant");
            legend.AddEntry(new GraphCellToRender('B'), "?");               // this will exercise pad
            legend.AddEntry(new GraphCellToRender('C'), "Cat");
            legend.AddEntry(new GraphCellToRender('H'), "Hattter");         // not enough space for this oen
            legend.Border = false;

            gv.Annotations.Add(legend);
            gv.Redraw(gv.Bounds);

            var expected =
                @"
 │AAnt
 ┤B?
 ┤CCat
0┼┬┬┬┬┬┬┬┬
 0    5";

            GraphViewTests.AssertDriverContentsAre(expected);
        }