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:

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.

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.

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.

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

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

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.

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.Dispose();       IGraphics gMeta = new GdiGraphics(
      diagram.Draw(gMeta, new RenderOptions(), 
	    diagram.Bounds, false);
IGraphics and GdiGraphics are defined in the MindFusion.Drawing namespace.