''' -----------------------------------------------------------------------------
''' Project	 : NHenry.Exception
''' Class	 : Exception.Main
''' -----------------------------------------------------------------------------
''' <summary>
''' Classe de gestion de l'affichage
''' </summary>
''' -----------------------------------------------------------------------------
Public NotInheritable Class Main
    Private Sub New()
        'e
    End Sub
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Affiche une boite de dialogue dédiée aux erreurs
    ''' </summary>
    ''' <param name="pEx">Exception à afficher</param>
    ''' <param name="pTitle">Titre de la fenetre</param>
    ''' <param name="pDescription">Description (remplace le pEx.ToString())</param>
    ''' <param name="pParams">ColParams contenant des objets pour le débuggage</param>
    ''' <param name="pAddDetail">Détails à ajouter (email par ex)</param>
    ''' <param name="pIcones">Icone à afficher</param>
    ''' <param name="pButtons">Style de boutons à utiliser</param>
    ''' <param name="pDefaultButton">Bouton pâr défaut</param>
    ''' <returns>Retourne un <c>System.Windows.Forms.DialogResult</c> représentant le bouton cliqué</returns>
    ''' <remarks>
    ''' </remarks>
    ''' -----------------------------------------------------------------------------
    Public Shared Function Show( _
    ByVal pEx As System.Exception, _
    Optional ByVal pTitle As String = "Erreur", _
    Optional ByVal pDescription As String = "", _
    Optional ByVal pParams As ColParams = Nothing, _
    Optional ByVal pAddDetail As String = "", _
    Optional ByVal pIcones As Windows.Forms.MessageBoxIcon = Windows.Forms.MessageBoxIcon.None, _
    Optional ByVal pButtons As Windows.Forms.MessageBoxButtons = Windows.Forms.MessageBoxButtons.OK, _
    Optional ByVal pDefaultButton As Windows.Forms.MessageBoxDefaultButton = Windows.Forms.MessageBoxDefaultButton.Button1 _
) As System.Windows.Forms.DialogResult

        Dim lDescription As String = ""
        Dim lDetail As String = ""

        If pDescription <> "" Then
            lDescription = pDescription
        ElseIf Not (pEx Is Nothing) Then
            lDescription = ClsDescriptions.Description(pEx, pParams)
        Else
            lDescription = "Pas de description"
        End If

        If pAddDetail <> "" Then
            lDetail = "Informations : " + pAddDetail + Environment.NewLine + Environment.NewLine
        End If
        If Not (pEx Is Nothing) Then
            lDetail += "Exception : " + ClsDescriptions.Detail(pEx, pParams) + Environment.NewLine + Environment.NewLine
        End If
        If Not (pParams Is Nothing) Then
            lDetail += "Paramètres de l'exception : " + pParams.ToString
        End If

        Return FrmShowError.InitDialog(lDescription, lDetail, pTitle, pIcones, pButtons, pDefaultButton)
    End Function
End Class
