Option Strict On
Option Explicit On

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

Namespace Nexamas.UI.Controls

    Partial Public NotInheritable Class MASProgressBar
#Region "Render"

        Protected Overrides Sub Render(canvas As SKCanvas, ctx As MASThemeContext, pixelBounds As SKRect)
            If canvas Is Nothing OrElse ctx Is Nothing Then Return

            Dim progressSlotLogical As SKRect = ResolveProgressSlotBoundsLogical(BoundsLogical)
            If progressSlotLogical.Width <= 0.5F OrElse progressSlotLogical.Height <= 0.5F Then Return

            Dim dpi As Single = PixelSnap.SafeDpi(ctx.Dpi)
            Dim progressSlotPx As New SKRect(
                progressSlotLogical.Left * dpi,
                progressSlotLogical.Top * dpi,
                progressSlotLogical.Right * dpi,
                progressSlotLogical.Bottom * dpi)

            _renderer.Draw(
                canvas:=canvas,
                ctx:=ctx,
                r:=progressSlotPx,
                minimum:=_minimum,
                maximum:=_maximum,
                value:=ResolveRenderValue(),
                visualState:=_visualState,
                frameMode:=_frameMode,
                containerSurfaceMaterialKey:=_containerSurfaceMaterialKey,
                containerBorderStrength:=_containerBorderStrength,
                containerSurfaceStrength:=_containerSurfaceStrength,
                contract:=_contract)
        End Sub

        Protected Overrides Sub OnBoundsChanged()
            MyBase.OnBoundsChanged()
            ArrangeLabel()
        End Sub

        Protected Overrides Function WantsKeyboardFocus() As Boolean
            Return False
        End Function

        Protected Overrides Function WantsPointerFocus() As Boolean
            Return False
        End Function

        Protected Overrides Function ExcludeFromPointerRouting() As Boolean
            Return True
        End Function

#End Region
    End Class

End Namespace
