Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.General
Imports Nexamas.UI.Rendering
Imports Nexamas.UI.Theming
Imports Nexamas.UI.Values
Imports Nexamas.UI.Architecture
Imports Nexamas.UI.Layout
Imports Nexamas.UI.Composition
Imports SkiaSharp

Namespace Nexamas.UI.Controls


    Partial Public NotInheritable Class MASGroupBox
#Region "Factories"

        Public Shared Function Create() As MASGroupBox
            Return New MASGroupBox()
        End Function

        Public Shared Function Create(title As String) As MASGroupBox
            Return New MASGroupBox(title)
        End Function

        Friend Shared Function [Default]() As MASGroupBox

            Return New MASGroupBox().
                WithSurfaceSource(MASGroupBoxSurfaceSource.Acrylic).
                WithBorderRecipe(MASGroupBoxBorderRecipe.ListSurface).
                WithBorderStrength(MASGroupBoxBorderStrength.Level5).
                WithPremiumBorder(True).
                WithShadow(True)

        End Function

#End Region


#Region "Fluent API - Bounds"

        Friend Function SetBounds(bounds As SKRect) As MASGroupBox
            Me.SetLocalLayoutBoundsInternal(bounds)
            Return Me
        End Function

        Friend Function SetBounds(x As Single,
                                  y As Single,
                                  width As Single,
                                  height As Single) As MASGroupBox

            Me.SetLocalLayoutBoundsInternal(
                New SKRect(x, y, x + width, y + height))

            Return Me

        End Function

        Friend Function WithBounds(bounds As SKRect) As MASGroupBox
            Return SetBounds(bounds)
        End Function

        Friend Function WithBounds(x As Single,
                                   y As Single,
                                   width As Single,
                                   height As Single) As MASGroupBox

            Return SetBounds(x, y, width, height)

        End Function

#End Region




#Region "Fluent API - Content"

        Public Function WithTitle(title As String) As MASGroupBox
            Me.Title = title
            Return Me
        End Function

#End Region




#Region "Fluent API - Surface"

        Public Function WithSurfaceSource(value As MASGroupBoxSurfaceSource) As MASGroupBox
            Me.SurfaceSource = value
            Return Me
        End Function

        Public Function WithBorderRecipe(value As MASGroupBoxBorderRecipe) As MASGroupBox
            Me.BorderRecipe = value
            Return Me
        End Function

        Public Function WithBorderStrength(value As MASGroupBoxBorderStrength) As MASGroupBox
            Me.BorderStrength = value
            Return Me
        End Function

        Public Function WithSurfaceMaterial(materialKey As String) As MASGroupBox
            Me.SurfaceMaterial = materialKey
            Return Me
        End Function

        Public Function WithPremiumBorder(value As Boolean) As MASGroupBox
            Me.DrawPremiumBorder = value
            Return Me
        End Function

        Public Function WithShadow(value As Boolean) As MASGroupBox
            Me.DrawShadow = value
            Return Me
        End Function

        Public Function WithSeparator(value As Boolean) As MASGroupBox
            Me.DrawSeparator = value
            Return Me
        End Function

        Public Function WithReserveHeaderWhenEmpty(value As Boolean) As MASGroupBox
            Me.ReserveHeaderWhenEmpty = value
            Return Me
        End Function

#End Region



#Region "Fluent API - Padding"

        <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
        Friend Function WithPadding(all As Single) As MASGroupBox
            SetPadding(all)
            Return Me
        End Function

        <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
        Friend Function WithPadding(horizontal As Single,
                                    vertical As Single) As MASGroupBox

            SetPadding(horizontal, vertical)
            Return Me

        End Function

        <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
        Friend Function WithPadding(left As Single,
                                    top As Single,
                                    right As Single,
                                    bottom As Single) As MASGroupBox

            Me.PaddingLeft = left
            Me.PaddingTop = top
            Me.PaddingRight = right
            Me.PaddingBottom = bottom

            Return Me

        End Function

#End Region




#Region "Fluent API - Children"

        Public Function Add(control As MASControlBase) As MASGroupBox

            AddChild(control)

            Return Me

        End Function

        Public Function Add(control As MASControlBase,
                            relativeContentBounds As SKRect) As MASGroupBox

            AddChild(control, relativeContentBounds)

            Return Me

        End Function

        Public Function Remove(control As MASControlBase) As MASGroupBox

            RemoveChild(control)

            Return Me

        End Function

        Public Function Clear() As MASGroupBox

            ClearChildren()

            Return Me

        End Function

#End Region




#Region "Fluent API - State"

        Public Function Show() As MASGroupBox
            Me.Visible = True
            Return Me
        End Function

        Public Function Hide() As MASGroupBox
            Me.Visible = False
            Return Me
        End Function

        Public Function Enable() As MASGroupBox
            Me.Enabled = True
            Return Me
        End Function

        Public Function Disable() As MASGroupBox
            Me.Enabled = False
            Return Me
        End Function

        Public Function WithVisible(value As Boolean) As MASGroupBox
            Me.Visible = value
            Return Me
        End Function

        Public Function WithEnabled(value As Boolean) As MASGroupBox
            Me.Enabled = value
            Return Me
        End Function

#End Region





#Region "Unified MASSize Fluent API"

        ''' <summary>
        ''' Strongly typed entry into the shared MASSize intent API.
        ''' This method keeps fluent chains on the concrete element while delegating all sizing decisions to MASControlBase/MASSize.
        ''' </summary>
        Public Shadows Function WithSize(sizeIntent As Nexamas.UI.Layout.MASSize) As MASGroupBox
            MyBase.SetSize(sizeIntent)
            Return Me
        End Function






#End Region

    End Class

End Namespace
