Пример #1
0
        void ConvertToPathDrawing(FileEntity file)
        {
            SVG svg = SVGReader.Read(file.FilePath);

            Drawing drawing = svg.GetDrawing();

            DrawingGroup group = drawing as DrawingGroup;

            Action <DrawingGroup> drawingAction = null;

            this.tx_code.Text = null;

            this.cv_pathdraw.Children.Clear();

            this.cv_pathdraw.Width  = svg.Width;
            this.cv_pathdraw.Height = svg.Height;

            drawingAction = l =>
            {
                foreach (var item in l.Children)
                {
                    if (item is GeometryDrawing)
                    {
                        GeometryDrawing gd = item as GeometryDrawing;

                        System.Windows.Shapes.Path p = new System.Windows.Shapes.Path();

                        p.Data   = gd.Geometry;
                        p.Fill   = gd.Brush;
                        p.Stroke = gd.Pen?.Brush;

                        this.tx_code.Text += gd.Geometry.ToString() + Environment.NewLine;
                        this.cv_pathdraw.Children.Add(p);
                    }
                    else if (item is DrawingGroup)
                    {
                        drawingAction(item as DrawingGroup);
                    }
                }
            };

            drawingAction(group);
        }
Пример #2
0
        void ConvertToImage(FileEntity file)
        {
            SVG svg = SVGReader.Read(file.FilePath);

            this.image_svg.Source = new DrawingImage(svg.GetDrawing());
        }