Ejemplo n.º 1
0
        private bool ProcessFile(string fileName, Stream imageStream)
        {
            _wpfRenderer.LinkVisitor       = new LinkVisitor();
            _wpfRenderer.ImageVisitor      = new EmbeddedImageVisitor();
            _wpfRenderer.FontFamilyVisitor = new FontFamilyVisitor();

            _wpfWindow.LoadDocument(fileName);

            _wpfRenderer.InvalidRect = SvgRectF.Empty;

            _wpfRenderer.Render(_wpfWindow.Document as SvgDocument);

            _drawing = _wpfRenderer.Drawing as DrawingGroup;
            if (_drawing == null)
            {
                return(false);
            }

            // Save to the image file...
            SaveImageFile(_drawing, imageStream);

            // Save to image and/or ZAML file if required...
            if (this.SaveXaml || this.SaveZaml)
            {
                SaveXamlFile(_drawing, fileName, null);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool ProcessFile(string fileName, string xamlFileName)
        {
            _wpfRenderer.LinkVisitor       = new LinkVisitor();
            _wpfRenderer.ImageVisitor      = new EmbeddedImageVisitor();
            _wpfRenderer.FontFamilyVisitor = new FontFamilyVisitor();

            _wpfWindow.LoadDocument(fileName);

            _wpfRenderer.InvalidRect = SvgRectF.Empty;

            _wpfRenderer.Render(_wpfWindow.Document as SvgDocument);

            DrawingGroup renderedDrawing = _wpfRenderer.Drawing as DrawingGroup;

            if (renderedDrawing == null)
            {
                return(false);
            }

            SaveFile(renderedDrawing, fileName, xamlFileName);

            renderedDrawing = null;

            return(true);
        }
Ejemplo n.º 3
0
        public static FrameworkElement LoadSvg(string filename)
        {
            var settings = new WpfDrawingSettings();

            settings.IncludeRuntime = true;
            var renderer = new WpfDrawingRenderer(settings);

            renderer.LinkVisitor       = new LinkVisitor();
            renderer.ImageVisitor      = new EmbeddedImageVisitor();
            renderer.FontFamilyVisitor = new FontFamilyVisitor();
            var svgWindow = new WpfSvgWindow(4096, 4096, renderer);

            svgWindow.LoadDocument(filename);
            svgWindow.Resize((int)svgWindow.Document.RootElement.Width.BaseVal.Value, (int)svgWindow.Document.RootElement.Height.BaseVal.Value);
            renderer.InvalidRect = SvgRectF.Empty;
            renderer.Render(svgWindow.Document as SvgDocument);
            var drawing = new System.Windows.Media.DrawingImage();

            drawing.Drawing = renderer.Drawing;
            var image = new System.Windows.Controls.Image();

            image.Source = drawing;
            image.Width  = renderer.Window.InnerWidth;
            image.Height = renderer.Window.InnerHeight;
            return(image);
        }
        private bool Load(string uri)
        {
            UnloadDiagrams();

            if (string.IsNullOrEmpty(uri))
            {
                return(false);
            }

            try
            {
                _wpfWindow.LoadDocument(uri, null);
                _wpfRenderer.Render(_wpfWindow.Document);
                this.Bounds = CalculateBounds(_wpfWindow);

                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.ToString());
                UnloadDiagrams();

                return(false);
            }
        }
Ejemplo n.º 5
0
        private DrawingGroup LoadFile(string fileName)
        {
            _wpfRenderer.LinkVisitor       = new LinkVisitor();
            _wpfRenderer.ImageVisitor      = new EmbeddedImageVisitor();
            _wpfRenderer.FontFamilyVisitor = new FontFamilyVisitor();

            _wpfWindow.LoadDocument(fileName);

            _wpfRenderer.InvalidRect = SvgRectF.Empty;

            _wpfRenderer.Render(_wpfWindow.Document as SvgDocument);

            _drawing = _wpfRenderer.Drawing as DrawingGroup;
            if (_drawing == null)
            {
                return(null);
            }

            SaveFile(fileName);

            return(_drawing);
        }