FlowChart.NET - FAQ - Diagram Serialization and Export
Overview   Features   Online Demo   Download   Gallery   FAQ   Forum   Online Help   Buy  

    Xml deserialization speed?

    Using LoadFromString?

    Using LoadFromXml?

    Convert FlowChart To Image?

    Convert shape to an image?

    Exporting a diagram to emf file?

    Saving a Selection?

    Drawing database ER diagrams with FlowChart.NET?

    Generating FlowChart Diagram from SQL-Data?

 

 

Q:    Has the XML deserialization speed been improved in the Diagram.LoadFromXml in v5?

A:   Version 5 uses the DOM API and version 4 used linear serialization, so the XML serialization is a bit slower in V5, but you will notice it only with a big number of items (in the thousands). In addition, version 5 serializes saved a single copy of shared node images, so XML serialization in the new version is much faster when using images. We have done some tests with 400 nodes and 400 links:

  • V4.3.1, without images: the file loads for a second
  • V5.0, without images: the file loads for a second
  • V4.3.1, with 10 images: the file loads for 12 seconds
  • V5.0, with 10 images: the file loads for 2 seconds

Each image from the last tests was assigned to 40 nodes. In this case, the speed in version 5 is better because the bytes of shared images are encoded and saved just once; whereas version 4 saves a separate copy for each node, and subsequently decodes 400 image copies when loading.

 

back to top

 

Q:    Can Diagram.LoadFromXml read XML strings created using previous version's XmlWriter class?

A:   The old XML format is still supported for reading; actually you must use the LoadFromString method to load an XML string.

 

back to top

 

Q:    In v5, is there a performance difference between the LoadFromXml overload which takes a document vs. the one which takes a string?

A:   The latter calls the former after creating an XmlDocument object from the string content.

 

back to top

 

Q:    Is it possible to convert a Diagram to a bitmap file.

A:   Call the Diagram.CreateImage method and then the Image.Save method.

 

back to top

 

Q:    I am trying to create a custom drag&drop icon to show up when dragging the shape around on the screen. Is there a way to convert a flowChart shape into an image on the fly?

A:   Create a graphics object using Graphics.FromImage. In order to draw a shape on the Graphics instance, create a temporary node, set its shape, and then call the ShapeNode.Draw method. A similar method is shown in the Flowcharter sample project where the icons in a list box represent Flowchart.NET shapes.

 

back to top

 

Q:    How can I export a diagram to emf file?

A:   Use the following code.

using (FileStream stream = new FileStream(
        @"C:\temp.wmf", FileMode.Create))
{
      Graphics g = CreateGraphics();
      IntPtr hDC = g.GetHdc();
      Metafile metafile = new Metafile(stream, hDC);
      g.ReleaseHdc(hDC);
      g.Dispose();       IGraphics gMeta = new GdiGraphics(
	    Graphics.FromImage(metafile));
	  
      diagram.Draw(gMeta, new RenderOptions(), 
	    diagram.Bounds, false);
	  
      gMeta.Dispose();
	  
      metafile.Dispose();
}
IGraphics and GdiGraphics are defined in the MindFusion.Drawing namespace.

 

back to top

 

Q:    Can I save to a file a selection of items.

A:   Use the CopySelection and PasteSelection methods to copy the selected items to a second Diagram instance, and call the Diagram.SaveToFile method to save them to a file.

 

back to top

 

Q:    Can FlowChart.NET read my database schema and generate an ER diagram for it?

A:   No. You should read the schema by ADO.NET and generate a diagram programmatically with the CreateTableNode and CreateDiagramLink methods.

 

back to top

 

Q:     I have an SQL-Table with some entries containing state and connection information in several columns. I already imported the nodes. Now I would like to organize the connections. Have you some hints which way I should choose to reach that?

A:   To create the connections, assign the node ID from the database to the ShapeNode.Tag property while creating the nodes. Run a second loop over the link records, and for each related node ID you have for a node, call CreateDiagramLink(node, Diagram.FindNode (relatedID)). If you already use the Tags to store other information, save the relations in a Hashtable. To arrange the diagram, use some of the layout algorithm classes, for example LayeredLayout.

 

back to top

 

   
 
   
Forums: FlowChart.NET, WpfDiagram, DiagramLite, JsDiagram, MasterChart, WebChart, Planner.NET, WpfPlanner, Reporting, ReportingLite
© MindFusion Ltd. 2012