FlowChartX provides the SaveToFile method to store diagram data to a disk file. The saved document can be reloaded later via the LoadFromFile method. The Dirty property indicates if a document has been changed since it was loaded. You can test this flag before your application exits, in order to display a confirmation dialog to the user if modified data has not been saved.
Two methods, SaveToString and LoadFromString, enable saving and loading FlowChartX documents into strings of ASCII characters. That makes easy saving diagrams in database fields or embedding them as part of XML documents. You should take heed of the size requirements though. Each byte of the binary representation of a diagram requires two Unicode characters in ASCII format. That makes four times more space that the one required for saving into files or streams in binary format.
It is possible to save a diagram as an XML document. To do that, create an instance of the XMLWriter class, set its Document property to the FlowChart to be serialized, and call the Write or WriteToString methods. Diagrams saved that way can be loaded later using the Read or ReadFromString method of an XMLReader instance.
Since version 4.1.5, the FlowChart class provides SaveToXml and LoadFromXml methods that implement serialization in a new XML format. This new format is supported by other MindFusion diagramming components, such as Flowchart.NET, JDiagram and WpfDiagram. XMLWriter and XMLReader are still available for compatibility reasons, but they will be removed from the next major FlowChartX release.
FlowChartX implements the IPersistStreamInit interface, which provide means to serialize/deserialize control contents into an OLE stream. Using methods of this interface you might save flowchart objects and properties as part of your own compound documents. Streams might also wrap memory buffers, database blobs, network transfers and more. For more information on IPersistStreamInit see the OLE documentation.
If embedded in a web page, FlowChartX runs in a 'safe for scripting' mode. This mode disables file creation and write operations in order to prevent malicious scripts to overwrite files on the users' hard disks. The following methods return an error if invoked in 'safe for scripting' mode: SaveToFile, SaveToBitmap and SaveToMetaFile.
In .NET the persisted state of an ActiveX control is encapsulated by AxHost.State class, which implements the ISerializable interface. The AxHost.State can be retrieved by the AxHost.OcxState property, which can be used together with objects of BinaryFormatter and Stream classes to serialize/deserialize a FlowChartX document.
Example: To save and load FlowChartX document to/from a file you can use following VB.NET code.
VB.NET Copy Code |
---|
Imports System.IO |