|
-
Jun 23rd, 2003, 10:17 AM
#1
Thread Starter
I wonder how many charact
PathData class unable to be serialized [RESOLVED]
So, I can't serialize PathData... why? I don't know... the best description I can get of PathData is that it is an array of bytes that encapsulates the points and point types in a graphics path. Seems to me an array of bytes should be serializable.
the PathData class encompasses an array of PointF structures (serializable), and PointType (serializable), so why can't the class be serialized?
Any ideas?
Last edited by nemaroller; Jun 24th, 2003 at 11:46 AM.
-
Jun 24th, 2003, 02:50 AM
#2
New Member
Although PathData contains serializable objects as properties, it does not implement the ISerializable interface itself. The best thing you could do is to encapsulate the properties from PathData in your own Serializable class.
-
Jun 24th, 2003, 10:09 AM
#3
Thread Starter
I wonder how many charact
Thanks jaycee, I had gotten too frustrated yesterday with it, so I am doing just that... just seems rather strange they would decide to mark as nonserializable.
-
Jun 24th, 2003, 10:22 AM
#4
Thread Starter
I wonder how many charact
And this is all the extra work I had to do... note that if anyone
else needs this in the future, you may want to remove all
code related to pPoint and pRotation, they were for my personal uses...
VB Code:
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Xml.Serialization
<Serializable()> Public Class FigureItem
Private pPoint As Point
Private pPathPoints() As PointF 'storesPathPoints
Private pPathTypes() As Byte 'storesPathTypes
Private pRotation As Integer
Public Sub New()
End Sub
Public Sub New(ByVal lPoint As Point, ByVal lPathData As PathData, _
ByVal lRotation As Integer)
pPoint = lPoint
pRotation = lRotation
'convert pathdata to our internal structure so
'we can serialize it (initialize new arrays set to
' size of PathData internal arrays)
pPathTypes = CType(Array.CreateInstance(GetType(Byte), lPathData.Types.Length), Byte())
pPathPoints = CType(Array.CreateInstance(GetType(PointF), lPathData.Points.Length), PointF())
lPathData.Types.CopyTo(pPathTypes, 0)
lPathData.Points.CopyTo(pPathPoints, 0)
End Sub
Public Property [PathData]() As PathData
Get
Dim r As New System.Drawing.Drawing2D.PathData()
r.Types = CType(Array.CreateInstance(GetType(Byte), pPathTypes.Length), Byte())
r.Points = CType(Array.CreateInstance(GetType(PointF), pPathPoints.Length), PointF())
pPathTypes.CopyTo(r.Types, 0)
pPathPoints.CopyTo(r.Points, 0)
Return r
End Get
Set(ByVal Value As PathData)
Value.Points.CopyTo(pPathPoints, 0)
Value.Types.CopyTo(pPathTypes, 0)
End Set
End Property
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|