Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.Layout

Namespace Nexamas.UI.Application

    ''' <summary>
    ''' Beginner-facing application-level facade for the MAS runtime size profile.
    ''' This is the public settings-page gateway; it delegates to the single MASSize runtime owner and does not
    ''' introduce a second sizing, density, or layout system.
    ''' </summary>
    Public NotInheritable Class MASApplicationSizing

        Friend Sub New()
        End Sub

        Public Custom Event CurrentChanged As EventHandler(Of MASSizeProfileChangedEventArgs)
            AddHandler(value As EventHandler(Of MASSizeProfileChangedEventArgs))
                If value Is Nothing Then Return
                MASRuntimeSizeProfileService.AddPublicCurrentChangedHandler(value)
            End AddHandler
            RemoveHandler(value As EventHandler(Of MASSizeProfileChangedEventArgs))
                If value Is Nothing Then Return
                MASRuntimeSizeProfileService.RemovePublicCurrentChangedHandler(value)
            End RemoveHandler
            RaiseEvent(sender As Object, e As MASSizeProfileChangedEventArgs)
                ' Forwarded by MASRuntimeSizeProfileService.
            End RaiseEvent
        End Event

        Public ReadOnly Property Current As MASSizeProfile
            Get
                Return MASRuntimeSizeProfileService.Current
            End Get
        End Property

        Public ReadOnly Property CurrentKind As MASSizeProfileKind
            Get
                Return MASRuntimeSizeProfileService.CurrentKind
            End Get
        End Property

        Public Function GetAll() As IReadOnlyList(Of MASSizeProfile)
            Return MASRuntimeSizeProfileService.GetAllProfiles()
        End Function

        Public Function TryUse(kind As MASSizeProfileKind) As Boolean
            Return MASRuntimeSizeProfileService.TryUse(kind)
        End Function

        Public Function TryUse(profile As MASSizeProfile) As Boolean
            Return MASRuntimeSizeProfileService.TryUse(profile)
        End Function

        Public Sub Use(kind As MASSizeProfileKind)
            MASRuntimeSizeProfileService.Use(kind)
        End Sub

        Public Sub Use(profile As MASSizeProfile)
            MASRuntimeSizeProfileService.Use(profile)
        End Sub

        Public Function TryApplyAndSave(kind As MASSizeProfileKind) As Boolean
            Return MASRuntimeSizeProfileService.TryApplyAndSave(kind)
        End Function

        Public Function TryApplyAndSave(profile As MASSizeProfile) As Boolean
            Return MASRuntimeSizeProfileService.TryApplyAndSave(profile)
        End Function

        Public Sub ApplyAndSave(kind As MASSizeProfileKind)
            MASRuntimeSizeProfileService.ApplyAndSave(kind)
        End Sub

        Public Sub ApplyAndSave(profile As MASSizeProfile)
            MASRuntimeSizeProfileService.ApplyAndSave(profile)
        End Sub

        Public Function SaveCurrent() As Boolean
            Return MASRuntimeSizeProfileService.SaveCurrent()
        End Function

        Public Sub Reset()
            MASRuntimeSizeProfileService.Reset()
        End Sub

    End Class

End Namespace
