예제 #1
0
        public static DrawObject Create(SVGImage svg)
        {
            try
            {
                DrawImageObject dobj;
                if (string.IsNullOrEmpty(svg.Id))
                {
                    dobj = new DrawImageObject(svg.HRef, ParseSize(svg.X, Dpi.X),
                                               ParseSize(svg.Y, Dpi.Y),
                                               ParseSize(svg.Width, Dpi.X),
                                               ParseSize(svg.Height, Dpi.Y));
                }
                else
                {
                    var di = new DrawImageObject();
                    if (!di.FillFromSvg(svg))
                    {
                        return(null);
                    }
                    dobj = di;
                }

                return(dobj);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawImageObject", "Create", ex.ToString(), SVGErr._LogPriority.Info);
                return(null);
            }
        }
예제 #2
0
 public bool FillFromSvg(SVGImage svg)
 {
     try
     {
         float x = ParseSize(svg.X, Dpi.X);
         float y = ParseSize(svg.Y, Dpi.Y);
         float w = ParseSize(svg.Width, Dpi.X);
         float h = ParseSize(svg.Height, Dpi.Y);
         RectangleF = new RectangleF(x, y, w, h);
         _fileName  = svg.HRef;
         _id        = svg.Id;
         try
         {
             _image = Image.FromFile(_fileName);
             return(true);
         }
         catch (Exception ex)
         {
             SVGErr.Log("DrawImageObject", "FillFromSvg", ex.ToString(), SVGErr._LogPriority.Info);
             return(false);
         }
     }
     catch (Exception ex0)
     {
         SVGErr.Log("DrawImageObject", "FillFromSvg", ex0.ToString(), SVGErr._LogPriority.Info);
         return(false);
     }
 }
예제 #3
0
        public static DrawPathObject Create(SVGPath svp)
        {
            DrawPathObject dp;

            try
            {
                string s = svp.PathData.Trim();
                s = s.Replace("\r", "");
                s = s.Replace("\n", " ");
                s = s.Trim();
                string[] arr = s.Split(' ');

                dp = new DrawPathObject(arr)
                {
                    Name = svp.ShapeName
                };
                dp.SetStyleFromSvg(svp);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPathObject", "Create", ex.ToString(), SVGErr._LogPriority.Info);
                dp = null;
            }

            return(dp);
        }
예제 #4
0
 public override void Draw(Graphics g)
 {
     try
     {
         g.SmoothingMode = SmoothingMode.AntiAlias;
         var    pen        = new Pen(Stroke, StrokeWidth);
         PointF centerTemp = GetCenter();
         if (Parent != null)//表示有设备父实体 则要求应用
         {
             var worldObj   = GetWorldDrawObject();
             var drawPoint1 = worldObj._startPoint;
             var drawPoint2 = worldObj._endPoint;
             //最终绘画
             g.DrawLine(pen, drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y);
             pen.Dispose();
         }
         else
         {
             var drawPoint1 = RotatePoint(centerTemp,
                                          new PointF(_startPoint.X + centerTemp.X, _startPoint.Y + centerTemp.Y), _angle);
             var drawPoint2 = RotatePoint(centerTemp, new PointF(_endPoint.X + centerTemp.X, _endPoint.Y + centerTemp.Y), _angle);
             ;
             g.DrawLine(pen, drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y);
             pen.Dispose();
         }
     }
     catch (Exception ex)
     {
         SVGErr.Log("DrawLine", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
     }
 }
예제 #5
0
        public override void Draw(Graphics g)
        {
            PointF p0 = new PointF();
            PointF p1 = new PointF();
            PointF p2 = new PointF();

            GraphicsPath gp = new GraphicsPath();

            try
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                Pen pen = new Pen(Stroke, StrokeWidth);
                //pen.Color = Color.Black;

                Brush       br         = new SolidBrush(Fill);
                IEnumerator enumerator = _pointArray.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    switch (((PathCommands)enumerator.Current).Pc)
                    {
                    case 'M':
                        p1 = ((PathCommands)enumerator.Current).P;
                        //gp.CloseFigure();

                        gp.StartFigure();
                        //p0 = p1;
                        break;

                    case 'L':
                        p2 = ((PathCommands)enumerator.Current).P;
                        gp.AddLine(p1, p2);
                        p1 = p2;
                        break;

                    case 'Z':
                        p2 = ((PathCommands)enumerator.Current).P;
                        gp.AddLine(p1, p2);
                        //gp.CloseFigure();
                        break;

                    default:
                        break;
                    }
                }

                g.FillPath(br, gp);
                g.DrawPath(pen, gp);
                _lastGp = gp;

                pen.Dispose();
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPolygon", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
            }

            //base.Draw(g);
        }
