Ejemplo n.º 1
0
        private void Drop(object sender, DragEventArgs e)
        {
            if (e.Data.Contains(DataFormats.FileNames))
            {
                var fileName = e.Data.GetFileNames()?.FirstOrDefault();
                if (!string.IsNullOrWhiteSpace(fileName))
                {
                    if (e.Source == _svgSourceDockPanel)
                    {
                        var svg     = new SvgSource();
                        var picture = svg.Load(fileName);
                        if (picture != null)
                        {
                            _svgSourceImage.Source = new SvgImage()
                            {
                                Source = svg
                            };
                        }
                    }

                    if (e.Source == _svgResourceDockPanel)
                    {
                        var svg     = new SvgSource();
                        var picture = svg.Load(fileName);
                        if (picture != null)
                        {
                            _svgResourceImage.Source = new SvgImage()
                            {
                                Source = svg
                            };
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void SvgImage_Load()
        {
            var uri         = new Uri($"avares://Svg.Skia.Avalonia.UnitTests/Assets/Icon.svg");
            var assetLoader = new AssetLoader(); // AvaloniaLocator.Current.GetService<IAssetLoader>()

            var svgFile = assetLoader.Open(uri);

            Assert.NotNull(svgFile);

            var svgSource = new SvgSource();
            var picture   = svgSource.Load(svgFile);

            Assert.NotNull(picture);

            var svgImage = new SvgImage()
            {
                Source = svgSource
            };

            Assert.NotNull(svgImage);
        }
Ejemplo n.º 3
0
        private void Drop(object sender, DragEventArgs e)
        {
            if (e.Data.Contains(DataFormats.FileNames))
            {
                var fileName = e.Data.GetFileNames()?.FirstOrDefault();
                if (!string.IsNullOrWhiteSpace(fileName))
                {
                    if (sender == _svgSourceDockPanel)
                    {
                        var svg = new SvgSource();
#if USE_PICTURE
                        var document = SKSvg.Open(fileName);
                        if (document != null)
                        {
                            var picture = SKSvg.ToModel(document);
                            if (picture != null)
                            {
                                svg.Picture            = picture;
                                _svgSourceImage.Source = new SvgImage()
                                {
                                    Source = svg
                                };
                            }
                        }
#else
                        var picture = svg.Load(fileName);
                        if (picture != null)
                        {
                            _svgSourceImage.Source = new SvgImage()
                            {
                                Source = svg
                            };
                        }
#endif
                    }

                    if (sender == _svgResourceDockPanel)
                    {
#if USE_PICTURE
                        var svg      = new SvgSource();
                        var document = SKSvg.Open(fileName);
                        if (document != null)
                        {
                            var picture = SKSvg.ToModel(document);
                            if (picture != null)
                            {
                                svg.Picture = picture;
                                _svgResourceImage.Source = new SvgImage()
                                {
                                    Source = svg
                                };
                            }
                        }
#else
                        var svg     = new SvgSource();
                        var picture = svg.Load(fileName);
                        if (picture != null)
                        {
                            _svgResourceImage.Source = new SvgImage()
                            {
                                Source = svg
                            };
                        }
#endif
                    }
                }
            }
        }