Saving Loading Document with Custom Classes


Author
Message
Thunis Kruger
Thunis Kruger
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)
Group: Forum Members
Posts: 6, Visits: 1

I implemented a custom port but the saving and loading of the diagram does not work. How do I save a drawing with custom classes?

Private Sub butSave_Click(sender As Object, e As EventArgs) Handles butSave.Click

Dim pm As New NPersistencyManager

pm.SaveDocumentToFile(document, "c:\\temp\\drawing1.nds")

End Sub

 

Private Sub butLoad_Click(sender As Object, e As EventArgs) Handles butLoad.Click

Dim pm As New NPersistencyManager

document = pm.LoadDocumentFromFile("c:\\temp\\drawing1.nds")

view.Document = document

End Sub

 

Public Class DLogicalLinePort

Inherits NLogicalLinePort

Public Overrides Sub Paint(ByVal context As NPaintContext)

' Compute the bounds of the port in device coordinates

Dim location__1 As NPointF = context.SceneToDevice.TransformPoint(Location)

Dim width As Single = NDR.BitmapPortSize.Width

Dim height As Single = NDR.BitmapPortSize.Height

Dim bounds As New NRectangleF(location__1.X - width / 2, location__1.Y - height / 2, width, height)

' Clip test

If context.DevicePaintArea.IntersectsWith(bounds) = False Then

Return

End If

' Paint the port

Dim circle As New NEllipsePath(bounds.Location, bounds.RightBottom)

NStyle.SetFillStyle(circle, New NColorFillStyle(Color.FromArgb(125, Color.Yellow)))

NStyle.SetStrokeStyle(circle, New NStrokeStyle(KnownArgbColorValue.Red))

circle.Paint(context)

End Sub

End Class


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi,

All custom classes you want to take part in the serialization process should be marked as Serializable. If you do not want to serialize any of the class fields simply mark it as NonSerialized.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search