예제 #6
0
        public bool SetStyleFromSvg(SVGText svg)
        {
            try
            {
                float x = ParseSize(svg.X, Dpi.X);
                float y = ParseSize(svg.Y, Dpi.Y);
                float w = ParseSize(svg.Width, Dpi.X);
                float h = ParseSize(svg.Height, Dpi.Y);
                Text = svg.Value;
                //font
                Stroke = svg.Fill;
                string family = svg.FontFamily;
                float  size   = ParseSize(svg.FontSize, Dpi.X);
                int    fs     = 0;
                if (svg.FontWeight.IndexOf("bold") >= 0)
                {
                    fs = 1;
                }
                if (svg.FontStyle.IndexOf("italic") >= 0)
                {
                    fs = fs | 2;
                }
                Font = new Font(family, size, (FontStyle)fs);
                //				y -= font.Size;
                y         -= Font.Height;
                RectangleF = new RectangleF(x, y, w, h);
                if (svg.TextAnchor.Length > 0)
                {
                    switch (svg.TextAnchor)
                    {
                    case "start":
                        TextAnchor.Alignment = StringAlignment.Near;
                        break;

                    case "end":
                        TextAnchor.Alignment = StringAlignment.Far;
                        RectangleF           = new RectangleF(x - w, y, w, h);
                        break;

                    case "middle":
                        TextAnchor.Alignment = StringAlignment.Center;
                        RectangleF           = new RectangleF(x - w / 2, y, w, h);
                        break;
                    }
                }
                return(true);
            }
            catch
            {
                SVGErr.Log("DrawText", "SetStyleFromSvg", "SetStyleFromSvg", SVGErr._LogPriority.Info);
                return(false);
            }
        }
