Profile Picture

Saving Loading Document with Custom Classes

Posted By Thunis Kruger 11 Years Ago
Author
Message
Thunis Kruger
questionmark Posted 11 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 11 Years Ago
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
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)Supreme Being (4,350 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,043, Visits: 3,777

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





Similar Topics


Reading This Topic