Option Strict On
Option Explicit On

Imports SkiaSharp
Imports Nexamas.UI.General

Namespace Nexamas.UI.Rendering

    Friend NotInheritable Class MASChartControlTokens
        Private Sub New()
        End Sub

        Friend Shared ReadOnly Property DesiredSizeDip As SKSize
            Get
                Return New SKSize(360.0F, 220.0F)
            End Get
        End Property

        Friend Shared ReadOnly Property MinimumSizeDip As SKSize
            Get
                Return New SKSize(180.0F, 120.0F)
            End Get
        End Property

        Friend Const SurfaceInsetDip As Single = 4.0F
        Friend Const ContentInsetDip As Single = 16.0F
        Friend Const TitleHeightDip As Single = 28.0F
        Friend Const AxisLabelHeightDip As Single = 18.0F
        Friend Const GridLineCount As Integer = 4
        Friend Const SeriesPointRadiusDip As Single = 3.0F
        Friend Const LineStrokeDip As Single = 2.0F
        Friend Const SparklineStrokeDip As Single = 1.6F
        Friend Const BarRadiusDip As Single = 4.0F
        Friend Const SurfaceRadiusDip As Single = 16.0F

        Friend Shared Function ToPx(valueDip As Single, dpi As Single) As Single
            Return valueDip * PixelSnap.SafeDpi(dpi)
        End Function

        Friend Shared Function ResolveSurfaceRect(boundsPx As SKRect, dpi As Single) As SKRect
            Dim inset As Single = ToPx(SurfaceInsetDip, dpi)
            Dim result As SKRect = boundsPx
            result.Inflate(-inset, -inset)
            Return result
        End Function

        Friend Shared Function ResolvePlotRect(boundsPx As SKRect, dpi As Single) As SKRect
            Dim surface As SKRect = ResolveSurfaceRect(boundsPx, dpi)
            Dim inset As Single = ToPx(ContentInsetDip, dpi)
            Dim titleHeight As Single = ToPx(TitleHeightDip, dpi)
            Dim axisLabelHeight As Single = ToPx(AxisLabelHeightDip, dpi)

            Return New SKRect(
                surface.Left + inset,
                surface.Top + inset + titleHeight,
                surface.Right - inset,
                surface.Bottom - inset - axisLabelHeight)
        End Function
    End Class

End Namespace
