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

    Private Sub FlowLayoutPanel1_ControlAdded(sender As Object, e As ControlEventArgs) Handles FlowLayoutPanel1.ControlAdded
        If FlowLayoutPanel1.Controls.Count Mod MyCombobox.FlowLayoutPanel_nbr_lignes = 0 Then
            'If FlowLayoutPanel1.Controls.Count = 3 Then
            FlowLayoutPanel1.SetFlowBreak(e.Control, True)
        End If
    End Sub



    Private Sub FlowLayoutPanel1_SizeChanged(sender As Object, e As EventArgs) Handles FlowLayoutPanel1.SizeChanged
        Me.Size = New Size(FlowLayoutPanel1.Size.Width + Back_Button.Width, FlowLayoutPanel1.Height)

    End Sub

    
    Private Sub Show_items_Load(sender As Object, e As EventArgs) Handles Me.Load

        Dim Form_ScreenPos As Point = Me.PointToScreen(New Point(0, 0))
        If Form_ScreenPos.X + Me.Width > Screen.FromControl(Me).WorkingArea.Width Then
            Me.Location = New Point(Screen.FromControl(Me).WorkingArea.Width - Me.Width - (Screen.FromControl(Me).WorkingArea.Width - MyCombobox.MyCombobox_ScreenPos.X), Me.Location.Y)
            FlowLayoutPanel1.Location = New Point(0, 0)
            Back_Button.Location = New Point(Me.Width - 50, 0)
            Back_Button.Text = "u"
        End If
        If Me.Location.X < 0 Then
            Me.Location = New Point(0, Me.Location.Y)
        End If
        If Form_ScreenPos.Y + Me.Height > Screen.FromControl(Me).WorkingArea.Height Then
            Me.Location = New Point(Me.Location.X, Screen.FromControl(Me).WorkingArea.Height - Me.Height - (Screen.FromControl(Me).WorkingArea.Height - MyCombobox.MyCombobox_ScreenPos.Y) + MyCombobox.MyCombobox_size.Height)
            Back_Button.Location = New Point(Back_Button.Location.X, Me.Height - 50)
        End If
        If Me.Location.Y < 0 Then
            Me.Location = New Point(Me.Location.X, 0)
        End If
    End Sub

  
End Class