784a52f0a9
- inseriti i messaggi nel file dei messaggi; - piccole correzioni nelle funzioni regex (\b --> \.*).
285 lines
9.1 KiB
VB.net
285 lines
9.1 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports System.IO
|
|
Imports System.Windows
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
Imports Ionic.Zip
|
|
|
|
Public Class PrintWndVM
|
|
Inherits VMBase
|
|
|
|
Shared m_Door As Part
|
|
|
|
#Region "MESSAGES"
|
|
|
|
Public ReadOnly Property Title As String
|
|
Get
|
|
' Print
|
|
Return EgtMsg(50411)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PrintMsg As String
|
|
Get
|
|
Return EgtMsg(50411)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
' Cancel
|
|
Return EgtMsg(50412)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property PrintToolTip As String
|
|
Get
|
|
Return EgtMsg(50411)
|
|
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
|
|
|
|
#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
|
|
|
|
' 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()
|
|
Dim nLayer As Integer = EgtGetFirstNameInGroup(nFirstPart, sLayerName)
|
|
If bSelect Then EgtSetStatus(nLayer, GDB_ST.ON_) Else EgtSetStatus(nLayer, GDB_ST.OFF)
|
|
Return True
|
|
End Function
|
|
|
|
Private m_cmdPrint As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
|
|
#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 printDlg As New PrintDialog
|
|
|
|
If printDlg.ShowDialog() Then
|
|
|
|
' Recupero le dimensioni dell'area di stampa
|
|
Dim dW As Double = printDlg.PrintableAreaWidth
|
|
Dim dH As Double = printDlg.PrintableAreaHeight
|
|
|
|
'' 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"
|
|
If Not EgtGetImage(SM.HIDDENLINE, colWhite, colWhite, nImgW, nImgH, sPath) Then
|
|
' Error in creating the print image
|
|
EgtOutLog(EgtMsg(50181))
|
|
Return
|
|
End If
|
|
|
|
Try
|
|
'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()
|
|
End If
|
|
Next
|
|
EgtSetCurrentContext(Map.refSceneManagerVM.ProjectScene.GetCtx)
|
|
End Sub
|
|
|
|
#End Region ' CancelCommand
|
|
|
|
Sub New()
|
|
' 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_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 |