Option Strict On
Option Explicit On

Imports System

Namespace Nexamas.UI.DiagnosticsDashboard

    ''' <summary>
    ''' Read-only layout facts supplied by the owning layout/application surface.
    ''' </summary>
    ''' <remarks>
    ''' The diagnostics dashboard does not scan controls, walk visual trees, mutate layout, or create UI.
    ''' Layout owners may pass already-known counts through this contract so the dashboard can display them.
    ''' </remarks>
    Friend NotInheritable Class MASDiagnosticsDashboardLayoutSnapshot

        Friend Shared ReadOnly Empty As New MASDiagnosticsDashboardLayoutSnapshot(0L, 0, "", False)

        Friend Sub New(layoutPassCount As Long,
                       elementCount As Integer,
                       ownerName As String,
                       factsAvailable As Boolean)
            Me.LayoutPassCount = Math.Max(0L, layoutPassCount)
            Me.ElementCount = Math.Max(0, elementCount)
            Me.OwnerName = If(ownerName, String.Empty)
            Me.FactsAvailable = factsAvailable
        End Sub

        Friend ReadOnly Property LayoutPassCount As Long
        Friend ReadOnly Property ElementCount As Integer
        Friend ReadOnly Property OwnerName As String
        Friend ReadOnly Property FactsAvailable As Boolean

        Friend ReadOnly Property HasElementFacts As Boolean
            Get
                Return FactsAvailable AndAlso ElementCount >= 0
            End Get
        End Property

        Friend Shared Function FromCounts(layoutPassCount As Long,
                                          elementCount As Integer,
                                          ownerName As String) As MASDiagnosticsDashboardLayoutSnapshot
            Return New MASDiagnosticsDashboardLayoutSnapshot(layoutPassCount, elementCount, ownerName, True)
        End Function

    End Class

End Namespace
