92 lines
3.2 KiB
VB.net
92 lines
3.2 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Public Class PrintPanelVM
|
|
|
|
' Definizione comandi
|
|
Private m_cmdPrint As ICommand
|
|
|
|
Public ReadOnly Property PrintToolTip As String
|
|
Get
|
|
' "Print shading" & vbCrLf & "Print hidden line (Shift)"
|
|
Return "Print"
|
|
End Get
|
|
End Property
|
|
|
|
#Region "PrintCommand"
|
|
|
|
Public ReadOnly Property PrintCommand As ICommand
|
|
Get
|
|
If m_cmdPrint Is Nothing Then
|
|
m_cmdPrint = New Command(AddressOf Print)
|
|
End If
|
|
Return m_cmdPrint
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Print(ByVal param As Object)
|
|
Dim SM_Select As SM = SM.SHADING
|
|
|
|
' Imposto la stampa HiddenLine (non è gestita la stampa WireFrame)
|
|
'If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 Then
|
|
' SM_Select = SM.HIDDENLINE
|
|
' EgtSetLineAttribs(3)
|
|
'End If
|
|
|
|
' Gestione stampa in funzione del della visualizzazione corrente
|
|
If OmagOFFICEMap.refShowPanelVM.WireframeIsChecked Then
|
|
SM_Select = SM.WIREFRAME
|
|
EgtSetLineAttribs(3)
|
|
ElseIf OmagOFFICEMap.refShowPanelVM.HiddenLineIsChecked Then
|
|
SM_Select = SM.HIDDENLINE
|
|
EgtSetLineAttribs(3)
|
|
End If
|
|
|
|
Dim printDlg As New PrintDialog
|
|
Dim sPath = OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\Image.png"
|
|
If printDlg.ShowDialog() Then
|
|
' Recupero le dimensioni dell'area di stampa
|
|
Dim dW As Double = printDlg.PrintableAreaWidth
|
|
Dim dH As Double = printDlg.PrintableAreaHeight
|
|
Try
|
|
' Prendo l'immagine corrente per la stampa
|
|
Dim colWhite As New Color3d(255, 255, 255)
|
|
' Recupero le dimensioni correnti della pagina di disegno
|
|
Dim nImgW As Integer = GetWidthDimProjectV()
|
|
Dim nImgH As Integer = GetHeightDimProjectV()
|
|
If Not EgtGetImage(SM_Select, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
' Error in creating the print image
|
|
EgtOutLog(EgtMsg(50181))
|
|
EgtSetLineAttribs(1)
|
|
Return
|
|
End If
|
|
EgtSetLineAttribs(1)
|
|
'Metodo complesso di stampa che permette di rilasciare il file :
|
|
'carico la bitmap e la metto in uno stream in memoria
|
|
Dim stream As System.IO.Stream = New System.IO.MemoryStream()
|
|
Dim bitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(sPath)
|
|
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png)
|
|
bitmap.Dispose()
|
|
' la sposto in una BitmapImage
|
|
Dim bitImage As New System.Windows.Media.Imaging.BitmapImage()
|
|
bitImage.BeginInit()
|
|
bitImage.StreamSource = stream
|
|
bitImage.EndInit()
|
|
' la sposto in un Visual Control
|
|
Dim tmpImg As New Image
|
|
tmpImg.BeginInit()
|
|
tmpImg.Source = bitImage
|
|
tmpImg.Stretch = Stretch.Uniform
|
|
tmpImg.EndInit()
|
|
' eseguo la stampa
|
|
printDlg.PrintVisual(tmpImg, EgtMsg(91688)) ' Parts Layout
|
|
Catch
|
|
' Rrror in executing print
|
|
EgtOutLog(EgtMsg(50182))
|
|
End Try
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' PrintCommand
|
|
|
|
End Class
|