示例#1
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)
         {
             ErrH.Log("DrawImage", "FillFromSvg", ex.ToString(), ErrH._LogPriority.Info);
             return(false);
         }
     }
     catch (Exception ex0)
     {
         ErrH.Log("DrawImage", "FillFromSvg", ex0.ToString(), ErrH._LogPriority.Info);
         return(false);
     }
 }
示例#2
0
        public static DrawPath Create(SvgPath svp)
        {
            DrawPath dp;

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

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

            return(dp);
        }
示例#3
0
 public override void Draw(Graphics g)
 {
     try
     {
         if (_reload)
         {
             _image  = ImageFromBytes(ReadPngMemImage(_fileName));
             Largura = _image.Width;
             Altura  = _image.Height;
             _reload = false;
         }
         if (_image != null)
         {
             g.DrawImage(_image, RectangleF);
         }
         else
         {
             base.Draw(g);
         }
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawImage", "Draw", ex.ToString(), ErrH._LogPriority.Info);
     }
 }
示例#4
0
 public static DrawObject Create(SvgImage svg)
 {
     try
     {
         DrawImage dobj;
         if (string.IsNullOrEmpty(svg.Id))
         {
             dobj = new DrawImage(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 DrawImage();
             if (!di.FillFromSvg(svg))
             {
                 return(null);
             }
             dobj = di;
         }
         return(dobj);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawImage", "Create", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#5
0
        protected void XnaToolUser_MouseMove(object sender, MouseEventArgs e)
        {
            //base.OnMouseMove(e);
            try
            {
                if (e.Button == MouseButtons.Left || e.Button == MouseButtons.None)
                {
                    if (_activeTool == Xna2dDrawToolType.Pan)
                    {
                        if (MousePan != null)
                        {
                            MousePan(sender, e);
                        }
                    }

                    var ind = (int)_activeTool;
                    _tools[ind].OnMouseMove(this, e);
                }
                else
                {
                    Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawArea", "DrawArea_MouseMove", ex.ToString(), ErrH._LogPriority.Info);
                Cursor = Cursors.Default;
            }
        }
示例#6
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)
            {
                ErrH.Log("DrawPolygon", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }

            //base.Draw(g);
        }
示例#7
0
        public static float ParseSize(string str, float dpi)
        {
            float koef = 1;
            int   ind  = str.IndexOf("pt");

            if (ind == -1)
            {
                ind = str.IndexOf("px");
            }
            if (ind == -1)
            {
                ind = str.IndexOf("pc");
            }
            if (ind == -1)
            {
                ind = str.IndexOf("cm");
                if (ind > 0)
                {
                    koef = dpi / 2.54f;
                }
            }
            if (ind == -1)
            {
                ind = str.IndexOf("mm");
                if (ind > 0)
                {
                    koef = dpi / 25.4f;
                }
            }
            if (ind == -1)
            {
                ind = str.IndexOf("in");
                if (ind > 0)
                {
                    koef = dpi;
                }
            }
            if (ind > 0)
            {
                str = str.Substring(0, ind);
            }
            str = RemoveAlphas(str);
            try
            {
                float res = float.Parse(str, CultureInfo.InvariantCulture);
                if (koef != 1.1)
                {
                    res *= koef;
                }
                return(res);
            }
            catch (Exception ex)
            {
                ErrH.Log("ParseFloat()", "DrawObject", ex.ToString(), ErrH._LogPriority.Info);
                return(0);
            }
        }
示例#8
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 = Color.FromNonPremultiplied(svg.Fill.R, svg.Fill.G, svg.Fill.B, svg.Fill.A);
                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 = XnaDrawing.defaultFont;
                //new System.Drawing.Font(family,size,(System.Drawing.FontStyle )fs);
                //				y -= font.Size;
                y        -= Font.MeasureString("T").Y;
                Rectangle = new Rectangle((int)x, (int)y, (int)w, (int)h);
                if (svg.TextAnchor.Length > 0)
                {
                    switch (svg.TextAnchor)
                    {
                    case "start":
                        TextAnchor.Alignment = System.Drawing.StringAlignment.Near;
                        break;

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

                    case "middle":
                        TextAnchor.Alignment = System.Drawing.StringAlignment.Center;
                        Rectangle            = new Rectangle((int)(x - w / 2), (int)y, (int)w, (int)h);
                        break;
                    }
                }
                return(true);
            }
            catch
            {
                ErrH.Log("DrawText", "SetStyleFromSvg", "SetStyleFromSvg", ErrH._LogPriority.Info);
                return(false);
            }
        }
示例#9
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
            {
                ErrH.Log("DrawText", "SetStyleFromSvg", "SetStyleFromSvg", ErrH._LogPriority.Info);
                return(false);
            }
        }
 public override bool IntersectsWith(RectangleF rect)
 {
     try
     {
         return(RectangleF.IntersectsWith(rect));
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawRectangle", "Intersect", ex.ToString(), ErrH._LogPriority.Info);
         return(false);
     }
 }
