20e5c383a9
-> gestione delle quote nell'assemblato, -> correzione caricamento parametri Off dei Jamb, -> correzione gestione riposizionamento (side) delle componenti sui telai
429 lines
15 KiB
VB.net
429 lines
15 KiB
VB.net
Imports combit.ListLabel25
|
|
Imports combit.ListLabel25.DataProviders
|
|
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Windows
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Ionic.Zip
|
|
Imports System.Collections.Generic
|
|
|
|
|
|
Public Class PrintWndVM
|
|
Inherits VMBase
|
|
|
|
Shared m_Door As Part
|
|
Friend MyLL As ListLabel
|
|
Private sPathImage As String
|
|
|
|
#Region "MESSAGES"
|
|
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
' Print
|
|
Return EgtMsg(50411)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DesignMsg As String
|
|
Get
|
|
' Design
|
|
Return EgtMsg(50312)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
' Cancel
|
|
Return EgtMsg(50412)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DeisgnToolTip As String
|
|
Get
|
|
' Design
|
|
Return EgtMsg(50312)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property HardwareMsg As String
|
|
Get
|
|
' Hardware
|
|
Return EgtMsg(50413)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property DimensioningMsg As String
|
|
Get
|
|
' Dimensioning
|
|
Return EgtMsg(50414)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property SavePDFMsg As String
|
|
Get
|
|
' Save as pdf
|
|
Return EgtMsg(50313)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
' abilita la selezione delle quote degli hardware
|
|
Private m_IsEnableCompoList As Boolean = True
|
|
Public ReadOnly Property IsEnableCompoList As Boolean
|
|
Get
|
|
Return m_IsEnableCompoList
|
|
End Get
|
|
End Property
|
|
|
|
' abilita la visualizzazione del bottone Design per definire i report
|
|
Private m_DesignVisibility As Visibility = OptionModule.m_VisibilityBtnDesign
|
|
Public Property DesignVisibility As Visibility
|
|
Get
|
|
Return m_DesignVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_DesignVisibility = value
|
|
End Set
|
|
End Property
|
|
|
|
' lista degli hardware presenti nella porta corrente
|
|
Private m_CompoList As New ObservableCollection(Of HardwareDimension)
|
|
Public Property CompoList As ObservableCollection(Of HardwareDimension)
|
|
Get
|
|
Return m_CompoList
|
|
End Get
|
|
Set(value As ObservableCollection(Of HardwareDimension))
|
|
m_CompoList = value
|
|
End Set
|
|
End Property
|
|
|
|
Shared Function TurnDimensioningLayer(sLayerName As String, bSelect As Boolean) As Boolean
|
|
Dim nFirstPart As Integer = EgtGetFirstPart()
|
|
While nFirstPart > 0
|
|
Dim nLayer As Integer = EgtGetFirstNameInGroup(nFirstPart, sLayerName)
|
|
If bSelect Then EgtSetStatus(nLayer, GDB_ST.ON_) Else EgtSetStatus(nLayer, GDB_ST.OFF)
|
|
nFirstPart = EgtGetNextPart(nFirstPart)
|
|
End While
|
|
Return True
|
|
End Function
|
|
|
|
Private m_cmdDesign As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
Private m_cmdSavePDF As ICommand
|
|
|
|
#Region "Preview"
|
|
|
|
Public Sub Preview()
|
|
' Creo l'immagine da allegare
|
|
' Nascondo la tavola ed eseguo zoom su quello che rimane
|
|
EgtZoom(ZM.ALL, True)
|
|
' Prendo l'immagine per la stampa
|
|
Dim colWhite As New Color3d(255, 255, 255)
|
|
Dim nImgW As Integer = 3000
|
|
Dim nImgH As Integer = 4000
|
|
Dim sPath As String = m_sTempDir & "\Image.png"
|
|
EgtSetLineAttribs(3)
|
|
If Not EgtGetImage(SM.HIDDENLINE, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
' Error in creating the print image
|
|
EgtOutLog(EgtMsg(50181))
|
|
Return
|
|
End If
|
|
EgtSetLineAttribs(1)
|
|
DdfFile.OrderInReport.Image = sPath
|
|
DdfFile.ReportDoor.Order(0).Image = sPath
|
|
' aggiungo file pdf da allegare
|
|
Dim FilePDF As New ReportAttachments("c:\Users\Nicola\Desktop\EdgePull4.pdf")
|
|
DdfFile.ReportDoor.AttachmentsList.Add(FilePDF)
|
|
sPathImage = sPath
|
|
Try
|
|
MyLL.DataBindingMode = DataBindingMode.Preload
|
|
'Dim Order As New List(Of ReportOrder)
|
|
'Order.Add(DdfFile.OrderInReport)
|
|
Dim Order As New List(Of TableDoor)
|
|
Order.Add(DdfFile.ReportDoor)
|
|
MyLL.SetDataBinding(Order, String.Empty)
|
|
If String.IsNullOrEmpty(IniFile.m_sListLabelCurrent) Then
|
|
'Dim VettOfFiles As String() = Directory.GetFiles(IniFile.m_sListLabelDir)
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelDir + "\MyOrder.lst"
|
|
Else
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelCurrent
|
|
End If
|
|
' permette di visualizzare una prestampa
|
|
MyLL.AutoDestination = LlPrintMode.PreviewControl
|
|
MyLL.AutoShowSelectFile = OptionModule.m_EnableBrowse
|
|
MyLL.AutoShowPrintOptions = False
|
|
MyLL.AutoProjectType = LlProject.List Or LlProject.FileAlsoNew
|
|
MyLL.Print()
|
|
IniFile.m_sListLabelCurrent = MyLL.LastProjectFile
|
|
WriteMainPrivateProfileString(S_REPORT, K_CURRENTREPORT, IniFile.m_sListLabelCurrent)
|
|
Catch generatedExceptionName As LL_User_Aborted_Exception
|
|
Catch LlException As ListLabelException
|
|
MessageBox.Show("Information: " + LlException.Message + vbLf & vbLf & "This information was generated by a List & Label custom exception.", "Information", MessageBoxButton.OK, MessageBoxImage.Information)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "SAvePDFCommand"
|
|
|
|
Public ReadOnly Property SavePDFCommand As ICommand
|
|
Get
|
|
If m_cmdSavePDF Is Nothing Then
|
|
m_cmdSavePDF = New Command(AddressOf SavePDF)
|
|
End If
|
|
Return m_cmdSavePDF
|
|
End Get
|
|
End Property
|
|
|
|
Sub SavePDF()
|
|
Try
|
|
MyLL.DataBindingMode = DataBindingMode.Preload
|
|
Dim Order As New List(Of TableDoor)
|
|
Order.Add(DdfFile.ReportDoor)
|
|
MyLL.SetDataBinding(Order, String.Empty)
|
|
If String.IsNullOrEmpty(IniFile.m_sListLabelCurrent) Then
|
|
'Dim VettOfFiles As String() = Directory.GetFiles(IniFile.m_sListLabelDir)
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelDir + "\MyOrder.lst"
|
|
Else
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelCurrent
|
|
End If
|
|
' permette di visualizzare una prestampa
|
|
MyLL.AutoDestination = LlPrintMode.PreviewControl
|
|
MyLL.AutoShowPrintOptions = OptionModule.m_EnableBrowse
|
|
MyLL.AutoProjectType = LlProject.List Or LlProject.FileAlsoNew
|
|
' Manca la selezione della path completa per salvare il pdf (ora nella cartella Report)
|
|
MyLL.Export(New ExportConfiguration(LlExportTarget.Pdf, IniFile.m_sListLabelDir + "\Test.pdf", IniFile.m_sListLabelCurrent))
|
|
Catch generatedExceptionName As LL_User_Aborted_Exception
|
|
Catch LlException As ListLabelException
|
|
MessageBox.Show("Information: " + LlException.Message + vbLf & vbLf & "This information was generated by a List & Label custom exception.", "Information", MessageBoxButton.OK, MessageBoxImage.Information)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region ' SAvePDFCommand
|
|
|
|
|
|
#Region "PrintCommand"
|
|
|
|
Public ReadOnly Property DesignCommand As ICommand
|
|
Get
|
|
If m_cmdDesign Is Nothing Then
|
|
m_cmdDesign = New Command(AddressOf Design)
|
|
End If
|
|
Return m_cmdDesign
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Design(ByVal param As Object)
|
|
Try
|
|
MyLL.DataBindingMode = DataBindingMode.Preload
|
|
Dim Order As New List(Of TableDoor)
|
|
Order.Add(DdfFile.ReportDoor)
|
|
MyLL.SetDataBinding(Order, String.Empty)
|
|
If String.IsNullOrEmpty(IniFile.m_sListLabelCurrent) Then
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelDir + "\MyOrder.lst"
|
|
Else
|
|
MyLL.AutoProjectFile = IniFile.m_sListLabelCurrent
|
|
End If
|
|
' permette di visualizzare una prestampa
|
|
MyLL.AutoDestination = LlPrintMode.PreviewControl
|
|
MyLL.AutoShowPrintOptions = OptionModule.m_EnableBrowse
|
|
MyLL.AutoProjectType = LlProject.List Or LlProject.FileAlsoNew
|
|
MyLL.Design()
|
|
Catch generatedExceptionName As LL_User_Aborted_Exception
|
|
Catch LlException As ListLabelException
|
|
MessageBox.Show("Information: " + LlException.Message + vbLf & vbLf & "This information was generated by a List & Label custom exception.", "Information", MessageBoxButton.OK, MessageBoxImage.Information)
|
|
End Try
|
|
Preview()
|
|
End Sub
|
|
|
|
Public Sub Print(ByVal param As Object)
|
|
Dim printDlg As New PrintDialog
|
|
Dim sPath = sPathImage
|
|
If printDlg.ShowDialog() Then
|
|
' Recupero le dimensioni dell'area di stampa
|
|
Dim dW As Double = printDlg.PrintableAreaWidth
|
|
Dim dH As Double = printDlg.PrintableAreaHeight
|
|
Try
|
|
Preview()
|
|
'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.Margin = New Thickness(30)
|
|
' ruoto a seconda dell'aspetto della pagina
|
|
'If (dH > dW And nImgH < nImgW) Or (dH < dW And nImgH > nImgW) Then
|
|
' tmpImg.LayoutTransform = New RotateTransform(-90)
|
|
'End If
|
|
tmpImg.EndInit()
|
|
' eseguo la stampa
|
|
printDlg.PrintVisual(tmpImg, "Parts Layout")
|
|
Catch
|
|
' Rrror in executing print
|
|
EgtOutLog(EgtMsg(50182))
|
|
End Try
|
|
End If
|
|
' Chiusura finestra
|
|
For Each Window In Application.Current.Windows
|
|
If TypeOf Window Is PrintWndV Then
|
|
Dim CurrWindow As PrintWndV = DirectCast(Window, PrintWndV)
|
|
CurrWindow.Close()
|
|
End If
|
|
Next
|
|
EgtSetCurrentContext(Map.refSceneManagerVM.ProjectScene.GetCtx)
|
|
|
|
End Sub
|
|
|
|
#End Region ' PrintCommand
|
|
|
|
#Region "CancelCommand"
|
|
|
|
Public ReadOnly Property CancelCommand() As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Close)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Close()
|
|
' Chiusura finestra
|
|
For Each Window In Application.Current.Windows
|
|
If TypeOf Window Is PrintWndV Then
|
|
Dim CurrWindow As PrintWndV = DirectCast(Window, PrintWndV)
|
|
CurrWindow.Close()
|
|
MyLL.Dispose()
|
|
End If
|
|
Next
|
|
EgtSetCurrentContext(Map.refSceneManagerVM.ProjectScene.GetCtx)
|
|
|
|
End Sub
|
|
|
|
#End Region ' CancelCommand
|
|
|
|
Sub New()
|
|
MyLL = New ListLabel
|
|
MyLL.LicensingInfo = "4pODHQ"
|
|
' copio il riferimento della porta corrente
|
|
m_Door = Map.refPartPageVM.CurrPart
|
|
Dim IndexCompoDoor As Integer = 1
|
|
Dim IndexCompoPrint As Integer = 0
|
|
' carico la lista di hardware presenti nella porta
|
|
Dim LocalHardware As New HardwareDimension
|
|
If m_Door.CompoList.Count >= 1 Then
|
|
LocalHardware.NameHardware = m_Door.CompoList(0).CompoType.Name
|
|
GetPrivateProfileCompoName(ConstCompo.S_LAYER, ConstCompo.K_LAYER_NAME, "", LocalHardware.NameLayer, m_Door.CompoList(0).CompoType.Path & "\" & CONFIGINI_FILE_NAME)
|
|
LocalHardware.SetSelectedLayer(True)
|
|
End If
|
|
CompoList.Add(LocalHardware)
|
|
While IndexCompoDoor < m_Door.CompoList.Count
|
|
If m_CompoList(IndexCompoPrint).NameHardware <> m_Door.CompoList(IndexCompoDoor).CompoType.Name Then
|
|
LocalHardware = New HardwareDimension
|
|
LocalHardware.NameHardware = m_Door.CompoList(IndexCompoDoor).CompoType.Name
|
|
GetPrivateProfileLayerName(ConstCompo.S_LAYER, ConstCompo.K_LAYER_NAME, LocalHardware.NameLayer, m_Door.CompoList(IndexCompoPrint).CompoType.Path & "\" & CONFIGINI_FILE_NAME)
|
|
LocalHardware.SetSelectedLayer(True)
|
|
m_CompoList.Add(LocalHardware)
|
|
IndexCompoPrint += 1
|
|
End If
|
|
IndexCompoDoor += 1
|
|
End While
|
|
NotifyPropertyChanged("CompoList")
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class HardwareDimension
|
|
Inherits VMBase
|
|
|
|
' il nome del Layer viene letto dal file Config.ini
|
|
Private m_NameLayer As String = String.Empty
|
|
Public Property NameLayer As String
|
|
Get
|
|
Return m_NameLayer
|
|
End Get
|
|
Set(value As String)
|
|
m_NameLayer = value
|
|
End Set
|
|
End Property
|
|
|
|
' nome dell'hardware
|
|
Private m_NameHardware As String
|
|
Public Property NameHardware As String
|
|
Get
|
|
Return m_NameHardware
|
|
End Get
|
|
Set(value As String)
|
|
m_NameHardware = value
|
|
NotifyPropertyChanged("NameHardware")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_NameHardwareDDF As String
|
|
Public Property NameHardwareDDF As String
|
|
Get
|
|
Return m_NameHardwareDDF
|
|
End Get
|
|
Set(value As String)
|
|
m_NameHardwareDDF = value
|
|
NotifyPropertyChanged("NameHardware")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsActive As Boolean
|
|
Public Property IsActive As Boolean
|
|
Get
|
|
Return m_IsActive
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_IsActive = value
|
|
m_HardwareDimension_Visibility = If(m_IsActive, Visibility.Visible, Visibility.Collapsed)
|
|
NotifyPropertyChanged("HardwareDimension_Visibility")
|
|
NotifyPropertyChanged("IsActive")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_HardwareDimension_Visibility As Visibility
|
|
Public ReadOnly Property HardwareDimension_Visibility As Visibility
|
|
Get
|
|
Return m_HardwareDimension_Visibility
|
|
End Get
|
|
End Property
|
|
|
|
' selezione dell'hardware
|
|
Private m_SelectedLayer As Boolean = False
|
|
Public Property SelectedLayer As Boolean
|
|
Get
|
|
Return m_SelectedLayer
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_SelectedLayer = value
|
|
PrintWndVM.TurnDimensioningLayer(m_NameLayer, m_SelectedLayer)
|
|
WriteMainPrivateProfileString("Dimensions", NameHardware, If(m_SelectedLayer, "1", "0"))
|
|
Map.refSceneManagerVM.RefreshBtn()
|
|
EgtZoom(ZM.ALL)
|
|
NotifyPropertyChanged("SelectedLayer")
|
|
End Set
|
|
End Property
|
|
|
|
Public Sub SetSelectedLayer(value As Boolean)
|
|
m_SelectedLayer = value
|
|
PrintWndVM.TurnDimensioningLayer(m_NameLayer, m_SelectedLayer)
|
|
WriteMainPrivateProfileString("Dimensions", NameHardware, If(m_SelectedLayer, "1", "0"))
|
|
NotifyPropertyChanged("SelectedLayer")
|
|
End Sub
|
|
|
|
End Class |