' Copyright (C) 2025  P4pillon.org
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU Affero General Public License as
' published by the Free Software Foundation, either version 3 of the
' License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU Affero General Public License for more details.
'
' You should have received a copy of the GNU Affero General Public License
' along with this program.  If not, see <https://www.gnu.org/licenses/>.
Public Class MyMsg_Box



    Public Sub Presentation(Titre As String, Texte As String, ByVal ONE_Show As Boolean, ByVal ONE_Texte As String, ByVal TWO_Show As Boolean, ByVal TWO_Texte As String, ByVal THREE_Show As Boolean, ByVal THREE_Texte As String)
  
        Try


            Title_Label.Text = Titre
            RichTextBox1.Text = vbCrLf & Texte
            If ONE_Show Then
                ONE_Button.Visible = True
                ONE_Button.Text = ONE_Texte
            Else
                ONE_Button.Visible = False
            End If
            If TWO_Show Then
                TWO_Button.Visible = True
                TWO_Button.Text = TWO_Texte
            Else
                TWO_Button.Visible = False
            End If
            If THREE_Show Then
                THREE_Button.Visible = True
                THREE_Button.Text = THREE_Texte
            Else
                THREE_Button.Visible = False
            End If


            Application.DoEvents()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub ONE_Button_Click(sender As Object, e As EventArgs) Handles ONE_Button.Click
        Me.DialogResult = Windows.Forms.DialogResult.Yes
    End Sub

    Private Sub TWO_Button_Click(sender As Object, e As EventArgs) Handles TWO_Button.Click
        Me.DialogResult = Windows.Forms.DialogResult.No
    End Sub


    Private Sub THREE_Button_Click(sender As Object, e As EventArgs) Handles THREE_Button.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub MyMsg_Box_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
        Select Case e.KeyCode
            Case 79 '"o", "O"
                If ONE_Button.Visible = True Then
                    ONE_Button_Click(Nothing, Nothing)
                End If
            Case 78 '"n", "N"
                If TWO_Button.Visible = True Then
                    TWO_Button_Click(Nothing, Nothing)
                End If
            Case Keys.Enter, 13
                If THREE_Button.Visible = True Then
                    THREE_Button_Click(Nothing, Nothing)
                End If
        End Select
    End Sub




    Private Sub MyMsg_Box_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        round()
        apiBlockInput(0)
        round2(RichTextBox1)
        round2(ONE_Button)
        round2(TWO_Button)
        round2(THREE_Button)
        RichTextBox1.SelectAll()
        RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
    End Sub
    Private Sub round()
        Me.FormBorderStyle = FormBorderStyle.None
        'Me.Height = 300
        'Me.Width = 400
        Dim p As New Drawing2D.GraphicsPath()
        p.StartFigure()
        p.AddArc(New Rectangle(0, 0, 40, 40), 180, 90)
        p.AddLine(40, 0, Me.Width - 40, 0)
        p.AddArc(New Rectangle(Me.Width - 40, 0, 40, 40), -90, 90)
        p.AddLine(Me.Width, 40, Me.Width, Me.Height - 40)
        p.AddArc(New Rectangle(Me.Width - 40, Me.Height - 40, 40, 40), 0, 90)
        p.AddLine(Me.Width - 40, Me.Height, 40, Me.Height)
        p.AddArc(New Rectangle(0, Me.Height - 40, 40, 40), 90, 90)
        p.CloseFigure()
        Me.Region = New Region(p)
        'Me.BackColor = Color.Red
    End Sub
   
End Class