예제 #1
0
        public override void RenderObject(Graphics g, DrawContext dcxt)
        {
            GraphicsPath path = new GraphicsPath();
            foreach (Object ch in pathes)
            {
                if (ch is VectorPathLine)
                {
                    VectorPathLine vpl = (VectorPathLine)ch;
                    path.AddLine(dcxt.X_V2S(vpl.x1), dcxt.Y_V2S(vpl.y1), dcxt.X_V2S(vpl.x2), dcxt.Y_V2S(vpl.y2));
                }
                else if (ch is VectorPathArc)
                {
                    VectorPathArc vpa = (VectorPathArc)ch;
                    path.AddArc(dcxt.X_V2S(vpa.x - vpa.w / 2), dcxt.Y_V2S(vpa.y - vpa.h/2), dcxt.W_V2S(vpa.w), dcxt.H_V2S(vpa.h), vpa.startagl, vpa.sweepagl);
                }
                else if (ch is VectorPathPie)
                {
                    VectorPathPie vpp = (VectorPathPie)ch;
                    path.AddArc(dcxt.X_V2S(vpp.x - vpp.w / 2), dcxt.Y_V2S(vpp.y - vpp.h/2), dcxt.W_V2S(vpp.w), dcxt.H_V2S(vpp.h), vpp.startagl, vpp.sweepagl);
                }
            }

            if (fill)
                g.FillPath(BrushWhenCxt(dcxt).Brush, path);
            else
                g.DrawPath(PenWhenCxt(dcxt).Pen, path);
        }
예제 #2
0
 public override XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
 {
     XmlElement box = dom.CreateElement("rect");
     box.SetAttribute("x", "" + dcxt.X_V2S(x));
     box.SetAttribute("y", "" + dcxt.Y_V2S(y));
     box.SetAttribute("width", "" + dcxt.W_V2S(w));
     box.SetAttribute("height", "" + dcxt.H_V2S(h));
     if (fill)
         box.SetAttribute("style", VectorSvgUtils.Brush2Style(BrushWhenCxt(dcxt).Brush));
     else
         box.SetAttribute("style", VectorSvgUtils.Pen2Style(PenWhenCxt(dcxt).Pen) + "fill:none;");
     return box;
 }
예제 #3
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     g.DrawString(text, FontWhenCxt(dcxt).Font, BrushWhenCxt(dcxt).Brush, dcxt.X_V2S(x), dcxt.Y_V2S(y));
 }
예제 #4
0
 public virtual XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
 {
     System.Diagnostics.Debug.WriteLine("ExportSVG fail: " + this.GetType().Name);
     return null;
 }
예제 #5
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     if (fill)
         g.FillPie(BrushWhenCxt(dcxt).Brush, dcxt.X_V2S(x-w/2), dcxt.Y_V2S(y-h/2), dcxt.W_V2S(w), dcxt.W_V2S(h), startagl, sweepagl);
     else
         g.DrawPie(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x - w / 2), dcxt.Y_V2S(y - h / 2), dcxt.W_V2S(w), dcxt.W_V2S(h), startagl, sweepagl);
 }
예제 #6
0
        public override XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
        {
            XmlElement text = dom.CreateElement("text");
            String style = VectorSvgUtils.Brush2Style(BrushWhenCxt(dcxt).Brush) + "font-size:" + FontWhenCxt(dcxt).Font.Size+";";
            text.SetAttribute("x", "" + dcxt.X_V2S(x));
            text.SetAttribute("y", "" + dcxt.Y_V2S(y + FontWhenCxt(dcxt).Font.Size + 2));
            //text.SetAttribute("y", "" + dcxt.Y_V2S(y));

            text.SetAttribute("style", style);
            if (this.text.Contains("\n"))
            {
                if (G == null)
                    G = Graphics.FromImage(new Bitmap(1, 1));
                Font font = FontWhenCxt(dcxt).Font;
                SizeF sf = new SizeF(0, 0);
                foreach (String l in this.text.Split('\n'))
                {
                    XmlElement xl = dom.CreateElement("tspan");
                    xl.SetAttribute("dx", "-" + dcxt.W_V2S(sf.Width));
                    xl.SetAttribute("dy", ""+ dcxt.H_V2S(sf.Height));
                    sf = G.MeasureString(l, font);
                    xl.InnerText = l;
                    text.AppendChild(xl);
                }
            }
            else
            {
                text.InnerText = this.text;
            }
            return text;
        }
예제 #7
0
 public virtual void RenderObject(Graphics g, DrawContext dcxt)
 {
     throw new Exception("VectorObject����δʵ����Ⱦ");
 }
