Imports System.IO Imports System.Net.Mail Imports System.Text Imports EgtBEAMWALL.Core Imports EgtUILib Imports MigraDoc.DocumentObjectModel Imports MigraDoc.Rendering Module Configuration ''' ''' tolgo eventuale indicazione solido rimasta da pezzo precedente ''' ''' Id pezzo ''' booleano visualizzazione solido 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 & "\OptStatistics.pdf" PrevSelect() End If Dim renderer As New PdfDocumentRenderer(True) With { .Document = document} renderer.RenderDocument() renderer.PdfDocument.Options.FlateEncodeMode = PdfSharp.Pdf.PdfFlateEncodeMode.BestCompression renderer.PdfDocument.Options.UseFlateDecoderForJpegImages = PdfSharp.Pdf.PdfUseFlateDecoderForJpegImages.Automatic renderer.PdfDocument.Options.CompressContentStreams = True 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 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