Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic SVG Export (Read 3352 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
SVG Export
Mar 25th, 2008 at 11:39am
Print Post  
Hello,

when trying to export a diagram in our application, we encouter the following error:

System.ArgumentException: Ungültiger Parameter.
bei System.Drawing.Drawing2D.GraphicsPath.get_PathTypes()
bei MindFusion.Svg.UnitFormatter.IsPathClosed(GraphicsPath g)
bei MindFusion.Svg.SvgGraphics.DrawPath(Pen pen, GraphicsPath path)
bei MindFusion.Diagramming.ShapeNode.xc79d59e9288101bd(IGraphics x41347a961b838962, RectangleF xa6236fc5cd405c4e, Boolean x2f9dabff87b2168b, Brush xb45de92d01a0ec1f, Pen x9c79b5ad7b769b12, RenderOptions xdfde339da46db651)
bei MindFusion.Diagramming.ShapeNode.Draw(IGraphics graphics, RenderOptions options)
bei MindFusion.Diagramming.Diagram.x83e1efc9aa69ada9(IGraphics x41347a961b838962, DiagramItem xccb63ca5f63dc470, Boolean x9c41bb4d9b3b314f)
bei MindFusion.Diagramming.Diagram.x679ae26de3befa07(IGraphics x41347a961b838962, RectangleF xd0772cd9ac472b96, Boolean x979174172ae18db3)
bei MindFusion.Diagramming.Diagram.Draw(IGraphics graphics, RenderOptions options, RectangleF clipRect, Boolean noModifiedItems)
bei MindFusion.Diagramming.Export.SvgExporter.Export(Diagram diagram, String filePath)
bei HSPforzheim.ProcessDesigner.GUI.DrawForm.diagramToSVGToolStripMenuItem_Click(Obj
ect sender, EventArgs e)

which is caused by an Invalid Parameter (sry for german translation).

Code itself:

Code
Select All
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.DefaultExt = "svg";



saveFileDialog.Filter = "SVG files|*.svg";



if (saveFileDialog.ShowDialog() == DialogResult.OK)



{




MindFusion.Diagramming.Export.SvgExporter svgExp =





new MindFusion.Diagramming.Export.SvgExporter();




svgExp.ExternalImages = false;




svgExp.Export(diagramView.Diagram, saveFileDialog.FileName);



} 



I don't know what causes this problem. SVG Export in your sample application works fine.

Best regards,

Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG Export
Reply #1 - Mar 25th, 2008 at 12:10pm
Print Post  
Hi,

Could you check in the debugger what are the node's Shape and Bounds values when the exception is thrown?

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: SVG Export
Reply #2 - Mar 25th, 2008 at 3:27pm
Print Post  
Hello Stoyan,

it seems to me, that the values for Shape and Bounds are correct for all items. The SVG export fails if the following node with the following shape is present in the diagram:

Code
Select All
    internal class ShapeProcessOperator : myShapes
    {
        public static ElementTemplate[] elements =
            new ElementTemplate[]
                {
                    new LineTemplate(0, 0, 100, 0), new LineTemplate(100, 0, 100, 100), new LineTemplate(100, 100, 0, 100),
                    new LineTemplate(0, 100, 0, 0)
                };

        public static ElementTemplate[] textArea =
            new ElementTemplate[]
                {
                    new LineTemplate(5, 55, 5, 95), new LineTemplate(5, 95, 95, 95), new LineTemplate(95, 95, 95, 55),
                    new LineTemplate(95, 55, 5, 55)
                };

        public ShapeProcessOperator() : base(elements, textArea, "Operation")
        {
            bgColor = Color.LightGreen;
            width = 40;
            height = 10;
            anchorPattern =
                new AnchorPattern(
                    new AnchorPoint[]
                        {
                            new AnchorPoint(50, 0, true, false, MarkStyle.Circle, Color.Blue),
                            new AnchorPoint(50, 100, false, true, MarkStyle.Circle, Color.Green),
                            new AnchorPoint(100, 50, true, true, MarkStyle.Cross, Color.Red)
                        });
        }
    } 



This node adjusts its anchorPattern while the user adds and removes links.

the following output is visible in the debugger:

draw string 'O0'
draw path
draw path

where O0 is the node with the ShapeProcessOperator - Shape.

Usually the following happens, if I use other shapes:

draw path
draw string 'B0'
draw path
draw string 'P0'
draw path
draw string 'E0'
draw path
draw string 'S0'
draw path
draw string 'E1'
draw path
draw string 'P1'
...and so on ...

Maybe a better hint for you. All these shapes also have no textarea defined. The text itself is a node. The shapes are defined like this:

Code
Select All
    internal class ShapeEnergy : myShapes
    {
        public static ElementTemplate[] elements =
            new ElementTemplate[]
                {
                    new LineTemplate(0, 50, 50, 0), new LineTemplate(50, 0, 100, 50), new LineTemplate(100, 50, 50, 100),
                    new LineTemplate(50, 100, 0, 50)
                };

        public ShapeEnergy()
            : base(elements, "Energie")
        {
            bgColor = Color.LightBlue;
            width = 10;
            height = 10;
        }
    } 



Best regards,

Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG Export
Reply #3 - Mar 26th, 2008 at 8:15am
Print Post  
Hi Alex,

I've copied your shape definitions to the exporter sample project, but could not reproduce the exception:
https://mindfusion.eu/_temp/SvgBug.zip

Could you copy all ShapeNode property values you are using to node1 and node2 in that project and see which one leads to the exception?

Thanks,
Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: SVG Export
Reply #4 - Mar 26th, 2008 at 10:53am
Print Post  
I added my shape definitions to that project. The error still persists.

Maybe you notice something. Here is the Link to the updated project:
http://pme.hs-pforzheim.de/_temp/Temp.rar

Thanks for your help!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG Export
Reply #5 - Mar 26th, 2008 at 11:56am
Print Post  
In the myShapes class, replace

public static ElementTemplate[] decorations = new ElementTemplate[] { };

with

public static ElementTemplate[] decorations = null;

If you pass a decorations array to the Shape constructor (even an empty one), FlowChart.NET creates a GraphicsPath from it when exporting to SVG. But then GraphicsPath throws an exception when accessing any of its properties and there aren't elements in the path. If you pass null for the decorations argument, there won't be a GraphicsPath created and the exporter works fine.

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: SVG Export
Reply #6 - Mar 26th, 2008 at 12:10pm
Print Post  
I changed it, and it WORKS! Great job!

But one little question left: I use a grid in my diagram. Unfortunatly this grid is exported also. Is there a way to not export this information?

Best regards,

Alex

and thank you (again) for great support!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: SVG Export
Reply #7 - Mar 26th, 2008 at 12:19pm
Print Post  
You will have to disable ShowGrid temporarily. If you are afraid that the users can see the grid disappear, do that on a copy of the diagram object and export the copy.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint