Creazione preview PDF

This commit is contained in:
Demetrio Cassarino
2023-09-27 16:07:13 +02:00
parent b77a893f12
commit f7a7b80bd0
7 changed files with 653 additions and 407 deletions
@@ -1010,6 +1010,9 @@
<ItemGroup>
<Resource Include="Resources\PDFEditor\MoveDown.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\PDFEditor\PrintPDF.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PostBuildEvent>IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\EgtBEAMWALL.ViewerOptimizerR32.exe
Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

@@ -1,11 +1,8 @@
<ScrollViewer x:Class="PDFEditorV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
Margin="0,0,0,5">
<Grid x:Class="PDFEditorV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"
Margin="0,0,0,5">
<!--<ScrollViewer Grid.Row="2"
IsEnabled="True"
@@ -14,122 +11,166 @@
Margin="1,0,0,2.5"
Padding="0"
BorderThickness="0">-->
<ItemsControl ItemsSource="{Binding ExpanderList}"
BorderThickness="0"
Margin="0"
Padding="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"
Margin="0"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander IsExpanded="True"
VerticalContentAlignment="Top">
<Expander.Header>
<TextBlock Text="{Binding sNameCategory}"
Foreground="DarkBlue"
FontSize="16"
FontWeight="Bold"/>
</Expander.Header>
<ItemsControl ItemsSource="{Binding ExpanderElementList}"
BorderThickness="0"
Margin="0"
Padding="0"
FontSize="14">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"
Margin="0"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type EgtBEAMWALL:ExpanderElement}">
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bParameter_IsChecked, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="{Binding sNameParameter}"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type EgtBEAMWALL:ExpanderTable}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!--<ListBox ItemsSource="{Binding RawPartColumns}"
SelectedItem="{Binding SelRawPartColumns}"
DisplayMemberPath="Name"
SelectionMode="Multiple"/>-->
<ListBox ItemsSource="{Binding RawPartColumns}"
SelectedItem="{Binding SelColumns}"
BorderThickness="0"
Margin="0"
Padding="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bIsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="{Binding Name}"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<UniformGrid Grid.Row="1"
Rows="2"
Visibility="{Binding vRawPartVisibility}">
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bSection_IsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="SECTION"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bImage_IsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="IMAGE"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</UniformGrid>
<StackPanel Grid.Column="1"
Orientation="Vertical"
VerticalAlignment="Center"
Margin="2.5,0,0,0">
<Button Command="{Binding MoveUpOrder_Command}"
Margin="0,0,0,2.5"
Style="{StaticResource LeftPanel_Button}">
<Image Source="/Resources/PDFEditor/MoveUp.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding MoveDownOrder_Command}"
Margin="0,2.5,0,2.5"
Style="{StaticResource LeftPanel_Button}">
<Image Source="/Resources/PDFEditor/MoveDown.png" Stretch="Uniform"/>
</Button>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<GroupBox Header="PDF Preview"
Margin="0,0,0,5"
Width="Auto">
<StackPanel Orientation="Horizontal"
Margin="5,5,5,5">
<Button ToolTip="PDF Viewer - Preview"
Command="{Binding CreatePreviewVis_Command}"
Margin="0,2.5,2.5,2.5"
Style="{StaticResource PDFPanel_Button}">
<Image Source="/Resources/PDFEditor/PrintPDF.png" Stretch="Uniform"/>
</Button>
<Button ToolTip="PDF Viewer - Optimizer"
Command="{Binding CreatePreviewOtt_Command}"
Margin="2.5,2.5,0,2.5"
Style="{StaticResource PDFPanel_Button}">
<Image Source="/Resources/PDFEditor/PrintPDF.png" Stretch="Uniform"/>
</Button>
</StackPanel>
</GroupBox>
<ScrollViewer Grid.Row="1"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ItemsControl
ItemsSource="{Binding ExpanderList}"
BorderThickness="0"
Margin="0"
Padding="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"
Margin="0"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander IsExpanded="True"
VerticalContentAlignment="Top">
<Expander.Header>
<TextBlock Text="{Binding sNameCategory}"
Foreground="DarkBlue"
FontSize="16"
FontWeight="Bold"/>
</Expander.Header>
<ItemsControl ItemsSource="{Binding ExpanderElementList}"
BorderThickness="0"
Margin="0"
Padding="0"
FontSize="14">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"
Margin="0"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type EgtBEAMWALL:ExpanderElement}">
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bParameter_IsChecked, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="{Binding sNameParameter}"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
<DataTemplate DataType="{x:Type EgtBEAMWALL:ExpanderTable}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<!--<ListBox ItemsSource="{Binding RawPartColumns}"
SelectedItem="{Binding SelRawPartColumns}"
DisplayMemberPath="Name"
SelectionMode="Multiple"/>-->
<ListBox ItemsSource="{Binding RawPartColumns}"
SelectedItem="{Binding SelColumns}"
BorderThickness="0"
Margin="0"
Padding="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bIsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="{Binding Name}"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<UniformGrid Grid.Row="1"
Rows="2"
Visibility="{Binding vRawPartVisibility}">
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bSection_IsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="SECTION"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="5,5,5,0">
<CheckBox IsChecked="{Binding bImage_IsChecked}"
Style="{StaticResource OptionCheckBox}"/>
<TextBlock Text="IMAGE"
Margin="2.5,0,2.5,0"
Style="{StaticResource OptionTextBlock}"/>
</StackPanel>
</UniformGrid>
<StackPanel Grid.Column="1"
Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Right"
Margin="2.5,0,0,0">
<Button Command="{Binding MoveUpOrder_Command}"
Margin="0,0,0,2.5"
Style="{StaticResource LeftPanel_Button}">
<Image Source="/Resources/PDFEditor/MoveUp.png" Stretch="Uniform"/>
</Button>
<Button Command="{Binding MoveDownOrder_Command}"
Margin="0,2.5,0,2.5"
Style="{StaticResource LeftPanel_Button}">
<Image Source="/Resources/PDFEditor/MoveDown.png" Stretch="Uniform"/>
</Button>
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<GroupBox Header="PDF"
Margin="0,0,0,5"
Grid.Column="1"
Grid.RowSpan="2"
Width="Auto">
<WebBrowser x:Name="browser"
EgtBEAMWALL:WebBrowserUtility.BindableSource="{Binding WebAddress}"/>
</GroupBox>
</Grid>
<!--</ScrollViewer>-->
</ScrollViewer>
</Grid>
@@ -8,7 +8,12 @@ Public Class PDFEditorVM
#Region "FIELDS & PROPERTIES"
'Lista contenente le singole categorie
Private Enum PDFPage As Integer
VIEW = 0 ' PDF Visualizzatore
MACHING = 1 ' PDF Ottimizzatore
End Enum
' Lista contenente le singole categorie
Private m_ExpanderList As New ObservableCollection(Of ExpanderPDF)
Public ReadOnly Property ExpanderList As ObservableCollection(Of ExpanderPDF)
Get
@@ -16,18 +21,84 @@ Public Class PDFEditorVM
End Get
End Property
' PDF visualizzato come preview nella sezione PDF Editor
Private m_WebAddress As String
Public Property WebAddress As String
Get
Return m_WebAddress
End Get
Set(value As String)
m_WebAddress = value
NotifyPropertyChanged(NameOf(WebAddress))
End Set
End Property
' Definizione comandi
Private m_cmdCreatePDFPreviewVis As ICommand
Private m_cmdCreatePDFPreviewOtt As ICommand
#End Region
Sub New()
Map.SetRefPDFEditorVM(Me)
m_ExpanderList.Add(New ExpanderPDF(ListTypes.MACHGROUPTOT))
m_ExpanderList.Add(New ExpanderPDF(ListTypes.MACHGROUP))
m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART_LIST))
m_ExpanderList.Add(New ExpanderPDF(ListTypes.RAWPART))
m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART_TOT))
m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART))
m_WebAddress = "about:blank" ' Pagina vuota
Map.SetRefPDFEditorVM(Me)
End Sub
#Region "COMMANDS"
#Region "CreatePreviewVis"
Public ReadOnly Property CreatePreviewVis_Command As ICommand
Get
If m_cmdCreatePDFPreviewVis Is Nothing Then
m_cmdCreatePDFPreviewVis = New Command(AddressOf CreatePreviewVis)
End If
Return m_cmdCreatePDFPreviewVis
End Get
End Property
''' <summary>
''' Funzione per la visualizzazione della preview del PDF della sezione visualizzatore
''' </summary>
Public Sub CreatePreviewVis()
Map.refStatisticsVM.CreatePrintPDF(PDFPage.VIEW, True)
m_WebAddress = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics - Visualization.pdf"
NotifyPropertyChanged(NameOf(WebAddress))
End Sub
#End Region ' CreatePreviewVis
#Region "CreatePreviewOt"
Public ReadOnly Property CreatePreviewOtt_Command As ICommand
Get
If m_cmdCreatePDFPreviewOtt Is Nothing Then
m_cmdCreatePDFPreviewOtt = New Command(AddressOf CreatePreviewOtt)
End If
Return m_cmdCreatePDFPreviewOtt
End Get
End Property
''' <summary>
''' Funzione per la visualizzazione della preview del PDF della sezione ottimizzatore
''' </summary>
Public Sub CreatePreviewOtt()
Map.refStatisticsVM.CreatePrintPDF(PDFPage.MACHING, True)
m_WebAddress = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics - Optimizer.pdf"
NotifyPropertyChanged(NameOf(WebAddress))
End Sub
#End Region ' CreatePreviewVis
#End Region ' Commands
End Class
Public Class ExpanderPDF
@@ -61,34 +132,34 @@ Public Class ExpanderPDF
Sub New(nListType As Integer)
Select Case nListType
Case ListTypes.MACHGROUPTOT
m_sNameCategory = EgtMsg(61729)
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61721)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61717)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61719)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61718)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61720)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61722)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61723)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61724)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61725)))
m_sNameCategory = EgtMsg(61729) ' Titolo Categoria: MachGroup Totals
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61721))) ' Numero di grezzi
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61717))) ' Volume totale
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61719))) ' Tempo totole stimato
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61718))) ' Tempo totale
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61720))) ' Tempo rimanente
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61722))) ' Numero di pezzi da BTL
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61723))) ' Numero di pezzi aggiunti
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61724))) ' Numero di pezzi inseriti nei grezzi
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61725))) ' Numero di pezzi completati
Case ListTypes.MACHGROUP
m_sNameCategory = EgtMsg(61730)
m_ExpanderElementList.Add(New ExpanderTable(S_OPTIMIZERSTATISTICS))
m_sNameCategory = EgtMsg(61730) ' Titolo Categoria: MachGroup List
m_ExpanderElementList.Add(New ExpanderTable(S_OPTIMIZERSTATISTICS)) ' Tabella MachGroupList
Case ListTypes.PART_LIST
m_sNameCategory = EgtMsg(61731)
m_ExpanderElementList.Add(New ExpanderTable(S_STATISTICS_PART))
m_sNameCategory = EgtMsg(61731) ' Titolo Categoria: Raw Part
m_ExpanderElementList.Add(New ExpanderTable(S_STATISTICS_PART)) ' Tabella RawPart + Sezione e Immagine
Case ListTypes.RAWPART
m_sNameCategory = EgtMsg(61732)
m_ExpanderElementList.Add(New ExpanderTable(S_RAWPARTSTATISTICS))
m_sNameCategory = EgtMsg(61732) ' Titolo Categoria: RawPart List
m_ExpanderElementList.Add(New ExpanderTable(S_RAWPARTSTATISTICS)) ' Tabella RawPartList
Case ListTypes.PART_TOT
m_sNameCategory = EgtMsg(61734)
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61716)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61717)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61718)))
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61720)))
m_sNameCategory = EgtMsg(61734) ' Titolo Categoria: Part Totals
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61716))) ' Numero totale di pezzi
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61717))) ' Volume totale
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61718))) ' Tempo totale
m_ExpanderElementList.Add(New ExpanderElement(EgtMsg(61720))) ' Tempo rimanente
Case ListTypes.PART
m_sNameCategory = EgtMsg(61733)
m_ExpanderElementList.Add(New ExpanderTable(S_STATISTICS))
m_sNameCategory = EgtMsg(61733) ' Titolo Categoria: Part List
m_ExpanderElementList.Add(New ExpanderTable(S_STATISTICS)) ' Tabella PartList
End Select
End Sub
@@ -223,6 +294,9 @@ Public Class ExpanderTable
End Get
End Property
''' <summary>
''' Funzione per spostare in alto la colonna
''' </summary>
Public Sub MoveUpOrder()
If IsNothing(m_RawPartColumns) Then Return
Dim nIndex As Integer = m_RawPartColumns.IndexOf(m_SelColumns)
@@ -243,6 +317,9 @@ Public Class ExpanderTable
End Get
End Property
''' <summary>
''' Funzione per spostare in basso la colonna
''' </summary>
Public Sub MoveDownOrder()
If IsNothing(m_RawPartColumns) Then Return
Dim nIndex As Integer = m_RawPartColumns.IndexOf(m_SelColumns)
@@ -254,4 +331,30 @@ Public Class ExpanderTable
#End Region ' COMMANDS
End Class
' Classe gestione binding Web browser
Public Class WebBrowserUtility
Public Shared ReadOnly BindableSourceProperty As DependencyProperty = DependencyProperty.RegisterAttached("BindableSource",
GetType(String),
GetType(WebBrowserUtility),
New UIPropertyMetadata(Nothing, AddressOf BindableSourcePropertyChanged))
Public Shared Function GetBindableSource(obj As DependencyObject) As String
Return DirectCast(obj.GetValue(BindableSourceProperty), String)
End Function
Public Shared Sub SetBindableSource(obj As DependencyObject, value As String)
obj.SetValue(BindableSourceProperty, value)
End Sub
Public Shared Sub BindableSourcePropertyChanged(o As DependencyObject, e As DependencyPropertyChangedEventArgs)
Dim browser As WebBrowser = TryCast(o, WebBrowser)
If browser IsNot Nothing Then
Dim uri As String = TryCast(e.NewValue, String)
browser.Source = If(uri IsNot Nothing, New Uri(uri), Nothing)
End If
End Sub
End Class
@@ -39,119 +39,119 @@ Module PDFHelper
' Return document
'End Function
Public Function CreateStatReport(ActivePage As Pages) As Document
Public Function CreateStatReport(ActivePage As Pages, bPreview As Boolean) As Document
' creo nuovo documento MigraDoc
Dim document As Document = New Document()
Dim Project As ProjectFileVM = Map.refProdManagerVM.CurrProd
Select Case ActivePage
Case Pages.VIEW
Project = Map.refProjManagerVM.CurrProj
document.Info.Title = Project.sProjId & " - " & Project.BTLFileName_Msg & " - Statistics"
Case Pages.MACHINING
Project = Map.refProdManagerVM.CurrProd
document.Info.Title = Project.sProdId & " - " & Project.ListName_Msg & " - Statistics"
End Select
If bPreview Then
document.Info.Title = "135 - TestProject - Statistics"
Else
Select Case ActivePage
Case Pages.VIEW
Project = Map.refProjManagerVM.CurrProj
document.Info.Title = Project.sProjId & " - " & Project.BTLFileName_Msg & " - Statistics"
Case Pages.MACHINING
Project = Map.refProdManagerVM.CurrProd
document.Info.Title = Project.sProdId & " - " & Project.ListName_Msg & " - Statistics"
End Select
End If
document.Info.Subject = "Production statistics of the project"
document.Info.Author = "EgtBEAMWALL"
DefineStyles(document)
'Logo
Dim section As Section = document.AddSection()
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
Dim sImageLogo As String = Map.refMainWindowVM.MainWindowM.sTempDir & "/Image" & "Logo landscape" & ".png"
DefineLogo(section, sImageLogo)
Select Case ActivePage
Case Pages.VIEW
DefinePartTotals(document)
DefineItemList(document, ListTypes.PART)
DefinePartTotals(document, section, bPreview)
DefineItemList(document, ListTypes.PART, bPreview)
Case Pages.MACHINING
DefineMachGroupTotals(document)
DefineItemList(document, ListTypes.MACHGROUP)
DefineItemList(document, ListTypes.RAWPART)
DefineMachGroupTotals(document, section, bPreview)
DefineItemList(document, ListTypes.MACHGROUP, bPreview)
DefineItemList(document, ListTypes.RAWPART, bPreview)
If True Then
DefineRawPartPictures(document)
CreateRawPartPages(document, bPreview)
End If
End Select
Return document
End Function
Public Sub DefinePartTotals(ByVal document As Document)
Dim section As Section = document.AddSection()
'Logo
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
Dim sImageLogo As String = Map.refMainWindowVM.MainWindowM.sTempDir & "/Image" & "Logo landscape" & ".png"
DefineLogo(section, sImageLogo)
' cambio orientamento a orizzontale
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("Part Totals", "Heading2")
paragraph.Format.SpaceBefore = "3.0cm"
Dim sPartTot As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61734))
Dim sBTLTotParts As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61716))
Dim sBTLTotVolume As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61717))
Dim sBTLTotTime As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61718))
Dim sBTLRemainingTime As ExpanderElement = sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61720))
If sBTLTotParts.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotParts_Msg & Map.refProjectVM.BTLStructureVM.sBTLTotParts)
If sBTLTotVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotVolume_Msg & Map.refProjectVM.BTLStructureVM.sBTLTotVolume)
If sBTLTotTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotTime_Msg & Map.refProjectVM.BTLStructureVM.sBTLTotTime)
If sBTLRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLRemainingTime_Msg & Map.refProjectVM.BTLStructureVM.sBTLRemainingTime)
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(Map.refStatisticsVM.BTLTotParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotParts, ""))
If sBTLTotVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotVolume_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotVolume, ""))
If sBTLTotTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotTime_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotTime, ""))
If sBTLRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLRemainingTime_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLRemainingTime, ""))
End Sub
Public Sub DefineMachGroupTotals(ByVal document As Document)
Dim section As Section = document.AddSection()
'Logo
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
Dim sImageLogo As String = Map.refMainWindowVM.MainWindowM.sTempDir & "/Image" & "Logo landscape" & ".png"
DefineLogo(section, sImageLogo)
Public Sub DefineMachGroupTotals(ByVal document As Document, section As Section, bPreview As Boolean)
'Dim section As Section = document.AddSection()
' cambio orientamento a orizzontale
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
pgSetup.Orientation = Orientation.Landscape
section.PageSetup = pgSetup
Dim paragraph As Paragraph = section.AddParagraph("Machgroup Totals", "Heading2")
paragraph.Format.SpaceBefore = "3.0cm"
Dim sMachGroup As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61729))
Dim sNumberBlanks As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61721))
Dim sTotalVolume As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61717))
Dim sEstimatedTotalTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61719))
Dim sTotalTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61718))
Dim sRemainingTime As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61720))
Dim sNumberPiecesBLT As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61722))
Dim sNumberPiecesAdded As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61723))
Dim sNumberPiecesInsertedBlanks As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61724))
Dim sNumberPiecesCompleted As ExpanderElement = sMachGroup.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(61725))
If sNumberBlanks.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotMachGroups_Msg & Map.refProjectVM.MachGroupPanelVM.sTotMachGroups)
If sTotalVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotVolume_Msg & Map.refProjectVM.MachGroupPanelVM.sTotVolume)
If sEstimatedTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotEstimatedTime_Msg & Map.refProjectVM.MachGroupPanelVM.sTotEstimatedTime)
If sTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotTime_Msg & Map.refProjectVM.MachGroupPanelVM.sTotTime)
If sRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLRemainingTime_Msg & Map.refProjectVM.MachGroupPanelVM.sRemainingTime)
If sNumberPiecesBLT.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotCNTParts_Msg & Map.refProjectVM.BTLStructureVM.sTotCNTParts)
If sNumberPiecesAdded.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotADDEDParts_Msg & Map.refProjectVM.BTLStructureVM.sTotADDEDParts)
If sNumberPiecesInsertedBlanks.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotINPRODParts_Msg & Map.refProjectVM.BTLStructureVM.sTotINPRODParts)
If sNumberPiecesCompleted.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotDONEParts_Msg & Map.refProjectVM.BTLStructureVM.sTotDONEParts)
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(Map.refStatisticsVM.TotMachGroups_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotMachGroups, ""))
If sTotalVolume.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotVolume_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotVolume, ""))
If sEstimatedTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotEstimatedTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotEstimatedTime, ""))
If sTotalTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLTotTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotTime, ""))
If sRemainingTime.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.BTLRemainingTime_Msg & If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sRemainingTime, ""))
If sNumberPiecesBLT.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotCNTParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotCNTParts, ""))
If sNumberPiecesAdded.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotADDEDParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotADDEDParts, ""))
If sNumberPiecesInsertedBlanks.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotINPRODParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotINPRODParts, ""))
If sNumberPiecesCompleted.bParameter_IsChecked Then paragraph = section.AddParagraph(Map.refStatisticsVM.TotDONEParts_Msg & If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotDONEParts, ""))
End Sub
Public Sub DefineItemList(ByVal document As Document, nListType As ListTypes)
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()
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()
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()
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)
Dim sW As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_W)
Dim sH As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_H)
Dim sL As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_L)
Dim sMaterial As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_MATERIAL)
Dim sUsage As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_USAGE)
Dim sWaste As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_WASTE)
Dim sUTime As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_UNITTIME)
Dim sQty As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_QTY)
Dim sPDN As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_PDN)
Dim sDesc As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DESC)
Dim sCNT As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_CNT)
Dim sAdded As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_ADDED)
Dim sDone As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DONE)
Dim sUVolume As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_UNITVOLUME)
Dim sTVolume As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_TOTVOLUME)
Dim sTTime As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_TOTTIME)
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 section As Section = document.LastSection()
Select Case nListType
Case ListTypes.PART
@@ -168,14 +168,19 @@ Module PDFHelper
' -1 -> riempio colonne della riga degli header
' >=0 -> riempio le colonne con i valori dei pezzi
Dim Itemlist As IEnumerable(Of Object) = Nothing
Select Case nListType
Case ListTypes.PART
Itemlist = Map.refProjectVM.BTLStructureVM.BTLPartVMList
Case ListTypes.MACHGROUP
Itemlist = Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
Case ListTypes.RAWPART
Itemlist = Map.refStatisticsVM.RawPartList
End Select
' Controllo se bPreview è true mostra il PDF di preview se no il PDF completo
If bPreview Then
Itemlist = New List(Of Object)
Else
Select Case nListType
Case ListTypes.PART
Itemlist = Map.refProjectVM.BTLStructureVM.BTLPartVMList
Case ListTypes.MACHGROUP
Itemlist = Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
Case ListTypes.RAWPART
Itemlist = Map.refStatisticsVM.RawPartList
End Select
End If
'If m_ActivePage = Pages.VIEW Then
' Itemlist = Map.refProjectVM.BTLStructureVM.BTLPartVMList.ToList()
'ElseIf m_ActivePage = Pages.MACHINING Then
@@ -221,12 +226,16 @@ Module PDFHelper
For ColumnIndex = 0 To Columnlist.Count - 1
Select Case Columnlist(ColumnIndex).Name
Case "colPDN"
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(1.5))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.PDN_Msg)
ElseIf nListType = ListTypes.PART Then
row.Cells(ColumnIndex).AddParagraph(BTLPartVM.nPDN)
If sPDN.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(1.5))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.PDN_Msg)
ElseIf nListType = ListTypes.PART Then
row.Cells(ColumnIndex).AddParagraph(BTLPartVM.nPDN)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colID"
If PartIndex = -2 Then
@@ -627,154 +636,25 @@ Module PDFHelper
document.LastSection.Add(table)
End Sub
Public Sub DefineRawPartPictures(ByVal document As Document)
Public Sub CreateRawPartPages(ByVal document As Document, bPreview As Boolean)
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = False
Dim sMachGroupList As ExpanderTable = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61731)).ExpanderElementList.FirstOrDefault()
Dim sPDN As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_PDN)
Dim sW As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_W)
Dim sH As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_H)
Dim sL As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_L)
Dim sDesc As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DESC)
Dim sMaterial As EgtDataGridColumn = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Name = COL_MATERIAL)
'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()
For Each RawPart As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
Dim section As Section = document.AddSection()
' cambio orientamento a verticale
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
pgSetup.Orientation = Orientation.Landscape
section.PageSetup = pgSetup
' creo immagine
EgtSetCurrMachGroup(RawPart.Id)
'If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then
' EgtSetView(VT.FRONT, False)
'Else
' EgtSetView(VT.TOP, False)
'End If
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.FRONT, VT.TOP), False)
EgtZoom(ZM.ALL, False)
Dim sImagePath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "/Image" & RawPart.Id & ".png"
EgtGetImage(SM.HIDDENLINE, New Color3d(255, 255, 255), New Color3d(255, 255, 255), 3000, 1000, sImagePath)
' aggiungo immagine
If sMachGroupList.bSection_IsChecked Then section.AddParagraph(RawPart.Name)
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
' aggiungo tabella dei pezzi
Dim table As Table = New Table()
table.Borders.Width = 0.75
For PartIndex = -2 To RawPart.PartVMList.Count - 1
Dim PartVM As PartVM = Nothing
Dim row As Row = Nothing
If PartIndex <> -2 Then
' aggiungo riga
row = table.AddRow()
End If
If PartIndex = -1 Then
' imposto la riga come header che si ripetera' all'inizio di ogni pagina
row.HeadingFormat = True
' coloro sfondo riga degli header
row.Shading.Color = Colors.Aqua
ElseIf PartIndex >= 0 Then
' recupero elemento della riga
PartVM = RawPart.PartVMList(PartIndex)
End If
Dim Columnlist As ObservableCollection(Of EgtDataGridColumn) = Nothing
'Columnlist = Map.refStatisticsVM.StatisticsColumns
Columnlist = sMachGroupList.RawPartColumns
For ColumnIndex = 0 To Columnlist.Count - 1
Select Case Columnlist(ColumnIndex).Name
Case "colPDN"
If sPDN.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(1.5))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.PDN_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.nPDN)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colW"
If sW.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.W_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sW)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colH"
If sH.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.H_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sH)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colL"
If sL.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.L_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sL)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colDESC"
If sDesc.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(4))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.NAM_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sNAM)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colNAME"
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(4))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.NAM_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sNAM)
End If
Case "colMATERIAL"
If sMaterial.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.MAT_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sMATERIAL)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
End Select
Next
' 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)
Else
For Each RawPart As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
CreateRawPartPage(document, sMachGroupList, sPDN, sW, sH, sL, sDesc, sMaterial, RawPart)
Next
' aggiungo tabella all'ultima sezione
section.Add(table)
Next
End If
'Dim paragraph As Paragraph = section.AddParagraph("Machgroup Totals", "Heading2")
'paragraph = section.AddParagraph(Map.refStatisticsVM.TotMachGroups_Msg & Map.refProjectVM.MachGroupPanelVM.sTotMachGroups)
@@ -788,9 +668,159 @@ Module PDFHelper
'paragraph = section.AddParagraph(Map.refStatisticsVM.TotDONEParts_Msg & Map.refProjectVM.BTLStructureVM.sTotDONEParts)
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)
Dim section As Section = document.AddSection()
' cambio orientamento a verticale
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
pgSetup.Orientation = Orientation.Landscape
section.PageSetup = pgSetup
Dim PartVMList As IEnumerable(Of Object)
If IsNothing(RawPart) Then
PartVMList = New List(Of Object)
CreateRawPartImage(section, sMachGroupList, 1, 1)
Else
PartVMList = RawPart.PartVMList
CreateRawPartImage(section, sMachGroupList, RawPart.Id, RawPart.Name)
End If
' aggiungo tabella dei pezzi
Dim table As Table = New Table()
table.Borders.Width = 0.75
For PartIndex = -2 To PartVMList.Count - 1
Dim PartVM As PartVM = Nothing
Dim row As Row = Nothing
If PartIndex <> -2 Then
' aggiungo riga
row = table.AddRow()
End If
If PartIndex = -1 Then
' imposto la riga come header che si ripetera' all'inizio di ogni pagina
row.HeadingFormat = True
' coloro sfondo riga degli header
row.Shading.Color = Colors.Aqua
ElseIf PartIndex >= 0 Then
' recupero elemento della riga
PartVM = PartVMList(PartIndex)
End If
Dim Columnlist As ObservableCollection(Of EgtDataGridColumn) = Nothing
'Columnlist = Map.refStatisticsVM.StatisticsColumns
Columnlist = sMachGroupList.RawPartColumns
For ColumnIndex = 0 To Columnlist.Count - 1
Select Case Columnlist(ColumnIndex).Name
Case "colPDN"
If sPDN.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(1.5))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.PDN_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.nPDN)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colW"
If sW.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.W_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sW)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colH"
If sH.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.H_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sH)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colL"
If sL.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.L_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sL)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colDESC"
If sDesc.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(4))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.NAM_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sNAM)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
Case "colNAME"
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(4))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.NAM_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sNAM)
End If
Case "colMATERIAL"
If sMaterial.bIsChecked Then
If PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(2))
ElseIf PartIndex = -1 Then
row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.MAT_Msg)
Else
row.Cells(ColumnIndex).AddParagraph(PartVM.sMATERIAL)
End If
ElseIf PartIndex = -2 Then
table.AddColumn(Unit.FromCentimeter(0))
End If
End Select
Next
Next
' aggiungo tabella all'ultima sezione
section.Add(table)
End Sub
Private Sub CreateRawPartImage(section As Section, sMachGroupList As ExpanderTable, RawPartId As Integer, RawPartName As String)
' creo immagine
EgtSetCurrMachGroup(RawPartId)
'If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then
' EgtSetView(VT.FRONT, False)
'Else
' EgtSetView(VT.TOP, False)
'End If
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.FRONT, VT.TOP), False)
EgtZoom(ZM.ALL, False)
Dim sImagePath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "/Image" & RawPartId & ".png"
EgtGetImage(SM.HIDDENLINE, New Color3d(255, 255, 255), New Color3d(255, 255, 255), 3000, 1000, sImagePath)
' aggiungo immagine
If sMachGroupList.bSection_IsChecked Then section.AddParagraph(RawPartName)
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(250)
Image.Width = Unit.FromMillimeter(245)
Image.Height = Unit.FromMillimeter(40)
Image.LockAspectRatio = True
Image.RelativeVertical = RelativeVertical.Line
@@ -317,33 +317,26 @@ Public Class StatisticsVM
End Select
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "PrintPDF"
Public ReadOnly Property PrintPDF_Command As ICommand
Get
If m_cmdPrintPDF Is Nothing Then
m_cmdPrintPDF = New Command(AddressOf PrintPDF)
End If
Return m_cmdPrintPDF
End Get
End Property
Public Sub PrintPDF()
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(Map.refMainMenuVM.SelPage)
Dim document As Document = PDFHelper.CreateStatReport(ActivePage, bPreview)
Dim documentPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\MigraDoc.mdddl"
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, documentPath)
Dim renderer As PdfDocumentRenderer = New PdfDocumentRenderer(True)
renderer.Document = document
renderer.RenderDocument()
' salvo il documento
Dim sFileName As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf"
Dim sFileName As String = ""
' Controllo la pagina e se bPreview e' True
If ActivePage = 0 AndAlso bPreview Then
sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics - Visualization.pdf" ' Se la pagina e' 0 e' bPreview e' True creo PDF Visualization
ElseIf ActivePage = 1 AndAlso bPreview Then
sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics - Optimizer.pdf" ' Se la pagina e' 1 e' bPreview e' True creo PDF Optimizer
Else
sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf" ' Altrimenti se bPreview e' Falso creo PDF Statistics
End If
Select Case Map.refMainMenuVM.SelPage
Case Pages.VIEW
sFileName = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & "Statistics.pdf"
@@ -363,11 +356,15 @@ Public Class StatisticsVM
EgtZoom(ZM.ALL, True)
End Select
' avvio il visualizzatore
renderer.PdfDocument.Save(sFileName)
' cancello file MigraDoc
File.Delete(documentPath)
' avvio il visualizzatore
Process.Start(sFileName)
If bPreview Then
Else
Process.Start(sFileName)
End If
Catch ex As Exception
EgtOutLog("Error genereting pdf: " & ex.ToString())
End Try
@@ -375,6 +372,65 @@ Public Class StatisticsVM
End Sub
#End Region ' METHODS
#Region "COMMANDS"
#Region "PrintPDF"
Public ReadOnly Property PrintPDF_Command As ICommand
Get
If m_cmdPrintPDF Is Nothing Then
m_cmdPrintPDF = New Command(AddressOf PrintPDF)
End If
Return m_cmdPrintPDF
End Get
End Property
Public Sub PrintPDF()
CreatePrintPDF(Map.refMainMenuVM.SelPage, False)
'LoadingWndHelper.OpenLoadingWnd(ActiveIds.CREATINGPDF, 1, "Creating PDF", "", 100)
'Try
' ' creo documento MigraDoc
' Dim document As Document = PDFHelper.CreateStatReport(Map.refMainMenuVM.SelPage, False)
' Dim documentPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\MigraDoc.mdddl"
' MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, documentPath)
' Dim renderer As PdfDocumentRenderer = New PdfDocumentRenderer(True)
' renderer.Document = document
' renderer.RenderDocument()
' ' salvo il documento
' Dim sFileName As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf"
' Select Case Map.refMainMenuVM.SelPage
' Case Pages.VIEW
' sFileName = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & "Statistics.pdf"
' Case Pages.MACHINING
' sFileName = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & Map.refProdManagerVM.CurrProd.sProdId & " - " & "Statistics.pdf"
' ' 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
' 'If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then
' ' EgtSetView(VT.ISO_SW, False)
' 'Else
' ' EgtSetView(VT.TOP, False)
' 'End If
' Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False)
' EgtZoom(ZM.ALL, True)
' End Select
' renderer.PdfDocument.Save(sFileName)
' ' cancello file MigraDoc
' File.Delete(documentPath)
' ' avvio il visualizzatore
' Process.Start(sFileName)
'Catch ex As Exception
' EgtOutLog("Error genereting pdf: " & ex.ToString())
'End Try
'LoadingWndHelper.CloseLoadingWnd(ActiveIds.CREATINGPDF)
End Sub
#End Region ' PrintPDF
#End Region ' COMMANDS
@@ -189,6 +189,19 @@
<Setter Property="Width" Value="30"/>
</Style>
<Style x:Key="PDFPanel_Button" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="200"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
</Style>
<!-- ______________________________________________________________________________________________________________________________________________ -->
<!-- ToggleButton Style -->