' 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 Microsoft.VisualBasic.PowerPacks.Printing


Public Class DP_Alerte_Med_PrintForm

    Private printername As String

    Private Sub DP_Alerte_PrintForm_Load(sender As Object, e As EventArgs) Handles Me.Load
        Me.Location = New Point(0, 0)
        Dim pd As New PrintDialog
        If pd.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Me.Close()

        printername = pd.PrinterSettings.PrinterName
    End Sub

    Private Sub DP_Alerte_Med_PrintForm_Shown(sender As Object, e As EventArgs) Handles Me.Shown
        Application.DoEvents()
        Dim pf As New PrintForm
        pf.PrinterSettings.PrinterName = printername
        pf.Form = Me
        pf.PrintAction = Printing.PrintAction.PrintToPrinter
        pf.PrinterSettings.DefaultPageSettings.Margins.Bottom = 0
        pf.PrinterSettings.DefaultPageSettings.Margins.Left = 0
        pf.PrinterSettings.DefaultPageSettings.Margins.Right = 0
        pf.PrinterSettings.DefaultPageSettings.Margins.Top = 0

        pf.Print()
        Me.Close()
    End Sub
End Class