b10cfb3913
-sistemata grafica progressbar per verifica -aggiunto creazione btlinfo nuovo progetto -aggiunto reset feature -sistemato creazione pdf
840 lines
46 KiB
VB.net
840 lines
46 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtBEAMWALL.Core
|
|
Imports EgtBEAMWALL.Core.ConstGen
|
|
Imports EgtUILib
|
|
Imports MigraDoc.DocumentObjectModel
|
|
Imports MigraDoc.DocumentObjectModel.Shapes
|
|
Imports MigraDoc.DocumentObjectModel.Shapes.Charts
|
|
Imports MigraDoc.DocumentObjectModel.Tables
|
|
Imports PdfSharp.Pdf.Content.Objects
|
|
|
|
Module PDFHelper
|
|
|
|
Friend Enum ListTypes As Integer
|
|
PART = 1
|
|
MACHGROUP = 2
|
|
RAWPART = 3
|
|
MACHGROUPTOT = 4
|
|
PART_LIST = 5
|
|
PART_TOT = 6
|
|
End Enum
|
|
|
|
Private m_TestText As String = "Testo di prova per testare MigraDoc nuget package"
|
|
Private m_TestMediumText As String = "Testo di prova MEDIO per testare MigraDoc nuget package"
|
|
Private m_TestShortText As String = "Testo di prova CORTO"
|
|
|
|
Public Function CreateStatReport(ActivePage As Pages, bPreview As Boolean) As Document
|
|
' creo nuovo documento MigraDoc
|
|
Dim document As New Document()
|
|
|
|
If ActivePage = Pages.VIEW Then
|
|
document.Info.Title = ProjectManagerVM.CurrProd.sProdId & " - " & ProjectManagerVM.CurrProd.BTLFileName_Msg & " - Statistics"
|
|
ElseIf ActivePage = Pages.MACHINING Then
|
|
document.Info.Title = ProjectManagerVM.CurrProd.sProdId & " - " & ProjectManagerVM.CurrProd.ListName_Msg & " - Statistics"
|
|
End If
|
|
|
|
document.Info.Subject = "Production statistics of the project"
|
|
document.Info.Author = "Optimizer"
|
|
DefineStyles(document)
|
|
'Logo
|
|
Dim section As Section = document.AddSection()
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
|
|
Dim sImageLogo As String = Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Logo landscape.png"
|
|
If Not System.IO.File.Exists(sImageLogo) Then
|
|
sImageLogo = Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\notfound.png"
|
|
End If
|
|
DefineLogo(section, sImageLogo)
|
|
|
|
|
|
If ActivePage = Pages.VIEW Then
|
|
DefinePartTotals(document, section, bPreview)
|
|
DefineItemList(document, ListTypes.PART, bPreview)
|
|
ElseIf ActivePage = Pages.MACHINING Then
|
|
DefineMachGroupTotals(document, section, bPreview)
|
|
DefineItemList(document, ListTypes.MACHGROUP, bPreview)
|
|
DefineItemList(document, ListTypes.RAWPART, bPreview)
|
|
If True Then
|
|
CreateRawPartPages(document, bPreview)
|
|
End If
|
|
End If
|
|
|
|
Return document
|
|
End Function
|
|
|
|
Public Sub DefinePartTotals(document As Document, section As Section, bPreview As Boolean)
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph(EgtMsg(61734) & "s", "Heading2")
|
|
paragraph.Format.SpaceBefore = "3.5cm"
|
|
Dim sPartTot As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61734)) ' Recupero lista Part Totals
|
|
Dim sBTLTotParts As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61716)) ' Recupero Numero totale pezzi con relativo checkbox
|
|
Dim sBTLTotVolume As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61717)) ' Recupero Volume totale con relativo checkbox
|
|
Dim sBTLTotTime As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61718)) ' Recupero Tempo totale con relativo checkbox
|
|
Dim sBTLRemainingTime As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61720)) ' Recupero Tempo rimanente con relativo checkbox
|
|
If sBTLTotParts.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotParts, "127"))
|
|
If sBTLTotVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotVolume_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotVolume, "9.156"))
|
|
If sBTLTotTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotTime_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotTime, "00:01:55"))
|
|
If sBTLRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLRemainingTime_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLRemainingTime, "00:01:55"))
|
|
End Sub
|
|
|
|
Public Sub DefineMachGroupTotals(ByVal document As Document, section As Section, bPreview As Boolean)
|
|
' cambio orientamento a orizzontale
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph(EgtMsg(61729), "Heading2")
|
|
paragraph.Format.SpaceBefore = "3.5cm"
|
|
Dim sMachGroup As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61729)) ' Recupero lista Machgroup Totals
|
|
Dim sNumberBlanks As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61721)) ' Recupero Numero di grezzi con relativo checkbox
|
|
Dim sTotalVolume As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61717)) ' Recupero Volume totale con relativo checkbox
|
|
Dim sEstimatedTotalTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61719)) ' Recupero Tempo totale stimato con relativo checkbox
|
|
Dim sTotalTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61718)) ' Recupero Tempo totale con relativo checkbox
|
|
Dim sRemainingTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61720)) ' Recupero Tempo rimanente con relativo checkbox
|
|
Dim sNumberPiecesBLT As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61722)) ' Recupero Numero di pezzi da BTL con relativo checkbox
|
|
Dim sNumberPiecesAdded As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61723)) ' Recupero Numero di pezzi aggiunti con relativo checkbox
|
|
Dim sNumberPiecesInsertedBlanks As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61724)) ' Recupero Numero di pezzi inseriti nei grezzi con relativo checkbox
|
|
Dim sNumberPiecesCompleted As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61725)) ' Recupero Numero di pezzi completati con relativo checkbox
|
|
If sNumberBlanks.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.TotMachGroups_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotMachGroups, "11"))
|
|
If sTotalVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotVolume_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotVolume, "3.168"))
|
|
If sEstimatedTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotEstimatedTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotEstimatedTime, "00:22:30"))
|
|
If sTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLTotTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotTime, "00:09:23"))
|
|
If sRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.BTLRemainingTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sRemainingTime, "00:09:23"))
|
|
If sNumberPiecesBLT.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.TotCNTParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotCNTParts, "127"))
|
|
If sNumberPiecesAdded.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.TotADDEDParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotADDEDParts, "0"))
|
|
If sNumberPiecesInsertedBlanks.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.TotINPRODParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotINPRODParts, "69"))
|
|
If sNumberPiecesCompleted.bParameter_IsChecked Then paragraph = section.AddParagraph(Statistic_Messages.TotDONEParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotDONEParts, "5"))
|
|
End Sub
|
|
|
|
Public Sub DefineItemList(ByVal document As Document, nListType As ListTypes, bPreview As Boolean)
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
|
|
'Recupero la lista delle colonne delle tabelle
|
|
Dim sMachGroupList As ExpanderTable = Nothing
|
|
If nListType = ListTypes.MACHGROUP Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61730)).ExpanderElementList.FirstOrDefault() ' Lista Tabella MachGroup List
|
|
ElseIf nListType = ListTypes.RAWPART Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61732)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Raw Part List
|
|
ElseIf nListType = ListTypes.PART Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61733)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Part List
|
|
End If
|
|
Dim sName As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_NAME) ' Recupero colonna 'colName' con relativo checkbox
|
|
Dim sW As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_W) ' Recupero colonna 'colW' con relativo checkbox
|
|
Dim sH As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_H) ' Recupero colonna 'colH' con relativo checkbox
|
|
Dim sL As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_L) ' Recupero colonna 'colL' con relativo checkbox
|
|
Dim sMaterial As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_MATERIAL) ' Recupero colonna 'colMaterial' con relativo checkbox
|
|
Dim sUsage As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_USAGE) ' Recupero colonna 'colUsage' con relativo checkbox
|
|
Dim sWaste As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_WASTE) ' Recupero colonna 'colWaste' con relativo checkbox
|
|
Dim sUTime As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_UNITTIME) ' Recupero colonna 'colUnitTime' con relativo checkbox
|
|
Dim sQty As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_QTY) ' Recupero colonna 'colQuantity' con relativo checkbox
|
|
Dim sPDN As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_PDN) ' Recupero colonna 'colPDN' con relativo checkbox
|
|
Dim sDesc As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DESC) ' Recupero colonna 'colDescription' con relativo checkbox
|
|
Dim sCNT As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_CNT) ' Recupero colonna 'colCNT' con relativo checkbox
|
|
Dim sAdded As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_ADDED) ' Recupero colonna 'colAdded' con relativo checkbox
|
|
Dim sDone As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DONE) ' Recupero colonna 'colDone' con relativo checkbox
|
|
Dim sUVolume As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_UNITVOLUME) ' Recupero colonna 'colUnitVolume' con relativo checkbox
|
|
Dim sTVolume As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_TOTVOLUME) ' Recupero colonna 'colTotVolume' con relativo checkbox
|
|
Dim sTTime As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_TOTTIME) ' Recupero colonna 'colTotTime' con relativo checkbox
|
|
Dim sINProd As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_INPROD) ' Recupero colonna 'colInProd' con relativo checkbox
|
|
Dim section As Section = document.LastSection()
|
|
DefineItem(document, nListType, bPreview, sMachGroupList, sName, sW, sH, sL, sMaterial, sUsage, sWaste, sUTime, sQty, sPDN, sDesc, sCNT, sAdded, sDone, sUVolume, sTVolume, sTTime, sINProd, section)
|
|
End Sub
|
|
|
|
Private Sub DefineItem(document As Document, nListType As ListTypes, bPreview As Boolean, sMachGroupList As ExpanderTable, sName As EgtDataGridColumn, sW As EgtDataGridColumn, sH As EgtDataGridColumn, sL As EgtDataGridColumn, sMaterial As EgtDataGridColumn, sUsage As EgtDataGridColumn, sWaste As EgtDataGridColumn, sUTime As EgtDataGridColumn, sQty As EgtDataGridColumn, sPDN As EgtDataGridColumn, sDesc As EgtDataGridColumn, sCNT As EgtDataGridColumn, sAdded As EgtDataGridColumn, sDone As EgtDataGridColumn, sUVolume As EgtDataGridColumn, sTVolume As EgtDataGridColumn, sTTime As EgtDataGridColumn, sINProd As EgtDataGridColumn, section As Section)
|
|
Select Case nListType
|
|
Case ListTypes.PART : section.AddParagraph(EgtMsg(61733), "Heading2")
|
|
Case ListTypes.MACHGROUP : section.AddParagraph(EgtMsg(61730), "Heading2")
|
|
Case ListTypes.RAWPART : section.AddParagraph(EgtMsg(61732), "Heading2")
|
|
End Select
|
|
|
|
Dim items As IList(Of Object) = GetItemList(nListType, bPreview)
|
|
If Not bPreview AndAlso (IsNothing(items) OrElse items.Count = 0) Then Return
|
|
|
|
Dim activeColumns As New List(Of Integer)
|
|
|
|
For i As Integer = 0 To sMachGroupList.RawPartColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(i).Name
|
|
|
|
If ColumnIsEnabled(colName, sPDN, sName, sW, sH, sL, sMaterial, sUsage, sWaste, sUTime, sQty, sDesc, sCNT, sAdded, sDone, sUVolume, sTVolume, sTTime, sINProd) Then
|
|
activeColumns.Add(i)
|
|
End If
|
|
Next
|
|
|
|
If activeColumns.Count = 0 Then Return
|
|
|
|
Dim table As New Table()
|
|
table.Borders.Width = 0.75
|
|
|
|
For Each colIndex As Integer In activeColumns
|
|
Dim width As Unit = GetColumnWidth(sMachGroupList.RawPartColumns(colIndex).Name, nListType)
|
|
table.AddColumn(width)
|
|
Next
|
|
|
|
Dim header As Row = table.AddRow()
|
|
header.HeadingFormat = True
|
|
header.Shading.Color = Colors.Aqua
|
|
|
|
For j As Integer = 0 To activeColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
header.Cells(j).AddParagraph(GetHeaderText(colName))
|
|
Next
|
|
|
|
If bPreview Then
|
|
Dim row As Row = table.AddRow()
|
|
For j As Integer = 0 To activeColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
row.Cells(j).AddParagraph(GetCellValue(colName, Nothing, nListType, bPreview))
|
|
Next
|
|
Else
|
|
For Each item As Object In items
|
|
Dim row As Row = table.AddRow()
|
|
|
|
For j As Integer = 0 To activeColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
row.Cells(j).AddParagraph(GetCellValue(colName, item, nListType, bPreview))
|
|
Next
|
|
Next
|
|
End If
|
|
|
|
If table.Columns.Count > 0 AndAlso table.Rows.Count > 0 Then document.LastSection.Add(table)
|
|
End Sub
|
|
|
|
Private Function ColumnIsEnabled(colName As String, sPDN As EgtDataGridColumn, sName As EgtDataGridColumn, sW As EgtDataGridColumn, sH As EgtDataGridColumn, sL As EgtDataGridColumn, sMaterial As EgtDataGridColumn, sUsage As EgtDataGridColumn, sWaste As EgtDataGridColumn, sUTime As EgtDataGridColumn, sQty As EgtDataGridColumn, sDesc As EgtDataGridColumn, sCNT As EgtDataGridColumn, sAdded As EgtDataGridColumn, sDone As EgtDataGridColumn, sUVolume As EgtDataGridColumn, sTVolume As EgtDataGridColumn, sTTime As EgtDataGridColumn, sINProd As EgtDataGridColumn) As Boolean
|
|
Select Case colName
|
|
Case COL_PDN : Return sPDN.bIsChecked
|
|
Case COL_NAME, COL_DESC : Return Not IsNothing(sName) AndAlso sName.bIsChecked Or Not IsNothing(sDesc) AndAlso sDesc.bIsChecked
|
|
Case COL_W : Return sW.bIsChecked
|
|
Case COL_H : Return sH.bIsChecked
|
|
Case COL_L : Return sL.bIsChecked
|
|
Case COL_MATERIAL : Return sMaterial.bIsChecked
|
|
Case COL_USAGE : Return sUsage.bIsChecked
|
|
Case COL_WASTE : Return sWaste.bIsChecked
|
|
Case COL_UNITTIME : Return sUTime.bIsChecked
|
|
Case COL_QTY : Return sQty.bIsChecked
|
|
Case COL_CNT : Return sCNT.bIsChecked
|
|
Case COL_ADDED : Return sAdded.bIsChecked
|
|
Case COL_DONE : Return sDone.bIsChecked
|
|
Case COL_UNITVOLUME : Return sUVolume.bIsChecked
|
|
Case COL_TOTVOLUME : Return sTVolume.bIsChecked
|
|
Case COL_TOTTIME : Return sTTime.bIsChecked
|
|
Case COL_INPROD : Return sINProd.bIsChecked
|
|
Case COL_ID : Return True
|
|
Case Else : Return False
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetColumnWidth(colName As String, nListType As ListTypes) As Unit
|
|
Select Case colName
|
|
Case COL_PDN : Return Unit.FromCentimeter(1)
|
|
Case COL_ID : Return Unit.FromCentimeter(1.5)
|
|
Case COL_W, COL_H : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1), Unit.FromCentimeter(2))
|
|
Case COL_L : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1.6), Unit.FromCentimeter(2))
|
|
Case COL_NAME, COL_DESC : Return Unit.FromCentimeter(4)
|
|
Case COL_MATERIAL : Return Unit.FromCentimeter(2)
|
|
Case COL_CNT : Return Unit.FromCentimeter(1.6)
|
|
Case COL_ADDED : Return Unit.FromCentimeter(1.5)
|
|
Case COL_INPROD : Return Unit.FromCentimeter(2.5)
|
|
Case COL_DONE : Return Unit.FromCentimeter(1.5)
|
|
Case COL_USAGE, COL_WASTE : Return Unit.FromCentimeter(2)
|
|
Case COL_UNITVOLUME : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1.5), Unit.FromCentimeter(2))
|
|
Case COL_TOTVOLUME : Return Unit.FromCentimeter(1.5)
|
|
Case COL_UNITTIME : Return Unit.FromCentimeter(2.2)
|
|
Case COL_TOTTIME : Return Unit.FromCentimeter(2)
|
|
Case COL_QTY : Return Unit.FromCentimeter(2)
|
|
Case Else : Return Unit.FromCentimeter(2)
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetHeaderText(colName As String) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return Statistic_Messages.PDN_Msg
|
|
Case COL_ID : Return Map.refStatisticsVM.ID_Msg
|
|
Case COL_W : Return Statistic_Messages.W_Msg
|
|
Case COL_H : Return Statistic_Messages.H_Msg
|
|
Case COL_L : Return Statistic_Messages.L_Msg
|
|
Case COL_NAME, COL_DESC : Return Statistic_Messages.NAM_Msg
|
|
Case COL_MATERIAL : Return Statistic_Messages.MAT_Msg
|
|
Case COL_CNT : Return Statistic_Messages.CNT_Msg
|
|
Case COL_ADDED : Return Statistic_Messages.ADDED_Msg
|
|
Case COL_INPROD : Return Statistic_Messages.INPROD_Msg
|
|
Case COL_DONE : Return Statistic_Messages.DONE_Msg
|
|
Case COL_USAGE : Return Statistic_Messages.Used_Msg
|
|
Case COL_WASTE : Return Statistic_Messages.Waste_Msg
|
|
Case COL_UNITVOLUME : Return Statistic_Messages.UNIT_VOLUME_Msg
|
|
Case COL_TOTVOLUME : Return Statistic_Messages.TOT_VOLUME_Msg
|
|
Case COL_UNITTIME : Return Statistic_Messages.UNIT_TIME_Msg
|
|
Case COL_TOTTIME : Return Statistic_Messages.TOT_TIME_Msg
|
|
Case COL_QTY : Return Statistic_Messages.QTY_Msg
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetItemList(nListType As ListTypes, bPreview As Boolean) As IList(Of Object)
|
|
If bPreview Then Return New List(Of Object)()
|
|
|
|
Select Case nListType
|
|
Case ListTypes.PART
|
|
Return Map.refProjectVM.BTLStructureVM.BTLPartVMList.Cast(Of Object)().ToList()
|
|
Case ListTypes.MACHGROUP
|
|
Return Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Cast(Of Object)().ToList()
|
|
Case ListTypes.RAWPART
|
|
Map.refStatisticsVM.LoadRawPart()
|
|
Return Map.refStatisticsVM.RawPartList.Cast(Of Object)().ToList()
|
|
Case Else
|
|
Return New List(Of Object)()
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetCellValue(colName As String, item As Object, nListType As ListTypes, bPreview As Boolean) As String
|
|
Select Case nListType
|
|
Case ListTypes.PART
|
|
Dim Part As BTLPartVM = CType(item, BTLPartVM)
|
|
|
|
Select Case colName
|
|
Case COL_PDN : Return If(bPreview, "1", Part.nPDN)
|
|
Case COL_W : Return If(bPreview, "200", Part.sW)
|
|
Case COL_H : Return If(bPreview, "360", Part.sH)
|
|
Case COL_L : Return If(bPreview, "6672.6", Part.sL)
|
|
Case COL_NAME, COL_DESC : Return Part.sNAM
|
|
Case COL_MATERIAL : Return Part.sMATERIAL
|
|
Case COL_CNT : Return If(bPreview, "1", Part.sCNT)
|
|
Case COL_ADDED : Return If(bPreview, "0", Part.sADDED)
|
|
Case COL_INPROD : Return If(bPreview, "0", Part.nINPROD)
|
|
Case COL_DONE : Return If(bPreview, "0", Part.nDONE)
|
|
Case COL_UNITVOLUME : Return If(bPreview, "0.48", Part.sUnitVolume)
|
|
Case COL_TOTVOLUME : Return If(bPreview, "0.48", Part.sTotVolume)
|
|
Case COL_UNITTIME : Return If(bPreview, "00:00:00", Part.sUnitTime)
|
|
Case COL_TOTTIME : Return If(bPreview, "00:00:00", Part.sTotTime)
|
|
End Select
|
|
Case ListTypes.MACHGROUP
|
|
Dim Machgroup As MyMachGroupVM = CType(item, MyMachGroupVM)
|
|
|
|
Select Case colName
|
|
Case COL_ID : Return Machgroup.Id
|
|
Case COL_W : Return If(bPreview, "120", Machgroup.dW)
|
|
Case COL_H : Return If(bPreview, "160", Machgroup.dH)
|
|
Case COL_L : Return If(bPreview, "15000", Machgroup.dL)
|
|
Case COL_NAME, COL_DESC : Return Machgroup.nName
|
|
Case COL_MATERIAL : Return Machgroup.sMATERIAL
|
|
Case COL_USAGE : Return If(bPreview, "99.719", Machgroup.sUsage)
|
|
Case COL_WASTE : Return If(bPreview, "0.5", Machgroup.sWaste)
|
|
Case COL_UNITVOLUME : Return If(bPreview, "0.48", Machgroup.dUnitVolume)
|
|
Case COL_UNITTIME : Return If(bPreview, "00:13:07", Machgroup.sUnitTime)
|
|
End Select
|
|
Case ListTypes.RAWPART
|
|
Dim RawPart As SParam = CType(item, SParam)
|
|
|
|
Select Case colName
|
|
Case COL_W : Return If(bPreview, "120", RawPart.sW)
|
|
Case COL_H : Return If(bPreview, "160", RawPart.sH)
|
|
Case COL_L : Return If(bPreview, "15000", RawPart.sL)
|
|
Case COL_MATERIAL : Return RawPart.sMaterial
|
|
Case COL_QTY : Return If(bPreview, "11", RawPart.nQuantity)
|
|
End Select
|
|
End Select
|
|
|
|
Return ""
|
|
End Function
|
|
|
|
Public Sub CreateRawPartPages(ByVal document As Document, bPreview As Boolean)
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = False
|
|
'Recupero la lista delle colonne delle tabelle
|
|
Dim sMachGroupList As ExpanderTable = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61731)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Raw Part
|
|
Dim sPDN As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_PDN) ' Recupero colonna 'colPDN' con relativo checkbox
|
|
Dim sW As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_W) ' Recupero colonna 'colW' con relativo checkbox
|
|
Dim sH As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_H) ' Recupero colonna 'colH' con relativo checkbox
|
|
Dim sL As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_L) ' Recupero colonna 'colL' con relativo checkbox
|
|
Dim sDesc As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DESC) ' Recupero colonna 'colDescription' con relativo checkbox
|
|
Dim sMaterial As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_MATERIAL) ' Recupero colonna 'colMaterial' con relativo checkbox
|
|
Dim nOrigMachGroupId As Integer = EgtGetCurrMachGroup()
|
|
' Controllo se bPreview è true mostra il PDF di preview se no il PDF completo
|
|
If bPreview Then
|
|
CreateRawPartPage(document, sMachGroupList, sPDN, sW, sH, sL, sDesc, sMaterial, Nothing, bPreview)
|
|
Else
|
|
For Each RawPart As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
|
|
CreateRawPartPage(document, sMachGroupList, sPDN, sW, sH, sL, sDesc, sMaterial, RawPart, bPreview)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CreateRawPartPage(document As Document, sMachGroupList As ExpanderTable, sPDN As EgtDataGridColumn, sW As EgtDataGridColumn, sH As EgtDataGridColumn, sL As EgtDataGridColumn, sDesc As EgtDataGridColumn, sMaterial As EgtDataGridColumn, RawPart As MyMachGroupVM, bPreview As Boolean)
|
|
Dim section As Section = document.AddSection()
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
|
|
Dim items As IList(Of Object)
|
|
|
|
If IsNothing(RawPart) Then
|
|
items = New List(Of Object)()
|
|
CreateRawPartImage(section, sMachGroupList, 44143, 1, bPreview)
|
|
Else
|
|
items = RawPart.PartVMList.Cast(Of Object)().ToList()
|
|
CreateRawPartImage(section, sMachGroupList, RawPart.Id, RawPart.Name, bPreview)
|
|
End If
|
|
|
|
If Not bPreview AndAlso items.Count = 0 Then Exit Sub
|
|
|
|
Dim activeColumns As New List(Of Integer)
|
|
|
|
For i = 0 To sMachGroupList.RawPartColumns.Count - 1
|
|
Dim colName = sMachGroupList.RawPartColumns(i).Name
|
|
|
|
If ColumnRawPartIsEnabled(colName, sPDN, Nothing, sW, sH, sL, sMaterial, Nothing, Nothing, Nothing, Nothing, sDesc, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing) Then
|
|
activeColumns.Add(i)
|
|
End If
|
|
Next
|
|
|
|
If activeColumns.Count = 0 Then Return
|
|
|
|
' --- CREA TABELLA ---
|
|
Dim table As New Table()
|
|
table.Borders.Width = 0.75
|
|
|
|
For Each colIndex In activeColumns
|
|
Dim width = GetRawPartColumnWidth(sMachGroupList.RawPartColumns(colIndex).Name)
|
|
table.AddColumn(width)
|
|
Next
|
|
|
|
Dim header = table.AddRow()
|
|
header.HeadingFormat = True
|
|
header.Shading.Color = Colors.Aqua
|
|
|
|
For j = 0 To activeColumns.Count - 1
|
|
Dim colName = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
header.Cells(j).AddParagraph(GetRawPartHeader(colName))
|
|
Next
|
|
|
|
If bPreview Then
|
|
Dim row = table.AddRow()
|
|
For j = 0 To activeColumns.Count - 1
|
|
Dim colName = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
row.Cells(j).AddParagraph(GetRawPartValue(colName, Nothing, bPreview))
|
|
Next
|
|
Else
|
|
For Each obj In items
|
|
Dim p = CType(obj, PartVM)
|
|
Dim row = table.AddRow()
|
|
|
|
For j = 0 To activeColumns.Count - 1
|
|
Dim colName = sMachGroupList.RawPartColumns(activeColumns(j)).Name
|
|
row.Cells(j).AddParagraph(GetRawPartValue(colName, p, bPreview))
|
|
Next
|
|
Next
|
|
End If
|
|
|
|
If table.Columns.Count > 0 AndAlso table.Rows.Count > 0 Then section.Add(table)
|
|
End Sub
|
|
|
|
Private Function ColumnRawPartIsEnabled(colName As String, sPDN As EgtDataGridColumn, sName As EgtDataGridColumn, sW As EgtDataGridColumn, sH As EgtDataGridColumn, sL As EgtDataGridColumn, sMaterial As EgtDataGridColumn, sUsage As EgtDataGridColumn, sWaste As EgtDataGridColumn, sUTime As EgtDataGridColumn, sQty As EgtDataGridColumn, sDesc As EgtDataGridColumn, sCNT As EgtDataGridColumn, sAdded As EgtDataGridColumn, sDone As EgtDataGridColumn, sUVolume As EgtDataGridColumn, sTVolume As EgtDataGridColumn, sTTime As EgtDataGridColumn, sINProd As EgtDataGridColumn) As Boolean
|
|
Select Case colName
|
|
Case COL_PDN : Return sPDN.bIsChecked
|
|
Case COL_W : Return sW.bIsChecked
|
|
Case COL_H : Return sH.bIsChecked
|
|
Case COL_L : Return sL.bIsChecked
|
|
Case COL_DESC : Return sDesc.bIsChecked
|
|
Case COL_MATERIAL : Return sMaterial.bIsChecked
|
|
Case COL_NAME : Return True
|
|
Case Else : Return False
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartColumnWidth(colName As String) As Unit
|
|
Select Case colName
|
|
Case COL_PDN : Return Unit.FromCentimeter(1.5)
|
|
Case COL_W, COL_H, COL_L : Return Unit.FromCentimeter(2)
|
|
Case COL_DESC, COL_NAME : Return Unit.FromCentimeter(4)
|
|
Case COL_MATERIAL : Return Unit.FromCentimeter(2)
|
|
Case Else : Return Unit.FromCentimeter(2)
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartHeader(colName As String) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return Statistic_Messages.PDN_Msg
|
|
Case COL_W : Return Statistic_Messages.W_Msg
|
|
Case COL_H : Return Statistic_Messages.H_Msg
|
|
Case COL_L : Return Statistic_Messages.L_Msg
|
|
Case COL_DESC, COL_NAME : Return Statistic_Messages.NAM_Msg
|
|
Case COL_MATERIAL : Return Statistic_Messages.MAT_Msg
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartValue(colName As String, p As PartVM, bPreview As Boolean) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return If(bPreview, "55", p.nPDN)
|
|
Case COL_W : Return If(bPreview, "120", p.sW)
|
|
Case COL_H : Return If(bPreview, "160", p.sH)
|
|
Case COL_L : Return If(bPreview, "185.9", p.sL)
|
|
Case COL_DESC, COL_NAME : Return If(bPreview, EgtMsg(63033), p.sNAM)
|
|
Case COL_MATERIAL : Return If(bPreview, "GL24h", p.sMATERIAL)
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub CreateRawPartImage(section As Section, sMachGroupList As ExpanderTable, RawPartId As Integer, RawPartName As String, bPreview As Boolean)
|
|
Dim sImagePath As String = String.Empty
|
|
' creo immagine
|
|
EgtSetCurrMachGroup(RawPartId)
|
|
EgtSetMachineLook(MCH_LOOK.TAB)
|
|
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.FRONT, VT.TOP), False)
|
|
EgtZoom(ZM.ALL, False)
|
|
Dim basePath = Map.refMainWindowVM.MainWindowM.sTempDir
|
|
Dim realImage = $"{basePath}\Image{RawPartId}.png"
|
|
Dim previewImage = $"{basePath}\ImageTest.png"
|
|
sImagePath = If(bPreview, previewImage, realImage)
|
|
EgtGetImage(SM.HIDDENLINE, New Color3d(255, 255, 255), New Color3d(255, 255, 255), 3000, 1000, sImagePath)
|
|
If sMachGroupList.bSection_IsChecked Then section.AddParagraph(RawPartName)
|
|
' aggiungo immagine
|
|
If sMachGroupList.bImage_IsChecked Then
|
|
Dim Image As Image = section.AddImage(sImagePath)
|
|
Image.LockAspectRatio = True
|
|
Image.Width = Unit.FromMillimeter(275)
|
|
Image.RelativeHorizontal = RelativeHorizontal.Page
|
|
Image.RelativeVertical = RelativeHorizontal.Page
|
|
Image.Left = 30
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub DefineLogo(section As Section, sImageLogo As String)
|
|
Dim Image As MigraDoc.DocumentObjectModel.Shapes.Image = section.Headers.FirstPage.AddImage(sImageLogo)
|
|
Image.Width = Unit.FromMillimeter(40)
|
|
Image.Height = Unit.FromMillimeter(40)
|
|
Image.LockAspectRatio = True
|
|
Image.RelativeVertical = RelativeVertical.Line
|
|
Image.Top = ShapePosition.Top
|
|
Image.Left = ShapePosition.Right
|
|
Image.WrapFormat.Style = WrapStyle.Through
|
|
Image.RelativeHorizontal = RelativeHorizontal.Margin
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Defines the styles used in the document.
|
|
''' </summary>
|
|
Public Sub DefineStyles(ByVal document As Document)
|
|
' recupera lo stile predefinito Normal.
|
|
Dim style As Style = document.Styles("Normal")
|
|
' Because all styles are derived from Normal, the next line changes the
|
|
' font of the whole document. Or, more exactly, it changes the font of
|
|
' all styles and paragraphs that do not redefine the font.
|
|
style.Font.Name = "Arial"
|
|
|
|
' Heading1 to Heading9 are predefined styles with an outline level. An outline level
|
|
' other than OutlineLevel.BodyText automatically creates the outline (or bookmarks)
|
|
' in PDF.
|
|
|
|
style = document.Styles("Heading1")
|
|
style.Font.Name = "Tahoma"
|
|
style.Font.Size = 14
|
|
style.Font.Bold = True
|
|
style.Font.Color = Colors.DarkBlue
|
|
style.ParagraphFormat.PageBreakBefore = True
|
|
style.ParagraphFormat.SpaceAfter = 6
|
|
|
|
style = document.Styles("Heading2")
|
|
style.Font.Size = 12
|
|
style.Font.Bold = True
|
|
style.ParagraphFormat.PageBreakBefore = False
|
|
style.ParagraphFormat.SpaceBefore = 6
|
|
style.ParagraphFormat.SpaceAfter = 6
|
|
|
|
style = document.Styles("Heading3")
|
|
style.Font.Size = 10
|
|
style.Font.Bold = True
|
|
style.Font.Italic = True
|
|
style.ParagraphFormat.SpaceBefore = 6
|
|
style.ParagraphFormat.SpaceAfter = 3
|
|
|
|
style = document.Styles(StyleNames.Header)
|
|
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right)
|
|
|
|
style = document.Styles(StyleNames.Footer)
|
|
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center)
|
|
|
|
' Create a new style called TextBox based on style Normal
|
|
style = document.Styles.AddStyle("TextBox", "Normal")
|
|
style.ParagraphFormat.Alignment = ParagraphAlignment.Justify
|
|
style.ParagraphFormat.Borders.Width = 2.5
|
|
style.ParagraphFormat.Borders.Distance = "3pt"
|
|
style.ParagraphFormat.Shading.Color = Colors.SkyBlue
|
|
|
|
' Create a new style called TOC based on style Normal
|
|
style = document.Styles.AddStyle("TOC", "Normal")
|
|
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots)
|
|
style.ParagraphFormat.Font.Color = Colors.Blue
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Defines the cover page.
|
|
''' </summary>
|
|
Public Sub DefineCover(ByVal document As Document)
|
|
Dim section As Section = document.AddSection()
|
|
Dim paragraph As Paragraph = section.AddParagraph()
|
|
paragraph.Format.SpaceAfter = "3cm"
|
|
Dim image As Shapes.Image = section.AddImage("../../images/Logo landscape.png")
|
|
image.Width = "10cm"
|
|
paragraph = section.AddParagraph("A sample document that demonstrates the" & vbLf & "capabilities of MigraDoc")
|
|
paragraph.Format.Font.Size = 16
|
|
paragraph.Format.Font.Color = Colors.DarkRed
|
|
paragraph.Format.SpaceBefore = "8cm"
|
|
paragraph.Format.SpaceAfter = "3cm"
|
|
paragraph = section.AddParagraph("Rendering date: ")
|
|
paragraph.AddDateField()
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Defines table of contents.
|
|
''' </summary>
|
|
Public Sub DefineTableOfContents(ByVal document As Document)
|
|
Dim section As Section = document.LastSection
|
|
section.AddPageBreak()
|
|
Dim paragraph As Paragraph = section.AddParagraph("Table of Contents")
|
|
paragraph.Format.Font.Size = 14
|
|
paragraph.Format.Font.Bold = True
|
|
paragraph.Format.SpaceAfter = 24
|
|
paragraph.Format.OutlineLevel = OutlineLevel.Level1
|
|
paragraph = section.AddParagraph()
|
|
paragraph.Style = "TOC"
|
|
Dim hyperlink As Hyperlink = paragraph.AddHyperlink("Paragraphs")
|
|
hyperlink.AddText("Paragraphs" & vbTab)
|
|
hyperlink.AddPageRefField("Paragraphs")
|
|
paragraph = section.AddParagraph()
|
|
paragraph.Style = "TOC"
|
|
hyperlink = paragraph.AddHyperlink("Tables")
|
|
hyperlink.AddText("Tables" & vbTab)
|
|
hyperlink.AddPageRefField("Tables")
|
|
paragraph = section.AddParagraph()
|
|
paragraph.Style = "TOC"
|
|
hyperlink = paragraph.AddHyperlink("Charts")
|
|
hyperlink.AddText("Charts" & vbTab)
|
|
hyperlink.AddPageRefField("Charts")
|
|
End Sub
|
|
|
|
#Region "Paragraphs"
|
|
|
|
Public Sub DefineParagraphs(ByVal document As Document)
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph("Paragraph Layout Overview", "Heading1")
|
|
paragraph.AddBookmark("Paragraphs")
|
|
DemonstrateParagraphsAlignment(document)
|
|
DemonstrateIndent(document)
|
|
DemonstrateFormattedText(document)
|
|
DemonstrateBordersAndShading(document)
|
|
End Sub
|
|
|
|
Private Sub DemonstrateParagraphsAlignment(ByVal document As Document)
|
|
document.LastSection.AddParagraph("Alignment", "Heading2")
|
|
document.LastSection.AddParagraph("Left Aligned", "Heading3")
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Alignment = ParagraphAlignment.Left
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("Right Aligned", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Alignment = ParagraphAlignment.Right
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("Centered", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Alignment = ParagraphAlignment.Center
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("Justified", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Alignment = ParagraphAlignment.Justify
|
|
paragraph.AddText(m_TestMediumText)
|
|
End Sub
|
|
|
|
Private Sub DemonstrateIndent(ByVal document As Document)
|
|
document.LastSection.AddParagraph("Indent", "Heading2")
|
|
document.LastSection.AddParagraph("Left Indent", "Heading3")
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.LeftIndent = "2cm"
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("Right Indent", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.RightIndent = "1in"
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("First Line Indent", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.FirstLineIndent = "12mm"
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("First Line Negative Indent", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.LeftIndent = "1.5cm"
|
|
paragraph.Format.FirstLineIndent = "-1.5cm"
|
|
paragraph.AddText(m_TestText)
|
|
End Sub
|
|
|
|
Private Sub DemonstrateFormattedText(ByVal document As Document)
|
|
document.LastSection.AddParagraph("Formatted Text", "Heading2")
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph()
|
|
paragraph.AddText("Text can be formatted ")
|
|
paragraph.AddFormattedText("bold", TextFormat.Bold)
|
|
paragraph.AddText(", ")
|
|
paragraph.AddFormattedText("italic", TextFormat.Italic)
|
|
paragraph.AddText(", or ")
|
|
paragraph.AddFormattedText("bold & italic", TextFormat.Bold Or TextFormat.Italic)
|
|
paragraph.AddText(".")
|
|
paragraph.AddLineBreak()
|
|
paragraph.AddText("You can set the ")
|
|
Dim formattedText As FormattedText = paragraph.AddFormattedText("size ")
|
|
formattedText.Size = 15
|
|
paragraph.AddText("the ")
|
|
formattedText = paragraph.AddFormattedText("color ")
|
|
formattedText.Color = Colors.Firebrick
|
|
paragraph.AddText("the ")
|
|
formattedText = paragraph.AddFormattedText("font", New Font("Verdana"))
|
|
paragraph.AddText(".")
|
|
paragraph.AddLineBreak()
|
|
paragraph.AddText("You can set the ")
|
|
formattedText = paragraph.AddFormattedText("subscript")
|
|
formattedText.Subscript = True
|
|
paragraph.AddText(" or ")
|
|
formattedText = paragraph.AddFormattedText("superscript")
|
|
formattedText.Superscript = True
|
|
paragraph.AddText(".")
|
|
End Sub
|
|
|
|
Private Sub DemonstrateBordersAndShading(ByVal document As Document)
|
|
document.LastSection.AddPageBreak()
|
|
document.LastSection.AddParagraph("Borders and Shading", "Heading2")
|
|
document.LastSection.AddParagraph("Border around Paragraph", "Heading3")
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Borders.Width = 2.5
|
|
paragraph.Format.Borders.Color = Colors.Navy
|
|
paragraph.Format.Borders.Distance = 3
|
|
paragraph.AddText(m_TestMediumText)
|
|
document.LastSection.AddParagraph("Shading", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Format.Shading.Color = Colors.LightCoral
|
|
paragraph.AddText(m_TestText)
|
|
document.LastSection.AddParagraph("Borders & Shading", "Heading3")
|
|
paragraph = document.LastSection.AddParagraph()
|
|
paragraph.Style = "TextBox"
|
|
paragraph.AddText(m_TestMediumText)
|
|
End Sub
|
|
|
|
#End Region ' Paragraphs
|
|
|
|
#Region "Tables"
|
|
|
|
Public Sub DefineTables(ByVal document As MigraDoc.DocumentObjectModel.Document)
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph("Table Overview", "Heading1")
|
|
paragraph.AddBookmark("Tables")
|
|
DemonstrateSimpleTable(document)
|
|
DemonstrateTableAlignment(document)
|
|
DemonstrateCellMerge(document)
|
|
End Sub
|
|
|
|
Public Sub DemonstrateSimpleTable(ByVal document As Document)
|
|
document.LastSection.AddParagraph("Simple Tables", "Heading2")
|
|
Dim table As New Table()
|
|
table.Borders.Width = 0.75
|
|
Dim column As Column = table.AddColumn(Unit.FromCentimeter(2))
|
|
column.Format.Alignment = ParagraphAlignment.Center
|
|
table.AddColumn(Unit.FromCentimeter(5))
|
|
Dim row As Row = table.AddRow()
|
|
row.Shading.Color = Colors.PaleGoldenrod
|
|
Dim cell As Cell = row.Cells(0)
|
|
cell.AddParagraph("Itemus")
|
|
cell = row.Cells(1)
|
|
cell.AddParagraph("Descriptum")
|
|
row = table.AddRow()
|
|
cell = row.Cells(0)
|
|
cell.AddParagraph("1")
|
|
cell = row.Cells(1)
|
|
cell.AddParagraph(m_TestShortText)
|
|
row = table.AddRow()
|
|
cell = row.Cells(0)
|
|
cell.AddParagraph("2")
|
|
cell = row.Cells(1)
|
|
cell.AddParagraph(m_TestText)
|
|
table.SetEdge(0, 0, 2, 3, Edge.Box, BorderStyle.Single, 1.5, Colors.Black)
|
|
document.LastSection.Add(table)
|
|
End Sub
|
|
|
|
Public Sub DemonstrateTableAlignment(ByVal document As MigraDoc.DocumentObjectModel.Document)
|
|
document.LastSection.AddParagraph("Cell Alignment", "Heading2")
|
|
Dim table As Table = document.LastSection.AddTable()
|
|
table.Borders.Visible = True
|
|
table.Format.Shading.Color = Colors.LavenderBlush
|
|
table.Shading.Color = Colors.Salmon
|
|
table.TopPadding = 5
|
|
table.BottomPadding = 5
|
|
Dim column As Column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Left
|
|
column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Center
|
|
column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Right
|
|
table.Rows.Height = 35
|
|
Dim row As Row = table.AddRow()
|
|
row.VerticalAlignment = VerticalAlignment.Top
|
|
row.Cells(0).AddParagraph("Text")
|
|
row.Cells(1).AddParagraph("Text")
|
|
row.Cells(2).AddParagraph("Text")
|
|
row = table.AddRow()
|
|
row.VerticalAlignment = VerticalAlignment.Center
|
|
row.Cells(0).AddParagraph("Text")
|
|
row.Cells(1).AddParagraph("Text")
|
|
row.Cells(2).AddParagraph("Text")
|
|
row = table.AddRow()
|
|
row.VerticalAlignment = VerticalAlignment.Bottom
|
|
row.Cells(0).AddParagraph("Text")
|
|
row.Cells(1).AddParagraph("Text")
|
|
row.Cells(2).AddParagraph("Text")
|
|
End Sub
|
|
|
|
Public Sub DemonstrateCellMerge(ByVal document As Document)
|
|
document.LastSection.AddParagraph("Cell Merge", "Heading2")
|
|
Dim table As Table = document.LastSection.AddTable()
|
|
table.Borders.Visible = True
|
|
table.TopPadding = 5
|
|
table.BottomPadding = 5
|
|
Dim column As Column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Left
|
|
column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Center
|
|
column = table.AddColumn()
|
|
column.Format.Alignment = ParagraphAlignment.Right
|
|
table.Rows.Height = 35
|
|
Dim row As Row = table.AddRow()
|
|
row.Cells(0).AddParagraph("Merge Right")
|
|
row.Cells(0).MergeRight = 1
|
|
row = table.AddRow()
|
|
row.VerticalAlignment = VerticalAlignment.Bottom
|
|
row.Cells(0).MergeDown = 1
|
|
row.Cells(0).VerticalAlignment = VerticalAlignment.Bottom
|
|
row.Cells(0).AddParagraph("Merge Down")
|
|
table.AddRow()
|
|
End Sub
|
|
|
|
#End Region ' Tables
|
|
|
|
Public Sub DefineCharts(ByVal document As Document)
|
|
Dim paragraph As Paragraph = document.LastSection.AddParagraph("Chart Overview", "Heading1")
|
|
paragraph.AddBookmark("Charts")
|
|
document.LastSection.AddParagraph("Sample Chart", "Heading2")
|
|
Dim chart As New Chart With {
|
|
.Left = 0,
|
|
.Width = Unit.FromCentimeter(16),
|
|
.Height = Unit.FromCentimeter(12)
|
|
}
|
|
Dim series As Series = chart.SeriesCollection.AddSeries()
|
|
series.ChartType = ChartType.Column2D
|
|
series.Add(New Double() {1, 17, 45, 5, 3, 20, 11, 23, 8, 19})
|
|
series.HasDataLabel = True
|
|
series = chart.SeriesCollection.AddSeries()
|
|
series.ChartType = ChartType.Line
|
|
series.Add(New Double() {41, 7, 5, 45, 13, 10, 21, 13, 18, 9})
|
|
Dim xseries As XSeries = chart.XValues.AddXSeries()
|
|
xseries.Add("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N")
|
|
chart.XAxis.MajorTickMark = TickMarkType.Outside
|
|
chart.XAxis.Title.Caption = "X-Axis"
|
|
chart.YAxis.MajorTickMark = TickMarkType.Outside
|
|
chart.YAxis.HasMajorGridlines = True
|
|
chart.PlotArea.LineFormat.Color = Colors.DarkGray
|
|
chart.PlotArea.LineFormat.Width = 1
|
|
document.LastSection.Add(chart)
|
|
End Sub
|
|
|
|
End Module
|