Пример #1
0
 /// <summary>
 /// Reads paths from an SVG file provided and sets all its data into this <see cref="VectorVinyl"/>.
 /// </summary>
 /// <param name="file">SVG file to read.</param>
 public void ReadFromFile(string file)
 {
     using var svgreader = new SVGReader(file);
     svgreader.ReadAllContents();
     this.ClearPaths();
     svgreader.ToVectorVinyl(this);
 }
Пример #2
0
        void ConvertToPathXaml(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;

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

                        string line = $"<Path Stroke=\"{gd.Pen?.Brush}\" Fill=\"{gd.Brush}\" Data=\"{gd.Geometry.ToString()}\"/>";

                        this.tx_code.Text += line.Replace($"Stroke =\"\"", "").Replace($"Fill =\"\"", "") + Environment.NewLine;
                    }
                    else if (item is DrawingGroup)
                    {
                        drawingAction(item as DrawingGroup);
                    }
                }
            };

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

            this.cv_data.Width  = svg.Width;
            this.cv_data.Height = svg.Height;

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

            p.Data   = svg.GetGeometry();
            p.Stroke = Brushes.Red;
            this.cv_data.Children.Clear();
            this.cv_data.Children.Add(p);
        }
Пример #4
0
        private void lb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string name = this.lb.SelectedValue == null ? null : this.lb.SelectedValue.ToString();

            if (string.IsNullOrWhiteSpace(name))
            {
                this.img.Source = null;
            }
            else
            {
                string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", name);

                SVG.SVG svg = SVGReader.Read(path);

                this.img.Source = new DrawingImage(svg.GetDrawing());
            }
        }
Пример #5
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);
        }
Пример #6
0
        void ConvertToImage(FileEntity file)
        {
            SVG svg = SVGReader.Read(file.FilePath);

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