예제 #8
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     g.DrawArc(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x - w / 2), dcxt.Y_V2S(y - h / 2), dcxt.W_V2S(w), dcxt.W_V2S(h), startagl, sweepagl);
 }
예제 #9
0
 public override XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
 {
     XmlElement circle = dom.CreateElement("ellipse");
     circle.SetAttribute("cx", "" + dcxt.X_V2S(x));
     circle.SetAttribute("cy", "" + dcxt.Y_V2S(y));
     circle.SetAttribute("rx", "" + dcxt.W_V2S(w/2));
     circle.SetAttribute("ry", "" + dcxt.H_V2S(h/2));
     if (fill)
         circle.SetAttribute("style", VectorSvgUtils.Brush2Style(BrushWhenCxt(dcxt).Brush));
     else
         circle.SetAttribute("style", VectorSvgUtils.Pen2Style(PenWhenCxt(dcxt).Pen) + "fill:none;");
     return circle;
 }
예제 #10
0
 public ContextPen PenWhenCxt(DrawContext dcxt)
 {
     return Pen.ScaleTo(dcxt.Scale * ScaleWeight);
 }
예제 #11
0
 public ContextBrush BrushWhenCxt(DrawContext dcxt)
 {
     return this.Brush;
 }
예제 #12
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     if (fill)
         g.FillRectangle(BrushWhenCxt(dcxt).Brush, dcxt.X_V2S(x), dcxt.Y_V2S(y), dcxt.W_V2S(w), dcxt.W_V2S(h));
     else
         g.DrawRectangle(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x), dcxt.Y_V2S(y), dcxt.W_V2S(w), dcxt.W_V2S(h));
 }
예제 #13
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     g.DrawLine(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x1), dcxt.Y_V2S(y1), dcxt.X_V2S(x2), dcxt.Y_V2S(y2));
 }
예제 #14
0
 public override XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
 {
     XmlElement line = dom.CreateElement("line");
     // <line x1="0" y1="0" x2="300" y2="300" style="stroke:rgb(99,99,99);stroke-width:2"/>
     line.SetAttribute("x1", "" + dcxt.X_V2S(x1));
     line.SetAttribute("y1", "" + dcxt.Y_V2S(y1));
     line.SetAttribute("x2", "" + dcxt.X_V2S(x2));
     line.SetAttribute("y2", "" + dcxt.Y_V2S(y2));
     line.SetAttribute("style", VectorSvgUtils.Pen2Style(PenWhenCxt(dcxt).Pen));
     return line;
 }
예제 #15
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     DrawContext ndcxt = new DrawContext(dcxt.Scale, dcxt.X_V2S(x), dcxt.Y_V2S(y));
     foreach (VectorObject vo in Children)
     {
         if(vo.Display)
             vo.RenderObject(g, ndcxt);
     }
 }
예제 #16
0
 public override XmlElement ExportSvg(XmlDocument dom, DrawContext dcxt)
 {
     DrawContext ndcxt = new DrawContext(dcxt.Scale, dcxt.X_V2S(x), dcxt.Y_V2S(y));
     XmlElement ele = dom.CreateElement("g");
     foreach (VectorObject vo in Children)
     {
         XmlElement cle = vo.ExportSvg(dom, ndcxt);
         if (cle != null)
             ele.AppendChild(cle);
     }
     return ele;
 }
예제 #17
0
 public override void RenderObject(Graphics g, DrawContext dcxt)
 {
     if (fill)
         g.FillEllipse(BrushWhenCxt(dcxt).Brush, dcxt.X_V2S(x - w / 2), dcxt.Y_V2S(y - h / 2), dcxt.W_V2S(w), dcxt.H_V2S(h));
     else
         g.DrawEllipse(PenWhenCxt(dcxt).Pen, dcxt.X_V2S(x - w / 2), dcxt.Y_V2S(y - h / 2), dcxt.W_V2S(w), dcxt.H_V2S(h));
 }
예제 #18
0
        public XmlElement GenSVG(String filename)
        {
            XmlDocument dom = new XmlDocument();
            XmlElement svg = dom.CreateElement("svg");
            svg.SetAttribute("xmlns", "http://www.w3.org/2000/svg");
            // dom.AppendChild(dom);

            // DrawContext dcxt = new DrawContext(1, 0, 0);
            DrawContext dc = new DrawContext();
            foreach (VectorObject vo in this.VectorObjects)
            {
                XmlElement ele = vo.ExportSvg(dom, dc);
                if (ele != null)
                    svg.AppendChild(ele);
            }
            dom.AppendChild(svg);
            dom.Save(filename);
            return svg;
        }
예제 #19
0
 public ContextFont FontWhenCxt(DrawContext dcxt)
 {
     return Font.ScaleTo(dcxt.Scale * ScaleWeight);
 }