Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Specialized
Imports System.Diagnostics
Imports System.IO
Imports System.Windows.Forms
Imports Nexamas.UI.Controls
Imports Nexamas.UI.Composition
Imports Nexamas.UI.FileSystem
Imports Nexamas.UI.General
Imports Nexamas.UI.Rendering
Imports Nexamas.UI.Theming
Imports Nexamas.UI.Values
Imports Nexamas.UI.Layout
Imports SkiaSharp

Namespace Nexamas.UI.Components


    Partial Public NotInheritable Class MASFilePickerControl
#Region "Default focus"

        ' CONTRACT:
        ' Provides the preferred initial focus target when this control is hosted
        ' inside any focusable container.
        '
        ' This contract is host-neutral:
        ' - It does not imply Overlay behavior.
        ' - It does not imply Float behavior.
        ' - It does not imply modal behavior.
        ' - It does not close or control its host.
        Public ReadOnly Property PreferredFocusControl As MASControlBase Implements IMASDefaultFocusProvider.PreferredFocusControl
            Get
                If _controller IsNot Nothing AndAlso _controller.IsSaveMode AndAlso _fileNameBox IsNot Nothing Then
                    Return _fileNameBox
                End If

                If _browser IsNot Nothing Then Return _browser
                Return Me
            End Get
        End Property

        Public Function FocusDefaultInput() As Boolean Implements IMASDefaultFocusProvider.FocusDefaultInput
            Try
                If _controller IsNot Nothing AndAlso _controller.IsSaveMode AndAlso _fileNameBox IsNot Nothing Then
                    _fileNameBox.FocusText()
                    Return True
                End If

                If _browser IsNot Nothing Then
                    RequestFocus(_browser)
                    Return True
                End If
            Catch masCaughtException1 As Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowFileSystemBoundary(masCaughtException1)
            End Try

            Return False
        End Function

#End Region


    End Class

End Namespace
