We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I programmatically create the symbols defined in a symbol palette file?

Platform: WinForms |
Control: Diagram |
Published Date: April 30, 2011 |
Last Revised Date: June 4, 2019

How do I programmatically create the symbols defined in a symbol palette file?

The Essential Diagram symbol palette file (*.edp file) is a serialized representation of the Syncfusion.Windows.Forms.Diagram.SymbolPalette class, a special type of diagram model that contains a collection of SymbolModel objects. The SymbolPalette can be retrieved from the palette file by deserializing the palette file as shown below,

C#

SymbolPalette palette = null;
FileStream iStream = null;
if (File.Exists(filename))
{
iStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
SoapFormatter formatter = new SoapFormatter();
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder;
formatter.AssemblyFormat = FormatterAssemblyStyle.Simple;
try
{
System.AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(Syncfusion.DiagramBaseAssembly.AssemblyResolver);
palette = (SymbolPalette) formatter.Deserialize(iStream);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
palette = null;
}
finally
{
iStream.Close();
System.AppDomain.CurrentDomain.AssemblyResolve -= new ResolveEventHandler(Syncfusion.DiagramBaseAssembly.AssemblyResolver);
}
}

 

VB

Dim palette As SymbolPalette = Nothing
Dim iStream As FileStream = Nothing
If File.Exists(filename) Then
iStream = New FileStream(filename, FileMode.Open, FileAccess.Read)
Dim formatter As SoapFormatter = New SoapFormatter
formatter.Binder = Syncfusion.Runtime.Serialization.AppStateSerializer.CustomBinder
formatter.AssemblyFormat = FormatterAssemblyStyle.Simple
Try
AddHandler System.AppDomain.CurrentDomain.AssemblyResolve, AddressOf Syncfusion.DiagramBaseAssembly.AssemblyResolver
palette = CType(formatter.Deserialize(iStream), SymbolPalette)
Catch ex As Exception
MessageBox.Show(ex.Message)
palette = Nothing
Finally
iStream.Close()
RemoveHandler System.AppDomain.CurrentDomain.AssemblyResolve, AddressOf Syncfusion.DiagramBaseAssembly.AssemblyResolver
End Try
End If
 

 

Once the SymbolPalette has been loaded, the SymbolPalette.Nodes property may be used to get hold of the collection of SymbolModels in that palette. SymbolModels serve as the design-time representation of symbols, and the symbol itself can be created using the SymbolModel.CreateInstance() method. The symbol can then be added to the diagram by a) Directly adding it to the diagram's Model.Nodes collection, b) Using the InsertSymbolTool or InsertNodeTool for interactive insertion, or c)Using the InsertNodesCmd for programmatic insertion.

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon