Option Strict On
Option Explicit On

Namespace Nexamas.UI.Rendering

    ''' <summary>
    ''' Evidence that material selection can be routed by generic surface slots/profiles without
    ''' element-specific material identities.
    ''' </summary>
    Friend NotInheritable Class MASSurfaceMaterialSlotRoutingReport

        Friend Sub New(name As String,
                       status As MASSurfaceMaterialSlotRoutingStatus,
                       profileCount As Integer,
                       assignmentCount As Integer,
                       canonicalAssignmentCount As Integer,
                       nativeProfileCount As Integer,
                       hasMaterialKeyRoute As Boolean,
                       hasProfileSlotRoute As Boolean,
                       hasDesignerProfileProjection As Boolean,
                       keepsProfilesElementAgnostic As Boolean)
            Me.Name = Normalize(name, "Surface Material Slot Routing")
            Me.Status = status
            Me.ProfileCount = If(profileCount < 0, 0, profileCount)
            Me.AssignmentCount = If(assignmentCount < 0, 0, assignmentCount)
            Me.CanonicalAssignmentCount = If(canonicalAssignmentCount < 0, 0, canonicalAssignmentCount)
            Me.NativeProfileCount = If(nativeProfileCount < 0, 0, nativeProfileCount)
            Me.HasMaterialKeyRoute = hasMaterialKeyRoute
            Me.HasProfileSlotRoute = hasProfileSlotRoute
            Me.HasDesignerProfileProjection = hasDesignerProfileProjection
            Me.KeepsProfilesElementAgnostic = keepsProfilesElementAgnostic
        End Sub

        Friend ReadOnly Property Name As String
        Friend ReadOnly Property Status As MASSurfaceMaterialSlotRoutingStatus
        Friend ReadOnly Property ProfileCount As Integer
        Friend ReadOnly Property AssignmentCount As Integer
        Friend ReadOnly Property CanonicalAssignmentCount As Integer
        Friend ReadOnly Property NativeProfileCount As Integer
        Friend ReadOnly Property HasMaterialKeyRoute As Boolean
        Friend ReadOnly Property HasProfileSlotRoute As Boolean
        Friend ReadOnly Property HasDesignerProfileProjection As Boolean
        Friend ReadOnly Property KeepsProfilesElementAgnostic As Boolean

        Friend ReadOnly Property IsReady As Boolean
            Get
                Return Status = MASSurfaceMaterialSlotRoutingStatus.SlotRoutingReady AndAlso
                       ProfileCount >= 5 AndAlso
                       AssignmentCount > 0 AndAlso
                       AssignmentCount = CanonicalAssignmentCount AndAlso
                       NativeProfileCount >= 2 AndAlso
                       HasMaterialKeyRoute AndAlso
                       HasProfileSlotRoute AndAlso
                       HasDesignerProfileProjection AndAlso
                       KeepsProfilesElementAgnostic
            End Get
        End Property

        Private Shared Function Normalize(value As String, fallback As String) As String
            Dim result As String = If(value, String.Empty).Trim()
            If result.Length = 0 Then Return fallback
            Return result
        End Function

    End Class

End Namespace
