Option Strict On
Option Explicit On

Imports Nexamas.UI.Rendering
Imports Nexamas.UI.Values

Namespace Nexamas.UI.Architecture

    ''' <summary>
    ''' Declares which shadow roles are valid for which architectural surface families.
    ''' This registry validates the contract only. It does not choose shadow strength.
    ''' Shadow strength is owned by MASShadowResolver through MASShadowRole.
    ''' </summary>
    Friend NotInheritable Class MASShadowContractRegistry

        Private Sub New()
        End Sub

        ''' <summary>
        ''' Returns whether the given role/family pair is legal.
        ''' None is always legal. Generic cannot carry a real shadow.
        ''' </summary>
        Friend Shared Function IsSupported(role As MASShadowRole,
                                           fam As CommonEnums.SurfaceFamily) As Boolean

            If role = MASShadowRole.None Then
                Return True
            End If

            If fam = CommonEnums.SurfaceFamily.Generic Then
                Return False
            End If

            Select Case role

                Case MASShadowRole.Soft
                    Return AllowsSoftShadow(fam)

                Case MASShadowRole.Control
                    Return AllowsControlShadow(fam)

                Case MASShadowRole.Floating
                    Return AllowsFloatingShadow(fam)

                Case MASShadowRole.Popup
                    Return AllowsPopupShadow(fam)

                Case MASShadowRole.Shell
                    Return AllowsShellShadow(fam)

                Case MASShadowRole.Dialog
                    Return AllowsDialogShadow(fam)

                Case MASShadowRole.Toast
                    Return fam = CommonEnums.SurfaceFamily.Toast

                Case MASShadowRole.Tooltip
                    Return fam = CommonEnums.SurfaceFamily.Tooltip

                Case Else
                    Return False

            End Select

        End Function

        Private Shared Function AllowsSoftShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.ScrollBar,
                     CommonEnums.SurfaceFamily.CheckBox,
                     CommonEnums.SurfaceFamily.RadioButton,
                     CommonEnums.SurfaceFamily.ToggleSwitch,
                     CommonEnums.SurfaceFamily.Row,
                     CommonEnums.SurfaceFamily.ProgressBar,
                     CommonEnums.SurfaceFamily.ColorPickerSVBox,
                     CommonEnums.SurfaceFamily.ColorPickerHueBar,
                     CommonEnums.SurfaceFamily.ColorPickerSlot,
                     CommonEnums.SurfaceFamily.ColorPickerSwatch,
                     CommonEnums.SurfaceFamily.ColorPickerMarker,
                     CommonEnums.SurfaceFamily.GroupBoxTitlePlate

                    Return True

                Case Else
                    Return AllowsControlShadow(fam)

            End Select

        End Function

        Private Shared Function AllowsControlShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.Input,
                     CommonEnums.SurfaceFamily.ComboBox,
                     CommonEnums.SurfaceFamily.Chip,
                     CommonEnums.SurfaceFamily.TabItem,
                     CommonEnums.SurfaceFamily.ButtonMas,
                     CommonEnums.SurfaceFamily.ButtonTal,
                     CommonEnums.SurfaceFamily.SegmentedControl,
                     CommonEnums.SurfaceFamily.TabStrip,
                     CommonEnums.SurfaceFamily.Tile,
                     CommonEnums.SurfaceFamily.TileBox,
                     CommonEnums.SurfaceFamily.SelectorItem,
                     CommonEnums.SurfaceFamily.CheckBox,
                        CommonEnums.SurfaceFamily.RadioButton,
                        CommonEnums.SurfaceFamily.ToggleSwitch,
                     CommonEnums.SurfaceFamily.ColorPickerPreview,
                     CommonEnums.SurfaceFamily.Chart,
                     CommonEnums.SurfaceFamily.PropertyGrid

                    Return True

                Case Else
                    Return AllowsFloatingShadow(fam)

            End Select

        End Function

        Private Shared Function AllowsFloatingShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.ListSurface,
                     CommonEnums.SurfaceFamily.Media,
                     CommonEnums.SurfaceFamily.DataGrid,
                     CommonEnums.SurfaceFamily.ListBox,
                     CommonEnums.SurfaceFamily.Card,
                     CommonEnums.SurfaceFamily.GroupBox,
                     CommonEnums.SurfaceFamily.ColorPicker,
                     CommonEnums.SurfaceFamily.PanelShell,
                     CommonEnums.SurfaceFamily.TopBar

                    Return True

                Case Else
                    Return AllowsPopupShadow(fam)

            End Select

        End Function

        Private Shared Function AllowsPopupShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.DropDown,
                     CommonEnums.SurfaceFamily.DropDownMenu,
                     CommonEnums.SurfaceFamily.ContextMenu,
                     CommonEnums.SurfaceFamily.Menu,
                     CommonEnums.SurfaceFamily.Fenster

                    Return True

                Case Else
                    Return False

            End Select

        End Function

        Private Shared Function AllowsShellShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.PanelShell,
                     CommonEnums.SurfaceFamily.TopBar,
                     CommonEnums.SurfaceFamily.Fenster

                    Return True

                Case Else
                    Return False

            End Select

        End Function

        Private Shared Function AllowsDialogShadow(fam As CommonEnums.SurfaceFamily) As Boolean

            Select Case fam
                Case CommonEnums.SurfaceFamily.Fenster,
                     CommonEnums.SurfaceFamily.PanelShell,
                     CommonEnums.SurfaceFamily.Card

                    Return True

                Case Else
                    Return False

            End Select

        End Function

    End Class

End Namespace