Esempio n. 1
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            var root = new SvgSvgElement("4in", "4in", "-10,-10 250,250");

            //adding multiple children

            root.AddChildren(
                new SvgRectElement(5, 5, 5, 5),
                new SvgEllipseElement(20, 20, 8, 12)
            {
                Style = "fill:yellow;stroke:red"
            },

                new SvgAElement("https://github.com/managed-commons/SvgNet").AddChildren(
                    new SvgTextElement("Textastic!", 30, 20)
            {
                Style = "fill:midnightblue;stroke:navy;stroke-width:1px;font-size:30px;font-family:Calibri"
            })
                );

            //group and path

            var grp = new SvgGroupElement("green_group")
            {
                Style = "fill:green;stroke:black;"
            };

            grp.AddChild(new SvgRectElement(30, 30, 5, 20));

            var ell = new SvgEllipseElement
            {
                CX = 50,
                CY = 50,
                RX = 10,
                RY = 20
            };

            var pathy = new SvgPathElement
            {
                D     = "M 20,80 C 20,90 30,80 70,100 C 70,100 40,60 50,60 z",
                Style = ell.Style
            };

            root.AddChild(grp);

            //cloning and style arithmetic

            grp.AddChildren(ell, pathy);

            grp.Style.Set("fill", "blue");

            var grp2 = (SvgGroupElement)SvgFactory.CloneElement(grp);

            grp2.Id = "cloned_red_group";

            grp2.Style.Set("fill", "red");

            grp2.Style += "opacity:0.5";

            grp2.Transform = "scale (1.2, 1.2)  translate(10)";

            root.AddChild(grp2);

            //output

            string s = root.WriteSVGString(true);

            tbOut.Text = s;

            string tempFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.svg");

            using (var tw = new StreamWriter(tempFile, false))
                tw.Write(s);

            svgOut.Navigate(new Uri(tempFile));
            svgOut.Refresh(WebBrowserRefreshOption.Completely);
        }
Esempio n. 2
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            SvgSvgElement root = new SvgSvgElement("4in", "4in", "0,0 100,100");

            //adding multiple children

            root.AddChildren(
                new SvgRectElement(5, 5, 5, 5),
                new SvgEllipseElement(30, 10, 8, 12),
                new SvgTextElement("Textastic!", 3, 20)
                );

            //group and path

            SvgGroupElement grp = new SvgGroupElement("green_group")
            {
                Style = "fill:green;stroke:black;"
            };

            SvgEllipseElement ell = new SvgEllipseElement {
                CX = 50,
                CY = 50,
                RX = 10,
                RY = 20
            };

            SvgPathElement pathy = new SvgPathElement {
                D     = "M 20,80 C 20,90 30,80 70,100 C 70,100 40,60 50,60 z",
                Style = ell.Style
            };

            root.AddChild(grp);

            //cloning and style arithmetic

            grp.AddChildren(ell, pathy);

            grp.Style.Set("fill", "blue");

            SvgGroupElement grp2 = (SvgGroupElement)SvgFactory.CloneElement(grp);

            grp2.Id = "cloned_red_group";

            grp2.Style.Set("fill", "red");

            grp2.Style += "opacity:0.5";

            grp2.Transform = "scale (1.2, 1.2)  translate(10)";

            root.AddChild(grp2);

            //output

            string s = root.WriteSVGString(true);

            tbOut.Text = s;

            string tempFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.svg");

            StreamWriter tw = new StreamWriter(tempFile, false);

            tw.Write(s);

            tw.Close();

            svgOut.Navigate(new Uri(tempFile));
            svgOut.Refresh(WebBrowserRefreshOption.Completely);
        }
Esempio n. 3
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            SvgSvgElement root = new SvgSvgElement("4in", "4in", "0,0 100,100");


            //adding multiple children

            root.AddChildren(
                new SvgRectElement(5, 5, 5, 5),
                new SvgEllipseElement(30, 10, 8, 12),
                new SvgTextElement("Textastic!", 3, 20)
                );


            //group and path

            SvgGroupElement grp = new SvgGroupElement("green_group");

            grp.Style = "fill:green;stroke:black;";

            SvgEllipseElement ell = new SvgEllipseElement();

            ell.CX = 50;
            ell.CY = 50;
            ell.RX = 10;
            ell.RY = 20;

            SvgPathElement pathy = new SvgPathElement();

            pathy.D     = "M 20,80 C 20,90 30,80 70,100 C 70,100 40,60 50,60 z";
            pathy.Style = ell.Style;

            root.AddChild(grp);


            //cloning and style arithmetic

            grp.AddChildren(ell, pathy);

            grp.Style.Set("fill", "blue");

            SvgGroupElement grp2 = (SvgGroupElement)SvgFactory.CloneElement(grp);

            grp2.Id = "cloned_red_group";

            grp2.Style.Set("fill", "red");

            grp2.Style += "opacity:0.5";

            grp2.Transform = "scale (1.2, 1.2)  translate(10)";

            root.AddChild(grp2);


            //output

            string s = root.WriteSVGString(true);

            tbOut.Text = s;

            StreamWriter tw = new StreamWriter("c:\\temp\\foo.svg", false);

            tw.Write(s);

            tw.Close();

            svgOut.SRC = "c:\\temp\\foo.svg";
        }