Esempio n. 1
0
 private int Break(SvgElement graph, SvgElement parent, XmlNode next)
 {
     if (graph is Group)
     {
         if (graph is Text)
         {
             Graphics graphics1 = base.CreateGraphics();
             SvgElementCollection collection1 = ((Text) graph).Break(graphics1);
             graphics1.Dispose();
             SvgElementCollection.ISvgElementEnumerator enumerator1 = collection1.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 SvgElement element1 = (SvgElement) enumerator1.Current;
                 this.svgDocument.NumberOfUndoOperations++;
                 element1.ID = CodeFunc.CreateString(this.svgDocument, "text");
                 ISvgBrush brush1 = ((IGraphPath) element1).GraphBrush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text1 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "fill", "url(#" + text1 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text1);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 brush1 = ((IGraphPath) element1).GraphStroke.Brush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text2 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "stroke", "url(#" + text2 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text2);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 if (next == null)
                 {
                     parent.AppendChild(element1);
                     continue;
                 }
                 parent.InsertBefore(element1, next);
             }
             this.svgDocument.NumberOfUndoOperations++;
             graph.ParentNode.RemoveChild(graph);
         }
         else
         {
             SvgElementCollection collection2 = ((Group) graph).GraphList.Clone();
             for (int num1 = collection2.Count - 1; num1 >= 0; num1--)
             {
                 SvgElement element2 = (SvgElement) collection2[num1];
                 Matrix matrix1 = new Matrix();
                 Matrix matrix2 = new Matrix();
                 if (element2 is IGraph)
                 {
                     if (graph.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix1 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     if (element2.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix2 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     matrix1.Multiply(matrix2);
                     Transf transf1 = new Transf();
                     transf1.setMatrix(matrix1);
                     AttributeFunc.SetAttributeValue(element2, "transform", transf1.ToString());
                 }
                 this.Break(element2, parent, next);
             }
             graph.ParentNode.RemoveChild(graph);
         }
         return 1;
     }
     if ((graph is IGraph) && (graph.ParentNode != parent))
     {
         this.svgDocument.NumberOfUndoOperations += 2;
         if (next != null)
         {
             parent.InsertBefore(graph.Clone(), next);
         }
         else
         {
             parent.PrependChild(graph.Clone());
         }
         return 0;
     }
     return 0;
 }
Esempio n. 2
0
        private void addChild(SvgElement element,Group symbol)
        {
            if(element is Use)
            {

                SvgElementCollection list = ((element as Use).RefElement as Symbol).GraphList;
                Use use =element as Use;
                Matrix matrix1 = new Matrix();
                if (use.SvgAttributes.ContainsKey("transform"))
                {
                    matrix1 = use.SvgAttributes["transform"] as Matrix;
                    matrix1 = matrix1.Clone();
                }
                matrix1.Translate(use.X,use.Y);

                Group g = this.svgDocument.CreateElement("g") as Group;
                g.SetAttribute("transform",new Transf(matrix1).ToString());
                foreach(SvgElement graph in list)
                {
                    addChild(graph,g);
                }
                symbol.AppendChild(g);
            }
            else
            {
                if(element is ConnectLine)
                {
                    ConnectLine cline = element as ConnectLine;
                    PointF point1 = cline.Points[0];
                    PointF point2 = cline.Points[1];

                    SvgElement element2= element.CloneNode(true) as SvgElement;

                    element2.RemoveAttribute("transform");
                    element2.RemoveAttribute("layer");

                    element2.RemoveAttribute("start");
                    element2.RemoveAttribute("end");
                    element2.SetAttribute("x1",""+point1.X);
                    element2.SetAttribute("y1",""+point1.Y);
                    element2.SetAttribute("x2",""+point2.X);
                    element2.SetAttribute("y2",""+point2.Y);

                    symbol.PrependChild(element2);
                }
                else
                {
                    SvgElement element2=element.Clone() as SvgElement;
                    element2.RemoveAttribute("layer");
                    symbol.AppendChild(element2);
                }
            }
        }