Hi Val,
Well, I have my answer by now, since it seems DrawCore must be called on all levels. Which makes sense.
As for the code, I've trimmed it down to highlight what I'm attempting to do. Here goes:
'--- Default.aspx.vb
myLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear()
myLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(New ColumnSymbologyLineStyle("element_code", "element_subcode"))
myLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
'--- Level 1 - database driven selection:
Public Class ColumnSymbologyLineStyle
Inherits LineStyle
Private m_symColumnName1 As String
Private m_symColumnName2 As String
Public Sub New(ByVal symColumnName1 As String, ByVal symColumnName2 As String)
m_symColumnName1 = symColumnName1
m_symColumnName2 = symColumnName2
End Sub
Protected Overrides Sub DrawCore(...)
Dim useLineStyle As LineStyle
For Each ft As Feature In features
useLineStyle = Nothing
Dim symColumnValue As String = ft.ColumnValues(m_symColumnName1).ToString().Trim()
Select Case symColumnValue
Case "1a"
useLineStyle = New MapInfoPenLineStyle(1, 2, 0)
Case "1b"
useLineStyle = New MapInfoPenLineStyle(2, 4, 255)
Case "1c"
useLineStyle = New MapInfoPenLineStyle(2, 81, 255)
'etc.
End Select
If useLineStyle IsNot Nothing Then
Dim featureCollection As Collection(Of Feature) = New Collection(Of Feature)()
featureCollection.Add(ft)
useLineStyle.Draw(featureCollection, canvas, labelsInThisLayer, labelsInAllLayers)
End If
Next
End Sub
End Class
'--- Level 2 - reusable "enumeration":
Public Class MapInfoPenLineStyle
Inherits LineStyle
Private m_PenPattern As Integer
Private m_PenColor As GeoColor
Private m_PenWidth As Integer
Public Sub New(ByVal penWidth As Integer, ByVal penPattern As Integer, ByVal penColor As Long)
Dim r As Integer, g As Integer, b As Integer
b = CInt(penColor Mod 256L)
g = CInt((penColor \ 256L) Mod 256L)
r = CInt(penColor \ 65536L) '65536 = 256*256
m_PenPattern = penPattern
m_PenColor = New GeoColor(r, g, b)
m_PenWidth = penWidth
End Sub
Protected Overloads Overrides Sub DrawCore(...)
Dim useLineStyle As LineStyle = Nothing
Select Case m_PenPattern
Case 1
'invisible = leave undefined
Case 2
useLineStyle = New LineStyle(New GeoPen(m_PenColor, m_PenWidth))
Case 3
LineStyles.CreateSimpleLineStyle(m_PenColor, m_PenWidth, LineDashStyle.Dot, True)
'etc. until 118
'example of complex line style:
Case 81
useLineStyle = New MapInfoPen_81_LineStyle(m_PenColor, m_PenWidth)
End Select
For Each ft As Feature In features
If useLineStyle IsNot Nothing Then
Dim featureCollection As Collection(Of Feature) = New Collection(Of Feature)()
featureCollection.Add(ft)
useLineStyle.Draw(featureCollection, canvas, labelsInThisLayer, labelsInAllLayers)
End If
Next
End Sub
End Class
'--- Level 3:
Public Class MapInfoPen_81_LineStyle
Inherits LineStyle
Private m_SymbolColor As GeoColor
Private m_LineWidth As Integer = 1
Public Sub New(ByVal rgbColor As Long, ByVal lineWidth As Integer)
Dim r As Integer, g As Integer, b As Integer
b = CInt(rgbColor Mod 256L)
g = CInt((rgbColor \ 256L) Mod 256L)
r = CInt(rgbColor \ 65536L) '65536 = 256*256
m_SymbolColor = New GeoColor(r, g, b)
m_LineWidth = lineWidth
End Sub
Protected Overloads Overrides Sub DrawCore(...)
Const DistBetweenSymbolsPx As Integer = 16
Dim worldIncrDist As Double = ExtentHelper.GetWorldDistanceBetweenTwoScreenPoints(canvas.CurrentWorldExtent, 0, 0, DistBetweenSymbolsPx, 0, canvas.Width, canvas.Height, GeographyUnit.Meter, DistanceUnit.Meter)
Dim screenRadius As Double = 3
Dim useLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Black, m_LineWidth, False)
For Each ft In features
Dim ftCollection As Collection(Of Feature) = New Collection(Of Feature)()
ftCollection.Add(ft)
useLineStyle.Draw(ftCollection, canvas, labelsInThisLayer, labelsInAllLayers)
Dim curShape As LineShape = DirectCast(ft.GetShape, LineShape)
Dim worldSumDist As Double = worldIncrDist / 2.0
Dim worldMaxDist As Double = curShape.GetLength(GeographyUnit.Meter, DistanceUnit.Meter)
While worldSumDist < worldMaxDist 'curShape.GetLength(GeographyUnit.Meter, DistanceUnit.Meter)
Dim insPt = curShape.GetPointOnALine(StartingPoint.FirstPoint, worldSumDist, GeographyUnit.Meter, DistanceUnit.Meter)
canvas.DrawEllipse(insPt, screenRadius * 2, screenRadius * 2, New GeoSolidBrush(m_SymbolColor), DrawingLevel.LevelFour)
worldSumDist += worldIncrDist
End While
Next 'ft
End Sub
End Class