示例#11
0
 public override void Draw(Graphics g)
 {
     try
     {
         g.SmoothingMode = SmoothingMode.AntiAlias;
         var pen = new Pen(Stroke, StrokeWidth);
         g.DrawLine(pen, _startPoint.X, _startPoint.Y, _endPoint.X, _endPoint.Y);
         pen.Dispose();
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawLine", "Draw", ex.ToString(), ErrH._LogPriority.Info);
     }
 }
示例#12
0
 public DrawImage(string fileName, float x, float y, float width, float height)
 {
     InitBox();
     _fileName = fileName;
     try
     {
         _image = Image.FromFile(fileName);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawArea", "DrawImage", ex.ToString(), ErrH._LogPriority.Info);
     }
     RectangleF = new RectangleF(x, y, width, height);
     Initialize();
 }
示例#13
0
 public override void Draw(SpriteBatch g)
 {
     try
     {
         //g.SmoothingMode = SmoothingMode.AntiAlias;
         //var pen = new Pen(Stroke, StrokeWidth);
         //TODO change DrawLine to include thickness
         XnaDrawing.DrawLine(2.0f, Stroke, new Vector2(_startPoint.X, _startPoint.Y), new Vector2(_endPoint.X, _endPoint.Y));
         //pen.Dispose();
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawLine", "Draw", ex.ToString(), ErrH._LogPriority.Info);
     }
 }
