Exemple #1
0
        public void Test_SvgGraphics()
        {
            using (MemoryStream stm = new MemoryStream()) {
                var svg = new SvgGraphics(stm, ExtRectF.CreateBounds(0, 0, 100, 100));

                svg.BeginDrawing();
                svg.Clear(UIHelper.ConvertColor(Color.Yellow));

                svg.BeginEntity(null);
                svg.DrawLine(10, 10, 50, 10, 1);
                svg.DrawArc(60, 60, 20, 15, 25, 1);
                svg.DrawEllipse(10, 10, 30, 30, null, null);
                svg.DrawRect(50, 50, 20, 20, 2);
                svg.DrawRoundedRect(80, 80, 10, 10, 3, 1);
                svg.EndEntity();

                svg.FillArc(60, 60, 20, 15, 25);
                svg.DrawEllipse(10, 10, 30, 30, null, null);
                svg.FillRect(50, 50, 20, 20);

                svg.SetColor(UIHelper.ConvertColor(Color.Red));
                svg.FillRoundedRect(80, 80, 10, 10, 3);

                svg.DrawCircleSegment(0, 0, 10, 20, 0, 17, null, null);
                svg.DrawImage(null, 0, 0, 100, 100);
                svg.DrawPolygon(new ExtPointF[] {}, null, null);
                svg.DrawString("x", 10, 10);

                svg.ResetState();
                svg.SaveState();
                svg.RestoreState();

                svg.Rotate(75);
                svg.Translate(10, 10);
                svg.Scale(0.5f, 0.5f);
                svg.SetClippingRect(0.0f, 0.0f, 10f, 10f);

                svg.SetFont(null);
                Assert.Throws(typeof(ArgumentNullException), () => { svg.SetColor(null); });

                svg.BeginLines(false);
                svg.EndLines();

                svg.EndDrawing();
            }
        }
Exemple #2
0
        public override void SetSVGMode(bool active, string svgFileName, int width, int height)
        {
            if (active)
            {
                fSVGWriter = new StreamWriter(new FileStream(svgFileName, FileMode.Create), Encoding.UTF8);
                fSVGGfx    = new SvgGraphics(fSVGWriter, ExtRectF.CreateBounds(0, 0, width, height));
                fSVGGfx.BeginDrawing();
            }
            else
            {
                if (fSVGWriter != null)
                {
                    fSVGGfx.EndDrawing();
                    fSVGGfx = null;

                    fSVGWriter.Flush();
                    fSVGWriter.Close();
                    fSVGWriter = null;
                }
            }
        }