' 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/>.
Imports System.Drawing.Printing

Public Class Choix_Papier

    Public num_facture_SV As Integer
    Public num_facture_VD As Integer

    Private Sub Choix_Papier_Load(sender As Object, e As EventArgs) Handles Me.Load
        PopulateInstalledPrintersCombo()
    End Sub

    Private Sub PopulateInstalledPrintersCombo()
        comboInstalledPrinters.Items.Clear()

        ' Add list of installed printers found to the combo box. 
        ' The pkInstalledPrinters string will be used to provide the display string. 
        Dim i As Integer
        Dim pkInstalledPrinters As String

        For i = 0 To PrinterSettings.InstalledPrinters.Count - 1

            pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i)

            comboInstalledPrinters.Items.Add(pkInstalledPrinters.ToString)
        Next
        comboInstalledPrinters.SelectedIndex = 0
    End Sub

 

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

        If RadioButton1.Checked = True Then
            Dim impr As New CERFA
            impr.cerfa_médecin = False
            impr.num_facture_SV = num_facture_SV
            impr.num_facture_VD = num_facture_VD
            impr.Type_Papier_CERFA = True
            impr.selected_printer = comboInstalledPrinters.Text
            If DUPLICATA_CheckBox.Checked = True Then
                impr.duplicata = True
            End If
            impr.Visible = True
            Me.Close()
        ElseIf RadioButton2.Checked = True Then
            Dim impr As New CERFA
            impr.num_facture_SV = num_facture_SV
            impr.num_facture_VD = num_facture_VD
            impr.Type_Papier_CERFA = False
            impr.selected_printer = comboInstalledPrinters.Text
            If DUPLICATA_CheckBox.Checked = True Then
                impr.duplicata = True
            End If
            impr.Visible = True
            Me.Close()
        ElseIf RadioButton3.Checked = True Then
            Dim impr As New CERFA
            impr.cerfa_médecin = True
            impr.num_facture_SV = num_facture_SV
            impr.Type_Papier_CERFA = True
            impr.selected_printer = comboInstalledPrinters.Text
            If DUPLICATA_CheckBox.Checked = True Then
                impr.duplicata = True
            End If
            impr.Visible = True
            Me.Close()
        Else
            MyMsg_Box.Presentation("Impression feuille de soins:", "Aucun type de document n'est selectionné, voulez vous en choisir un ?", True, "OUI", True, "NON", False, "")
            If MyMsg_Box.ShowDialog = Windows.Forms.DialogResult.Yes Then
                Exit Sub
            Else
                Me.Close()
            End If
        End If
    End Sub

    Private Sub Choix_Papier_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Me.TopMost = True
        Me.TopLevel = True
    End Sub
End Class