示例#14
0
        public override void Draw(SpriteBatch g)
        {
            float x1 = 0, y1 = 0;     // previous point

            try
            {
                //g.SmoothingMode = SmoothingMode.AntiAlias;

                if (Fill.ToColor() != Color.Transparent)
                {
                    var arr = new Vector2[_pointArray.Count];
                    for (int i = 0; i < _pointArray.Count; i++)
                    {
                        arr[i] = (Vector2)_pointArray[i];
                    }
                    //Brush brush = new SolidBrush(Fill);
                    XnaDrawing.DrawPolyline(arr, Fill.ToColor());
                }

                //var pen = new Pen(Stroke, StrokeWidth);

                IEnumerator enumerator = _pointArray.GetEnumerator();

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

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

                    XnaDrawing.DrawLine(2.0f, Stroke, new Vector2(x1, y1), new Vector2(x2, y2));

                    x1 = x2;
                    y1 = y2;
                }

                //pen.Dispose();
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawPolygon", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#15
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)
            {
                ErrH.Log("DrawPolygon", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#16
0
 public static XnaDrawLine Create(SvgLine svg)
 {
     try
     {
         var dobj = new XnaDrawLine(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)
     {
         ErrH.Log("CreateLine", "Draw", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#17
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)
            {
                ErrH.Log("DrawText", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#18
0
 public static DrawEllipse 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 DrawEllipse(cx - rx, cy - ry, rx * 2, ry * 2);
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawEllipse", "CreateRectangle", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
        public static DrawRectangle Create(SvgRect svg)
        {
            try
            {
                var dobj = new DrawRectangle(ParseSize(svg.X, Dpi.X),
                                             ParseSize(svg.Y, Dpi.Y),
                                             ParseSize(svg.Width, Dpi.X),
                                             ParseSize(svg.Height, Dpi.Y));
                dobj.SetStyleFromSvg(svg);
                dobj.Name = svg.ShapeName;

                return(dobj);
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawRectangle", "CreateRectangle:", ex.ToString(), ErrH._LogPriority.Info);
                return(null);
            }
        }
示例#20
0
        /// <summary>
        /// Create graphic object used for hit test
        /// </summary>
        protected override void CreateObjects()
        {
            if (AreaPath != null)
            {
                return;
            }
            try
            {
                // Create closed path which contains all polygon vertexes
                AreaPath = new GraphicsPath();

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

                IEnumerator enumerator = _pointArray.GetEnumerator();

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

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

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

                    x1 = x2;
                    y1 = y2;
                }

                AreaPath.CloseFigure();

                // Create region from the path
                AreaRegion = new System.Drawing.Region(AreaPath);
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawPolygon", "Create", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            try
            {
                RectangleF r = GetNormalizedRectangle(RectangleF);
                if (Fill != Color.Empty)
                {
                    Brush brush = new SolidBrush(Fill);
                    g.FillRectangle(brush, r);
                }
                Pen pen = new Pen(Stroke, StrokeWidth);
                g.DrawRectangle(pen, r.X, r.Y, r.Width, r.Height);

                pen.Dispose();
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawRectangle", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#22
0
        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(SpriteBatch g)
        {
            try
            {
                Rectangle r = GetNormalizedRectangle(Rectangle);
                if (Fill.ToColor() != Color.Transparent)
                {
                    //Brush brush = new SolidBrush(Fill);
                    XnaDrawing.DrawFilledRectangle(r, Fill.ToColor());
                }
                //Pen pen = new Pen(Stroke, StrokeWidth);
                //TODO change Draw Rectangle to include strokewidth
                XnaDrawing.DrawRectangle(r, Stroke);

                //pen.Dispose();
            }
            catch (Exception ex)
            {
                ErrH.Log("DrawRectangle", "Draw", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#23
0
 public override void Draw(SpriteBatch g)
 {
     try
     {
         if (_reload)
         {
             _image  = ImageFromBytes(ReadPngMemImage(_fileName));
             Width   = _image.Width;
             Height  = _image.Height;
             _reload = false;
         }
         //if (_image != null)
         //g.DrawTexture(_image,Rectangle);
         //else
         base.Draw(g);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawImage", "Draw", ex.ToString(), ErrH._LogPriority.Info);
     }
 }
示例#24
0
 public override void Draw(SpriteBatch g)
 {
     //SpriteFont font = null;
     if (Font == null)
     {
         Font = XnaDrawing.defaultFont;
     }
     if (Rectangle.Width == 0 || Rectangle.Height == 0)
     {
         Rectangle = CalcSize(Text, Font, Rectangle.X, Rectangle.Y, TextAnchor);
     }
     //Brush brush = new SolidBrush(Stroke);
     try
     {
         XnaDrawing.DrawText(Font, Text, Stroke, Rectangle, TextAnchor);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawText", "Draw", ex.ToString(), ErrH._LogPriority.Info);
     }
 }
示例#25
0
 public static XnaDrawText Create(SvgText svg)
 {
     if (string.IsNullOrEmpty(svg.Value))
     {
         return(null);
     }
     try
     {
         var dobj = new XnaDrawText(ParseSize(svg.X, Dpi.X),
                                    ParseSize(svg.Y, Dpi.Y))
         {
             Text = svg.Value
         };
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawText", "DrawText", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#26
0
 /// <summary>
 /// Get Image object from byte array
 /// </summary>
 /// <param name="arrb"></param>
 /// <returns></returns>
 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)
     {
         ErrH.Log("DrawImagee", "ImageFromBytes", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#27
0
        /// <summary>
        /// Mouse move - resize new polygon
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        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)
                {
                    // Distance between last two points is less than minimum -
                    // move last point
                    _newPolygon.MoveHandleTo(point, _newPolygon.HandleCount);
                }
                else
                {
                    // Add new point
                    _newPolygon.AddPoint(point);
                    _lastX = e.X;
                    _lastY = e.Y;
                }
                drawArea.Refresh();
            }
            catch (Exception ex)
            {
                ErrH.Log("ToolPolygon", "OnMouse", ex.ToString(), ErrH._LogPriority.Info);
            }
        }
示例#28
0
 public static XnaDrawPolygon Create(SvgPolyline svg)
 {
     try
     {
         string   s      = svg.Points.Trim();
         string[] arr    = s.Split(' ');
         var      points = new Point[arr.Length];
         for (int i = 0; i < arr.Length; i++)
         {
             var arrp = arr[i].Split(',');
             points[i] = new Point((int)ParseSize(arrp[0], Dpi.X),
                                   (int)ParseSize(arrp[1], Dpi.Y));
         }
         var dobj = new XnaDrawPolygon(points);
         dobj.SetStyleFromSvg(svg);
         return(dobj);
     }
     catch (Exception ex)
     {
         ErrH.Log("DrawPolygon", "Create", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#29
0
 /// <summary>
 /// Load image from file to byte array
 /// </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, "");
         ErrH.Log("DrawImagee", "ReadPngMemImage", ex.ToString(), ErrH._LogPriority.Info);
         return(null);
     }
 }
示例#30
0
        public bool LoadFromXml(XmlTextReader reader)
        {
            ErrH.Log("DrawArea", "LoadFromXML", "", ErrH._LogPriority.Info);
            _graphicsList.Clear();
            var svg = new SvgDoc();

            if (!svg.LoadFromFile(reader))
            {
                return(false);
            }
            SvgRoot root = svg.GetSvgRoot();

            if (root == null)
            {
                return(false);
            }
            try
            {
                SizePicture = new Point((int)XnaDrawObject.ParseSize(root.Width, XnaDrawObject.Dpi.X),
                                        (int)XnaDrawObject.ParseSize(root.Height, XnaDrawObject.Dpi.Y));
            }
            catch
            {
            }
            _mOriginalSize = SizePicture;
            SvgElement ele = root.getChild();

            _mScale = new Point(1, 1);
            if (ele != null)
            {
                _graphicsList.AddFromSvg(ele);
            }

            Description = _graphicsList.Description;
            return(true);
        }