예제 #7
0
        public override void Draw(Graphics g)
        {
            try
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                var pen = new Pen(Stroke, StrokeWidth);
                //if(_startPoint.X > _endPoint.X)
                //{
                //    var temp = _startPoint;
                //    _startPoint = _endPoint;
                //    _endPoint = temp;
                //}
                //g.DrawLine(pen, _startPoint.X, _startPoint.Y, _endPoint.X, _endPoint.Y);
                if (_startObject != null)
                {
                    _startPoint = _startObject.GetHandle(_startobjecthandle);
                }
                if (_endObject != null)
                {
                    _endPoint = _endObject.GetHandle(_endobjecthandle);
                }

                if (_startPoint.Y > _middlePoint.Y)
                {
                    _middlePoint.Y = _startPoint.Y;
                }
                if (_startPoint.X > _middlePoint.X)
                {
                    _middlePoint.X = _startPoint.X;
                }
                if (_endPoint.Y < _middlePoint.Y)
                {
                    _middlePoint.Y = _endPoint.Y;
                }
                if (_endPoint.X < _middlePoint.X)
                {
                    _middlePoint.X = _endPoint.X;
                }

                g.DrawLine(pen, _startPoint.X, _startPoint.Y, _middlePoint.X, _startPoint.Y);
                g.DrawLine(pen, _middlePoint.X, _startPoint.Y, _middlePoint.X, _endPoint.Y);
                g.DrawLine(pen, _middlePoint.X, _endPoint.Y, _endPoint.X, _endPoint.Y);

                pen.Dispose();
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawLine", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #8
0
        public DrawImageObject(string fileName, float x, float y, float width, float height)
        {
            InitBox();
            _fileName = fileName;
            try
            {
                _image = Image.FromFile(fileName);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawArea", "DrawImageObject", ex.ToString(), SVGErr._LogPriority.Info);
            }

            RectangleF = new RectangleF(x, y, width, height);
            Initialize();
        }
예제 #9
0
        public override void Draw(Graphics g)
        {
            float x1 = 0, y1 = 0;     // previous point

            try
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                if (Fill != Color.Empty)
                {
                    var arr = new PointF[_pointArray.Count];
                    for (int i = 0; i < _pointArray.Count; i++)
                    {
                        arr[i] = (PointF)_pointArray[i];
                    }
                    Brush brush = new SolidBrush(Fill);
                    g.FillPolygon(brush, arr);
                }

                var pen = new Pen(Stroke, StrokeWidth);

                IEnumerator enumerator = _pointArray.GetEnumerator();

                if (enumerator.MoveNext())
                {
                    x1 = ((PointF)enumerator.Current).X;
                    y1 = ((PointF)enumerator.Current).Y;
                }

                while (enumerator.MoveNext())
                {
                    float x2 = ((PointF)enumerator.Current).X;             // current point
                    float y2 = ((PointF)enumerator.Current).Y;             // current point

                    g.DrawLine(pen, x1, y1, x2, y2);

                    x1 = x2;
                    y1 = y2;
                }

                pen.Dispose();
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPolygon", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #10
0
        public override void Draw(Graphics g)
        {
            if (RectangleF.Width == 0 || RectangleF.Height == 0)
            {
                RectangleF = CalcSize(g, Text, Font, RectangleF.X, RectangleF.Y, TextAnchor);
            }
            Brush brush = new SolidBrush(Stroke);

            try
            {
                g.DrawString(Text, Font, brush, RectangleF, TextAnchor);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawText", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #11
0
 public static DrawLineObject Create(SVGLine svg)
 {
     try
     {
         var dobj = new DrawLineObject(ParseSize(svg.X1, Dpi.X),
                                       ParseSize(svg.Y1, Dpi.Y),
                                       ParseSize(svg.X2, Dpi.X),
                                       ParseSize(svg.Y2, Dpi.Y));
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         SVGErr.Log("CreateLine", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #12
0
 public static DrawEllipseObject Create(SVGEllipse svg)
 {
     try
     {
         float cx   = ParseSize(svg.CX, Dpi.X);
         float cy   = ParseSize(svg.CY, Dpi.Y);
         float rx   = ParseSize(svg.RX, Dpi.X);
         float ry   = ParseSize(svg.RY, Dpi.Y);
         var   dobj = new DrawEllipseObject(cx - rx, cy - ry, rx * 2, ry * 2);
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         SVGErr.Log("DrawEllipse", "CreateRectangle", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #13
0
        // ---------- PUBLIC METHODS END

        // ---------- PRIVATE METHODS

        protected SVGUnit(SVGWord doc)
        {
            SVGErr.Log("SvgElement", "SvgElement", "Element created", SVGErr._LogPriority.Info);

            m_doc = doc;

            m_attributes = new ArrayList();

            AddAttr(SVGAttribute._SvgAttribute.attrCore_Id, null);

            m_Parent   = null;
            m_Child    = null;
            m_Next     = null;
            m_Previous = null;

            m_sElementName  = "unsupported";
            m_sElementValue = "";
            m_bHasValue     = false;
            m_ElementType   = SVGUnitType.typeUnsupported;
        }
예제 #14
0
        protected override void CreateObjects()
        {
            if (AreaPath != null)
            {
                return;
            }
            try
            {
                AreaPath = new GraphicsPath();

                float x1 = 0, y1 = 0;     // previous point

                IEnumerator enumerator = _pointArray.GetEnumerator();

                if (enumerator.MoveNext())
                {
                    x1 = ((PointF)enumerator.Current).X;
                    y1 = ((PointF)enumerator.Current).Y;
                }

                while (enumerator.MoveNext())
                {
                    float x2 = ((PointF)enumerator.Current).X;             // current point
                    float y2 = ((PointF)enumerator.Current).Y;             // current point

                    AreaPath.AddLine(x1, y1, x2, y2);

                    x1 = x2;
                    y1 = y2;
                }

                AreaPath.CloseFigure();

                // Create region from the path
                AreaRegion = new Region(AreaPath);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPolygon", "Create", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #15
0
 /// <summary>
 /// 从字节数组获取图像对象
 /// </summary>
 public static Image ImageFromBytes(byte[] arrb)
 {
     if (arrb == null)
     {
         return(null);
     }
     try
     {
         // Perform the conversion
         var       ms     = new MemoryStream();
         const int offset = 0;
         ms.Write(arrb, offset, arrb.Length - offset);
         Image im = new Bitmap(ms);
         ms.Close();
         return(im);
     }
     catch (Exception ex)
     {
         SVGErr.Log("DrawImageObjecte", "ImageFromBytes", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #16
0
 public static DrawTextObject Create(SVGText svg)
 {
     if (string.IsNullOrEmpty(svg.Value))
     {
         return(null);
     }
     try
     {
         var dobj = new DrawTextObject(ParseSize(svg.X, Dpi.X),
                                       ParseSize(svg.Y, Dpi.Y))
         {
             Text = svg.Value
         };
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         SVGErr.Log("DrawText", "DrawText", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #17
0
        public override void Draw(Graphics g)
        {
            try
            {
                if (_reload)
                {
                    _image  = ImageFromBytes(ReadPngMemImage(_fileName));
                    Width   = _image.Width;
                    Height  = _image.Height;
                    _reload = false;
                }

                if (_image != null)
                {
                    if (hasRotation)
                    {
                        fixedCenter = GetCenter();
                        hasRotation = false;
                    }
                    PointF center = fixedCenter;
                    g.TranslateTransform(center.X, center.Y);
                    g.RotateTransform(-_angle);
                    g.TranslateTransform(-center.X, -center.Y);

                    g.DrawImage(_image, RectangleF);

                    g.ResetTransform();
                }

                else
                {
                    base.Draw(g);
                }
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawImageObject", "Draw", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #18
0
        /// <summary>
        /// 鼠标-调整新多边形的大小
        /// </summary>
        public override void OnMouseMove(DrawArea drawArea, MouseEventArgs e)
        {
            drawArea.Cursor = Cursor;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (_newPolygon == null)
            {
                return;                 // precaution
            }
            var point    = new Point(e.X, e.Y);
            int distance = (e.X - _lastX) * (e.X - _lastX) + (e.Y - _lastY) * (e.Y - _lastY);

            try
            {
                if (distance < MinDistance)
                {
                    //最后两点之间的距离小于最小值-
                    //移动最后一个点
                    _newPolygon.MoveHandleTo(point, _newPolygon.HandleCount);
                }
                else
                {
                    // 添加新点
                    _newPolygon.AddPoint(point);
                    _lastX = e.X;
                    _lastY = e.Y;
                }
                drawArea.Refresh();
            }
            catch (Exception ex)
            {
                SVGErr.Log("ToolPolygon", "OnMouse", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #19
0
 public static DrawPolygonObject Create(SVGPolyline svg)
 {
     try
     {
         string   s      = svg.Points.Trim();
         string[] arr    = s.Split(' ');
         var      points = new PointF[arr.Length];
         for (int i = 0; i < arr.Length; i++)
         {
             var arrp = arr[i].Split(',');
             points[i] = new PointF(ParseSize(arrp[0], Dpi.X),
                                    ParseSize(arrp[1], Dpi.Y));
         }
         var dobj = new DrawPolygonObject(points);
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         SVGErr.Log("DrawPolygonObject", "Create", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #20
0
 /// <summary>
 /// 将图像从文件加载到字节数组
 /// </summary>
 /// <param name="flnm">File name</param>
 /// <returns>byte array</returns>
 public static byte[] ReadPngMemImage(string flnm)
 {
     try
     {
         FileStream   fs = new FileStream(flnm, FileMode.Open, FileAccess.Read);
         MemoryStream ms = new MemoryStream();
         Bitmap       bm = new Bitmap(fs);
         bm.Save(ms, ImageFormat.Png);
         BinaryReader br = new BinaryReader(ms);
         ms.Position = 0;
         byte[] arrpic = br.ReadBytes((int)ms.Length);
         br.Close();
         fs.Close();
         ms.Close();
         return(arrpic);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error reading file " + ex, "");
         SVGErr.Log("DrawImageObjecte", "ReadPngMemImage", ex.ToString(), SVGErr._LogPriority.Info);
         return(null);
     }
 }
예제 #21
0
        /// <summary>
        /// 它返回从元素开始的SVG树的XML字符串。
        /// </summary>
        public string GetXML()
        {
            string sXML;

            sXML = OpenXMLTag();

            if (m_Child != null)
            {
                sXML += m_Child.GetXML();
            }

            sXML += CloseXMLTag();

            SVGUnit ele = m_Next;

            if (ele != null)
            {
                sXML += ele.GetXML();
            }

            SVGErr.Log("SvgElement", "GetXML", ElementInfo(), SVGErr._LogPriority.Info);

            return(sXML);
        }
예제 #22
0
        public DrawPathObject(String[] arr)
        {
            pathStr = arr;
            _x      = 0.0F;
            char currentCommand = new char();
            char nextCommand    = new char();

            _pointArray = new List <PathCommands>();
            init();

            try
            {
                for (int i = 0; i < arr.Length; i++)
                {
                    int idx;
                    if ((idx = arr[i].IndexOfAny(_commands)) >= 0)
                    {
                        if (idx == 0)
                        {
                            currentCommand = arr[i][idx];
                            arr[i]         = arr[i].Substring(1, arr[i].Length - 1);

                            if (!_gotX)
                            {
                                _xStr = arr[i];
                                _gotX = true;
                            }
                            else
                            {
                                _yStr = arr[i];
                                _gotY = true;
                            }
                        }
                        else if (idx == (arr[i].Length - 1))
                        {
                            currentCommand = arr[i][idx];
                            arr[i]         = arr[i].Substring(0, arr[i].Length - 1);

                            if (!_gotX)
                            {
                                _xStr = arr[i];

                                _gotX = true;
                            }
                            else
                            {
                                _yStr = arr[i];
                                _gotY = true;
                            }
                        }
                        else
                        {
                            _yStr       = arr[i].Substring(0, idx);
                            _xStrNxt    = arr[i].Substring(idx + 1, arr[i].Length - idx - 1);
                            nextCommand = arr[i][idx];
                            _gotX       = _gotY = true;
                        }
                    }
                    else
                    {
                        if (arr[i].Length > 0)
                        {
                            float t;
                            if (float.TryParse(arr[i], out t))
                            {
                                if (!_gotX)
                                {
                                    _xStr = arr[i];
                                    _gotX = true;
                                }
                                else
                                {
                                    _yStr = arr[i];
                                    _gotY = true;
                                }
                            }
                        }
                    }

                    if (_gotX && _gotY)
                    {
                        if (float.TryParse(_xStr, out _x))
                        {
                            if (float.TryParse(_yStr, out _y))
                            {
                                _pointArray.Add(new PathCommands(new PointF(_x, _y), currentCommand));
                            }
                        }

                        if (_xStrNxt?.Length > 0)
                        {
                            _xStr          = _xStrNxt;
                            _xStrNxt       = "";
                            currentCommand = nextCommand;
                            nextCommand    = '\0';

                            _gotX = true;
                            _gotY = false;
                        }
                        else
                        {
                            _gotY = _gotX = false;
                        }
                    }
                }

                //Now Change the last command to Z.
                //We wont care if it presnt in the actual.
                //We just need to close the figure
                _pointArray[_pointArray.Count - 1].Pc = 'Z';
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPathObject", "DrawPathObject", ex.ToString(), SVGErr._LogPriority.Info);
                MessageBox.Show("Error in SVGPath");
            }
        }
예제 #23
0
        protected override void CreateObjects()
        {
            if (AreaPath != null)
            {
                return;
            }
            try
            {
                // Create closed path which contains all polygon vertexes
                AreaPath = new GraphicsPath();
                var regionRectF = new RectangleF(0.0F, 0.0F, 0.0F, 0.0F);

                IEnumerator enumerator = _pointArray.GetEnumerator();

                if (enumerator.MoveNext())
                {
                    float x1 = ((PathCommands)enumerator.Current).P.X;     // previous point
                    float y1 = ((PathCommands)enumerator.Current).P.Y;     // previous point

                    regionRectF.X = x1;
                    regionRectF.Y = y1;

                    regionRectF.Width  = x1;
                    regionRectF.Height = y1;
                }

                while (enumerator.MoveNext())
                {
                    float x2 = ((PathCommands)enumerator.Current).P.X;             // current point
                    float y2 = ((PathCommands)enumerator.Current).P.Y;             // current point

                    if (regionRectF.X > x2)
                    {
                        regionRectF.X = x2;
                    }

                    if (regionRectF.Y > y2)
                    {
                        regionRectF.Y = y2;
                    }

                    if (regionRectF.Width < x2)
                    {
                        regionRectF.Width = x2;
                    }

                    if (regionRectF.Height < y2)
                    {
                        regionRectF.Height = y2;
                    }
                }

                regionRectF.Width  = regionRectF.Width - regionRectF.X;
                regionRectF.Height = regionRectF.Height - regionRectF.Y;
                if (regionRectF.Width < 1.0F)
                {
                    regionRectF.Width = 1.0F;
                }

                if (regionRectF.Height < 1.0F)
                {
                    regionRectF.Height = 1.0F;
                }

                // Create region from the path
                AreaRegion = new Region(regionRectF);
            }
            catch (Exception ex)
            {
                SVGErr.Log("DrawPath", "Create", ex.ToString(), SVGErr._LogPriority.Info);
            }
        }
예제 #24
0
        public bool LoadModelFromXml(string fileName)
        {
            var svgForm = new WorkspaceHolder {
                Dock = DockStyle.Fill, Name = fileName
            };

            svgForm.svgDrawForm.ToolDone      += OnToolDoneComplete;
            svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;

            svgForm.svgDrawForm.drawArea.Width  = 1600;
            svgForm.svgDrawForm.drawArea.Height = 900;

            XmlTextReader reader = null;

            //XmlReader reader = null;
            //var txt = File.ReadAllText(fileName);
            try
            {
                // FileStream fs = new FileStream(fileName,FileMode.Open);


                //reader =  XmlReader.Create(fileName);
                reader = new XmlTextReader(fileName);//从本地读取xml文件

                SVGErr.Log("DrawArea", "LoadFromXML", "", SVGErr._LogPriority.Info);
                var svg = new SVGWord();
                if (!svg.LoadFromFile(reader))
                {
                    return(false);
                }
                SVGRoot root = svg.GetSvgRoot();

                if (root == null)
                {
                    return(false);
                }
                SVGUnit ele = root.getChild();
                if (ele != null)
                {
                    //1 收集symbol获取svg上的设备
                    //2 从svg元数据中收集symbol之间的关系
                    //3 将所有use的设备实体生成
                    //4 绘制list集合将图素绘制出来
                    SVGFactory.CreateProjectFromXML(ele, svgForm.svgDrawForm.drawArea.GraphicsList);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            tabbedView.Add(svgForm);
            svgForm.Refresh();

            return(true);
        }