Protected giver kun adgang til klasser der har ned arvet fra den givne klasse.
Jeg har lavet det med protected, og private members i base er synlig via mybase., så dét er i orden. Jeg har tre afledte klasser og troede, at jeg kunne samle dem i en List<of type baseClass> .. men det kan jeg ikke. #&%£@!
Søren Enevoldsen foreslog i
http://www.udvikleren.dk/forum/37301/read-from-shapefile-and-paint-/at bruge et interface iBase og så siden List<iBase> .. er det sikkert at dét ville have virket til at samle de afledte i?
// edit
- Public Interface iPaint
- Sub Paint(ByRef g As System.Drawing.Graphics, e As System.Windows.Forms.PaintEventArgs)
- End Interface
-
-
- Class basePolyLine
- Inherits baseShape
- Implements cShape.iPaint
-
- Private sizList As New Collections.Generic.List(Of System.Drawing.Size)
- Private mPointFlist As New Collections.Generic.List(Of System.Drawing.PointF)
-
- Private _maxM, myminM, mmaxZ, mminZ As Double
- Private obj As Object
- Private mParts As Integer
- Private prts As cShape.intList
- Private pn As System.Drawing.Pen
-
-
- Public Sub New(ByVal someLines As cPolyLineM)
- obj = someLines
- MyBase.mBox = someLines.xyBox
- MyBase.shpType = someLines.Shapetype
- MyBase.mCount = someLines.NumberOfPoints
- 'shT = someLines.Shapetype
- _maxM = someLines.M_max
- myminM = someLines.M_min
- 'mbox = someLines.xyBox
- mParts = someLines.NumberOfParts
- 'mPoints = someLines.NumberOfPoints
- prts = someLines.Parts
- 'mList = someLines.M_List
- fillPointsM(someLines.Points, someLines.M_List)
- End Sub
-
- .....
-
- Public Sub Paint(ByRef g As System.Drawing.Graphics, ByRef e As System.Windows.Forms.PaintEventArgs) Implements cShape.iPaint.Paint
- For i As Integer = 0 To Me.mParts - 1 Step 1
- g.DrawLines(pn, mPointFlist.GetRange(sizList(i).Width, sizList(i).Height).ToArray())
- Next
- End Sub
-
- End Class
Syntaxen for interfacet er ikke i orden (jeg har ikke prøvet før) .. nogen forslag?
// edit edit .. nu forsvandt error, men koden er den samme, så det er nok i orden
Indlæg senest redigeret d. 18.03.2012 21:05 af Bruger #17086