Save and Load Layout
Save/Load layout functionality gives your application the opportunity to preserve RadDiagram's shapes and restore them later. The whole shapes' data is written in a XML file.
Here is a sample demonstrating how you can save the layout to a file:
Save Layout
Save Layout
string s = "default.xml";
System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
s = dialog.FileName;
}
this.radDiagram1.SaveToFile(s);
Dim s As String = "default.xml"
Dim dialog As New System.Windows.Forms.SaveFileDialog()
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"
dialog.Title = "Select a xml file"
If dialog.ShowDialog() = DialogResult.OK Then
s = dialog.FileName
End If
Me.radDiagram1.SaveToFile(s)
You can use the RadDiagram.Save method in case you need just the string representation of the XML data.
Load Layout
Here is a sample demonstrating how you can load the layout from a file:
Load Layout
string s = "default.xml";
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*";
dialog.Title = "Select a xml file";
if (dialog.ShowDialog() == DialogResult.OK)
{
s = dialog.FileName;
}
this.radDiagram1.LoadFromFile(s);
Dim s As String = "default.xml"
Dim dialog As New System.Windows.Forms.OpenFileDialog()
dialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"
dialog.Title = "Select a xml file"
If dialog.ShowDialog() = DialogResult.OK Then
s = dialog.FileName
End If
Me.radDiagram1.LoadFromFile(s)
You can use the RadDiagram.Load method in order to load data from a string representation of the XML data.