Files
egtbeamwall/EgtBEAMWALL.Optimizer/Utility/Configuration.vb
T
Demetrio Cassarino 7fceefc63e Optimizer 2.7.11.11
-inizio creazione pdf senza migradoc
2025-11-27 11:34:55 +01:00

103 lines
4.8 KiB
VB.net

Imports System.Printing
Imports System.Windows.Xps
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports MigraDoc.DocumentObjectModel
Imports MigraDoc.Rendering
Module Configuration
''' <summary>
''' tolgo eventuale indicazione solido rimasta da pezzo precedente
''' </summary>
''' <param name="nPartId">Id pezzo</param>
''' <param name="bShowSolid">booleano visualizzazione solido</param>
Friend Sub DeselectSolid(Optional nPartId As Integer = 0, Optional bShowSolid As Boolean = False)
If Map.refShowBeamPanelVM.ShowSolid_IsChecked Then
' tolgo eventuale indicazione solido rimasta da pezzo precedente
Map.refShowBeamPanelVM.SetShowSolid(False)
If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(nPartId, False, False)
End If
End Sub
' Public Sub CreatePrintPDF(ActivePage As Integer, bPreview As Boolean)
' LoadingWndHelper.OpenLoadingWnd(ActiveIds.CREATINGPDF, 1, "Creating PDF", "", 100)
' Try
' ' creo documento MigraDoc
' Dim document As Document = PDFHelper.CreateStatReport(ActivePage, bPreview)
'#If DEBUG Then
' Dim documentPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\MigraDoc.mdddl"
' MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, documentPath)
'#End If
' ' salvo il documento
' Dim sFileName As String = ""
' If ActivePage = Pages.VIEW AndAlso Not bPreview Then
' sFileName = ProjectManagerVM.CurrProd.sProdDirPath & "\" & "Statistics.pdf"
' ElseIf ActivePage = Pages.VIEW AndAlso bPreview Then
' sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf" ' Se la pagina e' 0 e' bPreview e' True creo PDF Visualization
' ElseIf ActivePage = Pages.MACHINING AndAlso Not bPreview Then
' sFileName = ProjectManagerVM.CurrProd.sProdDirPath & "\" & ProjectManagerVM.CurrProd.sProdId & " - " & "Statistics.pdf"
' ElseIf ActivePage = Pages.MACHINING AndAlso bPreview Then ' Se la pagina e' 1 e' bPreview e' True creo PDF Optimizer
' sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf"
' PrevSelect()
' End If
' Dim renderer As New PdfDocumentRenderer() With {
' .Document = document}
' renderer.RenderDocument()
' renderer.PdfDocument.Save(sFileName)
' If Not bPreview Then Process.Start(sFileName)
' Catch ex As Exception
' EgtOutLog("Error genereting pdf: " & ex.ToString())
' Finally
' LoadingWndHelper.CloseLoadingWnd(ActiveIds.CREATINGPDF)
' End Try
' End Sub
Public Sub CreatePrintPDF(ActivePage As Integer, bPreview As Boolean)
LoadingWndHelper.OpenLoadingWnd(ActiveIds.CREATINGPDF, 1, "Creating PDF", "", 100)
Try
Dim doc As FlowDocument = PDFFlowHelper.CreateStatReportFlow(ActivePage, bPreview)
Dim sFileName As String = ""
If ActivePage = Pages.VIEW AndAlso Not bPreview Then
sFileName = ProjectManagerVM.CurrProd.sProdDirPath & "\Statistics.pdf"
ElseIf ActivePage = Pages.VIEW AndAlso bPreview Then
sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf"
ElseIf ActivePage = Pages.MACHINING AndAlso Not bPreview Then
sFileName = ProjectManagerVM.CurrProd.sProdDirPath & "\" & ProjectManagerVM.CurrProd.sProdId & " - Statistics.pdf"
ElseIf ActivePage = Pages.MACHINING AndAlso bPreview Then
sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf"
PrevSelect()
End If
Dim server As New LocalPrintServer()
Dim queue As PrintQueue = server.GetPrintQueue("Microsoft Print to PDF")
Dim writer As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(queue)
Dim paginator As DocumentPaginator = CType(doc, IDocumentPaginatorSource).DocumentPaginator
writer.Write(paginator)
'If Not bPreview AndAlso System.IO.File.Exists(sFileName) Then
' Process.Start(sFileName)
'End If
Catch ex As Exception
EgtOutLog("Error generating PDF from FlowDocument: " & ex.ToString())
Finally
LoadingWndHelper.CloseLoadingWnd(ActiveIds.CREATINGPDF)
End Try
End Sub
Private Sub PrevSelect()
' ripristino selezione precedente
Dim nCurrMachGroupId As Integer = EgtGetCurrMachGroup()
If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup) AndAlso nCurrMachGroupId <> Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.Id Then
EgtSetCurrMachGroup(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.Id)
End If
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False)
EgtZoom(ZM.ALL, True)
End Sub
End Module