codice:
<Serializable()> _
Public Class Layer
Inherits Item
Private _Items As List(Of FillableItem)
Private _Name As String
Private _BgImage As BackgroundImage
Private _Index As Int32
Public ReadOnly Property Items() As List(Of FillableItem)
Get
Return _Items
End Get
End Property
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property BgImage() As BackgroundImage
Get
Return _BgImage
End Get
Set(ByVal value As BackgroundImage)
_BgImage = value
End Set
End Property
Public Property Index() As Int32
Get
Return _Index
End Get
Set(ByVal value As Int32)
_Index = value
End Set
End Property
Sub New()
_Items = New List(Of FillableItem)
End Sub
Public Overrides Sub Draw(ByVal G As System.Drawing.Graphics)
For Each I As Item In Me.Items
I.Draw(G)
Next
End Sub
End Class
Item è una classe astratta che contiene solo i membri Draw e Color. FillableItem è un'altra classe astratta, derivata da Item, che contiene molte altre proprietà. Da FillableItem derivano due classi: una astratta, PointConnectionItem; e una normale pubblica Mix. Da PointConnectionItem derivano altre due classi normali, ClosedCurve e ClosedLine. BackgroundImage è una classe normale non derivata. Questo è uno schema di ereditariteà per il mio progetto:

All'inizio pensavo l'errore fosse dovuto all'immagine, ma anche togliendola, persiste.