Results 1 to 4 of 4

Thread: PathData class unable to be serialized [RESOLVED]

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    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.

  2. #2
    New Member
    Join Date
    Apr 2003
    Location
    Nottingham
    Posts
    14
    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.

  3. #3

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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.

  4. #4

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    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:
    1. Imports System.Drawing
    2. Imports System.Drawing.Drawing2D
    3. Imports System.Xml.Serialization
    4.  
    5. <Serializable()> Public Class FigureItem
    6.  
    7.     Private pPoint As Point
    8.     Private pPathPoints() As PointF 'storesPathPoints
    9.     Private pPathTypes() As Byte  'storesPathTypes
    10.     Private pRotation As Integer
    11.     Public Sub New()
    12.  
    13.     End Sub
    14.  
    15.     Public Sub New(ByVal lPoint As Point, ByVal lPathData As PathData, _
    16.     ByVal lRotation As Integer)
    17.         pPoint = lPoint
    18.         pRotation = lRotation
    19.         'convert pathdata to our internal structure so
    20.         'we can serialize it (initialize new arrays set to
    21.         '                    size of PathData internal arrays)
    22.         pPathTypes = CType(Array.CreateInstance(GetType(Byte), lPathData.Types.Length), Byte())
    23.         pPathPoints = CType(Array.CreateInstance(GetType(PointF), lPathData.Points.Length), PointF())
    24.         lPathData.Types.CopyTo(pPathTypes, 0)
    25.         lPathData.Points.CopyTo(pPathPoints, 0)
    26.     End Sub
    27.  
    28.  
    29.  
    30.     Public Property [PathData]() As PathData
    31.         Get
    32.             Dim r As New System.Drawing.Drawing2D.PathData()
    33.             r.Types = CType(Array.CreateInstance(GetType(Byte), pPathTypes.Length), Byte())
    34.             r.Points = CType(Array.CreateInstance(GetType(PointF), pPathPoints.Length), PointF())
    35.             pPathTypes.CopyTo(r.Types, 0)
    36.             pPathPoints.CopyTo(r.Points, 0)
    37.             Return r
    38.         End Get
    39.         Set(ByVal Value As PathData)
    40.             Value.Points.CopyTo(pPathPoints, 0)
    41.             Value.Types.CopyTo(pPathTypes, 0)
    42.         End Set
    43.     End Property
    44. 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
  •  



Click Here to Expand Forum to Full Width