Option Strict On
Option Explicit On

Imports System.Collections.Generic
Imports Nexamas.UI.Theming

Namespace Nexamas.UI.Components

    Friend NotInheritable Class MessageBoxRequestFactory

        Private Sub New()
        End Sub

        Friend Shared Function Info(message As String,
                                    Optional title As String = "Information",
                                    Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Information) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsOK() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function Success(message As String,
                                       Optional title As String = "Success",
                                       Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Success) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsOK() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function Warning(message As String,
                                       Optional title As String = "Warning",
                                       Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Warning) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsOK() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function [Error](message As String,
                                       Optional title As String = "Error",
                                       Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Error) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsOK() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function Question(title As String,
                                        message As String,
                                        Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Question) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsYesNo() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function QuestionYesNoCancel(title As String,
                                                   message As String,
                                                   Optional detail As String = "") As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Question) _
                .WithTitle(title) _
                .WithMessage(message) _
                .WithDetail(detail) _
                .WithButtonsYesNoCancel() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function ConfirmDelete(itemName As String) As MessageBoxRequest

            Dim safeName As String = If(itemName, String.Empty).Trim()

            If safeName.Length = 0 Then
                safeName = "this item"
            End If

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Delete) _
                .WithTitle("Delete item") _
                .WithMessage("Are you sure you want to delete " & safeName & "?") _
                .WithDetail("This action cannot be undone.") _
                .WithDeleteCancel() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function ConfirmDiscardChanges() As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Warning) _
                .WithTitle("Discard changes") _
                .WithMessage("You have unsaved changes.") _
                .WithDetail("If you continue, your changes will be lost.") _
                .WithButtonsYesNoCancel() _
                .WithCloseButton(True) _
                .Build()

        End Function

        Friend Shared Function ConfirmCreateMissingIconsLibrary() As MessageBoxRequest

            Return MessageBoxRequestBuilder.Create(MessageBoxKind.Warning) _
                .WithTitle("Icons library not found") _
                .WithMessage("The icons library file was not found.") _
                .WithDetail("The application can create it now, but this may take some time. Choose Accept to continue or Cancel to close the application.") _
                .WithButtonsAndResults(
                    buttons:=New List(Of MASButtonSpec) From {
                        New MASButtonSpec(
                            text:="Accept",
                            personality:=MASButtonPersonality.Tal,
                            intent:=MASButtonIntent.Primary,
                            isDefault:=True,
                            isSelected:=False,
                            isEnabled:=True
                        ),
                        New MASButtonSpec(
                            text:="Cancel",
                            personality:=MASButtonPersonality.Tal,
                            intent:=MASButtonIntent.Subtle,
                            isDefault:=False,
                            isSelected:=False,
                            isEnabled:=True
                        )
                    },
                    results:=New List(Of MessageBoxResult) From {
                        MessageBoxResult.OK,
                        MessageBoxResult.Cancel
                    }) _
                .WithDefaultResult(MessageBoxResult.OK) _
                .WithEscapeResult(MessageBoxResult.Cancel) _
                .WithCloseButton(True) _
                .Build()

        End Function

    End Class

End Namespace