' 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 Mes_Couleurs_selecteur

    Public selected_color As String
    Private Sub Mes_Couleurs_selecteur_Load(sender As Object, e As EventArgs) Handles Me.Load
        FlowLayoutPanel1.Controls.Clear()
        Dim toto As New List(Of String)
        For Each colorName As String In KnownColor.GetNames(GetType(KnownColor))
            toto.Add(colorName)
        Next
        toto.Sort()

        'For Each colorName As String In KnownColor.GetNames(GetType(KnownColor))
        For Each colorName As String In toto
            Dim but As New Button
            but.Name = colorName
            but.BackColor = Color.FromName(colorName)
            but.ForeColor = System.Drawing.Color.FromArgb((CInt(but.BackColor.R) + 128) Mod 256, (CInt(but.BackColor.G) + 128) Mod 256, (CInt(but.BackColor.B) + 128) Mod 256)
            but.Height = 30
            but.Width = 150
            but.Text = colorName
            AddHandler but.Click, AddressOf set_selected_color
            FlowLayoutPanel1.Controls.Add(but)
        Next
    End Sub

    Public Sub set_selected_color(sender As Object, e As EventArgs)
        Dim the_color As Color
    
            the_color = Color.FromName(sender.name)
        Mes_Couleurs.Picked_Color = the_color
        Me.Close()
    End Sub


 
   
  
End Class