Esempio n. 1
0
        public void CanCreateObjectAdapterForModernGraphicRendererAndDrawLineWithColor()
        {
            var writer   = new StringWriter();
            var renderer = new ModernGraphicsRenderer(writer);
            var adapter  = new MGRendererObjectAdapter(renderer);

            var startX    = 1;
            var startY    = 1;
            var endX      = 10;
            var endY      = 20;
            var testColor = Color.Coral;

            adapter.Renderer.BeginDraw();
            adapter.SetColor((uint)testColor.ToArgb());
            adapter.MoveTo(startX, startY);
            adapter.LineTo(endX, endY);
            adapter.Renderer.EndDraw();

            var testString = new StringWriter();

            testString.WriteLine("<draw>");
            testString.WriteLine($"<line fromX={startX} fromY={startY} toX={endX} toY={endY}>");
            testString.WriteLine($"<color r={testColor.R} g={testColor.G} b={testColor.B} a={testColor.A} />");
            testString.WriteLine($"</line>");
            testString.WriteLine("</draw>");
            Assert.AreEqual(testString.ToString(), writer.ToString());
        }
Esempio n. 2
0
        public void CanCreateObjectAdapterForModernGraphicRendererAndDrawLine()
        {
            var writer   = new StringWriter();
            var renderer = new ModernGraphicsRenderer(writer);
            var adapter  = new MGRendererObjectAdapter(renderer);

            var startX = 1;
            var startY = 1;
            var endX   = 10;
            var endY   = 20;

            adapter.Renderer.BeginDraw();
            adapter.MoveTo(startX, startY);
            adapter.LineTo(endX, endY);
            adapter.Renderer.EndDraw();

            var testString = new StringWriter();

            testString.WriteLine("<draw>");
            testString.WriteLine($"<line fromX={startX} fromY={startY} toX={endX} toY={endY}/>");
            testString.WriteLine("</draw>");
            Assert.AreEqual(testString.ToString(), writer.ToString());
        }