diff --git a/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb b/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb index 4abb54c4..5a2f6f5a 100644 --- a/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb +++ b/EgtBEAMWALL.Core/BTLModel/BTLPartM.vb @@ -18,6 +18,17 @@ Public Class BTLPartM End Property ' Info del pezzo + + Public m_nPROJ As Integer + Public Property nPROJ As Integer + Get + Return m_nPROJ + End Get + Set(value As Integer) + m_nPROJ = value + End Set + End Property + Public m_nPDN As Integer Public Property nPDN As Integer Get @@ -752,6 +763,7 @@ Public Class BTLPartM Dim sValArray() As String Dim sValue As String = String.Empty Dim nValue As Integer = 0 + EgtGetInfo(nPartId, BTL_PRT_PROJ, NewBTLPart.m_nPROJ) EgtGetInfo(nPartId, BTL_PRT_PDN, NewBTLPart.m_nPDN) Dim nDO As Integer = 1 If EgtGetInfo(nPartId, BTL_PRT_DO, nDO) Then diff --git a/EgtBEAMWALL.Optimizer/AboutBoxWindow/AboutBoxV.xaml b/EgtBEAMWALL.Optimizer/AboutBoxWindow/AboutBoxV.xaml new file mode 100644 index 00000000..54742670 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/AboutBoxWindow/AboutBoxV.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerV.xaml.vb new file mode 100644 index 00000000..5ff604d0 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class BTLPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerVM.vb b/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerVM.vb new file mode 100644 index 00000000..df73aa0e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLPartManager/BTLPartManagerVM.vb @@ -0,0 +1,1185 @@ +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.IO +Imports EgtBEAMWALL.Core + +Public Class BTLPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property MachiningPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_BTLPartManager_IsEnabled As Boolean = True + Public ReadOnly Property BTLPartManager_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled + End Get + End Property + + Public ReadOnly Property CopyPart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled AndAlso Not IsNothing(Map.refShowBeamPanelVM) AndAlso Not Map.refShowBeamPanelVM.bShowAll AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 + End Get + End Property + + Public ReadOnly Property RotatePart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled AndAlso Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 1 + End Get + End Property + + Public ReadOnly Property RemovePart_IsEnabled As Boolean + Get + Return m_BTLPartManager_IsEnabled + End Get + End Property + + ' Definizione comandi + Private m_cmdNewRawPart As ICommand + Private m_cmdNewRawPartLast As ICommand + Private m_cmdAddToRawPart As ICommand + Private m_cmdCopyPart As ICommand + Private m_cmdAddPart As ICommand + Private m_cmdRemovePart As ICommand + Private m_cmdInvert As ICommand + Private m_cmdBackRotation As ICommand + Private m_cmdForwardRotation As ICommand + +#Region "Messages" + + Public ReadOnly Property NewRawPart_ToolTip As String + Get + Return EgtMsg(61903) + End Get + End Property + + Public ReadOnly Property NewRawPartLast_ToolTip As String + Get + Return EgtMsg(61977) + End Get + End Property + + Public ReadOnly Property AddToRawPart_ToolTip As String + Get + Return EgtMsg(61904) + End Get + End Property + + Public ReadOnly Property CopyPart_ToolTip As String + Get + Return EgtMsg(61905) + End Get + End Property + + Public ReadOnly Property AddPart_ToolTip As String + Get + Return EgtMsg(61906) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61907) + End Get + End Property + + Public ReadOnly Property AddFeature_ToolTip As String + Get + Return EgtMsg(61910) + End Get + End Property + + Public ReadOnly Property RemoveFeature_ToolTip As String + Get + Return EgtMsg(61911) + End Get + End Property + + Public ReadOnly Property BackRotation_ToolTip As String + Get + Return EgtMsg(61996) + End Get + End Property + + Public ReadOnly Property ForwardRotation_ToolTip As String + Get + Return EgtMsg(61997) + End Get + End Property + + Public ReadOnly Property InvertSx_ToolTip As String + Get + Return EgtMsg(61998) + End Get + End Property + + Public ReadOnly Property InvertDx_ToolTip As String + Get + Return EgtMsg(61999) + End Get + End Property + +#End Region ' Messages + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefBTLPartManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub UpdateView() + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + NotifyPropertyChanged(NameOf(MachiningPage_Visibility)) + End Sub + + Friend Sub SetBTLPartManagerIsEnabled(bIsEnabled As Boolean) + m_BTLPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(BTLPartManager_IsEnabled)) + NotifyPropertyChanged(NameOf(CopyPart_IsEnabled)) + NotifyPropertyChanged(NameOf(RemovePart_IsEnabled)) + End Sub + + Friend Sub PartShowAllChanged() + NotifyPropertyChanged(NameOf(CopyPart_IsEnabled)) + NotifyPropertyChanged(NameOf(RotatePart_IsEnabled)) + NotifyPropertyChanged(NameOf(RemovePart_IsEnabled)) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "NewRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property NewRawPart_Command As ICommand + Get + If m_cmdNewRawPart Is Nothing Then + m_cmdNewRawPart = New Command(AddressOf NewRawPartCmd) + End If + Return m_cmdNewRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub NewRawPartCmd() + NewRawPart(False) + End Sub + + Public Sub NewRawPart(bLast As Boolean) + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + If IsNothing(SelParts) OrElse SelParts.Count <= 0 Then Return + ' verifico che abbiano tutti la stessa sezione + Dim dHSection As Double = SelParts(0).dH + Dim dWSection As Double = SelParts(0).dW + For PartIndex = 0 To SelParts.Count - 1 + Dim Part As BTLPartVM = SelParts(PartIndex) + If Not IsNothing(Part) Then + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + If Part.dH <> dHSection OrElse Part.dW <> dWSection Then + MessageBox.Show(EgtMsg(61970), EgtMsg(30007)) + Return + End If + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + If Part.dH <> dHSection Then + MessageBox.Show(EgtMsg(61970), EgtMsg(30007)) + Return + End If + End If + Else + SelParts.Remove(Part) + End If + Next + ' se pareti e piu' di uno selezionato, esco + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL And SelParts.Count > 1 Then + MessageBox.Show(EgtMsg(61971), EgtMsg(30007)) + Return + End If + ' se nessun grezzo, rendo tutti i pezzi visibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.ShowAll(False) + End If + ' verifico se sono gia' stati messi tutti i pezzi richiesti + If Not VerifyPartCount(SelParts) Then Return + Dim dRawL As Double = SelParts(0).dL + Dim dRawW As Double = SelParts(0).dW + Dim dStartOffset As Double = 0 + Dim dKerf As Double = 0 + Dim dOffset As Double = WarehouseHelper.GetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' se tipo di definizione grezzo esplicito + If WarehouseHelper.GetRawPartDef = 1 OrElse ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift AndAlso WarehouseHelper.GetWarehouseType = WarehouseType.BASIC) Then + ' chiedo lunghezza grezzo + Dim sWarehouseIniPath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + dStartOffset = WarehouseHelper.GetStartOffset() + dRawL += dStartOffset + Else + dKerf = WarehouseHelper.GetKerf() + dRawL += 2 * dKerf + dRawW += 2 * dKerf + End If + Dim AddRawPartWndVM As New AddRawPartWndVM(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawL, dRawW, dStartOffset) + Dim AddRawPartWnd As Object = Nothing + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + AddRawPartWnd = New OnlyProdAddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + Else + AddRawPartWnd = New AddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + End If + If Not AddRawPartWnd.ShowDialog() Then Return + dRawL = AddRawPartWndVM.VariableList(0).dValue + dRawW = AddRawPartWndVM.VariableList(1).dValue + dStartOffset = AddRawPartWndVM.VariableList(1).dValue + ' se altrimenti definizione grezzo da warehouse + Else + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + dStartOffset = WarehouseHelper.GetStartOffset() + Else + dKerf = WarehouseHelper.GetKerf() + End If + ' se warehouse basic + Select Case WarehouseHelper.GetWarehouseType() + Case WarehouseType.BASIC + WarehouseHelper.GetCurrentDimensions(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dRawW, dRawL) + Case WarehouseType.MEDIUM + Dim SectionList As List(Of SParam) = WarehouseHelper.GetSectionList() + Dim SParamlist As List(Of SParam) = SectionList.FindAll(Function(x) x.SectXMat = SelParts(0).Section) + If bLast Then + Dim LastMaterial As SParam = WarehouseHelper.GetLastMaterial(SelParts(0).Section) + If Not IsNothing(LastMaterial) Then + dRawL = LastMaterial.dL + dRawW = LastMaterial.dW + ElseIf SParamlist.Count > 0 Then + dRawL = SParamlist(0).dL + dRawW = SParamlist(0).dW + Else + MessageBox.Show(EgtMsg(61975), EgtMsg(30007)) + Return + End If + Else + If SParamlist.Count = 0 Then + ' se pareti aumento dimensioni del kerf + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + dRawW += (2 * dKerf) + dRawL += (2 * dKerf) + End If + ' apro finestra con solo edit + If AddRawPartWnd(AddRawPartWndVM.EditTypes.ONLY_TEXT, SParamlist, dRawW, dRawL, dStartOffset, dOffset, dKerf) Then + WarehouseHelper.SetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dOffset) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + WarehouseHelper.SetStartOffset(dStartOffset) + Else + WarehouseHelper.SetKerf(dKerf) + End If + Else + Return + End If + ElseIf SParamlist.Count > 0 Then + ' imposto finestra con anche edit + If AddRawPartWnd(AddRawPartWndVM.EditTypes.TEXT_AND_COMBO, SParamlist, dRawW, dRawL, dStartOffset, dOffset, dKerf) Then + WarehouseHelper.SetOffset(Map.refProjectVM.BTLStructureVM.nPROJTYPE, dOffset) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + WarehouseHelper.SetStartOffset(dStartOffset) + Else + WarehouseHelper.SetKerf(dKerf) + End If + Else + Return + End If + End If + End If + End Select + End If + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' verifico se lunghezza barra e' maggiore della lunghezza dei pezzi + Dim dTotLen As Double = WarehouseHelper.GetStartOffset() + For PartIndex = 0 To SelParts.Count - 1 + If PartIndex <> 0 Then + dTotLen += WarehouseHelper.GetOffset(BWType.BEAM) + End If + dTotLen += SelParts(PartIndex).dL + Next + If dTotLen > dRawL Then + MessageBox.Show(EgtMsg(61972), EgtMsg(30007)) + Return + End If + End If + ' creo nuovo gruppo di lavorazione + Map.refMachGroupPanelVM.AddMachGroup() + Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup() + Dim sCurrMachGroupName As String = "" + EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, ProjectManagerVM.CurrProd.nProdId) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' ordino i pezzi per lunghezza + SelParts = SelParts.OrderBy(Function(x) x.dL).ToList + ' creo copie dei pezzi + Dim nPartDuploIdList As New List(Of Integer) + For Each Part In SelParts + Dim nDuploId As Integer = EgtDuploNew(Part.nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nDuploId) + ' lo rendo std + EgtSetMode(nDuploId, GDB_MD.STD) + nPartDuploIdList.Add(nDuploId) + Next + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dRawL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, SelParts(0).sMATERIAL) + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = WarehouseHelper.GetStartOffset() + ' ciclo sui pezzi + For nIndex = 0 To nPartDuploIdList.Count - 1 + ' se non è primo, aggiungo offset tra barre standard + If nIndex <> 0 Then + dPosX += WarehouseHelper.GetOffset(BWType.BEAM) + End If + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & nIndex + 1, nPartDuploIdList(nIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += SelParts(nIndex).dL + Next + Dim BeamMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.GetLastMachGroup() + ' eseguo script creazione grezzo + Dim nERR As Integer = 0 + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + ' elimino duplo e gruppo di lavorazione + For Each nDuploId In nPartDuploIdList + EgtErase(nDuploId) + Next + BeamMachGroup.DeleteMachGroup() + If File.Exists(sLogPath) Then + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Else + MessageBox.Show(EgtMsg(61973), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll() + End If + Return + End If + For nDuploIndex = 0 To SelParts.Count - 1 + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_ROT, SelParts(nDuploIndex).nROTATED) + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_FLIP, SelParts(nDuploIndex).nINVERTED) + Next + ' aggiorno contatore pezzi usati in Prod + For Each SelPart In SelParts + SelPart.RefreshPartInProd() + Next + 'aggiorno lista pezzi + BeamMachGroup.MyMachGroupM.RefreshPartList() + BeamMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati utilizzo barra + BeamMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Dim nPartDuploId As Integer = EgtDuploNew(SelParts(0).nPartId) + ' scrivo dati in gruppo di lavorazione + Dim dPosX As Double = dKerf + Dim dPosY As Double = dKerf + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, dRawL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, dRawW) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, SelParts(0).sMATERIAL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & 1, + nPartDuploId & "," & DoubleToString(dPosX, 3) & "," & DoubleToString(dPosY, 3) & ",0,0") + Dim WallMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 1) + ' eseguo script creazione grezzo + If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False, False) Then + ' elimino duplo e gruppo di lavorazione + EgtErase(nPartDuploId) + WallMachGroup.DeleteMachGroup() + If File.Exists(sLogPath) Then + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Else + MessageBox.Show(EgtMsg(61973), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + Return + End If + ' scrivo dati pezzo + EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX) + EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY) + EgtSetInfo(nPartDuploId, MGR_PRT_ROT, SelParts(0).nROTATED) + EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, SelParts(0).nINVERTED) + ' aggiorno contatore pezzi usati in Prod + SelParts(0).RefreshPartInProd() + ' aggiorno lista pezzi + WallMachGroup.MyMachGroupM.RefreshPartList() + WallMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati ultilizzo barra + WallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.TOP, False) + End If + EgtZoom(ZM.ALL) + End Sub + + ' funzione che apre finestra di scelta dimensioni grezzo + Private Function AddRawPartWnd(EditType As AddRawPartWndVM.EditTypes, SParamlist As List(Of SParam), ByRef dRawW As Double, ByRef dRawL As Double, + ByRef dStartOffset As Double, ByRef dOffset As Double, ByRef dKerf As Double) As Boolean + ' apro finestra con solo edit + Dim AddRawPartWndVM As New AddRawPartWndVM(EditType, Map.refProjectVM.BTLStructureVM.nPROJTYPE, SParamlist, dRawL, dRawW, dStartOffset, dOffset, dKerf) + Dim AddRawPartWndV As Object = Nothing + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + AddRawPartWndV = New OnlyProdAddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + Else + AddRawPartWndV = New AddRawPartWndV(Application.Current.MainWindow, AddRawPartWndVM) + End If + If Not AddRawPartWndV.ShowDialog() Then Return False + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.BEAM + dRawL = AddRawPartWndVM.VariableList(0).dValue + dStartOffset = AddRawPartWndVM.VariableList(1).dValue + dOffset = AddRawPartWndVM.VariableList(2).dValue + Case BWType.WALL + dRawW = AddRawPartWndVM.VariableList(0).dValue + dRawL = AddRawPartWndVM.VariableList(1).dValue + dKerf = AddRawPartWndVM.VariableList(2).dValue + dOffset = AddRawPartWndVM.VariableList(3).dValue + End Select + ' verifico se il materiale esiste in magazzino o devo aggiungerlo + Dim CurrSParam As SParam = Nothing + Select Case EditType + Case AddRawPartWndVM.EditTypes.ONLY_TEXT + ' lo aggiungo a lista materiali in magazzino + CurrSParam = AddRawMaterial(dRawW, dRawL) + Case AddRawPartWndVM.EditTypes.ONLY_COMBO + ' non faccio nulla + Case AddRawPartWndVM.EditTypes.TEXT_AND_COMBO + ' verifico se lunghezza testo corrisponde a materiale + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + CurrSParam = SParamlist.FirstOrDefault(Function(x) x.dL = AddRawPartWndVM.VariableList(0).dValue) + Else + CurrSParam = SParamlist.FirstOrDefault(Function(x) x.dL = AddRawPartWndVM.VariableList(1).dValue AndAlso x.dW = AddRawPartWndVM.VariableList(0).dValue) + End If + If IsNothing(CurrSParam) Then + ' lo aggiungo a lista materiali in magazzino + CurrSParam = AddRawMaterial(dRawW, dRawL) + End If + End Select + ' imposto il materiale selezionato come ultimo utilizzato + SetLastMaterial(CurrSParam.SectXMat, CurrSParam) + Return True + End Function + + Private Function AddRawMaterial(dRawW As Double, ByRef dRawL As Double) As SParam + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + Dim nQuantity As Integer = GetMainPrivateProfileInt(S_WAREHOUSE, K_DEFAULTQUANTITY, 1) + Dim CurrSParam = Nothing + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' creo sParam + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLParts(0)) Then CurrSParam = New SParam(Map.refProjectVM.BTLStructureVM.SelBTLParts(0).Section, dRawL, nQuantity, False) + Dim sL As String = String.Empty + sL = LenToString(CurrSParam.dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Beam_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.BEAM, CurrSParam.SectXMat) + ' ricavo nuovo indice materiale + Dim ParamIndex As Integer = 1 + Dim sParam As String = "" + While GetPrivateProfileString(S_BEAM, K_L & ParamIndex, "", sParam, sWarehousePath) > 0 + ParamIndex += 1 + End While + If SectXMatIndex > 0 Then + ' lo aggiungo in warehouse + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, + SectXMatIndex & "," & sL & "," & CurrSParam.nQuantity & "," & If(CurrSParam.bActive, 1, 0), + sWarehousePath) + Else + EgtOutLog("Error in material creation, section not found!") + End If + Return CurrSParam + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' creo sParam + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLParts(0)) Then CurrSParam = New SParam(Map.refProjectVM.BTLStructureVM.SelBTLParts(0).Section, dRawW, dRawL, nQuantity, False) + Dim sW As String = String.Empty + Dim sL As String = String.Empty + sW = LenToString(CurrSParam.dW, 3) + sL = LenToString(CurrSParam.dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Wall_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.WALL, CurrSParam.SectXMat) + ' ricavo nuovo indice materiale + Dim ParamIndex As Integer = 1 + Dim sParam As String = "" + While GetPrivateProfileString(S_WALL, K_S & ParamIndex, "", sParam, sWarehousePath) > 0 + ParamIndex += 1 + End While + ' lo aggiungo in warehouse + WritePrivateProfileString(S_WALL, K_S & ParamIndex, + SectXMatIndex & "," & sW & "," & sL & "," & CurrSParam.nQuantity & "," & If(CurrSParam.bActive, 1, 0), + sWarehousePath) + Return CurrSParam + End If + + Return Nothing + End Function + + Private Function VerifyPartCount(SelParts As List(Of BTLPartVM)) As Boolean + ' verifico se ci sono pezzi da aggiungere + Dim ToAddList As New List(Of String) + Dim ToAddVM As New List(Of BTLPartVM) + For Each SelPart In SelParts + If Not SelPart.CanAddPartToCount Then + ToAddList.Add(SelPart.nCNT & EgtMsg(61864) & SelPart.nADDED & EgtMsg(61865)) + ToAddVM.Add(SelPart) + End If + Next + ' se non ci sono, chiedo se aggiungerne uno nuovo + If ToAddList.Count > 0 Then + Dim sMessage As String = EgtMsg(61863) & Environment.NewLine + For Each sPart In ToAddList + sMessage &= " - " & sPart & Environment.NewLine + Next + If MessageBox.Show(sMessage & EgtMsg(61893), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + For Each PartVM In ToAddVM + PartVM.AddNewPartToAdded() + Next + Else + Return False + End If + End If + Return True + End Function + +#End Region ' NewRawPart + +#Region "NewRawPartLast" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property NewRawPartLast_Command As ICommand + Get + If m_cmdNewRawPartLast Is Nothing Then + m_cmdNewRawPartLast = New Command(AddressOf NewRawPartLast) + End If + Return m_cmdNewRawPartLast + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub NewRawPartLast() + NewRawPart(True) + End Sub + +#End Region ' NewRawPartLast + +#Region "AddToRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddToRawPart_Command As ICommand + Get + If m_cmdAddToRawPart Is Nothing Then + m_cmdAddToRawPart = New Command(AddressOf AddToRawPart) + End If + Return m_cmdAddToRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddToRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelPart As BTLPartVM + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count <= 0 Then + Return + Else + SelPart = Map.refProjectVM.BTLStructureVM.SelBTLParts(0) + End If + Dim SelParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + For Index = 0 To SelParts.Count() - 1 + If IsNothing(SelParts(Index)) Then + SelParts.RemoveAt(Index) + End If + Next + If IsNothing(SelPart) Then Return + If IsNothing(SelParts) OrElse SelParts.Count <= 0 Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se pareti e piu' di uno selezionato, esco + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL And SelParts.Count > 1 Then + MessageBox.Show(EgtMsg(61971), EgtMsg(30007)) + Return + End If + ' se MachGroup gia' mandato in produzione, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + ' verifico se sono gia' stati messi tutti i pezzi richiesti + If Not VerifyPartCount(SelParts) Then Return + ' verifico se impostato gruppo di lavorazione + Dim nCurrMachgroupId As Integer = EgtGetCurrMachGroup() + ' se nullo o diverso da quello selezionato in lista + If nCurrMachgroupId = GDB_ID.NULL OrElse nCurrMachgroupId <> SelMachGroup.Id Then + ' lo imposto + EgtSetCurrMachGroup(SelMachGroup.Id) + End If + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + Dim BeamMachGroup As MyMachGroupVM = SelMachGroup + ' verifico sezione e materiale + For Each Part In SelParts + If Part.Section <> BeamMachGroup.Section Then + MessageBox.Show(EgtMsg(61866), EgtMsg(30007)) + Return + End If + Next + ' verifico lunghezza totale + If Not VerifyTotLength(BeamMachGroup, SelParts) Then + MessageBox.Show(EgtMsg(61867), EgtMsg(30007)) + Return + End If + If AddPartToBeam(BeamMachGroup, SelParts) Then + ' aggiorno contatore pezzi usati in Prod + For Each Part In SelParts + Part.RefreshPartInProd() + Next + ' resetto stato di calc + SelMachGroup.ResetCalcMachGroup() + End If + ' aggiorno dati ultilizzo barra + BeamMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Dim WallMachGroup As MyMachGroupVM = SelMachGroup + ' verifico spessore + If SelPart.Section <> WallMachGroup.Section Then + MessageBox.Show(EgtMsg(61868), EgtMsg(30007)) + Return + End If + If AddPartToWall(WallMachGroup, SelPart) Then + ' aggiorno contatore pezzi usati in Prod + SelPart.RefreshPartInProd() + ' resetto stato di calc + SelMachGroup.ResetCalcMachGroup() + End If + ' aggiorno dati ultilizzo barra + WallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.TOP, False) + End If + EgtZoom(ZM.ALL) + End Sub + + Friend Function VerifyTotLength(BeamMachGroup As MyMachGroupVM, PartsToAdd As List(Of BTLPartVM)) As Boolean + Dim dNewPartPos As Double = 0 + If BeamMachGroup.PartVMList.Count > 0 Then + Dim LastPart As PartVM = BeamMachGroup.PartVMList(BeamMachGroup.PartVMList.Count - 1) + dNewPartPos += LastPart.dPOSX + LastPart.dL + End If + For Each Part In PartsToAdd + dNewPartPos += WarehouseHelper.GetOffset(BeamMachGroup.nType) + Part.dL + Next + Return dNewPartPos < BeamMachGroup.dL + End Function + + Friend Function AddPartToBeam(BeamMachGroup As MyMachGroupVM, PartsToAdd As List(Of BTLPartVM)) As Boolean + ' ordino i pezzi da aggiungere + PartsToAdd = PartsToAdd.OrderBy(Function(x) x.dL).ToList() + ' creo copie dei pezzi + Dim nPartDuploIdList As New List(Of Integer) + For Each Part In PartsToAdd + Dim nDuploId As Integer = EgtDuploNew(Part.nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nDuploId) + ' lo rendo std + EgtSetMode(nDuploId, GDB_MD.STD) + nPartDuploIdList.Add(nDuploId) + Next + ' calcolo posizione nuovo pezzo per rispettare ordine lunghezze + Dim nInsertIndex As Integer + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = BeamMachGroup.dStartCut + Dim nPartIndex As Integer = 0 + Dim nIndex As Integer + Dim bDuploInfo As Boolean = False + ' ciclo sui pezzi + For nIndex = 0 To BeamMachGroup.PartVMList.Count - 1 + For PartsToAddIndex = nPartIndex To PartsToAdd.Count - 1 + Dim Part As BTLPartVM = PartsToAdd(PartsToAddIndex) + ' se non ancora aggiunto e lunghezza minore del pezzo corrente, lo aggiungo + If nPartIndex < nPartDuploIdList.Count() AndAlso BeamMachGroup.PartVMList(nIndex).dL > Part.dL Then + ' se non è primo, aggiungo offset tra barre standard + If nIndex <> 0 OrElse nPartIndex <> 0 Then + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + End If + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, nPartDuploIdList(nPartIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += Part.dL + ' conservo indice d'inserimento + nInsertIndex = nIndex + nPartIndex += 1 + Else + Exit For + End If + Next + ' se non è primo, aggiungo offset del pezzo + If nIndex <> 0 Then + dPosX += BeamMachGroup.PartVMList(nIndex).dOffset + ' se sono a indice primo ed è stato aggiunto pezzo nuovo + ElseIf nIndex = 0 AndAlso nPartIndex > 0 Then + ' aggiungo offset tra barre standard + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + End If + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, BeamMachGroup.PartVMList(nIndex).nPartId & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += BeamMachGroup.PartVMList(nIndex).dL + Next + ' se non è ancora stato aggiunto + For PartsToAddIndex = nPartIndex To PartsToAdd.Count - 1 + ' aggiungo offset tra barre standard + dPosX += WarehouseHelper.GetOffset(BeamMachGroup.nType) + ' lo aggiungo in fondo + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + nPartIndex + 1, nPartDuploIdList(nPartIndex) & "," & DoubleToString(dPosX, 3)) + ' incremento posizione della sua lunghezza + dPosX += PartsToAdd(nPartIndex).dL + ' conservo indice d'inserimento + nInsertIndex = nIndex + nPartIndex += 1 + Next + ' elimino vecchio grezzo ed eseguo script creazione nuovo + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallito inserimento grezzo nella barra in AddPartToBeam") + ' elimino duplo + For Each nDuploId In nPartDuploIdList + EgtErase(nDuploId) + Next + ' aggiorno info grezzo + For nIndex = 0 To BeamMachGroup.PartVMList.Count - 1 + EgtSetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + 1, BeamMachGroup.PartVMList(nIndex).nPartId & "," & DoubleToString(BeamMachGroup.PartVMList(nIndex).dPOSX, 3)) + Next + ' rimuovo info duplo + While EgtGetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + 1, nPartDuploIdList(0)) + bDuploInfo = EgtGetInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + 1, nPartDuploIdList(0)) + EgtRemoveInfo(BeamMachGroup.Id, MGR_RPT_PART & nIndex + 1) + nIndex += 1 + End While + ' elimino vecchio grezzo ed eseguo script creazione nuovo + nRawId = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallita esecuzione ExecBeam. ERRORE") + End If + End If + For nDuploIndex = 0 To PartsToAdd.Count - 1 + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_ROT, PartsToAdd(nDuploIndex).nROTATED) + EgtSetInfo(nPartDuploIdList(nDuploIndex), MGR_PRT_FLIP, PartsToAdd(nDuploIndex).nINVERTED) + Next + ' aggiorno lista pezzi + BeamMachGroup.MyMachGroupM.RefreshPartList() + ' seleziono pezzo aggiunto + If BeamMachGroup.PartVMList.Count > nInsertIndex Then + BeamMachGroup.SelPart = BeamMachGroup.PartVMList(nInsertIndex) + ElseIf bDuploInfo Then + BeamMachGroup.SelPart = BeamMachGroup.PartVMList(BeamMachGroup.PartVMList.Count - 1) + End If + Return True + End Function + + Friend Function AddPartToWall(WallMachGroup As MyMachGroupVM, PartToAdd As BTLPartVM) As Boolean + ' creo copia del pezzo + Dim nPartDuploId As Integer = EgtDuploNew(PartToAdd.nPartId) + ' lo rendo std + EgtSetMode(nPartDuploId, GDB_MD.STD) + ' Posizione di inserimento + Dim dPosX As Double = WarehouseHelper.GetKerf() + Dim dPosY As Double = WarehouseHelper.GetKerf() + ' Se ci sono pezzi già inseriti + If WallMachGroup.PartVMList.Count > 0 Then + Dim LastWall As PartVM = WallMachGroup.PartVMList(WallMachGroup.PartVMList.Count - 1) + Dim LastWallPosX As Double = LastWall.dPOSX + Dim LastWallPosY As Double = LastWall.PartM.dPOSY + ' converto posizione ultimo pezzo nel riferimento BL + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + LastWallPosY = WallMachGroup.dW - LastWall.dW - LastWall.PartM.dPOSY + Case MCH_CR.BL + Case MCH_CR.TR + LastWallPosX = WallMachGroup.dL - LastWall.dL - LastWall.dPOSX + LastWallPosY = WallMachGroup.dW - LastWall.dW - LastWall.PartM.dPOSY + Case MCH_CR.BR + LastWallPosX = WallMachGroup.dL - LastWall.dL - LastWall.dPOSX + End Select + ' verifico se posso metterlo sopra in Y + Dim NextPosY = LastWallPosY + LastWall.dW + WarehouseHelper.GetOffset(WallMachGroup.nType) + If WallMachGroup.dW - NextPosY > PartToAdd.dW + 10 Then + dPosX = LastWallPosX + dPosY = NextPosY + Else + ' altrimenti lo affianco in X + dPosX = 10 + For i As Integer = 0 To WallMachGroup.PartVMList.Count - 1 + Dim CurrWall As PartVM = WallMachGroup.PartVMList(i) + Dim CurrWallPosX As Double = CurrWall.dPOSX + ' converto posizione pezzo corrente nel riferimento BL + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + Case MCH_CR.BL + Case MCH_CR.TR + CurrWallPosX = WallMachGroup.dL - CurrWall.dL - CurrWall.dPOSX + Case MCH_CR.BR + CurrWallPosX = WallMachGroup.dL - CurrWall.dL - CurrWall.dPOSX + End Select + Dim NextPosX = CurrWallPosX + CurrWall.dL + WarehouseHelper.GetOffset(WallMachGroup.nType) + If NextPosX > dPosX Then + dPosX = NextPosX + End If + Next + dPosY = 10 + End If + End If + ' converto posizione trovata da riferimento BL a quello corrente + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + dPosY = WallMachGroup.dW - PartToAdd.dW - dPosY + Case MCH_CR.BL + Case MCH_CR.TR + dPosX = WallMachGroup.dL - PartToAdd.dL - dPosX + dPosY = WallMachGroup.dW - PartToAdd.dW - dPosY + Case MCH_CR.BR + dPosX = WallMachGroup.dL - PartToAdd.dL - dPosX + End Select + ' aggiungo il pezzo al grezzo + If EgtAddPartToRawPart(nPartDuploId, New Point3d(dPosX, dPosY, 0), WallMachGroup.MyMachGroupM.nRawPartId) Then + EgtSetInfo(nPartDuploId, MGR_PRT_POSX, dPosX) + EgtSetInfo(nPartDuploId, MGR_PRT_POSY, dPosY) + EgtSetInfo(nPartDuploId, MGR_PRT_ROT, PartToAdd.nROTATED) + EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, PartToAdd.nINVERTED) + Else + Return False + End If + 'aggiorno lista pezzi + WallMachGroup.MyMachGroupM.RefreshPartList() + ' seleziono pezzo aggiunto + If WallMachGroup.PartVMList.Count > 0 Then WallMachGroup.SelPart = WallMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartDuploId) + Return True + End Function + +#End Region ' AddToRawPart + +#Region "CopyPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyPart_Command As ICommand + Get + If m_cmdCopyPart Is Nothing Then + m_cmdCopyPart = New Command(AddressOf CopyPart) + End If + Return m_cmdCopyPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyPart() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelPart) Then Return + ' creo copia + Dim NewPart As BTLPartM = SelPart.Copy() + If Not IsNothing(NewPart) Then + ' selezione ultimo che e' quello appena creato + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList(Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1), False, True) + End If + End Sub + +#End Region ' CopyPart + +#Region "AddPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddPart_Command As ICommand + Get + If m_cmdAddPart Is Nothing Then + m_cmdAddPart = New Command(AddressOf AddPart) + End If + Return m_cmdAddPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddPart(ByVal param As Object) + If IsNothing(ProjectManagerVM.CurrProj) Then Return + ' apro finestra di definizione nuovo part + Dim AddPartWndVM As New AddPartWndVM() + Dim AddPartWnd As Object = Nothing + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + AddPartWnd = New OnlyProdAddPartWndV(Application.Current.MainWindow, AddPartWndVM) + Else + AddPartWnd = New AddPartWndV(Application.Current.MainWindow, AddPartWndVM) + End If + If AddPartWnd.ShowDialog() Then + ' creo nuovo part + Dim nNewPartId As Integer = EgtBeamCreatePart() + ' scrivo info proj + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProj.nProjId) + EgtBeamSetPartProdNbr(AddPartWndVM.nPDN) + If Not IsNothing(AddPartWndVM.sNAM) Then EgtBeamSetPartName(AddPartWndVM.sNAM) + EgtBeamSetPartCount(AddPartWndVM.nCNT) + EgtBeamSetPartBox(AddPartWndVM.dL, AddPartWndVM.dH, AddPartWndVM.dW) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' recupero il box del pezzo + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nNewPartId, "Box") + Dim b3Solid As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Solid) + Dim bOk As Boolean = EgtRotate(nNewPartId, b3Solid.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + If bOk Then + EgtSetInfo(nNewPartId, BTL_PRT_ROTATED, 180) + End If + End If + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim NewPartVM As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + If Not IsNothing(NewPartVM) Then + EgtZoom(ZM.ALL) + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(NewPartVM, False, True) + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(NewPartVM.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(NewPartVM.Section) + End If + End If + End If + + End Sub + +#End Region ' AddPart + +#Region "RemovePart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemovePart_Command As ICommand + Get + If m_cmdRemovePart Is Nothing Then + m_cmdRemovePart = New Command(AddressOf RemovePartCmd) + End If + Return m_cmdRemovePart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemovePartCmd() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 0 Then + Dim CurrSelBTLParts As List(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.SelBTLParts.ToList() + For RemoveIndex = CurrSelBTLParts.Count - 1 To 0 Step -1 + RemovePart(CurrSelBTLParts(RemoveIndex), RemoveIndex = 0) + Next + End If + End Sub + + Public Sub RemovePart(BTLPartToDelete As BTLPartVM, bSelPrevious As Boolean) + ' verifico se ci sono già copie in grezzi + Dim nDuploCount As Integer = 0 + If EgtDuploCount(BTLPartToDelete.nPartId, nDuploCount) AndAlso nDuploCount > 0 Then + ' avviso che il pezzo non è cancellabile perchè in produzione + MessageBox.Show(String.Format(EgtMsg(61929), nDuploCount), EgtMsg(15003), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + ' verifico se rimuovere sezione dalla lista + If Not Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot BTLPartToDelete AndAlso x.Section = BTLPartToDelete.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Remove(BTLPartToDelete.Section) + Map.refProjectVM.BTLStructureVM.SelSection = SectionXMaterial.Empty + End If + ' Eseguo cancellazione + EgtBeamSetPart(BTLPartToDelete.nPartId) + If EgtBeamErasePart() Then + ' seleziono elemento precedente + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList.IndexOf(BTLPartToDelete) + Dim FilteredIndex As Integer = Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.IndexOf(BTLPartToDelete) + Map.refProjectVM.BTLStructureVM.SelBTLParts.Remove(BTLPartToDelete) + If bSelPrevious Then + If FilteredIndex = 0 Then + If Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(1)) + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing) + End If + ElseIf FilteredIndex = Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count - 1 Then + If Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View.Count - 2)) + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Nothing) + End If + Else + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList_View(FilteredIndex - 1)) + End If + End If + ' rimuovo dalla lista pezzi + Map.refProjectVM.BTLStructureVM.BTLPartVMList.RemoveAt(Index) + End If + End Sub + +#End Region ' RemovePart + +#Region "Invert" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property Invert_Command As ICommand + Get + If m_cmdInvert Is Nothing Then + m_cmdInvert = New Command(AddressOf Invert) + End If + Return m_cmdInvert + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub Invert() + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso IsNothing(ProjectManagerVM.CurrProj)) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then Return + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + ' inverto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.Invert() + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + End Sub + +#End Region ' Invert + +#Region "BackRotation" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property BackRotation_Command As ICommand + Get + If m_cmdBackRotation Is Nothing Then + m_cmdBackRotation = New Command(AddressOf BackRotation) + End If + Return m_cmdBackRotation + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub BackRotation() + If IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then Return + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + ' ruoto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.BackRotation(False, False) + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + EgtDraw() + End Sub + +#End Region ' BackRotation + +#Region "ForwardRotation" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ForwardRotation_Command As ICommand + Get + If m_cmdForwardRotation Is Nothing Then + m_cmdForwardRotation = New Command(AddressOf ForwardRotation) + End If + Return m_cmdForwardRotation + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ForwardRotation() + If IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM) Then Return + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + ' se modalita' assemblato + Dim bShowBuilding As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Configuration.AssembledMode(bShowBuilding) + ' ruoto i pezzi selezionati + For Each Part In Map.refProjectVM.BTLStructureVM.SelBTLParts + Part.ForwardRotation(False, False) + Next + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + EgtDraw() + End Sub + +#End Region ' ForwardRotation + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml b/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml new file mode 100644 index 00000000..a703fb1e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml.vb new file mode 100644 index 00000000..9558fa95 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLPartManager/OnlyProdBTLPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdBTLPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLViewModel/BTLFeatureVM.vb b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLFeatureVM.vb new file mode 100644 index 00000000..6312f28c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLFeatureVM.vb @@ -0,0 +1,721 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.Globalization +Imports System.IO +Imports System.Text.RegularExpressions +Imports System.Windows.Interop +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 +Imports Mysqlx.XDevAPI.Common + +Public Class BTLFeatureVM + Inherits Core.BTLFeatureVM + + Public Property GRPList As ObservableCollection(Of Integer) + Get + Return m_BTLFeatureM.GRPList + End Get + Set(value As ObservableCollection(Of Integer)) + m_BTLFeatureM.GRPList = value + End Set + End Property + + Public Overrides Property nSelGRP As Integer + Get + Return m_BTLFeatureM.nSelGRP + End Get + Set(value As Integer) + If value <> -1 Then + ' verifico se solido attivo + Dim bShowSolid As Boolean = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + ' aggiorno la feature con nuovo valore + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + m_BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(value, m_BTLFeatureM.nPRC, nSelSIDE, m_BTLFeatureM.sDES, m_BTLFeatureM.nPRID, + m_BTLFeatureM.frFRAME, vPar, sPar, vParQ) + If bOK Then + m_BTLFeatureM.nSelGRP = value + ' seleziono feature in disegno + SelGeomFeature() + ' rendo non calcolata questa feature + ResetCalcFeature() + End If + NotifyPropertyChanged(NameOf(nSelGRP)) + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + EgtDraw() + End If + End Set + End Property + + Public Property SIDEList As ObservableCollection(Of Integer) + Get + Return m_BTLFeatureM.SIDEList + End Get + Set(value As ObservableCollection(Of Integer)) + m_BTLFeatureM.SIDEList = value + End Set + End Property + + ' Lato + Public Overrides Property nSelSIDE As Integer + Get + Return m_BTLFeatureM.nSelSIDE + End Get + Set(value As Integer) + If value <> -1 Then + ' verifico se solido attivo + Dim bShowSolid As Boolean = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + ' se freecontour + If Me.m_BTLFeatureM.IsFreeContour() Then + ' cambio faccia alla geometria + Dim frOld As New Frame3d + EgtBeamGetSideData(nSelSIDE, frOld) + frOld.Invert() + Dim frNew As New Frame3d + EgtBeamGetSideData(value, frNew) + Dim sAuxId As String = "" + If EgtGetInfo(nFeatureId, "AUXID", sAuxId) Then + ' verifico se ha uno o due percorsi + Dim sAuxIdSplit() As String = sAuxId.Split(","c) + If Not IsNothing(sAuxIdSplit) AndAlso sAuxIdSplit.Length() >= 1 Then + Dim nAuxId As Integer = GDB_ID.NULL + If Integer.TryParse(sAuxIdSplit(0), nAuxId) Then + EgtTransform(nFeatureId + nAuxId, frOld, GDB_RT.GLOB) + EgtTransform(nFeatureId + nAuxId, frNew, GDB_RT.GLOB) + End If + End If + If Not IsNothing(sAuxIdSplit) AndAlso sAuxIdSplit.Length() >= 2 Then + Dim nAux2Id As Integer = GDB_ID.NULL + If Integer.TryParse(sAuxIdSplit(1), nAux2Id) Then + EgtTransform(nFeatureId + nAux2Id, frOld, GDB_RT.GLOB) + EgtTransform(nFeatureId + nAux2Id, frNew, GDB_RT.GLOB) + End If + End If + End If + End If + ' aggiorno la feature con nuovo valore + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + m_BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(nSelGRP, m_BTLFeatureM.nPRC, value, m_BTLFeatureM.sDES, m_BTLFeatureM.nPRID, + m_BTLFeatureM.frFRAME, vPar, sPar, vParQ) + If bOK Then + m_BTLFeatureM.nSelSIDE = value + SelGeomFeature() + ' rendo non calcolata questa feature + ResetCalcFeature() + End If + NotifyPropertyChanged(NameOf(nSelSIDE)) + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + EgtDraw() + End If + End Set + End Property + + Public Property VARIANTList As ObservableCollection(Of Integer) + Get + Return m_BTLFeatureM.VARIANTList + End Get + Set(value As ObservableCollection(Of Integer)) + m_BTLFeatureM.VARIANTList = value + End Set + End Property + + Public Overrides Property nSelVARIANT As Integer + Get + Return m_BTLFeatureM.nSelVARIANT + End Get + Set(value As Integer) + If value <> m_BTLFeatureM.nSelVARIANT Then + m_BTLFeatureM.nSelVARIANT = value + Dim vPar As Double() = Nothing + Dim sPar As String = Nothing + Dim vParQ As String() = Nothing + CreateFeatureVariant(value, vPar, sPar, vParQ) + If IsNothing(vPar) Then + m_BTLFeatureM.nSelVARIANT = 0 + CreateFeatureVariant(value, vPar, sPar, vParQ) + End If + m_BTLFeatureM.nSelVARIANT = value + Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(nSelGRP, m_BTLFeatureM.nPRC, nSelSIDE, sDES, m_BTLFeatureM.nPRID, + m_BTLFeatureM.frFRAME, vPar, sPar, vParQ) + If bOK Then + EgtDuploSetModified(m_BTLPartM.nPartId) + ' seleziono feature in disegno + SelGeomFeature() + ' rendo non calcolata questa feature + ResetCalcFeature() + End If + NotifyPropertyChanged(NameOf(nSelVARIANT)) + NotifyPropertyChanged(NameOf(PBTLParamVMList)) + NotifyPropertyChanged(NameOf(QBTLParamVMList)) + EgtDraw() + End If + End Set + End Property + + Private Sub CreateFeatureVariant(value As Integer, ByRef vPar() As Double, ByRef sPar As String, ByRef vParQ() As String) + ' crea parametri per questa feature da file ini + m_BTLFeatureM.CreateFeatureParams(m_BTLFeatureM) + m_BTLFeatureM.SetDefaultValues() + CreatePBTLParamVMList() + CreateQBTLParamVMList() + ' aggiorno la feature con nuovo valore + vPar = Nothing + sPar = Nothing + vParQ = Nothing + m_BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + ' imposto path disegno da mostrare in BottomPanel + If value > 0 AndAlso File.Exists(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & "." & sDES & ".png") Then + Map.refBottomPanelVM.SetCurrDraw(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & "." & sDES & ".png") + Else + Map.refBottomPanelVM.SetCurrDraw(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & ".png") + End If + End Sub + + Public Property sPriority As String + Get + Return m_BTLFeatureM.nPriority.ToString() + End Get + Set(value As String) + Dim nTemp As Integer = 0 + If Integer.TryParse(value, nTemp) Then + If EgtSetInfo(nFeatureId, BTL_FTR_PRIORITY, nTemp) Then + m_BTLFeatureM.nPriority = nTemp + ' setto feature da ricalcolare + ResetCalcFeature() + ' se in View + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' imposto modificato per copie + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) + End If + End If + End If + NotifyPropertyChanged(NameOf(sPriority)) + End Set + End Property + ' proprieta' che indica se e' attivo l'update del parametro bDO su piu' feature (attiva/disattiva tutti su pezzo, o per tipo con tasto destro) + ' necessario per evitare ricalcolo della grafica sulla modifica del parametro per ogni feature + Private Shared m_bDO_MultipleUpdate As Boolean = False + Public Shared Property bDO_MultipleUpdate As Boolean + Get + Return m_bDO_MultipleUpdate + End Get + Set(value As Boolean) + m_bDO_MultipleUpdate = value + End Set + End Property + + Public Overrides Property bDO As Boolean + Get + Return m_BTLFeatureM.bDO + End Get + Set(value As Boolean) + Dim bShowSolid As Boolean = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If value <> m_BTLFeatureM.bDO Then + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + ' verifico se solido attivo + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + End If + If EgtBeamEnableProcess(nFeatureId, value, Not m_bDO_MultipleUpdate) Then + m_BTLFeatureM.bDO = value + ' setto feature da ricalcolare + ResetCalcFeature() + ' se in View + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(m_BTLPartM)) Then + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) + End If + NotifyPropertyChanged(NameOf(bDO)) + ' aggiorno messaggio su context menu + For Each Item In MenuList + Item.NotifyPropertyChanged(NameOf(Item.sMsg)) + Next + End If + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + ' eventualmente ripristino solido + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + If Not m_bDO_MultipleUpdate Then EgtDraw() + ' aggiorno stato abilitazione del bottone modifica free contour + Map.refFeatureManagerVM.SetEditIsEnabled() + End If + End Set + End Property + + Public ReadOnly Property sDrawPath As String + Get + If nPRC = 900 AndAlso nSelVARIANT > 0 Then + Return Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & "." & sDES & ".png" + Else + Return Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & sDescGRP & ".png" + End If + End Get + End Property + + Private m_PBTLParamVMList As ObservableCollection(Of BTLParamVM) + Public Property PBTLParamVMList As ObservableCollection(Of BTLParamVM) + Get + Return m_PBTLParamVMList + End Get + Set(value As ObservableCollection(Of BTLParamVM)) + m_PBTLParamVMList = value + End Set + End Property + + Protected m_SelPBTLParam As BTLParamVM + Public Property SelPBTLParam As BTLParamVM + Get + Return m_SelPBTLParam + End Get + Set(value As BTLParamVM) + m_SelPBTLParam = value + If Not IsNothing(m_SelPBTLParam) Then + ' imposto path disegno da mostrare in BottomPanel + If Not IsNothing(Map.refBottomPanelVM) Then + Map.refBottomPanelVM.SetCurrDraw(m_SelPBTLParam.sDrawPath) + End If + End If + NotifyPropertyChanged(NameOf(SelPBTLParam)) + End Set + End Property + + Private m_QBTLParamVMList As ObservableCollection(Of BTLParamVM) + Public Property QBTLParamVMList As ObservableCollection(Of BTLParamVM) + Get + Return m_QBTLParamVMList + End Get + Set(value As ObservableCollection(Of BTLParamVM)) + m_QBTLParamVMList = value + End Set + End Property + + Protected m_SelQParam As BTLParamVM + Public Property SelQBTLParam As BTLParamVM + Get + Return m_SelQParam + End Get + Set(value As BTLParamVM) + m_SelQParam = value + If Not IsNothing(m_SelQParam) AndAlso Not IsNothing(Map.refBottomPanelVM) Then + ' imposto path disegno da mostrare in BottomPanel + Map.refBottomPanelVM.SetCurrDraw(m_SelQParam.sDrawPath) + End If + NotifyPropertyChanged(NameOf(SelQBTLParam)) + End Set + End Property + + Public ReadOnly Property Edit_Visibility As Visibility + Get + Return If(BTLFeatureM.IsFreeContour AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Public ReadOnly Property SaveCancel_Visibility As Visibility + Get + Return If(BTLFeatureM.IsFreeContour AndAlso Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Friend Sub RefreshFCMBtnVisibility() + NotifyPropertyChanged(NameOf(Edit_Visibility)) + NotifyPropertyChanged(NameOf(SaveCancel_Visibility)) + End Sub + + Private m_MenuList As New List(Of MenuItemVm) + Public Property MenuList As List(Of MenuItemVm) + Get + Return m_MenuList + End Get + Set(value As List(Of MenuItemVm)) + m_MenuList = value + End Set + End Property + + ' Definizione comandi + Private m_cmdEdit As ICommand + Private m_cmdSave As ICommand + Private m_cmdCancel As ICommand + Private m_cmdDeleteFeature As ICommand + +#Region "CONSTRUCTOR" + + Sub New(BTLFeatureM As BTLFeatureM, BTLPartM As BTLPartM) + m_BTLFeatureM = BTLFeatureM + AddHandler m_BTLFeatureM.PBTLParamAdded, AddressOf OnPBTLParamAdded + AddHandler m_BTLFeatureM.QBTLParamAdded, AddressOf OnQBTLParamAdded + m_BTLPartM = BTLPartM + CreatePBTLParamVMList() + CreateQBTLParamVMList() + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + m_MenuList.Add(New MenuItemVm(Me)) + End Sub + + Sub New(BTLFeatureM As BTLFeatureM) + m_BTLFeatureM = BTLFeatureM + AddHandler m_BTLFeatureM.QBTLParamAdded, AddressOf OnQBTLParamAdded + m_BTLPartM = Nothing + Dim Part As PartM = BTLFeatureM.ParentPart + If Part.nType = BWType.WALL Then CreateQBTLParamVMList() + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub CreatePBTLParamVMList() + Dim all As List(Of BTLParamVM) = (From BTLParamM In m_BTLFeatureM.GetPBTLParams() + Select New BTLParamVM(BTLParamM, m_BTLFeatureM)).ToList() + + For Each BTLParamVM As BTLParamVM In all + AddHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged + Next + + m_PBTLParamVMList = New ObservableCollection(Of BTLParamVM)(all) + AddHandler m_PBTLParamVMList.CollectionChanged, AddressOf OnPBTLParamVMListChanged + + End Sub + + Private Sub CreateQBTLParamVMList() + Dim all As List(Of BTLParamVM) = (From BTLParamM In m_BTLFeatureM.GetQBTLParams() + Select New BTLParamVM(BTLParamM, m_BTLFeatureM)).ToList() + + For Each BTLParamVM As BTLParamVM In all + AddHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged + Next + + m_QBTLParamVMList = New ObservableCollection(Of BTLParamVM)(all) + AddHandler m_QBTLParamVMList.CollectionChanged, AddressOf OnQBTLParamVMListChanged + End Sub + + ' funzione che aggiorna lo stato, la rotazione e gli errori dopo calcolo + Friend Sub CalcFeatureUpdate(ERR As Integer, ROT As Integer, MSG As String) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_ERR, ITG_PROD_ERR), ERR, True) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_MSG, ITG_PROD_MSG), MSG, True) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_ROT, ITG_PROD_ROT), ROT, True) + m_BTLFeatureM.nCALC_ERR = ERR + m_BTLFeatureM.nCALC_ROT = ROT + m_BTLFeatureM.sCALC_MSG = MSG + Select Case ERR + Case 0 + m_BTLFeatureM.nState = CalcStates.OK + Case 22 + m_BTLFeatureM.nState = CalcStates.COLLISION + Case 17, 19 + m_BTLFeatureM.nState = CalcStates.WARNING + Case < 0 + m_BTLFeatureM.nState = CalcStates.INFO + Case > 0 + m_BTLFeatureM.nState = CalcStates.ERROR_ + End Select + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + End Sub + + ' funzione che resetta gli errori del calcolo + Friend Sub ResetFeatureError() + Dim ERR As Integer = 0 + Dim MSG As String = "" + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_ERR, ITG_PROD_ERR), ERR, True) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_MSG, ITG_PROD_MSG), MSG, True) + m_BTLFeatureM.nCALC_ERR = ERR + m_BTLFeatureM.sCALC_MSG = MSG + Select Case ERR + Case 0 + m_BTLFeatureM.nState = CalcStates.OK + Case 22 + m_BTLFeatureM.nState = CalcStates.COLLISION + Case 17, 19 + m_BTLFeatureM.nState = CalcStates.WARNING + Case < 0 + m_BTLFeatureM.nState = CalcStates.INFO + Case > 0 + m_BTLFeatureM.nState = CalcStates.ERROR_ + End Select + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + End Sub + + Friend Sub ResetCalcFeature() + EgtRemoveInfo(nFeatureId, If(IsNothing(m_BTLPartM), ITG_PROD_ERR, ITG_PROJ_ERR)) + EgtRemoveInfo(nFeatureId, If(IsNothing(m_BTLPartM), ITG_PROD_MSG, ITG_PROJ_MSG)) + EgtRemoveInfo(nFeatureId, If(IsNothing(m_BTLPartM), ITG_PROD_ROT, ITG_PROJ_ROT)) + m_BTLFeatureM.nState = CalcStates.NOTCALCULATED + m_BTLFeatureM.nCALC_ERR = 0 + m_BTLFeatureM.nCALC_ROT = 0 + m_BTLFeatureM.sCALC_MSG = "" + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + End Sub + + Public Function Copy() As BTLFeatureM + Return Copy(m_BTLPartM) + End Function + + Public Function Copy(DestBTLPart As BTLPartM) As BTLFeatureM + ' creo nuova feature + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + m_BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + ' imposto eventuali percorsi + Dim nCrvId As Integer = GDB_ID.NULL + Dim nCrv2Id As Integer = GDB_ID.NULL + m_BTLFeatureM.GetFreeContourPaths(nCrvId, nCrv2Id) + ' creo la feature con nuovi valori + EgtBeamSetPart(DestBTLPart.nPartId) + Dim nNewFeatureId As Integer = EgtBeamAddProcess(m_BTLFeatureM.nSelGRP, m_BTLFeatureM.nPRC, m_BTLFeatureM.nSelSIDE, m_BTLFeatureM.sDES, + DestBTLPart.NewProcId(), m_BTLFeatureM.frFRAME, vPar, sPar, vParQ, nCrvId, nCrv2Id) + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + ' Riporto eventuali indicazioni di parametri Q custom + For Each QPar In QBTLParamVMList + If QPar.bCustom Then EgtSetInfo(nNewFeatureId, QPar.sName & "A", 1) + Next + ' Riporto priority + EgtSetInfo(nNewFeatureId, BTL_FTR_PRIORITY, m_BTLFeatureM.nPriority) + Dim NewFeat As BTLFeatureM = BTLFeatureM.CreateBTLFeature(m_BTLPartM, nNewFeatureId) + ' la aggiungo a struttura BTL pezzo di destinazione + DestBTLPart.AddBTLFeature(NewFeat) + Return NewFeat + End If + Return Nothing + End Function + + Public Overrides Sub RefreshFeature() + ' leggo gruppo, numero feature, lato e priorità + EgtGetInfo(nFeatureId, BTL_FTR_GRP, m_BTLFeatureM.nSelGRP) + EgtGetInfo(nFeatureId, BTL_FTR_PRC, m_BTLFeatureM.nPRC) + EgtGetInfo(nFeatureId, BTL_FTR_SIDE, m_BTLFeatureM.nSelSIDE) + EgtGetInfo(nFeatureId, BTL_FTR_PRIORITY, m_BTLFeatureM.nPriority) + Dim nDO As Integer = 1 + If EgtGetInfo(nFeatureId, BTL_FTR_DO, nDO) Then + m_BTLFeatureM.bDO = (nDO <> 0) + Else + m_BTLFeatureM.bDO = True + End If + NotifyPropertyChanged(NameOf(bDO)) + ' leggo des,prid e frame + EgtGetInfo(nFeatureId, BTL_FTR_DES, m_BTLFeatureM.sDES) + EgtGetInfo(nFeatureId, BTL_FTR_PRID, m_BTLFeatureM.nPRID) + EgtGetInfo(nFeatureId, BTL_FTR_FRAME, m_BTLFeatureM.frFRAME) + + ' aggiorno parametri della feature + + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "DeleteFeature" + + Public ReadOnly Property DeleteFeature_Command As ICommand + Get + If m_cmdDeleteFeature Is Nothing Then + m_cmdDeleteFeature = New Command(AddressOf DeleteFeature) + End If + Return m_cmdDeleteFeature + End Get + End Property + + Public Sub DeleteFeature() + If Map.refMainMenuVM.SelPage = Pages.VIEW Then Map.refFeatureListManagerVM.RemoveFeature() + End Sub + +#End Region ' DeleteFeature + +#Region "Edit" + + Public ReadOnly Property Edit_Command As ICommand + Get + If m_cmdEdit Is Nothing Then + m_cmdEdit = New Command(AddressOf Edit) + End If + Return m_cmdEdit + End Get + End Property + + Public Sub Edit() + ' attivo modalita' contorno libero + Map.refFreeContourManagerVM.Open() + End Sub + +#End Region ' Edit + +#Region "Save" + + Public ReadOnly Property Save_Command As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + Public Sub Save() + Select Case Map.refFreeContourManagerVM.SelType + Case FreeContourManagerVM.FreeContourTypes.ONE + Case FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES + Case FreeContourManagerVM.FreeContourTypes.TWO + End Select + ' disattivo modalita' contorno libero + Map.refFreeContourManagerVM.Close(True) + End Sub + +#End Region ' Save + +#Region "Cancel" + + Public ReadOnly Property Cancel_Command As ICommand + Get + If m_cmdCancel Is Nothing Then + m_cmdCancel = New Command(AddressOf Cancel) + End If + Return m_cmdCancel + End Get + End Property + + Public Sub Cancel() + ' disattivo modalita' contorno libero + Map.refFreeContourManagerVM.Close(False) + End Sub + +#End Region ' Cancel + +#End Region ' COMMANDS + +#Region "EVENTS" + + Private Sub OnPBTLParamAdded(sender As Object, e As BTLParamAddedEventArgs) Handles m_BTLFeatureM.PBTLParamAdded + Dim BTLParamVM As New BTLParamVM(e.NewBTLParam, m_BTLFeatureM) + PBTLParamVMList.Add(BTLParamVM) + End Sub + Private Sub OnQBTLParamAdded(sender As Object, e As BTLParamAddedEventArgs) Handles m_BTLFeatureM.QBTLParamAdded + Dim BTLParamVM As New BTLParamVM(e.NewBTLParam, m_BTLFeatureM) + QBTLParamVMList.Add(BTLParamVM) + End Sub + + Private Sub OnPBTLParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.NewItems + AddHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.OldItems + RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnPBTLParamVMPropertyChanged + Next + End If + End Sub + Private Sub OnQBTLParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.NewItems + AddHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.OldItems + RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnQBTLParamVMPropertyChanged + Next + End If + End Sub + + Private Sub OnPBTLParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.dValue), NameOf(sender.sValue) + ' riseleziono questa feature + SelGeomFeature() + ' rendo non calcolata questa feature + ResetCalcFeature() + End Select + End Sub + Private Sub OnQBTLParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.dValue), NameOf(sender.sValue) + ' riseleziono questa feature + SelGeomFeature() + ' rendo non calcolata questa feature + ResetCalcFeature() + End Select + End Sub + +#End Region ' EVENTS + +End Class + +Public Class MenuItemVm + Inherits VMBase + + Private m_ParentFeature As BTLFeatureVM + Public ReadOnly Property ParentFeature As BTLFeatureVM + Get + Return m_ParentFeature + End Get + End Property + + Public ReadOnly Property sMsg As String + Get + Return If(ParentFeature.bDO, "Disable all ", "Enable all ") & ParentFeature.sDescGRP + End Get + End Property + + ' Definizione comando + Private m_cmdCommand As ICommand + + Sub New(Parent As BTLFeatureVM) + m_ParentFeature = Parent + End Sub + +#Region "Cancel" + + Public ReadOnly Property MenuItem_Command As ICommand + Get + If m_cmdCommand Is Nothing Then + m_cmdCommand = New Command(AddressOf Command) + End If + Return m_cmdCommand + End Get + End Property + + Public Sub Command() + Dim bNewDo As Boolean = Not ParentFeature.bDO + ' imposto modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = True + ' aggiorno tutte le feature del pezzo + Dim SameProcFeatureList As List(Of BTLFeatureVM) = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Where(Function(x) x.nPRC = ParentFeature.nPRC AndAlso x.GRPList.Contains(ParentFeature.nSelGRP)).ToList() + For FeatureVMIndex = 0 To SameProcFeatureList.Count - 1 + If FeatureVMIndex = SameProcFeatureList.Count - 1 Then + ' reset modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = False + End If + Dim FeatureVM As BTLFeatureVM = SameProcFeatureList(FeatureVMIndex) + If FeatureVM.nPRC = ParentFeature.nPRC AndAlso FeatureVM.GRPList.Contains(ParentFeature.nSelGRP) Then + FeatureVM.bDO = bNewDo + End If + Next + End Sub + +#End Region ' Cancel + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/BTLViewModel/BTLParamVM.vb b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLParamVM.vb new file mode 100644 index 00000000..9adf6fff --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLParamVM.vb @@ -0,0 +1,334 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLParamVM + Inherits VMBase + + Protected m_BTLParamM As BTLParamM + Public ReadOnly Property BTLParamM As BTLParamM + Get + Return m_BTLParamM + End Get + End Property + + Private m_BTLFeatureM As BTLFeatureM + + Public ReadOnly Property bIsP As Boolean + Get + Return m_BTLParamM.bIsP + End Get + End Property + + Public Property bIsModified As Boolean + Get + Return m_BTLParamM.bIsModified + End Get + Set(value As Boolean) + m_BTLParamM.bIsModified = value + End Set + End Property + + Public ReadOnly Property Custom_Visibility As Visibility + Get + If bIsP Then + Return Visibility.Collapsed + Else + Return Visibility.Visible + End If + End Get + End Property + + ' parametri da struttura + Public Property sName As String + Get + Return m_BTLParamM.sName + End Get + Set(value As String) + m_BTLParamM.sName = value + End Set + End Property + + Public ReadOnly Property nId As Integer + Get + Return m_BTLParamM.nId + End Get + End Property + + Public Property sDescription As String + Get + Return m_BTLParamM.sDescription + End Get + Set(value As String) + m_BTLParamM.sDescription = value + End Set + End Property + + Public ReadOnly Property sMin As String + Get + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + Return DoubleToString(m_BTLParamM.dMin, 3) + Case BTLParamType.LENGTH + Return LenToString(m_BTLParamM.dMin, 3) + Case Else + Return "" + End Select + End Get + End Property + + Public ReadOnly Property dMin As Double + Get + Return m_BTLParamM.dMin + End Get + End Property + + Public ReadOnly Property sMax As String + Get + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + Return DoubleToString(m_BTLParamM.dMax, 3) + Case BTLParamType.LENGTH + Return LenToString(m_BTLParamM.dMax, 3) + Case Else + Return "" + End Select + End Get + End Property + + Public ReadOnly Property dMax As Double + Get + Return m_BTLParamM.dMax + End Get + End Property + + ' parametri da geometria + Public Property sValue As String + Get + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + Return DoubleToString(m_BTLParamM.dValue, 3) + Case BTLParamType.LENGTH + Return LenToString(m_BTLParamM.dValue, 3) + Case Else ' stringhe + Return m_BTLParamM.sValue + End Select + Return If(m_BTLParamM.nType = BTLParamType.LENGTH, LenToString(m_BTLParamM.dValue, 3), DoubleToString(m_BTLParamM.dValue, 3)) + End Get + Set(value As String) + Dim dNewValue As Double + ' trasformo valori + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + StringToDoubleAdv(value, dNewValue, True) + Case BTLParamType.LENGTH + StringToLenAdv(value, dNewValue, True) + Case Else + ' per string non faccio nulla + End Select + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + ' verifico che sia compreso tra minimo e massimo + If dNewValue < m_BTLParamM.dMin OrElse dNewValue > m_BTLParamM.dMax Then + MessageBox.Show(EgtMsg(61856), EgtMsg(30007)) + NotifyPropertyChanged(NameOf(sValue)) + Return + End If + ' recupero ParentPart + Dim ParentPart As BTLPartM = TryCast(m_BTLParamM.ParentFeature.ParentPart, BTLPartM) + ' recupero PartId + Dim nPartId As Integer = ParentPart.nPartId + ' numero di pezzi inseriti nelle barre + Dim INPROD As Integer = 0 + EgtDuploInRawCount(nPartId, INPROD) + ' recupero pezzi lavorati da Db + Dim nDoneCnt As Integer = DbControllers.m_ProjController.getCountItemState(ProjectManagerVM.CurrProj.nProjId, nPartId, ItemState.Assigned) + ' controllo se i pezzi sono lavorati se si messaggio di warning altrimenti messaggio informativo + If nDoneCnt > 0 Then + MessageBox.Show("Pezzo " & nPartId & " non modificato in " & INPROD & " barra/e perche' settata/e come da produrre", EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) + ElseIf INPROD > 0 Then + MessageBox.Show("Pezzo " & nPartId & " modificato in " & INPROD & " barra/e grezza/e", EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Information) + End If + UpdateParamValue(dNewValue, "") + Case Else + UpdateParamValue(0, value) + End Select + NotifyPropertyChanged(NameOf(bCustom)) + End Set + End Property + Public Property dValue As Double + Get + Return m_BTLParamM.dValue + End Get + Set(value As Double) + m_BTLParamM.dValue = value + NotifyPropertyChanged(NameOf(sValue)) + End Set + End Property + + Public Property sDefault As String + Get + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + Return DoubleToString(m_BTLParamM.dDefault, 3) + Case BTLParamType.LENGTH + Return LenToString(m_BTLParamM.dDefault, 3) + Case Else + Return "" + End Select + End Get + Set(value As String) + Dim dNewValue As Double + ' trasformo valori + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_ + StringToDoubleAdv(value, dNewValue, True) + Case BTLParamType.LENGTH + StringToLenAdv(value, dNewValue, True) + Case Else + ' per string non faccio nulla + End Select + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + ' verifico che sia compreso tra minimo e massimo + If dNewValue < m_BTLParamM.dMin OrElse dNewValue > m_BTLParamM.dMax Then + MessageBox.Show(EgtMsg(61856), EgtMsg(30007)) + NotifyPropertyChanged(NameOf(sDefault)) + Return + End If + m_BTLParamM.dDefault = dNewValue + m_BTLParamM.bIsModified = True + Case Else + m_BTLParamM.dDefault = 0 + m_BTLParamM.bIsModified = True + End Select + End Set + End Property + + Public ReadOnly Property nType As BTLParamType + Get + Return m_BTLParamM.nType + End Get + End Property + + Protected m_sDrawPath As String + Public ReadOnly Property sDrawPath As String + Get + Return Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Parameters\" & m_BTLFeatureM.sDescGRP & "_" & m_BTLParamM.sName & "_" & m_BTLFeatureM.nSelGRP & ".gif" + End Get + End Property + + Public Property bCustom As Boolean + Get + Return m_BTLParamM.bCustom + End Get + Set(value As Boolean) + ' Se de-checko il parametro settiamo il suo valore a quello di default + Dim bFound As Boolean = False + If Not value Then + ' Cerco il parametro Q direttamente nel file ini + Dim ParamIndex As String = 1 + Dim NewBTLParam As BTLParamM = Nothing + While BTLIniFile.GetBeamPrivateProfileParam(Me.m_BTLFeatureM.nSelGRP, Me.m_BTLFeatureM.nPRC, Me.m_BTLFeatureM.nSelVARIANT, False, ParamIndex, Nothing, NewBTLParam) + Dim QBTLParam As BTLParamVM = New BTLParamVM(NewBTLParam) + If QBTLParam.sName = Me.sName Then + Me.sValue = QBTLParam.sDefault + NotifyPropertyChanged(NameOf(sValue)) + m_BTLParamM.bCustom = value + ' setto nel DB che il parametro attuale è custom o meno + EgtSetInfo(m_BTLFeatureM.nFeatureId, m_BTLParamM.sName & "A", If(value, "1", "")) + NotifyPropertyChanged(NameOf(bCustom)) + Exit While + End If + ParamIndex += 1 + End While + End If + End Set + End Property + + Public ReadOnly Property sBWType As String + Get + Return m_BTLParamM.sBWType + End Get + End Property + +#Region "CONSTRUCTOR" + + Sub New(BTLParamM As BTLParamM, BTLFeatureM As BTLFeatureM) + m_BTLParamM = BTLParamM + m_BTLFeatureM = BTLFeatureM + End Sub + + Sub New(BTLParamM As BTLParamM) + m_BTLParamM = BTLParamM + m_BTLFeatureM = Nothing + End Sub + +#End Region ' CONSTRUCTOR + + Friend Sub UpdateParamValue(dNewValue As Double, sNewValue As String, Optional bDraw As Boolean = True) + ' verifico se solido attivo + Dim bShowSolid As Boolean = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + ' Recupero i parametri attuali della feature + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + m_BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + ' se P + If m_BTLParamM.bIsP Then + ' modifico parametro cambiato con value + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + vPar(m_BTLParamM.nId - 1) = dNewValue + Case BTLParamType.STRING_ + sPar = sNewValue + End Select + Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(m_BTLFeatureM.nSelGRP, m_BTLFeatureM.nPRC, m_BTLFeatureM.nSelSIDE, m_BTLFeatureM.sDES, + m_BTLFeatureM.nPRID, m_BTLFeatureM.frFRAME, vPar, sPar, vParQ) + If bOK Then + Select Case m_BTLParamM.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + m_BTLParamM.dValue = dNewValue + NotifyPropertyChanged(NameOf(sValue)) + Case BTLParamType.STRING_ + m_BTLParamM.sValue = sNewValue + NotifyPropertyChanged(NameOf(sValue)) + End Select + Else + NotifyPropertyChanged(NameOf(sValue)) + End If + ' se Q + Else + For Ind = 0 To vParQ.Length() - 1 + If vParQ(Ind).StartsWith(m_BTLParamM.sName) Then + vParQ(Ind) = m_BTLParamM.sName & ":" & DoubleToString(dNewValue, 3) + End If + Next + Dim bOK As Boolean = m_BTLFeatureM.UpdateParams(m_BTLFeatureM.nSelGRP, m_BTLFeatureM.nPRC, m_BTLFeatureM.nSelSIDE, m_BTLFeatureM.sDES, + m_BTLFeatureM.nPRID, m_BTLFeatureM.frFRAME, vPar, sPar, vParQ) + + If bOK Then + m_BTLParamM.bCustom = True + ' se sono in ottimizzazione + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + ' setto nel progetto il fatto che il parametro attuale è custom o meno + EgtSetInfo(m_BTLFeatureM.nFeatureId, m_BTLParamM.sName & "A", If(bCustom, "1", "")) + NotifyPropertyChanged(NameOf(bCustom)) + End If + m_BTLParamM.dValue = dNewValue + ' modifica provvisoria per mancanza aggiornamento su freecontour + If m_BTLFeatureM.IsFreeContour Then + EgtSetInfo(m_BTLFeatureM.nFeatureId, sName, dNewValue) + End If + NotifyPropertyChanged(NameOf(dValue)) + Else + NotifyPropertyChanged(NameOf(dValue)) + End If + End If + + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + If bDraw Then EgtDraw() + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLViewModel/BTLPartVM.vb b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLPartVM.vb new file mode 100644 index 00000000..d6572253 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLPartVM.vb @@ -0,0 +1,2279 @@ +Imports System.Collections.ObjectModel +Imports EgtWPFLib5 +Imports EgtUILib +Imports EgtBEAMWALL.Core +Imports System.Collections.Specialized +Imports System.ComponentModel + +Public Class BTLPartVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private WithEvents m_BTLPartM As BTLPartM + Public ReadOnly Property BTLPartM As BTLPartM + Get + Return m_BTLPartM + End Get + End Property + Private m_BTLStructureM As BTLStructureM + + Public ReadOnly Property nPartId As Integer + Get + Return m_BTLPartM.nPartId + End Get + End Property + + Public Property nPROJ As Integer + Get + Return m_BTLPartM.nPROJ + End Get + Set(value As Integer) + m_BTLPartM.nPROJ = value + End Set + End Property + + Public Property nPDN As Integer + Get + Return m_BTLPartM.nPDN + End Get + Set(value As Integer) + m_BTLPartM.nPDN = value + End Set + End Property + + Public Property bDO As Boolean + Get + Return m_BTLPartM.bDO + End Get + Set(value As Boolean) + m_BTLPartM.bDO = value + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_DO, If(value, 1, 0)) + NotifyPropertyChanged(NameOf(Calc_BorderBrush)) + End Set + End Property + + Public Property sNAM As String + Get + Return m_BTLPartM.sNAM + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_NAM, value) Then + m_BTLPartM.sNAM = value + End If + NotifyPropertyChanged(NameOf(sNAM)) + End Set + End Property + + Private Function SetBtlLHW(dBtlL As Double, dBtlH As Double, dBtlW As Double) As Boolean + Dim OldSection As SectionXMaterial = Section + ' verifico se ci sono già copie in grezzi + Dim nDuploCount As Integer = 0 + If EgtDuploCount(m_BTLPartM.nPartId, nDuploCount) AndAlso nDuploCount > 0 Then + ' se modalità travi e trave + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + If dBtlW <> m_BTLPartM.dBtlW OrElse dBtlH <> m_BTLPartM.dBtlH OrElse dBtlL <> m_BTLPartM.dBtlL Then + ' se pezzo gia' in produzione + Dim DuploList As New List(Of Integer) + EgtDuploList(m_BTLPartM.nPartId, DuploList) + Dim bDuploInProduction As Boolean = False + For Each DuploId In DuploList + Dim nSwapItem As Integer = GDB_ID.NULL + Dim sSwapItem As String = String.Empty + EgtGetInfo(DuploId, "!LST", sSwapItem) + Dim LSTValues() As String = sSwapItem.Split(","c) + If Not IsNothing(LSTValues(LSTValues.Count - 1)) AndAlso Integer.TryParse(LSTValues(LSTValues.Count - 1), nSwapItem) AndAlso nSwapItem > 0 Then + Dim nMachgroupId As Integer = EgtGetParent(EgtGetParent(EgtGetParent(nSwapItem))) + If nMachgroupId = GDB_ID.NULL Then + EgtOutLog("Trovato Duplo Ghost") + Else + Dim MachGroupModel = Nothing + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjManagerVM) Then + MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(ProjectManagerVM.CurrProj.nProdId, nMachgroupId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(ProjectManagerVM.CurrProj.nProdId, nMachgroupId) + End If + If Not IsNothing(MachGroupModel) AndAlso MachGroupModel.State > ItemState.ND Then + bDuploInProduction = True + Exit For + End If + End If + End If + Next + If bDuploInProduction Then + MessageBox.Show("Impossible change dimension because already in production!", "", MessageBoxButton.OK, MessageBoxImage.Exclamation) + Return False + End If + ' lo impedisco + ' avviso che tutti i pezzi verranno tolti dai grezzi e chiedo di confermare + If MessageBox.Show(String.Format(EgtMsg(61851), nDuploCount), EgtMsg(15003), MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then + MyMachGroupPanelM.DuploSetToDelete(m_BTLPartM.nPartId) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then DeleteDuplo_OnlyProdPage(DuploList) + Else + ' reimposto vecchio valore + Return False + End If + End If + End If + End If + + ' verifico se solido attivo + Dim bShowSolid As Boolean = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + + If Not EgtBeamSetPartBox(dBtlL, dBtlH, dBtlW, False) Then Return False + + ' imposto modificato per copie + MyMachGroupPanelM.SetDuploModified(m_BTLPartM.nPartId) + ' ricalcolo tutte le feature contenute + UpdateFeatures() + ' setto part da ricalcolare + ResetCalcTotalPart() + m_BTLPartM.dBtlL = dBtlL + m_BTLPartM.dBtlH = dBtlH + m_BTLPartM.dBtlW = dBtlW + ' aggiorno sezioni + Map.refProjectVM.BTLStructureVM.UpdateSection(Section, OldSection) + ' eventualmente ripristino solido + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + EgtDraw() + + Return True + End Function + + Private Sub DeleteDuplo_OnlyProdPage(DuploList As List(Of Integer)) + For Each nDuploId In DuploList + ' recupero grezzo cui appartiene + Dim nRawPartId As Integer = MyMachGroupPanelM.DuploGetRawPart(nDuploId) + ' recupero gruppo di lavorazione + Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(nRawPartId)) + ' lo setto come corrente + EgtSetCurrMachGroup(nMachGroupId) + ' elimino pezzo copia + EgtRemovePartFromRawPart(nDuploId) + EgtErase(nDuploId) + ' recupero gruppo di lavorazione e trave dell'interfaccia + Dim BeamMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId) + If Not IsNothing(BeamMachGroup) Then + Dim Beam As PartVM = BeamMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nDuploId) + EgtSetCurrMachGroup(BeamMachGroup.Id) + Beam.DeletePart() + End If + ' reset necessario per poter ottenere nMachGroupId corretto + EgtResetCurrMachGroup() + ' aggiorno dati utilizzo barra + BeamMachGroup.UpdateUsage() + Next + ' aggiorno quantita' in prod + Dim BTLPart As BTLPartVM = CALCPanelVM.GetBTLPartVMFromBTLPartId(m_BTLPartM.nPartId) + BTLPart.RefreshPartInProd() + End Sub + + Private Function GetOrigFrameGroup(nPartId As Integer) As Integer + Dim nCOP As Integer = GDB_ID.NULL + Dim nBAS As Integer = GDB_ID.NULL + EgtGetInfo(nPartId, "!COP", nCOP) + EgtGetInfo(nPartId, "!BAS", nBAS) + If nCOP = GDB_ID.NULL Then + Return nBAS + Else + EgtGetInfo(nCOP, "!BAS", nBAS) + Return nBAS + End If + End Function + + Public Property sL As String + Get + Dim nOrigGroupId As Integer = nPartId + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso EgtBeamGetBuildingIsOn() AndAlso Map.refShowBeamPanelVM.bShowAll Then + nOrigGroupId = GetOrigFrameGroup(nPartId) + End If + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nOrigGroupId, frBeam) + If IsX(frBeam.VersX(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlL, 3) + ElseIf IsX(frBeam.VersY(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlH, 3) + Else + Return LenToString(m_BTLPartM.dBtlW, 3) + End If + End Get + Set(value As String) + Dim dVal As Double + If StringToLenAdv(value, dVal, True) Then + Dim dBtlL = m_BTLPartM.dBtlL + Dim dBtlW = m_BTLPartM.dBtlW + Dim dBtlH = m_BTLPartM.dBtlH + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsX(frBeam.VersX(), EPS_SMALL) Then + dBtlL = dVal + ElseIf IsX(frBeam.VersY(), EPS_SMALL) Then + dBtlH = dVal + Else + dBtlW = dVal + End If + SetBtlLHW(dBtlL, dBtlH, dBtlW) + End If + NotifyPropertyChanged(NameOf(sL)) + NotifyPropertyChanged(NameOf(sH)) + NotifyPropertyChanged(NameOf(sW)) + ResetCalcTotalPart() + End Set + End Property + Public ReadOnly Property dL As Double + Get + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsX(frBeam.VersX(), EPS_SMALL) Then + Return m_BTLPartM.dBtlL + ElseIf IsX(frBeam.VersY(), EPS_SMALL) Then + Return m_BTLPartM.dBtlH + Else + Return m_BTLPartM.dBtlW + End If + End Get + End Property + Public ReadOnly Property dBtlL As Double + Get + Return m_BTLPartM.dBtlL + End Get + End Property + + Public Property sW As String + Get + Dim nOrigGroupId As Integer = nPartId + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso EgtBeamGetBuildingIsOn() AndAlso Map.refShowBeamPanelVM.bShowAll Then + nOrigGroupId = GetOrigFrameGroup(nPartId) + End If + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nOrigGroupId, frBeam) + If IsY(frBeam.VersX(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlL, 3) + ElseIf IsY(frBeam.VersY(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlH, 3) + Else + Return LenToString(m_BTLPartM.dBtlW, 3) + End If + End Get + Set(value As String) + Dim dVal As Double + If StringToLenAdv(value, dVal, True) Then + Dim dBtlL = m_BTLPartM.dBtlL + Dim dBtlW = m_BTLPartM.dBtlW + Dim dBtlH = m_BTLPartM.dBtlH + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsY(frBeam.VersX(), EPS_SMALL) Then + dBtlL = dVal + ElseIf IsY(frBeam.VersY(), EPS_SMALL) Then + dBtlH = dVal + Else + dBtlW = dVal + End If + SetBtlLHW(dBtlL, dBtlH, dBtlW) + End If + NotifyPropertyChanged(NameOf(sL)) + NotifyPropertyChanged(NameOf(sH)) + NotifyPropertyChanged(NameOf(sW)) + ResetCalcTotalPart() + End Set + End Property + Public ReadOnly Property dW As Double + Get + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsY(frBeam.VersX(), EPS_SMALL) Then + Return m_BTLPartM.dBtlL + ElseIf IsY(frBeam.VersY(), EPS_SMALL) Then + Return m_BTLPartM.dBtlH + Else + Return m_BTLPartM.dBtlW + End If + End Get + End Property + Public ReadOnly Property dBtlW As Double + Get + Return m_BTLPartM.dBtlW + End Get + End Property + + Public Property sH As String + Get + Dim nOrigGroupId As Integer = nPartId + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso EgtBeamGetBuildingIsOn() AndAlso Map.refShowBeamPanelVM.bShowAll Then + nOrigGroupId = GetOrigFrameGroup(nPartId) + End If + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nOrigGroupId, frBeam) + If IsZ(frBeam.VersX(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlL, 3) + ElseIf IsZ(frBeam.VersY(), EPS_SMALL) Then + Return LenToString(m_BTLPartM.dBtlH, 3) + Else + Return LenToString(m_BTLPartM.dBtlW, 3) + End If + End Get + Set(value As String) + Dim dVal As Double + If StringToLenAdv(value, dVal, True) Then + Dim dBtlL = m_BTLPartM.dBtlL + Dim dBtlW = m_BTLPartM.dBtlW + Dim dBtlH = m_BTLPartM.dBtlH + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsZ(frBeam.VersX(), EPS_SMALL) Then + dBtlL = dVal + ElseIf IsZ(frBeam.VersY(), EPS_SMALL) Then + dBtlH = dVal + Else + dBtlW = dVal + End If + SetBtlLHW(dBtlL, dBtlH, dBtlW) + End If + NotifyPropertyChanged(NameOf(sL)) + NotifyPropertyChanged(NameOf(sH)) + NotifyPropertyChanged(NameOf(sW)) + ResetCalcTotalPart() + End Set + End Property + Public ReadOnly Property dH As Double + Get + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nPartId, frBeam) + If IsZ(frBeam.VersX(), EPS_SMALL) Then + Return m_BTLPartM.dBtlL + ElseIf IsZ(frBeam.VersY(), EPS_SMALL) Then + Return m_BTLPartM.dBtlH + Else + Return m_BTLPartM.dBtlW + End If + End Get + End Property + Public ReadOnly Property dBtlH As Double + Get + Return m_BTLPartM.dBtlH + End Get + End Property + +#Region "Parametri pezzo" + + Public Property nSINGLEMEMBERNUM As Integer + Get + Return m_BTLPartM.nSINGLEMEMBERNUM + End Get + Set(value As Integer) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_SINGLEMEMBERNUM, value) Then + m_BTLPartM.nSINGLEMEMBERNUM = value + Else + NotifyPropertyChanged(NameOf(nSINGLEMEMBERNUM)) + End If + End Set + End Property + + Public Property sASSEMBLYNUM As String + Get + Return m_BTLPartM.sASSEMBLYNUM + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ASSEMBLYNUM, value) Then + m_BTLPartM.sASSEMBLYNUM = value + Else + NotifyPropertyChanged(NameOf(sASSEMBLYNUM)) + End If + End Set + End Property + + Public Property nORDERNUM As Integer + Get + Return m_BTLPartM.nORDERNUM + End Get + Set(value As Integer) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ORDERNUM, value) Then + m_BTLPartM.nORDERNUM = value + Else + NotifyPropertyChanged(NameOf(nORDERNUM)) + End If + End Set + End Property + + Public Property sDESIGN As String + Get + Return m_BTLPartM.sDESIGN + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_DESIGNATION, value) Then + m_BTLPartM.sDESIGN = value + Else + NotifyPropertyChanged(NameOf(sDESIGN)) + End If + End Set + End Property + + Public Property sANNOT As String + Get + Return m_BTLPartM.sANNOT + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ANNOTATION, value) Then + m_BTLPartM.sANNOT = value + Else + NotifyPropertyChanged(NameOf(sANNOT)) + End If + End Set + End Property + + Public Property sSTOREY As String + Get + Return m_BTLPartM.sSTOREY + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_STOREY, value) Then + m_BTLPartM.sSTOREY = value + Else + NotifyPropertyChanged(NameOf(sSTOREY)) + End If + End Set + End Property + + Public Property sGROUP As String + Get + Return m_BTLPartM.sGROUP + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_GROUP, value) Then + m_BTLPartM.sGROUP = value + Else + NotifyPropertyChanged(NameOf(sGROUP)) + End If + End Set + End Property + + Public Property sPACKAGE As String + Get + Return m_BTLPartM.sPACKAGE + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_PACKAGE, value) Then + m_BTLPartM.sPACKAGE = value + Else + NotifyPropertyChanged(NameOf(sPACKAGE)) + End If + End Set + End Property + + Public Property sMATERIAL As String + Get + Return m_BTLPartM.sMATERIAL + End Get + Set(value As String) + If value <> m_BTLPartM.sMATERIAL Then + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_MATERIAL, value) Then + ' verifico se ci sono altri pezzi con la sezione vecchia + Dim bOtherSection As Boolean = Map.refProjectVM.BTLStructureVM.BTLPartVMList.Any(Function(x) x IsNot Me AndAlso x.Section = Section) + Dim OldSection As SectionXMaterial = Nothing + If Not bOtherSection Then + ' recupero indice + OldSection = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x = Section) + End If + m_BTLPartM.sMATERIAL = value + ' aggiorno sezione + If bOtherSection Then + ' se sezione nuova non presente + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(Section) Then + ' creo nuova sezione + Map.refProjectVM.BTLStructureVM.SectionList.Add(Section) + End If + Else + ' se sezione nuova gia' presente + If Map.refProjectVM.BTLStructureVM.SectionList.Contains(Section) Then + ' cancello sezione vecchia + Map.refProjectVM.BTLStructureVM.SectionList.Remove(OldSection) + Else + ' altrimenti la modifico + If Not IsNothing(OldSection) Then + OldSection.sMaterial.Clear() + OldSection.sMaterial.Add(sMATERIAL) + End If + End If + End If + End If + NotifyPropertyChanged(NameOf(sMATERIAL)) + End If + End Set + End Property + + Public Property sTIMBERGRADE As String + Get + Return m_BTLPartM.sTIMBERGRADE + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_TIMBERGRADE, value) Then + m_BTLPartM.sTIMBERGRADE = value + Else + NotifyPropertyChanged(NameOf(sTIMBERGRADE)) + End If + End Set + End Property + + Public Property sQUALITYGRADE As String + Get + Return m_BTLPartM.sQUALITYGRADE + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_QUALITYGRADE, value) Then + m_BTLPartM.sQUALITYGRADE = value + Else + NotifyPropertyChanged(NameOf(sQUALITYGRADE)) + End If + End Set + End Property + + Public ReadOnly Property PartColour As Brush + Get + Return New SolidColorBrush(Color.FromArgb(m_BTLPartM.colCOLOR.ToColor().A, + CByte(m_BTLPartM.colCOLOR.R), + CByte(m_BTLPartM.colCOLOR.G), + CByte(m_BTLPartM.colCOLOR.B))) + End Get + End Property + + Public Property sCOLRGB As String + Get + Return m_BTLPartM.colCOLOR.R & "," & + m_BTLPartM.colCOLOR.G & "," & + m_BTLPartM.colCOLOR.B & "," & + nCOLA + End Get + Set(value As String) + Dim sValArray() As String = value.Split(",") + If sValArray.Count() >= 4 Then + m_BTLPartM.m_colCOLOR.R = Color3d.Clamp(sValArray(0), 0, 255) + m_BTLPartM.m_colCOLOR.G = Color3d.Clamp(sValArray(1), 0, 255) + m_BTLPartM.m_colCOLOR.B = Color3d.Clamp(sValArray(2), 0, 255) + m_BTLPartM.m_colCOLOR.A = Color3d.Clamp(nCOLA, 0, 100) + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_COLOUR, m_BTLPartM.colCOLOR.ToString()) + Else + NotifyPropertyChanged(NameOf(sCOLRGB)) + End If + End Set + End Property + + Public Property nCOLA As Integer + Get + Return m_BTLPartM.colCOLOR.A + End Get + Set(value As Integer) + If m_BTLPartM.colCOLOR.A <> value Then + m_BTLPartM.m_colCOLOR.A = Color3d.Clamp(value, 0, 100) + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_COLOUR, m_BTLPartM.colCOLOR.ToString()) + NotifyPropertyChanged(NameOf(nCOLA)) + NotifyPropertyChanged(NameOf(PartColour)) + End If + End Set + End Property + + Public Property dPLANINGLEN As String + Get + Return LenToString(m_BTLPartM.dPLANINGLEN, 3) + End Get + Set(value As String) + Dim dTempPlaningLen As Double + If StringToLenAdv(value, dTempPlaningLen, True) AndAlso EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_PLANINGLENGTH, dTempPlaningLen) Then + m_BTLPartM.dPLANINGLEN = dTempPlaningLen + Else + NotifyPropertyChanged(NameOf(dPLANINGLEN)) + End If + End Set + End Property + + Public Property dSTARTOFFSET As String + Get + Return LenToString(m_BTLPartM.dSTARTOFFSET, 3) + End Get + Set(value As String) + Dim dTempStartOffset As Double + If StringToLenAdv(value, dTempStartOffset, True) AndAlso EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_STARTOFFSET, dTempStartOffset) Then + m_BTLPartM.dSTARTOFFSET = dTempStartOffset + Else + NotifyPropertyChanged(NameOf(dSTARTOFFSET)) + End If + End Set + End Property + + Public Property dENDOFFSET As String + Get + Return LenToString(m_BTLPartM.dENDOFFSET, 3) + End Get + Set(value As String) + Dim dTempEndOffset As Double + If StringToLenAdv(value, dTempEndOffset, True) AndAlso EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ENDOFFSET, dTempEndOffset) Then + m_BTLPartM.dENDOFFSET = dTempEndOffset + Else + NotifyPropertyChanged(NameOf(dENDOFFSET)) + End If + End Set + End Property + + Public ReadOnly Property ocUID As ObservableCollection(Of Integer) + Get + Return m_BTLPartM.ocUID + End Get + End Property + + Public Property SelUID As Integer + Get + Return m_BTLPartM.SelUID + End Get + Set(value As Integer) + If m_BTLPartM.SelUID <> value Then + m_BTLPartM.m_refTransf = m_BTLPartM.refTransfList(value) + m_BTLPartM.SelUID = value + NotifyPropertyChanged(NameOf(TransfOrig)) + NotifyPropertyChanged(NameOf(TransfVersX)) + NotifyPropertyChanged(NameOf(TransfVersY)) + Else + NotifyPropertyChanged(NameOf(SelUID)) + End If + End Set + End Property + + Public Property TransfOrig As String + Get + If SelUID >= 0 AndAlso + SelUID < m_BTLPartM.refTransfList.Count AndAlso + Not IsNothing(m_BTLPartM.refTransfList(SelUID)) Then + Return LenToString(m_BTLPartM.refTransfList(SelUID).Orig().x, 3) & "," & + LenToString(m_BTLPartM.refTransfList(SelUID).Orig().y, 3) & "," & + LenToString(m_BTLPartM.refTransfList(SelUID).Orig().z, 3) + Else + Return Nothing + End If + End Get + Set(value As String) + Dim sValArray() As String = value.Split(",") + Dim ptOri As New Point3d + If sValArray.Count() >= 3 AndAlso + StringToLenAdv(sValArray(0), ptOri.x, True) AndAlso + StringToLenAdv(sValArray(1), ptOri.y, True) AndAlso + StringToLenAdv(sValArray(2), ptOri.z, True) AndAlso + m_BTLPartM.refTransf.ChangeOrigin(ptOri) Then + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_TRANSFORMATION & (SelUID + 1), LenToString(m_BTLPartM.refTransf.Orig.x, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.y, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.z, 3) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.z, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.z, 6)) + Else + NotifyPropertyChanged(NameOf(TransfOrig)) + End If + End Set + End Property + Public Property TransfVersX As String + Get + If SelUID >= 0 AndAlso + SelUID < m_BTLPartM.refTransfList.Count AndAlso + Not IsNothing(m_BTLPartM.refTransfList(SelUID)) Then + Return DoubleToString(m_BTLPartM.refTransfList(SelUID).VersX().x, 6) & "," & + DoubleToString(m_BTLPartM.refTransfList(SelUID).VersX().y, 6) & "," & + DoubleToString(m_BTLPartM.refTransfList(SelUID).VersX().z, 6) + Else + Return Nothing + End If + End Get + Set(value As String) + Dim ptOri As New Point3d(m_BTLPartM.refTransf.Orig()) + Dim vtVersY As New Vector3d(m_BTLPartM.refTransf.VersY()) + Dim sValArray() As String = value.Split(",") + Dim vtVersX As New Vector3d + If sValArray.Count() >= 3 AndAlso + StringToDoubleAdv(sValArray(0), vtVersX.x, True) AndAlso + StringToDoubleAdv(sValArray(1), vtVersX.y, True) AndAlso + StringToDoubleAdv(sValArray(2), vtVersX.z, True) AndAlso + m_BTLPartM.refTransf.Setup(ptOri, ptOri + vtVersX, ptOri + vtVersY) Then + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_TRANSFORMATION & (SelUID + 1), LenToString(m_BTLPartM.refTransf.Orig.x, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.y, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.z, 3) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.z, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.z, 6)) + NotifyPropertyChanged(NameOf(TransfVersX)) + NotifyPropertyChanged(NameOf(TransfVersY)) + Else + NotifyPropertyChanged(NameOf(TransfVersX)) + End If + End Set + End Property + Public Property TransfVersY As String + Get + If SelUID >= 0 AndAlso + SelUID < m_BTLPartM.refTransfList.Count AndAlso + Not IsNothing(m_BTLPartM.refTransfList(SelUID)) Then + Return DoubleToString(m_BTLPartM.refTransfList(SelUID).VersY().x, 6) & "," & + DoubleToString(m_BTLPartM.refTransfList(SelUID).VersY().y, 6) & "," & + DoubleToString(m_BTLPartM.refTransfList(SelUID).VersY().z, 6) + Else + Return Nothing + End If + End Get + Set(value As String) + Dim ptOri As New Point3d(m_BTLPartM.refTransf.Orig()) + Dim vtVersX As New Vector3d(m_BTLPartM.refTransf.VersX()) + Dim sValArray() As String = value.Split(",") + Dim vtVersY As New Vector3d + If sValArray.Count() >= 3 AndAlso + StringToDoubleAdv(sValArray(0), vtVersY.x, True) AndAlso + StringToDoubleAdv(sValArray(1), vtVersY.y, True) AndAlso + StringToDoubleAdv(sValArray(2), vtVersY.z, True) AndAlso + m_BTLPartM.refTransf.Setup(ptOri, ptOri + vtVersX, ptOri + vtVersY) Then + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_TRANSFORMATION & (SelUID + 1), LenToString(m_BTLPartM.refTransf.Orig.x, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.y, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.z, 3) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.z, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.z, 6)) + NotifyPropertyChanged(NameOf(TransfVersX)) + NotifyPropertyChanged(NameOf(TransfVersY)) + Else + NotifyPropertyChanged(NameOf(TransfVersY)) + End If + End Set + End Property + + Public ReadOnly Property ocCAMBERSIDE As ObservableCollection(Of Integer) + Get + Return m_BTLPartM.ocCAMBERSIDE + End Get + End Property + + Public Property SelCAMBERSIDE As Integer + Get + Return m_BTLPartM.SelCAMBERSIDE + End Get + Set(value As Integer) + Dim sValArray() As String = CamberParams.Split(",") + If sValArray.Count() >= 4 AndAlso + StringToLenAdv(sValArray(0), m_BTLPartM.m_dCamberLen1, True) AndAlso + StringToLenAdv(sValArray(1), m_BTLPartM.m_dCamberLen2, True) AndAlso + StringToLenAdv(sValArray(2), m_BTLPartM.m_dCamberLen3, True) AndAlso + StringToLenAdv(sValArray(3), m_BTLPartM.m_dCamberCross3, True) AndAlso + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_CAMBER, "SIDE: " & (value + 1) & + " P01: " & sValArray(0) & + " P02: " & sValArray(1) & + " P03: " & sValArray(2) & + " P04: " & sValArray(3)) Then + m_BTLPartM.SelCAMBERSIDE = value + Else + NotifyPropertyChanged(NameOf(SelCAMBERSIDE)) + End If + End Set + End Property + + Public Property CamberParams As String + Get + Return LenToString(m_BTLPartM.m_dCamberLen1, 3) & "," & + LenToString(m_BTLPartM.m_dCamberLen2, 3) & "," & + LenToString(m_BTLPartM.m_dCamberLen3, 3) & "," & + LenToString(m_BTLPartM.m_dCamberCross3, 3) + End Get + Set(value As String) + Dim sValArray() As String = value.Split(",") + If sValArray.Count() >= 4 AndAlso + StringToLenAdv(sValArray(0), m_BTLPartM.m_dCamberLen1, True) AndAlso + StringToLenAdv(sValArray(1), m_BTLPartM.m_dCamberLen2, True) AndAlso + StringToLenAdv(sValArray(2), m_BTLPartM.m_dCamberLen3, True) AndAlso + StringToLenAdv(sValArray(3), m_BTLPartM.m_dCamberCross3, True) Then + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_CAMBER, " SIDE: " & (SelCAMBERSIDE + 1) & + " P01: " & sValArray(0) & + " P02: " & sValArray(1) & + " P03: " & sValArray(2) & + " P04: " & sValArray(3)) + Else + NotifyPropertyChanged(NameOf(CamberParams)) + End If + End Set + End Property + + Public ReadOnly Property ocREFSIDEFIXCLAMP As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocREFSIDEFIXCLAMP + End Get + End Property + + Public Property SelREFSIDEFIXCLAMP As Integer + Get + Return m_BTLPartM.SelREFSIDEFIXCLAMP + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocREFSIDEFIXCLAMP) + Dim sValue As String = ocREFSIDEFIXCLAMP(nValue).Name '[Enum].GetName(GetType(PartOffset_RefSideFixClamp), nValue) + + Dim sValArray() As String = PartOffsetParams.Split(",") + If sValArray.Count() >= 4 AndAlso + StringToLenAdv(sValArray(0), m_BTLPartM.m_dPartOffsetSide1, True) AndAlso + StringToLenAdv(sValArray(1), m_BTLPartM.m_dPartOffsetSide2, True) AndAlso + StringToLenAdv(sValArray(2), m_BTLPartM.m_dPartOffsetSide3, True) AndAlso + StringToLenAdv(sValArray(3), m_BTLPartM.m_dPartOffsetSide4, True) AndAlso + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_PARTOFFSET, " P04: " & sValue & + " P11: " & sValArray(0) & + " P12: " & sValArray(1) & + " P13: " & sValArray(2) & + " P14: " & sValArray(3)) Then + m_BTLPartM.SelREFSIDEFIXCLAMP = value + Else + NotifyPropertyChanged(NameOf(SelREFSIDEFIXCLAMP)) + End If + End Set + End Property + + Public Property PartOffsetParams As String + Get + Return LenToString(m_BTLPartM.m_dPartOffsetSide1, 3) & "," & + LenToString(m_BTLPartM.m_dPartOffsetSide2, 3) & "," & + LenToString(m_BTLPartM.m_dPartOffsetSide3, 3) & "," & + LenToString(m_BTLPartM.m_dPartOffsetSide4, 3) + End Get + Set(value As String) + Dim nValue As Integer = IdNameStruct.IdFromInd(SelREFSIDEFIXCLAMP, ocREFSIDEFIXCLAMP) + Dim sValue As String = ocREFSIDEFIXCLAMP(nValue).Name '[Enum].GetName(GetType(PartOffset_RefSideFixClamp), nValue) + + Dim sValArray() As String = value.Split(",") + If sValArray.Count() >= 4 AndAlso + StringToLenAdv(sValArray(0), m_BTLPartM.m_dPartOffsetSide1, True) AndAlso + StringToLenAdv(sValArray(1), m_BTLPartM.m_dPartOffsetSide2, True) AndAlso + StringToLenAdv(sValArray(2), m_BTLPartM.m_dPartOffsetSide3, True) AndAlso + StringToLenAdv(sValArray(3), m_BTLPartM.m_dPartOffsetSide4, True) Then + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_PARTOFFSET, " P04: " & sValue & + " P11: " & sValArray(0) & + " P12: " & sValArray(1) & + " P13: " & sValArray(2) & + " P14: " & sValArray(3)) + Else + NotifyPropertyChanged(NameOf(PartOffsetParams)) + End If + End Set + End Property + + Public ReadOnly Property ocPROCESSINGQUALITY As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocPROCESSINGQUALITY + End Get + End Property + + Public Property SelPROCESSINGQUALITY As Integer + Get + Return m_BTLPartM.SelPROCESSINGQUALITY + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocPROCESSINGQUALITY) + Dim sValue As String = [Enum].GetName(GetType(ProcessingQuality), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_PROCESSINGQUALITY, sValue) Then + m_BTLPartM.SelPROCESSINGQUALITY = value + Else + NotifyPropertyChanged(NameOf(SelPROCESSINGQUALITY)) + End If + End Set + End Property + + Public ReadOnly Property ocRECESS As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocRECESS + End Get + End Property + + Public Property SelRECESS As Integer + Get + Return m_BTLPartM.SelRECESS + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocRECESS) + Dim sValue As String = [Enum].GetName(GetType(Recess), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_RECESS, sValue) Then + m_BTLPartM.SelRECESS = value + Else + NotifyPropertyChanged(NameOf(SelRECESS)) + End If + End Set + End Property + + Public ReadOnly Property ocSTOREYTYPE As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocSTOREYTYPE + End Get + End Property + + Public Property SelSTOREYTYPE As Integer + Get + Return m_BTLPartM.SelSTOREYTYPE + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocSTOREYTYPE) + Dim sValue As String = [Enum].GetName(GetType(StoreyType), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_STOREYTYPE, sValue) Then + m_BTLPartM.SelSTOREYTYPE = value + Else + NotifyPropertyChanged(NameOf(SelSTOREYTYPE)) + End If + End Set + End Property + + Public Property sELEMENTNUM As String + Get + Return m_BTLPartM.sELEMENTNUM + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ELEMENTNUM, value) Then + m_BTLPartM.sELEMENTNUM = value + Else + NotifyPropertyChanged(NameOf(sELEMENTNUM)) + End If + End Set + End Property + + Public Property nLAYER As Integer + Get + Return m_BTLPartM.nLAYER + End Get + Set(value As Integer) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_LAYER, value) Then + m_BTLPartM.nLAYER = value + Else + NotifyPropertyChanged(NameOf(nLAYER)) + End If + End Set + End Property + + Public Property sMODULENUM As String + Get + Return m_BTLPartM.sMODULENUM + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_MODULENUM, value) Then + m_BTLPartM.sMODULENUM = value + Else + NotifyPropertyChanged(NameOf(sMODULENUM)) + End If + End Set + End Property + + Public Property sCOMMENT As String + Get + Return m_BTLPartM.sCOMMENT + End Get + Set(value As String) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_COMMENT, value) Then + m_BTLPartM.sCOMMENT = value + Else + NotifyPropertyChanged(NameOf(sCOMMENT)) + End If + End Set + End Property + + Public Property GrainDirection As String + Get + Return DoubleToString(m_BTLPartM.refGrainDir.x, 6) & "," & + DoubleToString(m_BTLPartM.refGrainDir.y, 6) & "," & + DoubleToString(m_BTLPartM.refGrainDir.z, 6) + End Get + Set(value As String) + Dim sValArray() As String = value.Split(",") + Dim dX, dY, dZ As Double + If sValArray.Count() >= 3 AndAlso + StringToDoubleAdv(sValArray(0), dX, True) AndAlso + StringToDoubleAdv(sValArray(1), dY, True) AndAlso + StringToDoubleAdv(sValArray(2), dZ, True) Then + m_BTLPartM.refGrainDir = New Vector3d(dX, dY, dZ) + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_GRAINDIR, sValArray(0) & "," & + sValArray(1) & "," & + sValArray(2) & ";" & + If(bGRAINDIRALIGN, 1, 0)) + Else + NotifyPropertyChanged(NameOf(GrainDirection)) + End If + End Set + End Property + + Public Property bGRAINDIRALIGN As Boolean + Get + Return m_BTLPartM.bGRAINDIRALIGN + End Get + Set(value As Boolean) + Dim sValArray() As String = GrainDirection.Split(",") + If sValArray.Count() >= 3 AndAlso + StringToDoubleAdv(sValArray(0), m_BTLPartM.refGrainDir.x, True) AndAlso + StringToDoubleAdv(sValArray(1), m_BTLPartM.refGrainDir.y, True) AndAlso + StringToDoubleAdv(sValArray(2), m_BTLPartM.refGrainDir.z, True) AndAlso + EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_GRAINDIR, sValArray(0) & "," & + sValArray(1) & "," & + sValArray(2) & ";" & + If(value, 1, 0)) Then + m_BTLPartM.bGRAINDIRALIGN = value + NotifyPropertyChanged(NameOf(bGRAINDIRALIGN)) + End If + End Set + End Property + + Public ReadOnly Property ocREFSIDE As ObservableCollection(Of Integer) + Get + Return m_BTLPartM.ocREFSIDE + End Get + End Property + + Public Property SelREFSIDE As Integer + Get + Return m_BTLPartM.SelREFSIDE + End Get + Set(value As Integer) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_REFSIDE, (value + 1) & ";" & If(bREFSIDEALIGN, 1, 0)) Then + m_BTLPartM.SelREFSIDE = value + Else + NotifyPropertyChanged(NameOf(SelREFSIDE)) + End If + End Set + End Property + + Public Property bREFSIDEALIGN As Boolean + Get + Return m_BTLPartM.bREFSIDEALIGN + End Get + Set(value As Boolean) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_REFSIDE, (SelREFSIDE + 1) & ";" & If(value, 1, 0)) Then + m_BTLPartM.bREFSIDEALIGN = value + NotifyPropertyChanged(NameOf(bREFSIDEALIGN)) + End If + End Set + End Property + + Public ReadOnly Property ocALIGNLOCATION As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocALIGNLOCATION + End Get + End Property + + Public Property SelALIGNLOCATION As Integer + Get + Return m_BTLPartM.SelALIGNLOCATION + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocALIGNLOCATION) + Dim sValueLoc As String = [Enum].GetName(GetType(AlignmentLocation), nValue) + nValue = IdNameStruct.IdFromInd(SelALIGNENDTYPE, ocALIGNENDTYPE) + Dim sValueEnd As String = [Enum].GetName(GetType(AlignmentEndtype), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ALIGNMENT, sValueLoc & ": " & sValueEnd) Then + m_BTLPartM.SelALIGNLOCATION = value + Else + NotifyPropertyChanged(NameOf(SelALIGNLOCATION)) + End If + End Set + End Property + + Public ReadOnly Property ocALIGNENDTYPE As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocALIGNENDTYPE + End Get + End Property + + Public Property SelALIGNENDTYPE As Integer + Get + Return m_BTLPartM.SelALIGNENDTYPE + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(SelALIGNLOCATION, ocALIGNLOCATION) + Dim sValueLoc As String = [Enum].GetName(GetType(AlignmentLocation), nValue) + nValue = IdNameStruct.IdFromInd(value, ocALIGNENDTYPE) + Dim sValueEnd As String = [Enum].GetName(GetType(AlignmentEndtype), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_ALIGNMENT, sValueLoc & ": " & sValueEnd) Then + m_BTLPartM.SelALIGNENDTYPE = value + Else + NotifyPropertyChanged(NameOf(SelALIGNENDTYPE)) + End If + End Set + End Property + + Public ReadOnly Property ocMATERIALTYPEGRP As ObservableCollection(Of Object) + Get + Return m_BTLPartM.ocMATERIALTYPEGRP + End Get + End Property + + Public Property SelMATERIALTYPEGRP As Integer + Get + Return m_BTLPartM.SelMATERIALTYPEGRP + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, ocMATERIALTYPEGRP) + Dim sValue As String = ocMATERIALTYPEGRP(nValue).Name '[Enum].GetName(GetType(MaterialType), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_MATERIALTYPE, sValue & ": " & sMATERIALTYPESPEC) Then + m_BTLPartM.SelMATERIALTYPEGRP = value + Else + NotifyPropertyChanged(NameOf(SelMATERIALTYPEGRP)) + End If + End Set + End Property + + Public Property sMATERIALTYPESPEC As String + Get + Return m_BTLPartM.sMATERIALTYPESPEC + End Get + Set(value As String) + Dim nValue As Integer = IdNameStruct.IdFromInd(SelMATERIALTYPEGRP, ocMATERIALTYPEGRP) + Dim sValue As String = ocMATERIALTYPEGRP(nValue).Name '[Enum].GetName(GetType(MaterialType), nValue) + If EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_MATERIALTYPE, sValue & ": " & value) Then + m_BTLPartM.sMATERIALTYPESPEC = value + Else + NotifyPropertyChanged(NameOf(sMATERIALTYPESPEC)) + End If + End Set + End Property + +#End Region ' Parametri pezzo + + Public Property sCNT As String + Get + Return m_BTLPartM.nCNT + End Get + Set(value As String) + Dim nTempCNT As Integer + If Integer.TryParse(value, nTempCNT) AndAlso nTempCNT > 0 AndAlso EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_CNT, value) Then + m_BTLPartM.nCNT = nTempCNT + End If + NotifyPropertyChanged(NameOf(sCNT)) + End Set + End Property + Public ReadOnly Property nCNT As Integer + Get + Return m_BTLPartM.nCNT + End Get + End Property + + Public Property sADDED As String + Get + Return m_BTLPartM.nADDED + End Get + Set(value As String) + Dim nTempADDED As Integer + ' verificare che non venga inserito unn numero minore di quelli gia' in prod!!!!! e dare messagio!!! + If Integer.TryParse(value, nTempADDED) AndAlso nTempADDED >= 0 Then + If nTempADDED >= nINPROD Then + m_BTLPartM.nADDED = nTempADDED + Else + MessageBox.Show(EgtMsg(61857), "", MessageBoxButton.OK, MessageBoxImage.Warning) + End If + End If + NotifyPropertyChanged(NameOf(sADDED)) + End Set + End Property + Public ReadOnly Property nADDED As Integer + Get + Return m_BTLPartM.nADDED + End Get + End Property + + Public ReadOnly Property nINPROD As Integer + Get + Dim nTotInProd As Integer = m_BTLPartM.nINPROD + ' recupero numero di scrap + Dim nProjId As Integer = GDB_ID.NULL + EgtGetInfo(nPartId, PROJ, nProjId) + Dim nScrapCnt As Integer = DbControllers.m_ProjController.getCountItemState(nProjId, nPartId, ItemState.Scrapped) + If nScrapCnt > 0 Then nTotInProd -= nScrapCnt + Return nTotInProd + End Get + End Property + Public ReadOnly Property Foreground As SolidColorBrush + Get + Return If(nINPROD = nCNT + nADDED, Brushes.Green, Brushes.Black) + End Get + End Property + Public ReadOnly Property FontWeight As FontWeight + Get + Return If(nINPROD = nCNT + nADDED, FontWeights.Bold, FontWeights.Normal) + End Get + End Property + + Public Property nDONE As Integer + Get + Dim nTotDone As Integer = 0 + ' recupero pezzi lavorati da Db + Dim nProjId As Integer = GDB_ID.NULL + EgtGetInfo(nPartId, PROJ, nProjId) + Dim nDoneCnt As Integer = DbControllers.m_ProjController.getCountItemState(nProjId, nPartId, ItemState.Produced) + Return nDoneCnt + End Get + Set(value As Integer) + Dim nTempDONE As Integer + If Integer.TryParse(value, nTempDONE) AndAlso nTempDONE > 0 AndAlso EgtSetInfo(m_BTLPartM.nPartId, BTL_PRT_DONE, value) Then + m_BTLPartM.nDONE = nTempDONE + End If + NotifyPropertyChanged(NameOf(nDONE)) + End Set + End Property + + Public ReadOnly Property Background As SolidColorBrush + Get + If nDONE = nCNT + nADDED Then + Return Brushes.Yellow + ElseIf nDONE > 0 AndAlso nDONE < nCNT + nADDED Then + Return Brushes.Orange + Else + Return Brushes.White + End If + End Get + End Property + + Public ReadOnly Property sINVERTED As String + Get + Return m_BTLPartM.nINVERTED & "°" + End Get + End Property + + Public ReadOnly Property nINVERTED As Integer + Get + Return m_BTLPartM.nINVERTED + End Get + End Property + + Public Property bLockInversion As Boolean + Get + Return m_BTLPartM.bLockInversion + End Get + Set(value As Boolean) + If EgtSetInfo(nPartId, LOCK_FLIP, value) Then + m_BTLPartM.bLockInversion = value + NotifyPropertyChanged(NameOf(bLockInversion)) + End If + End Set + End Property + + Public ReadOnly Property sROTATED As String + Get + Return m_BTLPartM.nROTATED & "°" + End Get + End Property + + Public ReadOnly Property nROTATED As Integer + Get + Return m_BTLPartM.nROTATED + End Get + End Property + + Public Property bLockRotation As Boolean + Get + Return m_BTLPartM.bLockRotation + End Get + Set(value As Boolean) + If EgtSetInfo(nPartId, LOCK_ROT, value) Then + m_BTLPartM.bLockRotation = value + NotifyPropertyChanged(NameOf(bLockRotation)) + End If + End Set + End Property + + Public ReadOnly Property nCALC_ERR As Integer + Get + Return m_BTLPartM.nCALC_ERR + End Get + End Property + + Public ReadOnly Property nCALC_FALL As Integer + Get + Return m_BTLPartM.nCALC_FALL + End Get + End Property + + Public ReadOnly Property sCALC_MSG As String + Get + NotifyPropertyChanged(NameOf(CALC_MSG_Visibility)) + Return m_BTLPartM.sCALC_MSG + End Get + End Property + + Public Property nCALC_ROT As Integer + Get + Return m_BTLPartM.nCALC_ROT + End Get + Set(value As Integer) + m_BTLPartM.nCALC_ROT = value + End Set + End Property + + Public Property nCALC_TIME As Integer + Get + Return m_BTLPartM.nCALC_TIME + End Get + Set(value As Integer) + m_BTLPartM.nCALC_TIME = value + End Set + End Property + + Public Property nGlobalState As CalcStates + Get + Return m_BTLPartM.nGlobalState + End Get + Set(value As CalcStates) + m_BTLPartM.nGlobalState = value + End Set + End Property + + Public ReadOnly Property nFeaturesGlobalState As CalcStates + Get + Return m_BTLPartM.nFeaturesGlobalState + End Get + End Property + + Public Property nState As CalcStates + Get + Return m_BTLPartM.nState + End Get + Set(value As CalcStates) + m_BTLPartM.nState = value + End Set + End Property + + Public ReadOnly Property Calc_BorderBrush As SolidColorBrush + Get + If Not m_BTLPartM.bDO Then Return Brushes.Aqua + Select Case m_BTLPartM.nGlobalState + Case CalcStates.ERROR_, CalcStates.COLLISION + Return Brushes.Red + Case CalcStates.WARNING + Return Brushes.Orange + Case CalcStates.INFO, CalcStates.OK + Return Brushes.Green + Case CalcStates.NOTCALCULATED + Return Brushes.LightGray + Case Else + Return Brushes.Red + End Select + End Get + End Property + + Public ReadOnly Property CALC_ROT_Visibility As Visibility + Get + Return If(m_BTLPartM.nCALC_ROT <> 0, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property CALC_FALL_Visibility As Visibility + Get + Return If(m_BTLPartM.nCALC_FALL <> 0, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property CALC_ERR_Letter As String + Get + Select Case m_BTLPartM.m_nGlobalState + Case CalcStates.COLLISION + Return "c" + Case CalcStates.ERROR_ + Return "e" + Case CalcStates.WARNING + Return "w" + Case CalcStates.INFO + Return "i" + Case Else + Return "" + End Select + End Get + End Property + + Public ReadOnly Property CALC_ERR_Foreground As SolidColorBrush + Get + Select Case m_BTLPartM.m_nGlobalState + Case CalcStates.ERROR_, CalcStates.COLLISION + Return Brushes.Red + Case CalcStates.WARNING + Return Brushes.Orange + Case CalcStates.INFO + Return Brushes.Green + Case Else + Return Brushes.Red + End Select + End Get + End Property + + Public ReadOnly Property CALC_MSG_Visibility As Visibility + Get + Return If(String.IsNullOrWhiteSpace(m_BTLPartM.sCALC_MSG), Visibility.Collapsed, Visibility.Visible) + End Get + End Property + + Public ReadOnly Property Section As SectionXMaterial + Get + Dim nOrigGroupId As Integer = nPartId + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso EgtBeamGetBuildingIsOn() AndAlso Map.refShowBeamPanelVM.bShowAll Then + nOrigGroupId = GetOrigFrameGroup(nPartId) + End If + Dim frBeam As New Frame3d + EgtGetGroupGlobFrame(nOrigGroupId, frBeam) + Dim dL As Double + If IsX(frBeam.VersX(), EPS_SMALL) Then + dL = m_BTLPartM.dBtlL + ElseIf IsX(frBeam.VersY(), EPS_SMALL) Then + dL = m_BTLPartM.dBtlH + Else + dL = m_BTLPartM.dBtlW + End If + Dim dW As Double + If IsY(frBeam.VersX(), EPS_SMALL) Then + dW = m_BTLPartM.dBtlL + ElseIf IsY(frBeam.VersY(), EPS_SMALL) Then + dW = m_BTLPartM.dBtlH + Else + dW = m_BTLPartM.dBtlW + End If + Dim dH As Double + If IsZ(frBeam.VersX(), EPS_SMALL) Then + dH = m_BTLPartM.dBtlL + ElseIf IsZ(frBeam.VersY(), EPS_SMALL) Then + dH = m_BTLPartM.dBtlH + Else + dH = m_BTLPartM.dBtlW + End If + Return New SectionXMaterial(dW, dH, dL, m_BTLPartM.sMATERIAL) + End Get + End Property + + Public Property dUnitVolume As Double + Get + Return BTLPartM.dVolume + End Get + Set(value As Double) + If EgtSetInfo(nPartId, BTL_PRT_VOLUME, value) Then + m_BTLPartM.dVolume = value + Else + NotifyPropertyChanged(NameOf(dUnitVolume)) + End If + End Set + End Property + + Public ReadOnly Property sUnitVolume As String + Get + Return If(EgtUiUnitsAreMM(), DoubleToString(dUnitVolume / 1000000000, 3), DoubleToString(dUnitVolume * (12 / ONEINCH), 3)) + End Get + End Property + + Public ReadOnly Property sTotVolume As String + Get + Return If(EgtUiUnitsAreMM(), DoubleToString(dUnitVolume * (nCNT + nADDED) / 1000000000, 3), DoubleToString(dUnitVolume * (12 / ONEINCH) * nCNT, 3)) + End Get + End Property + + Public ReadOnly Property sUnitTime As String + Get + Return TimeSpan.FromSeconds(nCALC_TIME).ToString() + End Get + End Property + + Public ReadOnly Property sTotTime As String + Get + Return TimeSpan.FromSeconds(nCALC_TIME * (nCNT + nADDED)).ToString() + End Get + End Property + + Public Property bDOALL As Boolean? + Get + If BTLFeatureVMList.Count = 0 Then Return False + Dim bTemp As Boolean = BTLFeatureVMList(0).bDO + For FeatureIndex = 1 To BTLFeatureVMList.Count - 1 + If BTLFeatureVMList(FeatureIndex).bDO <> bTemp Then Return Nothing + Next + Return bTemp + End Get + Set(value As Boolean?) + If BTLFeatureVMList.Count = 0 Then + NotifyPropertyChanged(NameOf(bDOALL)) + Return + End If + ' imposto modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = True + For FeatureIndex = 0 To BTLFeatureVMList.Count - 1 + If FeatureIndex = BTLFeatureVMList.Count - 1 Then + ' reset modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = False + End If + Dim Feature As BTLFeatureVM = BTLFeatureVMList(FeatureIndex) + Feature.bDO = value + Next + End Set + End Property + + ' lista delle feature del pezzo + Private m_BTLFeatureVMList_ViewSource As CollectionViewSource = Nothing + Private m_BTLFeatureVMList_View As ListCollectionView = Nothing + Public m_BTLFeatureVMList As ObservableCollection(Of BTLFeatureVM) + Public Property BTLFeatureVMList As ObservableCollection(Of BTLFeatureVM) + Get + Return m_BTLFeatureVMList + End Get + Set(value As ObservableCollection(Of BTLFeatureVM)) + m_BTLFeatureVMList = value + End Set + End Property + Public ReadOnly Property BTLFeatureVMList_View As ListCollectionView + Get + Return m_BTLFeatureVMList_View + End Get + End Property + + Public m_SelBTLFeatureVM As BTLFeatureVM + Public Property SelBTLFeatureVM As BTLFeatureVM + Get + Return m_SelBTLFeatureVM + End Get + Set(value As BTLFeatureVM) + m_SelBTLFeatureVM = value + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART) Then + If Not IsNothing(m_SelBTLFeatureVM) Then + DirectCast(m_SelBTLFeatureVM, BTLFeatureVM).SelGeomFeature() + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + ' imposto path disegno da mostrare in BottomPanel + Map.refBottomPanelVM.SetCurrDraw(DirectCast(m_SelBTLFeatureVM, BTLFeatureVM).sDrawPath) + ' seleziono pagina BottomPanel + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.FEATURE) + End If + ' deseleziono i parametri + If Not IsNothing(SelBTLFeatureVM.SelPBTLParam) Then SelBTLFeatureVM.SelPBTLParam = Nothing + ' rinfresco bottoni freecontour + m_SelBTLFeatureVM.RefreshFCMBtnVisibility() + ' aggiorno stato abilitazione del bottone modifica free contour + Map.refFeatureManagerVM.SetEditIsEnabled() + Map.refFeatureManagerVM.NotifyPropertyChanged(NameOf(Map.refFeatureManagerVM.Priority_Visibility)) + ' Controlo se nPRC è 900 rendo visibile combobox Variant + If m_SelBTLFeatureVM.nPRC = 900 Then + Map.refFeatureManagerVM.SetVariant_Visibility(Visibility.Visible) + Dim nVariant As Integer = 0 + If Integer.TryParse(m_SelBTLFeatureVM.sDES, nVariant) Then + m_SelBTLFeatureVM.nSelVARIANT = nVariant + End If + If m_SelBTLFeatureVM.nSelVARIANT > 0 AndAlso + System.IO.File.Exists(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & m_SelBTLFeatureVM.sDescGRP & "." & m_SelBTLFeatureVM.sDES & ".png") Then + ' imposto path disegno da mostrare in BottomPanel + Map.refBottomPanelVM.SetCurrDraw(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & m_SelBTLFeatureVM.sDescGRP & "." & m_SelBTLFeatureVM.sDES & ".png") + Else + Map.refBottomPanelVM.SetCurrDraw(Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Features\" & m_SelBTLFeatureVM.sDescGRP & ".png") + End If + Else + Map.refFeatureManagerVM.SetVariant_Visibility(Visibility.Collapsed) + End If + Else + EgtDeselectAll() + End If + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.FeatureSelectionChanged() + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + EgtResetCurrMachGroup() + ResetSearchFound() + Map.refStatisticsTimePanelVM.SetViewPage_Visibility(Visibility.Visible) + Map.refStatisticsTimePanelVM.SetMachiningPage_Visibility(Visibility.Collapsed) + End If + EgtDraw() + NotifyPropertyChanged(NameOf(SelBTLFeatureVM)) + End Set + End Property + + Private m_Calc_PartEnd As Boolean = False + Public ReadOnly Property Calc_PartEnd As Boolean + Get + Return m_Calc_PartEnd + End Get + End Property + + Private m_bSearchFound As Boolean + Public ReadOnly Property bSearchFound As Boolean + Get + Return m_bSearchFound + End Get + End Property + Friend Sub SetSearchFound() + m_bSearchFound = True + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + Friend Sub ResetSearchFound() + m_bSearchFound = False + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + + Public ReadOnly Property Search_Background As SolidColorBrush + Get + Return If(m_bSearchFound AndAlso Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Brushes.Purple, Brushes.Transparent) + End Get + End Property + + Private m_bOpenFeatureList As Boolean = False + Public Property bOpenFeatureList As Boolean + Get + Return m_bOpenFeatureList + End Get + Set(value As Boolean) + m_bOpenFeatureList = value + End Set + End Property + Friend Sub SetOpenFeatureList(Value As Boolean) + m_bOpenFeatureList = Value + NotifyPropertyChanged(NameOf(bOpenFeatureList)) + End Sub + + ' Definizione comandi + Private m_cmdInvert As ICommand + Private m_cmdBackRotation As ICommand + Private m_cmdForwardRotation As ICommand + Private m_cmdXRotation As ICommand + Private m_cmdPartColour As ICommand + +#Region "MESSAGES" + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61602) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + +#End Region + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(BTLPartM As BTLPartM, BTLStructureM As BTLStructureM) + m_BTLPartM = BTLPartM + AddHandler m_BTLPartM.BTLFeatureAdded, AddressOf OnBTLFeatureAdded + m_BTLStructureM = BTLStructureM + CreateBTLFeatureVMList() + m_BTLFeatureVMList_ViewSource = New CollectionViewSource With {.Source = m_BTLFeatureVMList} + m_BTLFeatureVMList_View = m_BTLFeatureVMList_ViewSource.View + m_BTLFeatureVMList_View.CustomSort = New FeatureSorter + m_BTLFeatureVMList_View.Filter = AddressOf FeatureFilter + ' Aggiorno check DOALL + NotifyPropertyChanged(NameOf(bDOALL)) + ' Aggiorno stato da stati feature + CalcGlobalUpdate() + NotifyPropertyChanged(NameOf(CALC_FALL_Visibility)) + End Sub + + Private Function FeatureFilter(Feature As Object) As Boolean + Return BTLFeatureVMList.IndexOf(Feature) < 30 + End Function + + Public Class FeatureSorter + Implements IComparer + + Public Function Compare(x As Object, y As Object) As Integer Implements IComparer.Compare + Dim FeatureX As BTLFeatureVM = x + Dim FeatureY As BTLFeatureVM = y + Return -FeatureX.nCALC_ERR.CompareTo(FeatureY.nCALC_ERR) + End Function + + End Class + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub CreateBTLFeatureVMList() + Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_BTLPartM.GetBTLFeatures() + Select New BTLFeatureVM(BTLFeatureM, m_BTLPartM)).ToList() + + For Each BTLFeatureVM As BTLFeatureVM In all + AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + For Each BTLParamVM As BTLParamVM In BTLFeatureVM.PBTLParamVMList + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLPParamVMPropertyChanged + Next + AddHandler BTLFeatureVM.PBTLParamVMList.CollectionChanged, AddressOf OnBTLPParamVMListChanged + For Each BTLParamVM As BTLParamVM In BTLFeatureVM.QBTLParamVMList + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + AddHandler BTLFeatureVM.QBTLParamVMList.CollectionChanged, AddressOf OnBTLQParamVMListChanged + Next + + m_BTLFeatureVMList = New ObservableCollection(Of BTLFeatureVM)(all) + AddHandler m_BTLFeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged + End Sub + + Public Sub Rotation(IsPositive As Boolean, SelectedMachineType As MachineType, Optional bRedraw As Boolean = True, Optional dAng As Double = 90, Optional bVerifyDuplo As Boolean = True) + Dim OldSection As SectionXMaterial = Section + If m_BTLPartM.Rotation(IsPositive, SelectedMachineType, bRedraw, dAng) Then + ' aggiorno visualizzazione dimensioni + NotifyPropertyChanged(NameOf(sW)) + NotifyPropertyChanged(NameOf(sH)) + NotifyPropertyChanged(NameOf(sL)) + ' setto part e tutte le feature da ricalcolare + ResetCalcTotalPart() + ' aggiorno sezioni + Map.refProjectVM.BTLStructureVM.UpdateSection(Section, OldSection) + End If + NotifyPropertyChanged(NameOf(sROTATED)) + End Sub + + ' funzione che aggiorna lo stato e gli errori dopo calcolo + Friend Sub CalcPartUpdate(ERR As Integer, ROT As Integer, MSG As String) + EgtSetInfo(nPartId, ITG_PROJ_ERR, ERR, True) + EgtSetInfo(nPartId, ITG_PROJ_MSG, MSG, True) + EgtSetInfo(nPartId, ITG_PROJ_ROT, ROT, True) + m_BTLPartM.nCALC_ERR = ERR + m_BTLPartM.nCALC_ROT = ROT + m_BTLPartM.sCALC_MSG = MSG + Select Case ERR + Case 0 + nState = CalcStates.OK + Case 22 + nState = CalcStates.COLLISION + Case 17, 19 + nState = CalcStates.WARNING + Case < 0 + nState = CalcStates.INFO + Case > 0 + nState = CalcStates.ERROR_ + End Select + NotifyPropertyChanged(NameOf(Calc_BorderBrush)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + End Sub + + Friend Sub ResetCalcPart() + EgtRemoveInfo(nPartId, ITG_PROJ_ERR) + EgtRemoveInfo(nPartId, ITG_PROJ_MSG) + EgtRemoveInfo(nPartId, ITG_PROJ_ROT) + EgtRemoveInfo(nPartId, ITG_PROJ_FALL) + m_BTLPartM.nGlobalState = CalcStates.NOTCALCULATED + m_BTLPartM.nState = CalcStates.NOTCALCULATED + m_BTLPartM.nCALC_GlobalERR = 0 + m_BTLPartM.nCALC_ERR = 0 + m_BTLPartM.nCALC_ROT = 0 + m_BTLPartM.nCALC_FALL = 0 + m_BTLPartM.sCALC_MSG = "" + ' aggiorno lista feature in iconcina calcolo + BTLFeatureVMList_View.Refresh() + NotifyPropertyChanged(NameOf(Calc_BorderBrush)) + NotifyPropertyChanged(NameOf(CALC_FALL_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + End Sub + + Friend Sub ResetCalcTotalPart() + ResetCalcPart() + For Each Feature In m_BTLFeatureVMList + Feature.ResetCalcFeature() + Next + End Sub + + Friend Sub CalcFallUpdate(FALL As Integer) + EgtSetInfo(nPartId, ITG_PROJ_FALL, FALL, True) + m_BTLPartM.nCALC_FALL = FALL + NotifyPropertyChanged(NameOf(CALC_FALL_Visibility)) + End Sub + + Friend Sub CalcTimeUpdate(TIME As Integer) + EgtSetInfo(nPartId, ITG_PROJ_TIME, TIME, True) + m_BTLPartM.nCALC_TIME = TIME + NotifyPropertyChanged(NameOf(sTotTime)) + NotifyPropertyChanged(NameOf(sUnitTime)) + End Sub + + ' funzione che aggiorna lo stato e gli errori dopo calcolo + Friend Sub CalcGlobalUpdate(Optional bFeatureFirst As Boolean = False) + m_BTLPartM.nCALC_GlobalERR = nCALC_ERR + m_BTLPartM.nGlobalState = nState + m_BTLPartM.nFeaturesGlobalState = CalcStates.NOTCALCULATED + If nState > CalcStates.NOTCALCULATED Then + For Each Feature In BTLFeatureVMList + If Not Feature.bDO And Not bFeatureFirst Then + If Feature.nState = CalcStates.COLLISION AndAlso Feature.nState > m_BTLPartM.nGlobalState Then + m_BTLPartM.nGlobalState = Feature.nState + m_BTLPartM.nCALC_GlobalERR = Feature.nCALC_ERR + Else + Continue For + End If + End If + If ((Feature.nState = CalcStates.NOTCALCULATED And nState < CalcStates.WARNING) Or Not Feature.bDO) And bFeatureFirst Then + m_BTLPartM.nGlobalState = Feature.nState + m_BTLPartM.nCALC_GlobalERR = Feature.nCALC_ERR + EgtRemoveInfo(nPartId, ITG_PROJ_ERR) + Exit For + ElseIf Feature.nState = CalcStates.NOTCALCULATED And nState < CalcStates.WARNING Then + m_BTLPartM.nGlobalState = Feature.nState + m_BTLPartM.nCALC_GlobalERR = Feature.nCALC_ERR + EgtRemoveInfo(nPartId, ITG_PROJ_ERR) + Exit For + ElseIf Feature.nState > m_BTLPartM.nGlobalState Then + m_BTLPartM.nGlobalState = Feature.nState + m_BTLPartM.nCALC_GlobalERR = Feature.nCALC_ERR + End If + If Feature.nState > m_BTLPartM.nFeaturesGlobalState Then + m_BTLPartM.nFeaturesGlobalState = Feature.nState + End If + If Feature.nCALC_ROT <> 0 Then + m_BTLPartM.m_nCALC_ROT = Feature.nCALC_ROT + End If + Next + If m_BTLPartM.nGlobalState = CalcStates.NOTCALCULATED Then + EgtRemoveInfo(nPartId, ITG_PROJ_ERR) + End If + End If + NotifyPropertyChanged(NameOf(Calc_BorderBrush)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + NotifyPropertyChanged(NameOf(sCALC_MSG)) + m_Calc_PartEnd = True + End Sub + + Friend Sub ResetCalcPartEnd() + m_Calc_PartEnd = False + End Sub + + Public Function Copy() As BTLPartM + ' creo nuovo part + Dim nNewPartId As Integer = EgtBeamCreatePart() + If nNewPartId = GDB_ID.NULL Then Return Nothing + ' scrivo info proj + If Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProj.nProjId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nNewPartId, BTL_PRT_PROJ, ProjectManagerVM.CurrProd.nProjIdList(0)) + End If + EgtBeamSetPartProdNbr(m_BTLStructureM.NewPDN()) + EgtBeamSetPartName(m_BTLPartM.sNAM) + EgtBeamSetPartCount(m_BTLPartM.nCNT) + EgtBeamSetPartBox(m_BTLPartM.dBtlL, m_BTLPartM.dBtlH, m_BTLPartM.dBtlW) + + EgtSetInfo(nNewPartId, BTL_PRT_DO, m_BTLPartM.bDO) + EgtSetInfo(nNewPartId, BTL_PRT_CNT, m_BTLPartM.m_nCNT) + EgtSetInfo(nNewPartId, BTL_PRT_ADDED, m_BTLPartM.m_nADDED) + EgtSetInfo(nNewPartId, BTL_PRT_ASSEMBLYNUM, m_BTLPartM.m_sASSEMBLYNUM) + EgtSetInfo(nNewPartId, BTL_PRT_ORDERNUM, m_BTLPartM.m_nORDERNUM) + EgtSetInfo(nNewPartId, BTL_PRT_DESIGNATION, m_BTLPartM.m_sDESIGN) + EgtSetInfo(nNewPartId, BTL_PRT_ANNOTATION, m_BTLPartM.m_sANNOT) + EgtSetInfo(nNewPartId, BTL_PRT_STOREY, m_BTLPartM.m_sSTOREY) + EgtSetInfo(nNewPartId, BTL_PRT_GROUP, m_BTLPartM.m_sGROUP) + EgtSetInfo(nNewPartId, BTL_PRT_PACKAGE, m_BTLPartM.m_sPACKAGE) + EgtSetInfo(nNewPartId, BTL_PRT_TIMBERGRADE, m_BTLPartM.m_sTIMBERGRADE) + EgtSetInfo(nNewPartId, BTL_PRT_QUALITYGRADE, m_BTLPartM.m_sQUALITYGRADE) + EgtSetInfo(nNewPartId, BTL_PRT_COLOUR, m_BTLPartM.m_colCOLOR.ToString()) + EgtSetInfo(nNewPartId, BTL_PRT_PLANINGLENGTH, m_BTLPartM.m_dPLANINGLEN) + EgtSetInfo(nNewPartId, BTL_PRT_STARTOFFSET, m_BTLPartM.m_dSTARTOFFSET) + EgtSetInfo(nNewPartId, BTL_PRT_ENDOFFSET, m_BTLPartM.m_dENDOFFSET) + Dim ind As Integer = 1 + For Each UIDItem In m_BTLPartM.m_ocUID + EgtSetInfo(nNewPartId, BTL_PRT_UID & ind, UIDItem) + EgtSetInfo(nNewPartId, BTL_PRT_TRANSFORMATION & ind, LenToString(m_BTLPartM.refTransf.Orig.x, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.y, 3) & "," & + LenToString(m_BTLPartM.refTransf.Orig.z, 3) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersX.z, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.x, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.y, 6) & "," & + DoubleToString(m_BTLPartM.refTransf.VersY.z, 6)) + Next + EgtSetInfo(nNewPartId, BTL_PRT_CAMBER, " SIDE: " & (m_BTLPartM.SelCAMBERSIDE + 1) & + " P01: " & LenToString(m_BTLPartM.m_dCamberLen1, 3) & + " P02: " & LenToString(m_BTLPartM.m_dCamberLen2, 3) & + " P03: " & LenToString(m_BTLPartM.m_dCamberLen3, 3) & + " P04: " & LenToString(m_BTLPartM.m_dCamberCross3, 3)) + Dim nValue As Integer = IdNameStruct.IdFromInd(m_BTLPartM.SelREFSIDEFIXCLAMP, ocREFSIDEFIXCLAMP) + Dim sValue As String = ocREFSIDEFIXCLAMP(nValue).Name + EgtSetInfo(nNewPartId, BTL_PRT_PARTOFFSET, " P04: " & sValue & + " P11: " & m_BTLPartM.m_dPartOffsetSide1 & + " P12: " & m_BTLPartM.m_dPartOffsetSide2 & + " P13: " & m_BTLPartM.m_dPartOffsetSide3 & + " P14: " & m_BTLPartM.m_dPartOffsetSide4) + If m_BTLPartM.m_SelPROCESSINGQUALITY > -1 Then + nValue = IdNameStruct.IdFromInd(m_BTLPartM.m_SelPROCESSINGQUALITY, ocPROCESSINGQUALITY) + sValue = [Enum].GetName(GetType(ProcessingQuality), nValue) + EgtSetInfo(nNewPartId, BTL_PRT_PROCESSINGQUALITY, sValue) + End If + If m_BTLPartM.m_SelRECESS > -1 Then + nValue = IdNameStruct.IdFromInd(m_BTLPartM.m_SelRECESS, ocRECESS) + sValue = [Enum].GetName(GetType(Recess), nValue) + EgtSetInfo(nNewPartId, BTL_PRT_RECESS, sValue) + End If + If m_BTLPartM.m_SelSTOREYTYPE > -1 Then + nValue = IdNameStruct.IdFromInd(m_BTLPartM.m_SelSTOREYTYPE, ocSTOREYTYPE) + sValue = [Enum].GetName(GetType(StoreyType), nValue) + EgtSetInfo(nNewPartId, BTL_PRT_STOREYTYPE, sValue) + End If + EgtSetInfo(nNewPartId, BTL_PRT_ELEMENTNUM, m_BTLPartM.m_sELEMENTNUM) + EgtSetInfo(nNewPartId, BTL_PRT_LAYER, m_BTLPartM.m_nLAYER) + EgtSetInfo(nNewPartId, BTL_PRT_MODULENUM, m_BTLPartM.m_sMODULENUM) + 'EgtSetInfo(nNewPartId, BTL_PRT_USERATTRIBUTE, m_sUSERATTRIBUTE) + EgtSetInfo(nNewPartId, BTL_PRT_COMMENT, m_BTLPartM.m_sCOMMENT) + EgtSetInfo(nNewPartId, BTL_PRT_GRAINDIR, m_BTLPartM.refGrainDir.x & "," & + m_BTLPartM.refGrainDir.y & "," & + m_BTLPartM.refGrainDir.z & ";" & + If(m_BTLPartM.bGRAINDIRALIGN, 1, 0)) + EgtSetInfo(nNewPartId, BTL_PRT_REFSIDE, (m_BTLPartM.m_SelREFSIDE + 1) & ";" & If(m_BTLPartM.bREFSIDEALIGN, 1, 0)) + + nValue = IdNameStruct.IdFromInd(m_BTLPartM.SelALIGNLOCATION, ocALIGNLOCATION) + Dim sValueLoc As String = [Enum].GetName(GetType(AlignmentLocation), nValue) + nValue = IdNameStruct.IdFromInd(SelALIGNENDTYPE, ocALIGNENDTYPE) + Dim sValueEnd As String = [Enum].GetName(GetType(AlignmentEndtype), nValue) + EgtSetInfo(nNewPartId, BTL_PRT_ALIGNMENT, sValueLoc & ": " & sValueEnd) + + nValue = IdNameStruct.IdFromInd(m_BTLPartM.SelMATERIALTYPEGRP, ocMATERIALTYPEGRP) + sValue = ocMATERIALTYPEGRP(nValue).Name + EgtSetInfo(nNewPartId, BTL_PRT_MATERIALTYPE, sValue & ": " & m_BTLPartM.sMATERIALTYPESPEC) + + EgtSetInfo(nNewPartId, BTL_PRT_ROTATED, m_BTLPartM.nROTATED) + EgtSetInfo(nNewPartId, BTL_PRT_INVERTED, m_BTLPartM.nINVERTED) + EgtSetInfo(nNewPartId, BTL_PRT_MATERIAL, m_BTLPartM.m_sMATERIAL) + + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + 'aggiungo tutte le sue feature + For Each Feature In m_BTLFeatureVMList + Feature.Copy(NewPart) + Next + ' recupero box del pezzo + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nNewPartId, GDB_BB.STANDARD, b3Part) + ' ripristino le rotazioni di ROT e FLIP + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + EgtRotate(nNewPartId, b3Part.Center, Vector3d.X_AX, nROTATED) + EgtRotate(nNewPartId, b3Part.Center, Vector3d.Z_AX, nINVERTED) + Else + EgtRotate(nNewPartId, b3Part.Center, -Vector3d.Z_AX, nROTATED) + EgtRotate(nNewPartId, b3Part.Center, Vector3d.X_AX, nINVERTED) + End If + ' aggiungo pezzo alla lista + m_BTLStructureM.AddBTLPart(NewPart) + Return NewPart + End Function + + ' funzione che aggiorna tutte le feature dopo modifica dimensioni pezzo + Private Sub UpdateFeatures() + ' ricalcolo tutte le feature contenute + For Each Feature In m_BTLFeatureVMList + Feature.BTLFeatureM.UpdateParams(False) + ' setto feature da ricalcolare + Feature.ResetCalcFeature() + Next + EgtBeamUpdatePart() + End Sub + + Friend Sub AddNewPartToAdded(Optional PartQty As Integer = 1) + m_BTLPartM.nADDED += PartQty + NotifyPropertyChanged(NameOf(sADDED)) + End Sub + + Friend Sub RefreshPartInProd() + NotifyPropertyChanged(NameOf(nINPROD)) + NotifyPropertyChanged(NameOf(Foreground)) + NotifyPropertyChanged(NameOf(FontWeight)) + End Sub + + Friend Function CanAddPartToCount(Optional Qty As Integer = 1, Optional ByRef Added As Integer = 0) As Boolean + ' verifico se ci sono pezzi da aggiungere + Added = Math.Min(Qty, m_BTLPartM.nCNT + m_BTLPartM.nADDED - m_BTLPartM.nINPROD) + Return Qty = Added + End Function + + ' funzione che dato l'Id di un Part(Duplo) restituisce il BTLPart di origine + Friend Shared Function RetrieveBTLPartFromPart(nPartId As Integer) As BTLPartVM + Dim BTLPartId As Integer = MyMachGroupPanelM.DuploGetOriginal(nPartId) + Return Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = BTLPartId) + End Function + + ' funzione che calcola il volume del pezzo + Friend Sub CalcBTLPartVolume() + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case MachineType.BEAM + dUnitVolume = dBtlH * dBtlW * dBtlL + Case MachineType.WALL + Dim nOutlineLayerId As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE) + ' cerco Id feature + Dim nOutlineFeatureId = GDB_ID.NULL + For Each Feature In BTLFeatureVMList + If Feature.nPRC = 251 Then nOutlineFeatureId = Feature.nFeatureId + Exit For + Next + ' recupero AuxId + If nOutlineFeatureId <> GDB_ID.NULL Then + Dim nAuxId As Integer = 0 + If EgtGetInfo(nOutlineFeatureId, BTL_FTR_AUXID, nAuxId) Then + nOutlineFeatureId += nAuxId + End If + ' calcolo area + Dim dArea As Double = 0 + Dim vtN As New Vector3d + Dim dDist As Double = 0 + EgtCurveArea(nOutlineFeatureId, vtN, dDist, dArea) + dUnitVolume = dArea * dH + Else + dUnitVolume = dBtlH * dBtlW * dBtlL + End If + End Select + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "Invert" + + Public ReadOnly Property Invert_Command As ICommand + Get + If m_cmdInvert Is Nothing Then + m_cmdInvert = New Command(AddressOf Invert) + End If + Return m_cmdInvert + End Get + End Property + + Public Sub Invert() + ' eseguo inversione + m_BTLPartM.Inversion(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' setto part e tutte le feature da ricalcolare + ResetCalcTotalPart() + EgtDraw() + ' imposto lock + bLockInversion = True + NotifyPropertyChanged(NameOf(sINVERTED)) + End Sub + +#End Region ' Invert + +#Region "BackRotation" + + Public ReadOnly Property BackRotation_Command As ICommand + Get + If m_cmdBackRotation Is Nothing Then + m_cmdBackRotation = New Command(AddressOf BackRotationCmd) + End If + Return m_cmdBackRotation + End Get + End Property + + Public Sub BackRotationCmd() + BackRotation(True) + End Sub + + Public Sub BackRotation(Optional bUpdateSection As Boolean = False, Optional bRedraw As Boolean = True) + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + ' ruoto + Rotation(False, Map.refProjectVM.BTLStructureVM.nPROJTYPE, bRedraw) + ' imposto lock + bLockRotation = True + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If bUpdateSection AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + End Sub + +#End Region ' BackRotation + +#Region "ForwardRotation" + + Public ReadOnly Property ForwardRotation_Command As ICommand + Get + If m_cmdForwardRotation Is Nothing Then + m_cmdForwardRotation = New Command(AddressOf ForwardRotationCmd) + End If + Return m_cmdForwardRotation + End Get + End Property + + Public Sub ForwardRotationCmd(Optional bUpdateSection As Boolean = False) + ForwardRotation(True) + End Sub + + Public Sub ForwardRotation(Optional bUpdateSection As Boolean = False, Optional bRedraw As Boolean = True) + ' salvo sezione impostata + Dim CurrSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SelSection + Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, bRedraw) + ' imposto lock + bLockRotation = True + ' se progetto travi e sezione precedente diversa da vuota (tutti i pezzi) + If bUpdateSection AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso CurrSection <> SectionXMaterial.Empty Then + ' se esiste, imposto sezione inversa + Dim InverseSection As SectionXMaterial = Map.refProjectVM.BTLStructureVM.SectionList.FirstOrDefault(Function(x) x.dH = CurrSection.dW AndAlso x.dW = CurrSection.dH AndAlso x.sMaterial(0) = CurrSection.sMaterial(0)) + If Not IsNothing(InverseSection) Then Map.refProjectVM.BTLStructureVM.SetSelSection(InverseSection) + End If + End Sub + +#End Region ' ForwardRotation + + ' Comando inutilizzato ma conservato per eventuale rotazione a causa di importazione con rotazione sbagliata +#Region "XRotation" + + Public ReadOnly Property XRotation_Command As ICommand + Get + If m_cmdXRotation Is Nothing Then + m_cmdXRotation = New Command(AddressOf XRotation) + End If + Return m_cmdXRotation + End Get + End Property + + Public Sub XRotation() + If Map.refProjectVM.BTLStructureVM.nPROJTYPE <> MachineType.WALL Then Return + Dim OldSection As SectionXMaterial = Section + ' recupero il box del pezzo + Dim nLs As Integer = EgtGetFirstNameInGroup(nPartId, "Box") + Dim b3Solid As New BBox3d + EgtGetBBoxGlob(nLs, GDB_BB.STANDARD, b3Solid) + If b3Solid.IsEmpty() Then + EgtOutLog("ERROR: Box non definito per la trave " & sNAM) + Return + End If + Dim vtAxes As Vector3d = Vector3d.X_AX + ' eseguo rotazione di 90 gradi + If EgtRotate(nPartId, b3Solid.Center, vtAxes, 90, GDB_RT.GLOB) Then + ' imposto modificato per copie + MyMachGroupPanelM.SetDuploModified(nPartId) + End If + ' aggiorno visualizzazione dimensioni + NotifyPropertyChanged(NameOf(sW)) + NotifyPropertyChanged(NameOf(sH)) + NotifyPropertyChanged(NameOf(sL)) + ' setto part e tutte le feature da ricalcolare + ResetCalcTotalPart() + ' aggiorno sezioni + Map.refProjectVM.BTLStructureVM.UpdateSection(Section, OldSection) + End Sub + +#End Region ' XRotation + +#Region "PartColour" + + Public ReadOnly Property PartColour_Command As ICommand + Get + If m_cmdPartColour Is Nothing Then + m_cmdPartColour = New Command(AddressOf PartColourCmd) + End If + Return m_cmdPartColour + End Get + End Property + + Public Sub PartColourCmd() + Dim PartColor As New Color3d(192, 192, 192) + ' Eseguo modifica con dialogo + If SelectColor(m_BTLPartM.colCOLOR, PartColor) Then + sCOLRGB = PartColor.ToString + NotifyPropertyChanged(NameOf(PartColour)) + End If + End Sub + +#End Region ' PartColour + + Private Function SelectColor(Col As Color3d, ByRef NewCol As Color3d) As Boolean + ' Creo dialogo colori + 'Dim ColorDlg As New System.Windows.Forms.ColorDialog With { + ' .FullOpen = True, + ' .Color = Col.ToColor() + '} + Dim ColorDlg As Object + If bOnlyProd Then + ColorDlg = New OnlyProdEgtColorPickerV(Application.Current.MainWindow, New EgtColorPickerVM()) With { + .Color = Col.ToColor() + } + Else + ColorDlg = New EgtColorPickerV(Application.Current.MainWindow, New EgtColorPickerVM()) With { + .Color = Col.ToColor() + } + End If + ' Visualizzo dialogo + If ColorDlg.ShowDialog() <> Forms.DialogResult.OK Then Return False + ' Recupero colore scelto + NewCol.FromString(ColorDlg.Color.R & "," & ColorDlg.Color.G & "," & ColorDlg.Color.B & "," & ColorDlg.Color.A) 'NewCol.FromColor(ColorDlg.Color) + Return True + End Function + +#End Region ' COMMANDS + +#Region "EVENTS" + + Private Sub OnBTLFeatureAdded(sender As Object, e As BTLFeatureAddedEventArgs) + Dim BTLFeatureVM As BTLFeatureVM = New BTLFeatureVM(e.NewBTLFeature, m_BTLPartM) + BTLFeatureVMList.Add(BTLFeatureVM) + End Sub + + Private Sub OnBTLFeatureVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLFeatureVM As BTLFeatureVM In e.NewItems + AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLFeatureVM As BTLFeatureVM In e.OldItems + RemoveHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + m_BTLPartM.BTLFeatureMList.Remove(BTLFeatureVM.BTLFeatureM) + Next + End If + End Sub + Private Sub OnBTLPParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.NewItems + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLPParamVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.OldItems + RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnBTLPParamVMPropertyChanged + Next + End If + End Sub + Private Sub OnBTLQParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.NewItems + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.OldItems + RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + End If + End Sub + + Private Sub OnBTLFeatureVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.nSelGRP), NameOf(sender.nSelSIDE) + CalcGlobalUpdate(True) + ' imposto path disegno da mostrare in BottomPanel + Dim SelPBTLParam As BTLParamVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam + If Not IsNothing(Map.refBottomPanelVM) AndAlso Not IsNothing(SelPBTLParam) Then Map.refBottomPanelVM.SetCurrDraw(SelPBTLParam.sDrawPath) + Case NameOf(sender.bDO), NameOf(sender.sPriority) + NotifyPropertyChanged(NameOf(bDOALL)) + ' setto pezzo da ricalcolare + CalcGlobalUpdate(True) + End Select + End Sub + Private Sub OnBTLPParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.dValue), NameOf(sender.sValue) + CalcGlobalUpdate(True) + End Select + End Sub + Private Sub OnBTLQParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.dValue), NameOf(sender.sValue) + CalcGlobalUpdate(True) + End Select + End Sub + +#End Region + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLViewModel/BTLRawPartVM.vb b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLRawPartVM.vb new file mode 100644 index 00000000..481b77d2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLRawPartVM.vb @@ -0,0 +1,3 @@ +Friend Class BTLRawPartVM + +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLViewModel/BTLStructureVM.vb b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLStructureVM.vb new file mode 100644 index 00000000..b8f72cde --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BTLViewModel/BTLStructureVM.vb @@ -0,0 +1,1347 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLStructureVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Friend Enum SelectionTypes As Integer + NULL = 0 + SELECT_ = 1 + HIGHLIGHT = 2 + End Enum + + Private m_Calc_PartEnd As New DispatcherTimer + + Private WithEvents m_BTLStructureM As BTLStructureM + Public ReadOnly Property BTLStructureM As BTLStructureM + Get + Return m_BTLStructureM + End Get + End Property + + ' pezzi da BTL + Private m_BTLPartVMList_View As CollectionView = Nothing + Public ReadOnly Property BTLPartVMList_View As CollectionView + Get + Return m_BTLPartVMList_View + End Get + End Property + + Private m_BTLPartVMList As ObservableCollection(Of BTLPartVM) + Public Property BTLPartVMList As ObservableCollection(Of BTLPartVM) + Get + Return m_BTLPartVMList + End Get + Set(value As ObservableCollection(Of BTLPartVM)) + m_BTLPartVMList = value + End Set + End Property + + Private m_bOnlySelectItem As Boolean = False + Public Property bOnlySelectItem As Boolean + Get + Return m_bOnlySelectItem + End Get + Set(value As Boolean) + m_bOnlySelectItem = value + End Set + End Property + Private m_PrevSelectionType As SelectionTypes = SelectionTypes.NULL + Friend ReadOnly Property PrevSelectionType As SelectionTypes + Get + Return m_PrevSelectionType + End Get + End Property + Private m_SelectionType As SelectionTypes = SelectionTypes.NULL + Friend ReadOnly Property SelectionType As SelectionTypes + Get + Return m_SelectionType + End Get + End Property + Friend Sub SetSelectionType(value As SelectionTypes) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' rimuovo selezione da pezzo in MachGroup + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) AndAlso Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup) Then + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart) Then + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart = Nothing + End If + End If + End If + m_PrevSelectionType = m_SelectionType + If value = m_SelectionType And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART Or Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST) Then Return + m_SelectionType = value + Select Case m_SelectionType + Case SelectionTypes.SELECT_ + ' imposto modalita' proj su vista feature + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refProdProjManagerVM.SelProdProj = ProdProj.PROJ + ' rendo visibile PartManager + Map.refLeftPanelVM.SetOnlyProdPartManager_Visibility(Visibility.Visible) + End If + ' rendo enable bottone parameters + Map.refLeftPanelVM.SetParametersIsEnabled(True) + Map.refLeftPanelVM.SetData_IsEnabled(False) + ' verifico reset mark su tutti i pezzi + For Each BTLPart In m_BTLPartVMList + EgtResetMark(BTLPart.nPartId) + Next + ' mostro barra di gestione pezzo + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + Case SelectionTypes.HIGHLIGHT + ' imposto modalita' nulla su vista feature + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refProdProjManagerVM.SelProdProj = ProdProj.NULL + ' rendo visibile PartManager + Map.refLeftPanelVM.SetOnlyProdPartManager_Visibility(Visibility.Collapsed) + End If + ' rendo disable bottone parameters + Map.refLeftPanelVM.SetParametersIsEnabled(False) + Map.refLeftPanelVM.SetData_IsEnabled(True) + If m_PrevSelectionType = SelectionTypes.SELECT_ Then + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) + End If + If Not IsNothing(m_SelBTLPart) Then + m_SelBTLPart = Nothing + NotifyPropertyChanged(NameOf(SelBTLPart)) + End If + ' mostro pezzi selezionati + Map.refProjectVM.BTLStructureVM.ShowAll(False) + ' se attivata opzione, li assemblo + Map.refProjectVM.BTLStructureVM.ShowBuilding(If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Map.refShowBeamPanelVM.ShowBuilding_IsChecked, False), False) + ' nascondo barra di gestione pezzo + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + End Select + ' aggiornamento grafica + Configuration.UpdateGraphics() + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.FeatureSelectionChanged() + Map.refCALCPanelVM.SetIsEnabledForSelPart() + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + End Sub + + Private m_SelBTLParts As New PartsObservableCollection(Of BTLPartVM) + Public ReadOnly Property SelBTLParts As PartsObservableCollection(Of BTLPartVM) + Get + Return m_SelBTLParts + End Get + End Property + + Private m_SelBTLPartsCnt As Integer = Nothing + Public ReadOnly Property SelBTLPartsCnt As Integer + Get + Return m_SelBTLPartsCnt + End Get + End Property + + Private Sub SelBTLParts_CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If m_bOnlySelectItem Then Return + Select Case e.Action + Case NotifyCollectionChangedAction.Add + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + If e.NewItems.Count > 0 AndAlso Not IsNothing(e.NewItems(0)) Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_SelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + SelectBTLPart(e.NewItems(0)) + Else ' SelectionTypes.HIGHLIGHT + HighlightBTLPart(e.NewItems(0)) + End If + End If + Case NotifyCollectionChangedAction.Remove + If e.OldItems.Count > 0 AndAlso Not IsNothing(e.OldItems(0)) Then + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + DeselectBTLPart(e.OldItems(0)) + Else ' SelectionTypes.HIGHLIGHT + DeHighlightBTLPart(e.OldItems(0)) + End If + End If + Case NotifyCollectionChangedAction.Reset + If ((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso m_PrevSelectionType = SelectionTypes.SELECT_) OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If Not IsNothing(m_SelBTLPart) Then + DeselectBTLPart(m_SelBTLPart) + End If + Else ' SelectionTypes.HIGHLIGHT + For Each BTLPart In m_BTLPartVMList + DeHighlightBTLPart(BTLPart, False) + Next + EgtDraw() + End If + SelBTLPart = Nothing + End Select + ' aggiornamento grafica + Configuration.UpdateGraphics() + End Sub + + Private Sub SelectBTLPart(BtlPart As BTLPartVM) + m_SelBTLPart = BtlPart + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + Configuration.SelectedPieces(BtlPart.nPartId, Me) + ' seleziono pagina BottomPanel + If Not IsNothing(Map.refBottomPanelVM) Then + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + End If + ' mostro barra di gestione pezzo + If Not IsNothing(BtlPart.BTLFeatureVMList) AndAlso BtlPart.BTLFeatureVMList.Count > 0 Then SelBTLPart.SelBTLFeatureVM = BtlPart.BTLFeatureVMList(0) + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + Configuration.SetSearchPiece(BtlPart.nPartId) + ' seleziono pezzo nella scena + SceneSelPartSelection() + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' deseleziono eventuale MachGroup selezionato + If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + End If + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + End If + Configuration.SelectedPieces(BtlPart.nPartId, Me) + ' seleziono la prima feature + If Not IsNothing(BtlPart.BTLFeatureVMList) AndAlso BtlPart.BTLFeatureVMList.Count > 0 Then SelBTLPart.SelBTLFeatureVM = BtlPart.BTLFeatureVMList(0) + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + End If + NotifyPropertyChanged(NameOf(SelBTLPart)) + End Sub + Private Sub DeselectBTLPart(BtlPart As BTLPartVM) + ' se necessario tolgo solido dal precedentemente selezionato + Configuration.DeselectSolid(BtlPart.nPartId, True) + If m_SelBTLPart Is BtlPart Then + EgtBeamShowFacesName(False) + EgtBeamShowLoadingSide(False, False) + m_SelBTLPart = Nothing + NotifyPropertyChanged(NameOf(SelBTLPart)) + End If + ' disabilito eventuale feature selezionata + If Not IsNothing(BtlPart.m_SelBTLFeatureVM) AndAlso (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING) Then BtlPart.SelBTLFeatureVM = Nothing + EgtDraw() + End Sub + Private Sub HighlightBTLPart(BtlPart As BTLPartVM) + EgtSetMark(BtlPart.nPartId) + ' se modalità building + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ' evidenzio anche copie + Dim nNextPartId As Integer = EgtGetNext(BtlPart.nPartId) + While nNextPartId <> GDB_ID.NULL + Dim nOrigId As Integer = GDB_ID.NULL + If EgtGetInfo(nNextPartId, "!COP", nOrigId) AndAlso nOrigId <> GDB_ID.NULL AndAlso nOrigId = BtlPart.nPartId Then + EgtSetMark(nNextPartId) + Else + Exit While + End If + nNextPartId = EgtGetNext(nNextPartId) + End While + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + Configuration.SetSearchPiece(BtlPart.nPartId) + End If + ' seleziono pagina BottomPanel + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.NULL) + EgtDraw() + End Sub + Private Sub DeHighlightBTLPart(BtlPart As BTLPartVM, Optional bDraw As Boolean = True) + EgtResetMark(BtlPart.nPartId) + ' se modalità building + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ' deevidenzio anche copie + Dim nNextPartId As Integer = EgtGetNext(BtlPart.nPartId) + While nNextPartId <> GDB_ID.NULL + Dim nOrigId As Integer = GDB_ID.NULL + If EgtGetInfo(nNextPartId, "!COP", nOrigId) AndAlso nOrigId <> GDB_ID.NULL AndAlso nOrigId = BtlPart.nPartId Then + EgtResetMark(nNextPartId) + Else + Exit While + End If + nNextPartId = EgtGetNext(nNextPartId) + End While + End If + ' deevidenzio MachGroup e Duplo di questo pezzo + Configuration.ResetSearchPiece(BtlPart.nPartId) + ' seleziono pagina BottomPanel + If bDraw Then EgtDraw() + End Sub + + Private m_SelBTLPart As BTLPartVM = Nothing + Public Property SelBTLPart As BTLPartVM + Get + Return m_SelBTLPart + End Get + Set(value As BTLPartVM) + If Map.refMainMenuVM.SelPage = Pages.MACHINING Or (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) AndAlso + Not IsNothing(value) Then + ' resetto gruppo di lavorazione corrente + EgtResetCurrMachGroup() + If value IsNot m_SelBTLPart Then + If m_SelBTLPart.bOpenFeatureList Then + m_SelBTLPart.SetOpenFeatureList(False) + End If + value.SetOpenFeatureList(True) + Else + m_SelBTLPart.SetOpenFeatureList(m_SelBTLPart.bOpenFeatureList) + End If + End If + If Not IsNothing(m_SelBTLPart) Then + ' se necessario tolgo solido dal precedentemente selezionato + Configuration.DeselectSolid() + ' disabilito eventuale feature selezionata + If Not IsNothing(m_SelBTLPart.m_SelBTLFeatureVM) Then m_SelBTLPart.SelBTLFeatureVM = Nothing + End If + m_SelBTLPart = value + ' se seleziono un pezzo + If Not IsNothing(m_SelBTLPart) Then + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' se modalità building, la tolgo + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + ShowBuilding(False, False) + End If + ' seleziono pezzo nella scena + SceneSelPartSelection() + ' seleziono pezzo in Db geometrico + EgtBeamSetPart(m_SelBTLPart.nPartId) + ' seleziono pagina BottomPanel + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.PART) + ' mostro barra di gestione pezzo + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' deseleziono le feature + If Not IsNothing(m_SelBTLPart.SelBTLFeatureVM) Then SelBTLPart.SelBTLFeatureVM = Nothing + ' aggiorno stato selezionato tutto + Map.refShowBeamPanelVM.bShowAll = False + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + ' trovo ed evidenzio MachGroup e Duplo di questo pezzo + Configuration.SetSearchPiece(m_SelBTLPart.nPartId) + ' seleziono pezzo nella scena + SceneSelPartSelection() + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + End If + End If + NotifyPropertyChanged(NameOf(SelBTLPart)) + End Set + End Property + + Friend Sub SetSelBTLPart(SelBTLPart As BTLPartVM, Optional bByOptim As Boolean = False, Optional bSingleHighlight As Boolean = False) + If bByOptim Then + ' annullo evidenziazione MachGroup e Duplo + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each Machgroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + For Each Part As PartVM In Machgroup.PartVMList + Part.ResetSearchFound() + Next + Machgroup.ResetSearchFound() + Next + End If + End If + SetSelectionType(SelectionTypes.HIGHLIGHT) + If bByOptim Then + m_bOnlySelectItem = True + End If + If bByOptim Or bSingleHighlight Then + If SelBTLParts.Contains(SelBTLPart) Then + For Each Part In SelBTLParts.ToList() + If Part IsNot SelBTLPart Then SelBTLParts.Remove(Part) + Next + Else + SelBTLParts.Clear() + End If + End If + + If Not IsNothing(SelBTLPart) Then SelBTLParts.AddToList(SelBTLPart) + + If bByOptim Then + m_bOnlySelectItem = False + End If + End Sub + + ' lista parametri per ricerca testuale + Private m_SearchParamList As New ObservableCollection(Of IdNameStruct)({New IdNameStruct(BTLPartParam.NULL, ""), + New IdNameStruct(BTLPartParam.PDN, EgtMsg(61809)), + New IdNameStruct(BTLPartParam.NAM, EgtMsg(61603))}) + Public ReadOnly Property SearchParamList As ObservableCollection(Of IdNameStruct) + Get + Return m_SearchParamList + End Get + End Property + + Private m_SelSearchParam As IdNameStruct = m_SearchParamList(0) + Public Property SelSearchParam As IdNameStruct + Get + Return m_SelSearchParam + End Get + Set(value As IdNameStruct) + ' resetto il contenuto della barra di ricerca testuale e refresho la lista dei Part (in modo da averli visibili tutti) + SearchText = "" + NotifyPropertyChanged(NameOf(SearchText)) + ' ora setto il valore scelto come Parameter Type + m_SelSearchParam = value + End Set + End Property + + ' lista dei gruppi + Private m_GroupList_View As CollectionView = Nothing + Private m_GroupList As New ObservableCollection(Of String)({""}) + Public Property GroupList As ObservableCollection(Of String) + Get + Return m_GroupList + End Get + Set(value As ObservableCollection(Of String)) + m_GroupList = value + End Set + End Property + + Private m_SelGroup As String = "" + Public Property SelGroup As String + Get + Return m_SelGroup + End Get + Set(value As String) + m_SelGroup = value + m_BTLPartVMList_View.Refresh() + m_SectionList_View.Refresh() + m_SubGroupList_View.Refresh() + End Set + End Property + + ' lista dei SubGroup + Private m_SubGroupList_View As CollectionView = Nothing + Private m_SubGroupList As New ObservableCollection(Of String)({""}) + Public Property SubGroupList As ObservableCollection(Of String) + Get + Return m_SubGroupList + End Get + Set(value As ObservableCollection(Of String)) + m_SubGroupList = value + End Set + End Property + + Private m_SelSubGroup As String = "" + Public Property SelSubGroup As String + Get + Return m_SelSubGroup + End Get + Set(value As String) + m_SelSubGroup = value + m_BTLPartVMList_View.Refresh() + m_SectionList_View.Refresh() + m_GroupList_View.Refresh() + End Set + End Property + + ' lista delle sezioni utilizzate + Private m_SectionList_View As CollectionView = Nothing + Private m_SectionList As New ObservableCollection(Of SectionXMaterial)({SectionXMaterial.Empty}) + Public Property SectionList As ObservableCollection(Of SectionXMaterial) + Get + Return m_SectionList + End Get + Set(value As ObservableCollection(Of SectionXMaterial)) + m_SectionList = value + End Set + End Property + + Private m_SelSection As SectionXMaterial = SectionXMaterial.Empty + Public Property SelSection As SectionXMaterial + Get + Return m_SelSection + End Get + Set(value As SectionXMaterial) + If Not IsNothing(value) Then + m_SelSection = value + m_BTLPartVMList_View.Refresh() + m_GroupList_View.Refresh() + m_SubGroupList_View.Refresh() + End If + End Set + End Property + Friend Sub SetSelSection(value As SectionXMaterial) + If Not IsNothing(value) Then + m_SelSection = value + m_BTLPartVMList_View.Refresh() + m_GroupList_View.Refresh() + m_SubGroupList_View.Refresh() + End If + NotifyPropertyChanged(NameOf(SelSection)) + End Sub + + Private m_SearchText As String = "" + Public Property SearchText As String + Get + Return m_SearchText + End Get + Set(value As String) + m_SearchText = value + m_BTLPartVMList_View.Refresh() + m_GroupList_View.Refresh() + m_SectionList_View.Refresh() + End Set + End Property + + Public Property bDOALL As Boolean? + Get + If BTLPartVMList.Count = 0 Then Return False + Dim bTemp As Boolean = BTLPartVMList(0).bDO + For FeatureIndex = 1 To BTLPartVMList.Count - 1 + If BTLPartVMList(FeatureIndex).bDO <> bTemp Then Return Nothing + Next + Return bTemp + End Get + Set(value As Boolean?) + If BTLPartVMList.Count = 0 Then + NotifyPropertyChanged(NameOf(bDOALL)) + Return + End If + For PartIndex = 0 To BTLPartVMList.Count - 1 + Dim Part As BTLPartVM = BTLPartVMList(PartIndex) + If (IsNothing(m_SelSection) OrElse m_SelSection.dH = -1 OrElse Part.Section = m_SelSection) AndAlso + (SelGroup = "" OrElse Part.sGROUP = SelGroup) AndAlso + (SelSubGroup = "" OrElse Part.sSTOREY = SelSubGroup) AndAlso + (SelSearchParam.Id = BTLPartParam.NULL OrElse SearchText = String.Empty OrElse ( + (SelSearchParam.Id = BTLPartParam.PDN AndAlso Part.nPDN.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0) OrElse + (SelSearchParam.Id = BTLPartParam.NAM AndAlso Part.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0))) Then + Part.bDO = value + Part.NotifyPropertyChanged(NameOf(Part.bDO)) + End If + Next + End Set + End Property + +#Region "Parametri generici" + + Public Property sPROJNUM As String + Get + Return m_BTLStructureM.m_sPROJNUM + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJNUM, value) Then + m_BTLStructureM.m_sPROJNUM = value + Else + NotifyPropertyChanged(NameOf(sPROJNUM)) + End If + End Set + End Property + + Public Property sPROJNAME As String + Get + Return m_BTLStructureM.m_sPROJNAME + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJNAME, value) Then + m_BTLStructureM.m_sPROJNAME = value + Else + NotifyPropertyChanged(NameOf(sPROJNAME)) + End If + End Set + End Property + + Public Property sPROJPART As String + Get + Return m_BTLStructureM.m_sPROJPART + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJPART, value) Then + m_BTLStructureM.m_sPROJPART = value + Else + NotifyPropertyChanged(NameOf(sPROJPART)) + End If + End Set + End Property + + Public Property sPROJGUID As String + Get + Return m_BTLStructureM.m_sPROJGUID + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_PROJGUID, value) Then + m_BTLStructureM.m_sPROJGUID = value + Else + NotifyPropertyChanged(NameOf(sPROJGUID)) + End If + End Set + End Property + + Public ReadOnly Property nPROJTYPE As BWType + Get + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + Return Map.refProjManagerVM.nProjType + Case Pages.MACHINING + Return Map.refProdManagerVM.nProdType + Case Pages.ONLYPRODPAGE + Return Map.refOnlyProdManagerVM.nProdType + Case Else + Return BWType.NULL + End Select + End Get + End Property + + Public Property sLISTNAME As String + Get + Return m_BTLStructureM.m_sLISTNAME + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_LISTNAME, value) Then + DbControllers.m_ProjController.UpdateListName(ProjectManagerVM.CurrProj.nProjId, value) + m_BTLStructureM.m_sLISTNAME = value + Else + NotifyPropertyChanged(NameOf(sLISTNAME)) + End If + End Set + End Property + + Public Property sCUSTOMER As String + Get + Return m_BTLStructureM.m_sCUSTOMER + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_CUSTOMER, value) Then + m_BTLStructureM.m_sCUSTOMER = value + Else + NotifyPropertyChanged(NameOf(sCUSTOMER)) + End If + End Set + End Property + + Public Property sARCHITECT As String + Get + Return m_BTLStructureM.m_sARCHITECT + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_ARCHITECT, value) Then + m_BTLStructureM.m_sARCHITECT = value + Else + NotifyPropertyChanged(NameOf(sARCHITECT)) + End If + End Set + End Property + + Public Property sEDITOR As String + Get + Return m_BTLStructureM.m_sEDITOR + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EDITOR, value) Then + m_BTLStructureM.m_sEDITOR = value + Else + NotifyPropertyChanged(NameOf(sEDITOR)) + End If + End Set + End Property + + Public Property sDELIVDATE As String + Get + Return m_BTLStructureM.m_sDELIVDATE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_DELIVDATE, value) Then + m_BTLStructureM.m_sDELIVDATE = value + Else + NotifyPropertyChanged(NameOf(sDELIVDATE)) + End If + End Set + End Property + + Public Property sEXPDATE As String + Get + Return m_BTLStructureM.m_sEXPDATE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPDATE, value) Then + m_BTLStructureM.m_sEXPDATE = value + Else + NotifyPropertyChanged(NameOf(sEXPDATE)) + End If + End Set + End Property + + Public Property sEXPTIME As String + Get + Return m_BTLStructureM.m_sEXPTIME + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPTIME, value) Then + m_BTLStructureM.m_sEXPTIME = value + Else + NotifyPropertyChanged(NameOf(sEXPTIME)) + End If + End Set + End Property + + Public Property sEXPRELEASE As String + Get + Return m_BTLStructureM.m_sEXPRELEASE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPRELEASE, value) Then + m_BTLStructureM.m_sEXPRELEASE = value + Else + NotifyPropertyChanged(NameOf(sEXPRELEASE)) + End If + End Set + End Property + + Public Property sLANGUAGE As String + Get + Return m_BTLStructureM.m_sLANGUAGE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_LANGUAGE, value) Then + m_BTLStructureM.m_sLANGUAGE = value + Else + NotifyPropertyChanged(NameOf(sLANGUAGE)) + End If + End Set + End Property + + Public ReadOnly Property ocRANGE As List(Of Object) + Get + Return m_BTLStructureM.ocRANGE + End Get + End Property + + Public Property SelRANGE As Integer + Get + Return m_BTLStructureM.m_SelRANGE + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocRANGE) + Dim sValue As String = [Enum].GetName(GetType(Range), nValue) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_RANGE, sValue) Then + m_BTLStructureM.m_SelRANGE = value + Else + NotifyPropertyChanged(NameOf(SelRANGE)) + End If + End Set + End Property + + Public ReadOnly Property ocPROCESSINGQUALITY As List(Of Object) + Get + Return m_BTLStructureM.ocPROCESSINGQUALITY + End Get + End Property + + Public Property SelPROCESSINGQUALITY As Integer + Get + Return m_BTLStructureM.m_SelPROCESSINGQUALITY + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocPROCESSINGQUALITY) + Dim sValue As String = [Enum].GetName(GetType(ProcessingQuality), nValue) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_PRT_PROCESSINGQUALITY, sValue) Then + m_BTLStructureM.m_SelPROCESSINGQUALITY = value + Else + NotifyPropertyChanged(NameOf(SelPROCESSINGQUALITY)) + End If + End Set + End Property + + Public Property sCOMPUTERNAME As String + Get + Return m_BTLStructureM.m_sCOMPUTERNAME + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_COMPUTERNAME, value) Then + m_BTLStructureM.m_sCOMPUTERNAME = value + Else + NotifyPropertyChanged(NameOf(sCOMPUTERNAME)) + End If + End Set + End Property + + Public Property sUSER As String + Get + Return m_BTLStructureM.m_sUSER + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_USER, value) Then + m_BTLStructureM.m_sUSER = value + Else + NotifyPropertyChanged(NameOf(sUSER)) + End If + End Set + End Property + + Public Property sSRCFILE As String + Get + Return m_BTLStructureM.m_sSRCFILE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_SRCFILE, value) Then + m_BTLStructureM.m_sSRCFILE = value + Else + NotifyPropertyChanged(NameOf(sSRCFILE)) + End If + End Set + End Property + + Public Property sEXPFILE As String + Get + Return m_BTLStructureM.m_sEXPFILE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_EXPFILE, value) Then + m_BTLStructureM.m_sEXPFILE = value + Else + NotifyPropertyChanged(NameOf(sEXPFILE)) + End If + End Set + End Property + + Public ReadOnly Property ocRECESS As List(Of Object) + Get + Return m_BTLStructureM.ocRECESS + End Get + End Property + + Public Property SelRECESS As Integer + Get + Return m_BTLStructureM.m_SelRECESS + End Get + Set(value As Integer) + Dim nValue As Integer = IdNameStruct.IdFromInd(value, m_BTLStructureM.ocRECESS) + Dim sValue As String = [Enum].GetName(GetType(Recess), nValue) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_PRT_RECESS, sValue) Then + m_BTLStructureM.m_SelRECESS = value + Else + NotifyPropertyChanged(NameOf(SelRECESS)) + End If + End Set + End Property + + Public Property sUSERATTRIBUTE As String + Get + Return m_BTLStructureM.m_sUSERATTRIBUTE + End Get + Set(value As String) + If EgtSetInfo(m_BTLStructureM.nBTLInfoId, BTL_GEN_USERATTRIBUTE, value) Then + m_BTLStructureM.m_sUSERATTRIBUTE = value + Else + NotifyPropertyChanged(NameOf(sUSERATTRIBUTE)) + End If + End Set + End Property + + Public ReadOnly Property sBTLTotParts As String + Get + Return m_BTLPartVMList.Sum(Function(x) x.nCNT + x.nADDED) + End Get + End Property + + Public ReadOnly Property sBTLTotVolume As String + Get + Dim dMMTotVolume As Double = m_BTLPartVMList.Sum(Function(x) x.dUnitVolume * (x.nCNT + x.nADDED)) + Return If(EgtUiUnitsAreMM(), DoubleToString(dMMTotVolume / 1000000000, 3), DoubleToString(dMMTotVolume * (12 / ONEINCH), 3)) + End Get + End Property + + Public ReadOnly Property dBTLTotTime As Double + Get + Return m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * (x.nCNT + x.nADDED)) + End Get + End Property + + Public ReadOnly Property sBTLTotTime As String + Get + Return TimeSpan.FromSeconds(dBTLTotTime).ToString() + End Get + End Property + + Public ReadOnly Property sBTLDoneTime As String + Get + Return TimeSpan.FromSeconds(m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * x.nDONE)).ToString() + End Get + End Property + + Public ReadOnly Property sBTLRemainingTime As String + Get + Return TimeSpan.FromSeconds(dBTLTotTime - m_BTLPartVMList.Sum(Function(x) x.nCALC_TIME * x.nDONE)).ToString() + End Get + End Property + + Public ReadOnly Property sTotCNTParts As String + Get + Return m_BTLPartVMList.Sum(Function(x) x.nCNT) + End Get + End Property + + Public ReadOnly Property sTotADDEDParts As String + Get + Return m_BTLPartVMList.Sum(Function(x) x.nADDED) + End Get + End Property + + Public ReadOnly Property sTotINPRODParts As String + Get + Return m_BTLPartVMList.Sum(Function(x) x.nINPROD) + End Get + End Property + + Public ReadOnly Property sTotDONEParts As String + Get + Return m_BTLPartVMList.Sum(Function(x) x.nDONE) + End Get + End Property + +#End Region ' Parametri generici + + ' Definizione comandi + Private m_cmdDeletePart As ICommand + Private m_cmdProjSetting As ICommand + + Public ReadOnly Property PDN_Msg As String + Get + Return EgtMsg(61809) + End Get + End Property + +#End Region + +#Region "CONSTRUCTOR" + + Sub New(BTLStructureM As BTLStructureM) + m_BTLStructureM = BTLStructureM + AddHandler m_BTLStructureM.BTLPartAdded, AddressOf OnBTLPartAdded + AddHandler m_SelBTLParts.CollectionChanged, AddressOf SelBTLParts_CollectionChanged + ' creo lista di BTLPartVM + CreateBTLPartVMList() + m_BTLPartVMList_View = CollectionViewSource.GetDefaultView(m_BTLPartVMList) + m_GroupList_View = CollectionViewSource.GetDefaultView(m_GroupList) + m_SubGroupList_View = CollectionViewSource.GetDefaultView(m_SubGroupList) + m_SectionList_View = CollectionViewSource.GetDefaultView(m_SectionList) + m_BTLPartVMList_View.Filter = AddressOf PartFilter + m_GroupList_View.Filter = AddressOf GroupFilter + m_SectionList_View.Filter = AddressOf SectionFilter + m_BTLPartVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(BTLPartVM.nPROJ))) + m_Calc_PartEnd.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_Calc_PartEnd.Tick, AddressOf Calc_PartEnd_Tick + m_Calc_PartEnd.Start() + ' Aggiorno check DOALL + NotifyPropertyChanged(NameOf(bDOALL)) + If BTLStructureM.nAsseBaseId = GDB_ID.NULL Then + Map.refShowBeamPanelVM.SetShowBuilding(False) + End If + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub CreateBTLPartVMList() + Dim all As List(Of BTLPartVM) = (From BTLPartM In m_BTLStructureM.GetBTLParts() + Select New BTLPartVM(BTLPartM, m_BTLStructureM)).ToList() + + For Each BTLPartVM As BTLPartVM In all + AddHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged + Next + + m_BTLPartVMList = New ObservableCollection(Of BTLPartVM)(all) + AddHandler m_BTLPartVMList.CollectionChanged, AddressOf OnBTLPartVMListChanged + End Sub + + + Friend Sub LoadFilters() + For Each BTLPartVM As BTLPartVM In m_BTLPartVMList + ' verifico sezione, gruppo e sottogruppo per inserirli nei filtri + If Not SectionList.Contains(BTLPartVM.Section) Then + SectionList.Add(BTLPartVM.Section) + End If + If Not GroupList.Contains(BTLPartVM.sGROUP) Then + GroupList.Add(BTLPartVM.sGROUP) + End If + If Not SubGroupList.Contains(BTLPartVM.sSTOREY) Then + SubGroupList.Add(BTLPartVM.sSTOREY) + End If + Next + End Sub + + Private Sub Calc_PartEnd_Tick() + ' se calcolo non in corso (mainmenu e' attivo), esco + If Map.refMainMenuVM.MainMenu_IsEnabled Then Return + ' aggiorno iconcina delle feature dei part che hanno finito calcolo + For Each BTLPart In BTLPartVMList + If BTLPart.Calc_PartEnd Then + BTLPart.BTLFeatureVMList_View.Refresh() + BTLPart.ResetCalcPartEnd() + End If + Next + End Sub + + Friend Sub SceneSelPartSelection() + ' deseleziono tutto + EgtDeselectAll() + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' ciclo sui pezzi + For Each Part As BTLPartVM In m_BTLPartVMList + ' se non è quello selezionato, lo nasondo + If Part IsNot m_SelBTLPart Then + EgtSetMode(Part.nPartId, GDB_MD.HIDDEN) + Else + EgtSetMode(Part.nPartId, GDB_MD.STD) + End If + Next + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + End Sub + + Friend Sub ShowAll(Optional bRedraw As Boolean = True, Optional bOnlySelected As Boolean = False) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + If Not IsNothing(SelBTLPart) Then + ' se pezzo solido, lo riporto normale + Configuration.DeselectSolid() + ' tolgo pezzo selezionato + SelBTLPart.SelBTLFeatureVM = Nothing + End If + ' mostro tutti i pezzi + ' creo lista id presenti + Dim BTLPartIdList As List(Of Integer) = (From Part In BTLPartVMList + Select Part.nPartId).ToList() + BTLPartIdList.Sort() + Dim nGeomPartId As Integer = EgtGetFirstPart() + While nGeomPartId <> GDB_ID.NULL + Dim CurrPart As BTLPartVM = BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nGeomPartId) + If Not IsNothing(CurrPart) AndAlso Not bOnlySelected Then + Dim nMode As Integer + EgtGetMode(CurrPart.nPartId, nMode) + If nMode <> GDB_MD.STD Then + EgtSetMode(CurrPart.nPartId, GDB_MD.STD) + End If + Else + EgtSetMode(nGeomPartId, GDB_MD.HIDDEN) + End If + nGeomPartId = EgtGetNextPart(nGeomPartId) + End While + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + EgtZoom(ZM.ALL, bRedraw) + ' imposto stato per ShowBeamPanel + If Not bOnlySelected Then Map.refShowBeamPanelVM.bShowAll = True + End Sub + + Friend Sub HideAll(Optional bRedraw As Boolean = True) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + If Not IsNothing(SelBTLPart) Then + ' se pezzo solido, lo riporto normale + Configuration.DeselectSolid(GDB_ID.NULL, True) + ' tolgo pezzo selezionato + SelBTLPart.SelBTLFeatureVM = Nothing + End If + SetSelBTLPart(Nothing) + ' nascondo tutti i pezzi + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + Dim nMode As Integer + EgtGetMode(nPartId, nMode) + If nMode <> GDB_MD.HIDDEN Then + EgtSetMode(nPartId, GDB_MD.HIDDEN) + End If + nPartId = EgtGetNextPart(nPartId) + End While + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + EgtZoom(ZM.ALL, bRedraw) + ' imposto stato per ShowBeamPanel + Map.refShowBeamPanelVM.bShowAll = True + End Sub + + Friend Sub ShowBuilding(bShow As Boolean, Optional bRedraw As Boolean = True) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + + Dim bOn As Boolean = EgtBeamGetBuildingIsOn() + If bShow <> bOn Then + EgtBeamShowBuilding(bShow) + End If + + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + + ' aggiorno visualizzazione + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + EgtZoom(ZM.ALL, bRedraw) + End Sub + + Friend Sub ShowSolid(nPartId As Integer, bShow As Boolean, Optional bRedraw As Boolean = True) + ' se non viene passato, recupero il pezzo del primo oggetto selezionato + If nPartId = GDB_ID.NULL And Not IsNothing(SelBTLPart) Then + nPartId = SelBTLPart.nPartId + End If + If Not EgtIsPart(nPartId) Then + Dim nLayerId As Integer = EgtGetParent(nPartId) + Dim sLayerName As String = "" + EgtGetName(nLayerId, sLayerName) + If sLayerName <> ASSEBASE Then + Map.refMyStatusBarVM.SetOutputMessage("ERROR: Nessuna trave selezionata ", 5, MSG_TYPE.ERROR_) + Return + End If + End If + EgtDeselectAll() + + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + + If bShow Then EgtBeamCalcSolid(nPartId) + + EgtBeamShowSolid(nPartId, bShow) + If bRedraw Then EgtDraw() + + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + End Sub + + ' Funzione per regolarizzare, se necessario, la superficie della feature + Private Function RegularizeTriMesh(SurfId As Integer, DestGrpId As Integer, dStep As Double) As Integer + ' solo per superfici trimesh con poche facce (max4) + Dim nFacetCnt As Integer = EgtSurfTmFacetCount(SurfId) + If nFacetCnt > 4 Then + Return SurfId + End If + ' box della superficie + Dim b3Surf As New BBox3d + EgtGetBBox(SurfId, GDB_BB.STANDARD, b3Surf) + If b3Surf.IsEmpty() Or b3Surf.DimX() < 2 * dStep Then + Return SurfId + End If + ' recupero le facce e le divido in X + Dim dXmin As Double = b3Surf.Min().x - 1 + Dim dXmax As Double = b3Surf.Max().x + 1 + Dim nStep As Integer = CInt(Math.Floor((dXmax - dXmin) / dStep + 0.9)) + dStep = (dXmax - dXmin) / nStep + Dim NewSurfId As Integer = GDB_ID.NULL + For nF = 0 To nFacetCnt - 1 + Dim FacId As Integer = EgtCopySurfTmFacet(SurfId, nF, DestGrpId) + Dim b3Fac As New BBox3d + EgtGetBBox(FacId, GDB_BB.STANDARD, b3Fac) + Dim dX2 As Double = dXmin + For nI = 1 To nStep + Dim dX1 As Double = dX2 + dX2 = dX2 + dStep + If b3Fac.Min().x < dX2 And b3Fac.Max().x > dX1 Then + EgtCutSurfTmPlane(FacId, New Point3d(dX1, 0, 0), -Vector3d.X_AX, True) + EgtCutSurfTmPlane(FacId, New Point3d(dX2, 0, 0), Vector3d.X_AX, False) + Dim nCount As Integer = 0 + Dim LoopId As Integer = EgtExtractSurfTmFacetLoops(FacId, 0, DestGrpId, nCount) + EgtMergeCurvesInCurveCompo(LoopId, 0.001) + Dim TmpSurfId As Integer = EgtCreateSurfTmByFlatContour(DestGrpId, LoopId, 0.01) + EgtErase(LoopId) + If NewSurfId <> GDB_ID.NULL Then + NewSurfId = EgtCreateSurfTmBySewing(DestGrpId, 2, {NewSurfId, TmpSurfId}, True) + Else + NewSurfId = TmpSurfId + End If + EgtErase(FacId) + FacId = EgtCopySurfTmFacet(SurfId, nF, DestGrpId) + End If + Next + EgtErase(FacId) + Next + Return NewSurfId + End Function + + Private Function PartFilter(Part As Object) As Boolean + Dim CurrBTLPart As BTLPartVM = DirectCast(Part, BTLPartVM) + Dim bGroupOk As Boolean = True + Dim bSubGroupOk As Boolean = True + Dim bSectionOk As Boolean = True + Dim bSearchTextOk As Boolean = True + If SelSection <> SectionXMaterial.Empty AndAlso CurrBTLPart.Section <> SelSection Then bSectionOk = False + If SelGroup <> "" AndAlso CurrBTLPart.sGROUP <> SelGroup Then bGroupOk = False + If SelSubGroup <> "" AndAlso CurrBTLPart.sSTOREY <> SelSubGroup Then bSubGroupOk = False + If m_SelSearchParam.Id <> BTLPartParam.NULL AndAlso m_SearchText <> String.Empty AndAlso ( + (m_SelSearchParam.Id = BTLPartParam.PDN AndAlso CurrBTLPart.nPDN.ToString.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0) OrElse + (m_SelSearchParam.Id = BTLPartParam.NAM AndAlso CurrBTLPart.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) < 0)) Then + bSearchTextOk = False + End If + Dim bResult As Boolean = bSectionOk AndAlso bGroupOk AndAlso bSubGroupOk AndAlso bSearchTextOk + ' If Not bResult And CurrBTLPart.IsSelected Then CurrBTLPart.IsSelected = False + Return bResult + End Function + + Private Function GroupFilter(Group As Object) As Boolean + Dim CurrGroup As String = DirectCast(Group, String) + Dim bOk As Boolean = True + If CurrGroup <> "" AndAlso (SelSection <> SectionXMaterial.Empty OrElse SelSubGroup <> "" OrElse SearchText <> "") Then + bOk = m_BTLPartVMList.Any(Function(x) x.sGROUP = CurrGroup AndAlso + (SelSection = SectionXMaterial.Empty OrElse x.Section = SelSection) AndAlso + (SelSubGroup = "" OrElse x.sSTOREY = SelSubGroup) AndAlso + (SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0)) + End If + Return bOk + End Function + + Private Function SubGroupFilter(SubGroup As Object) As Boolean + Dim CurrSubGroup As String = DirectCast(SubGroup, String) + Dim bOk As Boolean = True + If CurrSubGroup <> "" AndAlso (SelSection <> SectionXMaterial.Empty OrElse SearchText <> "" OrElse SelGroup <> "") Then + bOk = m_BTLPartVMList.Any(Function(x) x.sGROUP = CurrSubGroup AndAlso + (SelSection = SectionXMaterial.Empty OrElse x.Section = SelSection) AndAlso + (SelGroup = "" OrElse x.sGROUP = SelGroup) AndAlso + (SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0)) + End If + Return bOk + End Function + + Private Function SectionFilter(Section As Object) As Boolean + Dim CurrSection As SectionXMaterial = DirectCast(Section, SectionXMaterial) + Dim bOk As Boolean = True + If CurrSection <> Section.Empty AndAlso (SelGroup <> "" OrElse SelSubGroup <> "" OrElse SearchText <> "") Then + bOk = m_BTLPartVMList.Any(Function(x) x.Section = CurrSection AndAlso + (SelGroup = "" OrElse x.sGROUP = SelGroup) AndAlso + (SelSubGroup = "" OrElse x.sSTOREY = SelSubGroup) AndAlso + (SearchText = "" OrElse Not x.sNAM.IndexOf(SearchText, StringComparison.InvariantCultureIgnoreCase) >= 0)) + End If + Return bOk + End Function + + Friend Sub UpdateSection(NewPartSection As SectionXMaterial, OldPartSection As SectionXMaterial) + If IsNothing(BTLPartVMList) Then Return + ' verifico se era unico con vecchia sezione + If Not m_BTLPartVMList.Any(Function(x) x.Section = OldPartSection) Then + ' nel caso seleziono filtro generico + SelSection = m_SectionList(0) + ' e poi lo cerco ed elimino + m_SectionList.FirstOrDefault(Function(x) x = OldPartSection) + m_SectionList.Remove(m_SectionList.FirstOrDefault(Function(x) x = OldPartSection)) + End If + ' verifico se esiste già nuova sezione + If Not m_SectionList.Any(Function(x) x = NewPartSection) Then + m_SectionList.Add(NewPartSection) + End If + End Sub + + ' funzione che aggiorna totale tempi a fine calcolo + Friend Sub CalcGlobalTime() + NotifyPropertyChanged(NameOf(sBTLTotTime)) + NotifyPropertyChanged(NameOf(sBTLDoneTime)) + NotifyPropertyChanged(NameOf(sBTLRemainingTime)) + End Sub + + ' funzione che aggiorna numero pezzi, volume e tempo totali + Friend Sub CalcGlobalUpdate() + NotifyPropertyChanged(NameOf(sBTLTotParts)) + NotifyPropertyChanged(NameOf(sBTLTotVolume)) + NotifyPropertyChanged(NameOf(sBTLTotTime)) + NotifyPropertyChanged(NameOf(sBTLDoneTime)) + NotifyPropertyChanged(NameOf(sBTLRemainingTime)) + End Sub + + ' funzione utilizata per aggiornare rot e flip dopo calcolo + Public Sub RefreshRotFlip() + For Each BTLPart In BTLPartVMList + If Not EgtGetInfo(BTLPart.nPartId, BTL_PRT_ROTATED, BTLPart.BTLPartM.nROTATED) Then + BTLPart.BTLPartM.nROTATED = 0 + End If + If Not EgtGetInfo(BTLPart.nPartId, BTL_PRT_INVERTED, BTLPart.BTLPartM.nINVERTED) Then + BTLPart.BTLPartM.nINVERTED = 0 + End If + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.sROTATED)) + BTLPart.NotifyPropertyChanged(NameOf(BTLPart.sINVERTED)) + Next + End Sub + +#End Region ' METHODS + +#Region "DeletePart" + + Public ReadOnly Property DeletePart_Command As ICommand + Get + If m_cmdDeletePart Is Nothing Then + m_cmdDeletePart = New Command(AddressOf DeletePart) + End If + Return m_cmdDeletePart + End Get + End Property + + Public Sub DeletePart() + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refBTLPartManagerVM.RemovePartCmd() + End Sub + +#End Region ' DeletePart + +#Region "ProjSetting" + + Public ReadOnly Property ProjSetting_Command As ICommand + Get + If m_cmdProjSetting Is Nothing Then + m_cmdProjSetting = New Command(AddressOf ProjSetting) + End If + Return m_cmdProjSetting + End Get + End Property + + Public Sub ProjSetting() + Dim x = 8 + End Sub + +#End Region ' ProjSetting + +#Region "EVENTS" + + Private Sub OnBTLPartAdded(sender As Object, e As BTLPartAddedEventArgs) + Dim BTLPartVM As BTLPartVM = New BTLPartVM(e.NewBTLPart, m_BTLStructureM) + m_BTLPartVMList.Add(BTLPartVM) + NotifyPropertyChanged(NameOf(BTLPartVMList)) + End Sub + + Private Sub OnBTLPartVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLPartVM As BTLPartVM In e.NewItems + AddHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLPartVM As BTLPartVM In e.OldItems + RemoveHandler BTLPartVM.PropertyChanged, AddressOf OnBTLPartVMPropertyChanged + m_BTLStructureM.BTLPartMList.Remove(BTLPartVM.BTLPartM) + Next + End If + End Sub + + Private Sub OnBTLPartVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case "bDO" + Case NameOf(sender.sMATERIAL) + If Not GroupList.Contains(sender.sMATERIAL) Then + GroupList.Add(sender.sMATERIAL) + End If + Case NameOf(sender.sW), NameOf(sender.sH), NameOf(sender.sL) + Case NameOf(sender.nDONE) + NotifyPropertyChanged(NameOf(sBTLDoneTime)) + NotifyPropertyChanged(NameOf(sBTLRemainingTime)) + Case NameOf(sender.bDO), NameOf(sender.sPriority) + NotifyPropertyChanged(NameOf(bDOALL)) + End Select + End Sub + +#End Region ' EVENTS + +End Class diff --git a/EgtBEAMWALL.Optimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml b/EgtBEAMWALL.Optimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml new file mode 100644 index 00000000..e0a034bb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/BeamMachiningsWindow/BeamMachiningsWindowV.xaml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..b380aec2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageV.xaml.vb @@ -0,0 +1,5 @@ +Public Class ConfigurationPageV + Private Sub ScrollViewer_Scroll(sender As Object, e As Primitives.ScrollEventArgs) + + End Sub +End Class diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb new file mode 100644 index 00000000..9e152b88 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -0,0 +1,1542 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core +Imports MS.Internal +Imports Ionic.Zip +Imports System.Globalization + +Public Class ConfigurationPageVM + Inherits VMBase + + Public Enum ConfigSubPages As Integer + GENERAL = 0 + QPARAMETERS = 1 + MACHINE = 2 + PDFEDITOR = 3 + End Enum + + Private m_QParametersModified As Boolean = False + Friend ReadOnly Property QParametersModified As Boolean + Get + Return m_QParametersModified + End Get + End Property + Friend Sub ResetQParametersModified() + m_QParametersModified = False + End Sub + + Private m_SelConfigSubPage As ConfigSubPages = ConfigSubPages.GENERAL + Public Property SelConfigSubPage As Integer + Get + Return m_SelConfigSubPage + End Get + Set(value As Integer) + m_SelConfigSubPage = value + If m_SelConfigSubPage = ConfigSubPages.GENERAL Then + SetGeneral_Visibility(Visibility.Visible) + SetParamaterQ_Visibility(Visibility.Collapsed) + SetPDFEditor_Visibility(Visibility.Collapsed) + ElseIf m_SelConfigSubPage = ConfigSubPages.QPARAMETERS Then + SetParamaterQ_Visibility(Visibility.Visible) + SetGeneral_Visibility(Visibility.Collapsed) + SetPDFEditor_Visibility(Visibility.Collapsed) + ElseIf m_SelConfigSubPage = ConfigSubPages.MACHINE Then + SetGeneral_Visibility(Visibility.Collapsed) + SetParamaterQ_Visibility(Visibility.Collapsed) + SetPDFEditor_Visibility(Visibility.Collapsed) + ElseIf m_SelConfigSubPage = ConfigSubPages.PDFEDITOR Then + SetPDFEditor_Visibility(Visibility.Visible) + SetGeneral_Visibility(Visibility.Collapsed) + SetParamaterQ_Visibility(Visibility.Collapsed) + End If + End Set + End Property + + ' flag modifica parametri Macchina + Friend bModifyMachParam As Boolean + + Public ReadOnly Property MachinePanelVM As MachinePanelVM + Get + Return Map.refMachinePanelVM + End Get + End Property + + Private m_ConfigMachTableList As New ObservableCollection(Of MachTable) + Public Property ConfigMachTableList As ObservableCollection(Of MachTable) + Get + Return m_ConfigMachTableList + End Get + Set(value As ObservableCollection(Of MachTable)) + m_ConfigMachTableList = value + End Set + End Property + + Public ReadOnly Property Custom_Visibility As Visibility + Get + If QBTLParamVMList(0).bIsP Then + Return Visibility.Collapsed + Else + Return Visibility.Visible + End If + End Get + End Property + + ' lista dei parametri Q di un Process + Private m_QBTLParamVMList_View As CollectionView = Nothing + Protected m_QBTLParamVMList As New ObservableCollection(Of QBTLParamVM) + Public Property QBTLParamVMList As ObservableCollection(Of QBTLParamVM) + Get + Return m_QBTLParamVMList + End Get + Set(value As ObservableCollection(Of QBTLParamVM)) + m_QBTLParamVMList = value + End Set + End Property + + Private m_PRCList As New ObservableCollection(Of PRC) + Public ReadOnly Property PRCList As ObservableCollection(Of PRC) + Get + Return m_PRCList + End Get + End Property + + Private m_LanguageList As New ObservableCollection(Of Language) + Public ReadOnly Property LanguageList As ObservableCollection(Of Language) + Get + Return m_LanguageList + End Get + End Property + + Private m_UnitMeasureList As List(Of String) = New List(Of String)({"inch", "mm"}) + Public ReadOnly Property UnitMeasureList As List(Of String) + Get + Return m_UnitMeasureList + End Get + End Property + + Private m_SelectedLanguage As Language + Public Property SelectedLanguage As Language + Get + Return m_SelectedLanguage + End Get + Set(value As Language) + If value IsNot m_SelectedLanguage Then + m_SelectedLanguage = value + End If + End Set + End Property + + Public Property SelMeasureUnit As Integer + Get + Return If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH) + End Get + Set(value As Integer) + ' salvo unità di misura precedente + Dim PrevMeasureUnit As MeasureUnitOpt = If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH) + If value <> PrevMeasureUnit Then + ' cambio unità di misura + EgtSetUiUnits(DirectCast(value, MeasureUnitOpt) = MeasureUnitOpt.MM) + End If + End Set + End Property + + Private m_SectionTime As Double + Public Property SectionTime As String + Get + Return DoubleToString(m_SectionTime, 5) + End Get + Set(value As String) + Dim dVal As Double = 0 + If StringToDoubleAdv(value, dVal, True) AndAlso dVal > 0 Then + m_SectionTime = dVal + End If + End Set + End Property + + Private m_PartTime As Double + Public Property PartTime As String + Get + Return DoubleToString(m_PartTime, 5) + End Get + Set(value As String) + Dim dVal As Double = 0 + If StringToDoubleAdv(value, dVal, True) AndAlso dVal > 0 Then + m_PartTime = dVal + End If + End Set + End Property + + Private m_bPrintLabel_IsChecked As Boolean + Public Property bPrintLabel_IsChecked As String + Get + Return m_bPrintLabel_IsChecked + End Get + Set(value As String) + m_bPrintLabel_IsChecked = value + End Set + End Property + + Private m_bBackupRunning As Boolean = False + Public ReadOnly Property bBackupRunning As Boolean + Get + Return m_bBackupRunning + End Get + End Property + + Private m_bRestoreRunning As Boolean = False + Public ReadOnly Property bRestoreRunning As Boolean + Get + Return m_bRestoreRunning + End Get + End Property + + Private m_bExternalBackupActive As Boolean + Public Property bExternalBackupActive As Boolean + Get + Return m_bExternalBackupActive + End Get + Set(value As Boolean) + m_bExternalBackupActive = value + WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALBACKUPACTIVE, If(m_bExternalBackupActive, 1, 0)) + End Set + End Property + + Private m_ExternalBackupFolderPath As String + Public Property ExternalBackupFolderPath As String + Get + Return m_ExternalBackupFolderPath + End Get + Set(value As String) + m_ExternalBackupFolderPath = value + WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, m_ExternalBackupFolderPath) + End Set + End Property + + Private m_ReminderList As New List(Of IdNameStruct)({New IdNameStruct(0, EgtMsg(61988)), New IdNameStruct(1, EgtMsg(61989)), New IdNameStruct(2, EgtMsg(61990)), New IdNameStruct(7, EgtMsg(61991)), New IdNameStruct(14, EgtMsg(61992)), New IdNameStruct(30, EgtMsg(61993))}) + Public ReadOnly Property ReminderList As List(Of IdNameStruct) + Get + Return m_ReminderList + End Get + End Property + + Private m_SelReminder As IdNameStruct + Public Property SelReminder As IdNameStruct + Get + Return m_SelReminder + End Get + Set(value As IdNameStruct) + m_SelReminder = value + WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_REMINDERFREQUENCY, m_SelReminder.Id) + End Set + End Property + + Private m_bGeneral_Visibility As Visibility = Visibility.Visible + Public ReadOnly Property General_Visibility As Visibility + Get + Return m_bGeneral_Visibility + End Get + End Property + Friend Sub SetGeneral_Visibility(value As Visibility) + m_bGeneral_Visibility = value + NotifyPropertyChanged(NameOf(General_Visibility)) + End Sub + + Private m_bParameterQ_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property ParameterQ_Visibility As Visibility + Get + Return m_bParameterQ_Visibility + End Get + End Property + Friend Sub SetParamaterQ_Visibility(value As Visibility) + m_bParameterQ_Visibility = value + NotifyPropertyChanged(NameOf(ParameterQ_Visibility)) + End Sub + + Private m_bMachine_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property Machine_Visibility As Visibility + Get + Return m_bMachine_Visibility + End Get + End Property + Friend Sub SetMachine_Visibility(value As Visibility) + m_bMachine_Visibility = value + NotifyPropertyChanged(NameOf(Machine_Visibility)) + End Sub + + Private m_bPDFEditor_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property PDFEditor_Visibility As Visibility + Get + Return m_bPDFEditor_Visibility + End Get + End Property + Friend Sub SetPDFEditor_Visibility(value As Visibility) + m_bPDFEditor_Visibility = value + NotifyPropertyChanged(NameOf(PDFEditor_Visibility)) + End Sub + + Friend m_MachineParameter_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property MachineParameter_Visibility As Visibility + Get + Return m_MachineParameter_Visibility + End Get + End Property + Friend Sub SetMachineParameter_Visibility(value As Visibility) + m_MachineParameter_Visibility = value + NotifyPropertyChanged(NameOf(MachineParameter_Visibility)) + End Sub + + '' Lista delle versioni del programma + 'Private m_ProgramVersionList As New List(Of DTO.ReleaseDTO) + 'Public ReadOnly Property ProgramVersionList As List(Of DTO.ReleaseDTO) + ' Get + ' Return m_ProgramVersionList + ' End Get + 'End Property + 'Friend Sub SetProgramVersionList(value As List(Of DTO.ReleaseDTO)) + ' m_ProgramVersionList = value + ' NotifyPropertyChanged(NameOf(ProgramVersionList)) + 'End Sub + + '' Item selezionato dalla lista delle versioni del programma + 'Private m_ProgramVersionListItem As DTO.ReleaseDTO + 'Public Property ProgramVersionListItem As DTO.ReleaseDTO + ' Get + ' Return m_ProgramVersionListItem + ' End Get + ' Set(value As DTO.ReleaseDTO) + ' m_ProgramVersionListItem = value + ' If Not IsNothing(m_ProgramVersionListItem) Then SetLinkVersionView(m_ProgramVersionListItem.UrlChangelog) + ' NotifyPropertyChanged(NameOf(ProgramVersionListItem)) + ' End Set + 'End Property + + ' Link della versione del programma + Private m_LinkVersionView As String + Public ReadOnly Property LinkVersionView As String + Get + Return m_LinkVersionView + End Get + End Property + Friend Sub SetLinkVersionView(value As String) + m_LinkVersionView = value + NotifyPropertyChanged(NameOf(LinkVersionView)) + End Sub + + ' Gestisce se attivare il pulsante che permette di collegarsi al link della versione + Private m_LinkVersionIsEnable As Boolean + Public ReadOnly Property LinkVersionIsEnable As Boolean + Get + Return m_LinkVersionIsEnable + End Get + End Property + Friend Sub SetLinkVersionIsEnable(value As Boolean) + m_LinkVersionIsEnable = value + NotifyPropertyChanged(NameOf(LinkVersionIsEnable)) + End Sub + + ' Gestisce la visibilita' della datagrid che mostra le versioni del programma + Private m_ProgramVersionListVisibility As Visibility + Public ReadOnly Property ProgramVersionListVisibility As Visibility + Get + Return m_ProgramVersionListVisibility + End Get + End Property + Friend Sub SetProgramVersionListVisibility(value As Visibility) + m_ProgramVersionListVisibility = value + NotifyPropertyChanged(NameOf(ProgramVersionListVisibility)) + End Sub + + Public ReadOnly Property ActualVersion As String + Get + Return EgtBEAMWALL.Core.Configuration.ActualVersion + End Get + End Property + + ' Definizione comandi + Private m_cmdSave As ICommand + Private m_cmdChooseExternalBackupFolderPath As ICommand + Private m_cmdBackup As ICommand + Private m_cmdRestore As ICommand + Private m_cmdGetAllRelease As ICommand + Private m_cmdLinkVersion As ICommand + Private m_cmdGetVersionFrom As ICommand + +#Region "Messages" + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61803) + End Get + End Property + + Public ReadOnly Property T_Msg As String + Get + Return EgtMsg(61804) + End Get + End Property + + Public ReadOnly Property PRC_Msg As String + Get + Return EgtMsg(61805) + End Get + End Property + + Public ReadOnly Property PND_Msg As String + Get + Return EgtMsg(6180) + End Get + End Property + + Public ReadOnly Property Type_Msg As String + Get + Return EgtMsg(61850) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61608) + End Get + End Property + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property Default_Msg As String + Get + Return EgtMsg(61802) + End Get + End Property + + Public ReadOnly Property Min_Msg As String + Get + Return EgtMsg(61616) + End Get + End Property + + Public ReadOnly Property Max_Msg As String + Get + Return EgtMsg(61617) + End Get + End Property + + Public ReadOnly Property CurrentLanguage_Msg As String + Get + Return EgtMsg(6501) + End Get + End Property + + Public ReadOnly Property LanguageAdvert_Msg As String + Get + Return EgtMsg(6502) + End Get + End Property + + Public ReadOnly Property MMUnits_Msg As String + Get + Return EgtMsg(6540) + End Get + End Property + + Public ReadOnly Property Nesting_Msg As String + Get + Return EgtMsg(61829) + End Get + End Property + + Public ReadOnly Property SectionTime_Msg As String + Get + Return EgtMsg(61806) + End Get + End Property + + Public ReadOnly Property PartTime_Msg As String + Get + Return EgtMsg(61807) + End Get + End Property + + Public ReadOnly Property DisplayIndex_Msg As String + Get + Return EgtMsg(61842) + End Get + End Property + + Public ReadOnly Property ColumnName_Msg As String + Get + Return EgtMsg(61843) + End Get + End Property + + Public ReadOnly Property CanUserReorder_Msg As String + Get + Return EgtMsg(61844) + End Get + End Property + + Public ReadOnly Property CanUserResize_Msg As String + Get + Return EgtMsg(61845) + End Get + End Property + + Public ReadOnly Property CanUserSort_Msg As String + Get + Return EgtMsg(61846) + End Get + End Property + + Public ReadOnly Property IsReadOnly_Msg As String + Get + Return EgtMsg(61847) + End Get + End Property + + Public ReadOnly Property Visible_Msg As String + Get + Return EgtMsg(61848) + End Get + End Property + + Public ReadOnly Property PrintLabel_Msg As String + Get + Return EgtMsg(61894) + End Get + End Property + + Public ReadOnly Property General_Msg As String + Get + Return EgtMsg(62535).ToUpper() + End Get + End Property + + Public ReadOnly Property ParameterQ_Msg As String + Get + Return EgtMsg(62536).ToUpper() + End Get + End Property + + Public ReadOnly Property Machine_Msg As String + Get + Return EgtMsg(62537).ToUpper() + End Get + End Property + + Public ReadOnly Property PDFEditor_Msg As String + Get + Return EgtMsg(62538).ToUpper() + End Get + End Property + + ' Messaggi Versione + + Public ReadOnly Property CtrlVersion_Msg As String + Get + Return EgtMsg(61739).ToUpper() + End Get + End Property + + Public ReadOnly Property ActVersion_Msg As String + Get + Return EgtMsg(61740) + End Get + End Property + + Public ReadOnly Property AllVersion_Msg As String + Get + Return EgtMsg(61741) + End Get + End Property + + Public ReadOnly Property VersionFrom_Msg As String + Get + Return EgtMsg(61742) + End Get + End Property + + Public ReadOnly Property NumVersion_Msg As String + Get + Return EgtMsg(61743) + End Get + End Property + + Public ReadOnly Property Version_Msg As String + Get + Return EgtMsg(61744) + End Get + End Property + + Public ReadOnly Property DateVersion_Msg As String + Get + Return EgtMsg(61745) + End Get + End Property + + Public ReadOnly Property StateVersion_Msg As String + Get + Return EgtMsg(61746) + End Get + End Property + +#End Region ' Messages + +#Region "Constructor" + + Sub New() + ' imposto riferimento in Map + Map.SetRefConfigurationPageVM(Me) + ' Leggo nome lingua corrente + Dim sLanguage As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sLanguage) + ' Leggo elenco lingue disponibili da file ini e imposto lingua corrente + Dim nIndex As Integer = 1 + While True + Dim ReadLanguage As Language = GetMainPrivateProfileLanguage(S_LANGUAGES, K_LANGUAGE & nIndex) + If IsNothing(ReadLanguage) Then Exit While + m_LanguageList.Add(ReadLanguage) + If String.Compare(ReadLanguage.Name, sLanguage, True) = 0 Then + m_SelectedLanguage = ReadLanguage + End If + nIndex += 1 + End While + ' Inizializzo la lingua corrente + m_SelectedLanguage = m_LanguageList(0) + Dim sMsgName As String = String.Empty + IniFile.GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sMsgName) + For Each Language In m_LanguageList + If Language.Name = sMsgName Then + m_SelectedLanguage = Language + Exit For + End If + Next + ' leggo SectionTime e PartTime + GetMainPrivateProfileString(S_NEST, K_SECTIONTIME, "", SectionTime) + GetMainPrivateProfileString(S_NEST, K_PARTTIME, "", PartTime) + m_bPrintLabel_IsChecked = (GetMainPrivateProfileInt(S_PRINTER, K_ENABLE, 0) <> 0) + ' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione + ConfigMachTableList = CurrentMachine.MachTableList + ' carico i parametri Q dei Process letti dall'ini + GetQParamsList() + ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + If Not IsNothing(QBTLParamVMList) Then + QBTLParamVMList.Clear() + End If + For Each PRCItem In PRCList + For Each QBTLParam In PRCItem.QBTLParamVMList + QBTLParamVMList.Add(QBTLParam) + Next + Next + NotifyPropertyChanged(NameOf(QBTLParamVMList)) + ' setto il grouping a 2 livelli (GRP e, sotto, PRC col nome completo) per la DataGrid + m_QBTLParamVMList_View = CollectionViewSource.GetDefaultView(m_QBTLParamVMList) + m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.GroupType))) + m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.ghDesc))) + ' leggo dati per backup + GetMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, "", m_ExternalBackupFolderPath) + Dim nDefaultReminderFrequency As Integer = GetMainPrivateProfileInt(S_BACKUPANDRESTORE, K_REMINDERFREQUENCY, 1) + SelReminder = m_ReminderList.FirstOrDefault(Function(x) x.Id = nDefaultReminderFrequency) + Dim nExternalBackupActive As Integer = GetMainPrivateProfileInt(S_BACKUPANDRESTORE, K_EXTERNALBACKUPACTIVE, 0) + m_bExternalBackupActive = nExternalBackupActive > 0 + SetMachineParameter_Visibility(Visibility.Collapsed) + SetMachine_Visibility(Visibility.Collapsed) + ' Setto pulsante link versioni a false + SetLinkVersionIsEnable(False) + ' Setto la datagrid non visibile + SetProgramVersionListVisibility(Visibility.Hidden) + NotifyPropertyChanged(NameOf(bExternalBackupActive)) + End Sub + +#End Region ' Constructor + +#Region "COMMANDS" + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub Save() + VerifyConfigPageModification() + End Sub + +#End Region ' SaveCommand + +#Region "ChooseExternalBackupFolderPath" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property ChooseExternalBackupFolderPath_Command As ICommand + Get + If m_cmdChooseExternalBackupFolderPath Is Nothing Then + m_cmdChooseExternalBackupFolderPath = New Command(AddressOf ChooseExternalBackupFolderPath) + End If + Return m_cmdChooseExternalBackupFolderPath + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub ChooseExternalBackupFolderPath() + Dim FileDialog As New Microsoft.Win32.SaveFileDialog() With {.InitialDirectory = m_ExternalBackupFolderPath, + .CheckFileExists = False, + .CheckPathExists = False, + .DefaultExt = ".folder", + .OverwritePrompt = False, + .FileName = "Select this ", + .Title = "Backup & Restore File Path"} + If FileDialog.ShowDialog() Then + m_ExternalBackupFolderPath = Path.GetDirectoryName(FileDialog.FileName) + WriteMainPrivateProfileString(S_BACKUPANDRESTORE, K_EXTERNALFILEPATH, m_ExternalBackupFolderPath) + NotifyPropertyChanged(NameOf(ExternalBackupFolderPath)) + End If + End Sub + +#End Region ' ChooseExternalBackupFolderPath + +#Region "Backup" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property Backup_Command As ICommand + Get + If m_cmdBackup Is Nothing Then + m_cmdBackup = New Command(AddressOf BackupCmd) + End If + Return m_cmdBackup + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub BackupCmd() + Backup(True) + End Sub + + Public Sub Backup(bLoadingWindow As Boolean) + m_bBackupRunning = True + ' verifico se esiste cartella backup, altrimenti la creo + Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\Backup" + If Directory.Exists(sBackupFolder) Then + ' verifico se devo cancellare backup vecchi + Dim nBackupCount As Integer = 0 + Dim YearDirList() As String = Directory.GetDirectories(sBackupFolder) + For YearIndex = YearDirList.Length - 1 To 0 Step -1 + Dim nYear As Integer = 0 + Integer.TryParse(Path.GetFileName(YearDirList(YearIndex)), nYear) + Dim sYearDir As String = sBackupFolder & "\" & nYear + Dim MonthDirList() As String = Directory.GetDirectories(sYearDir) + For MonthIndex = MonthDirList.Length - 1 To 0 Step -1 + Dim nMonth As Integer = 0 + Integer.TryParse(Path.GetFileName(MonthDirList(MonthIndex)), nMonth) + Dim sMonthDir As String = sYearDir & "\" & nMonth + Dim DayDirList() As String = Directory.GetDirectories(sMonthDir) + For DayIndex = DayDirList.Length - 1 To 0 Step -1 + Dim nDay As Integer = 0 + Integer.TryParse(Path.GetFileName(DayDirList(DayIndex)), nDay) + If nBackupCount > 3 Then + Directory.Delete(sBackupFolder & "\" & nYear & "\" & nMonth & "\" & nDay, True) + End If + Next + DayDirList = Directory.GetDirectories(sMonthDir) + If IsNothing(DayDirList) OrElse DayDirList.Length = 0 Then + Directory.Delete(sMonthDir) + End If + Next + MonthDirList = Directory.GetDirectories(sYearDir) + If IsNothing(MonthDirList) OrElse MonthDirList.Length = 0 Then + Directory.Delete(sYearDir) + End If + Next + Else + Directory.CreateDirectory(sBackupFolder) + End If + sBackupFolder &= "\" & DateTime.Now().Year + If Not Directory.Exists(sBackupFolder) Then + Directory.CreateDirectory(sBackupFolder) + End If + sBackupFolder &= "\" & DateTime.Now().Month + If Not Directory.Exists(sBackupFolder) Then + Directory.CreateDirectory(sBackupFolder) + End If + sBackupFolder &= "\" & DateTime.Now().Day + If Not Directory.Exists(sBackupFolder) Then + Directory.CreateDirectory(sBackupFolder) + End If + sBackupFolder &= "\" & DateTime.Now().ToString("yyyyMMddHHmmss") & ".bwbck" + Dim sBackupZipPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\DbBackup.zip" + ' apro finestra di caricamento + If bLoadingWindow Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.BACKUP, 2, EgtMsg(63022), EgtMsg(63023), 15) ' Backup ' Database backup + Dim bOk As Boolean = True + ' backup del Db corrente + Try + DataLayer.DbConfig.DataBaseDumpToFile(sBackupZipPath) + Catch ex As Exception + MessageBox.Show(EgtMsg(62103), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) + bOk = False + End Try + If bOk AndAlso File.Exists(sBackupZipPath) Then + If bLoadingWindow Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.BACKUP, 2, EgtMsg(63024), 15, 100) ' Projects backup + ' backup dei progetti correnti + Try + Using zip As New Ionic.Zip.ZipFile(sBackupFolder, Console.Out) + zip.AlternateEncodingUsage = ZipOption.Always + zip.AlternateEncoding = Text.Encoding.UTF8 + zip.CompressionMethod = CompressionMethod.None + ' aggiungo Db + zip.AddItem(sBackupZipPath, "") + ' aggiungo cartella progetti + Dim sProjectFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\" + Dim sKey As String = "" + EgtGetKeyInfo(sKey) + sKey = sKey.Replace(" ", "") + Dim sUserFolder As String = "" + If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then + sUserFolder = sKey.Substring(3, 6) + sProjectFolder &= sUserFolder + End If + zip.AddItem(sProjectFolder, sUserFolder) + ' salvo lo zip + zip.Save() + End Using + Catch ex As Exception + MessageBox.Show(EgtMsg(62103), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) + bOk = False + End Try + End If + ' se esiste zip del Db, lo elimino + If File.Exists(sBackupZipPath) Then + File.Delete(sBackupZipPath) + End If + ' se richiesto faccio copia su external source + If m_bExternalBackupActive Then + If Directory.Exists(m_ExternalBackupFolderPath) Then + CopyForExternalBackup(sBackupFolder, m_ExternalBackupFolderPath) + Else + MessageBox.Show(EgtMsg(62104), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' External folder does not exist or is not reachable! Copy to external folder impossible! + End If + End If + 'chiudo finestra di caricamento + If bLoadingWindow Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.BACKUP) + m_bBackupRunning = False + End Sub + + Private Async Sub CopyForExternalBackup(sBackupFile As String, sExternalBackupFolder As String) + Using SourceStream As FileStream = File.Open(sBackupFile, FileMode.Open) + Dim sExternalBackupFile As String = sExternalBackupFolder & "\" & Path.GetFileName(sBackupFile) + Using DestinationStream As FileStream = File.Create(sExternalBackupFile) + Await SourceStream.CopyToAsync(DestinationStream) + End Using + End Using + End Sub + +#End Region ' Backup + +#Region "Restore" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property Restore_Command As ICommand + Get + If m_cmdRestore Is Nothing Then + m_cmdRestore = New Command(AddressOf Restore) + End If + Return m_cmdRestore + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub Restore() + ' recupero processo del supervisore + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + ' verifico che sia chiuso + If localProc.Length > 0 Then + MessageBox.Show(EgtMsg(62105), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) ' Please verify the machine is stoped and close the supervisor before proceding with the restore operation! + Return + End If + m_bRestoreRunning = True + ' verifico se esiste backup + Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir & "\Backup" + Dim nYear As Integer = 0 + Dim nMonth As Integer = 0 + Dim nDay As Integer = 0 + Dim sRestorePath As String = "" + If Directory.Exists(sBackupFolder) Then + Dim YearDirList() As String = Directory.GetDirectories(sBackupFolder) + For YearIndex = YearDirList.Length - 1 To 0 Step -1 + nYear = 0 + Integer.TryParse(Path.GetFileName(YearDirList(YearIndex)), nYear) + Dim sYearDir As String = sBackupFolder & "\" & nYear + Dim MonthDirList() As String = Directory.GetDirectories(sYearDir) + For MonthIndex = MonthDirList.Length - 1 To 0 Step -1 + nMonth = 0 + Integer.TryParse(Path.GetFileName(MonthDirList(MonthIndex)), nMonth) + Dim sMonthDir As String = sYearDir & "\" & nMonth + Dim DayDirList() As String = Directory.GetDirectories(sMonthDir) + For DayIndex = DayDirList.Length - 1 To 0 Step -1 + nDay = 0 + Integer.TryParse(Path.GetFileName(DayDirList(DayIndex)), nDay) + Dim sDayDir As String = sMonthDir & "\" & nDay + Dim VersionList() As String = Directory.GetFiles(sDayDir) + If VersionList.Length > 0 Then + Dim nMaxVersion As Int64 = VersionList.Max(Function(x) Int64.Parse(Path.GetFileNameWithoutExtension(x))) + sRestorePath = sDayDir & "\" & nMaxVersion & ".bwbck" + Exit For + End If + Next + If Not String.IsNullOrEmpty(sRestorePath) Then Exit For + Next + If Not String.IsNullOrEmpty(sRestorePath) Then Exit For + Next + End If + If String.IsNullOrEmpty(sRestorePath) Then + MessageBox.Show(EgtMsg(62106), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Restore impossible! Last backup not found! + End If + If MessageBox.Show(String.Format(EgtMsg(62107), nYear, nMonth, nDay), EgtMsg(15002), MessageBoxButton.OKCancel, MessageBoxImage.Warning) <> MessageBoxResult.OK Then 'Are you sure you want to restore the last backup from {0}\{1}\{2}? If you proceed you will lose actual data! + m_bRestoreRunning = False + Return + End If + Dim bDoBackup = False + Select Case MessageBox.Show(EgtMsg(62108), EgtMsg(15003), MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' Do you want to do a backup of the current project before proceding with the restore? + Case MessageBoxResult.Yes + bDoBackup = True + Case MessageBoxResult.No + bDoBackup = False + Case MessageBoxResult.Cancel + MessageBox.Show(EgtMsg(62109), EgtMsg(15002), MessageBoxButton.OK, MessageBoxImage.Warning) + m_bRestoreRunning = False + Return + End Select + ' apro finestra di caricamento + LoadingWndHelper.OpenLoadingWnd(ActiveIds.RESTORE, 3, EgtMsg(63025), EgtMsg(63026), If(bDoBackup, 40, 10)) ' Restore ' Database Restore + If bDoBackup Then + Backup(False) + End If + ' recupero cartella corrente dei progetti + Dim sProjectFolder As String = Map.refMainWindowVM.MainWindowM.sDataDir + Dim sKey As String = "" + EgtGetKeyInfo(sKey) + sKey = sKey.Replace(" ", "") + Dim sUserFolder As String = "" + If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then + sUserFolder = sKey.Substring(3, 6) + End If + If Directory.Exists(sProjectFolder & "\" & sUserFolder) Then + ' elimino cartella dei progetti + Directory.Delete(sProjectFolder & "\" & sUserFolder, True) + End If + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.RESTORE, 2, EgtMsg(63027), If(bDoBackup, 40, 10), 80) ' Restore data extraction + ' estraggo lo zip nella cartella Temp + Dim sRestoreDir As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\Restore" + If Directory.Exists(sRestoreDir) Then + Directory.Delete(sRestoreDir, True) + End If + Directory.CreateDirectory(sRestoreDir) + Dim bOk As Boolean = True + ' apro file zip + Try + Using zip As New Ionic.Zip.ZipFile(sRestorePath, Console.Out) + ' estraggo file da zip + zip.ExtractAll(sRestoreDir) + End Using + Catch ex1 As Exception + EgtOutLog("Error! Impossible importing Recovery file " & sRestorePath & "!") + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show(EgtMsg(62110), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Impossible importing Recovery file! + bOk = False + End Try + Dim sBackupTempPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\DbRestore" + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.RESTORE, 3, EgtMsg(63028), 80, 100) ' Database restore + If bOk Then + ' restore del Db + Try + DataLayer.DbConfig.DataBaseRestoreFromFile(sRestoreDir & "\DbBackup.zip", "", sBackupTempPath) + Catch ex As Exception + MessageBox.Show(EgtMsg(62111), EgtMsg(15001), MessageBoxButton.OK, MessageBoxImage.Error) ' Restore failed! Impossible to restore the backup Database + bOk = False + End Try + End If + If File.Exists(sRestoreDir & "\DbBackup.zip") Then + File.Delete(sRestoreDir & "\DbBackup.zip") + End If + If bOk Then + ' sposto il backup al posto giusto + Directory.Move(sRestoreDir & "\" & sUserFolder, sProjectFolder & "\" & sUserFolder) + End If + If Directory.Exists(sRestoreDir) Then + Directory.Delete(sRestoreDir) + End If + LoadingWndHelper.CloseLoadingWnd(ActiveIds.RESTORE) + m_bRestoreRunning = False + End Sub + +#End Region ' Restore + + '#Region "GetAllReleaseCommand" + + ' ''' + ' ''' Comando che restituisce tutte le versioni del programma + ' ''' + ' Public ReadOnly Property GetAllReleaseCommand As ICommand + ' Get + ' If m_cmdGetAllRelease Is Nothing Then + ' m_cmdGetAllRelease = New Command(AddressOf GetAllRelease) + ' End If + ' Return m_cmdGetAllRelease + ' End Get + ' End Property + + ' ''' + ' ''' Funzione che restituisce tutte le versioni del programma + ' ''' + ' Public Async Sub GetAllRelease() + ' Dim bOk As Boolean = EgtBEAMWALL.Core.Configuration.GetComunication() + ' ' Controllo se la comunicazione è avvenuta con successo + ' If bOk Then + ' ' Setto la datagrid visibile + ' SetProgramVersionListVisibility(Visibility.Visible) + ' ' Recupero la lista di tutte le versioni del programma + ' SetProgramVersionList(Await EgtBEAMWALL.Core.Configuration.m_commLib.ReleaseGetAllAsync(K_BEAMWALL)) + ' End If + ' End Sub + + '#End Region ' ReleaseCommand + + '#Region "GetVersionFromCommand" + + ' ''' + ' ''' Comando che restituisce le versioni del programma filtrate + ' ''' + ' Public ReadOnly Property GetVersionFromCommand As ICommand + ' Get + ' If m_cmdGetVersionFrom Is Nothing Then + ' m_cmdGetVersionFrom = New Command(AddressOf GetVersionFrom) + ' End If + ' Return m_cmdGetVersionFrom + ' End Get + ' End Property + + ' ''' + ' ''' Funzione che restituisce le versioni del programma filtrate + ' ''' + ' Public Async Sub GetVersionFrom() + ' Dim bOk As Boolean = EgtBEAMWALL.Core.Configuration.GetComunication() + ' ' Controllo se la comunicazione è avvenuta con successo + ' If bOk Then + ' ' Setto la datagrid visibile + ' SetProgramVersionListVisibility(Visibility.Visible) + ' ' Recupero la lista delle versioni del programma filtrate per quella attuale + ' SetProgramVersionList(Await EgtBEAMWALL.Core.Configuration.m_commLib.ReleaseGetFiltLimitAsync(K_BEAMWALL, EgtBEAMWALL.Core.Configuration.ActualVersion, "2.5.15.0")) + ' End If + ' End Sub + + '#End Region ' ReleaseCommand + +#End Region ' COMMANDS + +#Region "Methods" + + ' funzione che scrive i parametri modificati sul file INI + Public Sub WriteMachParams() + If String.IsNullOrWhiteSpace(CurrentMachine.sMachParamIniFile) OrElse Not File.Exists(CurrentMachine.sMachParamIniFile) Then + EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable") + Return + End If + For Each MachTableItem In ConfigMachTableList + For Each MachParamItem In MachTableItem.MachParamList + If MachParamItem.IsModified Then + Dim sMachParamType As String = String.Empty + Select Case MachParamItem.nType + Case MachParamType.DOUBLE_ + sMachParamType = "d" + Case MachParamType.STRING_ + sMachParamType = "s" + Case MachParamType.LENGTH + sMachParamType = "l" + End Select + Dim MachParamString As String = sMachParamType & "," & MachParamItem.sName & "," & MachParamItem.sValue & "," & MachParamItem.sDescription + Dim bOk = WriteMachPrivateProfileString(MachParamItem.nParentTable, MachParamItem.nParamIndex, MachParamString) + If Not bOk Then + MessageBox.Show(EgtMsg(61859), EgtMsg(30007)) + Return + End If + MachParamItem.IsModifiedReset() + End If + Next + Next + ' se macchina di tipo BOTH copio il file appena scritto nella cartella Beam nella cartella Wall o viceversa + If CurrentMachine.nType = MachineType.BOTH Then + If CurrentMachine.sMachParamIniFile.Contains("\" & K_BEAM & "\") Then + File.Copy(CurrentMachine.sMachParamIniFile, CurrentMachine.sMachParamIniFile.Replace("\" & K_BEAM & "\", "\" & K_WALL & "\"), True) + Else + File.Copy(CurrentMachine.sMachParamIniFile, CurrentMachine.sMachParamIniFile.Replace("\" & K_WALL & "\", "\" & K_BEAM & "\"), True) + End If + End If + End Sub + + ' funzione che scrive i parametri modificati sul file LUA + Private Function WriteMachParamsLua() As Boolean + If String.IsNullOrWhiteSpace(CurrentMachine.sMachParamIniFile) OrElse Not File.Exists(CurrentMachine.sMachParamIniFile) Then + EgtOutLog("Impossible loading Mach parameters: MachData.ini file not found or not readable") + Return False + End If + ' inizio routine di scrittura + Dim NewTs3DataFileContent = New List(Of String) + Dim sMachineStr As String = String.Empty + For Each MachTableItem In ConfigMachTableList + NewTs3DataFileContent.Add("local " & MachTableItem.sName & " = {") + sMachineStr &= " " & MachTableItem.sName & "=" & MachTableItem.sName & "," + For Each MachParamItem In MachTableItem.MachParamList + NewTs3DataFileContent.Add(" " & MachParamItem.sName & "=" & MachParamItem.sValue & ",") + Next + NewTs3DataFileContent.Last().TrimEnd(",") + NewTs3DataFileContent.Add("}") + NewTs3DataFileContent.Add("") + Next + NewTs3DataFileContent.Add("local Machine = {" & sMachineStr.TrimEnd(",") & "}") + NewTs3DataFileContent.Add("return Machine") + Dim FilePath As String + If Map.refMainWindowVM.MainWindowM.bMachConfig Then + FilePath = CurrentMachine.sMachDir & "\" & If(CurrentMachine.nType = MachineType.BEAM, BEAM_DIR, WALL_DIR) & "\" & EBWDATA_FILE + Else + FilePath = CurrentMachine.sMachDir & "\" & If(CurrentMachine.nType = MachineType.BEAM, BEAM_DIR, WALL_DIR) & "\" & TS3DATA_FILE + End If + Dim sBakFilePath As String = Path.ChangeExtension(FilePath, ".bak") + If File.Exists(sBakFilePath) Then File.Delete(sBakFilePath) + If File.Exists(FilePath) Then File.Move(FilePath, sBakFilePath) + File.WriteAllLines(FilePath, NewTs3DataFileContent, Text.Encoding.UTF8) + ' se macchina di tipo BOTH copio il file appena scritto nella cartella Wall nella cartella Beam + If CurrentMachine.nType = MachineType.BOTH Then + Dim DestinationFilePath As String + If Map.refMainWindowVM.MainWindowM.bMachConfig Then + DestinationFilePath = CurrentMachine.sMachDir & "\" & BEAM_DIR & "\" & EBWDATA_FILE + Else + DestinationFilePath = CurrentMachine.sMachDir & "\" & BEAM_DIR & "\" & TS3DATA_FILE + End If + sBakFilePath = Path.ChangeExtension(DestinationFilePath, ".bak") + If File.Exists(sBakFilePath) Then File.Delete(sBakFilePath) + File.Move(DestinationFilePath, Path.ChangeExtension(DestinationFilePath, ".bak")) + File.Copy(FilePath, DestinationFilePath, True) + End If + Return True + End Function + + ' funzione che verifica la modifica dei valori in Configurazione e ne chiede il salvataggio + Friend Sub VerifyConfigPageModification() + Dim bExitFor = False + Select Case m_SelConfigSubPage + Case ConfigSubPages.GENERAL + ' aggiorno tutti i valori senza verificare modifiche + WriteMainPrivateProfileString(S_GENERAL, K_MESSAGES, m_SelectedLanguage.Name) + WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, SelMeasureUnit.ToString()) + WriteMainPrivateProfileString(S_NEST, K_SECTIONTIME, DoubleToString(m_SectionTime, 5)) + WriteMainPrivateProfileString(S_NEST, K_PARTTIME, DoubleToString(m_PartTime, 5)) + WriteMainPrivateProfileString(S_PRINTER, K_ENABLE, If(m_bPrintLabel_IsChecked, 1, 0)) + Case ConfigSubPages.QPARAMETERS + ' ciclo sui parametri Q + Dim bAskToSaveDefaultValues As Boolean = False + For Each PRCItem In PRCList + For Each QParam In PRCItem.QBTLParamVMList + If QParam.bIsModified Then + bAskToSaveDefaultValues = True + ' esco dai For + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + ' se nel ciclo è stato trovato almeno un valore modificato chiedo il salvataggio + If bAskToSaveDefaultValues Then + If MessageBox.Show(EgtMsg(61861), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' se si è scelto di salvare i valori li scrivo + WriteProcessParams(PRCList.ToList()) + m_QParametersModified = True + End If + ' in ogni caso ricarico i valori (in modo da resettare i flag di modifica) + GetQParamsList() + ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + If Not IsNothing(QBTLParamVMList) Then + QBTLParamVMList.Clear() + End If + For Each PRCItem In PRCList + For Each QBTLParam In PRCItem.QBTLParamVMList + QBTLParamVMList.Add(QBTLParam) + Next + Next + NotifyPropertyChanged(NameOf(QBTLParamVMList)) + End If + Case ConfigSubPages.MACHINE + ' ciclo sui parametri Macchina + For Each MachTableItem In ConfigMachTableList + For Each MachParamItem In MachTableItem.MachParamList + If MachParamItem.IsModified Then + If MessageBox.Show(EgtMsg(61860), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' scrivo i parametri Macchina + WriteMachParams() + WriteMachParamsLua() + Else + ' se da non salvare li resetto ed esco dai For + CreateMachParams() + bExitFor = True + Exit For + End If + End If + Next + If bExitFor Then Exit For + Next + End Select + End Sub + + ' funzione che verifica l'inserimento della password quando si edita un parametro Macchina + Friend Function VerifyConfigPagePassword() As Boolean + Dim InputPwdWnd As Object + ' Display message, title, and default value. + Dim InputPwdWndVM As New InputPwdWndVM() + If bOnlyProd Then + InputPwdWnd = New OnlyProdInputPwdWndV(Application.Current.MainWindow, InputPwdWndVM) + Else + InputPwdWnd = New InputPwdWndV(Application.Current.MainWindow, InputPwdWndVM) + End If + If InputPwdWnd.ShowDialog() Then + ' Lettura PWD dall'INI e confronto + Dim sPwdIni As String = String.Empty + If GetMainPrivateProfileString(S_MACH, K_PASSWORD, "", sPwdIni) <> 0 Then + If sPwdIni = InputPwdWndVM.sPassword Then Return True + End If + End If + Return False + End Function + + Public Sub GetQParamsList() + m_PRCList.Clear() + ' carico lista process + Dim TempPRCList As New ObservableCollection(Of Integer) + ' prima cerco i process L (GRPType = 0) + Dim GRPType As Integer = 0 + GetBeamPrivateProfileProcessList(GRPType, TempPRCList) + For Each PRC In TempPRCList + ' leggo gruppi + Dim GRPList As New ObservableCollection(Of Integer) + GetBeamPrivateProfileGRPList(GRPType, PRC, GRPList) + m_PRCList.Add(New PRC(If(GRPList.Count > 0, GRPList(0), GRPType), PRC, GetBeamPrivateProfileName(GRPType, PRC), CreateProcessParams(GRPType, PRC, False))) + Next + ' ora cerco i process T (GRPType = 1) + GRPType = 1 + GetBeamPrivateProfileProcessList(GRPType, TempPRCList) + For Each PRC In TempPRCList + ' leggo gruppi + Dim GRPList As New ObservableCollection(Of Integer) + GetBeamPrivateProfileGRPList(GRPType, PRC, GRPList) + m_PRCList.Add(New PRC(If(GRPList.Count > 0, GRPList(0), GRPType), PRC, GetBeamPrivateProfileName(GRPType, PRC), CreateProcessParams(GRPType, PRC, False))) + Next + End Sub + + ' funzione che crea l'elenco dei parametri P o Q di un Process + Public Function CreateProcessParams(GRPType As Integer, PRC As Integer, IsP As Boolean) + Dim ParamIndex As Integer = 1 + Dim TempList As New List(Of QBTLParamVM) + Dim NewBTLParam As BTLParamM = Nothing + ' leggo tutti i parametri P o Q del Process + ParamIndex = 1 + TempList = New List(Of QBTLParamVM) + If IsP Then + While BTLIniFile.GetBeamPrivateProfileParam(GRPType, PRC, 0, IsP, ParamIndex, Nothing, NewBTLParam) + TempList.Add(New QBTLParamVM(NewBTLParam, GRPType, PRC)) + ParamIndex += 1 + End While + Else + If CurrentMachine.nType = MachineType.BOTH Then + ' se macchina di tipo BOTH carico i Q di tipo BEAM e poi di tipo WALL + While BTLIniFile.GetBeamPrivateProfileParam(GRPType, PRC, IsP, ParamIndex, Nothing, NewBTLParam, MachineType.BEAM) + TempList.Add(New QBTLParamVM(NewBTLParam, GRPType, PRC)) + ParamIndex += 1 + End While + ParamIndex = 1 + While BTLIniFile.GetBeamPrivateProfileParam(GRPType, PRC, IsP, ParamIndex, Nothing, NewBTLParam, MachineType.WALL) + TempList.Add(New QBTLParamVM(NewBTLParam, GRPType, PRC)) + ParamIndex += 1 + End While + Else + ' altrimenti carico solo quelli corrispondenti al tipo della macchina selezionata + While BTLIniFile.GetBeamPrivateProfileParam(GRPType, PRC, IsP, ParamIndex, Nothing, NewBTLParam, CurrentMachine.nType) + TempList.Add(New QBTLParamVM(NewBTLParam, GRPType, PRC)) + ParamIndex += 1 + End While + End If + End If + Return TempList + End Function + + ' funzione che scrive l'elenco dei parametri P o Q di un Process + Public Sub WriteProcessParams(PRCList As List(Of PRC)) + For Each PRCItem In PRCList + Dim nPRCParamIndex As Integer = 1 + Dim sPrevType As String = String.Empty + For Each PRCParam In PRCItem.QBTLParamVMList + If PRCParam.bIsModified Then + ' costruisco la stringa da scrivere nel parametro + Dim sType As String = "" + If PRCParam.nType = 1 Then + sType = "d" + ElseIf PRCParam.nType = 4 Then + sType = "l" + End If + If sPrevType <> PRCParam.sBWType Then nPRCParamIndex = 1 + Dim sPRCParam As String = sType & "," & If(PRCParam.bIsP, "P", "Q") & PRCParam.nId.ToString("D2") & "," & PRCParam.sMin & "," & PRCParam.sMax & "," & PRCParam.sDefault & "," & PRCParam.sDescription + WritePrivateProfileString(CalcBeamPrivateProfileGRP(PRCItem.nGRP) & "." & PRCItem.nPRC, If(PRCParam.bIsP, "P", "Q" & PRCParam.sBWType) & nPRCParamIndex, sPRCParam, m_sBTLIniFile) + ' resetto il flag per il valore modificato + PRCParam.bIsModified = False + End If + sPrevType = PRCParam.sBWType + nPRCParamIndex += 1 + Next + Next + End Sub + + +#End Region ' Methods + +End Class + +Public Class MachParam + Inherits VMBase + + ' table a cui appartiene il parametro + Private m_nParentTable As Integer + Friend ReadOnly Property nParentTable As Integer + Get + Return m_nParentTable + End Get + End Property + + ' indice del parametro + Private m_nParamIndex As Integer + Friend ReadOnly Property nParamIndex As Integer + Get + Return m_nParamIndex + End Get + End Property + + ' tipo della variabile + Private m_nType As MachParamType + Friend ReadOnly Property nType As MachParamType + Get + Return m_nType + End Get + End Property + + ' parametri da struttura + Private m_sName As String + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + ' parametri da geometria + Private m_IsModifiedValue As Boolean = False + Private m_dValue As Double + Private m_sValue As String + Public Property sValue As String + Get + Select Case nType + Case MachParamType.DOUBLE_ + Return DoubleToString(m_dValue, 3) + Case MachParamType.LENGTH + Return LenToString(m_dValue, 3) + Case Else ' stringhe + Return m_sValue + End Select + Return If(nType = MachParamType.LENGTH, LenToString(m_dValue, 3), DoubleToString(m_dValue, 3)) + End Get + Set(value As String) + Dim dNewValue As Double + ' verifico se valore immesso è diverso dall'originale + If nParentTable > 0 Then + ' trasformo valori + Select Case nType + Case MachParamType.DOUBLE_ + StringToDoubleAdv(value, dNewValue, True) + m_IsModifiedValue = Math.Abs(dNewValue - m_dValue) > EPS_SMALL + Case MachParamType.LENGTH + StringToLenAdv(value, dNewValue, True) + m_IsModifiedValue = Math.Abs(dNewValue - m_dValue) > EPS_SMALL + Case Else + m_IsModifiedValue = String.Compare(value, m_sValue) <> 0 + End Select + End If + ' se valore immesso è diverso e password non inserita + If m_IsModifiedValue AndAlso Not Map.refConfigurationPageVM.bModifyMachParam Then + Map.refConfigurationPageVM.bModifyMachParam = Map.refConfigurationPageVM.VerifyConfigPagePassword() + If Not Map.refConfigurationPageVM.bModifyMachParam Then + NotifyPropertyChanged(NameOf(sValue)) + m_IsModifiedValue = False + Return + End If + End If + + Select Case nType + Case MachParamType.DOUBLE_, MachParamType.LENGTH + UpdateParamValue(dNewValue, "") + Case Else + UpdateParamValue(0, value) + End Select + + If Map.refConfigurationPageVM.bModifyMachParam Then Map.refConfigurationPageVM.VerifyConfigPageModification() + End Set + End Property + Public Property dValue As Double + Get + Return m_dValue + End Get + Set(value As Double) + m_dValue = value + NotifyPropertyChanged(NameOf(sValue)) + End Set + End Property + + ' descrizione del parametro + Private m_sDescription As String + Public Property sDescription As String + Get + Return m_sDescription + End Get + Set(value As String) + m_sDescription = value + End Set + End Property + + Private Sub StdInit(nParentTable As Integer, nParamIndex As Integer, Type As MachParamType, sName As String, sDescription As String) + m_nParentTable = nParentTable + m_nParamIndex = nParamIndex + m_nType = Type + m_sName = sName + m_sDescription = MsgToString(sDescription) + End Sub + + ' new per double e length + Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, dValue As Double, sDescription As String) + StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) + m_dValue = dValue 'sValue = DoubleToString(dValue, 3) + End Sub + + ' new per stringhe + Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, sDescription As String) + StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) + End Sub + + ' new per parametro vuoto + Sub New(nType As MachParamType, nParamIndex As Integer, sParamName As String) + StdInit(Nothing, nParamIndex, nType, sParamName, "") + End Sub + + Friend Sub UpdateParamValue(dNewValue As Double, sNewValue As String, Optional bDraw As Boolean = True) + Select Case nType + Case MachParamType.DOUBLE_, MachParamType.LENGTH + m_dValue = dNewValue + Case MachParamType.STRING_ + m_sValue = sNewValue + End Select + End Sub + + Public ReadOnly Property IsModified() As Boolean + Get + Return m_IsModifiedValue + End Get + End Property + + Public Sub IsModifiedReset() + m_IsModifiedValue = False + End Sub + +End Class + +Public Class MachTable + Inherits VMBase + + ' nome della table + Private m_sName As String + Public Property sName As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Private m_MachParamList As New ObservableCollection(Of MachParam) + Public Property MachParamList As ObservableCollection(Of MachParam) + Get + Return m_MachParamList + End Get + Set(value As ObservableCollection(Of MachParam)) + m_MachParamList = value + End Set + End Property + + Sub New(Name As String, ParamList As ObservableCollection(Of MachParam)) + sName = Name + MachParamList = ParamList + End Sub + +End Class + +' Tipo parametro nel file di configurazione Macchina +Public Enum MachParamType As Integer + DOUBLE_ = 1 + STRING_ = 2 + COMBO = 3 + LENGTH = 4 + CHECKBOX = 5 +End Enum + +' Converte il parametro isPermitted +'Public Class IsPermittedConverter +' Implements IValueConverter + +' Public Function Convert(value As Object, targetType As System.Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert +' Dim isPermitted As DTO.ReleaseDTO = TryCast(value, DTO.ReleaseDTO) +' Select Case isPermitted.IsPermitted +' Case 0 +' Return "Versione Acquistata" +' Case 1 +' Return "Versione da Acquistare" +' Case Else +' Return Nothing +' End Select +' Return Nothing +' End Function + +' Public Function ConvertBack(value As Object, targetType As System.Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack +' Throw New NotImplementedException() +' End Function +'End Class diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/General_ConfigurationPageV.xaml b/EgtBEAMWALL.Optimizer/ConfigurationPage/General_ConfigurationPageV.xaml new file mode 100644 index 00000000..1a271f72 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/General_ConfigurationPageV.xaml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml.vb new file mode 100644 index 00000000..2415658b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml.vb @@ -0,0 +1,2 @@ +Public Class OnlyProdConfigurationPageV +End Class diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml b/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml new file mode 100644 index 00000000..4fa8b2bb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..32248de7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/QParameter_ConfigurationPageV.xaml.vb @@ -0,0 +1,3 @@ +Public Class QParameter_ConfigurationPageV + +End Class diff --git a/EgtBEAMWALL.Optimizer/Constants/ConstWarehouseIni.vb b/EgtBEAMWALL.Optimizer/Constants/ConstWarehouseIni.vb new file mode 100644 index 00000000..de087fa2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Constants/ConstWarehouseIni.vb @@ -0,0 +1,16 @@ +Module ConstWarehouseIni + + Public Const WH_BASIC_INI_FILE_NAME As String = "Basic.ini" + Public Const WH_MEDIUM_INI_FILE_NAME As String = "Medium.ini" + + Public Const K_CURRENTL As String = "CurrentL" + Public Const K_CURRENTS As String = "CurrentS" + Public Const K_STARTOFFSET As String = "StartOffset" + Public Const K_KERF As String = "Kerf" + Public Const K_OFFSET As String = "Offset" + Public Const K_QUANTITY As String = "Quantity" + Public Const K_L As String = "L" + Public Const K_S As String = "S" + Public Const K_RANGE As String = "Range" + +End Module diff --git a/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/IListItemConverter.vb b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/IListItemConverter.vb new file mode 100644 index 00000000..6b198868 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/IListItemConverter.vb @@ -0,0 +1,4 @@ +Public Interface IListItemConverter + Function Convert(ByVal masterListItem As Object) As Object + Function ConvertBack(ByVal targetListItem As Object) As Object +End Interface diff --git a/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/MultiSelectorBehaviours.vb b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/MultiSelectorBehaviours.vb new file mode 100644 index 00000000..40dc6208 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/MultiSelectorBehaviours.vb @@ -0,0 +1,78 @@ +Imports System.Windows.Controls.Primitives + +Public Class MultiSelectorBehaviours + + Public Shared ReadOnly SynchronizedSelectedItemsProperty As DependencyProperty = DependencyProperty.RegisterAttached("SynchronizedSelectedItems", GetType(IList), GetType(MultiSelectorBehaviours), New PropertyMetadata(Nothing, AddressOf OnSynchronizedSelectedItemsChanged)) + Public Shared ReadOnly SynchronizationManagerProperty As DependencyProperty = DependencyProperty.RegisterAttached("SynchronizationManager", GetType(SynchronizationManager), GetType(MultiSelectorBehaviours), New PropertyMetadata(Nothing)) + + + Public Shared Function GetSynchronizedSelectedItems(ByVal dependencyObject As DependencyObject) As IList + Return CType(dependencyObject.GetValue(SynchronizedSelectedItemsProperty), IList) + End Function + + Public Shared Sub SetSynchronizedSelectedItems(ByVal dependencyObject As DependencyObject, ByVal value As IList) + dependencyObject.SetValue(SynchronizedSelectedItemsProperty, value) + End Sub + + Private Shared Function GetSynchronizationManager(ByVal dependencyObject As DependencyObject) As SynchronizationManager + Return CType(dependencyObject.GetValue(SynchronizationManagerProperty), SynchronizationManager) + End Function + + Private Shared Sub SetSynchronizationManager(ByVal dependencyObject As DependencyObject, ByVal value As SynchronizationManager) + dependencyObject.SetValue(SynchronizationManagerProperty, value) + End Sub + + Private Shared Sub OnSynchronizedSelectedItemsChanged(ByVal dependencyObject As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs) + If e.OldValue IsNot Nothing Then + Dim synchronizer As SynchronizationManager = GetSynchronizationManager(dependencyObject) + synchronizer.StopSynchronizing() + SetSynchronizationManager(dependencyObject, Nothing) + End If + + Dim list As IList = TryCast(e.NewValue, IList) + Dim selector As Selector = TryCast(dependencyObject, Selector) + + If list IsNot Nothing AndAlso selector IsNot Nothing Then + Dim synchronizer As SynchronizationManager = GetSynchronizationManager(dependencyObject) + + If synchronizer Is Nothing Then + synchronizer = New SynchronizationManager(selector) + SetSynchronizationManager(dependencyObject, synchronizer) + End If + + synchronizer.StartSynchronizingList() + End If + End Sub + + Private Class SynchronizationManager + Private ReadOnly _multiSelector As Selector + Private _synchronizer As TwoListSynchronizer + + Friend Sub New(ByVal selector As Selector) + _multiSelector = selector + End Sub + + Public Sub StartSynchronizingList() + Dim list As IList = GetSynchronizedSelectedItems(_multiSelector) + + If list IsNot Nothing Then + _synchronizer = New TwoListSynchronizer(GetSelectedItemsCollection(_multiSelector), list) + _synchronizer.StartSynchronizing() + End If + End Sub + + Public Sub StopSynchronizing() + _synchronizer.StopSynchronizing() + End Sub + + Public Shared Function GetSelectedItemsCollection(ByVal selector As Selector) As IList + If TypeOf selector Is MultiSelector Then + Return (TryCast(selector, MultiSelector)).SelectedItems + ElseIf TypeOf selector Is ListBox Then + Return (TryCast(selector, ListBox)).SelectedItems + Else + Throw New InvalidOperationException("Target object has no SelectedItems property to bind.") + End If + End Function + End Class +End Class diff --git a/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/TwoListSynchronizer.vb b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/TwoListSynchronizer.vb new file mode 100644 index 00000000..f443d530 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/DataGridMultiselectManaging/TwoListSynchronizer.vb @@ -0,0 +1,163 @@ +Imports System.Collections.Specialized + +Public Class TwoListSynchronizer + Implements IWeakEventListener + + Private Shared ReadOnly DefaultConverter As IListItemConverter = New DoNothingListItemConverter() + Private ReadOnly _masterList As IList + Private ReadOnly _masterTargetConverter As IListItemConverter + Private ReadOnly _targetList As IList + + Public Sub New(ByVal masterList As IList, ByVal targetList As IList, ByVal masterTargetConverter As IListItemConverter) + _masterList = masterList + _targetList = targetList + _masterTargetConverter = masterTargetConverter + End Sub + + Public Sub New(ByVal masterList As IList, ByVal targetList As IList) + Me.New(masterList, targetList, DefaultConverter) + End Sub + + Private Delegate Sub ChangeListAction(ByVal list As IList, ByVal e As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + + Public Sub StartSynchronizing() + ListenForChangeEvents(_masterList) + ListenForChangeEvents(_targetList) + SetListValuesFromSource(_masterList, _targetList, New Converter(Of Object, Object)(AddressOf ConvertFromMasterToTarget)) + + If Not TargetAndMasterCollectionsAreEqual() Then + SetListValuesFromSource(_targetList, _masterList, New Converter(Of Object, Object)(AddressOf ConvertFromTargetToMaster)) + End If + End Sub + + Public Sub StopSynchronizing() + StopListeningForChangeEvents(_masterList) + StopListeningForChangeEvents(_targetList) + End Sub + + Public Function ReceiveWeakEvent(ByVal managerType As Type, ByVal sender As Object, ByVal e As EventArgs) As Boolean Implements IWeakEventListener.ReceiveWeakEvent + HandleCollectionChanged(TryCast(sender, IList), TryCast(e, NotifyCollectionChangedEventArgs)) + Return True + End Function + + Protected Sub ListenForChangeEvents(ByVal list As IList) + If TypeOf list Is INotifyCollectionChanged Then + CollectionChangedEventManager.AddListener(TryCast(list, INotifyCollectionChanged), Me) + End If + End Sub + + Protected Sub StopListeningForChangeEvents(ByVal list As IList) + If TypeOf list Is INotifyCollectionChanged Then + CollectionChangedEventManager.RemoveListener(TryCast(list, INotifyCollectionChanged), Me) + End If + End Sub + + Private Sub AddItems(ByVal list As IList, ByVal e As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + Dim itemCount As Integer = e.NewItems.Count + + For i As Integer = 0 To itemCount - 1 + Dim insertionPoint As Integer = e.NewStartingIndex + i + + If insertionPoint > list.Count Then + list.Add(converter(e.NewItems(i))) + Else + list.Insert(insertionPoint, converter(e.NewItems(i))) + End If + Next + End Sub + + Private Function ConvertFromMasterToTarget(ByVal masterListItem As Object) As Object + Return If(_masterTargetConverter Is Nothing, masterListItem, _masterTargetConverter.Convert(masterListItem)) + End Function + + Private Function ConvertFromTargetToMaster(ByVal targetListItem As Object) As Object + Return If(_masterTargetConverter Is Nothing, targetListItem, _masterTargetConverter.ConvertBack(targetListItem)) + End Function + + Private Sub HandleCollectionChanged(ByVal sender As Object, ByVal e As NotifyCollectionChangedEventArgs) + Dim sourceList As IList = TryCast(sender, IList) + + Select Case e.Action + Case NotifyCollectionChangedAction.Add + PerformActionOnAllLists(AddressOf AddItems, sourceList, e) + Case NotifyCollectionChangedAction.Move + PerformActionOnAllLists(AddressOf MoveItems, sourceList, e) + Case NotifyCollectionChangedAction.Remove + PerformActionOnAllLists(AddressOf RemoveItems, sourceList, e) + Case NotifyCollectionChangedAction.Replace + PerformActionOnAllLists(AddressOf ReplaceItems, sourceList, e) + Case NotifyCollectionChangedAction.Reset + UpdateListsFromSource(TryCast(sender, IList)) + Case Else + End Select + End Sub + + Private Sub MoveItems(ByVal list As IList, ByVal e As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + RemoveItems(list, e, converter) + AddItems(list, e, converter) + End Sub + + Private Sub PerformActionOnAllLists(ByVal action As ChangeListAction, ByVal sourceList As IList, ByVal collectionChangedArgs As NotifyCollectionChangedEventArgs) + If sourceList Is _masterList Then + PerformActionOnList(_targetList, action, collectionChangedArgs, New Converter(Of Object, Object)(AddressOf ConvertFromMasterToTarget)) + Else + PerformActionOnList(_masterList, action, collectionChangedArgs, New Converter(Of Object, Object)(AddressOf ConvertFromTargetToMaster)) + End If + End Sub + + Private Sub PerformActionOnList(ByVal list As IList, ByVal action As ChangeListAction, ByVal collectionChangedArgs As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + StopListeningForChangeEvents(list) + action(list, collectionChangedArgs, converter) + ListenForChangeEvents(list) + End Sub + + Private Sub RemoveItems(ByVal list As IList, ByVal e As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + If e.OldItems.Count = 1 AndAlso e.OldStartingIndex <= list.Count - 1 Then + list.RemoveAt(e.OldStartingIndex) + Else + For Each Item In e.OldItems + list.Remove(Item) + Next + End If + End Sub + + Private Sub ReplaceItems(ByVal list As IList, ByVal e As NotifyCollectionChangedEventArgs, ByVal converter As Converter(Of Object, Object)) + RemoveItems(list, e, converter) + AddItems(list, e, converter) + End Sub + + Private Sub SetListValuesFromSource(ByVal sourceList As IList, ByVal targetList As IList, ByVal converter As Converter(Of Object, Object)) + StopListeningForChangeEvents(targetList) + targetList.Clear() + + For Each o As Object In sourceList + targetList.Add(converter(o)) + Next + + ListenForChangeEvents(targetList) + End Sub + + Private Function TargetAndMasterCollectionsAreEqual() As Boolean + Return _masterList.Cast(Of Object)().SequenceEqual(_targetList.Cast(Of Object)().[Select](Function(item) ConvertFromTargetToMaster(item))) + End Function + + Private Sub UpdateListsFromSource(ByVal sourceList As IList) + If sourceList Is _masterList Then + SetListValuesFromSource(_masterList, _targetList, New Converter(Of Object, Object)(AddressOf ConvertFromMasterToTarget)) + Else + SetListValuesFromSource(_targetList, _masterList, New Converter(Of Object, Object)(AddressOf ConvertFromTargetToMaster)) + End If + End Sub + + Friend Class DoNothingListItemConverter + Implements IListItemConverter + + Public Function Convert(ByVal masterListItem As Object) As Object Implements IListItemConverter.Convert + Return masterListItem + End Function + + Public Function ConvertBack(ByVal targetListItem As Object) As Object Implements IListItemConverter.ConvertBack + Return targetListItem + End Function + End Class +End Class diff --git a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj b/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj new file mode 100644 index 00000000..ba291f10 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj @@ -0,0 +1,1273 @@ + + + + Debug + AnyCPU + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + EgtBEAMWALL.Optimizer + EgtBEAMWALL.Optimizer + v4.7.2 + Custom + true + true + + + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + EgtBEAMWALL.Optimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x86 + true + + + true + bin\x86\Release\ + EgtBEAMWALL.Optimizer.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x86 + true + + + + ..\EgtBEAMWALL.Core\bin\Debug\EgtBEAMWALL.Core.dll + + + ..\EgtBEAMWALL.DataLayer\bin\Debug\EgtBEAMWALL.DataLayer.dll + + + ..\ExtLibs\EgtUILib.dll + + + ..\ExtLibs\EgtWPFLib5.dll + + + + + + + + + + + + + + + + + + + + + + + 4.0 + + + ..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0\Windows.winmd + + + + + + + + + + MSBuild:Compile + Designer + + + AboutBoxV.xaml + + + + + NewAddFeatureWndV.xaml + + + AddPartWndV.xaml + + + + OnlyProdAddPartWndV.xaml + + + AddRawPartWndV.xaml + + + + OnlyProdAddRawPartWndV.xaml + + + AddSectionXMaterialWndV.xaml + + + + Application.xaml + Code + + + NestingRunningWndV.xaml + + + + OnlyProdNestingRunningWndV.xaml + + + + + + OnlyProdProjectV.xaml + + + + OnlyProdOptimizePanelV.xaml + + + OptimizePanelV.xaml + + + + OnlyProdPartInRawPartManagerV.xaml + + + PartInRawPartManagerV.xaml + + + + PartInRawPartManagerWndV.xaml + + + OnlyProdPartManagerV.xaml + + + PartManagerV.xaml + + + + PartParametersWndV.xaml + + + + PdfViewer.xaml + + + + ProdManagerV.xaml + + + + ProdProjManagerV.xaml + + + + + + + OnlyProdProjectTypeWndV.xaml + + + ProjectTypeWndV.xaml + + + + ProjectV.xaml + + + + ProjManagerV.xaml + + + + OnlyProdRawPartManagerV.xaml + + + RawPartManagerV.xaml + + + + RawPartManagerWndV.xaml + + + + SceneHostV.xaml + + + + SetUpV.xaml + + + + OnlyProdShowBeamPanelV.xaml + + + ShowBeamPanelV.xaml + + + + OnlyProdShowPanelV.xaml + + + ShowPanelV.xaml + + + OnlyProdSpecialPanelV.xaml + + + SpecialPanelV.xaml + + + + OnlyProdStatisticsTimePanelV.xaml + + + StatisticsTimePanelV.xaml + + + + OptimizerStatisticsWndV.xaml + + + StatisticsWndV.xaml + + + OnlyProdOptimizerStatisticsV.xaml + + + OnlyProdPDFEditorV.xaml + + + OnlyProdStatisticsV.xaml + + + OptimizerStatisticsV.xaml + + + PDFEditorV.xaml + + + + + + StatisticsV.xaml + + + + + StatusBarV.xaml + + + + + ProdWndV.xaml + + + ProjWndV.xaml + + + + + + TopPanelV.xaml + + + + OnlyProdUpdateBTLWndV.xaml + + + OnlyProdUpdateOrAppendWndV.xaml + + + UpdateBTLWndV.xaml + + + + UpdateOrAppendWndV.xaml + + + + + + + Dictionary.xaml + + + + + + + + + + + + OnlyProdViewPanelV.xaml + + + ViewPanelV.xaml + + + OnlyProdWarehouseWndV.xaml + + + + WarehouseWndV.xaml + + + + + + + + + + + + + + + + + + + + + + + + + BlockedWndV.xaml + + + + BottomPanelV.xaml + + + + BTLDataWndV.xaml + + + + BTLPartManagerV.xaml + + + + OnlyProdBTLPartManagerV.xaml + + + + + + + CalcPanelV.xaml + + + + OnlyProdCalcPanelV.xaml + + + ChangeMaterialWndV.xaml + + + + ChangeParameterWndV.xaml + + + + ConfigurationPageV.xaml + + + + OnlyProdCheckVersionV.xaml + + + OnlyProdConfigurationPageV.xaml + + + + + + + FeatureListManagerV.xaml + + + + OnlyProdFeatureListManagerV.xaml + + + FeatureManagerV.xaml + + + + OnlyProdFeatureManagerV.xaml + + + FreeContourInputV.xaml + + + + OnlyProdFreeContourInputV.xaml + + + FreeContourManagerV.xaml + + + + OnlyProdFreeContourManagerV.xaml + + + InputPwdWndV.xaml + + + + OnlyProdInputPwdWndV.xaml + + + InstrumentPanelV.xaml + + + + OnlyProdInstrumentPanelV.xaml + + + BTLDataV.xaml + + + BTLPartListV.xaml + + + + + FeatureInPartInRawPartListV.xaml + + + + FeatureListV.xaml + + + + OnlyProdBTLPartListV.xaml + + + OnlyProdFeatureInPartInRawPartListV.xaml + + + OnlyProdFeatureListV.xaml + + + OnlyProdPartInRawPartListV.xaml + + + OnlyProdPParameterListV.xaml + + + OnlyProdQParameterListProdV.xaml + + + OnlyProdQParameterListV.xaml + + + OnlyProdRawPartListV.xaml + + + PartInRawPartListV.xaml + + + + PartParametersV.xaml + + + + PParameterListV.xaml + + + + + QParameterListV.xaml + + + + QParamListV.xaml + + + RawPartListV.xaml + + + + LeftPanelV.xaml + + + + OnlyProdLeftPanelV.xaml + + + + + + + MacroFeatureWndV.xaml + + + + NewMacroFeatureWnd.xaml + + + MainMenuV.xaml + + + + OnlyProdMainMenuV.xaml + + + + MainWindowV.xaml + + + + OnlyProdMainWindowV.xaml + + + MovePartInRawPartWndV.xaml + + + + OnlyProdMovePartInRawPartWndV.xaml + + + MultiCopyRawPartWndV.xaml + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8.5 + + + 1.16.0 + + + 6.4.4 + + + 3.21.9 + + + 1.3.5 + + + 10.0.26100.1742 + + + 8.0.21 + + + 13.0.1 + + + 5.0.1 + + + 1.50.5147 + + + 1.9.0 + + + 111.2.0 + + + 6.0.0 + + + 4.3.0 + + + 4.6.0 + + + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\EgtBEAMWALL.OptimizerR32.exe +IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\EgtBEAMWALL.OptimizerD32.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\EgtBEAMWALL.OptimizerR64.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\EgtBEAMWALL\EgtBEAMWALL.OptimizerD64.exe + + \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml new file mode 100644 index 00000000..70d02a60 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml @@ -0,0 +1,36 @@ + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml.vb new file mode 100644 index 00000000..4796b51e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class FeatureListManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerVM.vb b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerVM.vb new file mode 100644 index 00000000..3ba89550 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureListManager/FeatureListManagerVM.vb @@ -0,0 +1,371 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib.EgtInterface +Imports EgtWPFLib5 + +Public Class FeatureListManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property PartIsSelected As Boolean + Get + Return Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) + End Get + End Property + + Public ReadOnly Property FeatureIsSelected As Boolean + Get + Return PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) + End Get + End Property + + + Public ReadOnly Property CopyFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + Public ReadOnly Property MacroFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + Public ReadOnly Property AddFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not Map.refProjectVM.BTLStructureVM.SelBTLPartsCnt > 1 + End Get + End Property + + Public ReadOnly Property RemoveFeature_IsEnabled As Boolean + Get + Return Map.refBTLPartManagerVM.BTLPartManager_IsEnabled AndAlso PartIsSelected AndAlso FeatureIsSelected + End Get + End Property + + + Private m_cmdCopyFeature As ICommand + Private m_cmdMacroFeature As ICommand + Private m_cmdAddFeature As ICommand + Private m_cmdRemoveFeature As ICommand + +#End Region ' Fields & Properties + +#Region "Messages" + + Public ReadOnly Property CopyFeature_ToolTip As String + Get + Return EgtMsg(61908) + End Get + End Property + + Public ReadOnly Property MacroFeature_ToolTip As String + Get + Return EgtMsg(61909) + End Get + End Property + + Public ReadOnly Property AddFeature_ToolTip As String + Get + Return EgtMsg(61910) + End Get + End Property + + Public ReadOnly Property RemoveFeature_ToolTip As String + Get + Return EgtMsg(61911) + End Get + End Property + + +#End Region ' Messages + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefFeatureListManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub UpdateView() + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + End Sub + + Friend Sub SetLeftPanelIsEnabled(bIsEnabled As Boolean) + NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + End Sub + + Friend Sub PartShowAllChanged() + NotifyPropertyChanged(NameOf(AddFeature_IsEnabled)) + End Sub + + Friend Sub FeatureSelectionChanged() + NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + NotifyPropertyChanged(NameOf(RemoveFeature_IsEnabled)) + End Sub + + Private Sub CreateNewFeature(MacroListCount As Integer, nSelMacro As Integer, AddFeatureWndVM As AddFeatureWndVM, nNewFeatureId As Integer, bMacroFlag As Boolean, NewFeat As BTLFeatureM) + ' verifico se una Macro è selezionata + If MacroListCount > 0 AndAlso nSelMacro >= 0 Then + ' Creo nuova feature sulla base della Macro selezionata + ' Creo table e setto variabili + CreateMacroTable() + Dim bOk As Boolean + If AddFeatureWndVM.nSelMacroDefault >= 0 Then + bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroCustomFilePathList(nSelMacro)) + Else + bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(nSelMacro)) + End If + ' Leggo variabili + EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) + ' Reset lua + EgtLuaResetGlobVar("MACRO") + If Not bOk Then + MessageBox.Show(EgtMsg(61869), EgtMsg(30007)) + Return + End If + bMacroFlag = True + Else + ' Creo nuova feature (Macro non selezionata) + NewFeat = BTLFeatureM.CreateBTLFeature(AddFeatureWndVM.nSelPRC.nPRC, AddFeatureWndVM.nSelPRC.nGRP, AddFeatureWndVM.nSelPRC.nSIDE) + NewFeat.SetDefaultValues() + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + NewFeat.CalcParamArray(vPar, sPar, vParQ) + If NewFeat.nPRC = 900 Then NewFeat.sDES = "2" + ' aggiorno la feature con nuovo valore + EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, NewFeat.sDES, + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId(), + New Frame3d(), vPar, sPar, vParQ, GDB_ID.NULL, GDB_ID.NULL) + bMacroFlag = False + End If + ' se è stata creata + If nNewFeatureId <> GDB_ID.NULL Then + MyMachGroupPanelM.SetDuploModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' la aggiungo a struttura BTL corrente + NewFeat = BTLFeatureM.CreateBTLFeature(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM, nNewFeatureId) + If Not bMacroFlag Then NewFeat.SetDefaultValues() + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.AddBTLFeature(NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeat) + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End Sub + + Private Sub CreateMacroTable() + Dim nMacroW, nMacroH As Integer + If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM) Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 0 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 180 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 1 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 3 Then + nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW + nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH + Else + nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH + nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW + End If + ElseIf Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 90 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.nROTATED = 270 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 1 OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.m_SelBTLFeatureVM.nSelSIDE = 3 Then + nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH + nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW + Else + nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW + nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH + End If + Else + nMacroW = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW + nMacroH = Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH + End If + End If + + EgtLuaCreateGlobTable("MACRO") + EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) + EgtLuaSetGlobNumVar("MACRO.W", nMacroW) + EgtLuaSetGlobNumVar("MACRO.H", nMacroH) + EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "CopyFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyFeature_Command As ICommand + Get + If m_cmdCopyFeature Is Nothing Then + m_cmdCopyFeature = New Command(AddressOf CopyFeature) + End If + Return m_cmdCopyFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelPart) Then Return + Dim SelFeature As BTLFeatureVM = SelPart.SelBTLFeatureVM + If IsNothing(SelFeature) Then Return + ' creo copia + Dim NewFeature = SelFeature.Copy() + If Not IsNothing(NewFeature) Then + SelPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeature) + MyMachGroupPanelM.SetDuploModified(SelPart.nPartId) + End If + SelPart.ResetCalcPart() + End Sub + +#End Region ' CopyFeature + +#Region "MacroFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MacroFeature_Command As ICommand + Get + If m_cmdMacroFeature Is Nothing Then + m_cmdMacroFeature = New Command(AddressOf MacroFeature) + End If + Return m_cmdMacroFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MacroFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di creazione macro + Dim MacroFeatureWndVM As New MacroFeatureWndVM() + If bOnlyProd Then + Dim NewMacroFeatureWnd As New NewMacroFeatureWnd(Application.Current.MainWindow, MacroFeatureWndVM) + If NewMacroFeatureWnd.ShowDialog() Then + End If + Else + Dim MacroFeatureWnd As New MacroFeatureWndV(Application.Current.MainWindow, MacroFeatureWndVM) + If MacroFeatureWnd.ShowDialog() Then + End If + End If + End Sub + +#End Region ' MacroFeature + +#Region "AddFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property AddFeature_Command As ICommand + Get + If m_cmdAddFeature Is Nothing Then + m_cmdAddFeature = New Command(AddressOf AddFeature) + End If + Return m_cmdAddFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub AddFeature(ByVal param As Object) + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + ' apro finestra di definizione nuova feature + Dim AddFeatureWndVM As New AddFeatureWndVM() + Dim NewFeat As BTLFeatureM = Nothing + Dim nNewFeatureId As Integer = 0 + Dim bMacroFlag As Boolean = False + If bOnlyProd Then + Dim AddNewFeatureWnd As New NewAddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) + If AddNewFeatureWnd.ShowDialog() Then + ' verifico se una Macro è selezionata + If AddFeatureWndVM.nSelMacroDefault >= 0 Then + CreateNewFeature(AddFeatureWndVM.MacroDefaultList.Count, AddFeatureWndVM.nSelMacroDefault, AddFeatureWndVM, nNewFeatureId, bMacroFlag, NewFeat) + Else + CreateNewFeature(AddFeatureWndVM.MacroCustomList.Count, AddFeatureWndVM.nSelMacroCustom, AddFeatureWndVM, nNewFeatureId, bMacroFlag, NewFeat) + End If + End If + Else + Dim AddFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) + If AddFeatureWnd.ShowDialog() Then + ' verifico se una Macro è selezionata + CreateNewFeature(AddFeatureWndVM.MacroCustomList.Count, AddFeatureWndVM.nSelMacroCustom, AddFeatureWndVM, nNewFeatureId, bMacroFlag, NewFeat) + End If + End If + End Sub + +#End Region ' AddFeature + +#Region "RemoveFeature" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveFeature_Command As ICommand + Get + If m_cmdRemoveFeature Is Nothing Then + m_cmdRemoveFeature = New Command(AddressOf RemoveFeature) + End If + Return m_cmdRemoveFeature + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveFeature() + If IsNothing(ProjectManagerVM.CurrProj) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then Return + If EgtBeamEraseProcess(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId) Then + MyMachGroupPanelM.SetDuploModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) + ' rimuovo dalla lista feature + Dim Index As Integer = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.IndexOf(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) + If Index = 0 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 0 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(0) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + ElseIf Index = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 1 Then + If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 1 Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 2) + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing + End If + Else + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Index - 1) + End If + Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.RemoveAt(Index) + EgtDraw() + Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() + End If + End Sub + +#End Region ' RemoveFeature + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml b/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml new file mode 100644 index 00000000..ffc7386d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml @@ -0,0 +1,36 @@ + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml.vb new file mode 100644 index 00000000..ecb4d0f4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureListManager/OnlyProdFeatureListManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdFeatureListManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/FeatureManager/FeatureManagerV.xaml b/EgtBEAMWALL.Optimizer/FeatureManager/FeatureManagerV.xaml new file mode 100644 index 00000000..78f96f70 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FeatureManager/FeatureManagerV.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerV.xaml.vb new file mode 100644 index 00000000..48093a75 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class FreeContourManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerVM.vb b/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerVM.vb new file mode 100644 index 00000000..ff6c9262 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FreeContourManager/FreeContourManagerVM.vb @@ -0,0 +1,1335 @@ +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class FreeContourManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public Enum FreeContourTypes As Integer + ONE = 0 + ONEWITHANGLES = 1 + TWO = 2 + End Enum + Public Enum Paths As Integer + FIRST = 0 + SECOND = 1 + End Enum + + Private m_bPrevShowSolid As Boolean + + ' variabile che indica se il percorso deve essere chiuso + Private m_bClosedPathNeeded As Boolean = False + + ' variabile che indica se il progetto era modificato prima di modificare il percorso + Private m_bAlreadyModified As Boolean = False + + ' variabile che gestisce l'apertura della composita + Private m_bIsOpeningCurveCompo As Boolean + Public ReadOnly Property bIsOpeningCurveCompo As Boolean + Get + Return m_bIsOpeningCurveCompo + End Get + End Property + + Private m_bIsActive As Boolean = False + Public ReadOnly Property bIsActive As Boolean + Get + Return m_bIsActive + End Get + End Property + + Private m_nSelTextId As Integer = GDB_ID.NULL + ' parametro che indica se e' in corso l'editing di un angolo + Private m_bIsModifyingTextAngle As Boolean = False + Public ReadOnly Property bIsModifyingTextAngle As Boolean + Get + Return m_bIsModifyingTextAngle + End Get + End Property + ' parametro che indica se e' in corso il disegno di un percorso + Private m_bIsCreatingPath As Boolean = False + Public ReadOnly Property bIsCreatingPath As Boolean + Get + Return m_bIsCreatingPath + End Get + End Property + + Private m_TypeList As New List(Of String)({EgtMsg(62001), EgtMsg(62002), EgtMsg(62003)}) + Public Property TypeList As List(Of String) + Get + Return m_TypeList + End Get + Set(value As List(Of String)) + m_TypeList = value + End Set + End Property + + Private m_SelType As Integer + Public Property SelType As Integer + Get + Return m_SelType + End Get + Set(value As Integer) + ' se precedentemente impostato 2 percorsi + Select Case m_SelType + Case FreeContourTypes.ONEWITHANGLES + ' elimino layer testi angoli e layer copia + EgtErase(nSideAngTextLayer) + EgtErase(m_nNewPathCopyForSideAngleId) + nSideAngTextLayer = GDB_ID.NULL + m_TextAngle_Visibility = Visibility.Collapsed + NotifyPropertyChanged(NameOf(TextAngle_Visibility)) + Case FreeContourTypes.TWO + ' chiedo conferma + If MessageBox.Show(EgtMsg(61862), "", MessageBoxButton.YesNo, MessageBoxImage.Warning) <> MessageBoxResult.Yes Then + m_SelType = FreeContourTypes.TWO + NotifyPropertyChanged(NameOf(SelType)) + Return + Else + ' elimino secondo percorso + EgtErase(m_nNewSecondPathId) + m_PathList_Visibility = Visibility.Collapsed + NotifyPropertyChanged(NameOf(PathList_Visibility)) + End If + End Select + m_SelType = value + ' se nuova impostazione e' uno con angoli + Select Case m_SelType + Case FreeContourTypes.ONEWITHANGLES + ' creo testi angoli sul percorso + CreateSideAngText("") + m_TextAngle_Visibility = Visibility.Visible + Case FreeContourTypes.TWO + m_PathList_Visibility = Visibility.Visible + NotifyPropertyChanged(NameOf(PathList_Visibility)) + SelPath = Paths.FIRST + NotifyPropertyChanged(NameOf(SelPath)) + End Select + NotifyPropertyChanged(NameOf(TextAngle_Visibility)) + EgtDraw() + End Set + End Property + + Private m_PathList As New List(Of String)({EgtMsg(62004), EgtMsg(62005)}) + Public Property PathList As List(Of String) + Get + Return m_PathList + End Get + Set(value As List(Of String)) + m_PathList = value + End Set + End Property + + Private m_SelPath As Paths + Public Property SelPath As Integer + Get + Return m_SelPath + End Get + Set(value As Integer) + m_SelPath = value + Select Case m_SelPath + Case Paths.FIRST + EgtDeselectAll() + EgtResetMark(m_nNewSecondPathId) + If m_nNewPathId = GDB_ID.NULL OrElse EgtGetType(m_nNewPathId) = GDB_TY.NONE Then + m_Line2P_IsEnabled = True + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + Else + EgtSetMark(m_nNewPathId) + If m_Line2P_IsEnabled Then + m_Line2P_IsEnabled = False + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + End If + End If + Case Paths.SECOND + EgtDeselectAll() + EgtResetMark(m_nNewPathId) + If m_nNewSecondPathId = GDB_ID.NULL OrElse EgtGetType(m_nNewSecondPathId) = GDB_TY.NONE Then + m_Line2P_IsEnabled = True + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + Else + EgtSetMark(m_nNewSecondPathId) + If m_Line2P_IsEnabled Then + m_Line2P_IsEnabled = False + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + End If + End If + End Select + EgtDraw() + End Set + End Property + + Private m_Line2P_IsEnabled As Boolean = False + Public Property Line2P_IsEnabled As Boolean + Get + Return m_Line2P_IsEnabled + End Get + Set(value As Boolean) + m_Line2P_IsEnabled = value + End Set + End Property + + Private m_TextAngle_Visibility As Visibility = Visibility.Collapsed + Public Property TextAngle_Visibility As Visibility + Get + Return m_TextAngle_Visibility + End Get + Set(value As Visibility) + m_TextAngle_Visibility = value + End Set + End Property + + Private m_PathList_Visibility As Visibility = Visibility.Collapsed + Public Property PathList_Visibility As Visibility + Get + Return m_PathList_Visibility + End Get + Set(value As Visibility) + m_PathList_Visibility = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property Line2P_ToolTip As String + Get + Return EgtMsg(62006) + End Get + End Property + Public ReadOnly Property Delete_ToolTip As String + Get + Return EgtMsg(5223) + End Get + End Property + Public ReadOnly Property ArcFlip_ToolTip As String + Get + Return EgtMsg(5159) + End Get + End Property + Public ReadOnly Property ModifyCurve_ToolTip As String + Get + Return EgtMsg(5160) + End Get + End Property + Public ReadOnly Property AddPointCurve_ToolTip As String + Get + Return EgtMsg(5161) + End Get + End Property + Public ReadOnly Property RemovePointCurve_ToolTip As String + Get + Return EgtMsg(5162) + End Get + End Property + Public ReadOnly Property ChangeStart_ToolTip As String + Get + Return EgtMsg(5229) + End Get + End Property + Public ReadOnly Property InvertCurve_ToolTip As String + Get + Return EgtMsg(5228) + End Get + End Property + Public ReadOnly Property Move_ToolTip As String + Get + Return EgtMsg(5236) + End Get + End Property + Public ReadOnly Property Rotate_ToolTip As String + Get + Return EgtMsg(5237) + End Get + End Property + Public ReadOnly Property TextAngle_ToolTip As String + Get + Return EgtMsg(5249) + End Get + End Property + +#End Region ' Messages + + Friend SelPart As BTLPartVM + Friend SelFeature As BTLFeatureVM + Friend nSelPartId As Integer + Friend nSelFeatureId As Integer + Friend nProcessingLayerId As Integer + Friend nAuxId As Integer = 0 + Friend nSecondAuxId As Integer = 0 + Friend nOrigPathId As Integer = GDB_ID.NULL + Friend m_nNewPathId As Integer = GDB_ID.NULL + Friend m_nNewPathCopyForSideAngleId As Integer = GDB_ID.NULL + Friend nOrigSecondPathId As Integer = GDB_ID.NULL + Friend m_nNewSecondPathId As Integer = GDB_ID.NULL + Friend nSideAngTextLayer As Integer = GDB_ID.NULL + Friend SideAngValues As New List(Of SideAngle) + + ' Definizione comandi + Private m_cmdLine2P As ICommand + Private m_cmdDelete As ICommand + Private m_cmdModifyCurve As ICommand + Private m_cmdAddPointCurve As ICommand + Private m_cmdRemovePointCurve As ICommand + Private m_cmdArcflip As ICommand + Private m_cmdMove As ICommand + Private m_cmdRotate As ICommand + Private m_cmdMirror As ICommand + Private m_cmdScale As ICommand + Private m_cmdChangeStart As ICommand + Private m_cmdInvertCurve As ICommand + Private m_cmdTextAngle As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTORS" + + Sub New() + ' imposto riferimento in Map + Map.SetRefFreeContourManagerVM(Me) + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Friend Sub Open() + m_bIsActive = True + m_bAlreadyModified = EgtGetModified() + ' blocco funzionalita' interfaccia + Map.refProjectVM.ManageIsEnabled(False) + Map.refPartListVM.SetBTLPartListIsEnabled(False) + Map.refFeatureListVM.SetBTLFeatureListIsEnabled(False) + Map.refPParameterListVM.SetPParameterListIsEnabled(False) + Map.refQParameterListVM.SetQParameterListIsEnabled(False) + Map.refShowBeamPanelVM.SetShowSolid_IsEnabled(False) + Map.refShowBeamPanelVM.SetShowAll_IsEnabled(False) + 'resetto tutte le variabili + SelPart = Nothing + SelFeature = Nothing + nSelPartId = GDB_ID.NULL + nSelFeatureId = GDB_ID.NULL + nProcessingLayerId = GDB_ID.NULL + nAuxId = 0 + nSecondAuxId = 0 + nOrigPathId = GDB_ID.NULL + m_nNewPathId = GDB_ID.NULL + m_nNewPathCopyForSideAngleId = GDB_ID.NULL + nOrigSecondPathId = GDB_ID.NULL + m_nNewSecondPathId = GDB_ID.NULL + nSideAngTextLayer = GDB_ID.NULL + SideAngValues.Clear() + ' nascondo PartManager + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' verifico se solido attivo + m_bPrevShowSolid = Map.refShowBeamPanelVM.ShowSolid_IsChecked + If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + ' attivo visualizzazione direzione curve + EgtSetShowCurveDirection(True) + ' elimino eventuale vecchio layer testi + EgtErase(nSideAngTextLayer) + nSideAngTextLayer = GDB_ID.NULL + ' imposto Part/Feature/Layer Processing ... + SelPart = Map.refProjectVM.BTLStructureVM.SelBTLPart + SelFeature = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM + nSelPartId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId + nSelFeatureId = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId + nProcessingLayerId = EgtGetFirstNameInGroup(nSelPartId, PROCESSINGS) + Dim sAuxId As String = "" + If EgtGetInfo(nSelFeatureId, "AUXID", sAuxId) Then + ' verifico se ha uno o due percorsi + Dim sAuxIdSplit() As String = sAuxId.Split(","c) + If Integer.TryParse(sAuxIdSplit(0), nAuxId) Then + nOrigPathId = nSelFeatureId + nAuxId + ' faccio copia del percorso feature + m_nNewPathId = EgtCopyGlob(nOrigPathId, nSelFeatureId, GDB_POS.AFTER) + EgtModifyCurveThickness(m_nNewPathId, 0) + ' verifico se c'e' info angoli + Dim sSideAng As String = "" + If EgtGetInfo(nOrigPathId, "SideAngs", sSideAng) Then + ' creo testi angoli sul percorso + CreateSideAngText(sSideAng) + ' imposto modalita' con angoli + m_SelType = FreeContourTypes.ONEWITHANGLES + Else + ' imposto modalita' un percorso + m_SelType = FreeContourTypes.ONE + End If + End If + If sAuxIdSplit.Count > 1 AndAlso Not String.IsNullOrWhiteSpace(sAuxIdSplit(1)) Then + If Integer.TryParse(sAuxIdSplit(1), nSecondAuxId) Then + nOrigSecondPathId = nSelFeatureId + nSecondAuxId + ' faccio copia del percorso feature + m_nNewSecondPathId = EgtCopyGlob(nOrigSecondPathId, nSelFeatureId, GDB_POS.AFTER) + EgtModifyCurveThickness(m_nNewSecondPathId, 0) + ' imposto modalita' due percorsi + m_SelType = FreeContourTypes.TWO + End If + End If + ' se nuova senza percorsi + Else + ' imposto modalita' un percorso + m_SelType = FreeContourTypes.ONE + End If + NotifyPropertyChanged(NameOf(SelType)) + ' verifico se deve essere contorno chiuso + m_bClosedPathNeeded = SelFeature.nPRC <> 250 + ' imposto filtro selezione solo su curve + Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False) + ' imposto layer corrente per disegno + EgtSetCurrPartLayer(nSelPartId, nProcessingLayerId) + ' nascondo tutte le feature + Dim nTempFeatureId As Integer = EgtGetFirstInGroup(nProcessingLayerId) + While nTempFeatureId <> GDB_ID.NULL + EgtSetMode(nTempFeatureId, GDB_MD.HIDDEN) + nTempFeatureId = EgtGetNext(nTempFeatureId) + End While + ' nascondo tutti gli outline + Dim nOutlineLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, OUTLINE) + Dim nTempOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayerId) + While nTempOutlineId <> GDB_ID.NULL + EgtSetMode(nTempOutlineId, GDB_MD.HIDDEN) + nTempOutlineId = EgtGetNext(nTempOutlineId) + End While + ' deseleziono tutto + EgtDeselectAll() + ' rendo visibile solo percorso feature + EgtSetMode(m_nNewPathId, GDB_MD.STD) + If m_SelType = FreeContourTypes.TWO Then + EgtSetMode(m_nNewSecondPathId, GDB_MD.STD) + End If + ' verifico se modalita' uno o due percorsi + Select Case m_SelType + Case FreeContourTypes.ONE + ' se c'e' gia' un percorso disattivo la possibilita' di aggiungerne + m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL) + m_TextAngle_Visibility = Visibility.Collapsed + m_PathList_Visibility = Visibility.Collapsed + Case FreeContourTypes.ONEWITHANGLES + ' se c'e' gia' un percorso disattivo la possibilita' di aggiungerne + m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL) + m_TextAngle_Visibility = Visibility.Visible + m_PathList_Visibility = Visibility.Collapsed + Case FreeContourTypes.TWO + ' se ci sono gia' due percorsi + ' disattivo la possibilita' di aggiungerne + m_Line2P_IsEnabled = (m_nNewPathId = GDB_ID.NULL OrElse m_nNewSecondPathId = GDB_ID.NULL) + m_TextAngle_Visibility = Visibility.Collapsed + m_PathList_Visibility = Visibility.Visible + ' seleziono primo percorso + SelPath = Paths.FIRST + NotifyPropertyChanged(NameOf(SelPath)) + End Select + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + NotifyPropertyChanged(NameOf(TextAngle_Visibility)) + NotifyPropertyChanged(NameOf(PathList_Visibility)) + ' posiziono la griglia sul riferimento del contorno libero + Dim frFace As New Frame3d + EgtBeamGetSideData(SelFeature.nSelSIDE, frFace) + Dim frFrame As New Frame3d(SelFeature.BTLFeatureM.frFRAME) + frFrame.ToGlob( frFace) + EgtSetGridFrame(frFrame) + EgtSetGridShow(True, True) + Map.refSceneHostVM.MainScene.CPlaneView() + ' rimetto la selezione scena a null + Map.refSceneHostVM.MainScene.SetStatusNull() + ' attivo bottoni save e cancel + SelFeature.RefreshFCMBtnVisibility() + ' nascondo Part Manager + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' attivo pannello + Map.refProjectVM.SetFreeContourManager_Visibility(True) + EgtDraw() + End Sub + + Friend Sub Close(bSave As Boolean) + If Not m_bIsActive Then Return + m_bIsActive = False + ' gestisco modifiche ai percorsi + If bSave Then + Select Case m_SelType + Case FreeContourManagerVM.FreeContourTypes.ONE + EgtRemoveInfo(m_nNewPathId, "SideAngs") + ' ricalcolo auxid + EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0")) + Case FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES + SideAngValues = SideAngValues.OrderBy(Function(x) x.nIndex).ToList() + Dim sSideAngInfo As String = "" + For Index = 0 To SideAngValues.Count - 1 + If Index > 0 Then sSideAngInfo &= "," + Dim sAng As String = DoubleToString(SideAngValues(Index).dValue, 2) + sSideAngInfo &= sAng + Next + EgtSetInfo(m_nNewPathId, "SideAngs", sSideAngInfo) + EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0")) + Case FreeContourManagerVM.FreeContourTypes.TWO + ' ricalcolo auxid + EgtSetInfo(nSelFeatureId, "AUXID", (m_nNewPathId - nSelFeatureId).ToString("+#;-#;0") & "," & (m_nNewSecondPathId - nSelFeatureId).ToString("+#;-#;0")) + End Select + ' aggiorno la feature con nuovo valore + Dim vPar() As Double = Nothing + Dim sPar As String = String.Empty + Dim vParQ() As String = Nothing + Dim BTLFeatureM As BTLFeatureM = SelFeature.BTLFeatureM + BTLFeatureM.CalcParamArray(vPar, sPar, vParQ) + Dim bOK As Boolean = BTLFeatureM.UpdateParams(BTLFeatureM.nSelGRP, BTLFeatureM.nPRC, BTLFeatureM.nSelSIDE, BTLFeatureM.sDES, BTLFeatureM.nPRID, + BTLFeatureM.frFRAME, vPar, sPar, vParQ) + If bOK Then + SelFeature.SelGeomFeature() + ' rendo non calcolata questa feature + SelFeature.ResetCalcFeature() + SelPart.CalcGlobalUpdate(True) + ' cancello vecchi percorsi + EgtErase(nOrigPathId) + If nOrigSecondPathId <> GDB_ID.NULL Then + EgtErase(nOrigSecondPathId) + End If + End If + Else + ' elimino nuovo percorso + EgtErase(m_nNewPathId) + If m_nNewSecondPathId <> GDB_ID.NULL Then + EgtErase(m_nNewSecondPathId) + End If + End If + ' se con angoli elimino percorso copia + If SelType = FreeContourTypes.ONEWITHANGLES Then + EgtErase(m_nNewPathCopyForSideAngleId) + End If + ' se non e' a due percorsi ma e' rimasto il secondo originale, lo cancello + If SelType <> FreeContourTypes.TWO AndAlso nOrigSecondPathId <> GDB_ID.NULL Then + EgtErase(nOrigSecondPathId) + End If + ' mostro tutte le altre feature + Dim nTempFeatureId As Integer = EgtGetFirstInGroup(nProcessingLayerId) + While nTempFeatureId <> GDB_ID.NULL + EgtSetMode(nTempFeatureId, GDB_MD.STD) + nTempFeatureId = EgtGetNext(nTempFeatureId) + End While + ' mostro outline + Dim nOutlineLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, OUTLINE) + Dim nTempOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayerId) + While nTempOutlineId <> GDB_ID.NULL + EgtSetMode(nTempOutlineId, GDB_MD.STD) + nTempOutlineId = EgtGetNext(nTempOutlineId) + End While + ' elimino eventuale layer dei testi angoli + EgtErase(nSideAngTextLayer) + nSideAngTextLayer = GDB_ID.NULL + ' riporto griglia globale e la nascondo + EgtSetGridFrame(New Frame3d()) + EgtSetGridShow(False, False) + ' se il progetto non era modificato ed esco senza salvare, resetto lo stato di modificato + If Not m_bAlreadyModified And Not bSave Then + EgtResetModified() + End If + ' disattivo pannello + Map.refProjectVM.SetFreeContourManager_Visibility(False) + ' attivo bottone edit + SelFeature.RefreshFCMBtnVisibility() + ' resetto tutte le variabili correnti + SelPart = Nothing + SelFeature = Nothing + nSelPartId = GDB_ID.NULL + nSelFeatureId = GDB_ID.NULL + nProcessingLayerId = GDB_ID.NULL + ' riattivo Part Manager + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' disattivo modifiche su scena + Map.refSceneHostVM.MainScene.SetStatusNull() + If m_bPrevShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + ' disattivo visualizzazione direzione curve + EgtSetShowCurveDirection(False) + ' reimposto filtro selezione + Map.refSceneHostVM.MainScene.SetObjFilterForSel(True, True, True, True, True) + ' sblocco funzionalita' interfaccia + Map.refProjectVM.ManageIsEnabled(True) + Map.refPartListVM.SetBTLPartListIsEnabled(True) + Map.refFeatureListVM.SetBTLFeatureListIsEnabled(True) + Map.refPParameterListVM.SetPParameterListIsEnabled(True) + Map.refQParameterListVM.SetQParameterListIsEnabled(True) + Map.refShowBeamPanelVM.SetShowSolid_IsEnabled(True) + Map.refShowBeamPanelVM.SetShowAll_IsEnabled(True) + ' reimposto vista normale per pezzo + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + ' rimetto PartManager + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + End Sub + + ' funzione lanciata su fine creazione percorso + Friend Sub CreatingPathEnd() + m_bIsCreatingPath = False + Dim nNewPathLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, "NewPathLayer") + Dim nNewPathId As Integer = EgtGetFirstInGroup(nNewPathLayerId) + If nNewPathId <> GDB_ID.NULL Then + ' lo sposto nel layer delle feature + EgtRelocateGlob(nNewPathId, nSelFeatureId, GDB_POS.AFTER) + ' se deve essere chiuso + If m_bClosedPathNeeded AndAlso Not EgtCurveIsClosed(nNewPathId) Then + EgtCloseCurveCompo(nNewPathId) + End If + Select Case SelType + Case FreeContourTypes.TWO + Select Case m_SelPath + Case Paths.FIRST + m_nNewPathId = nNewPathId + Case Paths.SECOND + m_nNewSecondPathId = nNewPathId + End Select + Case FreeContourTypes.ONEWITHANGLES + m_nNewPathId = nNewPathId + CreateSideAngText("") + Case Else + m_nNewPathId = nNewPathId + End Select + m_Line2P_IsEnabled = False + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + End If + EgtErase(nNewPathLayerId) + EgtSetCurrPartLayer(nSelPartId, nProcessingLayerId) + End Sub + + Friend Sub UpdateUi() + ' se attiva operazione in piu' passaggi, esco + If Map.refSceneHostVM.MainController.GetContinue() Then Return + ' se finita creazione curva (è stata chiusa) + If Map.refFreeContourManagerVM.bIsCreatingPath Then + Dim nNewPathLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, "NewPathLayer") + Dim nNewPathId As Integer = EgtGetFirstInGroup(nNewPathLayerId) + If EgtGetType(nNewPathId) = GDB_TY.CRV_COMPO Then Map.refFreeContourManagerVM.CreatingPathEnd() + End If + ' se non ci sono piu' i percorsi, permetto di aggiungerli + If EgtGetType(m_nNewPathId) = GDB_TY.NONE Then + m_nNewPathId = GDB_ID.NULL + m_Line2P_IsEnabled = True + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + If m_SelType = FreeContourTypes.ONEWITHANGLES Then + EgtErase(m_nNewPathCopyForSideAngleId) + m_nNewPathCopyForSideAngleId = GDB_ID.NULL + EgtErase(nSideAngTextLayer) + nSideAngTextLayer = GDB_ID.NULL + End If + End If + If m_SelType = FreeContourTypes.TWO AndAlso m_SelPath = Paths.SECOND AndAlso EgtGetType(m_nNewSecondPathId) = GDB_TY.NONE Then + m_nNewSecondPathId = GDB_ID.NULL + m_Line2P_IsEnabled = True + NotifyPropertyChanged(NameOf(Line2P_IsEnabled)) + End If + ' se modalita' angoli + If m_SelType = FreeContourTypes.ONEWITHANGLES And m_nNewPathId <> GDB_ID.NULL Then + UpdateSideAngText() + End If + ' rimetto la selezione scena a null + EgtDeselectAll() + Map.refSceneHostVM.MainScene.SetStatusNull() + EgtDraw() + End Sub + + Private Sub CreateSideAngText(SideAng As String) + SideAngValues.Clear() + ' faccio copia per modifiche future + m_nNewPathCopyForSideAngleId = EgtCopyGlob(m_nNewPathId, nSelFeatureId, GDB_POS.AFTER) + ' creo testi angoli sul percorso + If nSideAngTextLayer = GDB_ID.NULL Then + nSideAngTextLayer = EgtCreateGroup(nSelPartId) + EgtSetName(nSideAngTextLayer, PATH_SIDEANGLAYER) + End If + Dim sSideAngSplit() As String = SideAng.Split(","c) + Dim nSideFirst As Integer + Dim nSideLast As Integer + EgtCurveDomain(m_nNewPathId, nSideFirst, nSideLast) + Dim nSideCnt As Integer = nSideLast - nSideFirst + For Index = 0 To nSideCnt - 1 + ' riporto angoli nel disegno + Dim ptText As Point3d + EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptText) + Dim dSideAng As Double = 0 + If sSideAngSplit.Count - 1 >= Index Then + StringToDoubleAdv(sSideAngSplit(Index), dSideAng, True) + End If + Dim sSideAng As String = DoubleToString(dSideAng, 2) & "°" + Dim TextId As Integer = EgtCreateText(nSideAngTextLayer, ptText, sSideAng, 20) + EgtSetInfo(TextId, "SideAng", dSideAng) + SideAngValues.Add(New SideAngle(TextId, Index, dSideAng)) + Next + End Sub + + Private Sub UpdateSideAngText() + Dim bNewIsClosed As Boolean = EgtCurveIsClosed(m_nNewPathId) + Dim bOldIsClosed As Boolean = EgtCurveIsClosed(m_nNewPathCopyForSideAngleId) + Dim NewSideAngValues As New List(Of SideAngle) + Dim nSideFirst As Integer + Dim nSideLast As Integer + EgtCurveDomain(m_nNewPathId, nSideFirst, nSideLast) + Dim nSideCnt As Integer = nSideLast - nSideFirst + Dim NewAngleList As New List(Of Point3d) + Dim OldAngleList As New List(Of Point3d) + ' leggo punti nuovi + For Index = 0 To nSideCnt '+ If(bIsClosed, -1, 0) + Dim ptNew As Point3d + EgtAtParamPoint(m_nNewPathId, Index, ptNew) + NewAngleList.Add(ptNew) + Next + ' leggo punti vecchi + For Index = 0 To SideAngValues.Count() '+ If(bIsClosed, -1, 0) + Dim ptOld As Point3d + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index, ptOld) + OldAngleList.Add(ptOld) + Next + ' confronto + Dim nNewIndex As Integer = 0 + Dim nOldIndex As Integer = 0 + Dim nPointsQty As Integer = Math.Max(SideAngValues.Count(), nSideCnt) '+ If(bIsClosed, -1, 0) + ' figura rigida + Dim bRotTrans As Boolean = True + If NewAngleList.Count = OldAngleList.Count Then + For RTIndex = 1 To NewAngleList.Count - 1 + ' verifico distanza del punto dal precedente + Dim NewDist As Double = Point3d.Dist(NewAngleList(RTIndex), NewAngleList(RTIndex - 1)) + Dim OldDist As Double = Point3d.Dist(OldAngleList(RTIndex), OldAngleList(RTIndex - 1)) + If Math.Abs(NewDist - OldDist) > EPS_SMALL Then + bRotTrans = False + Exit For + End If + ' verifico distanza del punto da quello iniziale + Dim NewDist0 As Double = Point3d.Dist(NewAngleList(RTIndex), NewAngleList(0)) + Dim OldDist0 As Double = Point3d.Dist(OldAngleList(RTIndex), OldAngleList(0)) + If Math.Abs(NewDist0 - OldDist0) > EPS_SMALL Then + bRotTrans = False + Exit For + End If + Next + End If + ' ciclo sui punti + For Index = 0 To nPointsQty + Dim CurrIndex As Integer = Index + '' percorso chiuso + ' cambiato punto inizio + Dim bChangedStart As Boolean = False + Dim nMovedIndex As Integer = -1 + If Not bRotTrans AndAlso bNewIsClosed OrElse bOldIsClosed Then + If Index < NewAngleList.Count Then + ' calcolo nuovo indice del punto + nMovedIndex = OldAngleList.FindIndex(Function(x) AreSamePointApprox(x, NewAngleList(CurrIndex))) + ' verifico se coincidono anche punti successivi o precedenti + If nMovedIndex <> -1 AndAlso nMovedIndex <> Index AndAlso ((Index + 1 < NewAngleList.Count AndAlso nMovedIndex + 1 < OldAngleList.Count AndAlso AreSamePointApprox(NewAngleList(Index + 1), OldAngleList(nMovedIndex + 1))) OrElse + (Index - 1 >= 0 AndAlso nMovedIndex - 1 >= 0 AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(nMovedIndex - 1))) OrElse + (Index - 1 >= 0 AndAlso nMovedIndex = 0 AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(OldAngleList.Count - 2)))) Then + bChangedStart = True + ' aggiorno lista sideang che deve essere riordinata + If Index < nPointsQty Then + Dim nOffset As Integer = If(nMovedIndex < Index, nPointsQty + nMovedIndex, nMovedIndex) - Index + Dim NewIndex As Integer = (Index + nOffset) Mod nPointsQty + NewSideAngValues.Add(New SideAngle(SideAngValues(NewIndex).nId, NewSideAngValues.Count, SideAngValues(NewIndex).dValue)) + End If + + End If + End If + End If + If bRotTrans Then + ' aggiorno posizione testo successivo + Dim ptOld As Point3d + Dim ptNew As Point3d + Dim vtDistance As Vector3d + If Index < nPointsQty Then + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index + 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(Index).nId, vtDistance) + NewSideAngValues.Add(New SideAngle(SideAngValues(Index).nId, NewSideAngValues.Count, SideAngValues(Index).dValue)) + End If + ElseIf bChangedStart Then + ' non faccio nulla perche' gestito sopra + ' se apro percorso + ElseIf Not bNewIsClosed AndAlso bOldIsClosed AndAlso Index = NewAngleList.Count Then + ' cancello il testo del lato rimosso + nMovedIndex = OldAngleList.FindIndex(Function(x) AreSamePointApprox(x, NewAngleList(CurrIndex - 1))) + Dim nOffset As Integer = If(nMovedIndex < Index, nPointsQty + nMovedIndex, nMovedIndex) - Index + Dim NewIndex As Integer = (nPointsQty + nOffset) Mod nPointsQty + EgtErase(SideAngValues(nOffset).nId) + NewSideAngValues.RemoveAt(NewSideAngValues.Count - 1) + ' se chiudo percorso + ElseIf bNewIsClosed AndAlso Not bOldIsClosed AndAlso Index = OldAngleList.Count Then + ' creo il testo del lato aggiunto + Dim ptText As Point3d + EgtAtParamPoint(m_nNewPathId, Index - 0.5, ptText) + Dim TextId As Integer = EgtCreateText(nSideAngTextLayer, ptText, "0°", 20) + ' aggiungo punto e incremento indice di confronto per riallineare successivo + NewSideAngValues.Add(New SideAngle(TextId, NewSideAngValues.Count - 1, 0)) + '' percorso aperto + ' punti coincidono: verifico che i punti coincidano e non siano il centro del percorso simmetrico + ElseIf Not bNewIsClosed AndAlso nNewIndex <= NewAngleList.Count - 1 AndAlso nOldIndex <= OldAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex), OldAngleList(nOldIndex)) AndAlso + Not (Index = nPointsQty / 2 AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(nPointsQty - Index + 1))) Then + If Index < nPointsQty AndAlso nOldIndex <= SideAngValues.Count - 1 Then + NewSideAngValues.Add(New SideAngle(SideAngValues(nOldIndex).nId, NewSideAngValues.Count, SideAngValues(nOldIndex).dValue)) + End If + ' punti simmetrici: verifico se sono simmetrici o se coincidono ma i precedenti sono simmetrici + ElseIf Not bNewIsClosed AndAlso Not bOldIsClosed AndAlso NewAngleList.Count = OldAngleList.Count AndAlso (AreSamePointApprox(NewAngleList(Index), OldAngleList(nPointsQty - Index)) OrElse + (AreSamePointApprox(NewAngleList(nNewIndex), OldAngleList(nOldIndex)) AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(nPointsQty - Index + 1)))) Then + If Index < nPointsQty Then + Dim sText As String = DoubleToString(SideAngValues(nPointsQty - 1 - Index).dValue, 2) + EgtModifyText(SideAngValues(Index).nId, sText) + NewSideAngValues.Add(New SideAngle(SideAngValues(nPointsQty - 1 - Index).nId, NewSideAngValues.Count, SideAngValues(nPointsQty - 1 - Index).dValue)) + End If + ' punto spostato: verifico che non coincidano ma che i precedenti o i successivi coincidano + ElseIf Not bNewIsClosed AndAlso + ((Index = nPointsQty AndAlso Index <= OldAngleList.Count - 1 AndAlso Not AreSamePointApprox(NewAngleList(Index), OldAngleList(Index)) AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(Index - 1))) OrElse + (nOldIndex + 1 <= OldAngleList.Count - 1 AndAlso nNewIndex + 1 <= NewAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex + 1), OldAngleList(nOldIndex + 1)))) Then + ' aggiorno posizione testo precedente + Dim ptOld As Point3d + Dim ptNew As Point3d + Dim vtDistance As Vector3d + If Index > 0 Then + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index - 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index - 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(Index - 1).nId, vtDistance) + End If + If Index < nPointsQty Then + ' aggiorno posizione testo successivo + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index + 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(Index).nId, vtDistance) + NewSideAngValues.Add(New SideAngle(SideAngValues(Index).nId, NewSideAngValues.Count, SideAngValues(Index).dValue)) + End If + '' percorso chiuso + ' punti coincidono: verifico che i punti coincidano e non siano inizio, fine o centro del percorso simmetrico + ElseIf bNewIsClosed AndAlso nNewIndex <= NewAngleList.Count - 1 AndAlso nOldIndex <= OldAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex), OldAngleList(nOldIndex)) AndAlso + Not ((Index = 0 AndAlso AreSamePointApprox(NewAngleList(Index + 1), OldAngleList(nPointsQty - 1))) OrElse + ((Index = nPointsQty / 2 OrElse Index = nPointsQty) AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(nPointsQty - Index + 1)))) Then + If Index < nPointsQty AndAlso nOldIndex < SideAngValues.Count Then + NewSideAngValues.Add(New SideAngle(SideAngValues(nOldIndex).nId, NewSideAngValues.Count, SideAngValues(nOldIndex).dValue)) + End If + ' punti simmetrici: verifico se sono simmetrici o se coincidono ma i precedenti sono simmetrici + ElseIf bNewIsClosed AndAlso bOldIsClosed AndAlso (AreSamePointApprox(NewAngleList(Index), OldAngleList(nPointsQty - Index)) OrElse + (AreSamePointApprox(NewAngleList(nNewIndex), OldAngleList(nOldIndex)) AndAlso AreSamePointApprox(NewAngleList(Index - 1), OldAngleList(nPointsQty - Index + 1)))) Then + If Index < nPointsQty Then + NewSideAngValues.Add(New SideAngle(SideAngValues(nPointsQty - 1 - Index).nId, NewSideAngValues.Count, SideAngValues(nPointsQty - 1 - Index).dValue)) + End If + ' punto spostato: verifico che non coincidano ma che i precedenti o i successivi coincidano + ElseIf (nOldIndex + 1 <= OldAngleList.Count - 1 AndAlso nNewIndex + 1 <= NewAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex + 1), OldAngleList(nOldIndex + 1))) OrElse + (bNewIsClosed AndAlso nOldIndex + 1 = OldAngleList.Count AndAlso nNewIndex + 1 = NewAngleList.Count AndAlso AreSamePointApprox(NewAngleList(1), OldAngleList(1))) Then + ' aggiorno posizione testo precedente + Dim ptOld As Point3d + Dim ptNew As Point3d + Dim vtDistance As Vector3d + If Index > 0 Then + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index - 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index - 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(Index - 1).nId, vtDistance) + End If + If Index < nPointsQty Then + ' aggiorno posizione testo successivo + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index + 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(nOldIndex).nId, vtDistance) + NewSideAngValues.Add(New SideAngle(SideAngValues(nOldIndex).nId, NewSideAngValues.Count, SideAngValues(nOldIndex).dValue)) + End If + ' punto aggiunto: Verifico che il punto successivo coincida con il vecchio corrente o che sia stato aggiunto in fondo + ElseIf (nNewIndex + 1 <= NewAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex + 1), OldAngleList(nOldIndex))) OrElse + (nOldIndex = OldAngleList.Count AndAlso OldAngleList.Count < NewAngleList.Count) Then + ' se non e' percorso aperto e primo punto + If bNewIsClosed OrElse (Index > 0 AndAlso Index <= SideAngValues.Count) Then + ' aggiorno posizione testo vecchio + Dim ptOld As Point3d + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index - 0.5, ptOld) + Dim ptNew As Point3d + EgtAtParamPoint(m_nNewPathId, Index - 0.5, ptNew) + Dim vtDistance As Vector3d = ptNew - ptOld + EgtMove(SideAngValues(Index - 1).nId, vtDistance) + End If + ' aggiungo testo nuovo + Dim TextIndex As Integer = If(bNewIsClosed OrElse Index <= SideAngValues.Count, Index, Index - 1) + 'If bIsClosed OrElse Index <= SideAngValues.Count - 1 Then + Dim ptText As Point3d + EgtAtParamPoint(m_nNewPathId, TextIndex + 0.5, ptText) + Dim TextId As Integer = EgtCreateText(nSideAngTextLayer, ptText, "0°", 20) + ' aggiungo punto e incremento indice di confronto per riallineare successivo + NewSideAngValues.Insert(TextIndex, New SideAngle(TextId, TextIndex, 0)) + nOldIndex -= 1 + ' punto tolto: verifico che il punto coincida con il vecchio successivo o che sia stato tolto in fondo + ElseIf (nOldIndex + 1 <= OldAngleList.Count - 1 AndAlso AreSamePointApprox(NewAngleList(nNewIndex), OldAngleList(nOldIndex + 1))) OrElse + (nNewIndex = NewAngleList.Count AndAlso OldAngleList.Count > NewAngleList.Count) Then + ' non aggiungo nulla, ma cancello testo + EgtErase(SideAngValues(Index).nId) + nNewIndex -= 1 + ' riposiziono testo del punto precedente + Dim ptOld As Point3d + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, If(Index = 0, OldAngleList.Count, Index) - 0.5, ptOld) + Dim ptNew As Point3d + EgtAtParamPoint(m_nNewPathId, If(Index = 0, NewAngleList.Count, Index) - 0.5, ptNew) + Dim vtDistance As Vector3d = ptNew - ptOld + EgtMove(SideAngValues(If(Index = 0, OldAngleList.Count, Index) - 1).nId, vtDistance) + ' spostato o ruotato intero percorso + Else + ' aggiorno posizione testo successivo + Dim ptOld As Point3d + Dim ptNew As Point3d + Dim vtDistance As Vector3d + If Index < nPointsQty Then + EgtAtParamPoint(m_nNewPathCopyForSideAngleId, Index + 0.5, ptOld) + EgtAtParamPoint(m_nNewPathId, Index + 0.5, ptNew) + vtDistance = ptNew - ptOld + EgtMove(SideAngValues(Index).nId, vtDistance) + NewSideAngValues.Add(New SideAngle(SideAngValues(Index).nId, NewSideAngValues.Count, SideAngValues(Index).dValue)) + End If + End If + nNewIndex += 1 + nOldIndex += 1 + Next + ' cancello vecchia copia e faccio copia nuovo percorso per modifiche future + EgtErase(m_nNewPathCopyForSideAngleId) + m_nNewPathCopyForSideAngleId = EgtCopyGlob(m_nNewPathId, nSelFeatureId, GDB_POS.AFTER) + SideAngValues = NewSideAngValues + EgtDraw() + 'End If + End Sub + + Friend Sub CloseIsModifyingTextAngle(bResult As Boolean) + If bResult Then + ' scrivo info con nuova inclinazione + Dim dAng As Double + StringToDoubleAdv(Map.refFreeContourInputVM.Text, dAng, True) + EgtSetInfo(m_nSelTextId, "SideAng", dAng) + Dim sAng As String = DoubleToString(dAng, 2) & "°" + EgtModifyText(m_nSelTextId, sAng) + Dim SideAngValue As SideAngle = SideAngValues.First(Function(x) x.nId = m_nSelTextId) + SideAngValue.dValue = dAng + End If + m_nSelTextId = GDB_ID.NULL + Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False) + Map.refFreeContourInputVM.ResetInputBox() + ' rimetto la selezione scena a null + EgtDeselectAll() + EgtDraw() + Map.refSceneHostVM.MainScene.SetStatusNull() + m_bIsModifyingTextAngle = False + End Sub + + Friend Sub CloseIsOpeningCurveCompo() + Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, True, False, False, False) + Map.refFreeContourInputVM.ResetInputBox() + ' rimetto la selezione scena a null + EgtDeselectAll() + EgtDraw() + Map.refSceneHostVM.MainScene.SetStatusNull() + m_bIsOpeningCurveCompo = False + End Sub + + Friend Function OnMouseSelectingObj(nId As Integer) As Boolean + ' se sto editando testo angoli + If Map.refFreeContourManagerVM.bIsModifyingTextAngle Then + ' verifico che il testo selezionato sia uno degli angoli + Dim nLayerId As Integer = EgtGetParent(nId) + Dim sLayerName As String = "" + EgtGetName(nLayerId, sLayerName) + Return sLayerName = PATH_SIDEANGLAYER + ElseIf Map.refFreeContourManagerVM.bIsOpeningCurveCompo Then + Return nId = m_nNewPathId + Else + Return False + End If + End Function + + Friend Sub OnMouseSelectedObj(nId As Integer, bLast As Boolean) + ' se sto editando testo angoli + If Map.refFreeContourManagerVM.bIsModifyingTextAngle Then + m_nSelTextId = nId + ' mostro campo da editare + Map.refFreeContourInputVM.PrepareInputBox(EgtMsg(62007), EgtMsg(62008), "", False, False) + Dim dSideAng As Double = 0 + EgtGetInfo(nId, "SideAng", dSideAng) + Dim sSideAng As String = DoubleToString(dSideAng, 2) + Map.refFreeContourInputVM.SetInputBoxText(sSideAng) + ' se sto aprendo percorso chiuso + ElseIf Map.refFreeContourManagerVM.bIsOpeningCurveCompo Then + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.OPENCOMPO) + m_bIsOpeningCurveCompo = False + End If + End Sub + + Private Sub InitCommand(bSelPath As Boolean) + ' attivo modifiche su scena + Map.refSceneHostVM.MainScene.ResetStatus() + ' seleziono percorso corrente + EgtDeselectAll() + If bSelPath Then EgtSelectObj(If(SelType = FreeContourTypes.TWO AndAlso m_SelPath = Paths.SECOND, m_nNewSecondPathId, m_nNewPathId)) + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "Line2P" + + ''' + ''' Returns a command that do Line2P. + ''' + Public ReadOnly Property Line2P_Command As ICommand + Get + If m_cmdLine2P Is Nothing Then + m_cmdLine2P = New Command(AddressOf Line2P) + End If + Return m_cmdLine2P + End Get + End Property + + ''' + ''' Execute the Line2P. This method is invoked by the Line2PCommand. + ''' + Public Sub Line2P(ByVal param As Object) + ' cancello eventuale gruppo precedente + Dim nNewPathLayerId As Integer = EgtGetFirstNameInGroup(nSelPartId, "NewPathLayer") + If nNewPathLayerId <> GDB_ID.NULL Then + EgtEmptyGroup(nNewPathLayerId) + Else + nNewPathLayerId = EgtCreateGroup(nSelPartId) + End If + EgtSetName(nNewPathLayerId, "NewPathLayer") + EgtSetCurrPartLayer(nSelPartId, nNewPathLayerId) + InitCommand(False) + Map.refSceneHostVM.MainController.SetContinue() + If Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.LINE2P) Then + m_bIsCreatingPath = True + Else + EgtErase(nNewPathLayerId) + End If + End Sub + +#End Region ' Line2P + +#Region "Delete" + + ''' + ''' Returns a command that do Line2P. + ''' + Public ReadOnly Property Delete_Command As ICommand + Get + If m_cmdDelete Is Nothing Then + m_cmdDelete = New Command(AddressOf Delete) + End If + Return m_cmdDelete + End Get + End Property + + ''' + ''' Execute the Line2P. This method is invoked by the Line2PCommand. + ''' + Public Sub Delete(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.SetLastInteger(GDB_ID.SEL) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.DELETE) + End Sub + +#End Region ' Line2P + +#Region "ModifyCurve" + + ''' + ''' Returns a command that do Linear Dimension. + ''' + Public ReadOnly Property ModifyCurve_Command As ICommand + Get + If m_cmdModifyCurve Is Nothing Then + m_cmdModifyCurve = New Command(AddressOf ModifyCurve) + End If + Return m_cmdModifyCurve + End Get + End Property + + ''' + ''' Execute the LinearDimension. This method is invoked by the LinDimCommand. + ''' + Public Sub ModifyCurve(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MODIFYCURVE) + End Sub + +#End Region ' ModifyCurve + +#Region "AddPointCurve" + + ''' + ''' Returns a command that do Linear Dimension. + ''' + Public ReadOnly Property AddPointCurve_Command As ICommand + Get + If m_cmdAddPointCurve Is Nothing Then + m_cmdAddPointCurve = New Command(AddressOf AddPointCurve) + End If + Return m_cmdAddPointCurve + End Get + End Property + + ''' + ''' Execute the LinearDimension. This method is invoked by the LinDimCommand. + ''' + Public Sub AddPointCurve(ByVal param As Object) + InitCommand(True) + If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CLOSECOMPO) + ElseIf (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CURVETOARC) + Else + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ADDPOINTCURVE) + End If + End Sub + +#End Region ' AddPointCurve + +#Region "RemovePointCurve" + + ''' + ''' Returns a command that do Linear Dimension. + ''' + Public ReadOnly Property RemovePointCurve_Command As ICommand + Get + If m_cmdRemovePointCurve Is Nothing Then + m_cmdRemovePointCurve = New Command(AddressOf RemovePointCurve) + End If + Return m_cmdRemovePointCurve + End Get + End Property + + ''' + ''' Execute the LinearDimension. This method is invoked by the LinDimCommand. + ''' + Public Sub RemovePointCurve(ByVal param As Object) + If (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + If Not m_bClosedPathNeeded Then + InitCommand(False) + m_bIsOpeningCurveCompo = True + Map.refFreeContourInputVM.ShowMessage(EgtMsg(62009), EgtMsg(62010)) + Else + Map.refSceneHostVM.MainScene.SetStatusNull() + End If + ElseIf (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CURVETOLINE) + Else + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.REMOVEPOINTCURVE) + End If + End Sub + +#End Region ' RemovePointCurve + +#Region "Move" + + ''' + ''' Returns a command that do Move. + ''' + Public ReadOnly Property Move_Command As ICommand + Get + If m_cmdMove Is Nothing Then + m_cmdMove = New Command(AddressOf Move) + End If + Return m_cmdMove + End Get + End Property + + ''' + ''' Execute the Move. This method is invoked by the MoveCommand. + ''' + Public Sub Move(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MOVE) + End Sub + +#End Region ' Move + +#Region "Rotate" + + ''' + ''' Returns a command that do Rotate. + ''' + Public ReadOnly Property Rotate_Command As ICommand + Get + If m_cmdRotate Is Nothing Then + m_cmdRotate = New Command(AddressOf Rotate) + End If + Return m_cmdRotate + End Get + End Property + + ''' + ''' Execute the Rotate. This method is invoked by the RotateCommand. + ''' + Public Sub Rotate(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.ROTATE) + End Sub + +#End Region ' Rotate + +#Region "Mirror" + + ''' + ''' Returns a command that do Mirror. + ''' + Public ReadOnly Property Mirror_Command As ICommand + Get + If m_cmdMirror Is Nothing Then + m_cmdMirror = New Command(AddressOf Mirror) + End If + Return m_cmdMirror + End Get + End Property + + ''' + ''' Execute the Mirror. This method is invoked by the MirrorCommand. + ''' + Public Sub Mirror(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.MIRROR) + End Sub + +#End Region ' Mirror + +#Region "Scale" + + ''' + ''' Returns a command that do Scale. + ''' + Public ReadOnly Property Scale_Command As ICommand + Get + If m_cmdScale Is Nothing Then + m_cmdScale = New Command(AddressOf Scale) + End If + Return m_cmdScale + End Get + End Property + + ''' + ''' Execute the Scale. This method is invoked by the ScaleCommand. + ''' + Public Sub Scale(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.SCALE) + End Sub + +#End Region ' Scale + +#Region "ChangeStart" + + ''' + ''' Returns a command that do Scale. + ''' + Public ReadOnly Property ChangeStart_Command As ICommand + Get + If m_cmdChangeStart Is Nothing Then + m_cmdChangeStart = New Command(AddressOf ChangeStart) + End If + Return m_cmdChangeStart + End Get + End Property + + ''' + ''' Execute the Scale. This method is invoked by the ScaleCommand. + ''' + Public Sub ChangeStart(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainScene.SetSnapPointType(SP.PT_END) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.CHANGESTARTCURVE) + End Sub + +#End Region ' ChangeStart + +#Region "InvertCurve" + + ''' + ''' Returns a command that do Scale. + ''' + Public ReadOnly Property InvertCurve_Command As ICommand + Get + If m_cmdInvertCurve Is Nothing Then + m_cmdInvertCurve = New Command(AddressOf InvertCurve) + End If + Return m_cmdInvertCurve + End Get + End Property + + ''' + ''' Execute the Scale. This method is invoked by the ScaleCommand. + ''' + Public Sub InvertCurve(ByVal param As Object) + InitCommand(True) + Map.refSceneHostVM.MainController.ExecuteCommand(Controller.CMD.INVERTCURVE) + End Sub + +#End Region ' InvertCurve + +#Region "TextAngle" + + ''' + ''' Returns a command that do Scale. + ''' + Public ReadOnly Property TextAngle_Command As ICommand + Get + If m_cmdTextAngle Is Nothing Then + m_cmdTextAngle = New Command(AddressOf TextAngle) + End If + Return m_cmdTextAngle + End Get + End Property + + ''' + ''' Execute the Scale. This method is invoked by the ScaleCommand. + ''' + Public Sub TextAngle(ByVal param As Object) + InitCommand(False) + ' imposto selezione solo testi + Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, False, False, False, True) + Map.refFreeContourInputVM.ShowMessage(EgtMsg(62007), EgtMsg(62011)) + m_bIsModifyingTextAngle = True + End Sub + +#End Region ' ScaleCommand + +#End Region ' COMMANDS + +End Class + +Public Class SideAngle + + ' Id geometrico dell'entita' text + Private m_nId As Integer + Public ReadOnly Property nId As Integer + Get + Return m_nId + End Get + End Property + + ' indice della posizione di questo lato all'interno del percorso + Private m_nIndex As Integer + Public Property nIndex As Integer + Get + Return m_nIndex + End Get + Set(value As Integer) + m_nIndex = value + End Set + End Property + + Private m_dValue As Double + Friend Property dValue As Double + Get + Return m_dValue + End Get + Set(value As Double) + m_dValue = value + End Set + End Property + + Sub New(Id As Integer, Index As Integer, Value As Double) + m_nId = Id + m_nIndex = Index + m_dValue = Value + End Sub + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml b/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml new file mode 100644 index 00000000..2c0b7f27 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml.vb new file mode 100644 index 00000000..d709879c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/FreeContourManager/OnlyProdFreeContourManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdFreeContourManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/InputPwdWnd/InputPwdWndV.xaml b/EgtBEAMWALL.Optimizer/InputPwdWnd/InputPwdWndV.xaml new file mode 100644 index 00000000..d98f9a6b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/InputPwdWnd/InputPwdWndV.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/InstrumentPanel/InstrumentPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/InstrumentPanel/InstrumentPanelV.xaml.vb new file mode 100644 index 00000000..b8adb880 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/InstrumentPanel/InstrumentPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class InstrumentPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/InstrumentPanel/MyInstrumentPanelVM.vb b/EgtBEAMWALL.Optimizer/InstrumentPanel/MyInstrumentPanelVM.vb new file mode 100644 index 00000000..dfdaa80e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/InstrumentPanel/MyInstrumentPanelVM.vb @@ -0,0 +1,357 @@ +Imports System.Collections.ObjectModel +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class MyInstrumentPanelVM + Inherits InstrumentPanelVM + + Public ReadOnly Property ChangeParam_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property ChangeMaterial_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.nUserLevel > 5 AndAlso Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property Statistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.MACHINING, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property VisStatistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property OtStatistic_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_InstrumentPanel_IsEnabled As Boolean = True + Public Property InstrumentPanel_IsEnabled As Boolean + Get + Return m_InstrumentPanel_IsEnabled + End Get + Set(value As Boolean) + m_InstrumentPanel_IsEnabled = value + End Set + End Property + + Private m_Statistics_IsEnabled As Boolean = True + Public Property Statistics_IsEnabled As Boolean + Get + Return m_Statistics_IsEnabled + End Get + Set(value As Boolean) + m_Statistics_IsEnabled = value + End Set + End Property + + ' flag per verificare se è stato selezionato il pulsante VIS o OTT se 0 = VIS se 1 = OTT + Private m_bVisOtt_Selected As Boolean = False + Public Property bVisOtt_Selected As Boolean + Get + Return m_bVisOtt_Selected + End Get + Set(value As Boolean) + m_bVisOtt_Selected = value + NotifyPropertyChanged(NameOf(bVisOtt_Selected)) + End Set + End Property + + + Dim m_PrevBottomPanelPage As BottomPanelVM.PartFeatureTab = BottomPanelVM.PartFeatureTab.STRUCTURE_ + Private m_Statistics_IsChecked As Boolean = False + Public Property Statistics_IsChecked As Boolean + Get + Return m_Statistics_IsChecked + End Get + Set(value As Boolean) + m_Statistics_IsChecked = value + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + If value Then + ' salvo pagina precedente + m_PrevBottomPanelPage = Map.refBottomPanelVM.SelPartFeatureTab + ' aggiorno valori totali + Map.refProjectVM.BTLStructureVM.CalcGlobalUpdate() + ' seleziono pagina Statistics + Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STATISTICS) + Else + ' seleziono pagina precedente + Map.refBottomPanelVM.SetSelPartFeatureTab(m_PrevBottomPanelPage) + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If value Then + ' aggiorno valori totali + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then Map.refProjectVM.MachGroupPanelVM.CalcGlobalUpdate() + ' aggiorno conto materiali usati + If Not IsNothing(ProjectManagerVM.CurrProd) Then Map.refStatisticsVM.LoadRawPart() + ' seleziono pagina Statistics + Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.STATISTICS) + Else + ' seleziono pagina precedente + Map.refTopPanelVM.SetSelTab(TopPanelVM.Tabs.OPTIMIZATION) + End If + End If + End Set + End Property + Friend Sub SetStatisticsIsChecked(value As Boolean) + m_Statistics_IsChecked = value + NotifyPropertyChanged(NameOf(Statistics_IsChecked)) + End Sub + + Private m_VisStatistic_IsEnabled As Boolean = True + Public Property VisStatistic_IsEnabled As Boolean + Get + Return m_VisStatistic_IsEnabled + End Get + Set(value As Boolean) + m_VisStatistic_IsEnabled = value + End Set + End Property + + Private m_OtStatistic_IsEnabled As Boolean = True + Public Property OtStatistic_IsEnabled As Boolean + Get + Return m_OtStatistic_IsEnabled + End Get + Set(value As Boolean) + m_OtStatistic_IsEnabled = value + End Set + End Property + + ' Definizione comandi + Private m_cmdData As ICommand + Private m_cmdChangeParameter As ICommand + Private m_cmdChangeMaterial As ICommand + Private m_cmdStatistics As ICommand + Private m_cmdVisualization As ICommand + Private m_cmdOptimizer As ICommand + +#Region "Messages" + + Public ReadOnly Property ChangeParam_ToolTip As String + Get + Return EgtMsg(61900) + End Get + End Property + + Public ReadOnly Property ChangeMaterial_ToolTip As String + Get + Return EgtMsg(61961) + End Get + End Property + + Public ReadOnly Property Statistics_Msg As String + Get + Return EgtMsg(61923) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTORS" + + Sub New() + ' imposto riferimento in Map + Map.SetRefInstrumentPanelVM(Me) + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Public Overrides Function OnPostGetDistIsChecked() As Boolean + If Not Map.refFreeContourManagerVM.bIsActive Then Map.refSceneHostVM.MainScene.SetStatusNull() + Return True + End Function + + Friend Sub SetGetDistance_IsChecked(bIsChecked As Boolean) + GetDistIsChecked = bIsChecked + End Sub + + Friend Sub ResetStatisticsIsChecked() + If Statistics_IsChecked Then + Statistics_IsChecked = False + NotifyPropertyChanged(NameOf(Statistics_IsChecked)) + End If + End Sub + + Friend Sub SetInstrumentPanelIsEnabled(bIsEnabled As Boolean) + m_InstrumentPanel_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(InstrumentPanel_IsEnabled)) + If Map.refFreeContourManagerVM.bIsActive Then + m_Statistics_IsEnabled = bIsEnabled + m_VisStatistic_IsEnabled = bIsEnabled + m_OtStatistic_IsEnabled = bIsEnabled + Else + m_Statistics_IsEnabled = True + m_VisStatistic_IsEnabled = True + m_OtStatistic_IsEnabled = True + End If + NotifyPropertyChanged(NameOf(Statistics_IsEnabled)) + NotifyPropertyChanged(NameOf(VisStatistic_IsEnabled)) + NotifyPropertyChanged(NameOf(OtStatistic_IsEnabled)) + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "ChangeParameter" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property ChangeParameter_Command As ICommand + Get + If m_cmdChangeParameter Is Nothing Then + m_cmdChangeParameter = New Command(AddressOf ChangeParameter) + End If + Return m_cmdChangeParameter + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub ChangeParameter() + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return + Dim ChangeParameterWndVM As New ChangeParameterWndVM + Dim ChangeParameterWnd As New ChangeParameterWndV(Application.Current.MainWindow, ChangeParameterWndVM) + If ChangeParameterWnd.ShowDialog() Then + LoadingWndHelper.OpenLoadingWnd(ActiveIds.CHANGEPARAM, 1, EgtMsg(63014), "", 100) ' Modifying parameters + ' faccio passare pezzi + If Not IsNothing(ChangeParameterWndVM.SelParam) Then + For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList + For Each Feature In Part.BTLFeatureVMList.Where(Function(x) x.nPRC = ChangeParameterWndVM.SelPRC.nPRC AndAlso CalcBeamPrivateProfileGRP(x.nSelGRP) = ChangeParameterWndVM.SelPRC.nGRP) + If ChangeParameterWndVM.SelParam.BTLParamM.nType = BTLParamType.CHECKBOX AndAlso Feature.bDO = ChangeParameterWndVM.SelParam.bActualValue Then + Feature.bDO = ChangeParameterWndVM.SelParam.bNewValue + Else + Dim ParamList As ObservableCollection(Of BTLParamVM) + If ChangeParameterWndVM.SelParam.BTLParamM.bIsP Then + ParamList = Feature.PBTLParamVMList + Else + ParamList = Feature.QBTLParamVMList + End If + For Each Param In ParamList.Where(Function(x) x.sName = ChangeParameterWndVM.SelParam.sName) + Select Case Param.nType + Case BTLParamType.DOUBLE_, BTLParamType.LENGTH + If Math.Abs( Param.dValue - ChangeParameterWndVM.SelParam.dActualValue) < EPS_SMALL Then + Param.UpdateParamValue(ChangeParameterWndVM.SelParam.dNewValue, "") + End If + Case BTLParamType.STRING_ + If Param.sValue = ChangeParameterWndVM.SelParam.sActualValue Then + Param.UpdateParamValue(0, ChangeParameterWndVM.SelParam.sNewValue) + End If + End Select + Next + End If + Next + Next + End If + LoadingWndHelper.CloseLoadingWnd(ActiveIds.CHANGEPARAM) + End If + End Sub + +#End Region ' ChangeParameter + +#Region "ChangeMaterial" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property ChangeMaterial_Command As ICommand + Get + If m_cmdChangeMaterial Is Nothing Then + m_cmdChangeMaterial = New Command(AddressOf ChangeMaterial) + End If + Return m_cmdChangeMaterial + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub ChangeMaterial() + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(ProjectManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse + (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return + Dim ChangeMaterialWndVM As New ChangeMaterialWndVM + Dim ChangeMaterialWnd As New ChangeMaterialWndV(Application.Current.MainWindow, ChangeMaterialWndVM) + If ChangeMaterialWnd.ShowDialog() Then + LoadingWndHelper.OpenLoadingWnd(ActiveIds.CHANGEMATERIAL, 1, EgtMsg(63021), "", 100) ' Modifying materials + ' faccio passare pezzi + If Not IsNothing(ChangeMaterialWndVM.SelProjMaterial) AndAlso Not IsNothing(ChangeMaterialWndVM.SelWhMaterial) Then + For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList.Where(Function(x) x.sMATERIAL = ChangeMaterialWndVM.SelProjMaterial) + Part.sMATERIAL = ChangeMaterialWndVM.SelWhMaterial + Next + End If + LoadingWndHelper.CloseLoadingWnd(ActiveIds.CHANGEMATERIAL) + End If + End Sub + +#End Region ' ChangeMaterial + +#Region "Visualization" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Visualization_Command As ICommand + Get + If m_cmdVisualization Is Nothing Then + m_cmdVisualization = New Command(AddressOf Visualization) + End If + Return m_cmdVisualization + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Visualization() + m_bVisOtt_Selected = False + Dim StatisticsWndV As New StatisticsWndV(Application.Current.MainWindow, New StatisticsVM()) + StatisticsWndV.ShowDialog() + End Sub + +#End Region ' Visualization + +#Region "Ottimization" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Optimizer_Command As ICommand + Get + If m_cmdOptimizer Is Nothing Then + m_cmdOptimizer = New Command(AddressOf Optimizer) + End If + Return m_cmdOptimizer + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Optimizer() + m_bVisOtt_Selected = True + Dim OptimizerStatisticsWndV As New OptimizerStatisticsWndV(Application.Current.MainWindow, New StatisticsVM()) + OptimizerStatisticsWndV.ShowDialog() + End Sub + +#End Region ' Ottimization + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml b/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml new file mode 100644 index 00000000..1100b4b3 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml.vb new file mode 100644 index 00000000..222eb955 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/InstrumentPanel/OnlyProdInstrumentPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdInstrumentPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml new file mode 100644 index 00000000..8b026626 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml.vb new file mode 100644 index 00000000..3c0dd19b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLDataV.xaml.vb @@ -0,0 +1,3 @@ +Public Class BTLDataV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml new file mode 100644 index 00000000..d12c5221 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml.vb new file mode 100644 index 00000000..c8db0288 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListV.xaml.vb @@ -0,0 +1,202 @@ +Imports System.Reflection +Imports EgtBEAMWALL.Core.ConstGen + +Public Class BTLPartListV + + Private m_BTLPartListVM As BTLPartListVM + + Private m_SelectBtn As MouseButton = MouseButton.Left + Private m_HighlightBtn As MouseButton = MouseButton.Right + + Private m_NameDataGridType As Type + Private s_isDraggingSelectionField As FieldInfo + Private s_endDraggingMethod As MethodInfo + + Sub New() + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + m_BTLPartListVM = DataContext + m_NameDataGridType = BTLPart_DataGrid.GetType() + s_isDraggingSelectionField = m_NameDataGridType.GetField("_isDraggingSelection", BindingFlags.Instance Or BindingFlags.NonPublic) + s_endDraggingMethod = m_NameDataGridType.GetMethod("EndDragging", BindingFlags.Instance Or BindingFlags.NonPublic) + SetSelButton(MouseButton.Right) + End Sub + + Public Sub SetSelButton(SelButton As MouseButton) + Select Case SelButton + Case MouseButton.Right + m_SelectBtn = MouseButton.Right + m_HighlightBtn = MouseButton.Left + Case Else ' MouseButton.Left + m_SelectBtn = MouseButton.Left + m_HighlightBtn = MouseButton.Right + End Select + End Sub + + Public Sub DataGrid_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If e.ChangedButton = MouseButton.Left Then + If e.ChangedButton = m_SelectBtn Then + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + e.Handled = True + Else + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) + End If + ElseIf e.ChangedButton = m_HighlightBtn AndAlso (Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso + ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control)) Then + e.Handled = True + ElseIf e.ChangedButton = m_HighlightBtn Then + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + 'Map.refProjectVM.SelProdProj = ProdProj.NULL + 'If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProdProjManagerVM.SelProdProj = ProdProj.NULL + End If + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PARTLIST) + End If + 'If e.ChangedButton = Input.MouseButton.Left Then + ' If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + ' e.Handled = True + ' Else + ' m_MainWindowVM.SetMouseButton("Left") + ' End If + 'ElseIf e.ChangedButton = Input.MouseButton.Right Then + ' m_MainWindowVM.SetMouseButton("Right") + 'End If + End Sub + + Public Sub DataGrid_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) + If e.ChangedButton = MouseButton.Right Then + If e.ChangedButton = m_SelectBtn Then + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + e.Handled = True + Else + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) + End If + ElseIf e.ChangedButton = m_HighlightBtn Then + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + End If + 'Else + 'If e.ChangedButton = m_HighlightBtn Then + ' Dim cell As DataGridCell = sender + ' If (Not IsNothing(cell) And Not cell.IsEditing) Then + ' Dim row As DataGridRow = FindVisualParent(Of DataGridRow)(cell) + ' If Not IsNothing(row) Then + ' row.IsSelected = Not row.IsSelected + ' e.Handled = True + ' End If + ' End If + ' m_MainWindowVM.SetMouseButton("Highlight") + 'End If + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART) + End If + End Sub + + Public Shared Function FindVisualParent(Of T As DependencyObject)(ByVal child As DependencyObject) As T + Dim parentObject As DependencyObject = VisualTreeHelper.GetParent(child) + If parentObject Is Nothing Then Return Nothing + Dim parent As T = TryCast(parentObject, T) + + If parent IsNot Nothing Then + Return parent + Else + Return FindVisualParent(Of T)(parentObject) + End If + End Function + + Public Sub DataGrid_PreviewMouseMove(sender As Object, e As MouseEventArgs) + If m_SelectBtn = MouseButton.Left AndAlso e.LeftButton = MouseButtonState.Pressed Then + If CBool(If(s_isDraggingSelectionField?.GetValue(BTLPart_DataGrid), False)) Then s_endDraggingMethod.Invoke(BTLPart_DataGrid, New Object(-1) {}) + End If + End Sub + + Private Sub PartList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not Row.IsSelected Then Return + Select Case e.ChangedButton + Case MouseButton.Left + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + Return + Else + BTLPart_DataGrid.SelectedItem = Nothing + BTLPart_DataGrid.SelectedItem = Row.DataContext + End If + + Case MouseButton.Right + + + End Select + 'If Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Map.refProjectVM.BTLStructureVM.BTLPartVMList.LongCount(Function(x) x.IsSelected) = 1 Then + ' e.Handled = True + ' Return + 'ElseIf Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not Keyboard.Modifiers = ModifierKeys.Shift AndAlso Not IsNothing(Row) Then + ' For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' If Not BTLPart Is Row.DataContext AndAlso BTLPart.IsSelected = True Then + ' BTLPart.SetIsSelected(False) + ' End If + ' Next + 'End If + 'If Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected Then + ' Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.SelBTLPart) + 'End If + End If + 'If TypeOf sender Is DataGridRow Then + ' Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + ' If Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Map.refProjectVM.BTLStructureVM.BTLPartVMList.LongCount(Function(x) x.IsSelected) = 1 Then + ' e.Handled = True + ' Return + ' ElseIf Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not Keyboard.Modifiers = ModifierKeys.Shift AndAlso Not IsNothing(Row) Then + ' For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' If Not BTLPart Is Row.DataContext AndAlso BTLPart.IsSelected = True Then + ' BTLPart.SetIsSelected(False) + ' End If + ' Next + ' End If + ' If Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected Then + ' Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.SelBTLPart) + ' End If + 'End If + End Sub + + Private Sub PartList_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not Row.IsSelected Then Return + Select Case e.ChangedButton + Case MouseButton.Right + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + Row.IsSelected = Not Row.IsSelected + Else + BTLPart_DataGrid.SelectedItem = Nothing + BTLPart_DataGrid.SelectedItem = Row.DataContext + ' metto focus su cella selezionata per evitare errori di focus del sistema normale + Dim dep As DependencyObject = CType(e.OriginalSource, DependencyObject) + While (dep IsNot Nothing) AndAlso Not (TypeOf dep Is DataGridCell) + dep = VisualTreeHelper.GetParent(dep) + End While + If dep Is Nothing Then Return + If TypeOf dep Is DataGridCell Then + Dim cell As DataGridCell = TryCast(dep, DataGridCell) + cell.Focus() + End If + End If + End Select + 'If Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Map.refProjectVM.BTLStructureVM.BTLPartVMList.LongCount(Function(x) x.IsSelected) = 1 Then + ' e.Handled = True + ' Return + 'ElseIf Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not Keyboard.Modifiers = ModifierKeys.Shift AndAlso Not IsNothing(Row) Then + ' For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' If Not BTLPart Is Row.DataContext AndAlso BTLPart.IsSelected = True Then + ' BTLPart.SetIsSelected(False) + ' End If + ' Next + 'End If + 'If Not Keyboard.Modifiers = ModifierKeys.Control AndAlso Not IsNothing(Row) AndAlso Row.IsSelected Then + ' Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.SelBTLPart) + 'End If + End If + + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb new file mode 100644 index 00000000..13c48ac6 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb @@ -0,0 +1,210 @@ +Imports System.Collections.ObjectModel +Imports System.Globalization +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BTLPartListVM + Inherits VMBase + + Private m_colPart_Do As EgtDataGridColumn + Public ReadOnly Property colPart_Do As EgtDataGridColumn + Get + Return m_colPart_Do + End Get + End Property + + Private m_PartColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property PartColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_PartColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_PartColumns = value + End Set + End Property + + Private m_PartList_IsEnabled As Boolean = True + Public Property PartList_IsEnabled As Boolean + Get + Return m_PartList_IsEnabled + End Get + Set(value As Boolean) + m_PartList_IsEnabled = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property PDN_Msg As String + Get + Return EgtMsg(61809) + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61810) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61605) + End Get + End Property + + Public ReadOnly Property H_Msg As String + Get + Return EgtMsg(61606) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61604) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property MAT_Msg As String + Get + Return EgtMsg(61607) + End Get + End Property + + Public ReadOnly Property CNT_Msg As String + Get + Return EgtMsg(61608) + End Get + End Property + Public ReadOnly Property ShortCNT_Msg As String + Get + Return EgtMsg(61952) + End Get + End Property + + Public ReadOnly Property ADDED_Msg As String + Get + Return EgtMsg(61813) + End Get + End Property + Public ReadOnly Property ShortADDED_Msg As String + Get + Return EgtMsg(61953) + End Get + End Property + Public ReadOnly Property INPROD_Msg As String + Get + Return EgtMsg(61609) + End Get + End Property + Public ReadOnly Property ShortINPROD_Msg As String + Get + Return EgtMsg(61954) + End Get + End Property + Public ReadOnly Property DONE_Msg As String + Get + Return EgtMsg(61814) + End Get + End Property + Public ReadOnly Property ShortDONE_Msg As String + Get + Return EgtMsg(61955) + End Get + End Property + + Public ReadOnly Property GRP_Msg As String + Get + Return EgtMsg(61624) + End Get + End Property + + Public ReadOnly Property STOREY_Msg As String + Get + Return EgtMsg(61623) + End Get + End Property + +#End Region ' Messages + + Sub New() + ' creo riferimento in Map + Map.SetRefPartListVM(Me) + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_PARTLIST, PartColumns) + ' recupero riferimento a colonna Do + m_colPart_Do = PartColumns.FirstOrDefault(Function(x) x.Name = COL_DO) + End Sub + + Friend Sub SetBTLPartListIsEnabled(bIsEnabled As Boolean) + m_PartList_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(PartList_IsEnabled)) + End Sub + +End Class + +Class DataGridCellBorderThicknessConverter + Implements IMultiValueConverter + + Public Function Convert(values() As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IMultiValueConverter.Convert + Dim ColumnList As ObservableCollection(Of EgtDataGridColumn) = Map.refPartListVM.PartColumns + Dim ColumnIndex As Integer = CInt(values(0)) + Dim bLeft As Boolean = False + Dim bRight As Boolean = False + Dim dThickness As Double = CDbl(parameter) + If Not IsNothing(ColumnList) AndAlso Not IsNothing(ColumnIndex) Then + If ColumnIndex = 0 Then + bLeft = True + ElseIf ColumnIndex = ColumnList.Count - 1 Then + bRight = True + End If + Else + Return New Thickness(0, dThickness, 0, dThickness) + End If + Return New Thickness(If(bLeft, dThickness, 0), dThickness, If(bRight, dThickness, 0), dThickness) + End Function + + Public Function ConvertBack(value As Object, targetTypes() As Type, parameter As Object, culture As CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack + Throw New NotImplementedException() + End Function + +End Class + +Class ProjIdToBtlFileName + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert + If TypeOf value IsNot Integer Then Return "" + Dim nProjId As Integer = CInt(value) + Dim ProjModel As EgtBEAMWALL.DataLayer.DatabaseModels.ProjModel = DbControllers.m_ProjController.FindByProjId(nProjId) + If IsNothing(ProjModel) Then Return "" + Return ProjModel.BTLFileName + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack + Throw New NotImplementedException() + End Function + +End Class + +Public Class BooleanToVisibilityConverter + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert + If Not TypeOf value Is Boolean Then Return Visibility.Collapsed + Dim bValue As Boolean = value + Return If(bValue, Visibility.Visible, Visibility.Collapsed) + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack + Throw New NotImplementedException() + End Function + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/DuploQParameterListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/DuploQParameterListVM.vb new file mode 100644 index 00000000..f2bc3b1d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/DuploQParameterListVM.vb @@ -0,0 +1,85 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class DuploQParameterListVM + +#Region "FIELDS & PROPERTIES" + + Private m_colQParam_Value As EgtDataGridColumn + Public ReadOnly Property colQParam_Value As EgtDataGridColumn + Get + Return m_colQParam_Value + End Get + End Property + + Private m_colQParam_Custom As EgtDataGridColumn + Public ReadOnly Property colQParam_Custom As EgtDataGridColumn + Get + Return m_colQParam_Custom + End Get + End Property + + Private m_QParameterListColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property QParameterListColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_QParameterListColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_QParameterListColumns = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property Custom_Msg As String + Get + Return EgtMsg(61801) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61808) + End Get + End Property + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property Value_Msg As String + Get + Return EgtMsg(61615) + End Get + End Property + + Public ReadOnly Property Min_Msg As String + Get + Return EgtMsg(61616) + End Get + End Property + Public ReadOnly Property Max_Msg As String + Get + Return EgtMsg(61617) + End Get + End Property + +#End Region ' Messages + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_DUPLOPARAMETERLIST_Q, QParameterListColumns) + ' recupero riferimento a colonna Value e Custom + m_colQParam_Value = QParameterListColumns.FirstOrDefault(Function(x) x.Name = COL_VALUE) + End Sub + +#End Region ' CONSTRUCTOR + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml new file mode 100644 index 00000000..b09c4a2c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml.vb new file mode 100644 index 00000000..8c04d770 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListV.xaml.vb @@ -0,0 +1,16 @@ +Imports EgtBEAMWALL.Core + +Public Class FeatureInPartInRawPartListV + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub FeatureInPartInRawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + Dim RowVM As BTLFeatureVM = DirectCast(e.Row.DataContext, BTLFeatureVM) + ' se in produzione impedisco modifica dei parametri + If DirectCast(RowVM.BTLFeatureM.ParentPart, PartM).nProductionState > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListVM.vb new file mode 100644 index 00000000..be04a03a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureInPartInRawPartListVM.vb @@ -0,0 +1,71 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class FeatureInPartInRawPartListVM + Inherits VMBase + + Private m_colFeatureInPartInRawPart_Do As EgtDataGridColumn + Public ReadOnly Property colFeatureInPartInRawPart_Do As EgtDataGridColumn + Get + Return m_colFeatureInPartInRawPart_Do + End Get + End Property + + Private m_colFeatureInPartInRawPart_Priority As EgtDataGridColumn + Public ReadOnly Property colFeatureInPartInRawPart_Priority As EgtDataGridColumn + Get + Return m_colFeatureInPartInRawPart_Priority + End Get + End Property + + Private m_FeatureInPartInRawPartColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property FeatureInPartInRawPartColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_FeatureInPartInRawPartColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_FeatureInPartInRawPartColumns = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61610) + End Get + End Property + + Public ReadOnly Property Priority_Msg As String + Get + Return EgtMsg(61895) + End Get + End Property + +#End Region ' Messages + + Sub New() + ' creo riferimento in Map + Map.SetRefFeatureInPartInRawPartListVM(Me) + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_FEATUREINPARTINRAWPARTLIST, FeatureInPartInRawPartColumns) + ' recupero riferimento a colonna Do + m_colFeatureInPartInRawPart_Do = FeatureInPartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_DO) + m_colFeatureInPartInRawPart_Priority = FeatureInPartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_PRIORITY) + End Sub + + Friend Sub UpdateColumns(nMachType As MachineType) + If Not IsNothing(m_colFeatureInPartInRawPart_Priority) Then + m_colFeatureInPartInRawPart_Priority.Visible = (nMachType = MachineType.WALL AndAlso CurrentMachine.bIsEnabledPriority) + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml new file mode 100644 index 00000000..a922aa05 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml.vb new file mode 100644 index 00000000..3e547cd7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListV.xaml.vb @@ -0,0 +1,12 @@ +Public Class FeatureListV + + Private Sub FeatureList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM + End If + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListVM.vb new file mode 100644 index 00000000..0676439f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/FeatureListVM.vb @@ -0,0 +1,66 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class FeatureListVM + Inherits VMBase + + Private m_colFeature_Do As EgtDataGridColumn + Public ReadOnly Property colFeature_Do As EgtDataGridColumn + Get + Return m_colFeature_Do + End Get + End Property + + Private m_FeatureColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property FeatureColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_FeatureColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_FeatureColumns = value + End Set + End Property + + Private m_FeatureList_IsEnabled As Boolean = True + Public Property FeatureList_IsEnabled As Boolean + Get + Return m_FeatureList_IsEnabled + End Get + Set(value As Boolean) + m_FeatureList_IsEnabled = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61610) + End Get + End Property + +#End Region ' Messages + + Sub New() + ' creo riferimento in Map + Map.SetRefFeatureListVM(Me) + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_FEATURELIST, FeatureColumns) + ' recupero riferimento a colonna Do + m_colFeature_Do = FeatureColumns.FirstOrDefault(Function(x) x.Name = COL_DO) + End Sub + + Friend Sub SetBTLFeatureListIsEnabled(bIsEnabled As Boolean) + m_FeatureList_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(FeatureList_IsEnabled)) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml new file mode 100644 index 00000000..4c4d0c3f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml.vb new file mode 100644 index 00000000..339581c4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml.vb @@ -0,0 +1,179 @@ +Imports System.Reflection +Imports EgtBEAMWALL.Core.ConstGen + +Public Class OnlyProdBTLPartListV + + Private m_BTLPartListVM As BTLPartListVM + + Private m_SelectBtn As MouseButton = MouseButton.Left + Private m_HighlightBtn As MouseButton = MouseButton.Right + + Private m_NameDataGridType As Type + Private s_isDraggingSelectionField As FieldInfo + Private s_endDraggingMethod As MethodInfo + + Sub New() + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + m_BTLPartListVM = DataContext + m_NameDataGridType = BTLPart_DataGrid.GetType() + s_isDraggingSelectionField = m_NameDataGridType.GetField("_isDraggingSelection", BindingFlags.Instance Or BindingFlags.NonPublic) + s_endDraggingMethod = m_NameDataGridType.GetMethod("EndDragging", BindingFlags.Instance Or BindingFlags.NonPublic) + SetSelButton(MouseButton.Right) + End Sub + + Public Sub SetSelButton(SelButton As MouseButton) + Select Case SelButton + Case MouseButton.Right + m_SelectBtn = MouseButton.Right + m_HighlightBtn = MouseButton.Left + Case Else ' MouseButton.Left + m_SelectBtn = MouseButton.Left + m_HighlightBtn = MouseButton.Right + End Select + End Sub + + Public Sub DataGrid_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If e.ChangedButton = MouseButton.Left Then + If e.ChangedButton = m_SelectBtn Then + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + e.Handled = True + Else + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) + End If + ElseIf e.ChangedButton = m_HighlightBtn AndAlso (Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso + ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control)) Then + e.Handled = True + ElseIf e.ChangedButton = m_HighlightBtn Then + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + End If + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PARTLIST) + End If + End Sub + + Public Sub DataGrid_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) + If e.ChangedButton = MouseButton.Right Then + If e.ChangedButton = m_SelectBtn Then + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + e.Handled = True + Else + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) + End If + ElseIf e.ChangedButton = m_HighlightBtn Then + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + End If + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART) + End If + End Sub + + Public Shared Function FindVisualParent(Of T As DependencyObject)(ByVal child As DependencyObject) As T + Dim parentObject As DependencyObject = VisualTreeHelper.GetParent(child) + If parentObject Is Nothing Then Return Nothing + Dim parent As T = TryCast(parentObject, T) + + If parent IsNot Nothing Then + Return parent + Else + Return FindVisualParent(Of T)(parentObject) + End If + End Function + + Public Sub DataGrid_PreviewMouseMove(sender As Object, e As MouseEventArgs) + If m_SelectBtn = MouseButton.Left AndAlso e.LeftButton = MouseButtonState.Pressed Then + If CBool(If(s_isDraggingSelectionField?.GetValue(BTLPart_DataGrid), False)) Then s_endDraggingMethod.Invoke(BTLPart_DataGrid, New Object(-1) {}) + End If + End Sub + + Private Sub PartList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + 'If TypeOf sender Is DataGridRow Then + ' Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + ' If TypeOf Row.DataContext IsNot BTLPartVM Then Return + ' Dim VM As BTLPartVM = DirectCast(Row.DataContext, BTLPartVM) + ' VM.SetOpenFeatureList(Not VM.bOpenFeatureList) + ' 'If Row.IsSelected Then + ' ' VM.bOpenFeatureList = Not VM.bOpenFeatureList + ' 'Else + ' ' VM.bOpenFeatureList = False + ' 'End If + 'End If + 'If TypeOf sender Is DataGridRow Then + ' Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + ' If Not Row.IsSelected Then Return + ' If TypeOf Row.DataContext IsNot BTLPartVM Then Return + ' Dim VM As BTLPartVM = DirectCast(Row.DataContext, BTLPartVM) + ' If VM.bOpenFeatureList Then + ' VM.bOpenFeatureList = False + ' End If + 'End If + + 'If TypeOf sender Is DataGridRow Then + ' Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + ' If Not Row.IsSelected Then Return + ' Select Case e.ChangedButton + ' Case MouseButton.Left + ' If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + ' Return + ' Else + ' BTLPart_DataGrid.SelectedItem = Nothing + ' BTLPart_DataGrid.SelectedItem = Row.DataContext + ' End If + + ' Case MouseButton.Right + + + ' End Select + 'End If + End Sub + + Private Sub PartList_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) + + 'If TypeOf sender Is DataGridRow Then + ' Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + ' If Not Row.IsSelected Then Return + ' Select Case e.ChangedButton + ' Case MouseButton.Right + ' If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + ' Row.IsSelected = Not Row.IsSelected + ' Else + ' BTLPart_DataGrid.SelectedItem = Nothing + ' BTLPart_DataGrid.SelectedItem = Row.DataContext + ' ' metto focus su cella selezionata per evitare errori di focus del sistema normale + ' Dim dep As DependencyObject = CType(e.OriginalSource, DependencyObject) + ' While (dep IsNot Nothing) AndAlso Not (TypeOf dep Is DataGridCell) + ' dep = VisualTreeHelper.GetParent(dep) + ' End While + ' If dep Is Nothing Then Return + ' If TypeOf dep Is DataGridCell Then + ' Dim cell As DataGridCell = TryCast(dep, DataGridCell) + ' cell.Focus() + ' End If + ' End If + ' End Select + 'End If + + End Sub + + Private Sub ListBox_PreviewMouseWheel(ByVal sender As Object, ByVal e As MouseWheelEventArgs) + ' gestione dello scroll, per permetterlo anche quando mouse su RowDetails + e.Handled = True + Dim DependencyParent As DependencyObject = sender + While TypeOf DependencyParent IsNot ListBox + DependencyParent = VisualTreeHelper.GetParent(DependencyParent) + End While + If IsNothing(DependencyParent) Then + Return + End If + Dim parent As ListBox = TryCast(DependencyParent, ListBox) + If IsNothing(parent) Then + Return + End If + parent?.[RaiseEvent](New MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) With { + .RoutedEvent = MouseWheelEvent, + .Source = sender + }) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml new file mode 100644 index 00000000..850af1c7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml.vb new file mode 100644 index 00000000..7ffe09bc --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureInPartInRawPartListV.xaml.vb @@ -0,0 +1,25 @@ +Imports EgtBEAMWALL.Core + +Public Class OnlyProdFeatureInPartInRawPartListV + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub FeatureInPartInRawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + Dim RowVM As BTLFeatureVM = DirectCast(e.Row.DataContext, BTLFeatureVM) + ' se in produzione impedisco modifica dei parametri + If DirectCast(RowVM.BTLFeatureM.ParentPart, PartM).nProductionState > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + + Private Sub FeatureList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart) Then + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.SelFeatureVM + End If + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml new file mode 100644 index 00000000..6962e0f1 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml.vb new file mode 100644 index 00000000..505d5dfa --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdFeatureListV.xaml.vb @@ -0,0 +1,12 @@ +Public Class OnlyProdFeatureListV + + Private Sub FeatureList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM + End If + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml new file mode 100644 index 00000000..d38b948e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml.vb new file mode 100644 index 00000000..e7a4f034 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPParameterListV.xaml.vb @@ -0,0 +1,12 @@ +Public Class OnlyProdPParameterListV + + Private Sub PParameterList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam + End If + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml new file mode 100644 index 00000000..1d8e8d7b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml.vb new file mode 100644 index 00000000..85174012 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdPartInRawPartListV.xaml.vb @@ -0,0 +1,29 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib.EgtInterface + +Public Class OnlyProdPartInRawPartListV + + ' funzione che permette di selezionare un pezzo anche quando gia' selezionato + Private Sub PartInRawPartRow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) Then + Dim MyMachGroup As Core.MyMachGroupVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = MyMachGroup + MyMachGroup.SelPart = MyMachGroup.SelPart + End If + End If + End Sub + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub PartInRawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + Dim RowVM As PartVM = DirectCast(e.Row.DataContext, PartVM) + ' se in produzione impedisco modifica dei parametri + If RowVM.nProduction_State > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml new file mode 100644 index 00000000..f964f5fc --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml.vb new file mode 100644 index 00000000..472d689c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListProdV.xaml.vb @@ -0,0 +1,27 @@ +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstGen + +Public Class OnlyProdQParameterListProdV + + Private Sub QParameterList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam + End If + End If + End Sub + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub QParameterList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + If Map.refMainMenuVM.SelPage <> Pages.MACHINING Then Return + Dim RowVM As BTLParamVM = DirectCast(e.Row.DataContext, BTLParamVM) + ' se in produzione impedisco modifica dei parametri + If DirectCast(RowVM.BTLParamM.ParentFeature.ParentPart, PartM).nProductionState > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml new file mode 100644 index 00000000..610352b2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml.vb new file mode 100644 index 00000000..ab7b55d5 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdQParameterListV.xaml.vb @@ -0,0 +1,26 @@ +Imports EgtBEAMWALL.Core + +Public Class OnlyProdQParameterListV + + Private Sub QParameterList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam + End If + End If + End Sub + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub QParameterList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + If Map.refMainMenuVM.SelPage <> Pages.MACHINING Then Return + Dim RowVM As BTLParamVM = DirectCast(e.Row.DataContext, BTLParamVM) + ' se in produzione impedisco modifica dei parametri + If DirectCast(RowVM.BTLParamM.ParentFeature.ParentPart, PartM).nProductionState > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml new file mode 100644 index 00000000..0546e46b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml.vb new file mode 100644 index 00000000..846ac030 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdRawPartListV.xaml.vb @@ -0,0 +1,28 @@ +Imports EgtBEAMWALL.Core + +Public Class OnlyProdRawPartListV + + ' funzione che permette di selezionare un RawPart anche quando gia' selezionato + Private Sub RawPartRow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + Dim RowVM As MyMachGroupVM = DirectCast(Row.DataContext, MyMachGroupVM) + ' se gia' selezionato rifaccio selezione perche' potrbbe essere selezionato un BTLPart + If Not IsNothing(Row) AndAlso Row.IsSelected Then + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup + End If + End If + End Sub + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub RawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + Dim RowVM As MyMachGroupVM = DirectCast(e.Row.DataContext, MyMachGroupVM) + ' se in produzione impedisco modifica dei parametri + If RowVM.nProduction_State > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml new file mode 100644 index 00000000..93561f54 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml.vb new file mode 100644 index 00000000..ccb518b4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListV.xaml.vb @@ -0,0 +1,12 @@ +Public Class PParameterListV + + Private Sub PParameterList_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) AndAlso Row.IsSelected AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam = Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.SelPBTLParam + End If + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListVM.vb new file mode 100644 index 00000000..bb2b1fea --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PParameterListVM.vb @@ -0,0 +1,97 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class PParameterListVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_colPParam_Value As EgtDataGridColumn + Public ReadOnly Property colPParam_Value As EgtDataGridColumn + Get + Return m_colPParam_Value + End Get + End Property + + Private m_PParameterListColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property PParameterListColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_PParameterListColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_PParameterListColumns = value + End Set + End Property + + Private m_PParameterList_IsEnabled As Boolean = True + Public Property PParameterList_IsEnabled As Boolean + Get + Return m_PParameterList_IsEnabled + End Get + Set(value As Boolean) + m_PParameterList_IsEnabled = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property Custom_Msg As String + Get + Return EgtMsg(61801) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61808) + End Get + End Property + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property Value_Msg As String + Get + Return EgtMsg(61615) + End Get + End Property + + Public ReadOnly Property Min_Msg As String + Get + Return EgtMsg(61616) + End Get + End Property + Public ReadOnly Property Max_Msg As String + Get + Return EgtMsg(61617) + End Get + End Property + +#End Region ' Messages + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Aggiungo riferimento a Map + Map.SetRefPParameterListVM(Me) + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_PARAMETERLIST_P, PParameterListColumns) + ' recupero riferimento a colonna Value + m_colPParam_Value = PParameterListColumns.FirstOrDefault(Function(x) x.Name = COL_VALUE) + End Sub + +#End Region ' CONSTRUCTOR + + Friend Sub SetPParameterListIsEnabled(bIsEnabled As Boolean) + m_PParameterList_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(PParameterList_IsEnabled)) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml new file mode 100644 index 00000000..ed7bf107 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml.vb b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml.vb new file mode 100644 index 00000000..55c57d93 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListV.xaml.vb @@ -0,0 +1,29 @@ +Imports EgtUILib +Imports EgtBEAMWALL.Core + +Public Class PartInRawPartListV + + ' funzione che permette di selezionare un pezzo anche quando gia' selezionato + Private Sub PartInRawPartRow_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) + If TypeOf sender Is DataGridRow Then + Dim Row As DataGridRow = DirectCast(sender, DataGridRow) + If Not IsNothing(Row) Then + Dim MyMachGroup As Core.MyMachGroupVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = MyMachGroup + MyMachGroup.SelPart = MyMachGroup.SelPart + End If + End If + End Sub + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub PartInRawPartList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + If IsNothing(e.Row) Then Return + Dim RowVM As PartVM = DirectCast(e.Row.DataContext, PartVM) + ' se in produzione impedisco modifica dei parametri + If RowVM.nProduction_State > ItemState.ND Then + 'For Each cell In Row.Item + e.Cancel = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListVM.vb new file mode 100644 index 00000000..1e35516d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PartInRawPartListVM.vb @@ -0,0 +1,165 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class PartInRawPartListVM + + Private m_colPartInRawPart_Offset As EgtDataGridColumn + Public ReadOnly Property colPartInRawPart_Offset As EgtDataGridColumn + Get + Return m_colPartInRawPart_Offset + End Get + End Property + + Private m_colPartInRawPart_Rot As EgtDataGridColumn + Public ReadOnly Property colPartInRawPart_Rot As EgtDataGridColumn + Get + Return m_colPartInRawPart_Rot + End Get + End Property + + Private m_colPartInRawPart_Flip As EgtDataGridColumn + Public ReadOnly Property colPartInRawPart_Flip As EgtDataGridColumn + Get + Return m_colPartInRawPart_Flip + End Get + End Property + + Private m_colPartInRawPart_PosX As EgtDataGridColumn + Public ReadOnly Property colPartInRawPart_PosX As EgtDataGridColumn + Get + Return m_colPartInRawPart_PosX + End Get + End Property + + Private m_colPartInRawPart_PosY As EgtDataGridColumn + Public ReadOnly Property colPartInRawPart_PosY As EgtDataGridColumn + Get + Return m_colPartInRawPart_PosY + End Get + End Property + + Private m_PartInRawPartColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property PartInRawPartColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_PartInRawPartColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_PartInRawPartColumns = value + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property PDN_Msg As String + Get + Return EgtMsg(61809) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61605) + End Get + End Property + + Public ReadOnly Property H_Msg As String + Get + Return EgtMsg(61606) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61604) + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + Public ReadOnly Property PosX_Msg As String + Get + Return EgtMsg(61811) + End Get + End Property + Public ReadOnly Property PosY_Msg As String + Get + Return EgtMsg(61812) + End Get + End Property + Public ReadOnly Property Offset_Msg As String + Get + Return EgtMsg(61755) + End Get + End Property + + Public ReadOnly Property MAT_Msg As String + Get + Return EgtMsg(61607) + End Get + End Property + + Public ReadOnly Property GRP_Msg As String + Get + Return EgtMsg(61624) + End Get + End Property + + Public ReadOnly Property STOREY_Msg As String + Get + Return EgtMsg(61623) + End Get + End Property + + Public ReadOnly Property ROTATION_Msg As String + Get + Return EgtMsg(61737) + End Get + End Property + + Public ReadOnly Property INVERSION_Msg As String + Get + Return EgtMsg(61738) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTOR" + + Sub New() + ' aggiungo riferimento a map + Map.SetRefPartInRawPartListVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + + Friend Sub UpdateColumns(nMachType As MachineType) + If nMachType = MachineType.BEAM Then + PartInRawPartColumns.Clear() + GetPrivateProfileColumns(S_PARTINRAWPARTLIST_BEAM, PartInRawPartColumns) + ElseIf nMachType = MachineType.WALL Then + PartInRawPartColumns.Clear() + GetPrivateProfileColumns(S_PARTINRAWPARTLIST_WALL, PartInRawPartColumns) + End If + ' recupero riferimento a colonne Offset, Rot, Flip, PosX, PosY + m_colPartInRawPart_Offset = m_PartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_OFFSET) + m_colPartInRawPart_Rot = m_PartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_ROT) + m_colPartInRawPart_Flip = m_PartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_FLIP) + m_colPartInRawPart_PosX = m_PartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_POSX) + m_colPartInRawPart_PosY = m_PartInRawPartColumns.FirstOrDefault(Function(x) x.Name = COL_POSY) + ' aggiorno la visibilità delle colonne + For Each col In PartInRawPartColumns + If Not bOnlyProd AndAlso nMachType = MachineType.BEAM AndAlso (col.Name.Equals(COL_ROT) OrElse col.Name.Equals(COL_FLIP) OrElse col.Name.Equals(COL_POSX)) Then + col.Visible = False + Else + col.Visible = True + End If + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/PartParametersV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/PartParametersV.xaml new file mode 100644 index 00000000..c23ade09 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ItemParamList/PartParametersV.xaml @@ -0,0 +1,463 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb new file mode 100644 index 00000000..c991aa65 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/LeftPanel/OnlyProdLeftPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdLeftPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamMachGroupVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamMachGroupVM.vb new file mode 100644 index 00000000..d76c44a7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamMachGroupVM.vb @@ -0,0 +1,340 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BeamMachGroupVM + Inherits Core.BeamMachGroupVM + + Public Overrides Property sStartCut As String + Get + Return LenToString(m_BeamMachGroupM.dStartCut, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLen(value, dValue) Then + Dim dOldValue As Double = m_BeamMachGroupM.dStartCut + m_BeamMachGroupM.dStartCut = dValue + If Not ReDrawBeamMachgroup() Then + ' rispristino vecchio valore + m_BeamMachGroupM.dStartCut = dOldValue + ReDrawBeamMachgroup() + End If + m_BeamMachGroupM.dStartCut = dValue + EgtDraw() + If PartVMList.Count > 0 Then + Dim Beam As BeamVM = DirectCast(PartVMList(0), BeamVM) + Beam.m_BeamM.UpdateOffset() + Beam.NotifyPropertyChanged(NameOf(Beam.sOffset)) + End If + ' resetto validazione del pezzo primo pezzo + If PartVMList.Count > 0 Then + PartVMList(0).ResetCalcPart() + Else + ResetCalcMachGroup() + End If + Else + NotifyPropertyChanged(NameOf(sStartCut)) + End If + End Set + End Property + +#Region "CONSTRUCTORS" + + Sub New(BeamMachGroupM As BeamMachGroupM) + MyBase.New(BeamMachGroupM) + ' aggiorno stato di produzione + ReadProductionState() + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Protected Overrides Sub CreateBeamVMList() + Dim all As List(Of BeamVM) = (From BeamM In m_BeamMachGroupM.GetParts() + Select New BeamVM(BeamM, Me)).ToList() + + For Each BeamVM As BeamVM In all + AddHandler BeamVM.PropertyChanged, AddressOf OnBeamVMPropertyChanged + Next + + m_PartVMList = New ObservableCollection(Of Core.PartVM)(all) + AddHandler m_PartVMList.CollectionChanged, AddressOf OnBeamVMListChanged + End Sub + + Private Sub ReadProductionState() + If IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProdManagerVM.CurrProd.nProdId) Then Return + Dim MachGroupModel As MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(Map.refProdManagerVM.CurrProd.nProdId, Id) + If Not IsNothing(MachGroupModel) Then + If Not String.IsNullOrEmpty(MachGroupModel.SupervisorId) Then + SetSupervisorId(MachGroupModel.SupervisorId) + End If + MyMachGroupM.SetProductionState(MachGroupModel.State) + End If + End Sub + + Public Overrides Sub RefreshPartList() + ' leggo StartCut da posizione primo pezzo + Dim sInfo As String = "" + Dim sSplitInfo() As String + Dim bFound As Boolean = False + EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo) + If Not String.IsNullOrWhiteSpace(sInfo) Then + sSplitInfo = sInfo.Split(","c) + StringToDouble(sSplitInfo(1), m_BeamMachGroupM.dStartCut) + Else + m_BeamMachGroupM.dStartCut = 0 + End If + '' aggiorno lista pezzi + 'PartVMList.Clear() + 'Dim nRawPartId As Integer = EgtGetFirstRawPart() + 'While nRawPartId <> GDB_ID.NULL + ' Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + ' If nPartId <> GDB_ID.NULL Then + ' Dim NewBeam As BeamVM = New BeamVM(Me, nPartId, nRawPartId) + ' PartVMList.Add(NewBeam) + ' NewBeam.UpdateOffset() + ' End If + ' nRawPartId = EgtGetNextRawPart(nRawPartId) + 'End While + End Sub + + Public Overrides Sub RefreshGroupData() + + End Sub + + Friend Sub UpdateUsage() + m_BeamMachGroupM.SetTotMat(dL) + m_BeamMachGroupM.SetMatForPart(0) + For Each Part In PartVMList + m_BeamMachGroupM.SetMatForPart(m_BeamMachGroupM.dMatForPart + Part.dL) + Next + NotifyPropertyChanged(NameOf(dUsage)) + NotifyPropertyChanged(NameOf(dWaste)) + End Sub + + Friend Function ReDrawBeamMachgroup() As Boolean + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = m_BeamMachGroupM.dStartCut + Dim nIndex As Integer + For nIndex = 0 To PartVMList.Count - 1 + If nIndex <> 0 Then + Dim Beam As BeamVM = DirectCast(PartVMList(nIndex), BeamVM) + dPosX += Beam.m_BeamM.dOffset + End If + PartVMList(nIndex).dPOSX = dPosX + EgtSetInfo(Id, MGR_RPT_PART & nIndex + 1, PartVMList(nIndex).nPartId & "," & DoubleToString(dPosX, 3)) + dPosX += PartVMList(nIndex).dL + Next + ' elimino eventuali successive info pezzi di troppo + nIndex = PartVMList.Count + 1 + Dim sTemp As String = "" + While EgtGetInfo(Id, MGR_RPT_PART & nIndex, sTemp) + EgtSetInfo(Id, MGR_RPT_PART & nIndex, "") + nIndex += 1 + End While + ' elimino vecchio grezzo ed eseguo script creazione nuovo + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemovePartFromRawPart(EgtGetFirstPartInRawPart(nRawId)) + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + If Not ExecBeam(Map.refMainWindowVM.MainWindowM.sTempDir, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then Return False + + Return True + End Function + + Friend Sub MoveBeam(Beam As BeamVM, MoveDirection As MoveDirections) + Dim nBeamIndex As Integer = PartVMList.IndexOf(Beam) + If nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.UP Then Return + If nBeamIndex = PartVMList.Count - 1 AndAlso MoveDirection = MoveDirections.DOWN Then Return + ' se pezzo mosso diventa primo + Dim FirstBeam As BeamVM + If (nBeamIndex = 1 AndAlso MoveDirection = MoveDirections.UP) OrElse (nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.DOWN) Then + '' resetto offset per vecchio primo + FirstBeam = DirectCast(PartVMList(0), BeamVM) + FirstBeam.ResetOffset() + End If + PartVMList.Move(nBeamIndex, nBeamIndex + MoveDirection) + ReDrawBeamMachgroup() + ' aggiorno offset primo pezzo + FirstBeam = DirectCast(PartVMList(0), BeamVM) + FirstBeam.m_BeamM.UpdateOffset() + FirstBeam.NotifyPropertyChanged(NameOf(FirstBeam.sOffset)) + End Sub + + Friend Sub ReorderBeam() + Dim TempPartList = PartVMList.OrderBy(Function(x) x.dL).ToList() + ' verifico se sono già in oridne + Dim bSort As Boolean = True + For PartIndex = 0 To PartVMList.Count - 1 + If PartVMList(PartIndex).nPartId <> TempPartList(PartIndex).nPartId Then + bSort = False + Exit For + End If + Next + If bSort Then Return + ' resetto offset primo pezzo + Dim FirstBeam As BeamVM = DirectCast(PartVMList(0), BeamVM) + FirstBeam.ResetOffset() + For PartIndex = 0 To TempPartList.Count - 1 + If PartVMList(PartIndex).nPartId <> TempPartList(PartIndex).nPartId Then + PartVMList.Move(PartVMList.IndexOf(TempPartList(PartIndex)), PartIndex) + End If + Next + ReDrawBeamMachgroup() + ' aggiorno offset primo pezzo + FirstBeam = DirectCast(PartVMList(0), BeamVM) + FirstBeam.m_BeamM.UpdateOffset() + FirstBeam.NotifyPropertyChanged(NameOf(FirstBeam.sOffset)) + End Sub + + Public Overrides Function Copy() As Core.MyMachGroupVM + EgtResetCurrMachGroup() + ' recupero lista dei pezzi BTL originali + Dim PartList As New List(Of BTLPartVM) + For Each Part In m_PartVMList + PartList.Add(BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId)) + Next + ' verifico che nessun pezzo da copiare abbia raggiunto il numero massimo + If Not VerifyPartCount(PartList) Then Return Nothing + ' creo nuovo gruppo di lavorazione + Map.refMachGroupPanelVM.AddMachGroup() + Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup() + Dim sCurrMachGroupName As String = "" + EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) + ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, Map.refProdManagerVM.CurrProd.nProdId) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dL) + For Index = 0 To m_PartVMList.Count - 1 + ' creo copia del pezzo + Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId) + ' lo rendo std + EgtSetMode(nPartDuploId, GDB_MD.STD) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & 1, nPartDuploId & "," & m_PartVMList(Index).sPOSX) + Next + Dim BeamMachGroup As BeamMachGroupVM = Map.refMachGroupPanelVM.GetLastMachGroup() + ' eseguo script creazione grezzo + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then + BeamMachGroup.DeleteMachGroup() + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return Nothing + End If + ' aggiorno contatore pezzi usati in Prod + For Each Part In PartList + Part.RefreshPartInProd() + Next + 'aggiorno lista pezzi + BeamMachGroup.m_BeamMachGroupM.RefreshPartList() + BeamMachGroup.m_BeamMachGroupM.RefreshGroupData() + ' aggiorno dati ultilizzo barra + BeamMachGroup.UpdateUsage() + EgtSetView(VT.ISO_SW, False) + Return BeamMachGroup + End Function + + Private Function VerifyPartCount(SelParts As List(Of BTLPartVM)) As Boolean + Dim sPartToAdd As String = "Raggiunto numero di pezzi da produrre per:" + Dim bPartToAdd As Boolean = False + For Each Part In SelParts + ' verifico se ci sono pezzi da aggiungere + If Not Part.CanAddPartToCount() Then + bPartToAdd = True + sPartToAdd &= Environment.NewLine & "- PDN" & Part.nPDN & " | BTL QTY " & Part.nCNT & " | ADDED QTY " & Part.nADDED + End If + Next + sPartToAdd &= Environment.NewLine & "Aggiungerli?" + If bPartToAdd Then + If MessageBox.Show(sPartToAdd, "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + For Each Part In SelParts + If Not Part.CanAddPartToCount() Then Part.AddNewPartToAdded() + Next + Else + Return False + End If + End If + Return True + End Function + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "DeleteMachGroup" + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overrides Sub DeleteMachGroup() + ' elimino tutte le copie + Dim nRawPartId As Integer = EgtGetFirstRawPart() + If nType = BWType.BEAM Then + Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nRawPartId <> GDB_ID.NULL + If EgtRemovePartFromRawPart(nBeamId) Then + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nBeamId) + EgtErase(nBeamId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + End If + nRawPartId = EgtGetNextRawPart(nRawPartId) + nBeamId = EgtGetFirstPartInRawPart(nRawPartId) + End While + Else + Dim nWallId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nWallId <> GDB_ID.NULL + If EgtRemovePartFromRawPart(nWallId) Then + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nWallId) + EgtErase(nWallId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + End If + nWallId = EgtGetFirstPartInRawPart(nRawPartId) + End While + End If + ' elimino MachGroup + EgtRemoveMachGroup(Me.Id) + ' rimuovo dalla lista grezzi + Dim Index As Integer = Map.refMachGroupPanelVM.MachGroupVMList.IndexOf(Me) + If Index = 0 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(0) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + ElseIf Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 2) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Index - 1) + End If + Map.refMachGroupPanelVM.MachGroupVMList.Remove(Me) + End Sub + +#End Region ' DeleteMachGroup + +#End Region ' COMMANDS + + Protected Overrides Sub OnBeamAdded(sender As Object, e As PartAddedEventArgs) + Dim BeamVM As BeamVM = New BeamVM(e.NewPart, Me) + PartVMList.Add(BeamVM) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamVM.vb new file mode 100644 index 00000000..1d1fdc80 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/BeamVM.vb @@ -0,0 +1,100 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class BeamVM + Inherits Core.BeamVM + + Public Overrides Property sOffset As String + Get + Return LenToString(m_BeamM.dOffset, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLen(value, dValue) Then + Dim dOldValue As Double = m_BeamM.dOffset + m_BeamM.dOffset = dValue + ' se prima trave della barra sostituisco valore anche a startoffset + Dim BeamMachGroup As BeamMachGroupVM = DirectCast(ParentMachGroupVM, BeamMachGroupVM) + If ParentMachGroupVM.PartVMList(0) Is Me Then + BeamMachGroup.dStartCut = dValue + End If + If Not BeamMachGroup.ReDrawBeamMachgroup() Then + ' rispristino vecchio valore + m_BeamM.dOffset = dOldValue + BeamMachGroup.dStartCut = dOldValue + BeamMachGroup.ReDrawBeamMachgroup() + End If + ' resetto validazione del pezzo + ResetCalcPart() + Else + NotifyPropertyChanged(NameOf(sOffset)) + End If + End Set + End Property + + Friend Sub ResetOffset() + m_BeamM.dOffset = RawPartConfiguration.dBeamDist + NotifyPropertyChanged(NameOf(sOffset)) + End Sub + +#Region "CONSTRUCTOR" + + Sub New(BeamM As BeamM, ParentMachGroupVM As BeamMachGroupVM) + MyBase.New(BeamM, ParentMachGroupVM) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Protected Overrides Sub CreateBTLFeatureVMList() + Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures() + Select New BTLFeatureVM(BTLFeatureM)).ToList() + + For Each BTLFeatureVM As BTLFeatureVM In all + AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + Next + + m_FeatureVMList = New ObservableCollection(Of Core.BTLFeatureVM)(all) + AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged + + End Sub + +#End Region ' METHODS + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overrides Sub DeletePart() + ' elimino pezzo copia + EgtRemovePartFromRawPart(Me.nPartId) + ' Recupero Id BTLPart originale + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nPartId) + EgtErase(Me.nPartId) + ' rimuovo dalla lista pezzi + Dim Index As Integer = ParentMachGroupVM.PartVMList.IndexOf(ParentMachGroupVM.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId)) + If Index = 0 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(0) + Else + ParentMachGroupVM.SelPart = Nothing + End If + ElseIf Index = ParentMachGroupvm.PartvMList.Count - 1 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(ParentMachGroupVM.PartVMList.Count - 2) + Else + ParentMachGroupVM.SelPart = Nothing + End If + Else + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1) + End If + ParentMachGroupVM.PartVMList.Remove(Me) + Dim BeamParentMachGroup As BeamMachGroupVM = DirectCast(ParentMachGroupVM, BeamMachGroupVM) + If Not IsNothing(BeamParentMachGroup) Then BeamParentMachGroup.ReDrawBeamMachgroup() + ' aggiorno contatore pezzi usati in Prod + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + EgtDraw() + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupPanelVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupPanelVM.vb new file mode 100644 index 00000000..d836e2c1 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupPanelVM.vb @@ -0,0 +1,260 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class MyMachGroupPanelVM + Inherits Core.MyMachGroupPanelVM + +#Region "FIELDS & PROPERTIES" + + Public Shadows Property SelectedMachGroup As MyMachGroupVM + Get + Return m_SelectedMachGroup + End Get + Set(value As MyMachGroupVM) + ' deevidenzio BTLPart di questo pezzo + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' mostro pezzi selezionati + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count = 1 Then + ' se pezzo evidenziato da selezione precedente + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST Then + Dim nSelBTLPartId As Integer = Map.refProjectVM.BTLStructureVM.SelBTLParts(0).nPartId + ' deevidenzio MachGroup e Duplo di questo pezzo + Configuration.ResetSearchPiece(nSelBTLPartId) + End If + End If + If Not IsNothing(SelectedMachGroup) AndAlso Not IsNothing(SelectedMachGroup.SelPart) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Configuration.ResetSearch(SelectedMachGroup.SelPart.nPartId) + End If + ' se modalita' assemblato + Configuration.AssembledMode(Map.refShowBeamPanelVM.ShowBuilding_IsChecked) + ' se precedente pezzo selezionato + If Not IsNothing(value) AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART AndAlso Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 0 Then + Dim SelBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLParts(0) + ' deseleziono pezzo in lista BTLPart + For BTLPartIndex = Map.refProjectVM.BTLStructureVM.SelBTLParts.Count - 1 To 0 Step -1 + Map.refProjectVM.BTLStructureVM.SelBTLParts.RemoveFromList(Map.refProjectVM.BTLStructureVM.SelBTLParts(BTLPartIndex)) + Next + ' e lo evidenzio + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + Map.refProdProjManagerVM.SelProdProj = ProdProj.NULL + Map.refShowBeamPanelVM.SetShowSolid(False) + Else + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + End If + Map.refProjectVM.BTLStructureVM.SelBTLParts.Add(SelBTLPart) + End If + End If + + If Map.refMainMenuVM.SelPage <> Pages.ONLYPRODPAGE Then Map.refShowBeamPanelVM.bShowAll = False + + m_SelectedMachGroup = value + If Not IsNothing(value) Then + OnPreSetCurrMachGroup() + EgtSetCurrMachGroup(value.Id) + OnPostSetCurrMachGroup() + End If + NotifyPropertyChanged(NameOf(SelectedMachGroup)) + ' imposto tipo di grid selezionata + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(value) Then + Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.MACHGROUP) + Map.refStatisticsTimePanelVM.SetMachiningPage_Visibility(Visibility.Visible) + Map.refStatisticsTimePanelVM.SetViewPage_Visibility(Visibility.Collapsed) + End If + ' se MachGroup gia' mandato in produzione,disabilito pulsanti verify e reset + If Not IsNothing(SelectedMachGroup) AndAlso SelectedMachGroup.nProduction_State >= ItemState.Assigned Then + Map.refCALCPanelVM.SetVerifyIsEnabled(False) + Else + Map.refCALCPanelVM.SetCalcPanelIsEnabled(True) + End If + End Set + End Property + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(MachGroupPanelM As MachGroupPanelM) + MyBase.New(MachGroupPanelM) + ' elimino copie da cancellare + DeleteDuplo() + ' verifico se volume grezzi calcolato + For Each MachGroup As MyMachGroupVM In m_MachGroupVMList + Dim bIsCalculated As Boolean = False + For Each Part In MachGroup.PartVMList + If Part.dVolume > 0 Then Continue For + Part.PartM.ReadVolume() + bIsCalculated = True + Next + If bIsCalculated Then + MachGroup.UpdateUsage() + End If + Next + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Protected Overrides Sub CreateMachGroupVMList() + Dim all As New List(Of MachGroupVM) + For Each MachGroupM In m_MachGroupPanelM.GetMachGroups() + all.Add(New MyMachGroupVM(MachGroupM)) + Next + + For Each MachGroupvM As MachGroupVM In all + AddHandler MachGroupvM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged + Next + + MachGroupVMList = New ObservableCollection(Of MachGroupVM)(all) + AddHandler MachGroupVMList.CollectionChanged, AddressOf OnMachGroupVMListChanged + End Sub + + Protected Overrides Sub OnMachGroupAdded(sender As Object, e As MachGroupAddedEventArgs) + Dim MachGroupVM As MachGroupVM = Nothing + Select Case DirectCast(e.NewMachGroupM, MyMachGroupM).nType + Case Core.ConstBeam.MachineType.BEAM, Core.ConstBeam.MachineType.WALL + MachGroupVM = New MyMachGroupVM(e.NewMachGroupM) + Case Core.ConstBeam.MachineType.NULL + Return + End Select + MachGroupVMList.Add(MachGroupVM) + NotifyPropertyChanged(NameOf(MachGroupVMList)) + End Sub + + Public Function RefreshMachGroupList() As Boolean + ' carico lista dei gruppi di lavorazione + For Each MachGroup As MyMachGroupM In MyMachGroupPanelM.UpdateFromNestingMyMachGroups(Map.refMachinePanelVM.MachineList.ToList()) + m_MachGroupPanelM.AddMachGroup(MachGroup) + Next + ' aggiorno contatore pezzi in produzione + For Each MachGroup As MyMachGroupVM In MachGroupVMList + For Each Part In MachGroup.PartVMList + ' aggiorno calcolo pezzi in produzione + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + Next + Next + ' seleziono primo MachGroup + If MachGroupVMList.Count > 0 Then SelectedMachGroup = MachGroupVMList(0) + EgtZoom(ZM.ALL) + Return True + End Function + + ' funzione utilizzata per caricare in lista gruppo aggiunto al progetto dal supervisore + Public Function AddMachGroupToList(nId As Integer) As Boolean + ' carico gruppo di lavorazione + Dim MachGroup As MyMachGroupM = MyMachGroupPanelM.LoadMyMachGroupFromId(nId, Map.refMachinePanelVM.MachineList.ToList()) + If Not IsNothing(MachGroup) Then + m_MachGroupPanelM.AddMachGroup(MachGroup) + Return True + End If + Return False + End Function + + ' funzione che cancella tutti i pezzi segnati da eliminare + Public Sub DeleteDuplo() + ' reset necessario per poter accedere direttamente al grezzo dalle info pezzo e al MachGroup tramite la gerarchia Db geometrico + EgtResetCurrMachGroup() + Dim bDuploToDeleteFound As Boolean = False + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + Dim bIsToDelete As Boolean = False + If DuploGetToDelete(nPartId, bIsToDelete) AndAlso bIsToDelete Then + ' verifico se ci sono copie + Dim nDuploCount As Integer = 0 + EgtDuploCount(nPartId, nDuploCount) + Dim DuploList As New List(Of Integer) + If nDuploCount > 0 AndAlso EgtDuploList(nPartId, DuploList) Then + bDuploToDeleteFound = True + ' cancello tutti i pezzi copia nelle barre + For Each nDuploId In DuploList + ' recupero grezzo cui appartiene + Dim nRawPartId As Integer = MyMachGroupPanelM.DuploGetRawPart(nDuploId) + ' recupero gruppo di lavorazione + Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(nRawPartId)) + ' lo setto come corrente + EgtSetCurrMachGroup(nMachGroupId) + ' elimino pezzo copia + EgtRemovePartFromRawPart(nDuploId) + EgtErase(nDuploId) + ' recupero gruppo di lavorazione e trave dell'interfaccia + Dim BeamMachGroup As MyMachGroupVM = MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId) + If Not IsNothing(BeamMachGroup) Then + Dim Beam As PartVM = BeamMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nDuploId) + EgtSetCurrMachGroup(BeamMachGroup.Id) + Beam.DeletePart() + End If + ' reset necessario per poter ottenere nMachGroupId corretto + EgtResetCurrMachGroup() + ' aggiorno dati utilizzo barra + BeamMachGroup.UpdateUsage() + Next + ' aggiorno quantita' in prod + Dim BTLPart As BTLPartVM = CALCPanelVM.GetBTLPartVMFromBTLPartId(nPartId) + BTLPart.RefreshPartInProd() + End If + DuploResetToDelete(nPartId) + End If + nPartId = EgtGetNextPart(nPartId) + End While + ' se cancellato almeno un pezzo + If bDuploToDeleteFound Then + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refOnlyProdManagerVM.Save() + Else + Map.refProdManagerVM.Save() + End If + End If + EgtResetCurrMachGroup() + End Sub + + Friend Shared Function DuploGetToDelete(nSouId As Integer, ByRef bToDelete As Boolean) As Boolean + If IsNothing(nSouId) Then Return False + Return EgtGetInfo(nSouId, DUPLO_TODELETE, bToDelete) + End Function + + Public Shared Function DuploSetToDelete(nSouId As Integer) As Boolean + If IsNothing(nSouId) Then Return False + Return EgtSetInfo(nSouId, DUPLO_TODELETE, True) + End Function + + Private Shared Function DuploResetToDelete(nSouId As Integer) As Boolean + If IsNothing(nSouId) Then Return False + Return EgtSetInfo(nSouId, DUPLO_TODELETE, "") + End Function + + Public Overrides Sub AddMachGroup() + Dim MyMachGroupM As MyMachGroupM = m_MyMachGroupPanelM.NewMyMachGroup(CurrentMachine.sMachineName, Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' e lo seleziono + SelectedMachGroup = MachGroupVMList.FirstOrDefault(Function(x) x.MachGroupM Is MyMachGroupM) + End Sub + + ' funzione che seleziona primo gruppo + Friend Sub SelFirstMachGroup() + If Not IsNothing(Me) AndAlso Not IsNothing(MachGroupVMList) AndAlso MachGroupVMList.Count > 0 Then + SelectedMachGroup = MachGroupVMList(0) + Else + SelectedMachGroup = Nothing + EgtResetCurrMachGroup() + ' nascondo tutti i pezzi + Map.refProjectVM.BTLStructureVM.HideAll() + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + End If + End Sub + + Public Overrides Function OnPostSetCurrMachGroup() As Boolean + ' resetto eventuale selezione pezzo + Dim SelMachGroup As MyMachGroupVM = DirectCast(SelectedMachGroup, MyMachGroupVM) + SelMachGroup.SetSelPart(Nothing) + ' Imposto vista solo tavola + EgtSetMachineLook(MCH_LOOK.TAB) + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL) + Return True + End Function + +#End Region ' METHODS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.qq.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.qq.vb new file mode 100644 index 00000000..31fc1e8b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.qq.vb @@ -0,0 +1,60 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public MustInherit Class MyMachGroupVM + Inherits Core.MyMachGroupVM + + + ' definizione comandi + Private m_cmdDeleteMachGroup As ICommand + +#Region "CONSTRUCTORS" + + Sub New(MyMachGroupM As MyMachGroupM) + MyBase.New(MyMachGroupM) + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "DeleteMachGroup" + + ' Returns a command that manage the MainWindow_Unloaded command + Public ReadOnly Property DeleteMachGroup_Command As ICommand + Get + If m_cmdDeleteMachGroup Is Nothing Then + m_cmdDeleteMachGroup = New Command(AddressOf DeleteMachGroup) + End If + Return m_cmdDeleteMachGroup + End Get + End Property + + Public Overridable Sub DeleteMachGroup() + ' elimino tutte le copie + Dim nRawPartId As Integer = EgtGetFirstRawPart() + Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nRawPartId <> GDB_ID.NULL + EgtRemovePartFromRawPart(nBeamId) + EgtErase(nBeamId) + nRawPartId = EgtGetNextRawPart(nRawPartId) + nBeamId = EgtGetFirstPartInRawPart(nRawPartId) + End While + ' elimino MachGroup + EgtRemoveMachGroup(Me.Id) + End Sub + +#End Region ' DeleteMachGroup + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.vb new file mode 100644 index 00000000..435a644c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/MyMachGroupVM.vb @@ -0,0 +1,934 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MyMachGroupVM + Inherits Core.MyMachGroupVM + +#Region "FIELDS & PROPERTIES" + +#Region "General" + + Private m_RefreshPartList_Timer As New DispatcherTimer + + Public Overrides Property SelPart As Core.PartVM + Get + Return m_SelPart + End Get + Set(value As Core.PartVM) + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' mostro pezzi selezionati + Map.refShowBeamPanelVM.bShowAll = False + ' se pezzo evidenziato da ultima selezione precedente + If Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST AndAlso Map.refProjectVM.BTLStructureVM.SelBTLParts.Count = 1 Then + Dim nSelBTLPartId As Integer = Map.refProjectVM.BTLStructureVM.SelBTLParts(0).nPartId + ' deevidenzio MachGroup e Duplo di questo pezzo + Configuration.ResetSearchPiece(nSelBTLPartId) + End If + If Not IsNothing(m_SelPart) Then + ' deevidenzio BTLPart di questo pezzo + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Configuration.ResetSearch(m_SelPart.nPartId) + End If + End If + ' se modalita' assemblato + Configuration.AssembledMode(Map.refShowBeamPanelVM.ShowBuilding_IsChecked) + End If + m_SelPart = value + ' seleziono pezzo + EgtDeselectAll() + If Not IsNothing(value) Then + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' imposto modalita' prod su vista feature + Map.refProdProjManagerVM.SelProdProj = ProdProj.PROD + ' deseleziono pezzo in lista BTLPart + For BTLPartIndex = Map.refProjectVM.BTLStructureVM.SelBTLParts.Count - 1 To 0 Step -1 + Map.refProjectVM.BTLStructureVM.SelBTLParts.RemoveFromList(Map.refProjectVM.BTLStructureVM.SelBTLParts(BTLPartIndex)) + Next + End If + EgtSelectObj(SelPart.nPartId) + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + DirectCast(m_SelPart, PartVM).SelectBTLPart() + End If + ' trovo ed evidenzio BTLPart di questo pezzo + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + Configuration.SetSearch(m_SelPart.nPartId) + End If + + End If + If Not IsNothing(value) Then EgtDraw() + NotifyPropertyChanged(NameOf(SelPart)) + End Set + End Property + Friend Sub SetSelPart(value As Core.PartVM) + m_SelPart = value + EgtDeselectAll() + EgtSelectObj(SelPart.nPartId) + NotifyPropertyChanged(NameOf(SelPart)) + End Sub + + Public Property sL As String + Get + Return LenToString(MyMachGroupM.dL, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim nRawPartId As Integer = EgtGetFirstRawPart() + If dValue <> MyMachGroupM.dL Then + Select Case nType + Case BWType.BEAM + ' se c'e' almeno un pezzo + If m_PartVMList.Count > 0 Then + ' verifico se la dimensione e' maggiore dello spazio occupato dai pezzi + Dim dTotLength As Double = 0 + For Each Part In m_PartVMList + dTotLength += Part.dL + Part.dOffset + Next + If dValue < dTotLength Then + dValue = dTotLength + End If + End If + EgtSetInfo(Id, MGR_RPT_BARLEN, dValue) + If Not ReDrawBeamMachgroup() Then + ' rispristino vecchio valore + EgtSetInfo(Id, MGR_RPT_BARLEN, MyMachGroupM.dL) + ReDrawBeamMachgroup() + NotifyPropertyChanged(NameOf(sL)) + Else + MyMachGroupM.dL = dValue + End If + EgtDraw() + Case BWType.WALL + ' se c'e' almeno un pezzo + If m_PartVMList.Count > 0 Then + ' verifico se la dimensione e' maggiore del box minimo dei pezzi + Dim b3Parts As New BBox3d + Configuration.VerifyMaxDimension(m_PartVMList, b3Parts) + Dim b3RawPart As New BBox3d + EgtGetRawPartBBox(nRawPartId, b3RawPart) + Dim dMinValue As Double = 0 + Select Case CurrentMachine.NestingCorner + Case MCH_CR.BL, MCH_CR.TL + dMinValue = b3Parts.DimX + (b3Parts.Min.x - b3RawPart.Min.x) + WarehouseHelper.GetKerf() + Case MCH_CR.BR, MCH_CR.TR + dMinValue = b3Parts.DimX + (b3RawPart.Max.x - b3Parts.Max.x) + WarehouseHelper.GetKerf() + End Select + If dValue < dMinValue Then + dValue = dMinValue + End If + End If + If EgtModifyRawPartSize(nRawPartId, dValue, MyMachGroupM.dW, MyMachGroupM.dH) Then + ' riporto il grezzo nell'angolo tavola di origine + Dim b3Tab As New BBox3d + Configuration.SelectCorner(b3Tab, nRawPartId) + ' sposto tutti i pezzi di quanto si e' accorciato il grezzo + If CurrentMachine.NestingCorner = MCH_CR.TR OrElse CurrentMachine.NestingCorner = MCH_CR.BR Then + For Each Part In m_PartVMList + EgtMovePartInRawPart(Part.nPartId, New Vector3d(dValue - MyMachGroupM.dL, 0, 0)) + Next + End If + ' ripristino eventuale PosZ + If MyMachGroupM.dPosZ >= 0 Then + EgtMoveRawPart(nRawPartId, New Vector3d(0, 0, MyMachGroupM.dPosZ)) + End If + EgtSetInfo(Id, MGR_RPT_PANELLEN, dValue) + EgtDraw() + MyMachGroupM.dL = dValue + Else + NotifyPropertyChanged(NameOf(sL)) + End If + End Select + UpdateUsage() + ResetCalcTotalMachGroup() + End If + End If + End Set + End Property + + Public Property sW As String + Get + Return LenToString(MyMachGroupM.dW, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + If nType = BWType.WALL Then + Dim nRawPartId As Integer = EgtGetFirstRawPart() + If dValue <> MyMachGroupM.dW Then + ' se c'e' almeno un pezzo + If m_PartVMList.Count > 0 Then + ' verifico se la dimensione e' maggiore del box minimo dei pezzi + Dim b3Parts As New BBox3d + Configuration.VerifyMaxDimension(m_PartVMList, b3Parts) + Dim b3RawPart As New BBox3d + EgtGetRawPartBBox(nRawPartId, b3RawPart) + Dim dMinValue As Double = 0 + Select Case CurrentMachine.NestingCorner + Case MCH_CR.BL, MCH_CR.BR + dMinValue = b3Parts.DimY + (b3Parts.Min.y - b3RawPart.Min.y) + WarehouseHelper.GetKerf() + Case MCH_CR.TL, MCH_CR.TR + dMinValue = b3Parts.DimY + (b3RawPart.Max.y - b3Parts.Max.y) + WarehouseHelper.GetKerf() + End Select + If dValue < dMinValue Then + dValue = dMinValue + End If + End If + If EgtModifyRawPartSize(nRawPartId, MyMachGroupM.dL, dValue, MyMachGroupM.dH) Then + ' riporto il grezzo nell'angolo tavola di origine + Dim b3Tab As New BBox3d + Configuration.SelectCorner(b3Tab, nRawPartId) + ' sposto tutti i pezzi di quanto si e' accorciato il grezzo + If CurrentMachine.NestingCorner = MCH_CR.TR OrElse CurrentMachine.NestingCorner = MCH_CR.TL Then + For Each Part In m_PartVMList + EgtMovePartInRawPart(Part.nPartId, New Vector3d(0, dValue - MyMachGroupM.dW, 0)) + Next + End If + ' ripristino eventuale PosZ + If MyMachGroupM.dPosZ >= 0 Then + EgtMoveRawPart(nRawPartId, New Vector3d(0, 0, MyMachGroupM.dPosZ)) + End If + EgtSetInfo(Id, MGR_RPT_PANELWIDTH, dValue) + EgtDraw() + MyMachGroupM.dW = dValue + Else + NotifyPropertyChanged(NameOf(sW)) + End If + UpdateUsage() + ResetCalcTotalMachGroup() + End If + End If + End If + End Set + End Property + + Public Property sH As String + Get + Return LenToString(MyMachGroupM.dH, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + MyMachGroupM.dH = value + End If + End Set + End Property + + Private m_bSearchFound As Boolean + Public ReadOnly Property bSearchFound As Boolean + Get + Return m_bSearchFound + End Get + End Property + Friend Sub SetSearchFound() + m_bSearchFound = True + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + Friend Sub ResetSearchFound() + m_bSearchFound = False + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + + Public ReadOnly Property Search_Background As SolidColorBrush + Get + Return If(m_bSearchFound, Brushes.Gold, Brushes.Transparent) + End Get + End Property + +#End Region ' General + +#Region "Beam" + + Public Overrides Property sStartCut As String + Get + Return LenToString(MyMachGroupM.dStartCut, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim dOldValue As Double = MyMachGroupM.dStartCut + ' verifico se con il nuovo StartCut tutti i pezzi stanno nella barra + Dim dTotLength As Double = 0 + For PartIndex = 0 To m_PartVMList.Count - 1 + Dim Part As PartVM = m_PartVMList(PartIndex) + If PartIndex = 0 Then + dTotLength += Part.dL + dValue + Else + dTotLength += Part.dL + Part.dOffset + End If + Next + If Me.dL < dTotLength Then + NotifyPropertyChanged(NameOf(sStartCut)) + Return + End If + MyMachGroupM.dStartCut = dValue + If Not ReDrawBeamMachgroup() Then + ' rispristino vecchio valore + MyMachGroupM.dStartCut = dOldValue + ReDrawBeamMachgroup() + NotifyPropertyChanged(NameOf(sStartCut)) + End If + EgtDraw() + If PartVMList.Count > 0 Then + Dim Beam As PartVM = PartVMList(0) + Beam.PartM.UpdateOffset() + Beam.NotifyPropertyChanged(NameOf(Beam.sOffset)) + End If + ' resetto validazione del pezzo primo pezzo + If PartVMList.Count > 0 Then + PartVMList(0).ResetCalcPart() + Else + ResetCalcMachGroup() + End If + UpdateUsage() + Else + NotifyPropertyChanged(NameOf(sStartCut)) + End If + End Set + End Property + +#End Region ' Beam + +#Region "Wall" + + Public Property sPosZ As String + Get + Return LenToString(MyMachGroupM.dPosZ, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim nRawPartId As Integer = EgtGetFirstRawPart() + If Math.Abs(dValue - MyMachGroupM.dPosZ) > EPS_SMALL Then + Select Case nType + Case BWType.BEAM + ' non utilizzato + Case BWType.WALL + ' se operazione di spostamento in z ha successo + If dValue >= 0 AndAlso EgtMoveRawPart(nRawPartId, New Vector3d(0, 0, dValue - MyMachGroupM.dPosZ)) Then + EgtSetInfo(Id, MGR_RPT_PANELPOSZ, dValue) + EgtDraw() + MyMachGroupM.dPosZ = dValue + Else + NotifyPropertyChanged(NameOf(sPosZ)) + End If + End Select + ResetCalcTotalMachGroup() + End If + End If + End Set + End Property + +#End Region ' Wall + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTORS" + + Sub New(MyMachGroupM As MyMachGroupM) + MyBase.New(MyMachGroupM) + ' aggiorno stato di produzione + ReadProductionState() + m_RefreshPartList_Timer.Interval = TimeSpan.FromMilliseconds(50) + AddHandler m_RefreshPartList_Timer.Tick, AddressOf RefreshPartList_Tick + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + +#Region "Machgroup" + + Friend Sub SetSelPart(PartVM As PartVM) + m_SelPart = PartVM + NotifyPropertyChanged(NameOf(SelPart)) + End Sub + + Public Overrides Sub RefreshGroupData() + + End Sub + + Public Shadows Function Copy(Optional Qty As Integer = 1) As Core.MyMachGroupVM + Dim BeamWallMachGroup As MyMachGroupVM = Nothing + If nType = BWType.BEAM Then + EgtResetCurrMachGroup() + ' recupero lista dei pezzi BTL originali + Dim PartList As New List(Of BTLPartVM) + For Each Part In m_PartVMList + PartList.Add(BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId)) + Next + ' verifico che nessun pezzo da copiare abbia raggiunto il numero massimo + If Not VerifyPartCount(PartList, Qty) Then Return Nothing + ' creo nuovi gruppi di lavorazione + For Ind = 1 To Qty + Map.refMachGroupPanelVM.AddMachGroup() + Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup() + Dim sCurrMachGroupName As String = "" + EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) + ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione + If Not IsNothing(Map.refProdManagerVM) Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, ProjectManagerVM.CurrProd.nProdId) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, ProjectManagerVM.CurrProd.nProdId) + End If + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_BARLEN, dL) + For Index = 0 To m_PartVMList.Count - 1 + ' creo copia del pezzo + Dim nPartDuploId As Integer = EgtDuploNew(PartList(Index).nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId) + ' lo rendo std + EgtSetMode(nPartDuploId, GDB_MD.STD) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & m_PartVMList(Index).sPOSX) + Next + BeamWallMachGroup = Map.refMachGroupPanelVM.GetLastMachGroup() + ' eseguo script creazione grezzo + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + BeamWallMachGroup.DeleteMachGroup() + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return Nothing + End If + ' aggiorno contatore pezzi usati in Prod + For Each Part In PartList + Part.RefreshPartInProd() + Next + 'aggiorno lista pezzi + BeamWallMachGroup.MyMachGroupM.RefreshPartList() + BeamWallMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati ultilizzo barra + BeamWallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.ISO_SW, False) + Next + ' se pareti + Else + ' recupero lista dei pezzi BTL originali + Dim CopyPartList As New List(Of CopyPart) + Dim PartList As New List(Of BTLPartVM) + For Each Part As PartVM In m_PartVMList + Dim BTLPartVM As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(Part.nPartId) + CopyPartList.Add(New CopyPart(BTLPartVM, Part.sPOSX, Part.sPOSY, Part.dROT, Part.nFLIP)) + PartList.Add(BTLPartVM) + Next + + EgtResetCurrMachGroup() + ' verifico che nessun pezzo da copiare abbia raggiunto il numero massimo + If Not VerifyPartCount(PartList, Qty) Then Return Nothing + ' creo nuovi gruppi di lavorazione + For ind = 1 To Qty + Map.refMachGroupPanelVM.AddMachGroup() + Dim nCurrMachGroup As Integer = EgtGetCurrMachGroup() + Dim sCurrMachGroupName As String = "" + EgtGetMachGroupName(nCurrMachGroup, sCurrMachGroupName) + ' scrivo dati per variabili P di comunicazione con la macchina in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PRODID, ProjectManagerVM.CurrProd.nProdId) + EgtSetInfo(nCurrMachGroup, MGR_RPT_MATERIAL, sMATERIAL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PATTID, nCurrMachGroup) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELLEN, dL) + EgtSetInfo(nCurrMachGroup, MGR_RPT_PANELWIDTH, dW) + For Index = 0 To CopyPartList.Count - 1 + Dim CopyPart As CopyPart = CopyPartList(Index) + ' creo copia del pezzo + Dim nPartDuploId As Integer = EgtDuploNew(CopyPart.BTLPart.nPartId) + ' elimino valori calcolo dell'originale + MyMachGroupPanelVM.DuploRemoveProjCalc(nPartDuploId) + ' lo rendo std + EgtSetMode(nPartDuploId, GDB_MD.STD) + ' annullo eventuale inversione del pezzo originale + Dim b3Duplo As New BBox3d + EgtGetBBoxGlob(nPartDuploId, GDB_BB.STANDARD, b3Duplo) + If CopyPart.BTLPart.nINVERTED > 0 Then + EgtRotate(nPartDuploId, b3Duplo.Center(), Vector3d.X_AX, 180, GDB_RT.GLOB) + End If + ' calcolo rotazione + Dim dRot As Double = CopyPart.dRot - CopyPart.BTLPart.nROTATED + If dRot <> 0 Then + EgtRotate(nPartDuploId, b3Duplo.Center(), -Vector3d.Z_AX, dRot, GDB_RT.GLOB) + End If + ' effettuo eventuale flip + If CopyPart.nFlip > 0 Then + EgtRotate(nPartDuploId, b3Duplo.Center(), Vector3d.X_AX, 180, GDB_RT.GLOB) + End If + EgtSetInfo(nPartDuploId, MGR_PRT_ROT, CopyPart.dRot) + EgtSetInfo(nPartDuploId, MGR_PRT_FLIP, CopyPart.nFlip) + ' scrivo dati costruzione grezzo in gruppo di lavorazione + EgtSetInfo(nCurrMachGroup, MGR_RPT_PART & (Index + 1), nPartDuploId & "," & CopyPart.sPosX & "," & CopyPart.sPosY & ",0,0") + Next + BeamWallMachGroup = Map.refMachGroupPanelVM.GetLastMachGroup() + ' eseguo script creazione grezzo + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecWall(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False, False) Then + BeamWallMachGroup.DeleteMachGroup() + Dim LogFile As String() = File.ReadAllLines(sLogPath) + If LogFile.Count >= 2 AndAlso Not IsNothing(LogFile(1)) Then + MessageBox.Show(LogFile(1), EgtMsg(30007), MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return Nothing + End If + ' aggiorno contatore pezzi usati in Prod + For Each Part In PartList + Part.RefreshPartInProd() + Next + 'aggiorno lista pezzi + BeamWallMachGroup.MyMachGroupM.RefreshPartList() + BeamWallMachGroup.MyMachGroupM.RefreshGroupData() + ' aggiorno dati ultilizzo barra + BeamWallMachGroup.UpdateUsage() + Core.ViewPanelVM.BWSetView(VT.TOP, False) + Next + End If + Return BeamWallMachGroup + End Function + + Friend Function ReDrawBeamMachgroup() As Boolean + ' scrivo dati di tutti i pezzi + Dim dPosX As Double = MyMachGroupM.dStartCut + Dim nIndex As Integer + For nIndex = 0 To PartVMList.Count - 1 + If nIndex <> 0 Then + dPosX += PartVMList(nIndex).PartM.dOffset + End If + PartVMList(nIndex).dPOSX = dPosX + EgtSetInfo(Id, MGR_RPT_PART & nIndex + 1, PartVMList(nIndex).nPartId & "," & DoubleToString(dPosX, 3)) + dPosX += PartVMList(nIndex).dL + Next + ' elimino eventuali successive info pezzi di troppo + nIndex = PartVMList.Count + 1 + Dim sTemp As String = "" + While EgtGetInfo(Id, MGR_RPT_PART & nIndex, sTemp) + EgtSetInfo(Id, MGR_RPT_PART & nIndex, "") + nIndex += 1 + End While + ' elimino vecchio grezzo ed eseguo script creazione nuovo + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemovePartFromRawPart(EgtGetFirstPartInRawPart(nRawId)) + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + Return ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) + End Function + + Friend Sub MoveBeam(Beam As PartVM, MoveDirection As MoveDirections) + Dim nBeamIndex As Integer = PartVMList.IndexOf(Beam) + If nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.UP Then Return + If nBeamIndex = PartVMList.Count - 1 AndAlso MoveDirection = MoveDirections.DOWN Then Return + ' se pezzo mosso diventa primo + Dim FirstBeam As PartVM = PartVMList(0) + If (nBeamIndex = 1 AndAlso MoveDirection = MoveDirections.UP) OrElse (nBeamIndex = 0 AndAlso MoveDirection = MoveDirections.DOWN) Then + '' resetto offset per vecchio primo + FirstBeam.ResetOffset() + End If + PartVMList.Move(nBeamIndex, nBeamIndex + MoveDirection) + ReDrawBeamMachgroup() + ' aggiorno offset primo pezzo + PartVMList(0).PartM.UpdateOffset() + PartVMList(0).NotifyPropertyChanged(NameOf(FirstBeam.sOffset)) + End Sub + + Friend Sub ReorderBeam() + Dim TempPartList = PartVMList.OrderBy(Function(x) x.dL).ToList() + ' verifico se sono già in oridne + Dim bSort As Boolean = True + For PartIndex = 0 To PartVMList.Count - 1 + If PartVMList(PartIndex).nPartId <> TempPartList(PartIndex).nPartId Then + bSort = False + Exit For + End If + Next + If bSort Then Return + ' resetto offset primo pezzo + Dim FirstBeam As PartVM = PartVMList(0) + FirstBeam.ResetOffset() + For PartIndex = 0 To TempPartList.Count - 1 + If PartVMList(PartIndex).nPartId <> TempPartList(PartIndex).nPartId Then + PartVMList.Move(PartVMList.IndexOf(TempPartList(PartIndex)), PartIndex) + End If + Next + ReDrawBeamMachgroup() + ' aggiorno offset primo pezzo + FirstBeam.PartM.UpdateOffset() + FirstBeam.NotifyPropertyChanged(NameOf(FirstBeam.sOffset)) + End Sub + + Private Function VerifyPartCount(SelParts As List(Of BTLPartVM), Optional Qty As Integer = 1) As Boolean + Dim sPartToAdd As String = "Raggiunto numero di pezzi da produrre per:" + Dim bPartToAdd As Boolean = False + For Each Part In SelParts + ' verifico se ci sono pezzi da aggiungere + If Not Part.CanAddPartToCount(Qty) Then + bPartToAdd = True + sPartToAdd &= Environment.NewLine & "- PDN" & Part.nPDN & " | BTL QTY " & Part.nCNT & " | ADDED QTY " & Part.nADDED + End If + Next + sPartToAdd &= Environment.NewLine & "Aggiungerli?" + If bPartToAdd Then + If MessageBox.Show(sPartToAdd, "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + For Each Part In SelParts + If Not Part.CanAddPartToCount() Then Part.AddNewPartToAdded() + Next + Else + Return False + End If + End If + Return True + End Function + + Private Sub ReadProductionState() + If IsNothing(Map.refProdManagerVM) OrElse IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(ProjectManagerVM.CurrProd.nProdId) Then Return + Dim MachGroupModel As MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(ProjectManagerVM.CurrProd.nProdId, Id) + If Not IsNothing(MachGroupModel) Then + If Not String.IsNullOrEmpty(MachGroupModel.SupervisorId) Then + SetSupervisorId(MachGroupModel.SupervisorId) + End If + nProduction_State = MachGroupModel.State + dtStartTime = MachGroupModel.DtStart + dtEndTime = MachGroupModel.DtEnd + End If + End Sub + + Friend Sub ResetCalcTotalMachGroup() + ResetCalcMachGroup() + For Each Part In PartVMList + Part.ResetCalcPart() + For Each Feature As BTLFeatureVM In Part.FeatureVMList + Feature.ResetCalcFeature() + Next + Next + End Sub + + Public Sub ResetSupervisorId() + ' resetto stato per MachGroup + nProduction_State = ItemState.ND + SetSupervisorId("") + Dim bTotDuploToUpdate As Boolean = False + Dim bTotIsModified As Boolean = False + ' sblocco duplo di tutti i part + For Each Part In PartVMList + ' recupero se Duplo da aggiornare + Dim bDuploToUpdate As Boolean = False + If EgtGetInfo(Part.nPartId, GDB_SI_DUPTOUPDATE, bDuploToUpdate) AndAlso bDuploToUpdate Then + bTotDuploToUpdate = True + End If + ' verifico tipo di progetto + Dim nBtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim nBWType As Integer = 0 + EgtGetInfo(nBtlInfoId, BTL_GEN_PROJTYPE, nBWType) + Dim DuploRot As Integer = 0 + Dim DuploFlip As Integer = 0 + Dim QParams As New Dictionary(Of String, Dictionary(Of String, String)) + ' se da aggiornare, leggo info del duplo che verrebbero perse + If bDuploToUpdate Then + ' recupero ROT (gradi) e FLIP (gradi) per non perderli + EgtGetInfo(Part.nPartId, MGR_PRT_ROT, DuploRot) + EgtGetInfo(Part.nPartId, MGR_PRT_FLIP, DuploFlip) + If DuploFlip <> 0 Then DuploFlip = 180 + If nBWType = BWType.WALL Then + ' ciclo sugli outline + Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(Part.nPartId, OUTLINE) + If nOutlineLayer <> GDB_ID.NULL Then + Dim nGlobPRId As Integer = 1 + Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer) + While nOutlineId <> GDB_ID.NULL + ' verifico che sia outline + Dim nPRC As Integer + If EgtGetInfo(nOutlineId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + If Not EgtGetInfo(nOutlineId, MGR_FTR_PRID, nPRId) Then + EgtSetInfo(nOutlineId, MGR_FTR_PRID, nGlobPRId) + nPRId = nGlobPRId + bTotIsModified = True + nGlobPRId += 1 + End If + Dim sKey As String = nPRId & "." & nPRC + QParams.Add(sKey, New Dictionary(Of String, String)) + For QIndex = 1 To 10 + Dim QKey As String = "Q" & QIndex.ToString("D2") + Dim QValue As Integer = 0 + If EgtGetInfo(nOutlineId, QKey, QValue) Then + QParams(sKey).Add(QKey, QValue) + End If + Next + End If + nOutlineId = EgtGetNext(nOutlineId) + End While + End If + ' ciclo sulle feature + Dim nFeatureLayer As Integer = EgtGetFirstNameInGroup(Part.nPartId, PROCESSINGS) + If nFeatureLayer <> GDB_ID.NULL Then + Dim nFeatureId As Integer = EgtGetFirstInGroup(nFeatureLayer) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nFeatureId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nFeatureId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + QParams.Add(sKey, New Dictionary(Of String, String)) + For QIndex = 1 To 10 + Dim QKey As String = "Q" & QIndex.ToString("D2") + Dim QValue As Integer = 0 + If EgtGetInfo(nFeatureId, QKey, QValue) Then + QParams(sKey).Add(QKey, QValue) + End If + Next + End If + nFeatureId = EgtGetNext(nFeatureId) + End While + End If + End If + End If + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' sblocco Duplo + EgtDuploResetLocked(Part.nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + ' se da aggiornare, ripristino info del duplo che verrebbero perse + If bDuploToUpdate Then + ' ripristino i valori di ROT e FLIP + EgtSetInfo(Part.nPartId, MGR_PRT_ROT, DuploRot) + EgtSetInfo(Part.nPartId, MGR_PRT_FLIP, DuploFlip) + If nBWType = BWType.WALL Then + ' ciclo sugli outline + Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(Part.nPartId, OUTLINE) + If nOutlineLayer <> GDB_ID.NULL Then + Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer) + While nOutlineId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nOutlineId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nOutlineId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + ' ripristino parametri Q + If QParams.ContainsKey(sKey) Then + For Each QPar In QParams(sKey) + EgtSetInfo(nOutlineId, QPar.Key, QPar.Value) + Next + End If + End If + nOutlineId = EgtGetNext(nOutlineId) + End While + End If + ' ciclo sulle feature + Dim nFeatureLayer As Integer = EgtGetFirstNameInGroup(Part.nPartId, PROCESSINGS) + If nFeatureLayer <> GDB_ID.NULL Then + Dim nFeatureId As Integer = EgtGetFirstInGroup(nFeatureLayer) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nFeatureId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nFeatureId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + ' ripristino parametri Q + If QParams.ContainsKey(sKey) Then + For Each QPar In QParams(sKey) + EgtSetInfo(nFeatureId, QPar.Key, QPar.Value) + Next + End If + End If + nFeatureId = EgtGetNext(nFeatureId) + End While + End If + End If + End If + Part.nProduction_State = ItemState.ND + Part.NotifyPropertyChanged(NameOf(Part.Background)) + If bDuploToUpdate Then + Dim Duplo As PartVM = CALCPanelVM.GetPartVMFromPartId(Part.nPartId) + Duplo.ResetCalcTotalPart() + End If + Next + If bTotDuploToUpdate Then + m_RefreshPartList_Timer.Start() + End If + If bTotIsModified Then + Dim CurrFilePath As String = "" + EgtGetCurrFilePath(CurrFilePath) + EgtSaveFile(CurrFilePath, NGE.CMPTEXT) + End If + NotifyPropertyChanged(NameOf(IsReadOnly)) + NotifyPropertyChanged(NameOf(Background)) + End Sub + + Private Sub RefreshPartList_Tick() + m_RefreshPartList_Timer.Stop() + Dim nCurrMachGroupId As Integer = EgtGetCurrMachGroup() + EgtSetCurrMachGroup(Id) + DirectCast(MachGroupM, MyMachGroupM).RefreshPartList() + EgtSetCurrMachGroup(nCurrMachGroupId) + End Sub + + Public Overrides Sub RefreshMachGroup() + For Each Part In PartVMList + Part.RefreshPart() + Next + End Sub + +#End Region ' Machgroup + +#Region "Parts" + + Protected Overrides Sub CreatePartVMList() + Dim all As List(Of PartVM) = (From PartM In MyMachGroupM.GetParts() + Select New PartVM(PartM, Me)).ToList() + + For Each PartVM As PartVM In all + AddHandler PartVM.PropertyChanged, AddressOf OnPartVMPropertyChanged + Next + + m_PartVMList = New ObservableCollection(Of Core.PartVM)(all) + AddHandler m_PartVMList.CollectionChanged, AddressOf OnPartVMListChanged + End Sub + + Public Overrides Sub RefreshPartList() + If nType = BWType.BEAM Then + ' leggo StartCut da posizione primo pezzo + Dim sInfo As String = "" + Dim sSplitInfo() As String + Dim bFound As Boolean = False + EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo) + If Not String.IsNullOrWhiteSpace(sInfo) Then + sSplitInfo = sInfo.Split(","c) + StringToDoubleAdv(sSplitInfo(1), MyMachGroupM.dStartCut) + Else + MyMachGroupM.dStartCut = 0 + End If + End If + End Sub + +#End Region ' Parts + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "DeleteMachGroup" + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overrides Sub DeleteMachGroup(Optional bMultipleCommand As Boolean = False) + If EgtSetCurrMachGroup(Me.Id) Then + ' elimino tutte le copie + Dim nRawPartId As Integer = EgtGetFirstRawPart() + If nType = BWType.BEAM Then + Dim nBeamId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nRawPartId <> GDB_ID.NULL + If EgtRemovePartFromRawPart(nBeamId) Then + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nBeamId) + EgtErase(nBeamId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + End If + nRawPartId = EgtGetNextRawPart(nRawPartId) + nBeamId = EgtGetFirstPartInRawPart(nRawPartId) + End While + Else + Dim nWallId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nWallId <> GDB_ID.NULL + If EgtRemovePartFromRawPart(nWallId) Then + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nWallId) + EgtErase(nWallId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + End If + nWallId = EgtGetFirstPartInRawPart(nRawPartId) + End While + End If + ' elimino MachGroup + EgtRemoveMachGroup(Me.Id) + End If + ' cambio pezzo selezionato + If bMultipleCommand Then + Dim Index As Integer = Map.refMachGroupPanelVM.MachGroupVMList.IndexOf(Me) + If Index = 0 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(1) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + ElseIf Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 2) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Index - 1) + End If + End If + ' rimuovo dalla lista grezzi + Map.refMachGroupPanelVM.MachGroupVMList.Remove(Me) + End Sub + +#End Region ' DeleteMachGroup + +#End Region ' COMMANDS + +#Region "EVENTS" + + Protected Overrides Sub OnPartAdded(sender As Object, e As PartAddedEventArgs) + Dim PartVM As PartVM = New PartVM(e.NewPart, Me) + PartVMList.Add(PartVM) + End Sub + +#End Region ' EVENTS + +End Class + +Class CopyPart + + Private m_BTLPart As BTLPartVM + Public ReadOnly Property BTLPart As BTLPartVM + Get + Return m_BTLPart + End Get + End Property + Private m_sPosX As String + Public ReadOnly Property sPosX As String + Get + Return m_sPosX + End Get + End Property + Private m_sPosY As String + Public ReadOnly Property sPosY As String + Get + Return m_sPosY + End Get + End Property + Private m_dRot As Double + Public ReadOnly Property dRot As Double + Get + Return m_dRot + End Get + End Property + Private m_nFlip As Integer + Public ReadOnly Property nFlip As Integer + Get + Return m_nFlip + End Get + End Property + + Sub New(BTLPart As BTLPartVM, sPosX As String, sPosY As String, dRot As Double, nFlip As Integer) + m_BTLPart = BTLPart + m_sPosX = sPosX + m_sPosY = sPosY + m_dRot = dRot + m_nFlip = nFlip + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/NewMachGroupPanelVM.qq.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/NewMachGroupPanelVM.qq.vb new file mode 100644 index 00000000..ddf0edb2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/NewMachGroupPanelVM.qq.vb @@ -0,0 +1,291 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class NewMachGroupPanelVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Protected m_MachGroupPanelM As MachGroupPanelM + + Public ReadOnly Property DefaultMachine As String + Get + Return m_MachGroupPanelM.DefaultMachine + End Get + End Property + + Private m_MachGroupVMList As ObservableCollection(Of MachGroupVM) + Public Property MachGroupVMList As ObservableCollection(Of MachGroupVM) + Get + Return m_MachGroupVMList + End Get + Set(value As ObservableCollection(Of MachGroupVM)) + m_MachGroupVMList = value + End Set + End Property + + Private m_SelectedMachGroup As MachGroupVM + Public Property SelectedMachGroup As MachGroupVM + Get + Return m_SelectedMachGroup + End Get + Set(value As MachGroupVM) + m_SelectedMachGroup = value + If Not IsNothing(value) Then + OnPreSetCurrMachGroup() + EgtSetCurrMachGroup(value.Id) + OnPostSetCurrMachGroup() + End If + NotifyPropertyChanged(NameOf(SelectedMachGroup)) + End Set + End Property + + Public ReadOnly Property MachGroupPanel_Visibility As Visibility + Get + Return m_MachGroupPanelM.MachGroupPanel_Visibility + End Get + End Property + + Public Sub SetMachGroupPanelVisibility(IsVisible As Boolean) + If IsVisible Then + m_MachGroupPanelM.MachGroupPanel_Visibility = Visibility.Visible + Else + m_MachGroupPanelM.MachGroupPanel_Visibility = Visibility.Collapsed + End If + NotifyPropertyChanged(NameOf(MachGroupPanel_Visibility)) + End Sub + + + ' Variabile che permette di abilitare/disabilitare i bottoni aggiungi e togli MachGroup + Public Property IsEnabledAddRemove As Boolean + Get + Return m_MachGroupPanelM.IsEnabledAddRemove + End Get + Set(value As Boolean) + m_MachGroupPanelM.IsEnabledAddRemove = value + NotifyPropertyChanged(NameOf(IsEnabledAddRemove)) + End Set + End Property + ' Variabile che definisce lo stato (attivi/disattivi) di tutti i gruppi tranne quello selezionato + Public ReadOnly Property IsEnabledMachGroups As Boolean + Get + Return m_MachGroupPanelM.IsEnabledMachGroups + End Get + End Property + + ' Definizione comandi + Private m_cmdSetCurrMachGroup As ICommand + Private m_cmdAddMachGroup As ICommand + Private m_cmdRemoveMachGroup As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(MachGroupPanelM As MachGroupPanelM) + m_MachGroupPanelM = MachGroupPanelM + If Not MachGroupPanelM.IsMultiMachGroup Then SetMachGroupPanelVisibility(False) + + ' Creo riferimento a questa classe in LibMap + '''LibMap.SetRefMachGroupPanelVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub CreateMachGroupVMList() + Dim all As List(Of MachGroupVM) = (From MachGroupM In m_MachGroupPanelM.GetMachGroups() + Select New MachGroupVM(MachGroupM)).ToList() + + For Each MachGroupvM As MachGroupVM In all + AddHandler MachGroupvM.PropertyChanged, AddressOf OnMachGroupvMPropertyChanged + Next + + m_MachGroupVMList = New ObservableCollection(Of MachGroupVM)(all) + AddHandler m_MachGroupVMList.CollectionChanged, AddressOf OnMachGroupVMListChanged + End Sub + + Public Overridable Function InitMachGroupList(Optional bUseDefaults As Boolean = False) As Boolean + ' Svuoto precedente lista di MachGroup + m_MachGroupPanelM.MachGroupMList.Clear() + ' verifico se esistono già gruppi di lavorazione o se devo creare il primo + Dim bOk As Boolean + Dim nId = EgtGetFirstMachGroup() + If nId <> GDB_ID.NULL Then + bOk = EgtSetCurrMachGroup(nId) + Else + If bUseDefaults Then + bOk = Not IsNothing(m_MachGroupPanelM.NewMachGroupWithDefaults()) + Else + bOk = Not IsNothing(m_MachGroupPanelM.NewMachGroup()) + End If + End If + If Not bOk Then Return False + ' Sistemazioni finali + m_MachGroupPanelM.MachGroupMList = MachGroupPanelM.LoadMachGroups() + SelectedMachGroup = MachGroupVMList(0) + Return True + End Function + + ' Funzione che permette di abilitare o disabilitare tutti i gruppi tranne quello selezionato più i bottni Add/Remove + Public Function SetMachGroupState(bState As Boolean) As Boolean + If bState Then + For Each Group In MachGroupVMList + Group.IsEnabled = True + Next + m_MachGroupPanelM.IsEnabledAddRemove = True + NotifyPropertyChanged(NameOf(IsEnabledAddRemove)) + m_MachGroupPanelM.IsEnabledMachGroups = True + Return True + Else + For Each Group In MachGroupVMList + If Group Is SelectedMachGroup Then + Group.IsEnabled = True + Else + Group.IsEnabled = False + End If + Next + m_MachGroupPanelM.IsEnabledAddRemove = False + NotifyPropertyChanged(NameOf(IsEnabledAddRemove)) + m_MachGroupPanelM.IsEnabledMachGroups = False + Return True + End If + Return False + End Function + + Public Overridable Function OnPreSetCurrMachGroup() As Boolean + Return True + End Function + + Public Overridable Function OnPostSetCurrMachGroup() As Boolean + Return True + End Function + + Public Overridable Function OnPreRemoveCurrMachGroup() As Boolean + Return True + End Function + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "AddMachGroupCommand" + + ''' + ''' Returns a command that set the selected MachGroup as the Current one. + ''' + Public ReadOnly Property AddMachGroupCommand As ICommand + Get + If m_cmdAddMachGroup Is Nothing Then + m_cmdAddMachGroup = New Command(AddressOf AddMachGroup) + End If + Return m_cmdAddMachGroup + End Get + End Property + + Public Overridable Sub AddMachGroup() + Dim MachGroupM As MachGroupM = m_MachGroupPanelM.NewMachGroup() + If IsNothing(MachGroupM) Then Return + ' lo seleziono + SelectedMachGroup = MachGroupVMList.FirstOrDefault(Function(x) x.MachGroupM Is MachGroupM) + EgtZoom(ZM.ALL) + End Sub + +#End Region ' AddMachGroupCommand + +#Region "RemoveMachGroupCommand" + + ''' + ''' Returns a command that set the selected MachGroup as the Current one. + ''' + Public ReadOnly Property RemoveMachGroupCommand As ICommand + Get + If m_cmdRemoveMachGroup Is Nothing Then + m_cmdRemoveMachGroup = New Command(AddressOf RemoveMachGroup) + End If + Return m_cmdRemoveMachGroup + End Get + End Property + + Public Overridable Sub RemoveMachGroup() + ' Calcolo indice del gruppo da cancellare + Dim nSelectedMachGroupIndex As Integer = MachGroupVMList.IndexOf(SelectedMachGroup) + If MachGroupVMList.Count = 1 Then + 'chiedo conferma prima di resettare il gruppo di lavorazione + Select Case MessageBox.Show("Eliminare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) + Case MessageBoxResult.Yes + ' cancello il gruppo corrente e ne creo uno nuovo con lo stesso nome + OnPreRemoveCurrMachGroup() + EgtRemoveMachGroup(MachGroupVMList(0).Id) + MachGroupVMList.Clear() + AddMachGroup() + EgtZoom(ZM.ALL) + Case MessageBoxResult.No + Return + End Select + Else + 'chiedo conferma prima di cancellare il gruppo di lavorazione + Select Case MessageBox.Show("Eliminare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question) + Case MessageBoxResult.Yes + ' cancello quello selezionato (ovvero il corrente) + OnPreRemoveCurrMachGroup() + EgtRemoveMachGroup(MachGroupVMList(nSelectedMachGroupIndex).Id) + ' rendo corrente il gruppo di lavorazione successivo a quello da cancellare + If nSelectedMachGroupIndex = 0 And MachGroupVMList.Count > 1 Then + EgtSetCurrMachGroup(MachGroupVMList(nSelectedMachGroupIndex + 1).Id) + SelectedMachGroup = MachGroupVMList(nSelectedMachGroupIndex + 1) + ' rendo corrente il gruppo di lavorazione precedente a quello da cancellare + ElseIf nSelectedMachGroupIndex > 0 Then + EgtSetCurrMachGroup(MachGroupVMList(nSelectedMachGroupIndex - 1).Id) + SelectedMachGroup = MachGroupVMList(nSelectedMachGroupIndex - 1) + End If + EgtZoom(ZM.ALL) + ' aggiorno la lista dei gruppi + MachGroupVMList.RemoveAt(nSelectedMachGroupIndex) + Case MessageBoxResult.No + Return + End Select + End If + + End Sub + +#End Region ' RemoveMachGroupCommand + +#End Region ' COMMANDS + +#Region "EVENTS" + + Private Sub OnMachGroupAdded(sender As Object, e As MachGroupAddedEventArgs) + Dim MachGroupVM As MachGroupVM = New MachGroupVM(e.NewMachGroupM) + m_MachGroupVMList.Add(MachGroupVM) + NotifyPropertyChanged(NameOf(MachGroupVMList)) + End Sub + + Private Sub OnMachGroupVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each MachGroupVM As MachGroupVM In e.NewItems + AddHandler MachGroupVM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each MachGroupVM As MachGroupVM In e.OldItems + RemoveHandler BTLPartVM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged + Next + End If + End Sub + + Private Sub OnMachGroupVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + 'Case nameof(sender.sMATERIAL) + End Select + End Sub + +#End Region ' EVENTS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.qq.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.qq.vb new file mode 100644 index 00000000..c5f2c2d2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.qq.vb @@ -0,0 +1,30 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.IO +Imports System.Windows.Input +Imports System.Windows.Media +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public MustInherit Class PartVM + Inherits Core.PartVM + +#Region "FIELDS & PROPERTIES" + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(PartM As PartM, ParentMachGroupVM As MyMachGroupVM) + MyBase.New(PartM, ParentMachGroupVM) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "COMMANDS" + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.vb new file mode 100644 index 00000000..fee3d93f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/PartVM.vb @@ -0,0 +1,784 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class PartVM + Inherits Core.PartVM + +#Region "FIELDS & PROPERTIES" + +#Region "General" + + ' variabile che indica se almeno un pezzo e' stato modificato durante il caricamento del progetto + Private Shared m_PartModifiedOnLoading As Boolean = False + + Public Overloads ReadOnly Property dVolume As Double + Get + Return dVolume + End Get + End Property + + Private m_bSearchFound As Boolean + Public ReadOnly Property bSearchFound As Boolean + Get + Return m_bSearchFound + End Get + End Property + Friend Sub SetSearchFound() + m_bSearchFound = True + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + Friend Sub ResetSearchFound() + m_bSearchFound = False + NotifyPropertyChanged(NameOf(Search_Background)) + End Sub + + Public ReadOnly Property Search_Background As SolidColorBrush + Get + Return If(m_bSearchFound, Brushes.Gold, Brushes.Transparent) + End Get + End Property + +#End Region ' General + +#Region "Beam" + + Public Overrides Property sOffset As String + Get + Return LenToString(m_PartM.dOffset, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim dOldValue As Double = m_PartM.dOffset + Dim BeamMachGroup As MyMachGroupVM = DirectCast(ParentMachGroupVM, MyMachGroupVM) + ' se prima trave della barra sostituisco valore anche a startoffset + If ParentMachGroupVM.PartVMList(0) Is Me Then + m_PartM.dOffset = dValue + BeamMachGroup.dStartCut = dValue + ElseIf dValue > CurrentMachine.dMinOffset Then + m_PartM.dOffset = dValue + Else + m_PartM.dOffset = CurrentMachine.dMinOffset + End If + If Not BeamMachGroup.ReDrawBeamMachgroup() Then + ' rispristino vecchio valore + m_PartM.dOffset = dOldValue + BeamMachGroup.dStartCut = dOldValue + BeamMachGroup.ReDrawBeamMachgroup() + End If + EgtDraw() + ' resetto validazione del pezzo + ResetCalcPart() + ParentMachGroupVM.UpdateUsage() + Else + NotifyPropertyChanged(NameOf(sOffset)) + End If + End Set + End Property + +#End Region ' Beam + +#Region "Wall" + + Public Overrides Property sPOSX As String + Get + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.WALL + ' se parete, valuto angolo di posizionamento + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL, MCH_CR.BL + Return LenToString(m_PartM.dPOSX, 3) + Case Else ' MCH_CR.TR, MCH_CR.BR + Return LenToString(m_ParentMachGroupVM.dL - dL - m_PartM.dPOSX, 3) + End Select + Case Else + Return LenToString(m_PartM.dPOSX, 3) + End Select + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim dOldValue As Double = m_PartM.dPOSX + Dim dNewValue As Double = dValue + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.WALL + ' se parete, valuto angolo di posizionamento + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL, MCH_CR.BL + dNewValue = dValue + Case Else ' MCH_CR.TR, MCH_CR.BR + dNewValue = m_ParentMachGroupVM.dL - dL - dValue + End Select + Case Else + m_PartM.dPOSX = dValue + End Select + If EgtMovePartInRawPart(nPartId, New Vector3d(dNewValue - dOldValue, 0, 0)) Then + EgtSetInfo(nPartId, MGR_PRT_POSX, dValue) + NotifyPropertyChanged(NameOf(sPOSX)) + ' resetto validazione del pezzo + ResetCalcPart() + Else + ' ripristino vecchio valore + m_PartM.dPOSX = dOldValue + End If + EgtDraw() + Else + NotifyPropertyChanged(NameOf(sPOSX)) + End If + End Set + End Property + + Public Overrides Property sPOSY As String + Get + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.WALL + ' valuto angolo di posizionamento + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL, MCH_CR.TR + Return LenToString(m_ParentMachGroupVM.dW - dW - m_PartM.dPOSY, 3) + Case Else ' MCH_CR.BL, MCH_CR.BR + Return LenToString(m_PartM.dPOSY, 3) + End Select + Case Else + Return LenToString(m_PartM.dPOSY, 3) + End Select + End Get + Set(value As String) + Dim dValue As Double + If StringToLenAdv(value, dValue, True) Then + Dim dOldValue As Double = m_PartM.dPOSY + Dim dNewValue As Double = dValue + ' valuto angolo di posizionamento + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.WALL + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL, MCH_CR.TR + dNewValue = m_ParentMachGroupVM.dW - dW - dValue + Case MCH_CR.BL, MCH_CR.BR + dNewValue = dValue + End Select + Case Else + m_PartM.dPOSY = dValue + End Select + If EgtMovePartInRawPart(nPartId, New Vector3d(0, dNewValue - dOldValue, 0)) Then + EgtSetInfo(nPartId, MGR_PRT_POSY, dValue) + NotifyPropertyChanged(NameOf(sPOSY)) + ' resetto validazione del pezzo + ResetCalcPart() + Else + ' ripristino vecchio valore + m_PartM.dPOSY = dOldValue + End If + EgtDraw() + Else + NotifyPropertyChanged(NameOf(sPOSY)) + End If + End Set + End Property + + Public Property bFLIP As Boolean + Get + Return m_PartM.nFLIP <> 0 + End Get + Set(value As Boolean) + If Map.refProjectVM.bCalcRunning Then Return + ' se MachGroup gia' mandato in produzione, esco + If m_ParentMachGroupVM.nProduction_State >= ItemState.Assigned Then Return + If (value And m_PartM.nFLIP = 0) OrElse (Not value And m_PartM.nFLIP <> 0) Then + ' salvo posizione + Dim dTempPosX As Double = m_PartM.dPOSX + Dim dTempPosY As Double = m_PartM.dPOSY + ' tolgo il pezzo dal grezzo + EgtRemovePartFromRawPart(nPartId) + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + Dim vtAxes As Vector3d + ' se travi ruoto attorno all'asse Z + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + vtAxes = Vector3d.Z_AX + ' se pareti ruoto attorno all'asse X + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + vtAxes = Vector3d.X_AX + End If + If EgtRotate(nPartId, b3Box.Center, vtAxes, 180, GDB_RT.GLOB) Then + m_PartM.nFLIP = If(value, 180, 0) + EgtSetInfo(nPartId, MGR_PRT_FLIP, If(value, 180, 0)) + Else + NotifyPropertyChanged(NameOf(bFLIP)) + End If + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + ' recupero box del pezzo + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part) + ' calcolo distanza tra i box + Dim vtDeltaBox As Vector3d = b3Box.Min - b3Part.Min + ' reinserisco il pezzo nel grezzo + EgtAddPartToRawPart(nPartId, New Point3d(dTempPosX - vtDeltaBox.x, dTempPosY - vtDeltaBox.y, 0), ParentMachGroupVM.MyMachGroupM.nRawPartId) + ElseIf bOnlyProd AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + ' elimino vecchio grezzo ed eseguo script creazione nuovo + DeleteOldRaw() + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallita creazione barra nell'ExecBeam in bFlip") + ' elimino vecchio grezzo ed eseguo script creazione nuovo + DeleteOldRaw() + If EgtRotate(nPartId, b3Box.Center, vtAxes, 180, GDB_RT.GLOB) Then + m_PartM.nFLIP = 180 + EgtSetInfo(nPartId, MGR_PRT_FLIP, 180) + Else + NotifyPropertyChanged(NameOf(m_PartM.nFLIP)) + End If + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallita esecuzione ExecBeam. ERRORE") + End If + End If + End If + ' lo riseleziono + EgtSelectObj(nPartId) + ' resetto validazione del pezzo + ResetCalcPart() + EgtDraw() + End If + End Set + End Property + +#End Region ' Wall + + Public Property bDOALL As Boolean? + Get + If Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList.Count = 0 Then Return False + Dim bTemp As Boolean = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList(0).bDO + For FeatureIndex = 1 To Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList.Count - 1 + If Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList(FeatureIndex).bDO <> bTemp Then Return Nothing + Next + Return bTemp + End Get + Set(value As Boolean?) + If Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList.Count = 0 Then + NotifyPropertyChanged(NameOf(bDOALL)) + Return + End If + ' imposto modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = True + For FeatureIndex = 0 To Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList.Count - 1 + If FeatureIndex = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList.Count - 1 Then + ' reset modalita' update multiplo + BTLFeatureVM.bDO_MultipleUpdate = False + End If + Dim Feature As BTLFeatureVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.SelPart.FeatureVMList(FeatureIndex) + Feature.bDO = value + Feature.NotifyPropertyChanged(NameOf(Feature.bDO)) + Next + End Set + End Property + + ' Definizione comandi + Private m_cmdBackRotation As ICommand + Private m_cmdForwardRotation As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New(PartM As PartM, ParentMachGroupVM As MyMachGroupVM) + MyBase.New(PartM, ParentMachGroupVM) + ' aggiorno stato calcolo + CalcGlobalUpdate() + ' aggiorno stato di produzione + ReadProductionData() + NotifyPropertyChanged(NameOf(bDOALL)) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + +#Region "Part" + + Friend Sub ResetOffset() + m_PartM.dOffset = WarehouseHelper.GetOffset(nType) + NotifyPropertyChanged(NameOf(sOffset)) + End Sub + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overrides Sub DeletePart() + ' elimino pezzo copia + EgtRemovePartFromRawPart(Me.nPartId) + ' Recupero Id BTLPart originale + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nPartId) + EgtErase(Me.nPartId) + ' rimuovo dalla lista pezzi + Dim Index As Integer = ParentMachGroupVM.PartVMList.IndexOf(ParentMachGroupVM.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId)) + If Index = 0 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(0) + Else + ParentMachGroupVM.SelPart = Nothing + End If + ElseIf Index = ParentMachGroupVM.PartVMList.Count - 1 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(ParentMachGroupVM.PartVMList.Count - 2) + Else + ParentMachGroupVM.SelPart = Nothing + End If + Else + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1) + End If + ParentMachGroupVM.PartVMList.Remove(Me) + ' aggiorno Db + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProdManagerVM) Then + DbControllers.m_PartController.Delete(ProjectManagerVM.CurrProd.nProdId, ParentMachGroupVM.Id, nPartId) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + DbControllers.m_PartController.Delete(ProjectManagerVM.CurrProd.nProdId, ParentMachGroupVM.Id, nPartId) + End If + If nType = MachineType.BEAM Then + Dim BeamParentMachGroup As MyMachGroupVM = DirectCast(ParentMachGroupVM, MyMachGroupVM) + If Not IsNothing(BeamParentMachGroup) Then BeamParentMachGroup.ReDrawBeamMachgroup() + End If + ' aggiorno contatore pezzi usati in Prod + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + EgtDraw() + End Sub + + Private Sub Rotate(IsPositive As Boolean) + If bOnlyProd AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM Then + ' elimino vecchio grezzo ed eseguo script creazione nuovo + DeleteOldRaw() + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' se invertito lo reinverto + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + ' eseguo rotazione attorno asse X + Dim dRot As Integer = 0 + If dW <> dH Then + dRot = If(IsPositive, 180, -180) + ElseIf dW = dH Then + dRot = If(IsPositive, 90, -90) + End If + Dim bOk As Boolean = EgtRotate(nPartId, b3Box.Center, Vector3d.X_AX, dRot, GDB_RT.GLOB) + If bOk Then + Dim TempRot = m_PartM.dROT + TempRot += dRot + If TempRot >= 360 Then + TempRot -= 360 + ElseIf TempRot < 0 Then + TempRot += 360 + End If + m_PartM.dROT = TempRot + EgtSetInfo(nPartId, MGR_PRT_ROT, m_PartM.dROT) + End If + ' ripristino eventuale inversione + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + Dim sLogPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\RawPartLog.txt" + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallita creazione barra nell'ExecBeam in Rotate") + ' elimino vecchio grezzo ed eseguo script creazione nuovo + DeleteOldRaw() + ' annullo Flip + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + ' ripristino rotazione + Dim TempRot = m_PartM.dROT + TempRot -= dRot + If TempRot >= 360 Then + TempRot -= 360 + ElseIf TempRot < 0 Then + TempRot += 360 + End If + m_PartM.dROT = TempRot + EgtSetInfo(nPartId, MGR_PRT_ROT, m_PartM.dROT) + EgtRotate(nPartId, b3Box.Center, Vector3d.X_AX, -dRot, GDB_RT.GLOB) + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.Z_AX, 180, GDB_RT.GLOB) + If Not ExecBeam(sLogPath, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdTypes.RAWPART, False) Then + EgtOutLog("Fallita esecuzione ExecBeam. ERRORE") + End If + NotifyPropertyChanged(NameOf(sROT)) + End If + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + ' salvo posizione + Dim dTempPosX As Double = m_PartM.dPOSX + Dim dTempPosY As Double = m_PartM.dPOSY + ' tolgo il pezzo dal grezzo + EgtRemovePartFromRawPart(nPartId) + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' se invertito lo reinverto + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.X_AX, 180, GDB_RT.GLOB) + Dim dAng As Double = If(IsPositive, 90, -90) + ' eseguo rotazione + Dim bOk As Boolean = EgtRotate(nPartId, b3Box.Center, -Vector3d.Z_AX, dAng, GDB_RT.GLOB) + If bOk Then + Dim TempRot = m_PartM.dROT + TempRot += dAng + If TempRot >= 360 Then + TempRot -= 360 + ElseIf TempRot < 0 Then + TempRot += 360 + End If + m_PartM.dROT = TempRot + EgtSetInfo(nPartId, MGR_PRT_ROT, m_PartM.dROT) + End If + ' ripristino eventuale inversione + If bFLIP Then EgtRotate(nPartId, b3Box.Center, Vector3d.X_AX, 180, GDB_RT.GLOB) + ' recupero box del pezzo + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part) + 'aggiorno box del box con rotazione + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' calcolo distanza tra i box + Dim vtDeltaBox As Vector3d = b3Box.Min - b3Part.Min ' Vector3d.NULL + ' calcolo posizione rispetto al riferimento + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.WALL + ' se parete, valuto angolo di posizionamento + Select Case CurrentMachine.NestingCorner + Case MCH_CR.TL + dTempPosY = dTempPosY - dW + dL + Case MCH_CR.BL + ' non cambio posizioni + Case MCH_CR.TR + dTempPosX = dTempPosX - dL + dW + dTempPosY = dTempPosY - dW + dL + Case MCH_CR.BR + dTempPosX = dTempPosX - dL + dW + End Select + Case Else + ' non cambio nulla + End Select + ' reinserisco il pezzo nel grezzo + EgtAddPartToRawPart(nPartId, New Point3d(dTempPosX - vtDeltaBox.x, dTempPosY - vtDeltaBox.y, 0), ParentMachGroupVM.MyMachGroupM.nRawPartId) + End If + ' lo riseleziono + EgtSelectObj(nPartId) + ' resetto validazione del pezzo + ResetCalcPart() + NotifyPropertyChanged(NameOf(sROT)) + End Sub + + Private Sub DeleteOldRaw() + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + End Sub + Friend Sub SelectBTLPart() + ' eseguo la selezione nella lista pezzi + Dim nBTLPartId As Integer = MyMachGroupPanelM.DuploGetOriginal(nPartId) + If Not IsNothing(nBTLPartId) Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nBTLPartId), True) + End If + End Sub + + Private Sub ReadProductionData() + If IsNothing(Map.refProdManagerVM) OrElse IsNothing(ProjectManagerVM.CurrProd) OrElse IsNothing(ProjectManagerVM.CurrProd.nProdId) Then Return + Dim PartModel As PartModel = DbControllers.m_PartController.FindByPartId(ProjectManagerVM.CurrProd.nProdId, nPartId) + If Not IsNothing(PartModel) Then + PartM.SetProductionState(PartModel.State) + PartM.dtStartTime = PartModel.DtStart + PartM.dtEndTime = PartModel.DtEnd + ' verifico se bloccare o sbloccare duplo + Dim bLocked As Boolean = True + EgtDuploGetLocked(nPartId, bLocked) + If PartModel.State <= ItemState.ND And bLocked Then + ' recupero se Duplo da aggiornare + Dim bDuploToUpdate As Boolean = False + EgtGetInfo(nPartId, GDB_SI_DUPTOUPDATE, bDuploToUpdate) + ' verifico tipo di progetto + Dim nBtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim nBWType As Integer = 0 + EgtGetInfo(nBtlInfoId, BTL_GEN_PROJTYPE, nBWType) + Dim DuploRot As Integer = 0 + Dim DuploFlip As Integer = 0 + Dim QParams As New Dictionary(Of String, Dictionary(Of String, String)) + ' se da aggiornare, leggo info del duplo che verrebbero perse + If bDuploToUpdate Then + ' recupero ROT (gradi) e FLIP (gradi) per non perderli + EgtGetInfo(nPartId, MGR_PRT_ROT, DuploRot) + EgtGetInfo(nPartId, MGR_PRT_FLIP, DuploFlip) + If DuploFlip <> 0 Then DuploFlip = 180 + If nBWType = BWType.WALL Then + ' ciclo sugli outline + Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE) + If nOutlineLayer <> GDB_ID.NULL Then + Dim nGlobPRId As Integer = 1 + Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer) + While nOutlineId <> GDB_ID.NULL + ' verifico che sia outline + Dim nPRC As Integer + If EgtGetInfo(nOutlineId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + If Not EgtGetInfo(nOutlineId, MGR_FTR_PRID, nPRId) Then + EgtSetInfo(nOutlineId, MGR_FTR_PRID, nGlobPRId) + nPRId = nGlobPRId + nGlobPRId += 1 + End If + Dim sKey As String = nPRId & "." & nPRC + QParams.Add(sKey, New Dictionary(Of String, String)) + For QIndex = 1 To 10 + Dim QKey As String = "Q" & QIndex.ToString("D2") + Dim QValue As Integer = 0 + If EgtGetInfo(nOutlineId, QKey, QValue) Then + QParams(sKey).Add(QKey, QValue) + End If + Next + End If + nOutlineId = EgtGetNext(nOutlineId) + End While + End If + ' ciclo sulle feature + Dim nFeatureLayer As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) + If nFeatureLayer <> GDB_ID.NULL Then + Dim nFeatureId As Integer = EgtGetFirstInGroup(nFeatureLayer) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nFeatureId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nFeatureId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + QParams.Add(sKey, New Dictionary(Of String, String)) + For QIndex = 1 To 10 + Dim QKey As String = "Q" & QIndex.ToString("D2") + Dim QValue As Integer = 0 + If EgtGetInfo(nFeatureId, QKey, QValue) Then + QParams(sKey).Add(QKey, QValue) + End If + Next + End If + nFeatureId = EgtGetNext(nFeatureId) + End While + End If + End If + End If + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' sblocco Duplo + EgtDuploResetLocked(nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + ' se da aggiornare, ripristino info del duplo che verrebbero perse + If bDuploToUpdate Then + ' ripristino i valori di ROT e FLIP + EgtSetInfo(nPartId, MGR_PRT_ROT, DuploRot) + EgtSetInfo(nPartId, MGR_PRT_FLIP, DuploFlip) + If nBWType = BWType.WALL Then + ' ciclo sugli outline + Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE) + If nOutlineLayer <> GDB_ID.NULL Then + Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer) + While nOutlineId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nOutlineId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nOutlineId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + ' ripristino parametri Q + If QParams.ContainsKey(sKey) Then + For Each QPar In QParams(sKey) + EgtSetInfo(nOutlineId, QPar.Key, QPar.Value) + Next + End If + End If + nOutlineId = EgtGetNext(nOutlineId) + End While + End If + ' ciclo sulle feature + Dim nFeatureLayer As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) + If nFeatureLayer <> GDB_ID.NULL Then + Dim nFeatureId As Integer = EgtGetFirstInGroup(nFeatureLayer) + While nFeatureId <> GDB_ID.NULL + ' verifico che sia feature + Dim nPRC As Integer + If EgtGetInfo(nFeatureId, MGR_FTR_PRC, nPRC) Then + Dim nPRId As Integer = 0 + EgtGetInfo(nFeatureId, MGR_FTR_PRID, nPRId) + Dim sKey As String = nPRId & "." & nPRC + ' ripristino parametri Q + If QParams.ContainsKey(sKey) Then + For Each QPar In QParams(sKey) + EgtSetInfo(nFeatureId, QPar.Key, QPar.Value) + Next + End If + End If + nFeatureId = EgtGetNext(nFeatureId) + End While + End If + End If + End If + nProduction_State = ItemState.ND + NotifyPropertyChanged(NameOf(Background)) + If bDuploToUpdate Then + ResetCalcTotalPart() + End If + ElseIf PartModel.State > ItemState.ND And Not bLocked Then + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + EgtDuploSetLocked(nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + End If + End If + End Sub + + Public Overrides Sub RefreshPart() + ' aggiorno dati del pezzo + EgtGetInfo(nPartId, BTL_PRT_PROJ, nProjId) + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + EgtGetInfo(nPartId, BTL_PRT_L, dL) + EgtGetInfo(nPartId, BTL_PRT_W, dW) + EgtGetInfo(nPartId, BTL_PRT_H, dH) + EgtGetInfo(nPartId, BTL_PRT_CNT, nCNT) + EgtGetInfo(nPartId, BTL_PRT_GROUP, sGROUP) + EgtGetInfo(nPartId, BTL_PRT_STOREY, sSTOREY) + EgtGetInfo(nPartId, BTL_PRT_MATERIAL, sMATERIAL) + If nType = BWType.BEAM Then + Else + ' leggo PosX, PosY, Rot e Flip + EgtGetInfo(nPartId, MGR_PRT_POSX, dPOSX) + EgtGetInfo(nPartId, MGR_PRT_POSY, dPOSY) + EgtGetInfo(nPartId, MGR_PRT_ROT, dROT) + EgtGetInfo(nPartId, MGR_PRT_FLIP, nFLIP) + End If + ' leggo volume + If Not EgtGetInfo(nPartId, BTL_PRT_VOLUME, dVolume) Then + Dim nOrigId As Integer = EgtDuploGetOriginal(nPartId) + EgtGetInfo(nOrigId, BTL_PRT_VOLUME, dVolume) + End If + ' leggo feature + PartM.RefreshBTLFeatures() + FeatureVMList.Clear() + CreateBTLFeatureVMList() + End Sub + +#End Region ' Part + +#Region "Feature" + + Protected Overrides Sub CreateBTLFeatureVMList() + Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures() + Select New BTLFeatureVM(BTLFeatureM)).ToList() + + For Each BTLFeatureVM As BTLFeatureVM In all + AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + If ParentMachGroupVM.nType = BWType.WALL Then + For Each BTLParamVM As BTLParamVM In BTLFeatureVM.QBTLParamVMList + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + AddHandler BTLFeatureVM.QBTLParamVMList.CollectionChanged, AddressOf OnBTLQParamVMListChanged + End If + Next + + m_FeatureVMList = New ObservableCollection(Of Core.BTLFeatureVM)(all) + AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged + + End Sub + + Friend Sub ResetCalcTotalPart() + ResetCalcPart() + For Each Feature In FeatureVMList + DirectCast(Feature, BTLFeatureVM).ResetCalcFeature() + Next + End Sub + +#End Region ' Feature + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "BackRotation" + + Public ReadOnly Property BackRotation_Command As ICommand + Get + If m_cmdBackRotation Is Nothing Then + m_cmdBackRotation = New Command(AddressOf BackRotation) + End If + Return m_cmdBackRotation + End Get + End Property + + Public Sub BackRotation() + ' se sta calcolando, esco subito + If Map.refProjectVM.bCalcRunning Then Return + ' se MachGroup gia' mandato in produzione, esco + If m_ParentMachGroupVM.nProduction_State >= ItemState.Assigned Then Return + Rotate(False) + EgtDraw() + End Sub + +#End Region ' BackRotation + +#Region "ForwardRotation" + + Public ReadOnly Property ForwardRotation_Command As ICommand + Get + If m_cmdForwardRotation Is Nothing Then + m_cmdForwardRotation = New Command(AddressOf ForwardRotation) + End If + Return m_cmdForwardRotation + End Get + End Property + + Public Sub ForwardRotation() + If Map.refProjectVM.bCalcRunning Then Return + ' se MachGroup gia' mandato in produzione, esco + If m_ParentMachGroupVM.nProduction_State >= ItemState.Assigned Then Return + Rotate(True) + EgtDraw() + End Sub + +#End Region ' ForwardRotation + +#End Region ' COMMANDS + +#Region "EVENTS" + + Protected Overrides Sub OnBTLFeatureVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.bDO) + ' setto pezzo da ricalcolare + ResetCalcTotalPart() + NotifyPropertyChanged(NameOf(bDOALL)) + End Select + End Sub + + Private Sub OnBTLQParamVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs) + If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.NewItems + AddHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + End If + If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then + For Each BTLParamVM As BTLParamVM In e.OldItems + RemoveHandler BTLParamVM.PropertyChanged, AddressOf OnBTLQParamVMPropertyChanged + Next + End If + End Sub + + Private Sub OnBTLQParamVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs) + Select Case e.PropertyName + Case NameOf(sender.dValue), NameOf(sender.sValue) + ' setto pezzo da ricalcolare + ResetCalcTotalPart() + End Select + End Sub + +#End Region ' EVENTS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/WallMachGroupVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/WallMachGroupVM.vb new file mode 100644 index 00000000..0d8d2949 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/WallMachGroupVM.vb @@ -0,0 +1,131 @@ +Imports System.Collections.ObjectModel +Imports System.Collections.Specialized +Imports System.ComponentModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class WallMachGroupVM + Inherits Core.WallMachGroupVM + +#Region "CONSTRUCTORS" + + Sub New(WallMachGroupM As WallMachGroupM) + MyBase.New(WallMachGroupM) + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Friend Function ReDrawWallMachgroup() As Boolean + ' scrivo dati di tutti i pezzi + Dim nIndex As Integer + For nIndex = 0 To PartVMList.Count - 1 + Dim Part As WallVM = PartVMList(nIndex) + EgtSetInfo(Id, MGR_RPT_PART & nIndex + 1, PartVMList(nIndex).nPartId & "," & Part.sPOSX & "," & + Part.sPOSY & "," & Part.PartM.nROTATED & "," & Part.PartM.nINVERTED) + Next + ' elimino eventuali successive info pezzi di troppo + nIndex = PartVMList.Count + 1 + Dim sTemp As String = "" + While EgtGetInfo(Id, MGR_RPT_PART & nIndex, sTemp) + EgtSetInfo(Id, MGR_RPT_PART & nIndex, "") + nIndex += 1 + End While + ' elimino vecchio grezzo ed eseguo script creazione nuovo + Dim nRawId As Integer = EgtGetFirstRawPart() + While nRawId <> GDB_ID.NULL + EgtRemoveRawPart(nRawId) + nRawId = EgtGetFirstRawPart() + End While + If Not ExecWall(Map.refMainWindowVM.MainWindowM.sTempDir, Map.refMachinePanelVM.SelectedMachine.Name, CalcIntegration.CmdType.RAWPART, False) Then Return False + Return True + End Function + + Public Overrides Function Copy() As Core.MyMachGroupVM + Return Nothing + End Function + +#End Region ' METHODS + + Protected Overrides Sub CreateWallVMList() + Dim all As List(Of WallVM) = (From WallM In m_WallMachGroupM.GetParts() + Select New WallVM(WallM, Me)).ToList() + + For Each WallVM As WallVM In all + AddHandler WallVM.PropertyChanged, AddressOf OnWallVMPropertyChanged + Next + + m_PartVMList = New ObservableCollection(Of Core.PartVM)(all) + AddHandler m_PartVMList.CollectionChanged, AddressOf OnWallVMListChanged + End Sub + + Protected Overrides Sub OnWallAdded(sender As Object, e As PartAddedEventArgs) + Dim WallVM As WallVM = New WallVM(e.NewPart, Me) + PartVMList.Add(WallVM) + End Sub + + Public Overrides Sub RefreshPartList() + End Sub + + Public Overrides Sub RefreshGroupData() + End Sub + + Friend Sub UpdateUsage() + m_WallMachGroupM.SetTotMat(dL * dW) + m_WallMachGroupM.SetMatForPart(0) + For Each Part In PartVMList + m_WallMachGroupM.SetMatForPart(m_WallMachGroupM.dMatForPart + (Part.dL * Part.dW)) + Next + NotifyPropertyChanged(NameOf(dUsage)) + NotifyPropertyChanged(NameOf(dWaste)) + End Sub + +#Region "COMMANDS" + +#Region "DeleteMachGroup" + + ' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded. + Public Overrides Sub DeleteMachGroup() + ' elimino tutte le copie + Dim nRawPartId As Integer = EgtGetFirstRawPart() + Dim nWallId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nWallId <> GDB_ID.NULL + If EgtRemovePartFromRawPart(nWallId) Then + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nWallId) + EgtErase(nWallId) + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + End If + nWallId = EgtGetFirstPartInRawPart(nRawPartId) + End While + ' elimino MachGroup + EgtRemoveMachGroup(Me.Id) + ' rimuovo dalla lista grezzi + Dim Index As Integer = Map.refMachGroupPanelVM.MachGroupVMList.IndexOf(Me) + If Index = 0 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(0) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + ElseIf Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 Then + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 1 Then + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 2) + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Nothing + EgtDraw() + End If + Else + Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(Index - 1) + End If + Map.refMachGroupPanelVM.MachGroupVMList.Remove(Me) + End Sub + +#End Region ' DeleteMachGroup + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachGroupPanel/WallVM.vb b/EgtBEAMWALL.Optimizer/MachGroupPanel/WallVM.vb new file mode 100644 index 00000000..d7f1a15e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachGroupPanel/WallVM.vb @@ -0,0 +1,210 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class WallVM + Inherits Core.WallVM + + Public Overrides Property sPOSX As String + Get + Return LenToString(m_WallM.dPOSX, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLen(value, dValue) Then + Dim dOldValue As Double = m_WallM.dPOSX + m_WallM.dPOSX = dValue + If EgtMovePartInRawPart(nPartId, New Vector3d(dValue - dOldValue, 0, 0)) Then + EgtSetInfo(nPartId, MGR_PRT_POSX, dValue) + Else + ' rispristino vecchio valore + m_WallM.dPOSX = dOldValue + End If + EgtDraw() + Else + NotifyPropertyChanged(NameOf(sPOSX)) + End If + End Set + End Property + + Public Overrides Property sPOSY As String + Get + Return LenToString(m_WallM.dPOSY, 3) + End Get + Set(value As String) + Dim dValue As Double + If StringToLen(value, dValue) Then + Dim dOldValue As Double = m_WallM.dPOSY + m_WallM.dPOSY = dValue + If EgtMovePartInRawPart(nPartId, New Vector3d(0, dValue - dOldValue, 0)) Then + EgtSetInfo(nPartId, MGR_PRT_POSY, dValue) + Else + ' rispristino vecchio valore + m_WallM.dPOSY = dOldValue + End If + EgtDraw() + Else + NotifyPropertyChanged(NameOf(sPOSY)) + End If + End Set + End Property + + Public Overrides Property bFLIP As Boolean + Get + Return m_WallM.bFLIP + End Get + Set(value As Boolean) + If value <> m_WallM.bFLIP Then + ' tolgo il pezzo dal grezzo + EgtRemovePartFromRawPart(nPartId) + ' recupero box del pezzo + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part) + If EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180) Then + m_WallM.bFLIP = value + EgtSetInfo(nPartId, MGR_PRT_FLIP, value) + Else + NotifyPropertyChanged(NameOf(bFLIP)) + End If + ' reinserisco il pezzo nel grezzo + EgtAddPartToRawPart(nPartId, New Point3d(dPOSX, m_WallM.dPOSY, 0), DirectCast(ParentMachGroupVM, WallMachGroupVM).m_WallMachGroupM.nRawPartId) + ' lo riseleziono + EgtSelectObj(nPartId) + EgtDraw() + End If + End Set + End Property + + ' Definizione comandi + Private m_cmdBackRotation As ICommand + Private m_cmdForwardRotation As ICommand + +#Region "CONSTRUCTOR" + + Sub New(WallM As WallM, ParentMachGroupVM As WallMachGroupVM) + MyBase.New(WallM, ParentMachGroupVM) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Protected Overrides Sub CreateBTLFeatureVMList() + Dim all As List(Of BTLFeatureVM) = (From BTLFeatureM In m_PartM.GetBTLFeatures() + Select New BTLFeatureVM(BTLFeatureM)).ToList() + + For Each BTLFeatureVM As BTLFeatureVM In all + AddHandler BTLFeatureVM.PropertyChanged, AddressOf OnBTLFeatureVMPropertyChanged + Next + + m_FeatureVMList = New ObservableCollection(Of Core.BTLFeatureVM)(all) + AddHandler m_FeatureVMList.CollectionChanged, AddressOf OnBTLFeatureVMListChanged + + End Sub + + Public Overrides Sub DeletePart() + ' elimino pezzo copia + EgtRemovePartFromRawPart(Me.nPartId) + ' Recupero Id BTLPart originale + Dim BTLPart As BTLPartVM = BTLPartVM.RetrieveBTLPartFromPart(nPartId) + EgtErase(Me.nPartId) + ' rimuovo dalla lista pezzi + Dim Index As Integer = ParentMachGroupVM.PartVMList.IndexOf(ParentMachGroupVM.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId)) + If Index = 0 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(0) + Else + ParentMachGroupVM.SelPart = Nothing + End If + ElseIf Index = ParentMachGroupVM.PartVMList.Count - 1 Then + If ParentMachGroupVM.PartVMList.Count > 1 Then + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(ParentMachGroupVM.PartVMList.Count - 2) + Else + ParentMachGroupVM.SelPart = Nothing + End If + Else + ParentMachGroupVM.SelPart = ParentMachGroupVM.PartVMList(Index - 1) + End If + ParentMachGroupVM.PartVMList.Remove(Me) + ' aggiorno contatore pezzi usati in Prod + If Not IsNothing(BTLPart) Then BTLPart.RefreshPartInProd() + EgtDraw() + End Sub + + Private Sub Rotate(IsPositive As Boolean) + ' tolgo il pezzo dal grezzo + EgtRemovePartFromRawPart(nPartId) + ' recupero box del pezzo + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nPartId, GDB_BB.STANDARD, b3Part) + ' se invertito lo reinverto + Dim bFliped As Boolean = bFLIP + If bFliped Then EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180) + Dim dAng As Double = If(IsPositive, 90, -90) + ' eseguo rotazione + Dim bOk As Boolean = EgtRotate(nPartId, b3Part.Center, -Vector3d.Z_AX, dAng) + If bOk Then + Dim TempRot = m_WallM.dROT + TempRot += dAng + If TempRot >= 360 Then + TempRot -= 360 + ElseIf TempRot < 0 Then + TempRot += 360 + End If + m_WallM.dROT = TempRot + EgtSetInfo(nPartId, MGR_PRT_ROT, m_WallM.dROT) + End If + ' ripristino eventuale inversione + If bFliped Then EgtRotate(nPartId, b3Part.Center, Vector3d.X_AX, 180) + ' reinserisco il pezzo nel grezzo + EgtAddPartToRawPart(nPartId, New Point3d(dPOSX, m_WallM.dPOSY, 0), DirectCast(ParentMachGroupVM, WallMachGroupVM).m_WallMachGroupM.nRawPartId) + ' lo riseleziono + EgtSelectObj(nPartId) + NotifyPropertyChanged(NameOf(sROT)) + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "BackRotation" + + Public ReadOnly Property BackRotation_Command As ICommand + Get + If m_cmdBackRotation Is Nothing Then + m_cmdBackRotation = New Command(AddressOf BackRotation) + End If + Return m_cmdBackRotation + End Get + End Property + + Public Sub BackRotation() + Rotate(False) + EgtDraw() + End Sub + +#End Region ' BackRotation + +#Region "ForwardRotation" + + Public ReadOnly Property ForwardRotation_Command As ICommand + Get + If m_cmdForwardRotation Is Nothing Then + m_cmdForwardRotation = New Command(AddressOf ForwardRotation) + End If + Return m_cmdForwardRotation + End Get + End Property + + Public Sub ForwardRotation() + Rotate(True) + EgtDraw() + End Sub + +#End Region ' ForwardRotation + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml new file mode 100644 index 00000000..6d211b1e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml.vb new file mode 100644 index 00000000..83a5832c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class MachinePanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb new file mode 100644 index 00000000..79084ac5 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb @@ -0,0 +1,414 @@ +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MachinePanelVM + Inherits EgtWPFLib5.MachinePanelVM + +#Region "FIELDS & PROPERTIES" + + ' Radice del direttorio delle macchine + Private m_sMachinesRoot As String + + ' Macchina correntemente selezionata e quindi attiva + Private m_SelectedMachine As Machine = Nothing + Public Overrides Property SelectedMachine As Machine + Get + Return m_SelectedMachine + End Get + Set(value As Machine) + If value IsNot m_SelectedMachine Then + ' imposto macchina in DbGeometrico + If Not IsNothing(value) AndAlso EgtSetCurrMachine(value.Name) OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + m_SelectedMachine = value + End If + ' Salvo impostazione macchina corrente + SaveCurrentMachine() + NotifyPropertyChanged(NameOf(SelectedMachine)) + ' inizializzo la macchina selezionata come macchina corrente + Dim nMachType As MachineType = DirectCast(m_SelectedMachine, MyMachine).nType + SectionXMaterial.SetType(nMachType) + If Not IsNothing(value) Then + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, value.Name, nMachType) + Else + InitCurrentMachine(Map.refMainWindowVM.MainWindowM.sMachinesRoot, m_SelectedMachine.Name, nMachType) + End If + ' mostro bottone tabella beam o wall a seconda del tipo + m_BeamTable_Visibility = If(nMachType = MachineType.BEAM OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + m_WallTable_Visibility = If(nMachType = MachineType.WALL OrElse nMachType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + NotifyPropertyChanged(NameOf(BeamTable_Visibility)) + NotifyPropertyChanged(NameOf(WallTable_Visibility)) + ' carico i Parametri Q da mostrare (Beam, Wall o entrambi) in base al tipo di macchina selezionata + If Not IsNothing(Map.refConfigurationPageVM) Then + ' carico i parametri Q dei Process letti dall'ini + Map.refConfigurationPageVM.GetQParamsList() + ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + If Not IsNothing(Map.refConfigurationPageVM.QBTLParamVMList) Then + Map.refConfigurationPageVM.QBTLParamVMList.Clear() + End If + For Each PRCItem In Map.refConfigurationPageVM.PRCList + For Each QBTLParam In PRCItem.QBTLParamVMList + Map.refConfigurationPageVM.QBTLParamVMList.Add(QBTLParam) + Next + Next + NotifyPropertyChanged(NameOf(Map.refConfigurationPageVM.QBTLParamVMList)) + End If + ' aggiorno nome macchina in statusbar + Map.refMyStatusBarVM.RefreshMachName() + End If + End Set + End Property + + Private m_MachPanel_IsEnabled As Boolean = True + Public Property MachPanel_IsEnabled As Boolean + Get + Return m_MachPanel_IsEnabled + End Get + Set(value As Boolean) + m_MachPanel_IsEnabled = value + NotifyPropertyChanged(NameOf(MachPanel_IsEnabled)) + End Set + End Property + + Private m_BeamTable_Visibility As Visibility + Public ReadOnly Property BeamTable_Visibility As Visibility + Get + Return m_BeamTable_Visibility + End Get + End Property + + Private m_WallTable_Visibility As Visibility + Public ReadOnly Property WallTable_Visibility As Visibility + Get + Return m_WallTable_Visibility + End Get + End Property + + Public ReadOnly Property SetUp_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bModifySetup, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + +#Region "Messages" + + Public ReadOnly Property ToolDBMsg As String + Get + Return EgtMsg(90706) + End Get + End Property + Public ReadOnly Property MachiningDbMsg As String + Get + Return EgtMsg(90707) + End Get + End Property + Public ReadOnly Property SetUpMsg As String + Get + Return EgtMsg(90933) + End Get + End Property + Public ReadOnly Property ParameterMachineMsg As String + Get + Return EgtMsg(61778) + End Get + End Property + +#End Region ' Messages + +#Region "ToolTip" + + Public ReadOnly Property ToolDBToolTip As String + Get + Return EgtMsg(5003) + End Get + End Property + Public ReadOnly Property MachiningDbToolTip As String + Get + Return EgtMsg(5004) + End Get + End Property + Public ReadOnly Property SetUpToolTip As String + Get + Return EgtMsg(31501) + End Get + End Property + +#End Region ' ToolTip + + ' Definizione comandi + Private m_cmdBeamTable As ICommand + Private m_cmdWallTable As ICommand + Private m_cmdParameterMachine As ICommand + +#End Region 'FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefMachinePanelVM(Me) + ' recupero cartella radice delle macchine + m_sMachinesRoot = Map.refMainWindowVM.MainWindowM.sMachinesRoot + ' Carica macchine da cartella delle macchine + MyMachine.MachineListInit(m_sMachinesRoot, MachineList) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub LoadCurrentMachine() + If MachineList.Count = 0 Then Return + Dim CurrMachine As Machine = Nothing + Dim CurrMachineName As String = String.Empty + GetMainPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMachineName) + Dim bFound As Boolean = False + If Not String.IsNullOrEmpty(CurrMachineName) Then + For Each Mach In MachineList + If Mach.Name = CurrMachineName Then + bFound = True + CurrMachine = Mach + Exit For + End If + Next + End If + If Not bFound And MachineList.Count > 0 Then + CurrMachine = MachineList(0) + End If + If Not IsNothing(CurrMachine) Then + If EgtSetCurrMachine(CurrMachine.Name) Then + SelectedMachine = CurrMachine + End If + End If + End Sub + + Friend Sub SaveCurrentMachine() + If IsNothing(m_SelectedMachine) Then Return + WriteMainPrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name) + End Sub + + Friend Sub UpdateCurrentMachine() + Dim sMachName As String = String.Empty + If EgtGetCurrMachineName(sMachName) Then + For Each Mach In MachineList + If Mach.Name = sMachName Then + SelectedMachine = Mach + Exit For + End If + Next + End If + End Sub + + Friend Function BeamMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Beam" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\BeamTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni travi + Dim sTitle = EgtMsg(9000) 'Tabelle delle lavorazioni delle travi + Dim BeamMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath) + Dim BeamMchsWinV As Object = Nothing + If bOnlyProd Then + BeamMchsWinV = New OnlyProdBeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM) + Else + BeamMchsWinV = New BeamMachiningsWindowV(Application.Current.MainWindow, BeamMchsWinVM) + End If + BeamMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle travi.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9009), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Friend Function WallMachDb() As Boolean + ' Assegno le path + Dim sBaseDir As String = m_sMachinesRoot & "\" & m_SelectedMachine.Name & "\" & "Wall" + ' verifico se ci sono i file ini + Dim sMachTypePath As String = sBaseDir & "\MachiningTypes.ini" + Dim sTabTemplPath As String = sBaseDir & "\WallTableTemplate.ini" + If File.Exists(sMachTypePath) AndAlso File.Exists(sTabTemplPath) Then + ' apro finestra di gestione lavorazioni pareti + Dim sTitle = EgtMsg(9010) 'Tabelle delle lavorazioni delle pareti + Dim WallMchsWinVM As New MyBeamMachiningsWindowVM(sTitle, sBaseDir, sMachTypePath, sTabTemplPath, False) + Dim WallMchsWinV As Object = Nothing + If bOnlyProd Then + WallMchsWinV = New OnlyProdBeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM) + Else + WallMchsWinV = New BeamMachiningsWindowV(Application.Current.MainWindow, WallMchsWinVM) + End If + WallMchsWinV.ShowDialog() + Else + ' Impossibile aprire l'Editor delle lavorazioni delle pareti.
Mancano i file di configurazione. - Errore + MessageBox.Show(EgtMsg(9011), EgtMsg(9008), MessageBoxButton.OK, MessageBoxImage.Stop) + End If + Return True + End Function + + Public Overrides Sub ToolDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtTdbReload() Then + EgtOutLog("Impossible reloading tool Db") + MessageBox.Show(EgtMsg(MSG_TOOLDBERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + + Dim ToolDbWindowVM As New MyToolDbWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Beam") + Dim ToolDbWindowV = Nothing + If bOnlyProd Then + ToolDbWindowV = New OnlyProdToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + Else + ToolDbWindowV = New ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + End If + + If ToolDbWindowVM.MatType <> 0 Then + ToolDbWindowV.Height = 640 + ToolDbWindowV.Width = 1024 + ToolDbWindowV.ShowDialog() + Else + Exit Sub + End If + End Sub + + Public Overrides Sub MachDb(ByVal param As Object) + If Not VerifyMachinesDir(m_sMachinesRoot) Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtMdbReload() Then + EgtOutLog("Impossible reloading machining Db") + MessageBox.Show(EgtMsg(MSG_MACHININGDBERRORS + 8), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(CurrentMachine.sMachIniFile, Map.refSceneHostVM.MainScene.GetCtx(), "Stone") + Dim MachDbWindowV = Nothing + If bOnlyProd Then + MachDbWindowV = New OnlyProdMachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + Else + MachDbWindowV = New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + End If + + If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then + MachDbWindowV.Height = 768 + MachDbWindowV.Width = 1024 + MachDbWindowV.ShowDialog() + Else + Exit Sub + End If + End Sub + + Public Overrides Sub SetUp(ByVal param As Object) + ' verifico che il file di configurazione attrezzaggio (lua) della macchina esista + If Not File.Exists(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) Then + EgtOutLog("SetUp error: SetUp configuration file doesn't exist ") + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato, + ' e testa e uscita dell'utensile attrezzato + EgtLuaExecFile(CurrentMachine.sMachDir & "\Scripts\" & SETUP_LUA) + ' verifico che le teste riportate in configurazione esistano + Dim Index As Integer = 1 + Dim nErr As Integer = 0 + While nErr = 0 + Dim sHead As String = String.Empty + nErr = 999 + EgtLuaSetGlobIntVar("STU.INDEX", Index) + EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + If EgtGetHeadExitCount(sHead) = 0 Then + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + End If + Index += 1 + End While + ' Reset lua + EgtLuaResetGlobVar("STU") + + Dim SetUpWindow As Object = Nothing + If bOnlyProd Then + SetUpWindow = New OnlyProdSetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) With { + .Height = 614, + .Width = 1024 + } + Else + SetUpWindow = New SetUpWindowV(Application.Current.MainWindow, New SetUpWindowVM(CurrentMachine.sMachDir, CurrentMachine.sMachineName)) With { + .Height = 614, + .Width = 1024 + } + End If + + SetUpWindow.ShowDialog() + End Sub + +#End Region + +#Region "COMMANDS" + +#Region "BeamTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property BeamTable_Command As ICommand + Get + If m_cmdBeamTable Is Nothing Then + m_cmdBeamTable = New Command(AddressOf BeamMachDb) + End If + Return m_cmdBeamTable + End Get + End Property + +#End Region ' BeamTable + +#Region "WallTable" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property WallTable_Command As ICommand + Get + If m_cmdWallTable Is Nothing Then + m_cmdWallTable = New Command(AddressOf WallMachDb) + End If + Return m_cmdWallTable + End Get + End Property + +#End Region ' WallTable + +#Region "ParameterMachine" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ParameterMachine_Command As ICommand + Get + If m_cmdParameterMachine Is Nothing Then + m_cmdParameterMachine = New Command(AddressOf ParameterMachineVisibility) + End If + Return m_cmdParameterMachine + End Get + End Property + + Public Sub ParameterMachineVisibility() + If Map.refConfigurationPageVM.m_MachineParameter_Visibility Then + Map.refConfigurationPageVM.SetMachineParameter_Visibility(Visibility.Visible) + Map.refConfigurationPageVM.SetMachine_Visibility(Visibility.Visible) + Else + Map.refConfigurationPageVM.SetMachineParameter_Visibility(Visibility.Collapsed) + Map.refConfigurationPageVM.SetMachine_Visibility(Visibility.Collapsed) + End If + End Sub + +#End Region ' ParameterMachine + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml new file mode 100644 index 00000000..46a2a5e3 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml.vb b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml.vb new file mode 100644 index 00000000..5d9a7df7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageV.xaml.vb @@ -0,0 +1,3 @@ +Public Class MachiningPageV + +End Class diff --git a/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageVM.vb b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageVM.vb new file mode 100644 index 00000000..54b9a5b3 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachiningPage/MachiningPageVM.vb @@ -0,0 +1,3 @@ +Public Class MachiningPageVM + +End Class diff --git a/EgtBEAMWALL.Optimizer/MacroFeatureWnd/MacroFeatureWndV.xaml b/EgtBEAMWALL.Optimizer/MacroFeatureWnd/MacroFeatureWndV.xaml new file mode 100644 index 00000000..0cb301a9 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MacroFeatureWnd/MacroFeatureWndV.xaml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/MainMenu/MainMenuV.xaml.vb b/EgtBEAMWALL.Optimizer/MainMenu/MainMenuV.xaml.vb new file mode 100644 index 00000000..874fb85d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MainMenu/MainMenuV.xaml.vb @@ -0,0 +1,3 @@ +Public Class MainMenuV + +End Class diff --git a/EgtBEAMWALL.Optimizer/MainMenu/MainMenuVM.vb b/EgtBEAMWALL.Optimizer/MainMenu/MainMenuVM.vb new file mode 100644 index 00000000..3d0f118c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MainMenu/MainMenuVM.vb @@ -0,0 +1,916 @@ +Imports System.IO +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgwProxy.LiMan + +Public Class MainMenuVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_OpenPage_Timer As New DispatcherTimer + Private m_bOpenPage As Boolean = False + Private m_nPageToOpen As Pages = Pages.MACHINING + + Private m_MainMenu_IsEnabled As Boolean = True + Public ReadOnly Property MainMenu_IsEnabled As Boolean + Get + Return m_MainMenu_IsEnabled + End Get + End Property + + Private m_SendFeedbackIsEnabled As Boolean = True + Public ReadOnly Property SendFeedbackIsEnabled As Boolean + Get + Return m_SelPage = Pages.VIEW Or m_SelPage = Pages.MACHINING Or m_SelPage = Pages.ONLYPRODPAGE + End Get + End Property + + Public Property View_IsChecked As Boolean + Get + Return m_SelPage = Pages.VIEW + End Get + Set(value As Boolean) + If value Then + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso Not IsNothing(ProjectManagerVM.CurrProd) AndAlso + ProjectManagerVM.CurrProj.nProdId = ProjectManagerVM.CurrProd.nProdId Then + ProjectManagerVM.CurrProj.SetReloadProject(False) + End If + SelPage = Pages.VIEW + End If + End Set + End Property + + Public Property Machining_IsChecked As Boolean + Get + Return m_SelPage = Pages.MACHINING + End Get + Set(value As Boolean) + If value Then + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso Not IsNothing(ProjectManagerVM.CurrProd) AndAlso + ProjectManagerVM.CurrProj.nProdId = ProjectManagerVM.CurrProd.nProdId Then + ProjectManagerVM.CurrProd.SetReloadProject(False) + End If + SelPage = Pages.MACHINING + End If + End Set + End Property + + Public Property OnlyProdPage_IsChecked As Boolean + Get + Return m_SelPage = Pages.ONLYPRODPAGE + End Get + Set(value As Boolean) + If value Then SelPage = Pages.ONLYPRODPAGE + End Set + End Property + + Public Property Supervisor_IsChecked As Boolean + Get + Return m_SelPage = Pages.SUPERVISOR + End Get + Set(value As Boolean) + If value Then SelPage = Pages.SUPERVISOR + End Set + End Property + + Public Property Config_IsChecked As Boolean + Get + Return m_SelPage = Pages.CONFIG + End Get + Set(value As Boolean) + If value Then SelPage = Pages.CONFIG + End Set + End Property + + Private m_Supervisor_Visibility As Visibility + Public ReadOnly Property Supervisor_Visibility As Visibility + Get + Return m_Supervisor_Visibility + End Get + End Property + + Private m_SelPage As Integer = -1 + Public Property SelPage As Integer + Get + Return m_SelPage + End Get + Set(value As Integer) + ' lancio selezione pagina con verifica file modificato + SetSelPage(value) + End Set + End Property + ' funzione che permette di cambiare pagina + ' bVerifyModification: se vero verifica modifiche su file e chiede di salvare + Friend Sub SetSelPage(Page As Pages, Optional bVerifyModification As Boolean = True) + Dim bOk As Boolean = True + ' Esco dallo stato corrente + Select Case m_SelPage + Case Pages.VIEW + bOk = ExitVIEW(bVerifyModification) + Case Pages.MACHINING + bOk = ExitMACHINING(bVerifyModification) + Case Pages.CONFIG + bOk = ExitCONFIG() + Case Pages.ONLYPRODPAGE + bOk = ExitONLYPRODPAGE(bVerifyModification) + End Select + If bOk Then + ' Entro nel nuovo stato + m_SelPage = Page + Select Case m_SelPage + Case Pages.VIEW + InitVIEW() + Case Pages.MACHINING + InitMACHINING() + Case Pages.CONFIG + InitCONFIG() + Case Pages.ONLYPRODPAGE + InitONLYPRODPAGE() + End Select + End If + ' aggiorno visualizzazione RadioButton + NotifyPropertyChanged(NameOf(View_IsChecked)) + NotifyPropertyChanged(NameOf(Machining_IsChecked)) + NotifyPropertyChanged(NameOf(Supervisor_IsChecked)) + NotifyPropertyChanged(NameOf(Config_IsChecked)) + NotifyPropertyChanged(NameOf(OnlyProdPage_IsChecked)) + End Sub + + Public ReadOnly Property OnlyProdPage_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bOnlyProd, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property ViewOptimizer_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bOnlyProd, Visibility.Collapsed, Visibility.Visible) + End Get + End Property + + ' Testo che mostra il numero di versioni da aggiornare + Private m_NumVersion As Integer + Public ReadOnly Property NumVersion As Integer + Get + Return m_NumVersion + End Get + End Property + Friend Sub SetNumVersion(value As Integer) + m_NumVersion = value + NotifyPropertyChanged(NameOf(NumVersion)) + End Sub + +#Region "Messages" + + Public ReadOnly Property Viewer_Msg As String + Get + Return EgtMsg(61830) + End Get + End Property + + Public ReadOnly Property Optimizer_Msg As String + Get + Return EgtMsg(61831) + End Get + End Property + + Public ReadOnly Property Configuration_Msg As String + Get + Return EgtMsg(61832) + End Get + End Property + + Public ReadOnly Property Supervisor_Msg As String + Get + Return EgtMsg(62500) + End Get + End Property + + Public ReadOnly Property OnlyProdPage_Msg As String + Get + Return EgtMsg(61896) + End Get + End Property + + Public ReadOnly Property NVersion_Msg As String + Get + Return EgtMsg(61747) + End Get + End Property + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property SendFeedbackToolTip As String + Get + Return EgtMsg(30513) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Messages + + ' Definizione comandi + Private m_cmdSupervisor As ICommand + Private m_cmdSendFeedback As ICommand + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in EgtCAM5Map + Map.SetRefMainMenuVM(Me) + ' abilito supervisore + If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR) Then + m_Supervisor_Visibility = Visibility.Visible + Else + m_Supervisor_Visibility = Visibility.Collapsed + End If + ' imposto numero di versioni da aggiornare + SetNumVersion(GetNumVersion()) + ' imposto timer di apertura da ottimizzatore + m_OpenPage_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_OpenPage_Timer.Tick, AddressOf OpenPage_Tick + m_OpenPage_Timer.Start() + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + ''' + ''' Funzione che restituisce il numero di versioni del programma che sono da aggiornare + ''' + ''' + Friend Function GetNumVersion() As Integer + 'Dim bOk As Boolean = EgtBEAMWALL.Core.Configuration.GetComunication() + '' Controllo se la comunicazione è avvenuta con successo + 'If bOk Then + ' ' Recupero la lista delle versioni del programma filtrate per quella attuale + ' Dim ReleaseList As List(Of DTO.ReleaseDTO) = EgtBEAMWALL.Core.Configuration.m_commLib.ReleaseGetFiltLimit(K_BEAMWALL, EgtBEAMWALL.Core.Configuration.ActualVersion, "2.5.15.0") + ' Return ReleaseList.Where(Function(r) r.IsPermitted).Count + 'Else + ' Return 0 + 'End If + End Function + + Friend Sub SetMainMenuIsEnabled(bIsEnabled As Boolean) + m_MainMenu_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(MainMenu_IsEnabled)) + End Sub + + Private Function InitVIEW() As Boolean + Map.refProjectVM.SetBottomPanel_Visibility(True) + Map.refProjectVM.SetLeftPanel_Visibility(True) + 'Map.refLeftPanelVM.UpdateView() + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.UpdateView() + If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.UpdateView() + Map.refProjectVM.SetFeatureManager_Visibility(True) + Map.refProjectVM.SetTopPanel_Visibility(False) + Map.refProjectVM.SetShowBeamPanel_Visibility(True) + Map.refProjectVM.SetProjManager_Visibility(True) + Map.refProjectVM.SetProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(False) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(False) + Map.refProjectVM.SetOptimizePanel_Visibility(Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refProjectVM.NotifyAllPanelVisibility() + Map.refCALCPanelVM.SetChooseMachineBtn_Visibility(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Map.refMachinePanelVM.MachineList.Count > 1 AndAlso GetMainPrivateProfileInt(S_MACH, K_CHANGEMACH, 0) = 1) + Map.refStatisticsTimePanelVM.SetStatisticsTimePanel_Visibility() + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ColumnVisibility = Visibility.Visible + End If + ' aggiorno la visibilità delle colonne + For Each col In Map.refFeatureListVM.FeatureColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refPartListVM.PartColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refStatisticsVM.StatisticsColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refPParameterListVM.PParameterListColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refQParameterListVM.QParameterListColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + ' imposto dimensioni colonne/righe della Grid + DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_VIEW, Map.refProjectVM.GridDims) + DimensionsIniFile.ReadGridDimensions(ConstDims.LEFTPANEL_VIEW, Map.refLeftPanelVM.GridDims) + ' apro progetto proj + If Not IsNothing(ProjectManagerVM.CurrProj) Then + If ProjectManagerVM.CurrProj.bReloadProject OrElse Map.refConfigurationPageVM.QParametersModified Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROJ, 2, EgtMsg(63005), 10, 100) ' Loading parts + Map.refProjManagerVM.OpenProject(ProjectManagerVM.CurrProj) + ' aggiorno le colonne in base al tipo progetto + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE <> BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Else + Map.refRawPartListVM.UpdateColumns(BWType.BEAM) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + Map.refTopPanelVM.ManageQParamsRowVisibility(BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(BWType.BEAM) + End If + ' resetto modifica parametri Q default + Map.refConfigurationPageVM.ResetQParametersModified() + DbControllers.m_ProjController.LockByProjId(ProjectManagerVM.CurrProj.nProjId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + Else + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROJ, 2, EgtMsg(63005), 10, 100) ' Loading parts + ' recupero indice di modifica progetto + Dim CommIndex As Integer = -1 + Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId) + For Each ActiveSession In ActiveSessionList + If ActiveSession.ItemId = ProjectManagerVM.CurrProj.nProdId Then + CommIndex = ActiveSession.Index + End If + Next + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63002), 30, 100) ' Loading machining groups + ' verifico se il prod di provenienza ha piu' proj + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then + ' se si rigenero BTLStructure + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(ProjectManagerVM.CurrProj.nProjId)) + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + End If + ' fisso indice sessione di comunicazione + If CommIndex > -1 Then + ProjectManagerVM.CurrProj.SetModificationIndex(CommIndex) + End If + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + ProjectManagerVM.CurrProj.SetReloadProject(True) + End If + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + DbControllers.m_ProjController.LockByProjId(ProjectManagerVM.CurrProj.nProjId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Else + Map.refSceneHostVM.MainController.NewProject() + Map.refProjectVM.BTLStructureVM = Nothing + Map.refProjectVM.MachGroupPanelVM = Nothing + End If + Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage)) + Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeParam_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeMaterial_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.Statistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.VisStatistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.OtStatistic_Visibility)) + Return True + End Function + + Private Function ExitVIEW(bVerifyModification As Boolean) As Boolean + ' verifico se progetto modificato, e chiedo se salvare + If bVerifyModification Then + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.CurrProj, ProjectType.PROJ) Then + Return False + End If + End If + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + Map.refProjectVM.SetBottomPanel_Visibility(False) + Map.refProjectVM.SetLeftPanel_Visibility(True) + Map.refProjectVM.SetFeatureManager_Visibility(False) + Map.refProjectVM.SetTopPanel_Visibility(True) + Map.refProjectVM.SetShowBeamPanel_Visibility(False) + Map.refProjectVM.SetProjManager_Visibility(False) + Map.refProjectVM.SetOnlyProdManager_Visibility(True) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(True) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(True) + Map.refProjectVM.SetProdManager_Visibility(True) + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Map.refCALCPanelVM.SetChooseMachine_Visibility(False) + Return True + End Function + + Private Function InitMACHINING() As Boolean + ' imposto dimensioni colonne/righe della Grid + DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_OPTIMIZER, Map.refProjectVM.GridDims) + DimensionsIniFile.ReadGridDimensions(ConstDims.LEFTPANEL_OPTIMIZER, Map.refLeftPanelVM.GridDims) + ' inizializzo gruppi di lavorazione + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso Not IsNothing(ProjectManagerVM.CurrProd.nProdId) AndAlso ProjectManagerVM.CurrProd.nProdId > 0 Then + If File.Exists(ProjectManagerVM.CurrProd.sProdPath) Then + ' apro progetto + If ProjectManagerVM.CurrProd.bReloadProject OrElse Map.refConfigurationPageVM.QParametersModified Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 50) ' Loading parts + Map.refProdManagerVM.TempCurrProd = ProjectManagerVM.CurrProd + If Map.refSceneHostVM.MainController.OpenProject(ProjectManagerVM.CurrProd.sProdPath, False) Then + ' aggiorno le colonne in base al tipo progetto + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE <> BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' resetto modifica parametri Q default + Map.refConfigurationPageVM.ResetQParametersModified() + DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + End If + Else + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 30) ' Loading parts + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(False) + ' verifico se il prod ha piu' proj + If ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then + ' se si rigenero BTLStructure + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0)) + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + End If + ' recupero indice di modifica progetto + Dim CommIndex As Integer = -1 + Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId) + For Each ActiveSession In ActiveSessionList + If ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then + CommIndex = ActiveSession.Index + End If + Next + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63002), 30, 100) ' Loading machining groups + ' carico lista dei MachGroup + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + ' fisso indice sessione di comunicazione + If CommIndex > -1 Then + ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex) + End If + ProjectManagerVM.CurrProd.SetReloadProject(True) + End If + ' se Warehouse di tipo Medium e piu' di un progetto collegato + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM AndAlso ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then + ' confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' controllo se devo lanciare verifica perche' importato + Dim bGetVerifyResult As Boolean = False + Dim bVerifyMach As Boolean = False + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + If EgtGetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, bGetVerifyResult) AndAlso bGetVerifyResult Then + If Not bVerifyMach Then bVerifyMach = True + EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, False) + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + If bVerifyMach Then + Map.refCALCPanelVM.VerifyAll() + End If + ' seleziono prima barra + Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup() + Else + MessageBox.Show(EgtMsg(61871)) + End If + Else + Map.refSceneHostVM.MainController.NewProject() + Map.refProjectVM.BTLStructureVM = Nothing + Map.refProjectVM.MachGroupPanelVM = Nothing + End If + ' aggiorno lista possibili nesting + Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) + ' aggiorno visibilita' degli elementi grafici + Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage)) + Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeParam_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.ChangeMaterial_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.Statistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.VisStatistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.OtStatistic_Visibility)) + Map.refTopPanelVM.NotifyPropertyChanged(NameOf(Map.refPartInRawPartManagerVM.MovePart_Visibility)) + Map.refProjectVM.SetBottomPanel_Visibility(False) + Map.refProjectVM.SetLeftPanel_Visibility(True) + If Not IsNothing(Map.refFeatureListManagerVM) Then Map.refFeatureListManagerVM.UpdateView() + If Not IsNothing(Map.refBTLPartManagerVM) Then Map.refBTLPartManagerVM.UpdateView() + Map.refProjectVM.SetFeatureManager_Visibility(False) + Map.refProjectVM.SetTopPanel_Visibility(True) + Map.refProjectVM.SetShowBeamPanel_Visibility(False) + Map.refProjectVM.SetProjManager_Visibility(False) + Map.refProjectVM.SetProdManager_Visibility(True) + Map.refProjectVM.SetOnlyProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(False) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(False) + Map.refProjectVM.NotifyAllPanelVisibility() + Map.refCALCPanelVM.SetChooseMachineBtn_Visibility(False) + Map.refTopPanelVM.UpdateQParameterVisibility() + Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility() + Map.refStatisticsTimePanelVM.SetStatisticsTimePanel_Visibility() + ' aggiorno la visibilità delle colonne + For Each col In Map.refFeatureListVM.FeatureColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refRawPartListVM.RawPartColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refFeatureInPartInRawPartListVM.FeatureInPartInRawPartColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refPartInRawPartListVM.PartInRawPartColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refStatisticsVM.OptimizerStatisticsColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ColumnVisibility = Visibility.Collapsed + End If + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Return True + End Function + + Private Function ExitMACHINING(bVerifyModification As Boolean) As Boolean + ' verifico se progetto modificato, e chiedo se salvare + If bVerifyModification Then + If ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) = MessageBoxResult.Cancel Then + Return False + End If + End If + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + Map.refProjectVM.SetBottomPanel_Visibility(True) + Map.refProjectVM.SetLeftPanel_Visibility(False) + Map.refProjectVM.SetFeatureManager_Visibility(True) + Map.refProjectVM.SetTopPanel_Visibility(False) + Map.refProjectVM.SetShowBeamPanel_Visibility(True) + Map.refProjectVM.SetProjManager_Visibility(True) + Map.refProjectVM.SetProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(False) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(False) + Map.refProjectVM.SetOptimizePanel_Visibility(Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refCALCPanelVM.SetChooseMachine_Visibility(False) + EgtResetCurrMachGroup() + Return True + End Function + + Private Function InitCONFIG() As Boolean + Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage)) + Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled)) + Return True + End Function + + Private Function ExitCONFIG() As Boolean + Map.refConfigurationPageVM.VerifyConfigPageModification() + ' resetto flag inserimento password + Map.refConfigurationPageVM.bModifyMachParam = False + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE <> BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Else + Map.refRawPartListVM.UpdateColumns(BWType.BEAM) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + Map.refTopPanelVM.ManageQParamsRowVisibility(BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(BWType.BEAM) + End If + Return True + End Function + + Private Function InitONLYPRODPAGE() As Boolean + ' aggiorno lista possibili nesting + Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) + ' aggiorno visibilita' degli elementi grafici + Map.refProjectVM.SetBottomPanel_Visibility(True) + Map.refProjectVM.SetLeftPanel_Visibility(False) + Map.refFeatureListManagerVM.UpdateView() + Map.refBTLPartManagerVM.UpdateView() + Map.refProjectVM.SetFeatureManager_Visibility(True) + Map.refProjectVM.SetTopPanel_Visibility(True) + Map.refProjectVM.SetShowBeamPanel_Visibility(True) + Map.refProjectVM.SetOnlyProdManager_Visibility(True) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(True) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(True) + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Map.refProjectVM.NotifyAllPanelVisibility() + Map.refCALCPanelVM.SetChooseMachineBtn_Visibility(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refMachinePanelVM.MachineList.Count > 1 AndAlso GetMainPrivateProfileInt(S_MACH, K_CHANGEMACH, 0) = 1) + Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility() + Map.refStatisticsTimePanelVM.SetStatisticsTimePanel_Visibility() + + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ColumnVisibility = Visibility.Visible + End If + ' aggiorno la visibilità delle colonne + For Each col In Map.refFeatureListVM.FeatureColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refPartListVM.PartColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + If Not IsNothing(Map.refStatisticsVM) Then + For Each col In Map.refStatisticsVM.StatisticsColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + End If + For Each col In Map.refPParameterListVM.PParameterListColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + For Each col In Map.refQParameterListVM.QParameterListColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + + DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_ONLYPROD, Map.refProjectVM.GridDims) + + ' inizializzo gruppi di lavorazione + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso Not IsNothing(ProjectManagerVM.CurrProd.nProdId) AndAlso ProjectManagerVM.CurrProd.nProdId > 0 Then + If File.Exists(ProjectManagerVM.CurrProd.sProdPath) Then + ' apro progetto + If ProjectManagerVM.CurrProd.bReloadProject OrElse Map.refConfigurationPageVM.QParametersModified Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 50) ' Loading parts + Map.refOnlyProdManagerVM.TempCurrProd = ProjectManagerVM.CurrProd + If Map.refSceneHostVM.MainController.OpenProject(ProjectManagerVM.CurrProd.sProdPath, False) Then + ' aggiorno le colonne in base al tipo progetto + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + If Not IsNothing(Map.refTopPanelVM) Then + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + End If + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) + ' resetto modifica parametri Q default + Map.refConfigurationPageVM.ResetQParametersModified() + DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refOnlyProdManagerVM.MruFileNames)) + End If + Else + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 2, EgtMsg(63005), 10, 30) ' Loading parts + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(False) + ' verifico se il prod ha piu' proj + If ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then + ' se si rigenero BTLStructure + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0)) + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + End If + ' recupero indice di modifica progetto + Dim CommIndex As Integer = -1 + Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId) + For Each ActiveSession In ActiveSessionList + If ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then + CommIndex = ActiveSession.Index + End If + Next + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63002), 30, 100) ' Loading machining groups + ' carico lista dei MachGroup + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + ' fisso indice sessione di comunicazione + If CommIndex > -1 Then + ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex) + End If + ProjectManagerVM.CurrProd.SetReloadProject(True) + End If + ' se Warehouse di tipo Medium e piu' di un progetto collegato + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM AndAlso ProjectManagerVM.CurrProd.nProjIdList.Count > 1 Then + ' confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + DbControllers.m_ProdController.LockByProdId(ProjectManagerVM.CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' controllo se devo lanciare verifica perche' importato + Dim bGetVerifyResult As Boolean = False + Dim bVerifyMach As Boolean = False + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + If EgtGetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, bGetVerifyResult) AndAlso bGetVerifyResult Then + If Not bVerifyMach Then bVerifyMach = True + EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, False) + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + If bVerifyMach Then + Map.refCALCPanelVM.VerifyAll() + End If + ' seleziono prima barra + Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup() + Else + MessageBox.Show(EgtMsg(61871)) + End If + Else + Map.refSceneHostVM.MainController.NewProject() + Map.refProjectVM.BTLStructureVM = Nothing + Map.refProjectVM.MachGroupPanelVM = Nothing + End If + Map.refMainWindowVM.NotifyPropertyChanged(NameOf(Map.refMainWindowVM.nSelTabPage)) + Map.refMainMenuVM.NotifyPropertyChanged(NameOf(Map.refMainMenuVM.SendFeedbackIsEnabled)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.Statistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.VisStatistic_Visibility)) + Map.refInstrumentPanelVM.NotifyPropertyChanged(NameOf(Map.refInstrumentPanelVM.OtStatistic_Visibility)) + Return True + End Function + + Private Function ExitONLYPRODPAGE(bVerifyModification As Boolean) As Boolean + ' verifico se progetto modificato, e chiedo se salvare + If bVerifyModification Then + If ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) = MessageBoxResult.Cancel Then + Return False + End If + End If + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + Map.refProjectVM.SetBottomPanel_Visibility(False) + Map.refProjectVM.SetLeftPanel_Visibility(True) + Map.refProjectVM.SetFeatureManager_Visibility(False) + Map.refProjectVM.SetTopPanel_Visibility(False) + Map.refProjectVM.SetShowBeamPanel_Visibility(False) + Map.refProjectVM.SetProjManager_Visibility(False) + Map.refProjectVM.SetProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdManager_Visibility(False) + Map.refProjectVM.SetOnlyProdLeftPanel_Visibility(False) + Map.refProjectVM.SetOnlyProdOptimizePanel_Visibility(False) + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Map.refCALCPanelVM.SetChooseMachine_Visibility(False) + EgtResetCurrMachGroup() + Return True + End Function + + Public Sub OpenPageFromSupervisor(Page As Pages) + If m_SelPage <> Page Then + m_nPageToOpen = Page + m_bOpenPage = True + End If + End Sub + + Public Sub OpenPage_Tick() + If Not m_bOpenPage Then Return + m_bOpenPage = False + ' apro la pagina + SelPage = m_nPageToOpen + m_nPageToOpen = Pages.MACHINING + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "Supervisor" + + Public ReadOnly Property Supervisor_Command As ICommand + Get + If m_cmdSupervisor Is Nothing Then + m_cmdSupervisor = New Command(AddressOf Supervisor) + End If + Return m_cmdSupervisor + End Get + End Property + + Public Sub Supervisor() + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + ' recupero processo del supervisore + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + If localProc.Length > 0 Then + For Each p As Process In localProc + ' porto in primo piano il Supervisor + BringWindowToFront(p.MainWindowHandle) + Exit For + Next + Else + Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" + Try + Process.Start(sSupervisorPath) + Catch ex As Exception + EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) + End Try + End If + End Sub + +#End Region ' Supervisor + +#Region "SendFeedbackCommand" + + ''' + ''' Returns a command that do SendFeedback. + ''' + Public ReadOnly Property SendFeedbackCommand As ICommand + Get + If m_cmdSendFeedback Is Nothing Then + m_cmdSendFeedback = New Command(AddressOf SendFeedback) + End If + Return m_cmdSendFeedback + End Get + End Property + + ''' + ''' Execute the SendFeedback. This method is invoked by the SendFeedbackCommand. + ''' + Public Sub SendFeedback(ByVal param As Object) + If (SelPage = Pages.MACHINING OrElse SelPage = Pages.ONLYPRODPAGE) AndAlso IsNothing(ProjectManagerVM.CurrProd) Then + MessageBox.Show(EgtMsg(61891), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' Recupero indirizzo a cui spedire la mail + Dim sSupportAddress As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_SUPPORT, "support@egaltech.com", sSupportAddress) + ' se vuoto do messaggio di errore ed esco + If String.IsNullOrWhiteSpace(sSupportAddress) Then + MessageBox.Show(EgtMsg(MSG_TOPCOMMANDBAR + 10), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' Recupero numero chiave + Dim sKey As String = String.Empty + EgtGetKeyInfo(sKey) + ' Esporto il progetto + Dim ProjFileMList As List(Of ProjFileM) + If (SelPage = Pages.MACHINING OrElse SelPage = Pages.ONLYPRODPAGE) And Not IsNothing(ProjectManagerVM.CurrProd) Then + ProjFileMList = DbControllers.m_ProjController.GetByProdAsc(ProjectManagerVM.CurrProd.nProdId) + Map.refProjManagerVM.SetCurrProj(ProjFileMList(0).nProjId) + End If + Dim sExportFileName = ProjectManagerVM.CurrProj.nProjId.ToString("0000") & " - " & ProjectManagerVM.CurrProj.sBTLFileName & " - ProjectExport" + Dim sExpZipToCreate = Map.refProjManagerVM.ExportProject(sExportFileName) + ' Creo zip file da allegare + Dim sZipToCreate As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\Feedback.zip" + If File.Exists(sZipToCreate) Then + File.Delete(sZipToCreate) + End If + Try + Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out) + ' aggiungo progetto esportato + If File.Exists(sExpZipToCreate) Then + zip.AddItem(sExpZipToCreate, "") + End If + ' aggiungo Prod e Proj associati + Dim ProdId As Integer + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + ProdId = ProjectManagerVM.CurrProj.nProdId + Case Pages.MACHINING, Pages.ONLYPRODPAGE + ProdId = ProjectManagerVM.CurrProd.nProdId + End Select + If ProdId = 0 Then + zip.AddItem(ProjectManagerVM.CurrProj.sProjDirPath, "Projs\" & ProjectManagerVM.CurrProj.nProjId.ToString("0000")) + Else + ProjFileMList = DbControllers.m_ProjController.GetByProdAsc(ProdId) + ' se piu' di uno + If IsNothing(ProjFileMList) Then + Return + ElseIf ProjFileMList.Count > 0 Then + Dim ProjFileVMList As New List(Of ProjectFileVM) + For Each Project In ProjFileMList + ProjFileVMList.Add(New ProjFileVM(Project)) + Next + For Each ProjFileVMItem In ProjFileVMList + zip.AddItem(ProjFileVMItem.sProjDirPath, "Projs\" & ProjFileVMItem.nProjId.ToString("0000")) + Next + zip.AddItem(ProjFileVMList(0).sProdDirPath, "Prods\" & ProjFileVMList(0).nProdId.ToString("0000")) + End If + End If + ' aggiungo cartella macchina del progetto + Dim sMachineDir As String = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & sMachineName + If Directory.Exists(sMachineDir) Then + zip.AddItem(sMachineDir, sMachineName) + End If + ' aggiungo file log + If File.Exists(Map.refMainWindowVM.MainWindowM.sLogFile) Then + zip.AddItem(Map.refMainWindowVM.MainWindowM.sLogFile, "") + End If + ' aggiungo file parametri P e Q + If File.Exists(BTLIniFile.m_sBTLIniFile) Then + zip.AddItem(BTLIniFile.m_sBTLIniFile, "") + End If + ' salvo lo zip + zip.Save() + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + End Try + ' preparo la mail per il supporto + Dim bEx As Boolean = False + Try + Dim sAddressArray As String() = sSupportAddress.Split(CType(",", Char())) + Dim SendFeedbackWindow As New EgtWPFLib5.MapiMailMessage("EgtBEAMWALL Feedback - " & sKey) + SendFeedbackWindow.Recipients.Add(sAddressArray(0)) + For index As Integer = 1 To sAddressArray.Length() - 1 + SendFeedbackWindow.Recipients.Add(sAddressArray(index), EgtWPFLib5.MapiMailMessage.RecipientType.CC) + Next + If Not String.IsNullOrWhiteSpace(sZipToCreate) AndAlso File.Exists(sZipToCreate) Then + SendFeedbackWindow.Files.Add(Map.refMainWindowVM.MainWindowM.sTempDir & "\Feedback.zip") + End If + SendFeedbackWindow.ShowDialog() + Catch ex As Exception + EgtOutLog("Feedback exception: " & ex.ToString) + bEx = True + End Try + If bEx OrElse EgtWPFLib5.MapiMailMessage.m_ErrorCode <> 0 Then + MessageBox.Show(String.Format(EgtMsg(MSG_TOPCOMMANDBAR + 12), sSupportAddress, sZipToCreate), EgtMsg(MSG_MESSAGEBOX + 3), MessageBoxButton.OK, MessageBoxImage.Information) + Else + Map.refMyStatusBarVM.SetOutputMessage(EgtMsg(30514)) + End If + End Sub + +#End Region ' SendFeedbackCommand + +#End Region ' COMMANDS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/MainMenu/OnlyProdMainMenuV.xaml b/EgtBEAMWALL.Optimizer/MainMenu/OnlyProdMainMenuV.xaml new file mode 100644 index 00000000..0f9975b3 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MainMenu/OnlyProdMainMenuV.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb new file mode 100644 index 00000000..544364c8 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -0,0 +1,1872 @@ +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports System.Windows.Threading + +Public Class OnlyProdManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + ' Nome file NGE con i pezzi selezionati per effettuare UpdateBTL + Friend Const UPDATEBTL_NGE As String = "UpdateBTL.nge" + + Private m_OpenProj_Timer As New DispatcherTimer + Private m_bOpenProj As Boolean = False + Private m_nProjIdToOpen As Integer = GDB_ID.NULL + + Private m_OnlyProdManager_IsEnabled As Boolean = True + Public ReadOnly Property OnlyProdManager_IsEnabled As Boolean + Get + Return m_OnlyProdManager_IsEnabled + End Get + End Property + Friend Sub SetOnlyProdManagerIsEnabled(bIsEnabled As Boolean) + m_OnlyProdManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(OnlyProdManager_IsEnabled)) + End Sub + + Friend Property CurrProj As ProjFileVM + Get + Return ProjectManagerVM.CurrProj + End Get + Set(value As ProjFileVM) + ProjectManagerVM.CurrProj = value + End Set + End Property + + Friend Property CurrProd As ProdFileVM + Get + Return ProjectManagerVM.CurrProd + End Get + Set(value As ProdFileVM) + ProjectManagerVM.CurrProd = value + End Set + End Property + + Private m_TempCurrProd As ProdFileVM + Friend Property TempCurrProd As ProdFileVM + Get + Return m_TempCurrProd + End Get + Set(value As ProdFileVM) + m_TempCurrProd = value + End Set + End Property + + Friend m_MruFiles As New MruList + Public ReadOnly Property MruFileNames As ObservableCollection(Of String) + Get + Dim IdAndBTLFileNames As New ObservableCollection(Of String) + For Each FileName In m_MruFiles.FileNames.ToList() + Dim PdId As Integer = 0 + Dim sPdId As String = Path.GetFileNameWithoutExtension(DirectCast(FileName, String).Replace("__", "_")) + Integer.TryParse(sPdId, PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + If IsNothing(PdFileM) Then + m_MruFiles.Remove(FileName) + Else + Dim PdFileVM = New ProdFileVM(PdFileM) + IdAndBTLFileNames.Add(sPdId & " | " & PdFileVM.sBTLFileName) + End If + Next + Return IdAndBTLFileNames + End Get + End Property + + Private m_GoToSupervisor_Visibility As Visibility + Public ReadOnly Property GoToSupervisor_Visibility As Visibility + Get + Return m_GoToSupervisor_Visibility + End Get + End Property + + Private m_UpdateBTL_Visibility As Visibility = Visibility.Collapsed + Public Property UpdateBTL_Visibility As Visibility + Get + Return m_UpdateBTL_Visibility + End Get + Set(value As Visibility) + m_UpdateBTL_Visibility = value + End Set + End Property + + Private m_AddProj_Visibility As Visibility + Public ReadOnly Property AddProj_Visibility As Visibility + Get + Return m_AddProj_Visibility + End Get + End Property + + ' indice ultimo progetto + Private m_nLastProdId As Integer + Friend ReadOnly Property nLastProdId As Integer + Get + Return m_nLastProdId + End Get + End Property + + Public ReadOnly Property nProjType As BWType + Get + Return If(Not IsNothing(CurrProj), CurrProj.nType, BWType.NULL) + End Get + End Property + + Public ReadOnly Property nProdType As BWType + Get + Return If(Not IsNothing(CurrProd), CurrProd.nType, BWType.NULL) + End Get + End Property + + ' Definizione comandi + Private m_cmdNew As ICommand + Private m_cmdOpen As ICommand + Private m_cmdOpenMruFile As ICommand + Private m_cmdSave As ICommand + Private m_cmdImportBTL As ICommand + Private m_cmdUpdateBTL As ICommand + Private m_cmdExportProject As ICommand + Private m_cmdImportProject As ICommand + Private m_cmdAddProj As ICommand + Private m_cmdGoToSupervisor As ICommand + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property NewToolTip As String + Get + Return EgtMsg(30501) + End Get + End Property + Public ReadOnly Property OpenToolTip As String + Get + Return EgtMsg(30502) + End Get + End Property + Public ReadOnly Property SaveToolTip As String + Get + Return EgtMsg(30503) + End Get + End Property + Public ReadOnly Property SaveAsToolTip As String + Get + Return EgtMsg(30504) + End Get + End Property + Public ReadOnly Property ImportBTL_ToolTip As String + Get + Return EgtMsg(61840) + End Get + End Property + Public ReadOnly Property UpdateBTL_ToolTip As String + Get + Return EgtMsg(61834) + End Get + End Property + Public ReadOnly Property ImportProject_ToolTip As String + Get + Return EgtMsg(61839) + End Get + End Property + Public ReadOnly Property ExportProject_ToolTip As String + Get + Return EgtMsg(61838) + End Get + End Property + Public ReadOnly Property GoToSupervisor_ToolTip As String + Get + Return EgtMsg(61974) + End Get + End Property + Public ReadOnly Property AddProj_ToolTip As String + Get + Return EgtMsg(61921) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Field & Properties + +#Region "CONSTRUCTORS" + + Sub New() + Map.SetRefOnlyProdManagerVM(Me) + ' Leggo ultimo indice di progetto + m_nLastProdId = GetMainPrivateProfileInt(S_GENERAL, K_PROJSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPROJFILES, 8) + ' leggo attivazione update btl + If GetMainPrivateProfileInt(S_GENERAL, K_UPDATEBTL, 0) > 0 Then UpdateBTL_Visibility = Visibility.Visible + + ' abilito passaggio a supervisore + If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR) Then + m_GoToSupervisor_Visibility = Visibility.Visible + Else + m_GoToSupervisor_Visibility = Visibility.Collapsed + End If + + ' attivo bottone AddProj + If GetMainPrivateProfileInt(S_GENERAL, K_ADDPROJ, 0) = 1 Then + m_AddProj_Visibility = Visibility.Visible + Else + m_AddProj_Visibility = Visibility.Collapsed + End If + + ' Leggo ultimo indice di progetto + m_nLastProdId = GetMainPrivateProfileInt(S_GENERAL, K_PRODSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPRODFILES, 8) + + ' imposto timer di apertura da ottimizzatore + m_OpenProj_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_OpenProj_Timer.Tick, AddressOf OpenProject_Tick + m_OpenProj_Timer.Start() + End Sub + +#End Region ' Constructors + +#Region "METHODS" + + Public Function SetCurrProj(nProjId As Integer) As Boolean + Return ProjectManagerVM.SetCurrProj(nProjId) + End Function + + Public Function UpdateCurrProj() As Boolean + Return SetCurrProj(CurrProj.nProjId) + End Function + + Private Function InitNewProj(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As Machine) As Boolean + ' se non ho ricevuto numero progetto da sovrascrivere + If nProjId = 0 Then + ' richiedo indice nuovo progetto + nProjId = DbControllers.m_ProjController.GetNextIndex(Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + ' salvo data creazione progetto + DbControllers.m_ProjController.Update(New ProjModel() With {.ProjId = nProjId, + .DtCreated = DateTime.Now(), + .PType = nType, + .Machine = If(Not IsNothing(Machine), Machine.Name, Nothing)}) + If nProjId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjectDir) Then + Directory.CreateDirectory(sProjectDir) + Else + Dim di As New DirectoryInfo(sProjectDir) + For Each file As FileInfo In di.EnumerateFiles() + file.Delete() + Next + For Each dir As DirectoryInfo In di.EnumerateDirectories() + dir.Delete(True) + Next + End If + Return True + End Function + + Friend Function InitNewProd(ByRef nProjId As Integer, ByRef nProdId As Integer, ByRef sProjectDir As String) As Boolean + ' richiedo indice nuovo progetto + nProdId = DbControllers.m_ProdController.GetNextIndex(nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + If nProdId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjectDir) Then + Directory.CreateDirectory(sProjectDir) + Else + Dim di As New DirectoryInfo(sProjectDir) + For Each file As FileInfo In di.EnumerateFiles() + file.Delete() + Next + For Each dir As DirectoryInfo In di.EnumerateDirectories() + dir.Delete(True) + Next + End If + Return True + End Function + + Private Sub ReloadBTLStructure() + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(CurrProj.nProjId)) + ' verifico se volume pezzi calcolato + Dim bIsCalculated As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If BTLPart.BTLPartM.dVolume > 0 Then Continue For + bIsCalculated = True + BTLPart.CalcBTLPartVolume() + Next + If bIsCalculated Then + Dim CurrProject As String = "" + EgtGetCurrFilePath(CurrProject) + EgtSaveFile(CurrProject, NGE.CMPTEXT) + End If + End Sub + + Public Function SetCurrProd(nProdId As Integer) As Boolean + Return ProjectManagerVM.SetCurrProd(nProdId) + End Function + + Public Sub OpenProject_Tick() + If Not m_bOpenProj Then Return + m_bOpenProj = False + + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' recupero progetto da Id + Dim DbProject As ProdFileM + DbProject = DbControllers.m_ProdController.FindCoreByProdId(m_nProjIdToOpen) + Dim ProjectVM As New ProdFileVM(DbProject) + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.CurrProj, ProjectType.PROJ) Then Return + OpenProject(ProjectVM) + End If + m_nProjIdToOpen = GDB_ID.NULL + End Sub + + Private Sub NewProdFromProj() + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + InitNewProd(CurrProj.nProjId, nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, CurrProj.sMachine) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim bOk = False + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If bOk Then + ' aggiorno path proj + UpdateCurrProj() + ' imposto currprod + SetCurrProd(nProdId) + ' imposto TempCurrProd + TempCurrProd = CurrProd + ' setto flag nuovo progetto in prod + CurrProd.bIsNew = True + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' riapro progetto prod + OpenProject(TempCurrProd) + End Sub + + Private Sub ManageImportLog(nProjId As Integer, sProjDir As String) + Dim LogFile As New List(Of String) + Using FileStream As New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) + Dim StreamReader As New StreamReader(FileStream) + Dim Line As String = StreamReader.ReadLine() + While Not StreamReader.EndOfStream + Line = StreamReader.ReadLine() + LogFile.Add(Line) + End While + StreamReader.Close() + End Using + If LogFile.Count > 0 Then + ' recupero ultima occorrenza di import + Dim sLastImport As String = LogFile.LastOrDefault(Function(x) x.Contains("ImportBtl")) + ' verifico linee successive + Dim nLastImportIndex As Integer = -1 + If Not String.IsNullOrWhiteSpace(sLastImport) Then + nLastImportIndex = LogFile.IndexOf(sLastImport) + End If + Dim sImportMessage As String = sLastImport & Environment.NewLine + Dim sImportLog As New List(Of String)({sLastImport}) + If nLastImportIndex > 0 Then + Dim bGlobalError As Boolean = False + ' ciclo sulle righe successive + For Index = nLastImportIndex + 1 To LogFile.Count - 1 + Dim sLogLine As String = LogFile(Index).Trim() + ' verifico se fanno parte dell'import + Dim bStartWithError As Boolean = sLogLine.StartsWith("Error") + Dim bStartWithInfo As Boolean = sLogLine.StartsWith("Info") + If Not bStartWithError And Not bStartWithInfo Then Exit For + If bStartWithError Then + If Not bGlobalError Then bGlobalError = True + sImportMessage &= sLogLine & Environment.NewLine + End If + sImportLog.Add(sLogLine) + Next + ' salvo file ImportLog nel progetto + Try + File.WriteAllLines(sProjDir & "\" & nProjId.ToString("0000") & "-ImportLog.txt", sImportLog) + Catch ex As Exception + ' + End Try + ' se almeno un errore, mostro log + If bGlobalError Then + MessageBox.Show(Application.Current.MainWindow, sImportMessage, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If + End If + End If + End Sub + + Public Sub OpenOnlyProjectFromSupervisor(ProjIdToOpen As Integer) + If Not IsNothing(ProjectManagerVM.CurrProd) Then + m_nProjIdToOpen = ProjIdToOpen + m_bOpenProj = True + End If + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "New" + + ''' + ''' Returns a command that do New. + ''' + Public ReadOnly Property New_Command As ICommand + Get + If m_cmdNew Is Nothing Then + m_cmdNew = New Command(AddressOf NewProject) + End If + Return m_cmdNew + End Get + End Property + + ''' + ''' Execute the New. This method is invoked by the NewCommand. + ''' + Public Sub NewProject() + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + ' se si ha una sola macchina disponibile (non BOTH) setto il nuovo porgetto a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il nuovo progetto + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New OnlyProdProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + ' creo nuovo progetto + If Map.refSceneHostVM.MainController.NewProject() Then + ' inizializzo nuovo progetto PROJ + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + InitNewProj(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nProjId + ' creo gruppo BTLinfo + Dim nBTLInfoLayer As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nBTLInfoLayer, BTLINFO) + EgtSetLevel(nBTLInfoLayer, GDB_LV.SYSTEM) + Map.refProjectVM.BTLStructureVM.BTLStructureM.UpdateBTLInfoLayer() + ' scrivo info proj e tipo su layer BtlInfo + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, nProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, nType) + ' salvo il progetto + If EgtSaveFile(sProjFileName, NGE.CMPTEXT) Then + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + Map.refPartManagerVM.LockVisibilityUpdate() + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + DbControllers.m_ProjController.UpdateInfo(nProjId, "Hand made", "Hand made", "", Date.MinValue, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + End If + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + ' inizializzo nuovo progetto PROD + NewProdFromProj() + Else + MessageBox.Show(EgtMsg(61876)) + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + End Sub + +#End Region ' New + +#Region "OpenCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenCommand As ICommand + Get + If m_cmdOpen Is Nothing Then + m_cmdOpen = New Command(AddressOf Open) + End If + Return m_cmdOpen + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Open() + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + OpenProject(Nothing) + End Sub + + Friend Sub OpenProject(TempCurrPd As ProdFileVM) + m_TempCurrProd = TempCurrPd + Dim sFilePath As String = "" + ' se la string è vuota + If IsNothing(TempCurrProd) Then + If GetMainPrivateProfileInt(S_GENERAL, K_PROJECTMODE, 0) = 1 Then + Dim OpenProdFileDialogVM As NewOpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta Prod + OpenProdFileDialogVM = New NewOpenProjectFileDialogVM + Dim OpenFile As New OnlyProdNewOpenProjectFileDialogV(Application.Current.MainWindow, OpenProdFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProdFileDialogVM.SelProject.ProdFileVM.sProdPath + m_TempCurrProd = OpenProdFileDialogVM.SelProject.ProdFileVM + Else + Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta file + OpenProjectFileDialogVM = New OpenProjectFileDialogVM + Dim OpenFile As New OnlyProdOpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProjectFileDialogVM.SelProject.sProdPath + TempCurrProd = OpenProjectFileDialogVM.SelProject + End If + Else + sFilePath = If(Not IsNothing(TempCurrProd.sProdPath), TempCurrProd.sProdPath, "") + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.OPENPROD, 3, EgtMsg(63004), EgtMsg(63001), 50) ' Optimization opening ' Loading project geometries + If File.Exists(sFilePath) Then + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = TempCurrProd.sMachine)) Then + ' rimuovo il file in apertura dalla lista degli MRU + m_MruFiles.Remove(sFilePath) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + NewProject() + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + Else + If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + Map.refProjectVM.SetOptimizePanel_Visibility(True) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.UpdateQParameterVisibility() + End If + End If + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(TempCurrProd.nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + MessageBox.Show(EgtMsg(61871)) + Map.refSceneHostVM.MainController.NewProject() + Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL") + End If + ' aggiorno lista possibili nesting + Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) + ' aggiorno visibilità bottone Muovi pezzi + Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility() + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + ' mostro tutti i pezzi + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.MachGroupVMList) AndAlso Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count <= 0 Then Map.refShowBeamPanelVM.ShowAll(True) + NotifyPropertyChanged(NameOf(MruFileNames)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.OPENPROD) + End Sub + +#End Region ' OpenCommand + +#Region "OpenMruFileCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenMruFileCommand As ICommand + Get + If m_cmdOpenMruFile Is Nothing Then + m_cmdOpenMruFile = New Command(AddressOf OpenMruFile) + End If + Return m_cmdOpenMruFile + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Public Sub OpenMruFile(ByVal param As Object) + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + ' ricavo l'Id e il progetto associato per l'apertura di quest'ultimo + Dim PdId As Integer = 0 + Dim arrStrPdId As String() = DirectCast(param, String).Split("|") + Integer.TryParse(arrStrPdId(0), PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + Dim PdFileVM = New ProdFileVM(PdFileM) + OpenProject(PdFileVM) + End Sub + +#End Region ' OpenMruFileCommand + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf SaveCmd) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub SaveCmd() + Save(True) + End Sub + + Public Function Save(Optional bShowLoading As Boolean = False) As Boolean + If IsNothing(CurrProd) Then Return False + If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63007), EgtMsg(63012), 70) ' Project saving ' Saving geometry + Dim bOk As Boolean = Map.refSceneHostVM.SaveProject() + If bShowLoading Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63013), 70, 100) ' Saving data on Db + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + If Not DbControllers.m_ProdController.UpdateMachGroup(CurrProd.nProdId, MyMachGroupList) And bShowLoading Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return False + End If + ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj + If Map.refCALCPanelVM.IsMachineModified() Then + DbControllers.m_ProdController.UpdateMachine(CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) + CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + ' ciclo sulla lista di ProjId associati + For Each ProjId In CurrProd.nProjIdList + ' aggiorno la Macchina per i ProjId associati sul DB + DbControllers.m_ProjController.UpdateMachine(ProjId, Map.refCALCPanelVM.SelectedMachine.Name) + ' se uno dei Proj interessati equivale al Proj correntemente aperto setto la Macchina dello stesso + ' (poichè il progetto corrente non viene riaperto e riletto dal DB) + If ProjId = CurrProj.nProjId Then CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + Next + Map.refCALCPanelVM.ResetMachineModified() + End If + ' se nuovo progetto + If CurrProd.bIsNew Then + ' resetto stato new + CurrProd.bIsNew = False + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + If bShowLoading Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return bOk + End Function + +#End Region ' SaveCommand + +#Region "ImportBTL" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportBTL_Command As ICommand + Get + If m_cmdImportBTL Is Nothing Then + m_cmdImportBTL = New Command(AddressOf ImportBTL) + End If + Return m_cmdImportBTL + End Get + End Property + + ''' + ''' Execute the ImportBTL. This method is invoked by the ImportBTLCommand. + ''' + Public Sub ImportBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + Return + End If + End If + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + ' verifico se non e' tra i BTL gia' importati + Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sFile) + Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(sBTLFileName) + If nAlreadyImported > 0 Then + ' recupero progetto con lo stesso nome + Dim ToDeleteProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nAlreadyImported) + ' se esiste gia' un'ottimizzazione + If ToDeleteProj.nProdId > 0 Then + Select Case MessageBox.Show(EgtMsg(61942), "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) ' BTL file already imported and optimized. Do you want to import it again? + Case MessageBoxResult.Yes + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.No + Return + End Select + Else + ' se non ha ottimizazione, chiedo se sovrascriverlo + Select Case MessageBox.Show(EgtMsg(61943), "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' BTL file already imported. Do you want to overwrite it? + Case MessageBoxResult.Yes + ' cancello BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nAlreadyImported, New List(Of BTLPartM)) + ' cancello nome BTL + DbControllers.m_ProjController.UpdateInfo(nAlreadyImported, DateTime.Now.ToString(), DateTime.Now.ToString(), "", DateTime.MinValue, BWType.NULL, "") + nProjId = nAlreadyImported + sProjDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + Case MessageBoxResult.No + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.Cancel + Return + End Select + End If + End If + ' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New OnlyProdProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' inizializzo nuovo progetto + InitNewProj(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' imposto il tipo di parametri Q da utilizzare + BTLIniFile.m_nBTLBWType = nType + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nProjId + ' copio file BTL + Dim sBtlCopyPath As String = sProjDir & "\" & Path.GetFileName(sFile) + Dim bOk = False + Try + File.Copy(sFile, sBtlCopyPath, True) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + ' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione + Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False + ' importo file + If bOk Then + bOk = Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) + End If + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk OrElse bFirstPart Then + ' salvo path di importazione + WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile)) + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + EgtOutLog("Errore nell'importazione BTL") + End If + If bOk Then + ' aggiorno Db + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + Next + End If + ' calcolo volumi pezzi + For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Part.CalcBTLPartVolume() + Next + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refPartManagerVM.LockVisibilityUpdate() + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + Else + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' elimino da Db + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nProjId, False) + End If + If bOk Then + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) + ' inizializzo nuovo progetto PROD + NewProdFromProj() + End If + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + ' gestisco log di importazione + ManageImportLog(nProjId, sProjDir) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + End Sub + +#End Region ' ImportBTL + +#Region "UpdateBTL" + + ''' + ''' Returns a command that do UpdateBTL. + ''' + Public ReadOnly Property UpdateBTL_Command As ICommand + Get + If m_cmdUpdateBTL Is Nothing Then + m_cmdUpdateBTL = New Command(AddressOf UpdateBTL) + End If + Return m_cmdUpdateBTL + End Get + End Property + + ''' + ''' Execute the UpdateBTL. This method is invoked by the UpdateBTLCommand. + ''' + Public Sub UpdateBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If IsNothing(CurrProd) Then Return + ' verifico se progetto modificato, e chiedo se salvare + If CurrProd.bIsNew Or EgtGetModified() OrElse Map.refCALCPanelVM.IsMachineModified() Then + Select Case MessageBox.Show(EgtMsg(61877), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Case MessageBoxResult.Yes + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + MessageBox.Show(EgtMsg(61892), "", MessageBoxButton.OK, MessageBoxImage.Exclamation) + Return + End Select + End If + + ' se vista tutti i pezzi + Dim bShowBuilding As Boolean = False + Dim bShowSolid As Boolean = False + Dim nSelPartId As Integer = GDB_ID.NULL + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, nSelPartId, True, True) + + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + End If + ' salvo lista pezzi del progetto originale + Dim OrigPartlist As ObservableCollection(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' creo un nuovo contesto su cui aprire il file BTL + Dim nCurrCtx As Integer = EgtGetCurrentContext() + Dim nTempCtx As Integer = EgtInitContext() + + ' setto il flag per inizializzazione gestore travi e pareti per importare progetto + Dim nFlag As Integer + Dim sBTLFlag As String + If nProdType = Core.ConstBeam.BWType.BEAM Then + sBTLFlag = K_BTLFLAG + Else + sBTLFlag = K_WALLBTLFLAG + End If + nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + + ' inizializzo gestore travi e pareti + EgtInitBeamMgr(nFlag) + + Dim bOk As Boolean = nTempCtx <> 0 + If bOk Then + ' importo il file BTL + bOk = bOk AndAlso Map.refSceneHostVM.MainController.ImportProject(sFile, False) + ' carico la lista dei Part importati e rimuovo i parametri generali del BTL + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + Dim BtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim PartToUpdateList As New List(Of BTLPartToUpdate) + + ' cerco tra i layer BTLInfo + While BtlInfoId <> GDB_ID.NULL + ' verifico se il layer appartiene al ProjId + Dim nBTLInfoLayerProjId As Integer + EgtGetInfo(BtlInfoId, BTL_PRT_PROJ, nBTLInfoLayerProjId) + ' carico la lista con i PDN dei pezzi del BTL importato + Dim nPDN As Integer = 0 + Dim sNAM As String = String.Empty + Dim nUID As Integer = 0 + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + Dim UIDList As New List(Of Integer) + Dim nIndUID As Integer = 1 + ' se devo filtrare un progetto + If nBTLInfoLayerProjId > 0 Then + ' verifico se il pezzo appartiene al ProjId + Dim nPartProjId As Integer + EgtGetInfo(nPartId, BTL_PRT_PROJ, nPartProjId) + If nPartProjId = nBTLInfoLayerProjId Then + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nIndUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + Else + ' altrimenti carico tutti + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + nPartId = EgtGetNextPart(nPartId) + End While + EgtErase(BtlInfoId) + BtlInfoId = EgtGetNextName(BtlInfoId, BTLINFO) + End While + + ' costruisco un dizionario con gli id dei sottonodi di AsseBase del BTL importato e il valore dell'Info N degli stessi + Dim AsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + Dim nAsseBaseSubNodeId As Integer = EgtGetFirstInGroup(AsseBaseId) + Dim sAsseBaseUID As String = String.Empty + Dim nAsseBaseUID As Integer = 0 + While nAsseBaseSubNodeId <> GDB_ID.NULL + If EgtGetInfo(nAsseBaseSubNodeId, BTL_ASSEBASE_N, sAsseBaseUID) Then + sAsseBaseUID = sAsseBaseUID.Remove(0, 4) + Integer.TryParse(sAsseBaseUID, nAsseBaseUID) + AsseBaseSubNodeDict.Add(nAsseBaseSubNodeId, sAsseBaseUID) + End If + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End While + + ' salvo il file BTL da cui abbiamo rimosso BtlInfo come file NGE + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + Dim bAppend As Boolean = False + ' se UserLevel > 5 e fra i Part importati ce ne sta almeno 1 con PDN uguale ai Part già presenti + ' apro la finestra per chiedere se si vuole aggiornare o accodare + If Map.refMainWindowVM.MainWindowM.nUserLevel > 5 Then + For Each PartToUpdate In PartToUpdateList + Dim bExitFor As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList + If PartToUpdate.nPDN = BTLPart.nPDN Then + Dim UpdateOrAppendWndVM As New UpdateOrAppendWndVM() + Dim UpdateOrAppendWnd As New OnlyProdUpdateOrAppendWndV(Application.Current.MainWindow, UpdateOrAppendWndVM) + If Not UpdateOrAppendWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + 'SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + ' salvo lo stato del bottone per accodare + bAppend = UpdateOrAppendWndVM.AppendIsChecked + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + End If + + ' se selezionato Append li accodo tutti + If bAppend Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto iniziale + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = 0 + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) + b3Parts.Add(b3Part) + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' inserisco il file importato nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId) + Dim bFirstLoop As Boolean = True + Dim LastPartMaxY As Double + Dim nIncrPDN As Integer = 0 + While nAddedPartId <> GDB_ID.NULL + ' incremento il PDN del Part aggiunto rispetto al PDN maggiore attualmente presente + EgtSetInfo(nAddedPartId, BTL_PRT_PDN, Map.refProjectVM.BTLStructureVM.BTLStructureM.NewPDN() + nIncrPDN) + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, If(bFirstLoop, b3Parts.Max.y, LastPartMaxY - b3Part.Min.y) + 500, 0)) + bFirstLoop = False + ' ricaviamo il box globale del part appena spostato, salviamo la sua Y massima e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + LastPartMaxY = b3Part.Max.y + b3Parts.Add(b3Part) + nAddedPartId = EgtGetNextPart(nAddedPartId) + nIncrPDN += 1 + End While + ' aggiungo i part inseriti alla lista + Dim nNewPartId As Integer = EgtGetNextPart(nLastProjPartId) + While nNewPartId <> GDB_ID.NULL + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nNewPartId = EgtGetNextPart(nNewPartId) + End While + + ' elimino gli AsseBase del progetto importato + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim CurrAsseBaseId = AsseBaseId + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + If Not AsseBaseIdList.Contains(CurrAsseBaseId) Then EgtErase(CurrAsseBaseId) + End While + + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + Else + ' altrimenti apro la finestra con l'elenco dei Part da checkare per l'inserimento nel progetto (unica strada se UserLevel <= 5), + ' che prevederà la sovrascrittura di quelli già presenti e l'aggiunta di quelli nuovi + Dim UpdateBTLWndVM As New UpdateBTLWndVM(PartToUpdateList) + Dim UpdateBTLWnd As New OnlyProdUpdateBTLWndV(Application.Current.MainWindow, UpdateBTLWndVM) + If Not UpdateBTLWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + 'SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + If UpdateBTLWndVM.BTLPartList.Count > 0 Then + ' sovrascrivo i Part nel progetto aperto con i Part checkati nella lista + Dim BTLPartToOverwriteWithList As New ObservableCollection(Of BTLPartToUpdate) + ' Elimino dal TempCtx i Part non checkati + For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList + If BTLPartToOverwriteWith.bInsert Then + BTLPartToOverwriteWithList.Add(BTLPartToOverwriteWith) + Else + ' elimino pezzo copia + Dim nCurrPartId = EgtGetCurrPart() + EgtErase(BTLPartToOverwriteWith.nPartId) + nCurrPartId = EgtGetCurrPart() + End If + Next + + ' costruisco un nuovo dizionario dei sottonodi di AsseBase contenente solo quelli corrispondenti agli UID contenuti + ' nei soli Part checkati del BTL nella finestra UpdateBTLWnd + Dim NewAsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + For Each BTLPartToOverwriteWithItem In BTLPartToOverwriteWithList + Dim bExitFor As Boolean = False + For Each UIDItem In BTLPartToOverwriteWithItem.UIDList + If AsseBaseSubNodeItem.Value = UIDItem Then + NewAsseBaseSubNodeDict.Add(AsseBaseSubNodeItem.Key, AsseBaseSubNodeItem.Value) + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + Next + ' confronto la lista appena costruita con quella originale ed elimino dal contesto i sottonodi con i valori non più presenti + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + If Not NewAsseBaseSubNodeDict.ContainsValue(AsseBaseSubNodeItem.Value) Then + EgtErase(AsseBaseSubNodeItem.Key) + End If + Next + + ' salvo il file NGE inserito a cui abbiamo rimosso i Part non checkati e gli AsseBase non più associati + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + ' torno sul contesto corrente + EgtDeleteContext(nTempCtx) + EgtSetCurrentContext(nCurrCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' elimino i pezzi da sovrascrivere nel progetto corrente + Configuration.DeletePieces(UpdateBTLWndVM.BTLPartList) + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + ' elimino i sottonodi di AsseBase da sovrascrivere + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + nAsseBaseSubNodeId = EgtGetFirstInGroup(AsseBaseId) + While nAsseBaseSubNodeId <> GDB_ID.NULL + If NewAsseBaseSubNodeDict.ContainsKey(nAsseBaseSubNodeId) Then + ' se sottonodo da cancellare salvo il suo id e ricavo il seguente prima di cancellarlo + Dim nCurrAsseBaseSubNodeId = nAsseBaseSubNodeId + nAsseBaseSubNodeId = EgtGetNext(nCurrAsseBaseSubNodeId) + bOk = EgtErase(nCurrAsseBaseSubNodeId) + Else + ' altrimenti ricavo il seguente e basta + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End If + End While + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto corrente + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = GDB_ID.NULL + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + If EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) Then + b3Parts.Add(b3Part) + End If + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' se sovrascrivo tutti e bbox esce nullo + If b3Parts.IsEmpty Then + b3Parts = New BBox3d(Point3d.ORIG) + End If + + ' inserisco il file NGE (ricavato dal BTL importato) nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + + ' ciclo su tutti gli AsseBase del progetto corrente + Dim nAsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While nAsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProjId As Integer + Dim nAsseBaseToEraseId As Integer = 0 + EgtGetInfo(nAsseBaseId, BTL_PRT_PROJ, nAsseBaseProjId) + ' se AsseBase di questo step del ciclo è nuovo e suo ProjId uguale a quello del progetto corrente + If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = CurrProd.nProdId Then + ' riloco i sottonodi del nuovo AsseBase nell'AsseBase del progetto aperto col medesimo ProjId + Dim AsseBaseSubNodeId As Integer = EgtGetFirstInGroup(nAsseBaseId) + While AsseBaseSubNodeId <> GDB_ID.NULL + ' ciclo su tutti gli AsseBase per trovare l'id di quello con ProjId uguale al progetto corrente + Dim FindAsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While FindAsseBaseId <> GDB_ID.NULL + Dim SameAsseBaseProjId As Integer + EgtGetInfo(FindAsseBaseId, BTL_PRT_PROJ, SameAsseBaseProjId) + ' se l'ho trovato esco dal While (FindAsseBaseId è l'id dell'AsseBase in cui vogliamo rilocare i sottonodi) + If SameAsseBaseProjId = CurrProd.nProdId Then Exit While + FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE) + End While + ' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo + Dim CurrAsseBaseSubNodeId = AsseBaseSubNodeId + AsseBaseSubNodeId = EgtGetNext(CurrAsseBaseSubNodeId) + bOk = bOk AndAlso EgtRelocate(CurrAsseBaseSubNodeId, FindAsseBaseId, GDB_POS.LAST_SON) + End While + ' salvo id dell'AsseBase per cancellarlo + nAsseBaseToEraseId = nAsseBaseId + End If + ' ricavo id del prossimo AsseBase + nAsseBaseId = EgtGetNextName(nAsseBaseId, ASSEBASE) + ' se salvato id dell'AsseBase per cancellarlo lo cancello + If nAsseBaseToEraseId <> 0 Then bOk = bOk AndAlso EgtErase(nAsseBaseToEraseId) + End While + + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = If(nLastProjPartId <> GDB_ID.NULL, EgtGetNextPart(nLastProjPartId), EgtGetFirstPart()) + Dim LastPartMaxY As Double + While nAddedPartId <> GDB_ID.NULL + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto e ruotato + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' salviamo la Y massima del box globale di tutti i part + LastPartMaxY = b3Parts.Max.y + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, LastPartMaxY - b3Part.Min.y + 500, 0)) + ' ricaviamo il box globale del part appena spostato e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + b3Parts.Add(b3Part) + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nAddedPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + AddedBTLPart.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + End If + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nAddedPartId = EgtGetNextPart(nAddedPartId) + End While + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + End If + End If + ' copio il file originale scelto nel dialog per l'Update nella cartella Proj del progetto corrente + If File.Exists(sFile) Then + 'Dim sDestPath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + Dim sDestPath As String = CurrProd.sProdDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + While File.Exists(sDestPath & ".btl") + sDestPath &= "_1" + End While + File.Copy(sFile, sDestPath & ".btl", False) + End If + End If + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + End Sub + +#End Region ' UpdateBTL + +#Region "ExportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ExportProject_Command As ICommand + Get + If m_cmdExportProject Is Nothing Then + m_cmdExportProject = New Command(AddressOf ExportProject) + End If + Return m_cmdExportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Function ExportProject(Optional sExportFileName As String = Nothing) As String + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return Nothing + If IsNothing(CurrProj) Then Return Nothing + Case Pages.MACHINING + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(CurrProd) Then Return Nothing + Case Pages.ONLYPRODPAGE + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(CurrProd) Then Return Nothing + Case Else + Return Nothing + End Select + + ' apro finestra di salvataggio progetto + Dim ExportDlg As New Microsoft.Win32.SaveFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .FileName = CurrProd.nProdId.ToString("0000") & " - " & CurrProd.sBTLFileName & " - ProjectExport"} + If IsNothing(sExportFileName) Then + 'If ExportDlg.ShowDialog() <> True Then Return Nothing + If ExportDlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Return Nothing + End If + + LoadingWndHelper.OpenLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63010), EgtMsg(63016), 30) ' Project exporting ' Adding export info + ' se assemblato me lo segno e lo smonto + Dim bShowBuilding As Boolean = False + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Configuration.ShowAllPieces(bShowBuilding) + End If + + ' per ogni BTLInfo nel progetto riporto il relativo nome del BTL + Dim nBTLInfoProjId As Integer + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, nBTLInfoProjId) + If nBTLInfoProjId > 0 Then + ' recupero il BTL file name di questo proj + Dim BTLFileNameProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nBTLInfoProjId) + If Not IsNothing(BTLFileNameProj) Then + EgtSetInfo(nBTLInfoLayerId, BTLFILENAME, BTLFileNameProj.sBTLFileName) + End If + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + ' aggiungo layer per info di export + Dim nImpExpPartId As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nImpExpPartId, EXP_PART) + ' ci scrivo nome macchina e tipo progetto + EgtSetInfo(nImpExpPartId, EXP_MACHINE, CurrProd.sMachine) + EgtSetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, CurrProd.nType) + + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63017), 30, 100) ' Exporting... + ' salvo info inserite + Map.refSceneHostVM.SaveProject() + ' creo file zip + Dim sZipToCreate As String = If(IsNothing(sExportFileName), ExportDlg.FileName, Map.refMainWindowVM.MainWindowM.sTempDir & "\" & sExportFileName & ".ngexp") + If File.Exists(sZipToCreate) Then + File.Delete(sZipToCreate) + End If + Try + Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out) + ' impacchetto tutta la cartella del progetto + Dim sProjectDirPath As String = If(CurrProd.nProdId > 0, CurrProd.sProdDirPath, CurrProd.sProjDirPath) + For Each sFile As String In Directory.GetFiles(sProjectDirPath) + zip.AddItem(sFile, "") + Next + ' salvo lo zip + zip.Save() + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Error in export file creation!") + End Try + ' elimino layer di esportazione + EgtErase(nImpExpPartId) + ' salvo eliminazione info inserite + Map.refSceneHostVM.SaveProject() + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.EXPORTPROJECT) + Return sZipToCreate + End Function + +#End Region ' ExportProject + +#Region "ImportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportProject_Command As ICommand + Get + If m_cmdImportProject Is Nothing Then + m_cmdImportProject = New Command(AddressOf ImportProject) + End If + Return m_cmdImportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Sub ImportProject() + Dim TempCurrProd As ProjectFileVM = CurrProd + ' lista di tutti gli errori riscontrati + Dim ErrorList As New List(Of String) + 'If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + If ProdFileVM.VerifyProjectModification(TempCurrProd) Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, "", sDir) + ' apro finestra scelta file + Dim ImportDlg As New Microsoft.Win32.OpenFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If ImportDlg.ShowDialog() <> True Then Return + ' creo cartella temporanea di estrazione in Temp + Dim sProjectimportDir As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\ProjectImport" + If Directory.Exists(sProjectimportDir) Then + Directory.Delete(sProjectimportDir, True) + End If + Directory.CreateDirectory(sProjectimportDir) + Try + Using zip As New Ionic.Zip.ZipFile(ImportDlg.FileName, Console.Out) + ' estraggo file da zip + zip.ExtractAll(sProjectimportDir) + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Impossibile importare file", "Errore") + Return + End Try + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63018), EgtMsg(63019), 30) ' Project importing ' Loading project + ' carico progetto + Dim sProjFromPath() As String = Directory.GetFiles(sProjectimportDir, "*.nge") + Dim bOk = EgtOpenFile(sProjFromPath(0)) + If Not bOk Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile aprire il file", "Errore") + Return + End If + ' recupero e verifico se ho a disposizione la macchina con cui e' stato creato il progetto + Dim nImpExpPartId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EXP_PART) + Dim sMachine As String = "" + EgtGetInfo(nImpExpPartId, EXP_MACHINE, sMachine) + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine)) Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + Dim Machine As Machine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine) + Dim nType As Integer = BWType.NULL + EgtGetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, nType) + If IsNothing(Machine) OrElse nType = BWType.NULL Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + ' elimino part di esportazione + EgtErase(nImpExpPartId) + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63020), 30, 100) ' Creating imported project + ' leggo proj e prod presenti dai layer BTLInfo + Dim ImportProjIdList As New List(Of Integer) + Dim NewProjIdList As New List(Of Integer) + Dim BTLInfoIdList As New List(Of Integer) + Dim BTLFileNameList As New List(Of String) + Dim CurrImportProjId As Integer + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, CurrImportProjId) + If CurrImportProjId > 0 Then + ImportProjIdList.Add(CurrImportProjId) + BTLInfoIdList.Add(nBTLInfoLayerId) + ' recupero nome file BTL Associato + Dim sBTLFileName As String = "" + EgtGetInfo(nBTLInfoLayerId, BTLFILENAME, sBTLFileName) + BTLFileNameList.Add(sBTLFileName) + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + If Not ImportProjIdList.Count > 0 Then + MessageBox.Show("Nessun progetto trovato all'interno del file importato", "Errore") + End If + ' carico i proj + For nProjIndex = 0 To ImportProjIdList.Count - 1 + Dim nImportProjId As Integer = ImportProjIdList(nProjIndex) + ' inizializzo nuovo proj + Dim nNewProjId As Integer = 0 + Dim sNewProjDir As String = "" + InitNewProj(nNewProjId, sNewProjDir, nType, Machine) + NewProjIdList.Add(nNewProjId) + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nImportProjId + ' costruisco BTLStructure del proj + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(nImportProjId)) + ' scrivo info proj su tutti i pezzi di questo progetto + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + EgtSetInfo(BTLPart.nPartId, BTL_PRT_PROJ, nNewProjId) + Next + ' cambio indicazione proj in gruppo di assemblaggio + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProj As Integer = 0 + EgtGetInfo(AsseBaseId, BTL_PRT_PROJ, nAsseBaseProj) + If nAsseBaseProj = nImportProjId Then + EgtSetInfo(AsseBaseId, BTL_PRT_PROJ, NewProjIdList(nProjIndex)) + Exit While + End If + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + ' riporto nuovo ProjId nel layer BTLInfo + EgtSetInfo(BTLInfoIdList(nProjIndex), BTL_PRT_PROJ, nNewProjId) + ' resetto tutti gli stati di CALC + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + BTLPart.ResetCalcTotalPart() + Next + ' salvo modifiche fatte al progetto + bOk = bOk AndAlso Map.refSceneHostVM.MainController.SaveProject() + If bOk Then + ' copio file BTL e progetto + Dim sBTLFromPath As String = sProjectimportDir & "\" & BTLFileNameList(nProjIndex) & ".btl" + Dim sProjFileName As String = sNewProjDir & "\" & nNewProjId.ToString("0000") & ".nge" + If sProjFromPath.Count > 0 AndAlso Not String.IsNullOrWhiteSpace(sProjFromPath(0)) Then + Try + If Not String.IsNullOrWhiteSpace(sBTLFromPath) AndAlso File.Exists(sBTLFromPath) Then + Dim sBtlToPath As String = sNewProjDir & "\" & Path.GetFileName(sBTLFromPath) + File.Copy(sBTLFromPath, sBtlToPath) + Else + ErrorList.Add(String.Format("File BTL del progetto {0} non trovato", nImportProjId)) + End If + File.Copy(sProjFromPath(0), sProjFileName) + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile copiare il file del progetto", "Errore") + Return + End Try + End If + ' aggiorno Db + Dim sBTLFileName As String = BTLFileNameList(nProjIndex) + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nNewProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Machine.Name) + Else + ' elimino da Db + + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nNewProjId, False) + End If + ' aggiorno BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nNewProjId, Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList) + ' resetto stato new + DbControllers.m_ProjController.ResetNew(nNewProjId) + ' resetto lock + DbControllers.m_ProjController.LockByProjId(nNewProjId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + DbControllers.m_ProjController.ResetController() + Next + ' se tutte le operazioni precedenti sono andate a buon fine + If bOk Then + ' sostituisco indicazione nuovi proj nei pezzi + Dim nDuploLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "DuploBase") + Dim nDuploId As Integer = EgtGetFirstInGroup(nDuploLayerId) + While nDuploId <> GDB_ID.NULL + ' recupero vecchio proj + Dim nOldProjId As Integer + EgtGetInfo(nDuploId, BTL_PRT_PROJ, nOldProjId) + ' lo cerco nella lista + Dim nOldProjIndex As Integer = ImportProjIdList.IndexOf(nOldProjId) + ' lo sostituisco + EgtSetInfo(nDuploId, BTL_PRT_PROJ, NewProjIdList(nOldProjIndex)) + nDuploId = EgtGetNext(nDuploId) + End While + ' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto + CurrProd = Nothing + ' carico Machgroup che non verrebbero altrimenti importati + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + ' inizializzo nuovo progetto PROD + InitNewProd(NewProjIdList(0), nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine) + For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' aggiorno ProdId sui MachGroup + EgtSetInfo(MachGroup.Id, MGR_RPT_PRODID, nProdId) + If Map.refMainWindowVM.MainWindowM.nUserLevel < 5 OrElse GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) <> 1 Then + ' resetto tutti gli stati di CALC + MachGroup.ResetCalcTotalMachGroup() + End If + Next + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' riporto info di futuro aggiornamento machgroup + nBTLInfoLayerId = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, True) + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + End If + ' salvo il progetto PROD + EgtSaveFile(sProjFromPath(0), NGE.CMPTEXT) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' copio tutti i bwe + For Each CurrFile In Directory.GetFiles(sProjectimportDir) + If Path.GetExtension(CurrFile) = ".bwe" OrElse Path.GetExtension(CurrFile) = ".html" Then + File.Copy(CurrFile, sProdDir & "\" & Path.GetFileName(CurrFile)) + End If + Next + End If + If bOk Then + ' aggiungo altri proj a prod + For Each nProjId In NewProjIdList + DbControllers.m_ProdController.AddProj(nProdId, nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Next + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + DbControllers.m_ProdController.UpdateMachGroup(nProdId, MyMachGroupList) + ' resetto lock + DbControllers.m_ProdController.LockByProdId(nProdId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + DbControllers.m_ProdController.ResetController() + ' imposto progetto corrente + If NewProjIdList.Count > 0 Then + SetCurrProj(NewProjIdList(0)) + SetCurrProd(nProdId) + OpenProject(CurrProd) ' Da controllare + End If + WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + End Sub + +#End Region ' ImportProject + +#Region "AddProj" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property AddProj_Command As ICommand + Get + If m_cmdAddProj Is Nothing Then + m_cmdAddProj = New Command(AddressOf AddProj) + End If + Return m_cmdAddProj + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub AddProj() + ' verifico se progetto modificato, e chiedo se salvare + If IsNothing(CurrProd) Then Return + Dim bNewProject As Boolean = False + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProd.sProdDirPath + Dim VerifyResult As MessageBoxResult = MessageBoxResult.None + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() OrElse CurrProd.bIsNew OrElse Map.refCALCPanelVM.IsMachineModified() Then + VerifyResult = MessageBox.Show(EgtMsg(61875), "", If(CurrProd.bIsNew, MessageBoxButton.OKCancel, MessageBoxButton.YesNoCancel), MessageBoxImage.Question) + Select Case VerifyResult + Case MessageBoxResult.Yes, MessageBoxResult.OK + ' salvo proj + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + EgtResetModified() + OpenProject(CurrProd) + End Select + Else + EgtResetModified() + End If + ' faccio scegliere proj da aggiungere + Dim OpenProjectFileDialogVM As New OpenProjectFileDialogVM + Dim ChooseProdFileDialog As New OnlyProdOpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = ChooseProdFileDialog.EgtShowDialog(ProjectType.PROJ, True) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + If IsNothing(OpenProjectFileDialogVM.SelProject.nProjId) OrElse OpenProjectFileDialogVM.SelProject.nProjId <= 0 Then Return + ' verifico che il proj selezionato non abbia prod + If Not IsNothing(OpenProjectFileDialogVM.SelProject.nProdId) AndAlso OpenProjectFileDialogVM.SelProject.nProdId > 0 Then + ' verifico che non sia uno di quelli gia' collegati a questo Prod + Dim bFound As Boolean = False + For Each nProjId As Integer In CurrProd.nProjIdList + If nProjId = OpenProjectFileDialogVM.SelProject.nProjId Then + bFound = True + Exit For + End If + Next + If bFound Then + MessageBox.Show("Selezionato progetto che fa gia' parte di questa produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Else + MessageBox.Show("Progetto gia' collegato ad una produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return + End If + ' verifico che sia associato alla stessa macchina + If OpenProjectFileDialogVM.SelProject.sMachine <> CurrProd.sMachine Then + MessageBox.Show("Progetto per una macchina diversa da quella del progetto corrente!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' inserisco proj nel prod corrente + Dim bOk As Boolean = EgtInsertFile(OpenProjectFileDialogVM.SelProject.sProjPath) + ' lo salvo + bOk = bOk AndAlso Save(False) + If bOk Then + ' riporto aggiunta proj a prod su Db + DbControllers.m_ProdController.AddProj(CurrProd.nProdId, OpenProjectFileDialogVM.SelProject.nProjId) + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' aggiorno CurrProd + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(CurrProd.nProdId) + CurrProd.ProdFileM.SetProjIdList(PdFileM.nProjIdList) + ' ricarico BTLPartList + OpenProject(CurrProd) + End Sub + +#End Region ' AddProj + +#Region "GoToSupervisor" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property GoToSupervisor_Command As ICommand + Get + If m_cmdGoToSupervisor Is Nothing Then + m_cmdGoToSupervisor = New Command(AddressOf GoToSupervisor) + End If + Return m_cmdGoToSupervisor + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub GoToSupervisor() + If IsNothing(CurrProd) Then Return + ' apro supervisore + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + ' recupero processo del supervisore + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + If localProc.Length > 0 Then + For Each p As Process In localProc + ' porto in primo piano il Supervisor + BringWindowToFront(p.MainWindowHandle) + Exit For + Next + Else + Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" + Try + Process.Start(sSupervisorPath, "1 " & CurrProd.nProdId) + Catch ex As Exception + EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) + End Try + End If + ' mando richiesta di apertura progetto in supervisore + DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, CurrProd.nProdId, CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") + End Sub + +#End Region ' GoToSupervisor + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml new file mode 100644 index 00000000..63abd7b0 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb new file mode 100644 index 00000000..b60c4a3d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdProjectV + +End Class diff --git a/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectVM.vb b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectVM.vb new file mode 100644 index 00000000..fdbc48c9 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OnlyProdProject/OnlyProdProjectVM.vb @@ -0,0 +1,448 @@ +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.Collections.ObjectModel + +Public Class OnlyProdProjectVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_Calc_Timer As New DispatcherTimer + + Private Property m_GridDims As New ObservableCollection(Of GridDimension) + Public Property GridDims As ObservableCollection(Of GridDimension) + Get + Return m_GridDims + End Get + Set + m_GridDims = Value + NotifyPropertyChanged(NameOf(GridDims)) + End Set + End Property + + Private m_BTLStructureVM As BTLStructureVM + Public Property BTLStructureVM As BTLStructureVM + Get + Return m_BTLStructureVM + End Get + Set(value As BTLStructureVM) + m_BTLStructureVM = value + NotifyPropertyChanged(NameOf(BTLStructureVM)) + End Set + End Property + + Private m_MachGroupPanelVM As MyMachGroupPanelVM + Public Property MachGroupPanelVM As MyMachGroupPanelVM + Get + Return m_MachGroupPanelVM + End Get + Set(value As MyMachGroupPanelVM) + m_MachGroupPanelVM = value + NotifyPropertyChanged(NameOf(MachGroupPanelVM)) + End Set + End Property + + Private m_bCalcRunning As Boolean = False + Public ReadOnly Property bCalcRunning As Boolean + Get + Return m_bCalcRunning + End Get + End Property + Private m_bLockUX As Boolean = False + + Private m_LeftPanel_Visibility As Boolean = True + Public Property LeftPanel_Visibility As Visibility + Get + Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_LeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean) + m_LeftPanel_Visibility = IsVisible + End Sub + + Private m_TopPanel_Visibility As Boolean = False + Public Property TopPanel_Visibility As Visibility + Get + Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_TopPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetTopPanel_Visibility(IsVisible As Boolean) + m_TopPanel_Visibility = IsVisible + End Sub + + Private m_BottomPanel_Visibility As Boolean = True + Public Property BottomPanel_Visibility As Visibility + Get + Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_BottomPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean) + m_BottomPanel_Visibility = IsVisible + End Sub + + Private m_PartManager_Visibility As Boolean = True + Public ReadOnly Property PartManager_Visibility As Visibility + Get + 'Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive) Then + Return Visibility.Visible + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Return Visibility.Visible + Else + Return Visibility.Collapsed + End If + End Get + End Property + + Private m_FeatureManager_Visibility As Boolean = True + Public Property FeatureManager_Visibility As Visibility + Get + Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FeatureManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean) + m_FeatureManager_Visibility = IsVisible + End Sub + + Private m_ShowBeamPanel_Visibility As Boolean = True + Public Property ShowBeamPanel_Visibility As Visibility + Get + Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ShowBeamPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean) + m_ShowBeamPanel_Visibility = IsVisible + End Sub + + Private m_ProjManager_Visibility As Boolean = True + Public Property ProjManager_Visibility As Visibility + Get + Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProjManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProjManager_Visibility(IsVisible As Boolean) + m_ProjManager_Visibility = IsVisible + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + End Sub + + Private m_ProdManager_Visibility As Boolean = True + Public Property ProdManager_Visibility As Visibility + Get + Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProdManager_Visibility(IsVisible As Boolean) + m_ProdManager_Visibility = IsVisible + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) + End Sub + + Private m_FullCompleteManager_Visibility As Boolean = True + Public Property FullCompleteManager_Visibility As Visibility + Get + Return If(m_FullCompleteManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FullCompleteManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFullCompleteManager_Visibility(IsVisible As Boolean) + m_FullCompleteManager_Visibility = IsVisible + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + End Sub + + Private m_OptimizePanel_Visibility As Boolean = True + Public Property OptimizePanel_Visibility As Visibility + Get + Return If(m_OptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOptimizePanel_Visibility(IsVisible As Boolean) + m_OptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) + End Sub + + Friend Sub NotifyCalcPanel_Visibility() + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility)) + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility)) + End Sub + + Private m_FreeContourManager_Visibility As Boolean = False + Public Property FreeContourManager_Visibility As Visibility + Get + Return If(m_FreeContourManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FreeContourManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean) + m_FreeContourManager_Visibility = IsVisible + NotifyPropertyChanged("FreeContourManager_Visibility") + End Sub + + Friend Sub NotifyAllPanelVisibility() + NotifyPropertyChanged("LeftPanel_Visibility") + NotifyPropertyChanged("TopPanel_Visibility") + NotifyPropertyChanged("BottomPanel_Visibility") + NotifyPropertyChanged("PartManager_Visibility") + NotifyPropertyChanged("FeatureManager_Visibility") + NotifyPropertyChanged("ShowBeamPanel_Visibility") + NotifyPropertyChanged("ProjManager_Visibility") + NotifyPropertyChanged("ProdManager_Visibility") + NotifyPropertyChanged("FullCompleteManager_Visibility") + NotifyCalcPanel_Visibility() + End Sub + +#End Region ' FIELDS & PROPERTIES + +#Region "Messages" + + Public ReadOnly Property ProduceRawPart_ToolTip As String + Get + Return EgtMsg(61912) + End Get + End Property + + Public ReadOnly Property ResetCALCRawPart_ToolTip As String + Get + Return EgtMsg(61924) + End Get + End Property + + Public ReadOnly Property ProduceAllRawPart_ToolTip As String + Get + Return EgtMsg(61913) + End Get + End Property + + Public ReadOnly Property CopyRawPart_ToolTip As String + Get + Return EgtMsg(61914) + End Get + End Property + + Public ReadOnly Property RemoveRawPart_ToolTip As String + Get + Return EgtMsg(61915) + End Get + End Property + + Public ReadOnly Property RemoveAllRawPart_ToolTip As String + Get + Return EgtMsg(61976) + End Get + End Property + + Public ReadOnly Property ReOrderPart_ToolTip As String + Get + Return EgtMsg(61916) + End Get + End Property + + Public ReadOnly Property MoveUpPart_ToolTip As String + Get + Return EgtMsg(61917) + End Get + End Property + + Public ReadOnly Property MoveDownPart_ToolTip As String + Get + Return EgtMsg(61918) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61919) + End Get + End Property + + Public ReadOnly Property MovePartInRawPart_ToolTip As String + Get + Return EgtMsg(61944) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjectVM(Me) + ' imposto timer per aggiornamenti Calc + m_Calc_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_Calc_Timer.Tick, AddressOf Calc_Timer_Tick + ' imposto dimensioni colonne/righe della Grid + DimensionsIniFile.ReadGridDimensions(ConstDims.PROJECT_VIEW, GridDims) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub SetCalcRunning(value As Boolean) + If value Then m_Calc_Timer.Start() + m_bCalcRunning = value + End Sub + + Friend Sub ManageIsEnabled(bIsEnabled As Boolean) + Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled) + Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled) + Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) + Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) + Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) + Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) + Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) + Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) + Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) + End Sub + + Private Sub Calc_Timer_Tick() + If m_bCalcRunning <> m_bLockUX Then + ' se calcolo iniziato + If m_bCalcRunning Then + ManageIsEnabled(False) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.IsReadOnly = True + End If + m_bLockUX = True + ' se calcolo finito + Else + ManageIsEnabled(True) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.ResetToOrigIsReadOnly() + End If + If m_BTLStructureVM.nPROJTYPE <> BWType.BEAM AndAlso Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.ResetToOrigIsReadOnly() + End If + ' fermo il timer + If Not m_bCalcRunning Then + m_Calc_Timer.Stop() + m_bLockUX = False + End If + End If + End If + + End Sub + +#End Region ' METHODS + +End Class + diff --git a/EgtBEAMWALL.Optimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb b/EgtBEAMWALL.Optimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb new file mode 100644 index 00000000..1b917c1a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OpenProjectFileDialog/OpenProjectFileDialogVM.vb @@ -0,0 +1,240 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class OpenProjectFileDialogVM + Inherits Core.OpenProjectFileDialogVM + +#Region "METHODS" + + Public Overrides Function Init(ProjectType As ProjectType, Optional CurrProjectList As List(Of ProjectFileVM) = Nothing, Optional GoToProd As Boolean = False) As Boolean? + m_ProjectType = ProjectType + m_GoToProd = GoToProd + ' carico colonne + LoadColumns(ProjectType) + NotifyPropertyChanged(NameOf(FilterTypeList)) + m_SelFilterType = m_FilterTypeList(0) + ' carico lista progetti + If IsNothing(CurrProjectList) OrElse CurrProjectList.Count = 0 Then + SetFixedProjectList(False) + RefreshProjectList() + Else + SetFixedProjectList(True) + m_ProjectList = New ObservableCollection(Of ProjectFileVM)(CurrProjectList) + NotifyPropertyChanged(NameOf(ProjectList)) + End If + m_ProjectList_View = CollectionViewSource.GetDefaultView(m_ProjectList) + m_ProjectList_View.Filter = AddressOf ProjectFilter + End Function + + Public Overrides Sub RefreshProjectList() + m_ProjectList.Clear() + ' calcolo periodo e righe + Dim dtStart As DateTime + Dim dtEnd As DateTime + Dim nRowQuantity As Integer = 20 + Select Case SelRowQuantity + Case RowQuantities.FIFTY + nRowQuantity = 50 + Case RowQuantities.HUNDRED + nRowQuantity = 100 + Case RowQuantities.HUNDREDANDFIFTY + nRowQuantity = 150 + End Select + Select Case m_SelDayType + Case DayTypes.LASTMONTH + dtEnd = DateTime.Today + TimeSpan.FromDays(1) + dtStart = dtEnd - TimeSpan.FromDays(30.5) + Case DayTypes.LAST3MONTHS + dtEnd = DateTime.Today + TimeSpan.FromDays(1) + dtStart = dtEnd - TimeSpan.FromDays(30.5 * 3) + Case DayTypes.LAST6MONTHS + dtEnd = DateTime.Today + TimeSpan.FromDays(1) + dtStart = dtEnd - TimeSpan.FromDays(30.5 * 6) + Case DayTypes.PERIOD + dtEnd = dtEndDate + TimeSpan.FromDays(1) + dtStart = dtStartDate + End Select + ' leggo da db + If m_ProjectType = ProjectType.PROJ Then + Dim DbProjectList As New List(Of ProjFileM) + ' CheckMe: lasciato come prima, anche NON attivi (cancellazione logica) + If m_SelBTLDateType = BTLDateTypes.CREATEDATE Then + DbProjectList = DbControllers.m_ProjController.GetLastDesc(dtStart, dtEnd, nRowQuantity, True) + Else + DbProjectList = DbControllers.m_ProjController.GetLastByExpDesc(dtStart, dtEnd, nRowQuantity, False) + End If + If m_GoToProd Then + For Each Project In DbProjectList + ' recupero path per verificare esista + If IsNothing(Project.nProdId) OrElse Project.nProdId = 0 Then Continue For + Dim sPath As String = Map.refMainWindowVM.MainWindowM.sProdsDir & "\" & Project.nProdId.ToString("0000") & "\" & Project.nProdId.ToString("0000") & ".nge" + If Project.sMachine = ProjectManagerVM.CurrProj.sMachine AndAlso + Project.nType = ProjectManagerVM.CurrProj.nType Then + If File.Exists(sPath) Then + m_ProjectList.Add(New ProjFileVM(Project)) + Else + DbControllers.m_ProdController.DeleteProd(Project.nProdId, True) + EgtOutLog("Found project on Db without the folder and erased it! Prod number " & Project.nProdId.ToString("0000")) + End If + End If + Next + Else + For Each Project In DbProjectList + ' recupero path per verificare esista + If IsNothing(Project.nProjId) OrElse Project.nProjId = 0 Then Continue For + Dim sPath As String = Map.refMainWindowVM.MainWindowM.sProjsDir & "\" & Project.nProjId.ToString("0000") & "\" & Project.nProjId.ToString("0000") & ".nge" + If File.Exists(sPath) Then + m_ProjectList.Add(New ProjFileVM(Project)) + Else + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(Project.nProjId, False) + EgtOutLog("Found project on Db without the folder and erased it! Proj number " & Project.nProjId.ToString("0000")) + End If + Next + End If + ElseIf m_ProjectType = ProjectType.PROD Then + Dim DbProjectList As New List(Of ProdFileM) + DbProjectList = DbControllers.m_ProdController.GetLastDesc(dtStart, dtEnd, nRowQuantity, True) + For Each Project In DbProjectList + ' recupero path per verificare esista + If IsNothing(Project.nProdId) OrElse Project.nProdId = 0 Then Continue For + Dim sPath As String = Map.refMainWindowVM.MainWindowM.sProdsDir & "\" & Project.nProdId.ToString("0000") & "\" & Project.nProdId.ToString("0000") & ".nge" + If File.Exists(sPath) Then + m_ProjectList.Add(New ProdFileVM(Project)) + Else + DbControllers.m_ProdController.DeleteProd(Project.nProdId, True) + EgtOutLog("Found project on Db without the folder and erased it! Prod number " & Project.nProdId.ToString("0000")) + End If + Next + End If + End Sub + + Public Overrides Sub Delete() + If IsNothing(SelProject) Then Return + ' recupero indice per riselezionare + Dim ProjListIndex As Integer = m_ProjectList.IndexOf(SelProject) + If m_ProjectType = ProjectType.PROJ Then + ' verifico se proj selezionato e' il corrente + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso SelProject.nProjId = ProjectManagerVM.CurrProj.nProjId Then + MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + ' verifico se proj selezionato ha prod + If SelProject.nProdId > 0 Then + MessageBox.Show(EgtMsg(61873), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + Map.refProjManagerVM.m_MruFiles.Remove(SelProject.sProjPath) + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + ' cancello progetto + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(SelProject.nProjId, False) + ' cancello cartella del Proj + Try + Directory.Delete(SelProject.sProjDirPath, True) + Catch ex As Exception + EgtOutLog("Error in deleting directory " & SelProject.sProjDirPath) + End Try + ' aggiorno lista progetti + m_ProjectList.Clear() + Dim DbProjectList As New List(Of ProjFileM) + DbProjectList = DbControllers.m_ProjController.GetLastDesc(50, False) + For Each Project In DbProjectList + m_ProjectList.Add(New ProjFileVM(Project)) + Next + ElseIf m_ProjectType = ProjectType.PROD Then + ' verifico se prod selezionato e' il corrente + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso SelProject.nProdId = ProjectManagerVM.CurrProd.nProdId Then + MessageBox.Show(EgtMsg(61872), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + ' verifico se ci sono grezzi mandati al supervisore + If DbControllers.m_ProdController.IsAnyInSupervisor(SelProject.nProdId) Then + MessageBox.Show(EgtMsg(61874), EgtMsg(30009), MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If + Map.refProdManagerVM.m_MruFiles.Remove(SelProject.sProdPath) + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + ' cancello progetto + DbControllers.m_ProdController.DeleteProd(SelProject.nProdId, True) + ' riporto prod in proj + Dim nCurrCtx As Integer = EgtGetCurrentContext() + Dim nTempCtx As Integer = EgtInitContext() + If nTempCtx <> 0 Then + ' inizializzo gestore lavorazioni + EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir) + ' apro, ripulisco e salvo il progetto in tutti i proj correlati + Dim ProdFile As ProdFileVM = DirectCast(SelProject, ProdFileVM) + For Each nProjId In ProdFile.nProjIdList + EgtOpenFile(SelProject.sProdPath) + ' cancello tutti i gruppi di lavorazione + Dim nMachGroupId As Integer = EgtGetFirstMachGroup() + While nMachGroupId <> GDB_ID.NULL + EgtSetCurrMachGroup(nMachGroupId) + Dim nRawPartId As Integer = EgtGetFirstRawPart() + While nRawPartId <> GDB_ID.NULL + Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId) + While nPartId <> GDB_ID.NULL + EgtRemovePartFromRawPart(nPartId) + ' elimino pezzo copia + EgtErase(nPartId) + nPartId = EgtGetFirstPartInRawPart(nRawPartId) + End While + nRawPartId = EgtGetNextRawPart(nRawPartId) + End While + EgtRemoveMachGroup(nMachGroupId) + nMachGroupId = EgtGetFirstMachGroup() + End While + ' cancello tutti i gruppi che sono di un progetto diverso da questo + Dim nGroupId As Integer = EgtGetFirstInGroup(GDB_ID.ROOT) + While nGroupId <> GDB_ID.NULL + Dim nGroupProjId As Integer = GDB_ID.NULL + Dim nNextGroupId As Integer = EgtGetNext(nGroupId) + If EgtGetInfo(nGroupId, BTL_PRT_PROJ, nGroupProjId) Then + If nGroupProjId <> nProjId Then + EgtErase(nGroupId) + End If + End If + nGroupId = nNextGroupId + End While + EgtSaveFile(ProdFile.GetProjPath(nProjId), NGE.CMPTEXT) + Next + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + End If + ' se proj corrente era il prod cancellato, aggiorno proj corrente + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso ProjectManagerVM.CurrProj.nProdId = SelProject.nProdId Then + Map.refProjManagerVM.UpdateCurrProj() + End If + ' cancello cartella del Prod + Try + Directory.Delete(SelProject.sProdDirPath, True) + Catch ex As Exception + EgtOutLog("Error in deleting directory " & SelProject.sProdDirPath) + End Try + ' aggiorno lista progetti + m_ProjectList.Clear() + Dim DbProjectList As New List(Of ProdFileM) + DbProjectList = DbControllers.m_ProdController.GetLastDesc(50, False) + For Each Project In DbProjectList + m_ProjectList.Add(New ProdFileVM(Project)) + Next + End If + ' ripristino selezionato + If ProjListIndex >= 0 AndAlso ProjListIndex <= m_ProjectList.Count - 1 Then + SelProject = m_ProjectList(ProjListIndex) + NotifyPropertyChanged(NameOf(SelProject)) + End If + ' reset dei controller per tornare in sync + DbControllers.m_ProjController.ResetController() + DbControllers.m_ProdController.ResetController() + End Sub + +#End Region ' METHODS + +End Class diff --git a/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml b/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml new file mode 100644 index 00000000..ce9a9310 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml @@ -0,0 +1,23 @@ + + + + + + diff --git a/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb new file mode 100644 index 00000000..24b81fc3 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OptimizePanel/OnlyProdOptimizePanelV.xaml.vb @@ -0,0 +1,11 @@ +Public Class OnlyProdOptimizePanelV + + 'Private Sub OptimizeBtn_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + ' Dim OptimizeBtn = TryCast(sender, FrameworkElement) + + ' If OptimizeBtn IsNot Nothing Then + ' OptimizeBtn.ContextMenu.IsOpen = True + ' End If + 'End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml new file mode 100644 index 00000000..fdb08751 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml.vb new file mode 100644 index 00000000..b073a2a4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelV.xaml.vb @@ -0,0 +1,11 @@ +Public Class OptimizePanelV + + Private Sub OptimizeBtn_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) + Dim OptimizeBtn = TryCast(sender, FrameworkElement) + + If OptimizeBtn IsNot Nothing Then + OptimizeBtn.ContextMenu.IsOpen = True + End If + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelVM.vb b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelVM.vb new file mode 100644 index 00000000..c793ba5f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/OptimizePanel/OptimizePanelVM.vb @@ -0,0 +1,502 @@ +Imports System.Threading +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class OptimizePanelVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Friend m_bNestingRunning As Boolean = False + Friend m_StopNesting As Boolean = False + + Public Enum PartType As Integer + MATERIAL = 0 + ALL = 1 + End Enum + + Friend Enum OriginType As Integer + STANDARD = 0 + FROM_BTL = 1 + End Enum + + Private m_PartTypeList As New List(Of IdNameStruct)({New IdNameStruct(PartType.MATERIAL, EgtMsg(61957)), + New IdNameStruct(PartType.ALL, EgtMsg(61956))}) + Public ReadOnly Property PartTypeList As List(Of IdNameStruct) + Get + Return m_PartTypeList + End Get + End Property + + Private m_SelPartType As IdNameStruct + Public Property SelPartType As IdNameStruct + Get + Return m_SelPartType + End Get + Set(value As IdNameStruct) + m_SelPartType = value + End Set + End Property + + Private m_OriginTypeList As New List(Of IdNameStruct)({New IdNameStruct(OriginType.STANDARD, EgtMsg(61964)), + New IdNameStruct(OriginType.FROM_BTL, EgtMsg(61965))}) + Public ReadOnly Property OriginTypeList As List(Of IdNameStruct) + Get + Return m_OriginTypeList + End Get + End Property + + Private m_SelOriginType As IdNameStruct + Public Property SelOriginType As IdNameStruct + Get + Return m_SelOriginType + End Get + Set(value As IdNameStruct) + m_SelOriginType = value + NotifyPropertyChanged(NameOf(NestingOption_Visibility)) + End Set + End Property + + Private m_bLDIntersOther As Boolean = False + Public Property bLDIntersOther As Boolean + Get + Return m_bLDIntersOther + End Get + Set(value As Boolean) + m_bLDIntersOther = value + WriteMainPrivateProfileString(S_NEST, K_LDINTERSOTHER, If(m_bLDIntersOther, 1, 0)) + End Set + End Property + Public ReadOnly Property NestingOption_Visibility As Visibility + Get + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + If CurrentMachine.nType = MachineType.WALL OrElse CurrentMachine.nType = MachineType.BOTH Then + If CurrentMachine.dHorDrillDiam > 0 And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO) And m_SelOriginType.Id = OriginType.STANDARD Then + Return Visibility.Visible + End If + End If + End If + Return Visibility.Collapsed + End Get + End Property + + Private m_nMinScore As Integer + Public Property dMinScore As Double + Get + Return m_nMinScore + End Get + Set(value As Double) + m_nMinScore = Math.Floor(Math.Min(100, Math.Max(value, 0))) + WriteMainPrivateProfileString(S_NEST, K_MINSCORE, m_nMinScore) + End Set + End Property + + Private m_Optimize_IsEnabled As Boolean = True + Public ReadOnly Property Optimize_IsEnabled As Boolean + Get + Return m_Optimize_IsEnabled + End Get + End Property + Private m_CalcRotFlip_IsEnabled As Boolean = True + Public ReadOnly Property CalcRotFlip_IsEnabled As Boolean + Get + Return m_CalcRotFlip_IsEnabled + End Get + End Property + + Public ReadOnly Property CalcRotFlip_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO), Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Public ReadOnly Property Optimize_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))), Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property OriginType_Visibility As Visibility + Get + Return If(Optimize_Visibility = Visibility.Visible AndAlso OriginTypeList.Count > 1, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Public ReadOnly Property MachiningPage_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.MACHINING Or Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + +#Region "Messages" + + Public ReadOnly Property LongDrillArea_Msg As String + Get + Return EgtMsg(61889) + End Get + End Property + + Public ReadOnly Property MinScore_Msg As String + Get + Return EgtMsg(61890) + End Get + End Property + + Public ReadOnly Property Optimize_Msg As String + Get + Return EgtMsg(61833) + End Get + End Property + + Public ReadOnly Property Warehouse_ToolTip As String + Get + Return EgtMsg(61920) + End Get + End Property + + Public ReadOnly Property CalcRotFlip_ToolTip As String + Get + Return EgtMsg(61932) + End Get + End Property + + Public ReadOnly Property UnlockFlip_ToolTip As String + Get + Return EgtMsg(61933) + End Get + End Property + + Public ReadOnly Property UnlockRot_ToolTip As String + Get + Return EgtMsg(61934) + End Get + End Property + +#End Region ' Messages + + ' Definizione comandi + Private m_cmdOptimize As ICommand + Private m_cmdCalcRotFlip As ICommand + Private m_cmdUnlockRot As ICommand + Private m_cmdUnlockFlip As ICommand + Private m_cmdWarehouse As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' aggiungo riferimento a Map + Map.SetRefOptimizePanelVM(Me) + m_SelPartType = PartTypeList(0) + m_SelOriginType = OriginTypeList(0) + m_bLDIntersOther = False + NotifyPropertyChanged(NameOf(SelPartType)) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub SetOptimizePanelIsEnabled(bIsEnabled As Boolean) + ' se pareti e senza opzione nesting, lascio disabilitato + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Not Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO) Then + m_Optimize_IsEnabled = False + m_CalcRotFlip_IsEnabled = False + Else + m_Optimize_IsEnabled = bIsEnabled + m_CalcRotFlip_IsEnabled = bIsEnabled + End If + NotifyPropertyChanged(NameOf(Optimize_IsEnabled)) + NotifyPropertyChanged(NameOf(CalcRotFlip_IsEnabled)) + End Sub + + Friend Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer + If nProg > 0 And nProg <= 100 Then + NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.NEST + NestingRunningWndVM.m_CurrTime = nProg + ElseIf nProg > 100 And nProg <= 200 Then + NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.ADDPART + NestingRunningWndVM.m_CurrTime = nProg - 100 + ElseIf nProg > 200 And nProg <= 300 Then + NestingRunningWndVM.m_CurrState = SectionProgress.NestStates.CALCRAWPART + NestingRunningWndVM.m_CurrTime = nProg - 200 + End If + ' Costringo ad aggiornare + UpdateUI() + ' Eventuale attesa + Thread.Sleep(nPause) + ' Ritorno eventuale stop + If m_StopNesting Then + m_StopNesting = False + Return 1 + Else + Return 0 + End If + End Function + + Private Sub StartCalcRotFlip(BTLPart As BTLPartVM) + ' ricalcolo rotflip + m_bNestingRunning = True + ' se vista tutti i pezzi + Dim bShowBuilding As Boolean = False + Configuration.ShowAllPieces(bShowBuilding) + Dim NestingRunningWndVM As New NestingRunningWndVM(m_SelPartType.Id, BTLPart) + Dim NestingRunningWnd As New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM) + NestingRunningWnd.ShowDialog() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + EgtDraw() + m_bNestingRunning = False + End Sub + + Friend Sub UpdateOriginTypeList(bFromBtl As Boolean) + m_OriginTypeList = New List(Of IdNameStruct) + If Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM OrElse (Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO))) Then + m_OriginTypeList.Add(New IdNameStruct(OriginType.STANDARD, EgtMsg(61964))) + End If + If bFromBtl Then + m_OriginTypeList.Add(New IdNameStruct(OriginType.FROM_BTL, EgtMsg(61965))) + End If + NotifyPropertyChanged(NameOf(OriginTypeList)) + NotifyPropertyChanged(NameOf(OriginType_Visibility)) + NotifyPropertyChanged(NameOf(SelOriginType)) + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "CalcRotFlip" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property CalcRotFlip_Command As ICommand + Get + If m_cmdCalcRotFlip Is Nothing Then + m_cmdCalcRotFlip = New Command(AddressOf CalcRotFlip) + End If + Return m_cmdCalcRotFlip + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub CalcRotFlip() + If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return + ' lancio calcolo RotFlip + StartCalcRotFlip(Nothing) + End Sub + +#End Region ' CalcRotFlip + +#Region "UnlockRot" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property UnlockRot_Command As ICommand + Get + If m_cmdUnlockRot Is Nothing Then + m_cmdUnlockRot = New Command(AddressOf UnlockRot) + End If + Return m_cmdUnlockRot + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub UnlockRot() + If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If IsNothing(BTLPart) Then Continue For + If BTLPart.bLockRotation Then + BTLPart.bLockRotation = False + End If + Next + ' lancio calcolo RotFlip + StartCalcRotFlip(Nothing) + Else + Dim SelBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelBTLPart) Then Return + If SelBTLPart.bLockRotation Then + SelBTLPart.bLockRotation = False + ' lancio calcolo RotFlip + StartCalcRotFlip(SelBTLPart) + End If + End If + End Sub + +#End Region ' UnlockRot + +#Region "UnlockFlip" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property UnlockFlip_Command As ICommand + Get + If m_cmdUnlockFlip Is Nothing Then + m_cmdUnlockFlip = New Command(AddressOf UnlockFlip) + End If + Return m_cmdUnlockFlip + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub UnlockFlip() + If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If IsNothing(BTLPart) Then Continue For + BTLPart.bLockInversion = False + Next + ' lancio calcolo RotFlip + StartCalcRotFlip(Nothing) + Else + Dim SelBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart + If IsNothing(SelBTLPart) Then Return + SelBTLPart.bLockInversion = False + ' lancio calcolo RotFlip + StartCalcRotFlip(SelBTLPart) + End If + End Sub + +#End Region ' UnlockFlip + +#Region "Optimize" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Optimize_Command As ICommand + Get + If m_cmdOptimize Is Nothing Then + m_cmdOptimize = New Command(AddressOf Optimize) + End If + Return m_cmdOptimize + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Optimize() + If IsNothing(m_SelPartType) OrElse IsNothing(m_SelOriginType) Then Return + If IsNothing(Map.refProjectVM.BTLStructureVM) OrElse IsNothing(Map.refProjectVM.BTLStructureVM.BTLPartVMList) OrElse Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count = 0 Then Return + ' se nessun grezzo, rendo tutti i pezzi visibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.ShowAll(False) + End If + ' apro finestra di attesa nesting + m_bNestingRunning = True + Dim NestingRunningWnd As Object = Nothing + Dim NestingRunningWndVM As NestingRunningWndVM + If m_SelOriginType.Id = OriginType.FROM_BTL Then + NestingRunningWndVM = New NestingRunningWndVM(m_SelPartType.Id) + Else + NestingRunningWndVM = New NestingRunningWndVM(m_SelPartType.Id, m_bLDIntersOther, m_nMinScore) + End If + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + NestingRunningWnd = New OnlyProdNestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM) + Else + NestingRunningWnd = New NestingRunningWndV(Application.Current.MainWindow, NestingRunningWndVM) + End If + NestingRunningWnd.ShowDialog() + m_bNestingRunning = False + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + ' mostro risultati + Dim sResult As String = "" + Dim dStartOffset As Double = WarehouseHelper.GetStartOffset() + For Each Section In NestingRunningWndVM.SectionProgressList + Dim bSectionInitiated As Boolean = False + If Section.SectionPartList.Count > 0 AndAlso Section.SParamList.Count = 0 Then + sResult &= "Section " & Section.Section.sSectionXMaterial & ": no raw part found in the warehouse!" & Environment.NewLine + bSectionInitiated = True + End If + For Each Part In Section.SectionPartList + If Part.nINPROD <> Part.nCNT + Part.nADDED Then + ' verifico se inizializzare sezione + If Not bSectionInitiated Then + sResult &= "Section " & Section.Section.sSectionXMaterial & ":" & Environment.NewLine + bSectionInitiated = True + End If + ' recupero VM + Dim PartVM As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is Part) + If Not IsNothing(PartVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM AndAlso Section.SParamList.Count > 0 Then + Dim dMaxL As Double = Section.SParamList.Max(Function(x) x.dL) + If PartVM.dL + dStartOffset < dMaxL Then + sResult &= " - " & Part.nPDN & ": material L(" & dMaxL & ") too short for a part with L(" & PartVM.dL & ")!" & Environment.NewLine + Else + sResult &= " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine + End If + ElseIf Not IsNothing(PartVM) AndAlso Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL Then + If Not Section.SParamList.Any(Function(x) x.dL > PartVM.dL AndAlso x.dW > PartVM.dW) Then + sResult &= " - " & Part.nPDN & ": no material can fit part dimensions(" & PartVM.dW & " x " & PartVM.dL & ")!" & Environment.NewLine + Else + sResult &= " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine + End If + Else + sResult &= " - " & Part.nPDN & ": partially nested!" & "(" & Part.nINPROD & "/" & Part.nCNT + Part.nADDED & ")" & Environment.NewLine + End If + End If + Next + Next + If Not String.IsNullOrWhiteSpace(sResult) Then + MessageBox.Show(Application.Current.MainWindow, sResult, "", MessageBoxButton.OK, MessageBoxImage.Warning) + End If + End Sub + +#End Region ' Optimize + +#Region "Warehouse" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Warehouse_Command As ICommand + Get + If m_cmdWarehouse Is Nothing Then + m_cmdWarehouse = New Command(AddressOf Warehouse) + End If + Return m_cmdWarehouse + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Warehouse() + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then 'If Not IsNothing(ProjectManagerVM.CurrProd) Then + Dim WarehouseWnd As Object + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + WarehouseWnd = New OnlyProdWarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM()) + Else + WarehouseWnd = New WarehouseWndV(Application.Current.MainWindow, New WarehouseWndVM()) + End If + WarehouseWnd.ShowDialog() + End If + End Sub + +#End Region ' Warehouse + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml b/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml new file mode 100644 index 00000000..e5d6b1b7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml @@ -0,0 +1,34 @@ + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml.vb new file mode 100644 index 00000000..65bbae45 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/OnlyProdPartInRawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdPartInRawPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml new file mode 100644 index 00000000..4cf757de --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml @@ -0,0 +1,35 @@ + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb new file mode 100644 index 00000000..e9a8122c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class PartInRawPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerVM.vb b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerVM.vb new file mode 100644 index 00000000..9d5216ab --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerVM.vb @@ -0,0 +1,221 @@ +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class PartInRawPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Public ReadOnly Property MovePart_Visibility As Visibility + Get + If Not IsNothing(Map.refProjectVM) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + Return If(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.BEAM, Visibility.Visible, Visibility.Collapsed) + End If + Return Visibility.Visible + End Get + End Property + + Private m_PartInRawPartManager_IsEnabled As Boolean = True + Public ReadOnly Property PartInRawPartManager_IsEnabled As Boolean + Get + Return m_PartInRawPartManager_IsEnabled + End Get + End Property + Friend Sub SetPartInRawPartManagerIsEnabled(bIsEnabled As Boolean) + m_PartInRawPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(PartInRawPartManager_IsEnabled)) + End Sub + + ' Definizione comandi + Private m_cmdRemovePart As ICommand + Private m_cmdMoveUpPart As ICommand + Private m_cmdMoveDownPart As ICommand + Private m_cmdReOrderPart As ICommand + +#End Region ' Fields & Properties + +#Region "CONSTRUCTORS" + + Sub New() + Map.SetRefPartInRawPartManagerVM(Me) + End Sub + +#End Region ' Constructor + +#Region "Messages" + + Public ReadOnly Property ReOrderPart_ToolTip As String + Get + Return EgtMsg(61916) + End Get + End Property + + Public ReadOnly Property MoveUpPart_ToolTip As String + Get + Return EgtMsg(61917) + End Get + End Property + + Public ReadOnly Property MoveDownPart_ToolTip As String + Get + Return EgtMsg(61918) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61919) + End Get + End Property + +#End Region ' Messages + +#Region "COMMANDS" + +#Region "RemovePart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemovePart_Command As ICommand + Get + If m_cmdRemovePart Is Nothing Then + m_cmdRemovePart = New Command(AddressOf RemovePart) + End If + Return m_cmdRemovePart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemovePart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + SelPart.DeletePart() + SelMachGroup.UpdateUsage() + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' RemovePart + +#Region "MoveUpPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveUpPart_Command As ICommand + Get + If m_cmdMoveUpPart Is Nothing Then + m_cmdMoveUpPart = New Command(AddressOf MoveUpPart) + End If + Return m_cmdMoveUpPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveUpPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.UP) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveUpPart + +#Region "MoveDownPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MoveDownPart_Command As ICommand + Get + If m_cmdMoveDownPart Is Nothing Then + m_cmdMoveDownPart = New Command(AddressOf MoveDownPart) + End If + Return m_cmdMoveDownPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MoveDownPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN) + EgtDraw() + ' riseleziono trave + SelMachGroup.SelPart = SelPart + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' MoveDownPart + +#Region "ReOrderPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ReOrderPart_Command As ICommand + Get + If m_cmdReOrderPart Is Nothing Then + m_cmdReOrderPart = New Command(AddressOf ReOrderPart) + End If + Return m_cmdReOrderPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ReOrderPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + Dim SelPart As PartVM = SelMachGroup.SelPart + If IsNothing(SelPart) Then Return + If SelMachGroup.nType = MachineType.BEAM Then + SelMachGroup.ReorderBeam() + EgtDraw() + ' riseleziono trave + If Not IsNothing(SelPart) Then + SelMachGroup.SelPart = SelPart + End If + End If + SelMachGroup.ResetCalcMachGroup() + End Sub + +#End Region ' ReOrderPart + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml new file mode 100644 index 00000000..2ba7490b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb new file mode 100644 index 00000000..04aa079e --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartInRawPartManager/PartInRawPartManagerWndV.xaml.vb @@ -0,0 +1,3 @@ +Public Class PartInRawPartManagerWndV + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml b/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml new file mode 100644 index 00000000..a5a98cbf --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml.vb new file mode 100644 index 00000000..9daecf28 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartManager/OnlyProdPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml b/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml new file mode 100644 index 00000000..f8acbbae --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml.vb new file mode 100644 index 00000000..430cfd1c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartManager/PartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class PartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartManager/PartManagerVM.vb b/EgtBEAMWALL.Optimizer/PartManager/PartManagerVM.vb new file mode 100644 index 00000000..d825645c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartManager/PartManagerVM.vb @@ -0,0 +1,37 @@ +Imports EgtBEAMWALL.Core.ConstGen +Imports EgtWPFLib5 + +Public Class PartManagerVM + Inherits VMBase + + Private m_PartManager_IsEnabled As Boolean = True + Public ReadOnly Property PartManager_IsEnabled As Boolean + Get + Return m_PartManager_IsEnabled + End Get + End Property + + Private m_Lock_Visibility As Visibility + Public ReadOnly Property Lock_Visibility As Visibility + Get + Return If(Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso + Map.refProjectVM.BTLStructureVM.nPROJTYPE = Core.ConstBeam.BWType.WALL AndAlso + Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO), Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Sub New() + ' salvo riferimento in Map + Map.SetRefPartManagerVM(Me) + End Sub + + Friend Sub SetPartManagerIsEnabled(bIsEnabled As Boolean) + m_PartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(PartManager_IsEnabled)) + End Sub + + Friend Sub LockVisibilityUpdate() + NotifyPropertyChanged(NameOf(Lock_Visibility)) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/PartParametersWnd/PartParametersWndV.xaml b/EgtBEAMWALL.Optimizer/PartParametersWnd/PartParametersWndV.xaml new file mode 100644 index 00000000..9a97d323 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/PartParametersWnd/PartParametersWndV.xaml @@ -0,0 +1,468 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerV.xaml.vb new file mode 100644 index 00000000..d9d92d39 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProdManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerVM.vb new file mode 100644 index 00000000..2aaf55d4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProdManager/ProdManagerVM.vb @@ -0,0 +1,638 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class ProdManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_OpenProj_Timer As New DispatcherTimer + Private m_bOpenProj As Boolean = False + Private m_nProjIdToOpen As Integer = GDB_ID.NULL + + Private m_ProdManager_IsEnabled As Boolean = True + Public ReadOnly Property ProdManager_IsEnabled As Boolean + Get + Return m_ProdManager_IsEnabled + End Get + End Property + + Friend Property CurrProd As ProdFileVM + Get + Return ProjectManagerVM.CurrProd + End Get + Set(value As ProdFileVM) + ProjectManagerVM.CurrProd = value + End Set + End Property + + Private m_TempCurrProd As ProdFileVM + Friend Property TempCurrProd As ProdFileVM + Get + Return m_TempCurrProd + End Get + Set(value As ProdFileVM) + m_TempCurrProd = value + End Set + End Property + + ' indice ultimo progetto + Private m_nLastProdId As Integer + Friend ReadOnly Property nLastProdId As Integer + Get + Return m_nLastProdId + End Get + End Property + + Public ReadOnly Property nProdType As BWType + Get + Return If(Not IsNothing(CurrProd), CurrProd.nType, BWType.NULL) + End Get + End Property + + Friend m_MruFiles As New MruList + Public ReadOnly Property MruFileNames As ObservableCollection(Of String) + Get + Dim IdAndBTLFileNames As New ObservableCollection(Of String) + For Each FileName In m_MruFiles.FileNames.ToList() + Dim PdId As Integer = 0 + Dim sPdId As String = Path.GetFileNameWithoutExtension(DirectCast(FileName, String).Replace("__", "_")) + Integer.TryParse(sPdId, PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + If IsNothing(PdFileM) Then + m_MruFiles.Remove(FileName) + Else + Dim PdFileVM = New ProdFileVM(PdFileM) + IdAndBTLFileNames.Add(sPdId & " | " & PdFileVM.sBTLFileName) + End If + Next + Return IdAndBTLFileNames + End Get + End Property + + Private m_GoToSupervisor_Visibility As Visibility + Public ReadOnly Property GoToSupervisor_Visibility As Visibility + Get + Return m_GoToSupervisor_Visibility + End Get + End Property + + Public ReadOnly Property GoToProj_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Collapsed, Visibility.Visible) + End Get + End Property + + Private m_AddProj_Visibility As Visibility + Public ReadOnly Property AddProj_Visibility As Visibility + Get + Return m_AddProj_Visibility + End Get + End Property + + ' Definizione comandi + Private m_cmdOpen As ICommand + Private m_cmdOpenMruFile As ICommand + Private m_cmdSave As ICommand + Private m_cmdAddProj As ICommand + Private m_cmdGoToProj As ICommand + Private m_cmdGoToSupervisor As ICommand + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property OpenToolTip As String + Get + Return EgtMsg(30502) + End Get + End Property + Public ReadOnly Property SaveToolTip As String + Get + Return EgtMsg(30503) + End Get + End Property + Public ReadOnly Property AddProj_ToolTip As String + Get + Return EgtMsg(61921) + End Get + End Property + Public ReadOnly Property GoToProj_ToolTip As String + Get + Return EgtMsg(61922) + End Get + End Property + Public ReadOnly Property GoToSupervisor_ToolTip As String + Get + Return EgtMsg(61974) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProdManagerVM(Me) + ' abilito passaggio a supervisore + If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR) Then + m_GoToSupervisor_Visibility = Visibility.Visible + Else + m_GoToSupervisor_Visibility = Visibility.Collapsed + End If + + ' attivo bottone AddProj + If GetMainPrivateProfileInt(S_GENERAL, K_ADDPROJ, 0) = 1 Then + m_AddProj_Visibility = Visibility.Visible + Else + m_AddProj_Visibility = Visibility.Collapsed + End If + ' Leggo ultimo indice di progetto + m_nLastProdId = GetMainPrivateProfileInt(S_GENERAL, K_PRODSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPRODFILES, 8) + ' imposto timer di apertura da ottimizzatore + m_OpenProj_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_OpenProj_Timer.Tick, AddressOf OpenProject_Tick + m_OpenProj_Timer.Start() + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Function InitNewProject(ByRef nProjId As Integer, ByRef nProdId As Integer, ByRef sProjectDir As String) As Boolean + ' richiedo indice nuovo progetto + nProdId = DbControllers.m_ProdController.GetNextIndex(nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + If nProdId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjectDir) Then + Directory.CreateDirectory(sProjectDir) + Else + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProjectDir) + For Each file As FileInfo In di.EnumerateFiles() + file.Delete() + Next + For Each dir As DirectoryInfo In di.EnumerateDirectories() + dir.Delete(True) + Next + End If + Return True + End Function + + Public Function SetCurrProd(nProdId As Integer) As Boolean + Return ProjectManagerVM.SetCurrProd(nProdId) + End Function + + Public Sub ResetCurrProd() + CurrProd = Nothing + End Sub + + Friend Sub SetProdManagerIsEnabled(bIsEnabled As Boolean) + m_ProdManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(ProdManager_IsEnabled)) + End Sub + + Public Sub OpenProjectFromSupervisor(ProjIdToOpen As Integer) + If (Not IsNothing(ProjectManagerVM.CurrProd) AndAlso ProjIdToOpen <> ProjectManagerVM.CurrProd.nProdId) OrElse Map.refMainMenuVM.SelPage <> Pages.MACHINING Then + m_nProjIdToOpen = ProjIdToOpen + m_bOpenProj = True + End If + End Sub + + Public Sub OpenProject_Tick() + If Not m_bOpenProj Then Return + m_bOpenProj = False + Select Case Map.refMainMenuVM.SelPage + Case Pages.MACHINING + ' recupero progetto da Id + Dim DbProject As ProdFileM + DbProject = DbControllers.m_ProdController.FindCoreByProdId(m_nProjIdToOpen) + Dim ProjectVM As New ProdFileVM(DbProject) + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.CurrProj, ProjectType.PROJ) Then Return + OpenProject(ProjectVM) + Case Pages.VIEW + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(ProjectManagerVM.CurrProj, ProjectType.PROJ) Then Return + LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63004), EgtMsg(63011), 10) ' Optimization opening ' Loading environment + If Not IsNothing(ProjectManagerVM.CurrProj) AndAlso (m_nProjIdToOpen <> ProjectManagerVM.CurrProj.nProdId OrElse IsNothing(ProjectManagerVM.CurrProd)) Then + Map.refProdManagerVM.SetCurrProd(m_nProjIdToOpen) + ProjectManagerVM.CurrProd.SetReloadProject(True) + Else + ProjectManagerVM.CurrProd.SetReloadProject(False) + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' vado in pagina prod + Map.refMainMenuVM.SetSelPage(Pages.MACHINING, False) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.GOTOPROD) + End Select + m_nProjIdToOpen = GDB_ID.NULL + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "OpenCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenCommand As ICommand + Get + If m_cmdOpen Is Nothing Then + m_cmdOpen = New Command(AddressOf Open) + End If + Return m_cmdOpen + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Open() + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + OpenProject(Nothing) + End Sub + + Friend Sub OpenProject(TempCurrPd As ProdFileVM) + m_TempCurrProd = TempCurrPd + Dim sFilePath As String = "" + ' se la string è vuota + If IsNothing(TempCurrProd) Then + If GetMainPrivateProfileInt(S_GENERAL, K_PROJECTMODE, 0) = 1 Then + Dim OpenProdFileDialogVM As NewOpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta Prod + OpenProdFileDialogVM = New NewOpenProjectFileDialogVM + Dim OpenFile As New NewOpenProjectFileDialogV(Application.Current.MainWindow, OpenProdFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProdFileDialogVM.SelProject.ProdFileVM.sProdPath + m_TempCurrProd = OpenProdFileDialogVM.SelProject.ProdFileVM + Else + Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta file + OpenProjectFileDialogVM = New OpenProjectFileDialogVM + Dim OpenFile As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROD) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + sFilePath = OpenProjectFileDialogVM.SelProject.sProdPath + TempCurrProd = OpenProjectFileDialogVM.SelProject + End If + Else + sFilePath = If(Not IsNothing(TempCurrProd.sProdPath), TempCurrProd.sProdPath, "") + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.OPENPROD, 3, EgtMsg(63004), EgtMsg(63001), 50) ' Optimization opening ' Loading project geometries + If File.Exists(sFilePath) Then + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine)) Then + ' rimuovo il file in apertura dalla lista degli MRU + Map.refProdManagerVM.m_MruFiles.Remove(sFilePath) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Map.refProjManagerVM.NewProject() + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + Else + If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + Map.refProjectVM.SetOptimizePanel_Visibility(True) + Map.refTopPanelVM.UpdateQParameterVisibility() + End If + End If + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(TempCurrProd.nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + MessageBox.Show(EgtMsg(61871)) + Map.refSceneHostVM.MainController.NewProject() + Map.refMainWindowVM.SetTitle("New - EgtBEAMWALL") + End If + ' aggiorno lista possibili nesting + Map.refOptimizePanelVM.UpdateOriginTypeList(EgtGetFirstNameInGroup(GDB_ID.ROOT, "RawParts") <> GDB_ID.NULL) + ' aggiorno visibilità bottone Muovi pezzi + Map.refRawPartManagerVM.UpdateMovePartInRawPartVisibility() + ' resetto eventuale visualizzazione statistiche + Map.refInstrumentPanelVM.ResetStatisticsIsChecked() + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + ' mostro tutti i pezzi + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.MachGroupVMList) AndAlso Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count <= 0 Then Map.refShowBeamPanelVM.ShowAll(True) + NotifyPropertyChanged(NameOf(MruFileNames)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.OPENPROD) + End Sub + +#End Region ' OpenCommand + +#Region "OpenMruFileCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenMruFileCommand As ICommand + Get + If m_cmdOpenMruFile Is Nothing Then + m_cmdOpenMruFile = New Command(AddressOf OpenMruFile) + End If + Return m_cmdOpenMruFile + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Public Sub OpenMruFile(ByVal param As Object) + ' verifico se progetto modificato, e chiedo se salvare + If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + ' ricavo l'Id e il progetto associato per l'apertura di quest'ultimo + Dim PdId As Integer = 0 + Dim arrStrPdId As String() = DirectCast(param, String).Split("|") + Integer.TryParse(arrStrPdId(0), PdId) + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(PdId) + Dim PdFileVM = New ProdFileVM(PdFileM) + OpenProject(PdFileVM) + End Sub + +#End Region ' OpenMruFileCommand + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf SaveCmd) + End If + Return m_cmdSave + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub SaveCmd() + Save(True) + End Sub + + Public Function Save(Optional bShowLoading As Boolean = False) As Boolean + If IsNothing(CurrProd) Then Return False + If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63007), EgtMsg(63012), 70) ' Project saving ' Saving geometry + Dim bOk As Boolean = Map.refSceneHostVM.SaveProject() + If bShowLoading Then LoadingWndHelper.UpdateLoadingWnd(ActiveIds.SAVEPROD, 2, EgtMsg(63013), 70, 100) ' Saving data on Db + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + If Not DbControllers.m_ProdController.UpdateMachGroup(CurrProd.nProdId, MyMachGroupList) And bShowLoading Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return False + End If + ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj + If Map.refCALCPanelVM.IsMachineModified() Then + DbControllers.m_ProdController.UpdateMachine(ProjectManagerVM.CurrProd.nProdId, Map.refCALCPanelVM.SelectedMachine.Name) + ProjectManagerVM.CurrProd.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + ' ciclo sulla lista di ProjId associati + For Each ProjId In ProjectManagerVM.CurrProd.nProjIdList + ' aggiorno la Macchina per i ProjId associati sul DB + DbControllers.m_ProjController.UpdateMachine(ProjId, Map.refCALCPanelVM.SelectedMachine.Name) + ' se uno dei Proj interessati equivale al Proj correntemente aperto setto la Macchina dello stesso + ' (poichè il progetto corrente non viene riaperto e riletto dal DB) + If ProjId = ProjectManagerVM.CurrProj.nProjId Then ProjectManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + Next + Map.refCALCPanelVM.ResetMachineModified() + End If + ' se nuovo progetto + If CurrProd.bIsNew Then + ' resetto stato new + CurrProd.bIsNew = False + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + If bShowLoading Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROD) + Return bOk + End Function + +#End Region ' SaveCommand + +#Region "AddProj" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property AddProj_Command As ICommand + Get + If m_cmdAddProj Is Nothing Then + m_cmdAddProj = New Command(AddressOf AddProj) + End If + Return m_cmdAddProj + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub AddProj() + ' verifico se progetto modificato, e chiedo se salvare + If IsNothing(CurrProd) Then Return + Dim bNewProject As Boolean = False + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProd.sProdDirPath + Dim VerifyResult As MessageBoxResult = MessageBoxResult.None + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() OrElse CurrProd.bIsNew OrElse Map.refCALCPanelVM.IsMachineModified() Then + VerifyResult = MessageBox.Show(EgtMsg(61875), "", If(CurrProd.bIsNew, MessageBoxButton.OKCancel, MessageBoxButton.YesNoCancel), MessageBoxImage.Question) + Select Case VerifyResult + Case MessageBoxResult.Yes, MessageBoxResult.OK + ' salvo proj + Map.refProdManagerVM.Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + EgtResetModified() + OpenProject(CurrProd) + End Select + Else + EgtResetModified() + End If + ' faccio scegliere proj da aggiungere + Dim OpenProjectFileDialogVM As New OpenProjectFileDialogVM + Dim ChooseProdFileDialog As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = ChooseProdFileDialog.EgtShowDialog(ProjectType.PROJ, True) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + If IsNothing(OpenProjectFileDialogVM.SelProject.nProjId) OrElse OpenProjectFileDialogVM.SelProject.nProjId <= 0 Then Return + ' verifico che il proj selezionato non abbia prod + If Not IsNothing(OpenProjectFileDialogVM.SelProject.nProdId) AndAlso OpenProjectFileDialogVM.SelProject.nProdId > 0 Then + ' verifico che non sia uno di quelli gia' collegati a questo Prod + Dim bFound As Boolean = False + For Each nProjId As Integer In CurrProd.nProjIdList + If nProjId = OpenProjectFileDialogVM.SelProject.nProjId Then + bFound = True + Exit For + End If + Next + If bFound Then + MessageBox.Show("Selezionato progetto che fa gia' parte di questa produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Else + MessageBox.Show("Progetto gia' collegato ad una produzione!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + End If + Return + End If + ' verifico che sia associato alla stessa macchina + If OpenProjectFileDialogVM.SelProject.sMachine <> CurrProd.sMachine Then + MessageBox.Show("Progetto per una macchina diversa da quella del progetto corrente!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' inserisco proj nel prod corrente + Dim bOk As Boolean = EgtInsertFile(OpenProjectFileDialogVM.SelProject.sProjPath) + ' lo salvo + bOk = bOk AndAlso Save(False) + If bOk Then + ' riporto aggiunta proj a prod su Db + DbControllers.m_ProdController.AddProj(CurrProd.nProdId, OpenProjectFileDialogVM.SelProject.nProjId) + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' aggiorno CurrProd + Dim PdFileM = DbControllers.m_ProdController.FindCoreByProdId(CurrProd.nProdId) + CurrProd.ProdFileM.SetProjIdList(PdFileM.nProjIdList) + ' ricarico BTLPartList + OpenProject(CurrProd) + End Sub + + +#End Region ' AddProj + +#Region "GoToProj" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property GoToProj_Command As ICommand + Get + If m_cmdGoToProj Is Nothing Then + m_cmdGoToProj = New Command(AddressOf GoToProj) + End If + Return m_cmdGoToProj + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub GoToProj() + If IsNothing(CurrProd) Then Return + ' recupero Proj associati da Db + Dim ProjFileMList As List(Of ProjFileM) = DbControllers.m_ProjController.GetByProdAsc(CurrProd.nProdId) + Dim nProjId As Integer = 0 + ' verifico se salvare progetto corrente + Dim VerifyResult As MessageBoxResult = ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) + If VerifyResult = MessageBoxResult.Cancel Then Return + ' se piu' di uno + If IsNothing(ProjFileMList) Then + Return + ElseIf ProjFileMList.Count = 1 AndAlso ProjFileMList(0).nProjId > 0 Then + LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROJ, 2, EgtMsg(63015), EgtMsg(63011), 10) ' Part viewer opening ' Loading environment + nProjId = ProjFileMList(0).nProjId + ElseIf ProjFileMList.Count > 1 Then + Dim ProjFileVMList As New List(Of ProjectFileVM) + For Each Project In ProjFileMList + ProjFileVMList.Add(New ProjFileVM(Project)) + Next + ' apro finestra di scelta + Dim OpenProjectFileDialogVM As New OpenProjectFileDialogVM + Dim ChooseProjFileDialog As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = ChooseProjFileDialog.EgtShowDialog(ProjectType.PROJ, ProjFileVMList) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + ' se proj selezionato + If Not IsNothing(OpenProjectFileDialogVM.SelProject.nProdId) AndAlso OpenProjectFileDialogVM.SelProject.nProdId > 0 Then + nProjId = OpenProjectFileDialogVM.SelProject.nProjId + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROJ, 2, EgtMsg(63015), EgtMsg(63011), 10) ' Part viewer opening ' Loading environment + Else Return + End If + ' apro progetto proj + Map.refProjManagerVM.SetCurrProj(nProjId) + ' ricarico progetto se il prod e' nullo (quindi e' stato cancellato) + ProjectManagerVM.CurrProj.SetReloadProject(IsNothing(CurrProd) OrElse VerifyResult = MessageBoxResult.No OrElse VerifyResult = MessageBoxResult.None) + ' vado in pagina proj + Map.refMainMenuVM.SetSelPage(Pages.VIEW, False) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.GOTOPROJ) + End Sub + +#End Region ' GoToProj + +#Region "GoToSupervisor" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property GoToSupervisor_Command As ICommand + Get + If m_cmdGoToSupervisor Is Nothing Then + m_cmdGoToSupervisor = New Command(AddressOf GoToSupervisor) + End If + Return m_cmdGoToSupervisor + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub GoToSupervisor() + If IsNothing(CurrProd) Then Return + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + ' apro supervisore + Dim sSupervisorName As String = "EgtBEAMWALL.SupervisorR32" + ' recupero processo del supervisore + Dim localProc As Process() = Process.GetProcessesByName(sSupervisorName) + If localProc.Length > 0 Then + For Each p As Process In localProc + ' porto in primo piano il Supervisor + BringWindowToFront(p.MainWindowHandle) + Exit For + Next + Else + Dim sSupervisorPath As String = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory) & "\" & sSupervisorName & ".exe" + Try + Process.Start(sSupervisorPath, "1 " & CurrProd.nProdId) + Catch ex As Exception + EgtOutLog("Error: impossible starting supervisor from path " & sSupervisorPath) + End Try + End If + ' mando richiesta di apertura progetto in supervisore + DbControllers.m_StatusMapController.UpdateAction(DbControllers.m_SupervisorId, ProjectManagerVM.CurrProd.nProdId, ProjectManagerVM.CurrProd.nProdId, StatusMapItemType.Comm, StatusMapOpType.ChangeProdInSupervisorRequest, "") + Else + MessageBox.Show("Supervisor is not available for this machine!", "Error", MessageBoxButton.OK, MessageBoxImage.Error) + End If + End Sub + +#End Region ' GoToSupervisor + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml new file mode 100644 index 00000000..92fc9655 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml.vb new file mode 100644 index 00000000..816dd5c5 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProdProjManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerVM.vb b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerVM.vb new file mode 100644 index 00000000..710dab2f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProdProjManager/ProdProjManagerVM.vb @@ -0,0 +1,43 @@ +Imports EgtBEAMWALL.Core.ConstGen +Imports EgtWPFLib5 + +Public Class ProdProjManagerVM + Inherits VMBase + +#Region "FIELD & PROPERTIES" + + ' Selezione Tab Prod / Proj + Private m_SelProdProj As ProdProj + Public Property SelProdProj As Integer + Get + Return m_SelProdProj + End Get + Set(value As Integer) + m_SelProdProj = value + NotifyPropertyChanged(NameOf(SelProdProj)) + End Set + End Property + + Public ReadOnly Property PartManager_Visibility As Visibility + Get + Return Map.refProjectVM.PartManager_Visibility + End Get + End Property + + Public ReadOnly Property FreeContourManager_Visibility As Visibility + Get + Return Map.refProjectVM.FreeContourManager_Visibility + End Get + End Property + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + Map.SetRefProdProjManagerVM(Me) + End Sub + +#End Region ' Constructor + +End Class diff --git a/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml new file mode 100644 index 00000000..33006d12 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml.vb new file mode 100644 index 00000000..74e0c1c0 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProjManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerVM.vb new file mode 100644 index 00000000..d408dbb6 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjManager/ProjManagerVM.vb @@ -0,0 +1,1736 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class ProjManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + ' Nome file NGE con i pezzi selezionati per effettuare UpdateBTL + Friend Const UPDATEBTL_NGE As String = "UpdateBTL.nge" + + Private m_ProjManager_IsEnabled As Boolean = True + Public ReadOnly Property ProjManager_IsEnabled As Boolean + Get + Return m_ProjManager_IsEnabled + End Get + End Property + + Friend Property CurrProj As ProjFileVM + Get + Return ProjectManagerVM.CurrProj + End Get + Set(value As ProjFileVM) + ProjectManagerVM.CurrProj = value + End Set + End Property + + Private m_TempCurrProj As ProjFileVM + Friend Property TempCurrProj As ProjFileVM + Get + Return m_TempCurrProj + End Get + Set(value As ProjFileVM) + m_TempCurrProj = value + End Set + End Property + + Private m_IsEnabled As Boolean + Public Property IsEnabled As Boolean + Get + Return m_IsEnabled + End Get + Set(value As Boolean) + If value <> m_IsEnabled Then + m_IsEnabled = value + NotifyPropertyChanged(NameOf(IsEnabled)) + End If + End Set + End Property + + ' indice ultimo progetto + Private m_nLastProjId As Integer + Friend ReadOnly Property nLastProjId As Integer + Get + Return m_nLastProjId + End Get + End Property + + Public ReadOnly Property nProjType As BWType + Get + Return If(Not IsNothing(CurrProj), CurrProj.nType, BWType.NULL) + End Get + End Property + + Friend m_MruFiles As New MruList + Public ReadOnly Property MruFileNames As ObservableCollection(Of String) + Get + Dim IdAndBTLFileNames As New ObservableCollection(Of String) + For Each FileName In m_MruFiles.FileNames.ToList() + Dim PjId As Integer = 0 + Dim sPjId As String = Path.GetFileNameWithoutExtension(DirectCast(FileName, String).Replace("__", "_")) + Integer.TryParse(sPjId, PjId) + Dim PjFileM = DbControllers.m_ProjController.FindByProjIdConv(PjId) + If IsNothing(PjFileM) Then + m_MruFiles.Remove(FileName) + Else + IdAndBTLFileNames.Add(sPjId & " | " & PjFileM.sBTLFileName) + End If + Next + Return IdAndBTLFileNames + End Get + End Property + + Private m_UpdateBTL_Visibility As Visibility = Visibility.Collapsed + Public Property UpdateBTL_Visibility As Visibility + Get + Return m_UpdateBTL_Visibility + End Get + Set(value As Visibility) + m_UpdateBTL_Visibility = value + End Set + End Property + + Public ReadOnly Property GoToProd_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE, Visibility.Collapsed, Visibility.Visible) + End Get + End Property + + ' Definizione comandi + Private m_cmdNew As ICommand + Private m_cmdOpen As ICommand + Private m_cmdOpenMruFile As ICommand + Private m_cmdSave As ICommand + Private m_cmdSaveAs As ICommand + Private m_cmdExport As ICommand + Private m_cmdDxfOut As ICommand + Private m_cmdImportBTL As ICommand + Private m_cmdUpdateBTL As ICommand + Private m_cmdImportProject As ICommand + Private m_cmdExportProject As ICommand + Private m_cmdGoToProd As ICommand + Private m_cmdSendFeedback As ICommand + +#Region "ToolTip" + + 'Proprietà ToolTip + Public ReadOnly Property NewToolTip As String + Get + Return EgtMsg(30501) + End Get + End Property + Public ReadOnly Property OpenToolTip As String + Get + Return EgtMsg(30502) + End Get + End Property + Public ReadOnly Property SaveToolTip As String + Get + Return EgtMsg(30503) + End Get + End Property + Public ReadOnly Property SaveAsToolTip As String + Get + Return EgtMsg(30504) + End Get + End Property + Public ReadOnly Property InsertToolTip As String + Get + Return EgtMsg(30505) + End Get + End Property + Public ReadOnly Property ImportBTL_ToolTip As String + Get + Return EgtMsg(61840) + End Get + End Property + Public ReadOnly Property UpdateBTL_ToolTip As String + Get + Return EgtMsg(61834) + End Get + End Property + Public ReadOnly Property ExportProject_ToolTip As String + Get + Return EgtMsg(61838) + End Get + End Property + Public ReadOnly Property ImportProject_ToolTip As String + Get + Return EgtMsg(61839) + End Get + End Property + Public ReadOnly Property GoToProd_ToolTip As String + Get + Return EgtMsg(61835) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjManagerVM(Me) + ' Leggo ultimo indice di progetto + m_nLastProjId = GetMainPrivateProfileInt(S_GENERAL, K_PROJSINDEX, 1) + ' Impostazioni MruLists + m_MruFiles.Init(S_MRUPROJFILES, 8) + ' leggo attivazione update btl + If GetMainPrivateProfileInt(S_GENERAL, K_UPDATEBTL, 0) > 0 Then + UpdateBTL_Visibility = Visibility.Visible + End If + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub NewProdFromProj() + ' inizializzo nuovo progetto + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + Map.refProdManagerVM.InitNewProject(CurrProj.nProjId, nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, CurrProj.nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, CurrProj.sMachine) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim bOk = False + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If bOk Then + ' aggiorno path proj + Map.refProjManagerVM.UpdateCurrProj() + ' imposto currprod + Map.refProdManagerVM.SetCurrProd(nProdId) + ' imposto TempCurrProd + Map.refProdManagerVM.TempCurrProd = ProjectManagerVM.CurrProd + ' setto flag nuovo progetto in prod + ProjectManagerVM.CurrProd.bIsNew = True + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + End Sub + + Private Function InitNewProject(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As Machine) As Boolean + ' se non ho ricevuto numero progetto da sovrascrivere + If nProjId = 0 Then + ' richiedo indice nuovo progetto + nProjId = DbControllers.m_ProjController.GetNextIndex(Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + ' salvo data creazione progetto + DbControllers.m_ProjController.Update(New ProjModel() With {.ProjId = nProjId, + .DtCreated = DateTime.Now(), + .PType = nType, + .Machine = If(Not IsNothing(Machine), Machine.Name, Nothing)}) + If nProjId <= 0 Then Return False + sProjectDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + ' creo cartella nuovo progetto + If Not Directory.Exists(sProjectDir) Then + Directory.CreateDirectory(sProjectDir) + Else + Dim di As System.IO.DirectoryInfo = New DirectoryInfo(sProjectDir) + For Each file As FileInfo In di.EnumerateFiles() + file.Delete() + Next + For Each dir As DirectoryInfo In di.EnumerateDirectories() + dir.Delete(True) + Next + End If + Return True + End Function + + Private Function UpdateProjData(nProjId As Integer, nProdId As Integer, dtExportDate As DateTime, + sListName As String) + Return DbControllers.m_ProjController.Update(New ProjModel() With {.ProjId = nProjId, + .DtExported = dtExportDate, + .ListName = sListName}) + End Function + + ''' + ''' Aggiornamento descrizione del PROJ con nuova colonna + ''' + ''' + ''' + ''' + Private Function UpdateDescription(nProjId As Integer, Description As String) + Return DbControllers.m_ProjController.UpdateDescription(nProjId, Description) + End Function + + Public Function SetCurrProj(nProjId As Integer) As Boolean + Return ProjectManagerVM.SetCurrProj(nProjId) + End Function + + Public Function UpdateCurrProj() As Boolean + Return SetCurrProj(CurrProj.nProjId) + End Function + + Public Sub ResetCurrProj() + CurrProj = Nothing + End Sub + + Friend Sub SetProjManagerIsEnabled(bIsEnabled As Boolean) + m_ProjManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(ProjManager_IsEnabled)) + End Sub + + Private Sub ReloadBTLStructure() + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(ProjectManagerVM.CurrProj.nProjId)) + ' verifico se volume pezzi calcolato + Dim bIsCalculated As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If BTLPart.BTLPartM.dVolume > 0 Then Continue For + bIsCalculated = True + BTLPart.CalcBTLPartVolume() + Next + If bIsCalculated Then + Dim CurrProject As String = "" + EgtGetCurrFilePath(CurrProject) + EgtSaveFile(CurrProject, NGE.CMPTEXT) + End If + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "New" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property New_Command As ICommand + Get + If m_cmdNew Is Nothing Then + m_cmdNew = New Command(AddressOf NewProject) + End If + Return m_cmdNew + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub NewProject() + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + ' se si ha una sola macchina disponibile (non BOTH) setto il nuovo porgetto a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il nuovo progetto + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New ProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + ' creo nuovo progetto + If Map.refSceneHostVM.MainController.NewProject() Then + ' inizializzo nuovo progetto + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + InitNewProject(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nProjId + ' creo gruppo BTLinfo + Dim nBTLInfoLayer As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nBTLInfoLayer, BTLINFO) + EgtSetLevel(nBTLInfoLayer, GDB_LV.SYSTEM) + Map.refProjectVM.BTLStructureVM.BTLStructureM.UpdateBTLInfoLayer() + ' scrivo info proj e tipo su layer BtlInfo + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, nProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, nType) + ' salvo il progetto + If EgtSaveFile(sProjFileName, NGE.CMPTEXT) Then + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + Map.refPartManagerVM.LockVisibilityUpdate() + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + DbControllers.m_ProjController.UpdateInfo(nProjId, "Hand made", "Hand made", "", Date.MinValue, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + End If + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Else + MessageBox.Show(EgtMsg(61876)) + End If + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + End Sub + +#End Region ' New + +#Region "OpenCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenCommand As ICommand + Get + If m_cmdOpen Is Nothing Then + m_cmdOpen = New Command(AddressOf Open) + End If + Return m_cmdOpen + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Open() + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + OpenProject(Nothing) + End Sub + + Friend Sub OpenProject(ReceivedCurrProj As ProjFileVM) + Dim bStart As Boolean = IsNothing(m_TempCurrProj) + m_TempCurrProj = ReceivedCurrProj + ' se la stringa è vuota + If IsNothing(TempCurrProj) Then + If GetMainPrivateProfileInt(S_GENERAL, K_PROJECTMODE, 0) = 1 Then + Dim OpenProdFileDialogVM As NewOpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta Prod + OpenProdFileDialogVM = New NewOpenProjectFileDialogVM + Dim OpenFile As New NewOpenProjectFileDialogV(Application.Current.MainWindow, OpenProdFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROJ) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + Dim TempProd As ProdItem = OpenProdFileDialogVM.SelProject + If TempProd.ProjFileList.Count > 1 Then + ' apro dialogo di scelta Proj + Dim OpenProjFileDialogVM As OpenProjectFileDialogVM = Nothing + OpenProjFileDialogVM = New OpenProjectFileDialogVM + Dim ProjOpenFile As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjFileDialogVM) + Dim ProjDialogResult As Boolean? = ProjOpenFile.EgtShowDialog(ProjectType.PROJ, OpenProdFileDialogVM.SelProject.ProjFileList) + If IsNothing(DialogResult) OrElse Not ProjDialogResult Then Return + TempCurrProj = OpenProjFileDialogVM.SelProject + ElseIf TempProd.ProjFileList.Count = 1 Then + TempCurrProj = OpenProdFileDialogVM.SelProject.ProjFileList(0) + Else Return + End If + Else + Dim OpenProjectFileDialogVM As OpenProjectFileDialogVM = Nothing + ' apro dialogo di scelta file + OpenProjectFileDialogVM = New OpenProjectFileDialogVM + Dim OpenFile As New OpenProjectFileDialogV(Application.Current.MainWindow, OpenProjectFileDialogVM) + Dim DialogResult As Boolean? = OpenFile.EgtShowDialog(ProjectType.PROJ) + If IsNothing(DialogResult) OrElse Not DialogResult Then Return + TempCurrProj = OpenProjectFileDialogVM.SelProject + End If + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.OPENPROJ, 3, EgtMsg(63000), EgtMsg(63001), 50) ' Project opening ' Loading project geometries + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = TempCurrProj.nProjId + ' se esiste prod prendo quello, altrimenti proj + Dim sFilePath As String = "" + If Not IsNothing(TempCurrProj.nProdId) AndAlso TempCurrProj.nProdId > 0 Then + sFilePath = TempCurrProj.sProdPath + Else + sFilePath = TempCurrProj.sProjPath + End If + SectionXMaterial.SetType(TempCurrProj.nType) + Core.ViewPanelVM.UpdateBWType(TempCurrProj.nType) + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(TempCurrProj.nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProjManagerVM.TempCurrProj.sMachine)) Then + ' rimuovo il file in apertura dalla lista degli MRU + Dim ProjId As Integer = ProjectManagerVM.nLoadingProjId + Dim PjFileVM As ProjFileVM + If Not IsNothing(ProjId) AndAlso ProjId <> 0 Then + PjFileVM = New ProjFileVM(DbControllers.m_ProjController.FindByProjIdConv(ProjId)) + If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Remove(PjFileVM.sProjPath) + End If + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + If bStart Then Map.refProjManagerVM.NewProject() + Else + If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refPartManagerVM.LockVisibilityUpdate() + End If + End If + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.OPENPROJ) + End Sub + +#End Region ' OpenCommand + +#Region "OpenMruFileCommand" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property OpenMruFileCommand As ICommand + Get + If m_cmdOpenMruFile Is Nothing Then + m_cmdOpenMruFile = New Command(AddressOf OpenMruFile) + End If + Return m_cmdOpenMruFile + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Public Sub OpenMruFile(ByVal param As Object) + ' verifico se progetto modificato, e chiedo se salvare + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + ' ricavo l'Id e il progetto associato per l'apertura di quest'ultimo + Dim PjId As Integer = 0 + Dim arrStrPjId As String() = DirectCast(param, String).Split("|") + Integer.TryParse(arrStrPjId(0), PjId) + Dim PjFileM = DbControllers.m_ProjController.FindByProjIdConv(PjId) + Dim PjFileVM = New ProjFileVM(PjFileM) + OpenProject(PjFileVM) + End Sub + +#End Region ' OpenMruFileCommand + +#Region "SaveCommand" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property SaveCommand As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf SaveCmd) + End If + Return m_cmdSave + End Get + End Property + + Public Sub SaveCmd() + Save(True) + End Sub + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub Save(Optional bShowLoading As Boolean = False) + If IsNothing(CurrProj) Then Return + Dim bShowBuilding As Boolean = False + Dim bShowSolid As Boolean = False + If bShowLoading Then LoadingWndHelper.OpenLoadingWnd(ActiveIds.SAVEPROJ, 1, EgtMsg(63007), "", 100) ' Project saving + ' se vista tutti i pezzi + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, True, False) + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = CurrProj.nProjId + Map.refSceneHostVM.SaveProject() + Map.refMainWindowVM.SetTitle(CurrProj.nProjId.ToString("0000") & " - " & CurrProj.sBTLFileName & " - EgtBEAMWALL") + ' aggiorno BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(CurrProj.nProjId, Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList) + ' se nuovo progetto + If CurrProj.bIsNew Then + ' resetto stato new + DbControllers.m_ProjController.ResetNew(CurrProj.nProjId) + CurrProj.bIsNew = False + End If + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + ' verifico se Reset Macchina modificato e nel caso aggiorno DB e CurrProj + If Map.refCALCPanelVM.IsMachineModified() Then + DbControllers.m_ProjController.UpdateMachine(ProjectManagerVM.CurrProj.nProjId, Map.refCALCPanelVM.SelectedMachine.Name) + ProjectManagerVM.CurrProj.SetMachine(Map.refCALCPanelVM.SelectedMachine.Name) + ' se esiste un Prod associato al Proj corrente aggiorno anche questo Prod nel DB + If ProjectManagerVM.CurrProj.nProdId > 0 Then DbControllers.m_ProdController.UpdateMachine(ProjectManagerVM.CurrProj.nProdId, + Map.refCALCPanelVM.SelectedMachine.Name) + Map.refCALCPanelVM.ResetMachineModified() + End If + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + NotifyPropertyChanged(NameOf(MruFileNames)) + If bShowLoading Then LoadingWndHelper.CloseLoadingWnd(ActiveIds.SAVEPROJ) + End Sub + +#End Region ' SaveCommand + +#Region "ImportBTL" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportBTL_Command As ICommand + Get + If m_cmdImportBTL Is Nothing Then + m_cmdImportBTL = New Command(AddressOf ImportBTL) + End If + Return m_cmdImportBTL + End Get + End Property + + ''' + ''' Execute the ImportBTL. This method is invoked by the ImportBTLCommand. + ''' + Public Sub ImportBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + Return + End If + End If + Dim nProjId As Integer = 0 + Dim sProjDir As String = "" + ' verifico se non e' tra i BTL gia' importati + Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sFile) + Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(sBTLFileName) + If nAlreadyImported > 0 Then + ' recupero progetto con lo stesso nome + Dim ToDeleteProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nAlreadyImported) + ' se esiste gia' un'ottimizzazione + If ToDeleteProj.nProdId > 0 Then + Select Case MessageBox.Show(EgtMsg(61942), "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) ' BTL file already imported and optimized. Do you want to import it again? + Case MessageBoxResult.Yes + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.No + Return + End Select + Else + ' se non ha ottimizazione, chiedo se sovrascriverlo + Select Case MessageBox.Show(EgtMsg(61943), "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Information) ' BTL file already imported. Do you want to overwrite it? + Case MessageBoxResult.Yes + ' cancello BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nAlreadyImported, New List(Of BTLPartM)) + ' cancello nome BTL + DbControllers.m_ProjController.UpdateInfo(nAlreadyImported, DateTime.Now.ToString(), DateTime.Now.ToString(), "", DateTime.MinValue, BWType.NULL, "") + nProjId = nAlreadyImported + sProjDir = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + Case MessageBoxResult.No + ' lo importo, quindi non devo fare nulla + Case MessageBoxResult.Cancel + Return + End Select + End If + End If + ' se si ha una sola macchina disponibile (non BOTH) setto il progetto importato a quella macchina e al tipo progetto associato + ' altrimenti apro il dialog per scegliere la macchina e il tipo progetto a cui settare il progetto importato + Dim Machine As Machine = Nothing + Dim nType As BWType = BWType.NULL + Dim ProjectTypeWndVM As New ProjectTypeWndVM() + If ProjectTypeWndVM.MachineList.Count = 1 AndAlso DirectCast(ProjectTypeWndVM.SelMachine, MyMachine).nType <> MachineType.BOTH Then + Machine = ProjectTypeWndVM.SelMachine + nType = DirectCast(Machine, MyMachine).nType + Else + Dim ProjectTypeWnd As New ProjectTypeWndV(Application.Current.MainWindow, ProjectTypeWndVM) + If ProjectTypeWnd.ShowDialog() Then + Machine = ProjectTypeWndVM.SelMachine + nType = ProjectTypeWndVM.nSelType + Else + Return + End If + End If + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' inizializzo nuovo progetto + InitNewProject(nProjId, sProjDir, nType, Machine) + SetCurrProj(nProjId) + ' imposto il tipo di parametri Q da utilizzare + BTLIniFile.m_nBTLBWType = nType + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nProjId + ' copio file BTL + Dim sBtlCopyPath As String = sProjDir & "\" & Path.GetFileName(sFile) + Dim bOk = False + Try + File.Copy(sFile, sBtlCopyPath, True) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + ' disattivo temporaneamente bottone assemblato per non prendere il riferimento sbagliato durante importazione + Dim bAssembly As Boolean = Map.refShowBeamPanelVM.ShowBuilding_IsChecked + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = False + ' importo file + If bOk Then + bOk = Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) + End If + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk OrElse bFirstPart Then + ' salvo path di importazione + WriteMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, Path.GetDirectoryName(sFile)) + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) + SectionXMaterial.SetType(nType) + Core.ViewPanelVM.UpdateBWType(nType) + ' imposto flag secondo tipo di progetto (travi o pareti) + Dim sBTLFlag As String = If(nType = Core.ConstBeam.BWType.BEAM, K_BTLFLAG, K_WALLBTLFLAG) + Dim nFlag As Integer = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + EgtBeamSetFlag(nFlag) + Else + EgtOutLog("Errore nell'importazione BTL") + End If + If bOk Then + ' aggiorno Db + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nProjId) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + For Each Wall In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Wall.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + Next + End If + ' calcolo volumi pezzi + For Each Part In Map.refProjectVM.BTLStructureVM.BTLPartVMList + Part.CalcBTLPartVolume() + Next + Map.refProjectVM.SetOptimizePanel_Visibility(Map.refProjectVM.BTLStructureVM.nPROJTYPE = BWType.WALL AndAlso Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NESTING_AUTO)) + Map.refPartManagerVM.LockVisibilityUpdate() + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63006), 70, 100) ' Loading graphics + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + Else + Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' elimino da Db + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nProjId, False) + End If + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + ' gestisco log di importazione + ManageImportLog(nProjId, sProjDir) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + End Sub + + Private Sub ManageImportLog(nProjId As Integer, sProjDir As String) + Dim LogFile As New List(Of String) + Using FileStream As New FileStream(Map.refMainWindowVM.MainWindowM.sLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) + Dim StreamReader As New StreamReader(FileStream) + Dim Line As String = StreamReader.ReadLine() + While Not StreamReader.EndOfStream + Line = StreamReader.ReadLine() + LogFile.Add(Line) + End While + StreamReader.Close() + End Using + If LogFile.Count > 0 Then + ' recupero ultima occorrenza di import + Dim sLastImport As String = LogFile.LastOrDefault(Function(x) x.Contains("ImportBtl")) + ' verifico linee successive + Dim nLastImportIndex As Integer = -1 + If Not String.IsNullOrWhiteSpace(sLastImport) Then + nLastImportIndex = LogFile.IndexOf(sLastImport) + End If + Dim sImportMessage As String = sLastImport & Environment.NewLine + Dim sImportLog As New List(Of String)({sLastImport}) + If nLastImportIndex > 0 Then + Dim bGlobalError As Boolean = False + ' ciclo sulle righe successive + For Index = nLastImportIndex + 1 To LogFile.Count - 1 + Dim sLogLine As String = LogFile(Index).Trim() + ' verifico se fanno parte dell'import + Dim bStartWithError As Boolean = sLogLine.StartsWith("Error") + Dim bStartWithInfo As Boolean = sLogLine.StartsWith("Info") + If Not bStartWithError And Not bStartWithInfo Then Exit For + If bStartWithError Then + If Not bGlobalError Then bGlobalError = True + sImportMessage &= sLogLine & Environment.NewLine + End If + sImportLog.Add(sLogLine) + Next + ' salvo file ImportLog nel progetto + Try + File.WriteAllLines(sProjDir & "\" & nProjId.ToString("0000") & "-ImportLog.txt", sImportLog) + Catch ex As Exception + ' + End Try + ' se almeno un errore, mostro log + If bGlobalError Then + MessageBox.Show(Application.Current.MainWindow, sImportMessage, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If + End If + End If + End Sub + +#End Region ' ImportBTL + +#Region "UpdateBTL" + + ''' + ''' Returns a command that do UpdateBTL. + ''' + Public ReadOnly Property UpdateBTL_Command As ICommand + Get + If m_cmdUpdateBTL Is Nothing Then + m_cmdUpdateBTL = New Command(AddressOf UpdateBTL) + End If + Return m_cmdUpdateBTL + End Get + End Property + + ''' + ''' Execute the UpdateBTL. This method is invoked by the UpdateBTLCommand. + ''' + Public Sub UpdateBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If IsNothing(CurrProj) Then Return + ' verifico se progetto modificato, e chiedo se salvare + If CurrProj.bIsNew Or EgtGetModified() OrElse Map.refCALCPanelVM.IsMachineModified() Then + Select Case MessageBox.Show(EgtMsg(61877), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Case MessageBoxResult.Yes + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + MessageBox.Show(EgtMsg(61892), "", MessageBoxButton.OK, MessageBoxImage.Exclamation) + Return + End Select + End If + + ' se vista tutti i pezzi + Dim bShowBuilding As Boolean = False + Dim bShowSolid As Boolean = False + Dim nSelPartId As Integer = GDB_ID.NULL + Configuration.ShowAllPieces(bShowBuilding, bShowSolid, nSelPartId, True) + + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, "", sDir) + If bWithDlg Then + ' apro finestra scelta file + Dim BTLDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".btl", + .Filter = "BTL (*.btl)|*.btl" & + "|BTLX (*.btlx)|*.btlx", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If BTLDlg.ShowDialog() Then + sFile = BTLDlg.FileName + Else + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + ' SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + End If + ' salvo lista pezzi del progetto originale + Dim OrigPartlist As ObservableCollection(Of BTLPartVM) = Map.refProjectVM.BTLStructureVM.BTLPartVMList + ' creo un nuovo contesto su cui aprire il file BTL + Dim nCurrCtx As Integer = EgtGetCurrentContext() + Dim nTempCtx As Integer = EgtInitContext() + + ' setto il flag per inizializzazione gestore travi e pareti per importare progetto + Dim nFlag As Integer + Dim sBTLFlag As String + If Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then + sBTLFlag = K_BTLFLAG + Else + sBTLFlag = K_WALLBTLFLAG + End If + nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + + ' inizializzo gestore travi e pareti + EgtInitBeamMgr(nFlag) + + Dim bOk As Boolean = nTempCtx <> 0 + If bOk Then + ' importo il file BTL + bOk = bOk AndAlso Map.refSceneHostVM.MainController.ImportProject(sFile, False) + ' carico la lista dei Part importati e rimuovo i parametri generali del BTL + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + Dim BtlInfoId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim PartToUpdateList As New List(Of BTLPartToUpdate) + + ' cerco tra i layer BTLInfo + While BtlInfoId <> GDB_ID.NULL + ' verifico se il layer appartiene al ProjId + Dim nBTLInfoLayerProjId As Integer + EgtGetInfo(BtlInfoId, BTL_PRT_PROJ, nBTLInfoLayerProjId) + ' carico la lista con i PDN dei pezzi del BTL importato + Dim nPDN As Integer = 0 + Dim sNAM As String = String.Empty + Dim nUID As Integer = 0 + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + Dim UIDList As New List(Of Integer) + Dim nIndUID As Integer = 1 + ' se devo filtrare un progetto + If nBTLInfoLayerProjId > 0 Then + ' verifico se il pezzo appartiene al ProjId + Dim nPartProjId As Integer + EgtGetInfo(nPartId, BTL_PRT_PROJ, nPartProjId) + If nPartProjId = nBTLInfoLayerProjId Then + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nIndUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + Else + ' altrimenti carico tutti + EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) + EgtGetInfo(nPartId, BTL_PRT_NAM, sNAM) + While EgtGetInfo(nPartId, BTL_PRT_UID & nUID, nUID) + UIDList.Add(nUID) + nIndUID += 1 + End While + PartToUpdateList.Add(New BTLPartToUpdate(nPartId, nPDN, sNAM, UIDList, OrigPartlist.Any(Function(x) x.nPDN = nPDN))) + End If + nPartId = EgtGetNextPart(nPartId) + End While + EgtErase(BtlInfoId) + BtlInfoId = EgtGetNextName(BtlInfoId, BTLINFO) + End While + + ' costruisco un dizionario con gli id dei sottonodi di AsseBase del BTL importato e il valore dell'Info N degli stessi + Dim AsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + Dim nAsseBaseSubNodeId As Integer = EgtGetFirstInGroup(AsseBaseId) + Dim sAsseBaseUID As String = String.Empty + Dim nAsseBaseUID As Integer = 0 + While nAsseBaseSubNodeId <> GDB_ID.NULL + If EgtGetInfo(nAsseBaseSubNodeId, BTL_ASSEBASE_N, sAsseBaseUID) Then + sAsseBaseUID = sAsseBaseUID.Remove(0, 4) + Integer.TryParse(sAsseBaseUID, nAsseBaseUID) + AsseBaseSubNodeDict.Add(nAsseBaseSubNodeId, sAsseBaseUID) + End If + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End While + + ' salvo il file BTL da cui abbiamo rimosso BtlInfo come file NGE + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + Dim bAppend As Boolean = False + ' se UserLevel > 5 e fra i Part importati ce ne sta almeno 1 con PDN uguale ai Part già presenti + ' apro la finestra per chiedere se si vuole aggiornare o accodare + If Map.refMainWindowVM.MainWindowM.nUserLevel > 5 Then + For Each PartToUpdate In PartToUpdateList + Dim bExitFor As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList + If PartToUpdate.nPDN = BTLPart.nPDN Then + Dim UpdateOrAppendWndVM As New UpdateOrAppendWndVM() + Dim UpdateOrAppendWnd As New UpdateOrAppendWndV(Application.Current.MainWindow, UpdateOrAppendWndVM) + If Not UpdateOrAppendWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + 'SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + ' salvo lo stato del bottone per accodare + bAppend = UpdateOrAppendWndVM.AppendIsChecked + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + End If + + ' se selezionato Append li accodo tutti + If bAppend Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto iniziale + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = 0 + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) + b3Parts.Add(b3Part) + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' inserisco il file importato nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = EgtGetNextPart(nLastProjPartId) + Dim bFirstLoop As Boolean = True + Dim LastPartMaxY As Double + Dim nIncrPDN As Integer = 0 + While nAddedPartId <> GDB_ID.NULL + ' incremento il PDN del Part aggiunto rispetto al PDN maggiore attualmente presente + EgtSetInfo(nAddedPartId, BTL_PRT_PDN, Map.refProjectVM.BTLStructureVM.BTLStructureM.NewPDN() + nIncrPDN) + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, If(bFirstLoop, b3Parts.Max.y, LastPartMaxY - b3Part.Min.y) + 500, 0)) + bFirstLoop = False + ' ricaviamo il box globale del part appena spostato, salviamo la sua Y massima e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + LastPartMaxY = b3Part.Max.y + b3Parts.Add(b3Part) + nAddedPartId = EgtGetNextPart(nAddedPartId) + nIncrPDN += 1 + End While + ' aggiungo i part inseriti alla lista + Dim nNewPartId As Integer = EgtGetNextPart(nLastProjPartId) + While nNewPartId <> GDB_ID.NULL + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nNewPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nNewPartId = EgtGetNextPart(nNewPartId) + End While + + ' elimino gli AsseBase del progetto importato + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim CurrAsseBaseId = AsseBaseId + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + If Not AsseBaseIdList.Contains(CurrAsseBaseId) Then EgtErase(CurrAsseBaseId) + End While + + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + Else + ' altrimenti apro la finestra con l'elenco dei Part da checkare per l'inserimento nel progetto (unica strada se UserLevel <= 5), + ' che prevederà la sovrascrittura di quelli già presenti e l'aggiunta di quelli nuovi + Dim UpdateBTLWndVM As New UpdateBTLWndVM(PartToUpdateList) + Dim UpdateBTLWnd As New UpdateBTLWndV(Application.Current.MainWindow, UpdateBTLWndVM) + If Not UpdateBTLWnd.ShowDialog() Then + ' torno sul contesto corrente + EgtSetCurrentContext(nCurrCtx) + EgtDeleteContext(nTempCtx) + ' rileggo la struttura BTL + ReloadBTLStructure() + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + 'SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + Return + End If + If UpdateBTLWndVM.BTLPartList.Count > 0 Then + ' sovrascrivo i Part nel progetto aperto con i Part checkati nella lista + Dim BTLPartToOverwriteWithList As New ObservableCollection(Of BTLPartToUpdate) + ' Elimino dal TempCtx i Part non checkati + For Each BTLPartToOverwriteWith In UpdateBTLWndVM.BTLPartList + If BTLPartToOverwriteWith.bInsert Then + BTLPartToOverwriteWithList.Add(BTLPartToOverwriteWith) + Else + ' elimino pezzo copia + Dim nCurrPartId = EgtGetCurrPart() + EgtErase(BTLPartToOverwriteWith.nPartId) + nCurrPartId = EgtGetCurrPart() + End If + Next + + ' costruisco un nuovo dizionario dei sottonodi di AsseBase contenente solo quelli corrispondenti agli UID contenuti + ' nei soli Part checkati del BTL nella finestra UpdateBTLWnd + Dim NewAsseBaseSubNodeDict As New Dictionary(Of Integer, Integer) + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + For Each BTLPartToOverwriteWithItem In BTLPartToOverwriteWithList + Dim bExitFor As Boolean = False + For Each UIDItem In BTLPartToOverwriteWithItem.UIDList + If AsseBaseSubNodeItem.Value = UIDItem Then + NewAsseBaseSubNodeDict.Add(AsseBaseSubNodeItem.Key, AsseBaseSubNodeItem.Value) + bExitFor = True + Exit For + End If + Next + If bExitFor Then Exit For + Next + Next + ' confronto la lista appena costruita con quella originale ed elimino dal contesto i sottonodi con i valori non più presenti + For Each AsseBaseSubNodeItem In AsseBaseSubNodeDict + If Not NewAsseBaseSubNodeDict.ContainsValue(AsseBaseSubNodeItem.Value) Then + EgtErase(AsseBaseSubNodeItem.Key) + End If + Next + + ' salvo il file NGE inserito a cui abbiamo rimosso i Part non checkati e gli AsseBase non più associati + EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE, NGE.CMPTEXT) + + ' torno sul contesto corrente + EgtDeleteContext(nTempCtx) + EgtSetCurrentContext(nCurrCtx) + + ' rileggo la struttura BTL del progetto corrente per non avere quella del contesto temporaneo ancora presente + ReloadBTLStructure() + + ' elimino i pezzi da sovrascrivere nel progetto corrente + Configuration.DeletePieces(UpdateBTLWndVM.BTLPartList) + + ' salvo gli id degli AsseBase presenti nel progetto corrente + Dim AsseBaseIdList As New List(Of Integer) + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + AsseBaseIdList.Add(AsseBaseId) + ' elimino i sottonodi di AsseBase da sovrascrivere + AsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + nAsseBaseSubNodeId = EgtGetFirstInGroup(AsseBaseId) + While nAsseBaseSubNodeId <> GDB_ID.NULL + If NewAsseBaseSubNodeDict.ContainsKey(nAsseBaseSubNodeId) Then + ' se sottonodo da cancellare salvo il suo id e ricavo il seguente prima di cancellarlo + Dim nCurrAsseBaseSubNodeId = nAsseBaseSubNodeId + nAsseBaseSubNodeId = EgtGetNext(nCurrAsseBaseSubNodeId) + bOk = EgtErase(nCurrAsseBaseSubNodeId) + Else + ' altrimenti ricavo il seguente e basta + nAsseBaseSubNodeId = EgtGetNext(nAsseBaseSubNodeId) + End If + End While + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + + ' calcolo BBox globale del progetto corrente + Dim b3Parts As New BBox3d + Dim nProjPartId As Integer = EgtGetFirstPart() + Dim nLastProjPartId As Integer = GDB_ID.NULL + While nProjPartId <> GDB_ID.NULL + Dim b3Part As New BBox3d + If EgtGetBBoxGlob(nProjPartId, GDB_BB.ONLY_VISIBLE, b3Part) Then + b3Parts.Add(b3Part) + End If + nLastProjPartId = nProjPartId + nProjPartId = EgtGetNextPart(nProjPartId) + End While + ' se sovrascrivo tutti e bbox esce nullo + If b3Parts.IsEmpty Then + b3Parts = New BBox3d(Point3d.ORIG) + End If + + ' inserisco il file NGE (ricavato dal BTL importato) nel progetto corrente + bOk = bOk AndAlso EgtInsertFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & UPDATEBTL_NGE) + + ' ciclo su tutti gli AsseBase del progetto corrente + Dim nAsseBaseId = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While nAsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProjId As Integer + Dim nAsseBaseToEraseId As Integer = 0 + EgtGetInfo(nAsseBaseId, BTL_PRT_PROJ, nAsseBaseProjId) + ' se AsseBase di questo step del ciclo è nuovo e suo ProjId uguale a quello del progetto corrente + If Not AsseBaseIdList.Contains(nAsseBaseId) AndAlso nAsseBaseProjId = ProjectManagerVM.CurrProj.nProjId Then + ' riloco i sottonodi del nuovo AsseBase nell'AsseBase del progetto aperto col medesimo ProjId + Dim AsseBaseSubNodeId As Integer = EgtGetFirstInGroup(nAsseBaseId) + While AsseBaseSubNodeId <> GDB_ID.NULL + ' ciclo su tutti gli AsseBase per trovare l'id di quello con ProjId uguale al progetto corrente + Dim FindAsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While FindAsseBaseId <> GDB_ID.NULL + Dim SameAsseBaseProjId As Integer + EgtGetInfo(FindAsseBaseId, BTL_PRT_PROJ, SameAsseBaseProjId) + ' se l'ho trovato esco dal While (FindAsseBaseId è l'id dell'AsseBase in cui vogliamo rilocare i sottonodi) + If SameAsseBaseProjId = ProjectManagerVM.CurrProj.nProjId Then Exit While + FindAsseBaseId = EgtGetNextName(FindAsseBaseId, ASSEBASE) + End While + ' salvo id dell'AsseBase corrente per ottenere il seguente prima di rilocarlo + Dim CurrAsseBaseSubNodeId = AsseBaseSubNodeId + AsseBaseSubNodeId = EgtGetNext(CurrAsseBaseSubNodeId) + bOk = bOk AndAlso EgtRelocate(CurrAsseBaseSubNodeId, FindAsseBaseId, GDB_POS.LAST_SON) + End While + ' salvo id dell'AsseBase per cancellarlo + nAsseBaseToEraseId = nAsseBaseId + End If + ' ricavo id del prossimo AsseBase + nAsseBaseId = EgtGetNextName(nAsseBaseId, ASSEBASE) + ' se salvato id dell'AsseBase per cancellarlo lo cancello + If nAsseBaseToEraseId <> 0 Then bOk = bOk AndAlso EgtErase(nAsseBaseToEraseId) + End While + + ' deseleziono tutto + EgtDeselectAll() + ' ciclo sui pezzi aggiunti + Dim nAddedPartId As Integer = If(nLastProjPartId <> GDB_ID.NULL, EgtGetNextPart(nLastProjPartId), EgtGetFirstPart()) + Dim LastPartMaxY As Double + While nAddedPartId <> GDB_ID.NULL + ' recupero layer del box + Dim nBoxLayerId As Integer = EgtGetFirstNameInGroup(nAddedPartId, "Box") + ' recupero box del layer box + Dim b3Box As New BBox3d + EgtGetBBoxGlob(nBoxLayerId, GDB_BB.STANDARD, b3Box) + ' ricaviamo il box globale del part appena aggiunto e ruotato + Dim b3Part As New BBox3d + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + ' salviamo la Y massima del box globale di tutti i part + LastPartMaxY = b3Parts.Max.y + ' sposto il pezzo per distanziarlo dall'ultimo di un offset pari a 500 + bOk = bOk AndAlso EgtMove(nAddedPartId, New Vector3d(0, LastPartMaxY - b3Part.Min.y + 500, 0)) + ' ricaviamo il box globale del part appena spostato e lo aggiungiamo al box globale di tutti i part + EgtGetBBoxGlob(nAddedPartId, 1, b3Part) + b3Parts.Add(b3Part) + ' aggiungo dati pezzo + Dim NewPart As BTLPartM = BTLPartM.CreateBTLPart(nAddedPartId) + ' aggiungo pezzo alla lista + Map.refProjectVM.BTLStructureVM.BTLStructureM.AddBTLPart(NewPart) + Dim AddedBTLPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.BTLPartM Is NewPart) + ' se progetto pareti e vista ruotata + If nType = BWType.WALL AndAlso (CurrentMachine.ViewDir = VT.ISO_NW OrElse CurrentMachine.ViewDir = VT.ISO_NE) Then + ' ruoto le pareti di 180 per raddrizzarle rispetto alla vista + AddedBTLPart.Rotation(True, Map.refProjectVM.BTLStructureVM.nPROJTYPE, True, 180, False) + End If + ' verifico se aggiungere sezione alla lista + If Not Map.refProjectVM.BTLStructureVM.SectionList.Contains(AddedBTLPart.Section) Then + Map.refProjectVM.BTLStructureVM.SectionList.Add(AddedBTLPart.Section) + End If + nAddedPartId = EgtGetNextPart(nAddedPartId) + End While + WriteMainPrivateProfileString(S_GENERAL, K_LASTUPDATEDIR, Path.GetDirectoryName(sFile)) + End If + End If + ' copio il file originale scelto nel dialog per l'Update nella cartella Proj del progetto corrente + If File.Exists(sFile) Then + Dim sDestPath As String = ProjectManagerVM.CurrProj.sProjDirPath & "\" & Path.GetFileNameWithoutExtension(sFile) + While File.Exists(sDestPath & ".btl") + sDestPath = sDestPath & "_1" + End While + File.Copy(sFile, sDestPath & ".btl", False) + End If + End If + ' se assemblato lo ripristino + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + If nSelPartId <> GDB_ID.NULL Then + Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nSelPartId) + If Not IsNothing(SelPart) Then + 'SelPart.IsSelected = True + If bShowSolid Then Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, True, False) + End If + End If + EgtZoom(ZM.ALL) + End Sub + +#End Region ' UpdateBTL + +#Region "ExportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ExportProject_Command As ICommand + Get + If m_cmdExportProject Is Nothing Then + m_cmdExportProject = New Command(AddressOf ExportProject) + End If + Return m_cmdExportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Function ExportProject(Optional sExportFileName As String = Nothing) As String + Select Case Map.refMainMenuVM.SelPage + Case Pages.VIEW + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return Nothing + If IsNothing(CurrProj) Then Return Nothing + Case Pages.MACHINING + If ProdFileVM.VerifyProjectModification(ProjectManagerVM.CurrProd) = MessageBoxResult.Cancel Then Return Nothing + If IsNothing(ProjectManagerVM.CurrProd) Then Return Nothing + Case Else + Return Nothing + End Select + + ' apro finestra di salvataggio progetto + Dim ExportDlg As New Microsoft.Win32.SaveFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .FileName = CurrProj.nProjId.ToString("0000") & " - " & CurrProj.sBTLFileName & " - ProjectExport"} + If IsNothing(sExportFileName) Then + 'If ExportDlg.ShowDialog() <> True Then Return Nothing + If ExportDlg.ShowDialog() <> System.Windows.Forms.DialogResult.OK Then Return Nothing + End If + + LoadingWndHelper.OpenLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63010), EgtMsg(63016), 30) ' Project exporting ' Adding export info + ' se assemblato me lo segno e lo smonto + Dim bShowBuilding As Boolean = False + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + Configuration.ShowAllPieces(bShowBuilding) + End If + + ' per ogni BTLInfo nel progetto riporto il relativo nome del BTL + Dim nBTLInfoProjId As Integer + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, nBTLInfoProjId) + If nBTLInfoProjId > 0 Then + ' recupero il BTL file name di questo proj + Dim BTLFileNameProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nBTLInfoProjId) + If Not IsNothing(BTLFileNameProj) Then + EgtSetInfo(nBTLInfoLayerId, BTLFILENAME, BTLFileNameProj.sBTLFileName) + End If + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + ' aggiungo layer per info di export + Dim nImpExpPartId As Integer = EgtCreateGroup(GDB_ID.ROOT) + EgtSetName(nImpExpPartId, EXP_PART) + ' ci scrivo nome macchina e tipo progetto + EgtSetInfo(nImpExpPartId, EXP_MACHINE, CurrProj.sMachine) + EgtSetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, CurrProj.nType) + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.EXPORTPROJECT, 2, EgtMsg(63017), 30, 100) ' Exporting... + ' salvo info inserite + Map.refSceneHostVM.SaveProject() + ' creo file zip + Dim sZipToCreate As String = If(IsNothing(sExportFileName), ExportDlg.FileName, Map.refMainWindowVM.MainWindowM.sTempDir & "\" & sExportFileName & ".ngexp") + If File.Exists(sZipToCreate) Then + File.Delete(sZipToCreate) + End If + Try + Using zip As New Ionic.Zip.ZipFile(sZipToCreate, Console.Out) + ' impacchetto tutta la cartella del progetto + Dim sProjectDirPath As String = If(CurrProj.nProdId > 0, CurrProj.sProdDirPath, CurrProj.sProjDirPath) + For Each sFile As String In Directory.GetFiles(sProjectDirPath) + zip.AddItem(sFile, "") + Next + ' salvo lo zip + zip.Save() + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Error in export file creation!") + End Try + ' elimino layer di esportazione + EgtErase(nImpExpPartId) + ' salvo eliminazione info inserite + Map.refSceneHostVM.SaveProject() + If bShowBuilding Then Map.refProjectVM.BTLStructureVM.ShowBuilding(True, False) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.EXPORTPROJECT) + Return sZipToCreate + End Function + +#End Region ' ExportProject + +#Region "ImportProject" + + ''' + ''' Returns a command that do Export. + ''' + Public ReadOnly Property ImportProject_Command As ICommand + Get + If m_cmdImportProject Is Nothing Then + m_cmdImportProject = New Command(AddressOf ImportProject) + End If + Return m_cmdImportProject + End Get + End Property + + ''' + ''' Execute the Export. This method is invoked by the ExportCommand. + ''' + Public Sub ImportProject() + Dim CurrProd As ProjectFileVM = ProjectManagerVM.CurrProd + ' lista di tutti gli errori riscontrati + Dim ErrorList As New List(Of String) + If Not ProjFileVM.VerifyProjectModification(CurrProj, ProjectType.PROJ) Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, "", sDir) + 'apro finestra scelta file + Dim ImportDlg As New Microsoft.Win32.OpenFileDialog() With {.DefaultExt = ".ngexp", + .Filter = "ProjectExport (*.ngexp)|*.ngexp", + .InitialDirectory = If(Directory.Exists(sDir), sDir, ""), + .CheckFileExists = True, + .ValidateNames = True} + If ImportDlg.ShowDialog() <> True Then Return + ' creo cartella temporanea di estrazione in Temp + Dim sProjectimportDir As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\ProjectImport" + If Directory.Exists(sProjectimportDir) Then + Try + Directory.Delete(sProjectimportDir, True) + Catch ex As Exception + EgtOutLog("Delete old import project failed!") + MessageBox.Show("Importazione Fallita!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End Try + End If + Directory.CreateDirectory(sProjectimportDir) + Try + Using zip As New Ionic.Zip.ZipFile(ImportDlg.FileName, Console.Out) + ' estraggo file da zip + zip.ExtractAll(sProjectimportDir) + End Using + Catch ex1 As Exception + EgtOutLog("Exception in zip: " & ex1.ToString()) + MessageBox.Show("Impossibile importare file", "Errore") + Return + End Try + LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63018), EgtMsg(63019), 30) ' Project importing ' Loading project + ' carico progetto + Dim sProjFromPath() As String = Directory.GetFiles(sProjectimportDir, "*.nge") + Dim bOk = EgtOpenFile(sProjFromPath(0)) + If Not bOk Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile aprire il file", "Errore") + Return + End If + ' recupero e verifico se ho a disposizione la macchina con cui e' stato creato il progetto + Dim nImpExpPartId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EXP_PART) + Dim sMachine As String = "" + EgtGetInfo(nImpExpPartId, EXP_MACHINE, sMachine) + ' se la macchina del progetto in apertura non è tra le macchine disponibili lo segnalo e apro un progetto vuoto + If IsNothing(Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine)) Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + Dim Machine As Machine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = sMachine) + Dim nType As Integer = BWType.NULL + EgtGetInfo(nImpExpPartId, BTL_GEN_PROJTYPE, nType) + If IsNothing(Machine) OrElse nType = BWType.NULL Then + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show(EgtMsg(61885), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + Return + End If + ' elimino part di esportazione + EgtErase(nImpExpPartId) + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTPROJECT, 2, EgtMsg(63020), 30, 100) ' Creating imported project + ' leggo proj e prod presenti dai layer BTLInfo + Dim ImportProjIdList As New List(Of Integer) + Dim NewProjIdList As New List(Of Integer) + Dim BTLInfoIdList As New List(Of Integer) + Dim BTLFileNameList As New List(Of String) + Dim CurrImportProjId As Integer + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + ' recupero il ProjId + EgtGetInfo(nBTLInfoLayerId, BTL_PRT_PROJ, CurrImportProjId) + If CurrImportProjId > 0 Then + ImportProjIdList.Add(CurrImportProjId) + BTLInfoIdList.Add(nBTLInfoLayerId) + ' recupero nome file BTL Associato + Dim sBTLFileName As String = "" + EgtGetInfo(nBTLInfoLayerId, BTLFILENAME, sBTLFileName) + BTLFileNameList.Add(sBTLFileName) + End If + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + If Not ImportProjIdList.Count > 0 Then + MessageBox.Show("Nessun progetto trovato all'interno del file importato", "Errore") + End If + ' carico i proj + For nProjIndex = 0 To ImportProjIdList.Count - 1 + Dim nImportProjId As Integer = ImportProjIdList(nProjIndex) + ' inizializzo nuovo proj + Dim nNewProjId As Integer = 0 + Dim sNewProjDir As String = "" + InitNewProject(nNewProjId, sNewProjDir, nType, Machine) + NewProjIdList.Add(nNewProjId) + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nImportProjId + ' costruisco BTLStructure del proj + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(nImportProjId)) + ' scrivo info proj su tutti i pezzi di questo progetto + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + EgtSetInfo(BTLPart.nPartId, BTL_PRT_PROJ, nNewProjId) + Next + ' cambio indicazione proj in gruppo di assemblaggio + Dim AsseBaseId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + While AsseBaseId <> GDB_ID.NULL + Dim nAsseBaseProj As Integer = 0 + EgtGetInfo(AsseBaseId, BTL_PRT_PROJ, nAsseBaseProj) + If nAsseBaseProj = nImportProjId Then + EgtSetInfo(AsseBaseId, BTL_PRT_PROJ, NewProjIdList(nProjIndex)) + Exit While + End If + AsseBaseId = EgtGetNextName(AsseBaseId, ASSEBASE) + End While + ' riporto nuovo ProjId nel layer BTLInfo + EgtSetInfo(BTLInfoIdList(nProjIndex), BTL_PRT_PROJ, nNewProjId) + ' resetto tutti gli stati di CALC + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + BTLPart.ResetCalcTotalPart() + Next + ' salvo modifiche fatte al progetto + bOk = bOk AndAlso Map.refSceneHostVM.MainController.SaveProject() + If bOk Then + ' copio file BTL e progetto + Dim sBTLFromPath As String = sProjectimportDir & "\" & BTLFileNameList(nProjIndex) & ".btl" + Dim sProjFileName As String = sNewProjDir & "\" & nNewProjId.ToString("0000") & ".nge" + If sProjFromPath.Count > 0 AndAlso Not String.IsNullOrWhiteSpace(sProjFromPath(0)) Then + Try + If Not String.IsNullOrWhiteSpace(sBTLFromPath) AndAlso File.Exists(sBTLFromPath) Then + Dim sBtlToPath As String = sNewProjDir & "\" & Path.GetFileName(sBTLFromPath) + File.Copy(sBTLFromPath, sBtlToPath) + Else + ErrorList.Add(String.Format("File BTL del progetto {0} non trovato", nImportProjId)) + End If + File.Copy(sProjFromPath(0), sProjFileName) + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + MessageBox.Show("Impossibile copiare il file del progetto", "Errore") + Return + End Try + End If + ' aggiorno Db + Dim sBTLFileName As String = BTLFileNameList(nProjIndex) + Dim ExportDate As DateTime + DateTime.TryParse(Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPDATE & " " & + Map.refProjectVM.BTLStructureVM.BTLStructureM.m_sEXPTIME, ExportDate) + DbControllers.m_ProjController.UpdateInfo(nNewProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Machine.Name) + Else + ' elimino da Db + + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nNewProjId, False) + End If + ' aggiorno BTLParts su DB + DbControllers.m_ProjController.UpdateBtlParts(nNewProjId, Map.refProjectVM.BTLStructureVM.BTLStructureM.BTLPartMList) + ' resetto stato new + DbControllers.m_ProjController.ResetNew(nNewProjId) + ' resetto lock + DbControllers.m_ProjController.LockByProjId(nNewProjId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + DbControllers.m_ProjController.ResetController() + Next + ' se tutte le operazioni precedenti sono andate a buon fine + If bOk Then + ' sostituisco indicazione nuovi proj nei pezzi + Dim nDuploLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "DuploBase") + Dim nDuploId As Integer = EgtGetFirstInGroup(nDuploLayerId) + While nDuploId <> GDB_ID.NULL + ' recupero vecchio proj + Dim nOldProjId As Integer + EgtGetInfo(nDuploId, BTL_PRT_PROJ, nOldProjId) + ' lo cerco nella lista + Dim nOldProjIndex As Integer = ImportProjIdList.IndexOf(nOldProjId) + ' lo sostituisco + EgtSetInfo(nDuploId, BTL_PRT_PROJ, NewProjIdList(nOldProjIndex)) + nDuploId = EgtGetNext(nDuploId) + End While + ' resetto CurrProd per evitare di leggere valori produzione dal Db di quel progetto + ProjectManagerVM.CurrProd = Nothing + ' carico Machgroup che non verrebbero altrimenti importati + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count > 0 Then + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + Map.refProdManagerVM.InitNewProject(NewProjIdList(0), nProdId, sProdDir) + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine) + For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + ' aggiorno ProdId sui MachGroup + EgtSetInfo(MachGroup.Id, MGR_RPT_PRODID, nProdId) + If Map.refMainWindowVM.MainWindowM.nUserLevel < 5 OrElse GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) <> 1 Then + ' resetto tutti gli stati di CALC + MachGroup.ResetCalcTotalMachGroup() + End If + Next + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' riporto info di futuro aggiornamento machgroup + nBTLInfoLayerId = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + While nBTLInfoLayerId <> GDB_ID.NULL + EgtSetInfo(nBTLInfoLayerId, IMP_VERIFYMACHGROUP, True) + nBTLInfoLayerId = EgtGetNextName(nBTLInfoLayerId, BTLINFO) + End While + End If + ' salvo il progetto PROD + EgtSaveFile(sProjFromPath(0), NGE.CMPTEXT) + ' copio file progetto + Dim sProjPath As String = String.Empty + Dim sProdPath As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + If EgtGetCurrFilePath(sProjPath) AndAlso Not String.IsNullOrEmpty(sProjPath) Then + Try + File.Copy(sProjPath, sProdPath) + bOk = True + Catch ex As Exception + EgtOutLog("Impossibile copiare il file") + bOk = False + End Try + End If + If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso GetMainPrivateProfileInt(S_MACH, K_EXPORTBWE, 0) = 1 Then + ' copio tutti i bwe + For Each CurrFile In Directory.GetFiles(sProjectimportDir) + If Path.GetExtension(CurrFile) = ".bwe" OrElse Path.GetExtension(CurrFile) = ".html" Then + File.Copy(CurrFile, sProdDir & "\" & Path.GetFileName(CurrFile)) + End If + Next + End If + If bOk Then + ' aggiungo altri proj a prod + For Each nProjId In NewProjIdList + DbControllers.m_ProdController.AddProj(nProdId, nProjId, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Next + Else + ' elimino da DB + DbControllers.m_ProdController.DeleteProd(nProdId, True) + End If + Dim MyMachGroupList As New List(Of MyMachGroupM) + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM) Then + For Each MachGroup In Map.refProjectVM.MachGroupPanelVM.m_MyMachGroupPanelM.MachGroupMList + MyMachGroupList.Add(MachGroup) + Next + End If + ' aggiorno pezzi su Db + DbControllers.m_ProdController.UpdateMachGroup(nProdId, MyMachGroupList) + ' resetto lock + DbControllers.m_ProdController.LockByProdId(nProdId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + End If + DbControllers.m_ProdController.ResetController() + End If + ' imposto progetto corrente + If NewProjIdList.Count > 0 Then + SetCurrProj(NewProjIdList(0)) + OpenProject(CurrProj) + End If + ' ripristino eventuale CurrProd precedente + ProjectManagerVM.CurrProd = CurrProd + WriteMainPrivateProfileString(S_GENERAL, K_LASTNGEXPDIR, Path.GetDirectoryName(ImportDlg.FileName)) + LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTPROJECT) + End Sub + +#End Region ' ImportProject + +#Region "GoToProd" + + ''' + ''' Returns a command that do GoToProd. + ''' + Public ReadOnly Property GoToProd_Command As ICommand + Get + If m_cmdGoToProd Is Nothing Then + m_cmdGoToProd = New Command(AddressOf GoToProd) + End If + Return m_cmdGoToProd + End Get + End Property + + ''' + ''' Execute the GoToProd. This method is invoked by the GoToProd_Command. + ''' + Public Sub GoToProd(ByVal param As Object) + If IsNothing(CurrProj) Then Return + ' verifico se progetto modificato, e chiedo se salvare + Dim bSaved As Boolean = True + If CurrProj.bIsNew Or EgtGetModified() OrElse Map.refCALCPanelVM.IsMachineModified() Then + Select Case MessageBox.Show(EgtMsg(61877), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Case MessageBoxResult.Yes + Save() + Case MessageBoxResult.Cancel + Return + Case Else ' No + If ProjectManagerVM.CurrProj.bIsNew Then + MessageBox.Show(EgtMsg(61878), "", MessageBoxButton.OK, MessageBoxImage.Exclamation) + Return + End If + ' resetto stato modificato + Map.refSceneHostVM.MainController.ResetModified() + bSaved = False + End Select + End If + + LoadingWndHelper.OpenLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63004), EgtMsg(63011), 10) ' Optimization opening ' Loading environment + + Dim nProdId As Integer = ProjectManagerVM.CurrProj.nProdId + If nProdId > 0 Then + ProjectManagerVM.SetCurrProd(nProdId) + ProjectManagerVM.CurrProd.SetReloadProject(bSaved) + Else + 'creo nuova ottimizzazione da progetto corrente + NewProdFromProj() + End If + ' Ricavo il tipo di Warehouse settato nell'INI + Dim nDefault As Integer = 2 + If GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) = WarehouseType.MEDIUM Then + ' Se di tipo Medium confronto le Sezioni del BTL importato con quelle in Warehouse + WarehouseWndVM.UpdateSectionXMaterial() + End If + ' vado in pagina prod + Map.refMainMenuVM.SetSelPage(Pages.MACHINING, False) + ' aggiorno titolo + Map.refMainWindowVM.UpdateTitle() + LoadingWndHelper.CloseLoadingWnd(ActiveIds.GOTOPROD) + End Sub + +#End Region ' GoToProd + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml b/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml new file mode 100644 index 00000000..e8aa19c4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml.vb b/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml.vb new file mode 100644 index 00000000..32a2c3bb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Project/ProjectV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ProjectV + +End Class diff --git a/EgtBEAMWALL.Optimizer/Project/ProjectVM.vb b/EgtBEAMWALL.Optimizer/Project/ProjectVM.vb new file mode 100644 index 00000000..221708fb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Project/ProjectVM.vb @@ -0,0 +1,461 @@ +Imports System.Windows.Threading +Imports EgtBEAMWALL.Core +Imports EgtWPFLib5 +Imports System.Collections.ObjectModel + +Public Class ProjectVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_Calc_Timer As New DispatcherTimer + + Friend Event OnPreControllerExec(sFilePath As String) + Friend Event OnPostControllerExec() + + ' Flag per non salvare Script appena eseguito in elenco MruScript + Private m_bScriptInMru As Boolean = True + + Private Property m_GridDims As New ObservableCollection(Of GridDimension) + Public Property GridDims As ObservableCollection(Of GridDimension) + Get + Return m_GridDims + End Get + Set + m_GridDims = Value + NotifyPropertyChanged(NameOf(GridDims)) + End Set + End Property + + Private m_BTLStructureVM As BTLStructureVM + Public Property BTLStructureVM As BTLStructureVM + Get + Return m_BTLStructureVM + End Get + Set(value As BTLStructureVM) + m_BTLStructureVM = value + NotifyPropertyChanged(NameOf(BTLStructureVM)) + End Set + End Property + + Private m_MachGroupPanelVM As MyMachGroupPanelVM + Public Property MachGroupPanelVM As MyMachGroupPanelVM + Get + Return m_MachGroupPanelVM + End Get + Set(value As MyMachGroupPanelVM) + m_MachGroupPanelVM = value + NotifyPropertyChanged(NameOf(MachGroupPanelVM)) + End Set + End Property + + Private m_bCalcRunning As Boolean = False + Public ReadOnly Property bCalcRunning As Boolean + Get + Return m_bCalcRunning + End Get + End Property + Private m_bLockUX As Boolean = False + + Private m_LeftPanel_Visibility As Boolean = True + Public Property LeftPanel_Visibility As Visibility + Get + Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_LeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean) + m_LeftPanel_Visibility = IsVisible + End Sub + + Private m_TopPanel_Visibility As Boolean = False + Public Property TopPanel_Visibility As Visibility + Get + Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_TopPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetTopPanel_Visibility(IsVisible As Boolean) + m_TopPanel_Visibility = IsVisible + End Sub + + Private m_BottomPanel_Visibility As Boolean = True + Public Property BottomPanel_Visibility As Visibility + Get + Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_BottomPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean) + m_BottomPanel_Visibility = IsVisible + End Sub + + Private m_PartManager_Visibility As Boolean = True + Public ReadOnly Property PartManager_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_FeatureManager_Visibility As Boolean = True + Public Property FeatureManager_Visibility As Visibility + Get + Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FeatureManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean) + m_FeatureManager_Visibility = IsVisible + End Sub + + Private m_ShowBeamPanel_Visibility As Boolean = True + Public Property ShowBeamPanel_Visibility As Visibility + Get + Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ShowBeamPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean) + m_ShowBeamPanel_Visibility = IsVisible + End Sub + + Private m_ProjManager_Visibility As Boolean = True + Public Property ProjManager_Visibility As Visibility + Get + Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProjManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProjManager_Visibility(IsVisible As Boolean) + m_ProjManager_Visibility = IsVisible + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) + End Sub + + Private m_ProdManager_Visibility As Boolean = True + Public Property ProdManager_Visibility As Visibility + Get + Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_ProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetProdManager_Visibility(IsVisible As Boolean) + m_ProdManager_Visibility = IsVisible + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) + End Sub + + Private m_OptimizePanel_Visibility As Boolean = True + Public Property OptimizePanel_Visibility As Visibility + Get + Return If(m_OptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOptimizePanel_Visibility(IsVisible As Boolean) + m_OptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) + End Sub + + Friend Sub NotifyCalcPanel_Visibility() + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility)) + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility)) + End Sub + + Private m_FreeContourManager_Visibility As Boolean = False + Public Property FreeContourManager_Visibility As Visibility + Get + Return If(m_FreeContourManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_FreeContourManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean) + m_FreeContourManager_Visibility = IsVisible + NotifyPropertyChanged(NameOf(FreeContourManager_Visibility)) + End Sub + + ' OnlyProdProject + + Private m_OnlyProdManager_Visibility As Boolean = True + Public Property OnlyProdManager_Visibility As Visibility + Get + Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdManager_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean) + m_OnlyProdManager_Visibility = IsVisible + End Sub + + Private m_OnlyProdLeftPanel_Visibility As Boolean = True + Public Property OnlyProdLeftPanel_Visibility As Visibility + Get + Return If(m_OnlyProdLeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdLeftPanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdLeftPanel_Visibility(IsVisible As Boolean) + m_OnlyProdLeftPanel_Visibility = IsVisible + End Sub + + Private m_OnlyProdOptimizePanel_Visibility As Boolean = True + Public Property OnlyProdOptimizePanel_Visibility As Visibility + Get + Return If(m_OnlyProdOptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) + End Get + Set(value As Visibility) + m_OnlyProdOptimizePanel_Visibility = (value = Visibility.Visible) + End Set + End Property + Friend Sub SetOnlyProdOptimizePanel_Visibility(IsVisible As Boolean) + m_OnlyProdOptimizePanel_Visibility = IsVisible + NotifyPropertyChanged(NameOf(OnlyProdOptimizePanel_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) + Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) + End Sub + + Public ReadOnly Property SpecialPanel_Visibility As Visibility + Get + Return If(Map.refMainWindowVM.MainWindowM.bSpecialPanel AndAlso Map.refMainWindowVM.MainWindowM.nUserLevel > 5, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_MacroFeature_IsEnabled As Boolean = False + Public Property MacroFeature_IsEnabled As Boolean + Get + Return m_MacroFeature_IsEnabled + End Get + Set(value As Boolean) + m_MacroFeature_IsEnabled = value + NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) + End Set + End Property + + Enum GridSelTypes As Integer + PARTLIST = 1 + PART = 2 + MACHGROUP = 3 + End Enum + Private m_LastSelGridType As GridSelTypes + Public ReadOnly Property LastSelGridType As GridSelTypes + Get + Return m_LastSelGridType + End Get + End Property + Friend Sub SetLastSelGridType(value As GridSelTypes) + m_LastSelGridType = value + End Sub + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefProjectVM(Me) + ' imposto timer per aggiornamenti Calc + m_Calc_Timer.Interval = TimeSpan.FromMilliseconds(500) + AddHandler m_Calc_Timer.Tick, AddressOf Calc_Timer_Tick + ' imposto dimensioni colonne/righe della Grid + Dim ProjectGridDim As String = If(Map.refMainWindowVM.MainWindowM.bOnlyProd, ConstDims.PROJECT_ONLYPROD, ConstDims.PROJECT_VIEW) + DimensionsIniFile.ReadGridDimensions(ProjectGridDim, GridDims) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub SetCalcRunning(value As Boolean) + If value Then m_Calc_Timer.Start() + m_bCalcRunning = value + End Sub + + Friend Sub ManageIsEnabled(bIsEnabled As Boolean) + Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled) + Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled) + Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) + Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) + Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) + Map.refBTLPartManagerVM.SetBTLPartManagerIsEnabled(bIsEnabled) + Map.refFeatureListManagerVM.SetLeftPanelIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) + If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) + Map.refRawPartManagerVM.SetRawPartManagerIsEnabled(bIsEnabled) + Map.refPartInRawPartManagerVM.SetPartInRawPartManagerIsEnabled(bIsEnabled) + Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) + Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) + End Sub + + Private Sub Calc_Timer_Tick() + If m_bCalcRunning <> m_bLockUX Then + ' se calcolo iniziato + If m_bCalcRunning Then + ManageIsEnabled(False) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.IsReadOnly = True + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.IsReadOnly = True + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.IsReadOnly = True + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.IsReadOnly = True + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.IsReadOnly = True + End If + m_bLockUX = True + ' se calcolo finito + Else + ManageIsEnabled(True) + ' aggiungere gestione colonne editabili delle tabelle + If Not IsNothing(Map.refPartListVM.colPart_Do) Then + Map.refPartListVM.colPart_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then + Map.refFeatureListVM.colFeature_Do.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then + Map.refPParameterListVM.colPParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then + Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then + Map.refQParameterListVM.colQParam_Custom.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then + Map.refRawPartListVM.colRawPart_StartCut.ResetToOrigIsReadOnly() + End If + If m_BTLStructureVM.nPROJTYPE <> BWType.BEAM AndAlso Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then + Map.refRawPartListVM.colRawPart_W.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then + Map.refRawPartListVM.colRawPart_L.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then + Map.refRawPartListVM.colRawPart_PosZ.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then + Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then + Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then + Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then + Map.refPartInRawPartListVM.colPartInRawPart_PosY.ResetToOrigIsReadOnly() + End If + If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then + Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.ResetToOrigIsReadOnly() + End If + ' fermo il timer + If Not m_bCalcRunning Then + m_Calc_Timer.Stop() + m_bLockUX = False + End If + End If + End If + + End Sub + + Friend Sub ManageQParamsRowVisibility(bVisible As Boolean) + If bVisible Then + DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims) + Else + GridDimension.SetSoftwareMod(True) + Dim FeatureRow = m_GridDims(4) + Dim QParRow = m_GridDims(5) + m_GridDims(4).GridLen = New GridLength(1, GridUnitType.Star) + m_GridDims(4).NotifyPropertyChanged(NameOf(FeatureRow.GridLen)) + m_GridDims(5).GridLen = New GridLength(0) + m_GridDims(5).NotifyPropertyChanged(NameOf(QParRow.GridLen)) + GridDimension.SetSoftwareMod(False) + End If + End Sub + + Friend Sub NotifyAllPanelVisibility() + NotifyPropertyChanged(NameOf(LeftPanel_Visibility)) + NotifyPropertyChanged(NameOf(TopPanel_Visibility)) + NotifyPropertyChanged(NameOf(BottomPanel_Visibility)) + NotifyPropertyChanged(NameOf(PartManager_Visibility)) + NotifyPropertyChanged(NameOf(FeatureManager_Visibility)) + NotifyPropertyChanged(NameOf(ShowBeamPanel_Visibility)) + NotifyPropertyChanged(NameOf(ProjManager_Visibility)) + NotifyPropertyChanged(NameOf(ProdManager_Visibility)) + NotifyCalcPanel_Visibility() + End Sub + +#End Region ' Methods + +End Class + diff --git a/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFile.vb b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFile.vb new file mode 100644 index 00000000..f2fddca8 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFile.vb @@ -0,0 +1,69 @@ +Imports System.IO + +Public Class ProdFile + + 'Private m_nProjId As Integer = 0 + 'Public ReadOnly Property nProjId As Integer + ' Get + ' Return m_nProjId + ' End Get + 'End Property + + 'Friend ReadOnly Property sProjPath As String + ' Get + ' Dim sPath As String = String.Empty + ' If IsNothing(m_nProjId) OrElse m_nProjId = 0 Then Return String.Empty + ' sPath = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & FILENAMESEPARATOR + ' If Not IsNothing(m_nProdId) AndAlso m_nProdId > 0 Then + ' sPath &= nProjId.ToString("0000") + ' End If + ' sPath &= FILENAMESEPARATOR & BTLFileName & ".nge" + ' Return sPath + ' End Get + 'End Property + + Private m_nProdId As Integer = 0 + Public ReadOnly Property nProdId As Integer + Get + Return m_nProdId + End Get + End Property + Friend ReadOnly Property sProdPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_nProdId) OrElse m_nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" + End Get + End Property + + 'Private m_BTLFileName As String = String.Empty + 'Public ReadOnly Property BTLFileName As String + ' Get + ' Return m_BTLFileName + ' End Get + 'End Property + + Private m_NewProd As Boolean + Friend Property NewProd As Boolean + Get + Return m_NewProd + End Get + Set(value As Boolean) + m_NewProd = value + End Set + End Property + Public ReadOnly Property ProjectFileName As String + Get + Return m_nProdId.ToString("0000") + End Get + End Property + + Sub New(ProdFileName As String) + Integer.TryParse(Path.GetFileNameWithoutExtension(ProdFileName), m_nProdId) + End Sub + + Friend Sub SetProdId(nProdId As Integer) + m_nProdId = nProdId + End Sub + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFileVM.vb b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFileVM.vb new file mode 100644 index 00000000..75e75e7a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProdFileVM.vb @@ -0,0 +1,97 @@ +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class ProdFileVM + Inherits Core.ProdFileVM + +#Region "CONSTRUCTORS" + + Sub New(ProdFileM As ProdFileM) + MyBase.New(ProdFileM) + ' aggiungo nome btl + Dim sBTLFileName As String = "" + For Each TempCurrProj In nProjIdList + Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(TempCurrProj) + If Not IsNothing(TempProj) Then sBTLFileName &= TempProj.sListName + Next + SetBTLFileName(sBTLFileName) + ' verifico valore description + If Not IsNothing(ProdFileM) AndAlso String.IsNullOrWhiteSpace(ProdFileM.sName) Then + For Each TempCurrProj In nProjIdList + Dim TempProj As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(TempCurrProj) + If Not IsNothing(TempProj) AndAlso Not String.IsNullOrWhiteSpace(TempProj.sBTLFileName) Then + DbControllers.m_ProdController.UpdateDescription(ProdFileM.nProdId, TempProj.sBTLFileName) + ProdFileM.sName = TempProj.sBTLFileName + End If + Next + End If + End Sub + +#End Region ' CONSTRUCTORS + + Friend Function GetProjPath(nProjId As Integer) + Dim sPath As String = String.Empty + If nProjId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & ".nge" + End Function + + Friend Shared Function VerifyProjectModification(CurrProject As ProdFileVM) As MessageBoxResult + If IsNothing(CurrProject) Then Return True + Dim bNewProject As Boolean = False + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProject.sProdDirPath + Dim VerifyResult As MessageBoxResult = MessageBoxResult.None + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() OrElse CurrProject.bIsNew OrElse Map.refCALCPanelVM.IsMachineModified() Then + VerifyResult = MessageBox.Show(EgtMsg(61875), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Select Case VerifyResult + Case MessageBoxResult.Yes + ' salvo proj + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If + Case MessageBoxResult.Cancel + Return MessageBoxResult.Cancel + Case Else ' No + EgtResetModified() + Map.refCALCPanelVM.RevertToOriginalMachine() + If CurrProject.bIsNew Then + ' lo elimino + Try + Directory.Delete(sProjectDirPath, True) + Catch ex As Exception + End Try + If Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProdPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.MruFileNames)) + End If + DbControllers.m_ProdController.DeleteProd(CurrProject.nProdId, False) + If Not IsNothing(Map.refProjManagerVM) AndAlso CurrProject.nProdId = ProjectManagerVM.CurrProj.nProdId Then + ' reset prod in path proj + Map.refProjManagerVM.UpdateCurrProj() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso CurrProject.nProdId = ProjectManagerVM.CurrProj.nProdId Then + ' reset prod in path proj + Map.refOnlyProdManagerVM.UpdateCurrProj() + End If + If Not IsNothing(Map.refProdManagerVM) Then + ProjectManagerVM.CurrProd = Nothing + End If + EgtResetModified() + Return MessageBoxResult.No + End If + End Select + Else + EgtResetModified() + End If + DbControllers.m_ProdController.ResetController() + DbControllers.m_ProdController.LockByProdId(CurrProject.nProdId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Return VerifyResult + End Function + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjFileVM.vb b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjFileVM.vb new file mode 100644 index 00000000..d449abc7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjFileVM.vb @@ -0,0 +1,83 @@ +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class ProjFileVM + Inherits Core.ProjFileVM + + Public ReadOnly Property bIsEnabled As Boolean + Get + Return Not DbControllers.bNetwork OrElse Not bIsLocked + End Get + End Property + +#Region "CONSTRUCTORS" + + Sub New(ProjectFileM As ProjFileM) + MyBase.New(ProjectFileM) + ' verifico valore description + If Not IsNothing(ProjectFileM) AndAlso String.IsNullOrWhiteSpace(ProjectFileM.sDescription) Then + DbControllers.m_ProjController.UpdateDescription(ProjectFileM.nProjId, ProjectFileM.sBTLFileName) + ProjectFileM.sDescription = ProjectFileM.sBTLFileName + End If + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Friend Shared Function VerifyProjectModification(CurrProject As ProjFileVM, Type As ProjectType) As Boolean + If IsNothing(CurrProject) Then Return True + Dim sProjectDirPath As String = "" + sProjectDirPath = CurrProject.sProjDirPath + ' verifico se progetto modificato, e chiedo se salvare + If EgtGetModified() OrElse CurrProject.bIsNew OrElse Map.refCALCPanelVM.IsMachineModified() Then + Select Case MessageBox.Show(EgtMsg(61875), "", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) + Case MessageBoxResult.Yes + ' salvo proj + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.Save() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.Save() + End If + Map.refCALCPanelVM.IsMachineApplied = False + Case MessageBoxResult.Cancel + Return False + Case Else ' No + EgtResetModified() + Map.refCALCPanelVM.RevertToOriginalMachine() + Map.refCALCPanelVM.IsMachineApplied = False + If CurrProject.bIsNew Then + ' lo elimino + If Directory.Exists(sProjectDirPath) Then + Directory.Delete(sProjectDirPath, True) + End If + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Remove(CurrProject.sProjPath) + Map.refOnlyProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.MruFileNames)) + End If + + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(CurrProject.nProjId, False) + If Not IsNothing(Map.refProjManagerVM) Then + ProjectManagerVM.CurrProj = Nothing + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + ProjectManagerVM.CurrProj = Nothing + End If + EgtResetModified() + Return True + End If + End Select + Else + EgtResetModified() + End If + DbControllers.m_ProjController.LockByProjId(CurrProject.nProjId, False, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + Return True + End Function + +#End Region ' METHODS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjectFileVM.vb b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjectFileVM.vb new file mode 100644 index 00000000..f7e0b651 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectFileVM/ProjectFileVM.vb @@ -0,0 +1,143 @@ +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib + +Public Class ProjectFileVM + Inherits VMBase + + Protected m_ProjectFileM As ProjectFileM + + Public Overridable ReadOnly Property nProjId As Integer + Get + Return m_ProjectFileM.nProjId + End Get + End Property + Public Overridable ReadOnly Property sProjId As String + Get + Return m_ProjectFileM.nProjId.ToString("0000") + End Get + End Property + + Public Overridable ReadOnly Property nProdId As Integer + Get + Return m_ProjectFileM.nProdId + End Get + End Property + Public Overridable ReadOnly Property sProdId As String + Get + Return m_ProjectFileM.nProdId.ToString("0000") + End Get + End Property + + Friend Overridable ReadOnly Property sProjDirPath As String + Get + If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") + End Get + End Property + Friend Overridable ReadOnly Property sProjPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty + sPath = refMainWindowVM.MainWindowM.sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & ".nge" + Return sPath + End Get + End Property + + Friend Overridable ReadOnly Property sProdDirPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") + End Get + End Property + Friend Overridable ReadOnly Property sProdPath As String + Get + Dim sPath As String = String.Empty + If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty + Return refMainWindowVM.MainWindowM.sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge" + End Get + End Property + + Public Overridable Property bIsNew As Boolean + Get + Return m_ProjectFileM.bIsNew + End Get + Set(value As Boolean) + m_ProjectFileM.bIsNew = value + End Set + End Property + + Public Overridable Property bIsLocked As Boolean + Get + Return m_ProjectFileM.bIsLocked + End Get + Set(value As Boolean) + m_ProjectFileM.bIsLocked = value + End Set + End Property + + Public ReadOnly Property dtCreateDate As DateTime + Get + Return m_ProjectFileM.dtCreateDate + End Get + End Property + + Public ReadOnly Property nType As BWType + Get + Return m_ProjectFileM.nType + End Get + End Property + + ' variabile che indica se ricaricare il progetto + Private m_bReloadProject As Boolean = True + Friend ReadOnly Property bReloadProject As Boolean + Get + Return m_bReloadProject + End Get + End Property + +#Region "Messages" + + Public ReadOnly Property Id_Msg As String + Get + Return EgtMsg(61815) + End Get + End Property + Public ReadOnly Property BTLFileName_Msg As String + Get + Return EgtMsg(61819) + End Get + End Property + Public ReadOnly Property ListName_Msg As String + Get + Return EgtMsg(61820) + End Get + End Property + Public ReadOnly Property ExportDate_Msg As String + Get + Return EgtMsg(61821) + End Get + End Property + Public ReadOnly Property CreateDate_Msg As String + Get + Return EgtMsg(61822) + End Get + End Property + Public ReadOnly Property Name_Msg As String + Get + Return EgtMsg(61808) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTORS" + +#End Region ' CONSTRUCTORS + + Friend Sub SetReloadProject(bValue As Boolean) + m_bReloadProject = bValue + End Sub + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ProjectManager/ProjectManagerVM.vb b/EgtBEAMWALL.Optimizer/ProjectManager/ProjectManagerVM.vb new file mode 100644 index 00000000..a12f385a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectManager/ProjectManagerVM.vb @@ -0,0 +1,56 @@ +Imports EgtBEAMWALL.Core + +Module ProjectManagerVM + + Private m_CurrProj As ProjFileVM + Friend Property CurrProj As ProjFileVM + Get + Return m_CurrProj + End Get + Set(value As ProjFileVM) + m_CurrProj = value + End Set + End Property + + Private m_CurrProd As ProdFileVM + Friend Property CurrProd As ProdFileVM + Get + Return m_CurrProd + End Get + Set(value As ProdFileVM) + m_CurrProd = value + End Set + End Property + + ' indice progetto in caricamento + Private m_nLoadingProjId As Integer = 0 + Friend Property nLoadingProjId As Integer + Get + Return m_nLoadingProjId + End Get + Set(value As Integer) + m_nLoadingProjId = value + End Set + End Property + + Public Function SetCurrProj(nProjId As Integer) As Boolean + Dim CurrProjM As ProjFileM = DbControllers.m_ProjController.FindByProjIdConv(nProjId) + If IsNothing(CurrProjM) Then Return False + m_CurrProj = New ProjFileVM(CurrProjM) + If Map.refMainWindowVM.MainWindowM.bOnlyProd AndAlso CurrProjM.nProdId > 0 AndAlso IsNothing(CurrProd) Then + SetCurrProd(m_CurrProj.nProdId) + End If + Return True + End Function + + Public Function SetCurrProd(nProdId As Integer) As Boolean + Dim CurrProdM As ProdFileM = DbControllers.m_ProdController.FindCoreByProdId(nProdId) + If IsNothing(CurrProdM) Then Return False + m_CurrProd = New ProdFileVM(CurrProdM) + If Map.refMainWindowVM.MainWindowM.bOnlyProd AndAlso CurrProdM.nProjIdList.Count > 0 AndAlso IsNothing(CurrProj) Then + SetCurrProj(m_CurrProd.nProjIdList(0)) + End If + Return True + End Function + +End Module diff --git a/EgtBEAMWALL.Optimizer/ProjectTypeWnd/OnlyProdProjectTypeWndV.xaml b/EgtBEAMWALL.Optimizer/ProjectTypeWnd/OnlyProdProjectTypeWndV.xaml new file mode 100644 index 00000000..d8173083 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ProjectTypeWnd/OnlyProdProjectTypeWndV.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/OnlyProdRawPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/RawPartManager/OnlyProdRawPartManagerV.xaml.vb new file mode 100644 index 00000000..2c280369 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/OnlyProdRawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdRawPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml new file mode 100644 index 00000000..6ec0858d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml @@ -0,0 +1,47 @@ + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml.vb b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml.vb new file mode 100644 index 00000000..63a2a858 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerV.xaml.vb @@ -0,0 +1,3 @@ +Public Class RawPartManagerV + +End Class diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerVM.vb b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerVM.vb new file mode 100644 index 00000000..389fab21 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerVM.vb @@ -0,0 +1,432 @@ +Imports System.Data.Entity.ModelConfiguration.Configuration.Properties +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class RawPartManagerVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_RawPartManager_IsEnabled As Boolean = True + Public ReadOnly Property RawPartManagerIsEnabled As Boolean + Get + Return m_RawPartManager_IsEnabled + End Get + End Property + Friend Sub SetRawPartManagerIsEnabled(bIsEnabled As Boolean) + m_RawPartManager_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(RawPartManagerIsEnabled)) + End Sub + + Private m_ProduceRawPart_Visibility As Visibility + Public ReadOnly Property ProduceRawPart_Visibility As Visibility + Get + Return m_ProduceRawPart_Visibility + End Get + End Property + + Private m_MovePartInRawPart_Visibility As Visibility + Public ReadOnly Property MovePartInRawPart_Visibility As Visibility + Get + Return m_MovePartInRawPart_Visibility + End Get + End Property + + ' Definizione comandi + Private m_cmdProduceAllRawPart As ICommand + Private m_cmdProduceRawPart As ICommand + Private m_cmdCopyRawPart As ICommand + Private m_cmdRemoveRawPart As ICommand + Private m_cmdRemoveAllRawPart As ICommand + Private m_cmdMovePartInRawPart As ICommand + +#End Region ' Fields & Properties + +#Region "Messages" + + Public ReadOnly Property ProduceRawPart_ToolTip As String + Get + Return EgtMsg(61912) + End Get + End Property + + Public ReadOnly Property ProduceAllRawPart_ToolTip As String + Get + Return EgtMsg(61913) + End Get + End Property + + Public ReadOnly Property CopyRawPart_ToolTip As String + Get + Return EgtMsg(61914) + End Get + End Property + + Public ReadOnly Property RemoveRawPart_ToolTip As String + Get + Return EgtMsg(61915) + End Get + End Property + + Public ReadOnly Property RemoveAllRawPart_ToolTip As String + Get + Return EgtMsg(61976) + End Get + End Property + + Public ReadOnly Property ReOrderPart_ToolTip As String + Get + Return EgtMsg(61916) + End Get + End Property + + Public ReadOnly Property RemovePart_ToolTip As String + Get + Return EgtMsg(61919) + End Get + End Property + + Public ReadOnly Property MovePartInRawPart_ToolTip As String + Get + Return EgtMsg(61944) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTORS" + + Sub New() + Map.SetRefRawPartManagerVM(Me) + ' mostro bottoni produci solo se supervisore attivo + m_ProduceRawPart_Visibility = If(Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.SUPERVISOR), Visibility.Visible, Visibility.Collapsed) + End Sub + +#End Region ' Constructors + +#Region "METHODS" + + Friend Sub UpdateMovePartInRawPartVisibility() + m_MovePartInRawPart_Visibility = If(Map.refMainWindowVM.MainWindowM.nUserLevel > 5 AndAlso Not IsNothing(ProjectManagerVM.CurrProd) AndAlso + ProjectManagerVM.CurrProd.nType = BWType.WALL, Visibility.Visible, Visibility.Collapsed) + NotifyPropertyChanged(NameOf(MovePartInRawPart_Visibility)) + End Sub + +#End Region ' Methods + +#Region "COMMANDS" + +#Region "ProduceRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceRawPart_Command As ICommand + Get + If m_cmdProduceRawPart Is Nothing Then + m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart) + End If + Return m_cmdProduceRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim ErrorMsg As String = "" + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCE) + Map.refCALCPanelVM.Verify() + Return + End If + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MessageBox.Show(ErrorMsg) + End If + Else + ' altrimenti lo copio se path disponibile + If Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.OK Or Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.INFO Then + Dim sSaveCncPath As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVECNCPATH, "", sSaveCncPath, CurrentMachine.sMachIniFile) + Dim sSaveExt As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVEEXT, "", sSaveExt, CurrentMachine.sMachIniFile) + If String.IsNullOrWhiteSpace(sSaveExt) Then + sSaveExt = ".cnc" + ElseIf sSaveExt(0) <> "." Then + sSaveExt = "." & sSaveExt + End If + Try + Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & ".cnc" + Dim sNewPath As String = sSaveCncPath & "\" & Map.refProdManagerVM.CurrProd.sProdId & "-" & Map.refMachGroupPanelVM.SelectedMachGroup.Name.ToString() & sSaveExt + File.Copy(sMachGroupFilePath, sNewPath, True) + MessageBox.Show(String.Format("File copied! You can find it at {0}", {sNewPath}), "Info", MessageBoxButton.OK, MessageBoxImage.Information) + Catch ex As Exception + MessageBox.Show(String.Format("Copy to {0} folder failed!", {sSaveCncPath}), "Error", MessageBoxButton.OK, MessageBoxImage.Error) + End Try + End If + End If + End Sub + + Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean + If IsNothing(MachGroup) Then Return False + ' se barra gia' assegnata a supervisore, esco + If MachGroup.nProduction_State >= ItemState.Assigned Then Return False + If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then + ' se ci sono modifiche, salvo il pogetto + If EgtGetModified() AndAlso Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Map.refProdManagerVM.Save() + ElseIf EgtGetModified() AndAlso Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refOnlyProdManagerVM.Save() + End If + ' mando al supervisore + DbControllers.m_MachGroupController.UpdateOrder(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(ProjectManagerVM.CurrProd.nProdId) + 1) + DbControllers.m_MachGroupController.UpdateSupervisor(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId) + MachGroup.SentToSupervisor() + For Each Part As PartVM In MachGroup.PartVMList + DbControllers.m_PartController.UpdateStatus(ProjectManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned) + Part.nProduction_State = ItemState.Assigned + Part.NotifyPropertyChanged(NameOf(Part.Background)) + ' disabilito impostazione modificato + Dim DisableMgr As New DisableModifiedMgr + ' blocco modifica del pezzo + EgtDuploSetLocked(Part.nPartId) + ' ripristino precedente impostazione modificato + DisableMgr.ReEnable() + Next + Return True + Else + ErrorMsg = String.Format(EgtMsg(62568), MachGroup.Name) + Return False + End If + End Function + +#End Region ' ProduceRawPart + +#Region "ProduceAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property ProduceAllRawPart_Command As ICommand + Get + If m_cmdProduceAllRawPart Is Nothing Then + m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart) + End If + Return m_cmdProduceAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub ProduceAllRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + ' se attiva opzione e non ancora calcolato + If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.ND AndAlso x.nGlobalState = CalcStates.NOTCALCULATED) Then + Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCEALL) + Map.refCALCPanelVM.VerifyAll() + Return + End If + If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then + Dim MachgroupErrorList As New List(Of MachGroupVM) + Dim sErrorMessage As String = "" + Dim bErrorMessage As Boolean = False + For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList + ' verifico se modalita' supervisore attiva + If GetPrivateProfileInt(S_GENERAL, K_SUPERVISOR, 1, CurrentMachine.sMachIniFile) = 1 Then + Dim ErrorMsg As String = "" + If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then + MachgroupErrorList.Add(Machgroup) + End If + Else + ' altrimenti lo copio se path disponibile + If Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.OK Or Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.INFO Then + Dim sSaveCncPath As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVECNCPATH, "", sSaveCncPath, CurrentMachine.sMachIniFile) + Dim sSaveExt As String = "" + GetPrivateProfileString(S_GENERAL, K_SAVEEXT, "", sSaveExt, CurrentMachine.sMachIniFile) + If String.IsNullOrWhiteSpace(sSaveExt) Then + sSaveExt = ".cnc" + ElseIf sSaveExt(0) <> "." Then + sSaveExt = "." & sSaveExt + End If + If String.IsNullOrWhiteSpace(sSaveCncPath) OrElse Not Directory.Exists(sSaveCncPath) Then Return + Try + Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & Machgroup.Name.ToString() & ".cnc" + Dim sNewPath As String = sSaveCncPath & "\" & Map.refProdManagerVM.CurrProd.sProdId & "-" & Machgroup.Name.ToString() & sSaveExt + File.Copy(sMachGroupFilePath, sNewPath, True) + sErrorMessage &= String.Format("File copied! You can find it at {0}", {sNewPath}) & Environment.NewLine + Catch ex As Exception + sErrorMessage &= String.Format("Copy to {0} folder failed!", {sSaveCncPath}) & Environment.NewLine + End Try + End If + End If + Next + If Not String.IsNullOrWhiteSpace(sErrorMessage) Then + sErrorMessage = "Results for all the parts generated:" & Environment.NewLine & sErrorMessage + MessageBox.Show(sErrorMessage, If(bErrorMessage, "Error", "Info"), MessageBoxButton.OK, MessageBoxImage.Information) + End If + If MachgroupErrorList.Count > 0 Then + Dim sMachGroups As String = "" + For Each MachGroup In MachgroupErrorList + sMachGroups &= " " & MachGroup.Name & "," + Next + sMachGroups = sMachGroups.Trim({" "c, ","c}) + MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups)) + End If + End If + End Sub + +#End Region ' ProduceAllRawPart + +#Region "CopyRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property CopyRawPart_Command As ICommand + Get + If m_cmdCopyRawPart Is Nothing Then + m_cmdCopyRawPart = New Command(AddressOf CopyRawPart) + End If + Return m_cmdCopyRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub CopyRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim nQty As Integer = 1 + ' se premuto shift + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM() + Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM) + If Not MultiCopyRawPartWnd.ShowDialog() Then Return + nQty = MultiCopyRawPartWndVM.nQuantity + End If + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' creo copia + Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty) + If Not IsNothing(NewMachGroup) Then + ' lo seleziono + Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup + End If + End Sub + +#End Region ' CopyRawPart + +#Region "RemoveRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveRawPart_Command As ICommand + Get + If m_cmdRemoveRawPart Is Nothing Then + m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPartCmd) + End If + Return m_cmdRemoveRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveRawPartCmd() + RemoveRawPart() + End Sub + + Public Sub RemoveRawPart(Optional bAll As Boolean = False) + If IsNothing(ProjectManagerVM.CurrProd) Then Return + ' se tutti + If bAll Then + ' cancello tutti + For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1 + Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index) + ' se barra gia' assegnata a supervisore, esco + If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For + CurrMachGroup.DeleteMachGroup(True) + Next + Else + Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If IsNothing(SelMachGroup) Then Return + ' se barra gia' assegnata a supervisore, esco + If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return + SelMachGroup.DeleteMachGroup() + If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then Map.refMachGroupPanelVM.SelectedMachGroup = Map.refMachGroupPanelVM.MachGroupVMList(0) + End If + EgtDraw() + ' se nessun grezzo, rimetto tutti i pezzi invisibili + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then + Map.refProjectVM.BTLStructureVM.HideAll(True) + End If + End Sub + +#End Region ' RemoveRawPart + +#Region "RemoveAllRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property RemoveAllRawPart_Command As ICommand + Get + If m_cmdRemoveAllRawPart Is Nothing Then + m_cmdRemoveAllRawPart = New Command(AddressOf RemoveAllRawPart) + End If + Return m_cmdRemoveAllRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub RemoveAllRawPart() + RemoveRawPart(True) + End Sub + +#End Region ' RemoveAllRawPart + +#Region "MovePartInRawPart" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property MovePartInRawPart_Command As ICommand + Get + If m_cmdMovePartInRawPart Is Nothing Then + m_cmdMovePartInRawPart = New Command(AddressOf MovePartInRawPart) + End If + Return m_cmdMovePartInRawPart + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub MovePartInRawPart() + If IsNothing(ProjectManagerVM.CurrProd) Then Return + Dim MovePartInRawPartWndVM As New MovePartInRawPartWndVM() + Dim MovePartInRawPartWnd As Object + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + MovePartInRawPartWnd = New OnlyProdMovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) + Else + MovePartInRawPartWnd = New MovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) + End If + If Not MovePartInRawPartWnd.ShowDialog() Then Return + End Sub + +#End Region ' MovePartInRawPart + +#End Region ' Commands + +End Class diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml new file mode 100644 index 00000000..1889ce1d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml.vb b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml.vb new file mode 100644 index 00000000..f35aa6e4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/RawPartManager/RawPartManagerWndV.xaml.vb @@ -0,0 +1,3 @@ +Public Class RawPartManagerWndV + +End Class diff --git a/EgtBEAMWALL.Optimizer/Resources/AboutBox/EgalwareLogo.png b/EgtBEAMWALL.Optimizer/Resources/AboutBox/EgalwareLogo.png new file mode 100644 index 00000000..6868d9d1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/AboutBox/EgalwareLogo.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/AboutBoxImage.png b/EgtBEAMWALL.Optimizer/Resources/AboutBoxImage.png new file mode 100644 index 00000000..a11230b2 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/AboutBoxImage.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ChooseMachine.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ChooseMachine.png new file mode 100644 index 00000000..7f246703 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ChooseMachine.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Edit.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Edit.png new file mode 100644 index 00000000..0e325bec Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Edit.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ResetCalc.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ResetCalc.png new file mode 100644 index 00000000..71ca1ea4 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/ResetCalc.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Simulate.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Simulate.png new file mode 100644 index 00000000..dc2cf654 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Simulate.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Verify.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Verify.png new file mode 100644 index 00000000..0012ce56 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/Verify.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/CALCPanel/VerifyAll.png b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/VerifyAll.png new file mode 100644 index 00000000..b49c1831 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/CALCPanel/VerifyAll.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/Configuration/MachiningsTable.png b/EgtBEAMWALL.Optimizer/Resources/Configuration/MachiningsTable.png new file mode 100644 index 00000000..5ab6b0cf Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/Configuration/MachiningsTable.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/AddPointCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/AddPointCurve.png new file mode 100644 index 00000000..5bd7bfb7 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/AddPointCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ApproxCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ApproxCurve.png new file mode 100644 index 00000000..593f8668 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ApproxCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Arc3P.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Arc3P.png new file mode 100644 index 00000000..1df2af49 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Arc3P.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcCSE.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcCSE.png new file mode 100644 index 00000000..64e2aee6 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcCSE.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcFlip.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcFlip.png new file mode 100644 index 00000000..4468ce00 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcFlip.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcPDP.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcPDP.png new file mode 100644 index 00000000..f74b1a5f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ArcPDP.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/BreakCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/BreakCurve.png new file mode 100644 index 00000000..183d4a2a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/BreakCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Chamfer.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Chamfer.png new file mode 100644 index 00000000..a10190dc Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Chamfer.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColor.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColor.png new file mode 100644 index 00000000..3497b6b1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColor.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColorAlpha.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColorAlpha.png new file mode 100644 index 00000000..04bb076c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeColorAlpha.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeLayer.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeLayer.png new file mode 100644 index 00000000..cb06885a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeLayer.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeStart.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeStart.png new file mode 100644 index 00000000..1321300c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ChangeStart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Circle3P.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Circle3P.png new file mode 100644 index 00000000..ae4f8bda Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Circle3P.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCD.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCD.png new file mode 100644 index 00000000..5480d8f9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCD.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCP.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCP.png new file mode 100644 index 00000000..77a481b0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/CircleCP.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Delete.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Delete.png new file mode 100644 index 00000000..b90063f2 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Delete.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeCurve.png new file mode 100644 index 00000000..be9e1c7a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeSurf.png new file mode 100644 index 00000000..b62f3e9d Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExplodeSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtendCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtendCurve.png new file mode 100644 index 00000000..cbf8d91f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtendCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractFacetLoops.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractFacetLoops.png new file mode 100644 index 00000000..2fd45919 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractFacetLoops.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractLoops.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractLoops.png new file mode 100644 index 00000000..6c71a4c1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractLoops.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractSurfFacet.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractSurfFacet.png new file mode 100644 index 00000000..76601717 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ExtractSurfFacet.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Extrude.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Extrude.png new file mode 100644 index 00000000..1b245f2d Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Extrude.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Fillet.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Fillet.png new file mode 100644 index 00000000..b40c3779 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Fillet.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/IntersectSurfSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/IntersectSurfSurf.png new file mode 100644 index 00000000..1f4c4aac Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/IntersectSurfSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertCurve.png new file mode 100644 index 00000000..e10899de Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertSurf.png new file mode 100644 index 00000000..5b3bf7f9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/InvertSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/JoinCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/JoinCurve.png new file mode 100644 index 00000000..666b2e68 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/JoinCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Line2P.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Line2P.png new file mode 100644 index 00000000..2690838f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Line2P.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinePDL.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinePDL.png new file mode 100644 index 00000000..043fe986 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinePDL.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinearDimension.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinearDimension.png new file mode 100644 index 00000000..706c9e82 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/LinearDimension.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/MergeSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/MergeSurf.png new file mode 100644 index 00000000..f3f6ed3e Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/MergeSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror.png new file mode 100644 index 00000000..c8edab75 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror3D.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror3D.png new file mode 100644 index 00000000..a169939c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Mirror3D.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyCurve.png new file mode 100644 index 00000000..f84dfcff Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyText.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyText.png new file mode 100644 index 00000000..ba37037d Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ModifyText.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Move.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Move.png new file mode 100644 index 00000000..78ab3a24 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Move.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Offset.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Offset.png new file mode 100644 index 00000000..81c0be25 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Offset.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Plane.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Plane.png new file mode 100644 index 00000000..bb85fcb6 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Plane.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Point.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Point.png new file mode 100644 index 00000000..5a43bfeb Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Point.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Polygon.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Polygon.png new file mode 100644 index 00000000..fe09e3ae Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Polygon.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/PolygonSide.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/PolygonSide.png new file mode 100644 index 00000000..c90cd4bf Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/PolygonSide.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rectangle2P.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rectangle2P.png new file mode 100644 index 00000000..51bb0a70 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rectangle2P.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemoveColor.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemoveColor.png new file mode 100644 index 00000000..c3b2850b Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemoveColor.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemovePointCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemovePointCurve.png new file mode 100644 index 00000000..ee039fe3 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/RemovePointCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Revolve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Revolve.png new file mode 100644 index 00000000..821795ff Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Revolve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate.png new file mode 100644 index 00000000..ec867359 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate3D.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate3D.png new file mode 100644 index 00000000..f9d6d3dc Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Rotate3D.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Ruled.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Ruled.png new file mode 100644 index 00000000..25aa70c4 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Ruled.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale.png new file mode 100644 index 00000000..ab5f4479 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale3D.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale3D.png new file mode 100644 index 00000000..08bf3a11 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Scale3D.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Screw.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Screw.png new file mode 100644 index 00000000..f9d52270 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Screw.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidAddSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidAddSurf.png new file mode 100644 index 00000000..cd687b1e Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidAddSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidIntersectSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidIntersectSurf.png new file mode 100644 index 00000000..b5d1518e Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidIntersectSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidSubtractSurf.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidSubtractSurf.png new file mode 100644 index 00000000..0672f494 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SolidSubtractSurf.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SplitCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SplitCurve.png new file mode 100644 index 00000000..25386eb5 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/SplitCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Swept.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Swept.png new file mode 100644 index 00000000..88f86ee1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Swept.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Text.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Text.png new file mode 100644 index 00000000..c7af3e01 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/Text.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ThickCurve.png b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ThickCurve.png new file mode 100644 index 00000000..03ac50ca Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/DrawPanel/ThickCurve.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/Egalware.ico b/EgtBEAMWALL.Optimizer/Resources/Egalware.ico new file mode 100644 index 00000000..5adc1d9e Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/Egalware.ico differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtBEAMWALL.ico b/EgtBEAMWALL.Optimizer/Resources/EgtBEAMWALL.ico new file mode 100644 index 00000000..e5c1219f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtBEAMWALL.ico differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Folder.png b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Folder.png new file mode 100644 index 00000000..2c1339d0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Folder.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtDialog/New.png b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/New.png new file mode 100644 index 00000000..78a5a0b3 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/New.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Restore.png b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Restore.png new file mode 100644 index 00000000..1b8455e9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Restore.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Root.png b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Root.png new file mode 100644 index 00000000..86b6283a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtDialog/Root.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Asterisk.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Asterisk.png new file mode 100644 index 00000000..82b2dcaa Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Asterisk.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Error.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Error.png new file mode 100644 index 00000000..4f6d82fb Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Error.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Exclamation.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Exclamation.png new file mode 100644 index 00000000..7e098c6c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Exclamation.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Hand.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Hand.png new file mode 100644 index 00000000..59dfe1c1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Hand.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Information.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Information.png new file mode 100644 index 00000000..755d51b8 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Information.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Question.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Question.png new file mode 100644 index 00000000..8312408f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Question.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Warning.png b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Warning.png new file mode 100644 index 00000000..1e72f684 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/EgtMessageBox/Warning.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Analyze.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Analyze.png new file mode 100644 index 00000000..e322f1d5 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Analyze.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/ChangeParam.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/ChangeParam.png new file mode 100644 index 00000000..2cb53b6a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/ChangeParam.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/GetDist.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/GetDist.png new file mode 100644 index 00000000..520e4065 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/GetDist.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Ott.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Ott.png new file mode 100644 index 00000000..7b515606 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Ott.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Statistics.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Statistics.png new file mode 100644 index 00000000..9e8de191 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Statistics.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Vis.png b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Vis.png new file mode 100644 index 00000000..3932ee75 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/InstrumentPanel/Vis.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddFeature.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddFeature.png new file mode 100644 index 00000000..4fad3bf8 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddFeature.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddPart.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddPart.png new file mode 100644 index 00000000..71c7f507 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddToRawPart.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddToRawPart.png new file mode 100644 index 00000000..2a61a231 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/AddToRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyFeature.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyFeature.png new file mode 100644 index 00000000..4327d0c9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyFeature.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyPart.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyPart.png new file mode 100644 index 00000000..6d7ddbbd Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/CopyPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/MacroFeature.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/MacroFeature.png new file mode 100644 index 00000000..e1a23c05 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/MacroFeature.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPart.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPart.png new file mode 100644 index 00000000..5cd9de33 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPartAuto.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPartAuto.png new file mode 100644 index 00000000..e98e4157 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/NewRawPartAuto.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemoveFeature.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemoveFeature.png new file mode 100644 index 00000000..ff302913 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemoveFeature.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemovePart.png b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemovePart.png new file mode 100644 index 00000000..d9a30a77 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/LeftPanel/RemovePart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/MainMenu/Send.png b/EgtBEAMWALL.Optimizer/Resources/MainMenu/Send.png new file mode 100644 index 00000000..a9bcbe4c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/MainMenu/Send.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveLeftParts.png b/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveLeftParts.png new file mode 100644 index 00000000..25b6de38 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveLeftParts.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveRightParts.png b/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveRightParts.png new file mode 100644 index 00000000..551c31fc Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/MovePartInRawPart/MoveRightParts.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/OpenProjectFileDialog/Archived.png b/EgtBEAMWALL.Optimizer/Resources/OpenProjectFileDialog/Archived.png new file mode 100644 index 00000000..bad56a1f Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/OpenProjectFileDialog/Archived.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/FlipRot.png b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/FlipRot.png new file mode 100644 index 00000000..025b2552 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/FlipRot.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockFlip.png b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockFlip.png new file mode 100644 index 00000000..5b4cc1ec Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockFlip.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockRotation.png b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockRotation.png new file mode 100644 index 00000000..6079c1da Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/UnlockRotation.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/Warehouse.png b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/Warehouse.png new file mode 100644 index 00000000..f2ba7545 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/OptimizePanel/Warehouse.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PDFEditor/Delete.png b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/Delete.png new file mode 100644 index 00000000..b90063f2 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/Delete.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveDown.png b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveDown.png new file mode 100644 index 00000000..e2391dd9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveDown.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveUp.png b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveUp.png new file mode 100644 index 00000000..690b72a8 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/MoveUp.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PDFPreview.png b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PDFPreview.png new file mode 100644 index 00000000..8fda14bc Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PDFPreview.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PrintPDF.png b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PrintPDF.png new file mode 100644 index 00000000..f157e996 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PDFEditor/PrintPDF.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/Clock.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/Clock.png new file mode 100644 index 00000000..6b7c9186 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/Clock.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftInvert.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftInvert.png new file mode 100644 index 00000000..25b6de38 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftInvert.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftRotate.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftRotate.png new file mode 100644 index 00000000..c5fbfb32 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/LeftRotate.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.old.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.old.png new file mode 100644 index 00000000..273cb2e4 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.old.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.png new file mode 100644 index 00000000..d9fa7e32 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/Locked.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/RightInvert.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/RightInvert.png new file mode 100644 index 00000000..f2d8c5c9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/RightInvert.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/RightRotate.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/RightRotate.png new file mode 100644 index 00000000..1d3d7596 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/RightRotate.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.old.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.old.png new file mode 100644 index 00000000..92665677 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.old.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.png b/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.png new file mode 100644 index 00000000..e51fa23a Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/PartManager/Unlocked.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/AddProj.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/AddProj.png new file mode 100644 index 00000000..f6a90193 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/AddProj.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ExportProject.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ExportProject.png new file mode 100644 index 00000000..90b4a55e Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ExportProject.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProd.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProd.png new file mode 100644 index 00000000..add3f83c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProd.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProj.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProj.png new file mode 100644 index 00000000..8532d4c8 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/GoToProj.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportBTL.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportBTL.png new file mode 100644 index 00000000..3bf49d9c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportBTL.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportProject.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportProject.png new file mode 100644 index 00000000..1244776c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/ImportProject.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/New.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/New.png new file mode 100644 index 00000000..78a5a0b3 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/New.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Open.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Open.png new file mode 100644 index 00000000..616c02b0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Open.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Options.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Options.png new file mode 100644 index 00000000..6fb84bbc Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Options.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Save.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Save.png new file mode 100644 index 00000000..0eca2603 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/Save.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/SaveAs.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/SaveAs.png new file mode 100644 index 00000000..1d5cfaef Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/SaveAs.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ProjectManager/UpdateBTL.png b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/UpdateBTL.png new file mode 100644 index 00000000..dabe3aee Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ProjectManager/UpdateBTL.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowAll.png b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowAll.png new file mode 100644 index 00000000..37a0de81 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowAll.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowBuilding.png b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowBuilding.png new file mode 100644 index 00000000..419a9555 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowBuilding.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowSolid.png b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowSolid.png new file mode 100644 index 00000000..383a95ef Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowBeamPanel/ShowSolid.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingHL.png b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingHL.png new file mode 100644 index 00000000..8aa5a3ac Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingHL.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingSH.png b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingSH.png new file mode 100644 index 00000000..0c6690d1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingSH.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingWF.png b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingWF.png new file mode 100644 index 00000000..1f2de621 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ShowPanel/RenderingWF.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/Statistics/CopyToClipboard.png b/EgtBEAMWALL.Optimizer/Resources/Statistics/CopyToClipboard.png new file mode 100644 index 00000000..5a8780fd Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/Statistics/CopyToClipboard.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/Statistics/PrintPDF.png b/EgtBEAMWALL.Optimizer/Resources/Statistics/PrintPDF.png new file mode 100644 index 00000000..f157e996 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/Statistics/PrintPDF.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/CopyRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/CopyRawPart.png new file mode 100644 index 00000000..cdcd0fd4 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/CopyRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveDownPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveDownPart.png new file mode 100644 index 00000000..e2391dd9 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveDownPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/MovePartInRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MovePartInRawPart.png new file mode 100644 index 00000000..c4dcd5a1 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MovePartInRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveUpPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveUpPart.png new file mode 100644 index 00000000..690b72a8 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/MoveUpPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceAllRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceAllRawPart.png new file mode 100644 index 00000000..922dd623 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceAllRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceRawPart.png new file mode 100644 index 00000000..0a77cdfb Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ProduceRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveAllRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveAllRawPart.png new file mode 100644 index 00000000..a913ce7c Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveAllRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.old.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.old.png new file mode 100644 index 00000000..aa4257e0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.old.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.png new file mode 100644 index 00000000..2c1e6372 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemovePart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveRawPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveRawPart.png new file mode 100644 index 00000000..23ba0d89 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/RemoveRawPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TopPanel/ReorderPart.png b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ReorderPart.png new file mode 100644 index 00000000..f76b880d Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TopPanel/ReorderPart.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/TreeView/Folder.png b/EgtBEAMWALL.Optimizer/Resources/TreeView/Folder.png new file mode 100644 index 00000000..2c1339d0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/TreeView/Folder.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBACK.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBACK.png new file mode 100644 index 00000000..0c2790cd Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBACK.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBOTTOM.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBOTTOM.png new file mode 100644 index 00000000..6a48b645 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromBOTTOM.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromFRONT.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromFRONT.png new file mode 100644 index 00000000..08abc995 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromFRONT.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NE.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NE.png new file mode 100644 index 00000000..e0c71baf Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NE.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NW.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NW.png new file mode 100644 index 00000000..203e2903 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_NW.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SE.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SE.png new file mode 100644 index 00000000..28910889 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SE.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SW.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SW.png new file mode 100644 index 00000000..909e25e5 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromISO_SW.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromLEFT.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromLEFT.png new file mode 100644 index 00000000..d4a4e85d Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromLEFT.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromRIGHT.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromRIGHT.png new file mode 100644 index 00000000..f182c1a2 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromRIGHT.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromTOP.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromTOP.png new file mode 100644 index 00000000..214358d0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/LookFromTOP.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomAll.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomAll.png new file mode 100644 index 00000000..e1a27d16 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomAll.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomIn.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomIn.png new file mode 100644 index 00000000..b370a3e0 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomIn.png differ diff --git a/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomOut.png b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomOut.png new file mode 100644 index 00000000..187a1a02 Binary files /dev/null and b/EgtBEAMWALL.Optimizer/Resources/ViewPanel/ZoomOut.png differ diff --git a/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb new file mode 100644 index 00000000..d83397cb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb @@ -0,0 +1,1240 @@ +Imports System.Windows.Interop +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.DataLayer.DatabaseModels +Imports System.Windows.Forms + +Public Class MySceneHostVM + Inherits EgtWPFLib5.SceneHostVM + + ' Identificativi per pezzo da selezionare/deselezionare + Private m_nIdToSel As Integer = GDB_ID.NULL + Private m_nIdToDesel As Integer = GDB_ID.NULL + ' Dati movimento + Private m_dMaxStep As Double = 0 + ' Dati per Drag + Private m_nRestRadius As Integer = 5 + Private m_bDrag As Boolean = False + Private m_bDragToStart As Boolean = False + Private m_bVerify As Boolean = False + Private m_bFromParking As Boolean = False + Private m_bDragging As Boolean = False + Private m_locPrev As System.Drawing.Point + Private m_ptPrev As Point3d + Private m_vtTotMove As Vector3d + Private m_dSnapDist As Double = 0 + + + Private bReducedCut As Boolean = False + Private m_bMagnetic As Boolean + +#Region "CONSTRUCTOR" + + Sub New() + MyBase.New() + AddHandler MainController.OnNewProject, AddressOf OnNewProject + AddHandler MainController.OnOpenProject, AddressOf OnOpenProject + AddHandler MainController.OnSavingProject, AddressOf OnSavingProject + AddHandler MainController.OnSavedProject, AddressOf OnSavedProject + AddHandler MainController.OnImportingProject, AddressOf OnImportingProject + AddHandler MainController.OnImportedProject, AddressOf OnImportedProject + AddHandler MainController.PrepareInputBox, AddressOf PrepareInputBox + AddHandler MainController.SetInputBoxText, AddressOf SetInputBoxText + AddHandler MainController.SetInputBoxCheck, AddressOf SetInputBoxCheck + AddHandler MainController.AddInputBoxCombo, AddressOf AddInputBoxCombo + AddHandler MainController.UpdateUI, AddressOf UpdateUI + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Overrides Sub InitScene() + InitSceneEvents() + ' Inizializzazione Scena + PreInitializeScene() + ' Se tutto bene + If MainScene.Init() And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.BEAM Or KEY_OPT.WALL) Then + PostInitializeScene() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + ' Imposto focus pulsante su false + MainScene.SetFocusOnMove(False) + ' Recupero e imposto handle finestra principale + Dim hMainWnd As IntPtr = New WindowInteropHelper(Application.Current.MainWindow).Handle + EgtSetMainWindowHandle(hMainWnd) + EgtSetCurrentContext(MainScene.GetCtx()) + ' Imposto direttorio ausiliario per import/gestione BTL + Dim sBtlAuxDir As String = String.Empty + GetMainPrivateProfileString(S_IMPORT, K_BTLAUXDIR, "", sBtlAuxDir) + EgtSetBtlAuxDir(sBtlAuxDir) + ' inizializzo gestore travi e pareti + EgtInitBeamMgr(EIB_FL.TS3_POS + EIB_FL.USEUATTR) + ' inizializzo gestore lavorazioni + EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir) + ' Seleziono la macchina impostata nel file ini + Map.refMachinePanelVM.LoadCurrentMachine() + Return + End If + ' Problemi + ' Se manca la chiave + If Map.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or Map.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then + EgtOutLog("Missing Dongle") + ' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore" + Dim sText As String = EgtMsg(10102) & vbCrLf & EgtMsg(10103) + Dim sTitle As String = EgtMsg(10101) + MessageBox.Show(Application.Current.MainWindow, sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error) + ' Altrimenti manca la licenza + Else + EgtOutLog("Problems with Licence") + ' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore" + Dim sText As String = EgtMsg(10105) & vbCrLf & EgtMsg(10106) + Dim sTitle As String = EgtMsg(10101) + If MessageBox.Show(Application.Current.MainWindow, sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then + ' Apro dialogo per richiesta file licenza + Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With { + .DefaultExt = ".lic", + .Filter = "Licences (.lic)|*.lic", + .CheckFileExists = True, + .ValidateNames = True + } + If LicDlg.ShowDialog() = True Then + ' Recupero il direttorio del file + Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName) + ' Se il file non è già nel direttorio di configurazione lo copio + If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(Map.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then + Try + File.Copy(LicDlg.FileName, Path.Combine(Map.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True) + Catch ex As Exception + End Try + End If + ' Imposto il nuovo file di licenza nell'Ini + WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName) + End If + End If + End If + ' Chiudo il programma + End + End Sub + + Public Overrides Sub InitSceneEvents() + AddHandler MainScene.OnCursorPos, AddressOf OnCursorPos + AddHandler MainScene.OnMouseSetObjFilterForSelect, AddressOf OnMouseSetObjFilterForSelect + AddHandler MainScene.OnMouseSelectedAll, AddressOf OnMouseSelectedAll + AddHandler MainScene.OnMouseDeselectedAll, AddressOf OnMouseDeselectedAll + AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene + AddHandler MainScene.OnMouseMoveScene, AddressOf OnMouseMoveScene + AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene + AddHandler MainScene.OnMouseSelectingObj, AddressOf OnMouseSelectingObj + AddHandler MainScene.OnMouseSelectedObj, AddressOf OnMouseSelectedObj + AddHandler MainScene.OnMouseSelectedPart, AddressOf OnMouseSelectedPart + AddHandler MainScene.OnMouseSelectedLayer, AddressOf OnMouseSelectedLayer + AddHandler MainScene.OnMouseSelectedPath, AddressOf OnMouseSelectedPath + AddHandler MainScene.OnMousePointFromSelection, AddressOf OnMousePointFromSelection + AddHandler MainScene.OnMouseDone, AddressOf OnMouseDone + AddHandler MainScene.OnMouseSelectedPoint, AddressOf OnMouseSelectedPoint + AddHandler MainScene.OnMouseSelectedDir, AddressOf OnMouseSelectedDir + AddHandler MainScene.OnMouseMoveSelPoint, AddressOf OnMouseMoveSelPoint + AddHandler MainScene.OnShowDistance, AddressOf OnShowDistance + AddHandler MainScene.KeyDown, AddressOf OnKeyDown + AddHandler MainScene.OnCloseGetDist, AddressOf OnCloseGetDist + AddHandler MainScene.OnChangedSnapPointType, AddressOf OnChangedSnapPointType + End Sub + + Private Sub PreInitializeScene() + ' imposto colore di default + Dim DefColor As New Color3d(0, 0, 0) + GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor) + MainScene.SetDefaultMaterial(DefColor) + ' imposto colori sfondo + Dim BackTopColor As New Color3d(192, 192, 192) + GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor) + Dim BackBotColor As New Color3d(BackTopColor) + GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor) + MainScene.SetViewBackground(BackTopColor, BackBotColor) + ' imposto colore di evidenziazione + Dim MarkColor As New Color3d(255, 255, 0) + GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor) + MainScene.SetMarkMaterial(MarkColor) + ' imposto colore per superfici selezionate + Dim SelSurfColor As New Color3d(255, 255, 192) + GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor) + MainScene.SetSelSurfMaterial(SelSurfColor) + ' imposto tipo e colore del rettangolo di zoom + Dim bOutline As Boolean = True + Dim ZwColor As New Color3d(0, 0, 0) + GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor) + MainScene.SetZoomWinAttribs(bOutline, ZwColor) + ' imposto colore della linea di distanza + Dim DstLnColor As New Color3d(255, 0, 0) + GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor) + MainScene.SetDistLineMaterial(DstLnColor) + ' imposto parametri OpenGL + Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3) + Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0) + Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32) + Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32) + MainScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits) + End Sub + + Private Sub PostInitializeScene() + ' Impostazioni Controller + MainController.SetScene(MainScene) + ' imposto tipo coordinate + MainScene.SetGridCursorPos(True) + ' modo di visualizzazione + Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING) + Map.refShowPanelVM.SetShowMode(DirectCast(nShowMode, SM)) + ' visualizzazione avanzata dei triangoli costituenti le superfici + Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0) + EgtSetShowTriaAdv(bShowTriaAdv) + ' tipo visualizzazione per Zmap + Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1) + EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False) + ' dimensione lineare max in pixel delle textures + Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096) + EgtSetTextureMaxLinPixels(nTxrMaxLinPix) + ' tipo snap point + MainScene.SetSnapPointType(SP.PT_SKETCH) + ' visualizzazione assemblato + Dim nShowBuilding As Boolean = GetMainPrivateProfileInt(S_SCENE, K_SHOWBUILDING, 0) <> 0 + Map.refShowBeamPanelVM.SetShowBuilding(nShowBuilding) + ' imposto parametri geometrici griglia + EgtSetGridGeo(100, 1, 10, 100) + End Sub + +#End Region ' METHODS + +#Region "ProjectManager" + + Public Overrides Function NewProject() As Boolean + EgtSetCurrentContext(MainScene.GetCtx()) + Dim bOk As Boolean = MainController.NewProject() + MainScene.SetStatusNull() + Return bOk + End Function + + Public Overrides Function OpenProject(sFilePath As String) As Boolean + EgtSetCurrentContext(MainScene.GetCtx()) + Dim bOk As Boolean = False + If String.IsNullOrEmpty(sFilePath) Then + ' Recupero cartella dell'ultimo progetto aperto + Dim sDir As String = MainController.GetCurrFile() + If String.IsNullOrWhiteSpace(sDir) Then + GetMainPrivateProfileString(S_MRUFILES, K_FILE, "", sDir) + End If + If Not String.IsNullOrWhiteSpace(sDir) Then + sDir = Path.GetDirectoryName(sDir) + End If + bOk = MainController.OpenProject(sDir) + Else + bOk = MainController.OpenProject(sFilePath, False) + End If + MainScene.SetStatusNull() + Return bOk + End Function + + Public Overrides Function SaveProject() As Boolean + Dim bOk As Boolean = MyBase.SaveProject() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + Return bOk + End Function + + Public Overrides Function SaveAsProject() As Boolean + Dim bOk As Boolean = MyBase.SaveAsProject() + ' Imposto stato gestione mouse diretto della scena a nessuno + MainScene.SetStatusNull() + Return bOk + End Function + + Public Overrides Function ImportProject() As Boolean + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_MRUIMPORT, K_FILE & "1", "", sDir) + If Not String.IsNullOrWhiteSpace(sDir) Then + sDir = Path.GetDirectoryName(sDir) + End If + sDir.TrimEnd("\"c) + Return MainController.ImportProject(sDir) + End Function + +#End Region ' ProjectManager + +#Region "SCENE EVENTS" + + Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String) + Map.refMyStatusBarVM.SetCurrPos(sCursorPos) + End Sub + + Private Sub OnMouseSetObjFilterForSelect(sender As Object, bZeroDim As Boolean, bCurve As Boolean, + bSurf As Boolean, bVolume As Boolean, bExtra As Boolean) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra) + End If + End Sub + + Private Sub OnMouseSelectedAll(ByVal sender As Object, bOnlyVisble As Boolean) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseSelectedAll(bOnlyVisble) + End If + End Sub + + Private Sub OnMouseDeselectedAll(ByVal sender As Object) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseDeselectedAll() + End If + End Sub + + Private Sub OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + If Map.refInstrumentPanelVM.GetDistIsChecked Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive AndAlso + (Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Or + Map.refFreeContourManagerVM.bIsOpeningCurveCompo) Then + ' passo entità selezionata + Map.refFreeContourManagerVM.OnMouseSelectedObj(EgtGetFirstSelectedObj(), True) + ElseIf Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseDownScene(sender, e) + Else + View_Feature_OnMouseDownScene(sender, e) + End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseDownScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseDownScene(sender, e) + End If + End If + End If + End Sub + + Private Sub OnMouseMoveScene(sender As Object, e As Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + If Map.refInstrumentPanelVM.GetDistIsChecked Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive Then Return + If Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseMoveScene(sender, e) + Else + View_Feature_OnMouseMoveScene(sender, e) + End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseMoveScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseMoveScene(sender, e) + End If + End If + End If + End Sub + + Private Sub OnMouseUpScene(sender As Object, e As Forms.MouseEventArgs) + If e.Button = Forms.MouseButtons.Middle Then Return + If Map.refInstrumentPanelVM.GetDistIsChecked Then Return + If Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Pages.ONLYPRODPAGE And (Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART OrElse Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PARTLIST)) Then + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then + If Map.refFreeContourManagerVM.bIsActive AndAlso Map.refFreeContourManagerVM.SelType = FreeContourManagerVM.FreeContourTypes.ONEWITHANGLES Then + Return + ElseIf Map.refShowBeamPanelVM.bShowAll Then + View_Part_OnMouseUpScene(sender, e) + Else + View_Feature_OnMouseUpScene(sender, e) + End If + End If + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse (Pages.ONLYPRODPAGE And Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.MACHGROUP) Then + If Not IsNothing(Map.refMachGroupPanelVM) AndAlso Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then + Dim SelectedMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup + If EgtGetCurrMachGroup() = GDB_ID.NULL Then Return + If SelectedMachGroup.nType = BWType.BEAM Then + Beam_OnMouseUpScene(sender, e) + ElseIf SelectedMachGroup.nType = BWType.WALL Then + Wall_OnMouseUpScene(sender, e) + End If + End If + End If + End Sub + + Private Sub OnMouseSelectingObj(ByVal sender As Object, ByVal nId As Integer, ByRef bOk As Boolean) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + bOk = Map.refFreeContourManagerVM.OnMouseSelectingObj(nId) + End If + End Sub + + Private Sub OnMouseSelectedObj(ByVal sender As Object, ByVal nId As Integer, ByVal bLast As Boolean) + MainController.MouseSelectedObj(nId, bLast) + End Sub + + Private Sub OnMouseSelectedPart(ByVal sender As Object, ByVal nId As Integer) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseSelectedPart(nId) + End If + End Sub + + Private Sub OnMouseSelectedLayer(ByVal sender As Object, ByVal nId As Integer) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseSelectedLayer(nId) + End If + End Sub + + Private Sub OnMouseSelectedPath(ByVal sender As Object, ByVal nId As Integer, ByVal bHaltOnFork As Boolean) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseSelectedPath(nId, bHaltOnFork) + End If + End Sub + + Private Sub OnMousePointFromSelection(ByVal sender As Object, ByVal nId As Integer, ByVal PtP As Point3d, ByVal nAux As Integer) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.SetPointFromSelection(nId, PtP, nAux) + End If + End Sub + + Private Sub OnMouseDone(ByVal sender As Object) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.Done(Map.refFreeContourInputVM.Text) + End If + End Sub + + Private Sub OnMouseSelectedPoint(ByVal sender As Object, ByVal PtP As Point3d, ByVal nSep As SEP, ByVal nId As Integer) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + Dim bDone As Boolean = (Keyboard.Modifiers And ModifierKeys.Control) <> ModifierKeys.Control + MainController.MouseSelectedPoint(PtP, nSep, nId, bDone) + End If + End Sub + + Private Sub OnMouseSelectedDir(ByVal sender As Object, ByVal VtDir As Vector3d) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.SetLastVector3d(VtDir) + End If + End Sub + + Private Sub OnMouseMoveSelPoint(ByVal sender As Object, ByVal PtP As Point3d) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + MainController.MouseMoveInSelectionPoint(PtP) + End If + End Sub + + Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String) + Map.refMyStatusBarVM.SetOutputMessage(sDistance) + End Sub + + Private Sub OnKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) + ' Se in modalità edit L250 + If (Map.refMainMenuVM.SelPage = Pages.VIEW OrElse (Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Map.refProjectVM.LastSelGridType = ProjectVM.GridSelTypes.PART)) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refFreeContourManagerVM.bIsActive Then + ' Con DEL eseguo cancellazione delle entità selezionate + If e.KeyData = System.Windows.Forms.Keys.Delete Then + MainController.SetLastInteger(GDB_ID.SEL) + MainController.ExecuteCommand(Controller.CMD.DELETE) + ' Con SPAZIO ripeto l'ultimo comando + ElseIf e.KeyData = System.Windows.Forms.Keys.Space Then + MainController.RepeatLastCommand() + ' Con 'A' e in modalità continuazione, forzo il passaggio ad arco + ElseIf e.KeyData = System.Windows.Forms.Keys.A And MainController.GetContinue() Then + MainController.ContinueArcPDP() + ' Con 'L' e in modalità continuazione, forzo il passaggio a retta + ElseIf e.KeyData = System.Windows.Forms.Keys.L And MainController.GetContinue() Then + MainController.ContinueLine2P() + ' Con 'V' cambio lo stato del check + ElseIf e.KeyData = System.Windows.Forms.Keys.V Then + Map.refFreeContourInputVM.ChangeInputBoxCheck() + End If + End If + End Sub + + Private Sub OnCloseGetDist(sender As System.Object) + Map.refInstrumentPanelVM.SetGetDistance_IsChecked(False) + End Sub + + Private Sub OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean) + Dim BtnColor As Brush + If bUser Then + BtnColor = New SolidColorBrush(SystemColors.ControlColor) + Else + BtnColor = Brushes.Bisque + End If + Select Case nSpType + Case SP.PT_SKETCH + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1102), BtnColor) 'Sketch Point + Case SP.PT_GRID + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1104), BtnColor) 'Grid Point + Case SP.PT_END + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1106), BtnColor) 'End Point + Case SP.PT_MID + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1108), BtnColor) 'Mid Point + Case SP.CENTER + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1110), BtnColor) 'Center + Case SP.CENTROID + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1112), BtnColor) 'Centroid + Case SP.PT_NEAR + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1114), BtnColor) 'Near Point + Case SP.PT_INTERS + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1116), BtnColor) 'Inters Point + Case SP.PT_TANGENT + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1118), BtnColor) 'Tang Point + Case SP.PT_PERPENDICULAR + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1120), BtnColor) 'Perp Point + Case SP.PT_MINDIST + Map.refMyStatusBarVM.SetSnapPointType(EgtMsg(1122), BtnColor) 'MinDist Point + Case Else + Map.refMyStatusBarVM.SetSnapPointType("---", BtnColor) + End Select + End Sub + +#End Region ' SCENE EVENTS + +#Region "CONTROLLER EVENTS" + + Private Sub OnNewProject(sender As Object, bOk As Boolean) + Map.refMainWindowVM.SetTitle(" New - EgtBEAMWALL") + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateNewBTLStructure()) + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + EgtDraw() + MainScene.SetStatusNull() + End Sub + + Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean) + Dim ProjectType As ProjectType = If(Map.refMainMenuVM.SelPage = Pages.VIEW, ProjectType.PROJ, ProjectType.PROD) + Dim ProjId As Integer = If(ProjectType = ProjectType.PROJ, ProjectManagerVM.nLoadingProjId, 0) + Dim CurrProd As ProdFileVM = Nothing + ' Procedo a seconda del risultato + If bOk Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROJ, 2, EgtMsg(63005), 50, 70) ' Loading part list + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROD, 2, EgtMsg(63005), 50, 70) ' Loading part list + ' leggo struttura BTL + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(ProjId)) + ' verifico se volume pezzi calcolato + Dim bIsCalculated As Boolean = False + For Each BTLPart In Map.refProjectVM.BTLStructureVM.BTLPartVMList + If BTLPart.BTLPartM.dVolume > 0 Then Continue For + bIsCalculated = True + BTLPart.CalcBTLPartVolume() + Next + If bIsCalculated Then + Dim CurrProject As String = "" + EgtGetCurrFilePath(CurrProject) + EgtSaveFile(CurrProject, NGE.CMPTEXT) + End If + WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) + ' in base al tipo progetto aggiungo il file in apertura alla lista degli MRU + If ProjectType = ProjectType.PROJ Then + ' nel caso PROJ ricavo il percorso del file tramite il ProjId + Dim PjFileVM As ProjFileVM + If Not IsNothing(ProjId) AndAlso ProjId <> 0 Then + PjFileVM = New ProjFileVM(DbControllers.m_ProjController.FindByProjIdConv(ProjId)) + If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Add(PjFileVM.sProjPath) + End If + ' imposto macchina del progetto + Map.refMachinePanelVM.SelectedMachine = Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProjManagerVM.TempCurrProj.sMachine) + ' aggiorno le colonne in base al tipo progetto + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + ProjectManagerVM.CurrProj = Map.refProjManagerVM.TempCurrProj + DbControllers.m_ProjController.LockByProjId(ProjectManagerVM.CurrProj.nProjId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + ElseIf ProjectType = ProjectType.PROD Then + ' se salvato, carico progetto in lista mru + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) AndAlso Not Map.refProdManagerVM.TempCurrProd.bIsNew Then + Map.refProdManagerVM.m_MruFiles.Add(sFile) + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) AndAlso Not Map.refOnlyProdManagerVM.TempCurrProd.bIsNew Then + Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) + End If + ' imposto macchina del progetto + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = ProjectManagerVM.CurrProj.sMachine)) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refOnlyProdManagerVM.TempCurrProd.sMachine), + Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = ProjectManagerVM.CurrProd.sMachine)) + End If + SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + Core.ViewPanelVM.UpdateBWType(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + ' aggiorno le colonne in base al tipo progetto + Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + Map.refFeatureInPartInRawPartListVM.UpdateColumns(CurrentMachine.nType) + If Not IsNothing(Map.refTopPanelVM) Then + Map.refTopPanelVM.ManageQParamsRowVisibility(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE <> BWType.BEAM) + End If + Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.BTLStructureM.nPROJTYPE) + If Not IsNothing(Map.refProdManagerVM) AndAlso Not IsNothing(Map.refProdManagerVM.TempCurrProd) Then + CurrProd = Map.refProdManagerVM.TempCurrProd + ProjectManagerVM.CurrProd = CurrProd + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.TempCurrProd) Then + CurrProd = Map.refOnlyProdManagerVM.TempCurrProd + ProjectManagerVM.CurrProd = CurrProd + End If + DbControllers.m_ProdController.LockByProdId(CurrProd.nProdId, True, Map.refMainWindowVM.MainWindowM.GetKeyNumber()) + ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel + Map.refCALCPanelVM.LoadMachineList() + End If + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROJ, 3, EgtMsg(63006), 70, 100) ' Loading graphics + ' mostro tutti i pezzi + Map.refShowBeamPanelVM.ShowAll(True) + ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + ' recupero indice di modifica progetto quando caricato + Dim CommIndex As Integer = -1 + Dim ActiveSessionList As List(Of StatusMapModel) = DbControllers.m_StatusMapController.GetProd(m_SupervisorId) + For Each ActiveSession In ActiveSessionList + If Not IsNothing(ProjectManagerVM.CurrProd) AndAlso ActiveSession.ItemId = ProjectManagerVM.CurrProd.nProdId Then + CommIndex = ActiveSession.Index + End If + Next + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.OPENPROD, 3, EgtMsg(63002), 70, 100) ' Loading machining groups + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.GOTOPROD, 3, EgtMsg(63002), 50, 100) ' Loading machining groups + ' carico gruppi di lavorazione + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + ' fisso indice sessione di comunicazione + If CommIndex > -1 Then + ProjectManagerVM.CurrProd.SetModificationIndex(CommIndex) + End If + + ' seleziono primo gruppo + If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count > 0 Then + Map.refProjectVM.MachGroupPanelVM.SelFirstMachGroup() + Else + Map.refProjectVM.BTLStructureVM.HideAll() + End If + End If + Else + ' in base al tipo progetto rimuovo il file in apertura dalla lista degli MRU + If ProjectType = ProjectType.PROJ Then + ' nel caso PROJ ricavo il percorso del file tramite il ProjId + Dim PjFileVM As ProjFileVM + If Not IsNothing(ProjId) AndAlso ProjId <> 0 Then + PjFileVM = New ProjFileVM(DbControllers.m_ProjController.FindByProjIdConv(ProjId)) + If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Remove(PjFileVM.sProjPath) + End If + End If + If ProjectType = ProjectType.PROD Then Map.refProdManagerVM.m_MruFiles.Remove(sFile) + MessageBox.Show(Application.Current.MainWindow, EgtMsg(10003) & " '" & sFile & "'", EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error opening file + Map.refProjManagerVM.NewProject() + If Map.refMainMenuVM.SelPage = Pages.MACHINING OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then + Map.refProjectVM.MachGroupPanelVM = New MyMachGroupPanelVM(MyMachGroupPanelM.CreateMyMachGroupPanel(Map.refMachinePanelVM.MachineList.ToList())) + End If + End If + ' carico filtri di ricerca + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then Map.refProjectVM.BTLStructureVM.LoadFilters() + + MainScene.SetStatusNull() + End Sub + + Private Sub OnSavingProject(ByVal sender As Object, sFile As String) + End Sub + + Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) + Dim ProjectType As ProjectType = If(Map.refMainMenuVM.SelPage = Pages.VIEW, ProjectType.PROJ, ProjectType.PROD) + Dim ProjId As Integer = If(ProjectType = ProjectType.PROJ, ProjectManagerVM.nLoadingProjId, 0) + ' Se salvataggio non riuscito, esco subito + If Not bOk Then + ' in base al tipo progetto rimuovo il file in salvataggio dalla lista degli MRU + If ProjectType = ProjectType.PROJ Then + ' nel caso PROJ ricavo il percorso del file tramite il ProjId + Dim PjFileVM As ProjFileVM + If Not IsNothing(ProjId) AndAlso ProjId <> 0 Then + PjFileVM = New ProjFileVM(DbControllers.m_ProjController.FindByProjIdConv(ProjId)) + If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Remove(PjFileVM.sProjPath) + End If + End If + If ProjectType = ProjectType.PROD Then Map.refProdManagerVM.m_MruFiles.Remove(sFile) + Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file + MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + Return + End If + ' in base al tipo progetto aggiungo il file in salvataggio alla lista degli MRU + If ProjectType = ProjectType.PROJ Then + ' nel caso PROJ ricavo il percorso del file tramite il ProjId + Dim PjFileVM As ProjFileVM + If Not IsNothing(ProjId) AndAlso ProjId <> 0 Then + PjFileVM = New ProjFileVM(DbControllers.m_ProjController.FindByProjIdConv(ProjId)) + If Not IsNothing(PjFileVM.ProjFileM) AndAlso Not IsNothing(PjFileVM.sProjPath) Then Map.refProjManagerVM.m_MruFiles.Add(PjFileVM.sProjPath) + End If + End If + If ProjectType = ProjectType.PROD Then + If Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso Not IsNothing(Map.refProdManagerVM) Then + Map.refProdManagerVM.m_MruFiles.Add(sFile) + ElseIf Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE AndAlso Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.m_MruFiles.Add(sFile) + End If + End If + ' Salvo nome ultimo file + WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile) + End Sub + + Private Sub OnImportingProject(sender As Object, nType As Integer, ByRef nFlag As Integer) + If nType = FT.BTL Or nType = FT.BTLX Then + Dim sBTLFlag As String + If Not IsNothing(Map.refProjManagerVM) AndAlso Map.refProjManagerVM.nProjType = Core.ConstBeam.BWType.BEAM OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Map.refOnlyProdManagerVM.nProjType = Core.ConstBeam.BWType.BEAM Then + sBTLFlag = K_BTLFLAG + Else + sBTLFlag = K_WALLBTLFLAG + End If + nFlag = GetMainPrivateProfileInt(S_IMPORT, sBTLFlag, EIB_FL.TS3_POS + EIB_FL.SORT + EIB_FL.USEUATTR) + Else + MessageBox.Show(Application.Current.MainWindow, EgtMsg(10005), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' File type unknown - Error + End If + End Sub + + Private Sub OnImportedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) + Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk OrElse bFirstPart Then + LoadingWndHelper.UpdateLoadingWnd(ActiveIds.IMPORTBTL, 2, EgtMsg(63005), 50, 70) ' Loading parts + ' leggo struttura BTL + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0)) + Dim nPartId As Integer = EgtGetFirstPart() + While nPartId <> GDB_ID.NULL + ' scrivo in ogni pezzo ProjId + EgtSetInfo(nPartId, BTL_PRT_PROJ, ProjectManagerVM.nLoadingProjId) + nPartId = EgtGetNextPart(nPartId) + ' scrivo Id negli outline + Dim nPRId As Integer = 1 + Dim nOutlineLayer As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE) + If nOutlineLayer <> GDB_ID.NULL Then + Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutlineLayer) + While nOutlineId <> GDB_ID.NULL + ' verifico che sia feature + If EgtExistsInfo(nOutlineId, MGR_FTR_PRC) Then + EgtSetInfo(nOutlineId, MGR_FTR_PRID, nPRId) + nPRId += 1 + End If + nOutlineId = EgtGetNext(nOutlineId) + End While + End If + End While + ' scrivo info proj e type su layer BtlInfo + Dim nBTLInfoLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, ProjectManagerVM.nLoadingProjId) + EgtSetInfo(nBTLInfoLayer, BTL_GEN_PROJTYPE, ProjectManagerVM.CurrProj.nType) + ' scrivo info proj su layer AsseBase + Dim nAsseBaseLayer As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ASSEBASE) + EgtSetInfo(nAsseBaseLayer, BTL_PRT_PROJ, ProjectManagerVM.nLoadingProjId) + Else + Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file + MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + If Not IsNothing(Map.refProjManagerVM) Then + Map.refProjManagerVM.NewProject() + ElseIf Not IsNothing(Map.refOnlyProdManagerVM) Then + Map.refOnlyProdManagerVM.NewProject() + End If + End If + MainScene.SetStatusNull() + End Sub + + Private Sub PrepareInputBox(ByVal sTitle As String, ByVal sLabel As String, ByVal sCheckLabel As String, + ByVal bShowCombo As Boolean, ByVal bShowBtn As Boolean) + Map.refFreeContourInputVM.PrepareInputBox(sTitle, sLabel, sCheckLabel, bShowCombo, bShowBtn) + End Sub + + Private Sub SetInputBoxText(ByVal sText As String) + Map.refFreeContourInputVM.SetInputBoxText(sText) + End Sub + + Private Sub SetInputBoxCheck(ByVal bCheck As Boolean) + Map.refFreeContourInputVM.SetInputBoxCheck(bCheck) + End Sub + + Private Sub AddInputBoxCombo(ByVal sText As String, ByVal bSelected As Boolean) + Map.refFreeContourInputVM.AddInputBoxCombo(sText, bSelected) + End Sub + + Private Sub UpdateUI(ByVal sender As Object, ByVal bReloadUI As Boolean) + If Map.refFreeContourManagerVM.bIsActive Then + ' pulisco input e relativi messaggi + Map.refFreeContourInputVM.ResetInputBox() + Map.refFreeContourManagerVM.UpdateUi() + End If + If MainController.GetContinue() Then + Map.refMyStatusBarVM.SetOutputMessage(EgtMsg(399)) ' Continue : 'L' with line, 'A' with arc + Else + Map.refMyStatusBarVM.ClearOutputMessage() + End If + End Sub + +#End Region ' CONTROLLER EVENTS + +#Region "MACHINING EVENTS" + +#Region "Beam" + + Friend Sub Beam_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' Recupero l'identificativo del pezzo cui appartiene + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + Dim MyMachGroup As MyMachGroupVM = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, MyMachGroupVM) + Dim bPartInTable As Boolean = MyMachGroup.PartVMList.Any(Function(x) x.PartM.nRawPartId = EgtGetParent(nPartId)) + Dim bFound As Boolean = False + If EgtIsPart(nPartId) OrElse EgtIsDuplo(nPartId) OrElse bPartInTable Then bFound = True + If Not bFound Then + nId = EgtGetNextObjInSelWin() + Continue While + End If + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nPartId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId + End If + Exit While + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_bDragToStart = True + End Sub + + Friend Sub Beam_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDragToStart Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + Return + End If + m_bDragToStart = False + End If + End Sub + + Friend Sub Beam_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + ' Se pezzo da selezionare non è già selezionato + Dim SelMachgroup As MyMachGroupVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup + If Not IsNothing(SelMachgroup) AndAlso + (IsNothing(SelMachgroup.SelPart) OrElse SelMachgroup.SelPart.nPartId <> m_nIdToSel) Then + ' Eseguo la selezione nel machgroup corrente + SelMachgroup.SelPart = SelMachgroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = m_nIdToSel) + ' eseguo la selezione nella lista pezzi + Dim nBTLPartId As Integer = MyMachGroupPanelM.DuploGetOriginal(m_nIdToSel) + If Not IsNothing(nBTLPartId) Then + Map.refProjectVM.BTLStructureVM.SetSelBTLPart(Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nBTLPartId), True) + End If + End If + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' Beam + +#Region "Wall" + + Friend Sub Wall_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) + ' Per default no drag + m_bDrag = False + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' scarto box per evitare selezione pezzo esterno in finestre + Dim sName As String = "" + EgtGetName(nId, sName) + If sName = "Box" Then + nId = EgtGetNextObjInSelWin() + Continue While + End If + ' Recupero l'identificativo del pezzo cui appartiene + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + Dim MyMachGroup As MyMachGroupVM = DirectCast(Map.refMachGroupPanelVM.SelectedMachGroup, MyMachGroupVM) + Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = MyMachGroup.MyMachGroupM.nRawPartId) + If EgtIsPart(nPartId) OrElse EgtIsDuplo(nPartId) OrElse bPartInTable Then + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nPartId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId + End If + ' Drag possibile + m_bDrag = True + Exit While + End If + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_locPrev = e.Location + m_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev) + m_bDragToStart = m_bDrag + m_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0 + m_vtTotMove = Vector3d.NULL() + End Sub + + Friend Sub Wall_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDrag Or m_bDragging Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + m_bDragToStart = False + End If + ' Determino cosa muovere + Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) + ' se modalita' nesting manuale non attiva, esco + If GetMainPrivateProfileInt(S_NEST, K_MANUALNEST, 0) <= 0 Then Return + ' Inizio esecuzione di drag + m_bDragging = True + ' Ricavo il punto corrente in coordinate mondo + Dim ptCurr As Point3d + EgtUnProjectPoint(e.Location, ptCurr) + ' Ricavo il vettore di movimento + Dim vtMove As Vector3d = ptCurr - m_ptPrev + ' Muovo i pezzi selezionati di quanto possibile + If vtMove.SqLen() > EPS_SMALL * EPS_SMALL Then + ' verifico se il pezzo da muovere e' selezionato + If nMoveId = GDB_ID.SEL Then + ' muovo tutti i pezzi selezionati + Dim nPartId As Integer = EgtGetFirstSelectedObj() + While nPartId <> GDB_ID.NULL + EgtMovePartInRawPart(nPartId, vtMove) + ' aggiorno valore nel PartVM + Dim PartVM As PartVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId) + If Not IsNothing(PartVM) Then + PartVM.NotifyPropertyChanged(NameOf(PartVM.dPOSX)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.sPOSX)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.dPOSY)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.sPOSY)) + End If + nPartId = EgtGetNextSelectedObj() + End While + Else + EgtMovePartInRawPart(nMoveId, vtMove) + ' aggiorno valore nel PartVM + Dim PartVM As PartVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = nMoveId) + If Not IsNothing(PartVM) Then + PartVM.NotifyPropertyChanged(NameOf(PartVM.dPOSX)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.sPOSX)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.dPOSY)) + PartVM.NotifyPropertyChanged(NameOf(PartVM.sPOSY)) + End If + End If + EgtDraw() + End If + ' Aggiorno il punto precedente + m_ptPrev = ptCurr + ' Terminata esecuzione di drag + m_bDragging = False + End Sub + + Private Sub Move(nMoveId As Integer, vtMove As Vector3d, ptCurr As Point3d) + ' Se movimento con sola verifica finale + If m_bVerify Then + Dim x = EgtMove(nMoveId, vtMove) + m_vtTotMove += vtMove + ' altrimenti caso con verifica durante il movimento + Else + '' Aggiorno regioni per nesting + 'UpdateNestRegions() !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + 'EnableReferenceRegion(False) + ' muovo il pezzo + EgtMovePartInRawPart(nMoveId, vtMove) 'EgtMovePart(nMoveId, bReducedCut, vtMove) + EgtSaveCollInfo() + ' se movimento risultante nullo, provo con movimento tangente + Dim bTgMoved As Boolean = False + If vtMove.IsSmall() Then + ' riprovo con movimento tangente + Dim vtTgMove As Vector3d = ptCurr - m_ptPrev + EgtTgMovePartOnCollision(nMoveId, bReducedCut, vtTgMove) + bTgMoved = (Not vtTgMove.IsSmall()) + End If + ' se abilitato magnetico (allineamento + snap), lo provo + Dim bAlignMoved As Boolean = False + Dim bSnapMoved As Boolean = False + If m_bMagnetic Then + EgtAlignPartOnCollision(nMoveId, bReducedCut, bAlignMoved) + If m_dSnapDist > EPS_SMALL Then + EgtRestoreCollInfo() + EgtMovePartToSnapPointOnCollision(nMoveId, bReducedCut, m_dSnapDist, bSnapMoved) + End If + End If + End If + End Sub + + Friend Sub Wall_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se movimento con sola verifica finale + If m_bVerify Then + ' Determino cosa verificare + Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL) + '' Aggiorno regioni per nesting + 'UpdateNestRegions() !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + 'EnableReferenceRegion(False) + ' Eseguo verifica + If EgtVerifyPart(nMoveId, bReducedCut) Then + ' Non superata riporto alla posizione iniziale + Else + EgtMove(nMoveId, -m_vtTotMove) + End If + ' altrimenti caso con verifica durante il movimento + Else + ' Basta reset alla fine + End If + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + ' se non sono in modalita' manuale + If GetMainPrivateProfileInt(S_NEST, K_MANUALNEST, 0) <= 0 Then + ' deseleziono tutto per evitare selezioni multiple + EgtDeselectAll() + End If + ' Eseguo la selezione + EgtSelectObj(m_nIdToSel) + ' Se pezzo da selezionare non è già selezionato + Dim SelMachgroup As MyMachGroupVM = Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup + If Not IsNothing(SelMachgroup) AndAlso + (IsNothing(SelMachgroup.SelPart) OrElse SelMachgroup.SelPart.nPartId <> m_nIdToSel) Then + ' Eseguo la selezione nel machgroup corrente + SelMachgroup.SetSelPart(SelMachgroup.PartVMList.FirstOrDefault(Function(x) x.nPartId = m_nIdToSel)) + ' eseguo la selezione nella lista pezzi + DirectCast(SelMachgroup.SelPart, PartVM).SelectBTLPart() + End If + ' Se deselezione da eseguire + ElseIf m_nIdToDesel <> GDB_ID.NULL Then + ' se sono in modalita' manuale, permetto la deselezione + If GetMainPrivateProfileInt(S_NEST, K_MANUALNEST, 0) > 0 Then + EgtDeselectObj(m_nIdToDesel) + End If + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' Wall + +#End Region ' WALL EVENTS + +#Region "VIEW EVENTS" + +#Region "Part" + + Friend Sub View_Part_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' Recupero l'identificativo del pezzo cui appartiene + Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId)) + Dim bFound As Boolean = False + If Map.refShowBeamPanelVM.ShowBuilding_IsChecked Then + Dim nLayerId As Integer = EgtGetParent(nPartId) + Dim sLayerName As String = "" + EgtGetName(nLayerId, sLayerName) + If sLayerName = ASSEBASE Then + Dim nSou As Integer + If EgtGetInfo(nPartId, GDB_SI_COPY, nSou) Then nPartId = nSou + bFound = True + End If + Else + If EgtIsPart(nPartId) Then bFound = True + End If + If Not bFound Then + nId = EgtGetNextObjInSelWin() + Continue While + End If + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nPartId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nPartId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nPartId + End If + Exit While + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_bDragToStart = True + End Sub + + Friend Sub View_Part_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDragToStart Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + Return + End If + m_bDragToStart = False + End If + End Sub + + Friend Sub View_Part_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + Dim CurrPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = m_nIdToSel) + If e.Button = Forms.MouseButtons.Left Then + ' imposto tipo ultima Grid selezionata + Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PARTLIST) + ' imposto highlight + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.HIGHLIGHT) + ' gestisco evidenziazione pezzo + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift OrElse (Keyboard.Modifiers And ModifierKeys.Control) = ModifierKeys.Control Then + If IsNothing(CurrPart) Then Return + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Contains(CurrPart) Then + Map.refProjectVM.BTLStructureVM.SelBTLParts.Remove(CurrPart) + Else + Map.refProjectVM.BTLStructureVM.SelBTLParts.Add(CurrPart) + End If + Else + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 0 Then + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Contains(CurrPart) Then + For RemoveIndex = Map.refProjectVM.BTLStructureVM.SelBTLParts.Count - 1 To 0 Step -1 + If Map.refProjectVM.BTLStructureVM.SelBTLParts(RemoveIndex) IsNot CurrPart Then + Map.refProjectVM.BTLStructureVM.SelBTLParts.Remove(Map.refProjectVM.BTLStructureVM.SelBTLParts(RemoveIndex)) + End If + Next + Else + Map.refProjectVM.BTLStructureVM.SelBTLParts.Clear() + Map.refProjectVM.BTLStructureVM.SelBTLParts.Add(CurrPart) + End If + Else + Map.refProjectVM.BTLStructureVM.SelBTLParts.Add(CurrPart) + End If + End If + ElseIf e.Button = Forms.MouseButtons.Right Then + ' imposto tipo ultima Grid selezionata + Map.refProjectVM.SetLastSelGridType(ProjectVM.GridSelTypes.PART) + ' imposto selezione + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.SELECT_) + ' seleziono il pezzo + If Map.refProjectVM.BTLStructureVM.SelBTLParts.Count > 0 Then + Map.refProjectVM.BTLStructureVM.SelBTLParts.Clear() + End If + Map.refProjectVM.BTLStructureVM.SelBTLParts.Add(CurrPart) + End If + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' Part + +#Region "Feature" + + Friend Sub View_Feature_OnMouseDownScene(sender As Object, e As Forms.MouseEventArgs) + ' Verifico se selezionato indicativo di pezzo + EgtSetObjFilterForSelWin(True, True, True, True, True) + Dim nSel As Integer + EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel) + Dim nId As Integer = EgtGetFirstObjInSelWin() + While nId <> GDB_ID.NULL + ' Verifico se e' una feature + Dim nFeatureLayer As Integer = EgtGetParent(nId) + Dim sFeatureLayerName As String = "" + EgtGetName(nFeatureLayer, sFeatureLayerName) + If (sFeatureLayerName <> PROCESSINGS AndAlso sFeatureLayerName <> OUTLINE) OrElse EgtGetType(nId) <> GDB_TY.SRF_MESH Then + nId = EgtGetNextObjInSelWin() + Continue While + End If + Dim nStat As Integer = GDB_ST.ON_ + EgtGetStatus(nId, nStat) + ' Se già selezionato + If nStat = GDB_ST.SEL Then + ' Memorizzo Id da deselezionare + m_nIdToDesel = nId + Else + ' Memorizzo Id da selezionare + m_nIdToSel = nId + End If + Exit While + nId = EgtGetNextObjInSelWin() + End While + ' Dati per drag + m_bDragToStart = True + End Sub + + Friend Sub View_Feature_OnMouseMoveScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se drag non abilitato o già in esecuzione, esco + If Not m_bDragToStart Then Return + ' Se primo movimento di drag, verifico di aver superato la soglia di movimento in pixel + If m_bDragToStart Then + If Math.Abs(e.Location.X - m_locPrev.X) < m_nRestRadius And + Math.Abs(e.Location.Y - m_locPrev.Y) < m_nRestRadius Then + Return + End If + m_bDragToStart = False + End If + End Sub + + Friend Sub View_Feature_OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs) + ' Se eseguito drag + If Not m_bDragToStart Then + ' Se selezione da eseguire + ElseIf m_nIdToSel <> GDB_ID.NULL Then + ' Se feature da selezionare non è già selezionata + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso + (IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) OrElse Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId <> m_nIdToSel) Then + ' Eseguo la selezione + Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.nFeatureId = m_nIdToSel) + End If + End If + ' Reset + m_bDrag = False + m_nIdToSel = GDB_ID.NULL + m_nIdToDesel = GDB_ID.NULL + EgtDraw() + End Sub + +#End Region ' Feature + +#End Region ' VIEW EVENTS + +End Class diff --git a/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml b/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml new file mode 100644 index 00000000..22e55479 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml.vb b/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml.vb new file mode 100644 index 00000000..3bcf798f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SceneHost/SceneHostV.xaml.vb @@ -0,0 +1,19 @@ +Imports System.Windows.Interop +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class SceneHostV + + Private m_MySceneHostVM As MySceneHostVM + + Sub New() + ' This call is required by the designer. + InitializeComponent() + ' Assegno al riferimento locale al VM il VM preso dal DataContext + Me.DataContext = New MySceneHostVM + m_MySceneHostVM = DirectCast(Me.DataContext, MySceneHostVM) + m_MySceneHostVM.SetMainScene(MainScene) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/SetUp/SetUpSupportClass.vb b/EgtBEAMWALL.Optimizer/SetUp/SetUpSupportClass.vb new file mode 100644 index 00000000..410e7b53 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SetUp/SetUpSupportClass.vb @@ -0,0 +1,794 @@ +Imports System.Collections.ObjectModel +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class PositionGroup + + ' Lista delle posizioni + Private m_PositionList As New ObservableCollection(Of Position) + Public Property PositionList As ObservableCollection(Of Position) + Get + Return m_PositionList + End Get + Set(value As ObservableCollection(Of Position)) + m_PositionList = value + End Set + End Property + + Sub New() + End Sub + + Sub New(PositionList As ObservableCollection(Of Position)) + m_PositionList = PositionList + End Sub + +End Class + +Public Class Position + + Private Const INVALIDPOS As String = "" + + Private m_TcPos As String + Public Property TcPos As String + Get + Return m_TcPos + End Get + Set(value As String) + m_TcPos = value + End Set + End Property + + Friend m_IsModifiedHead As Boolean = False + Friend m_IsAppliedHead As Boolean = True + Private m_OrigHead As String = Nothing + Friend Property OrigHead As String + Get + Return m_OrigHead + End Get + Set(value As String) + m_OrigHead = value + m_IsAppliedHead = True + End Set + End Property + Private m_Head As String + ''' + ''' Property that read and write to the tool's database the Head + ''' + Friend Property Head As String + Get + Return m_Head + End Get + Set(value As String) + If value = String.Empty Or value <> m_Head Then + m_Head = value + If Not IsNothing(m_Head) And Not IsNothing(m_OrigHead) Then + m_IsAppliedHead = (m_Head = m_OrigHead) + Else + m_IsAppliedHead = IsNothing(m_Head) And IsNothing(m_OrigHead) + End If + m_IsModifiedHead = True + End If + End Set + End Property + Friend Sub SetHead(value As String) + If value = String.Empty Or value <> m_Head Then + m_Head = value + m_IsModifiedHead = False + End If + End Sub + + ' Lista delle uscite con relativi utensili associati + Private m_ExitToolAssociationList As New ObservableCollection(Of ExitToolAssociation) + Public Property ExitToolAssociationList As ObservableCollection(Of ExitToolAssociation) + Get + Return m_ExitToolAssociationList + End Get + Set(value As ObservableCollection(Of ExitToolAssociation)) + m_ExitToolAssociationList = value + End Set + End Property + +#Region "METHODS" + + Friend Sub SetIsValidPosFromTool(TUuid As String) + EgtLuaSetGlobStringVar("STU.TUUID", TUuid) + EgtLuaSetGlobStringVar("STU.TCPOS", m_TcPos) + EgtLuaCallFunction("STU.GetValidHeadExitForPos") + ' Leggo variabili + Dim sHead As String = String.Empty + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + Dim nExit As Integer = 0 + EgtLuaGetGlobIntVar("STU.EXIT", nExit) + Dim nErr As Integer = 999 + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr <> 0 Then + ' disattivo tutte le uscite tranne quelle attrezzate + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + Dim sToolName As String = String.Empty + EgtTdbGetToolFromUUID(TUuid, sToolName) + EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_TcPos) + Return + End If + ' verifico se la posizione è libera o c'è un utensile attrezzato + Dim PosIsOccupied As Boolean = False + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + PosIsOccupied = True + Exit For + End If + Next + ' se la posizione non è valida, disattivo tutte le uscite tranne quelle attrezzate + If sHead = INVALIDPOS Then + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + ' altrimenti, se la posizione nell'attrezzaggio è vuota + ElseIf Not PosIsOccupied Then + ' se l'uscita restituita esiste + If ExitToolAssociationList.Count >= nExit Then + ' disattivo tutte le uscite tranne quella restituita + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitIndex + 1 = nExit Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = True + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + ' altrimenti lascio attiva solo la prima uscita + Else + ExitToolAssociationList(0).IsEnabledPos = True + For ExitIndex = 1 To ExitToolAssociationList.Count - 1 + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + Next + End If + ' altrimenti, se le teste coincidono + ElseIf sHead = Head Then + ' se l'uscita restituita è libera la attivo e disattivo tutte le altre non occupate + If Not ExitToolAssociationList(nExit - 1).IsOccupied Then + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = True + ElseIf ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + ' altrimenti le disattivo tutte tranne quelle occupate + Else + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsValidPos = True + Else + ExitToolAssociationList(ExitIndex).IsValidPos = False + End If + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + End If + ' se le teste non coincidono + Else + EgtLuaSetGlobStringVar("STU.HEAD1", sHead) + EgtLuaSetGlobStringVar("STU.HEAD2", Head) + EgtLuaCallFunction("STU.IsCompatibleHeads") + ' Leggo variabili + Dim bIsValid As Boolean = False + EgtLuaGetGlobBoolVar("STU.ISVALID", bIsValid) + nErr = 999 + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr <> 0 Then + ' disattivo tutte le uscite tranne quelle attrezzate + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + Dim sToolName As String = String.Empty + EgtTdbGetToolFromUUID(TUuid, sToolName) + EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_TcPos) + Return + End If + ' se le teste sono compatibili + If bIsValid Then + ' se l'uscita restituita è libera la attivo e disattivo tutte le altre non occupate + If nExit < ExitToolAssociationList.Count - 1 AndAlso Not ExitToolAssociationList(nExit - 1).IsOccupied Then + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = True + ElseIf ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsValidPos = False + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + ' altrimenti le disattivo tutte tranne quelle occupate + Else + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + If ExitIndex = nExit - 1 Then + ExitToolAssociationList(ExitIndex).IsValidPos = True + Else + ExitToolAssociationList(ExitIndex).IsValidPos = False + End If + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + End If + ' se le teste non sono compatibili + Else + ' disabilito tutte le uscite + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + Next + End If + End If + + End Sub + + Friend Sub SetNotValidPos() + ' le disattivo tutte tranne quelle occupate + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + ExitToolAssociationList(ExitIndex).IsEnabledPos = True + ExitToolAssociationList(ExitIndex).IsValidPos = Nothing + Else + ExitToolAssociationList(ExitIndex).IsEnabledPos = False + End If + Next + End Sub + +#End Region ' Methods + + Sub New(TcPos As String, Head As String, ExitNum As Integer) + Me.TcPos = TcPos + Me.SetHead(Head) + For ExitIndex = 1 To ExitNum + ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, Me)) + Next + End Sub + +End Class + +Public Class ExitToolAssociation + Inherits VMBase + + ' Riferimento alla lista utensili + Friend Shared sh_ToolsList As ObservableCollection(Of FamilyToolItem) + ' riferimento alla lista posizioni + Friend Shared sh_PositionGroupList As ObservableCollection(Of PositionGroup) + ' Actions + Friend Shared m_delIsModifiedSetUp As Action + + ' Riferimento alla posizione di questa uscita + Private m_MyPos As Position + + Private m_IsOccupied As Boolean + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Public Property IsOccupied As Boolean + Get + Return m_IsOccupied + End Get + Set(value As Boolean) + If value <> m_IsOccupied Then + m_IsOccupied = value + NotifyPropertyChanged(NameOf(IsOccupied)) + End If + End Set + End Property + + Private m_IsEnabledPos As Boolean + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Public Property IsEnabledPos As Boolean + Get + Return m_IsEnabledPos + End Get + Set(value As Boolean) + If value <> m_IsEnabledPos Then + m_IsEnabledPos = value + NotifyPropertyChanged(NameOf(IsEnabledPos)) + End If + End Set + End Property + + Private m_IsValidPos As Boolean? + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Public Property IsValidPos As Boolean? + Get + Return m_IsValidPos + End Get + Set(value As Boolean?) + m_IsValidPos = value + NotifyPropertyChanged(NameOf(ExitBtnBackgroundCol)) + End Set + End Property + + Public ReadOnly Property ExitBtnBackgroundCol As SolidColorBrush + Get + If IsNothing(m_IsValidPos) Then + Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221)) + ElseIf m_IsValidPos Then + If m_IsOccupied Then + Return New SolidColorBrush(Color.FromArgb(255, 255, 255, 0)) ' yellow + Else + Return New SolidColorBrush(Color.FromArgb(255, 0, 255, 0)) ' green + End If + Else + Return New SolidColorBrush(Color.FromArgb(255, 221, 221, 221)) + End If + End Get + End Property + + Private m_Exit As String + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Public Property ExitPar As String + Get + Return m_Exit + End Get + Set(value As String) + If value <> m_Exit Then + m_Exit = value + End If + End Set + End Property + + Friend m_IsModifiedTool As Boolean = False + Friend m_IsAppliedTool As Boolean = True + Private m_OrigTool As ToolItem = Nothing + Friend Property OrigTool As ToolItem + Get + Return m_OrigTool + End Get + Set(value As ToolItem) + m_OrigTool = value + m_IsAppliedTool = True + End Set + End Property + Private m_Tool As ToolItem + ''' + ''' Property that read and write to the tool's database the Uuid + ''' + Public Property Tool As ToolItem + Get + Return m_Tool + End Get + Set(value As ToolItem) + m_Tool = value + If Not IsNothing(m_Tool) And Not IsNothing(m_OrigTool) Then + m_IsAppliedTool = (m_Tool.Uuid = m_OrigTool.Uuid) + Else + m_IsAppliedTool = IsNothing(m_Tool) And IsNothing(m_OrigTool) + End If + m_IsModifiedTool = True + NotifyPropertyChanged(NameOf(Tool)) + m_delIsModifiedSetUp() + End Set + End Property + Friend Sub SetTool(ToolItem As ToolItem) + m_Tool = ToolItem + If Not IsNothing(m_Tool) And Not IsNothing(m_OrigTool) Then + m_IsAppliedTool = (m_Tool.Uuid = m_OrigTool.Uuid) + Else + m_IsAppliedTool = IsNothing(m_Tool) And IsNothing(m_OrigTool) + End If + m_IsModifiedTool = False + NotifyPropertyChanged(NameOf(Tool)) + End Sub + +#Region "Messages" + + Public ReadOnly Property ToolTipMsg As String + Get + If IsNothing(m_Tool) Then Return "" + EgtTdbSetCurrTool(m_Tool.Name) + Dim dValue As Double = 0 + Dim nType As Integer + EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType) + EgtTdbGetCurrToolParam(MCH_TP.DIAM, dValue) + Dim sDiam As String = LenToString(dValue, 4) + EgtTdbGetCurrToolParam(MCH_TP.LEN, dValue) + Dim sLen As String = LenToString(dValue, 4) + EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dValue) + Dim MaxMat As String = LenToString(dValue, 4) + Return (EgtMsg(6053) & ": " & ConvertToolTypeToString(nType) & Environment.NewLine & + EgtMsg(6056) & ": " & sDiam & Environment.NewLine & + EgtMsg(6062) & ": " & sLen & Environment.NewLine & + EgtMsg(6064) & ": " & MaxMat) + End Get + End Property + + Private Function ConvertToolTypeToString(ToolType As Integer) As String + Select Case ToolType + Case MCH_TY.DRILL_STD + Return EgtMsg(6001) + Case MCH_TY.DRILL_LONG + Return EgtMsg(6006) + Case MCH_TY.SAW_STD + Return EgtMsg(6002) + Case MCH_TY.SAW_FLAT + Return EgtMsg(6007) + Case MCH_TY.MILL_STD + Return EgtMsg(6003) + Case MCH_TY.MILL_NOTIP + Return EgtMsg(6008) + Case MCH_TY.MORTISE_STD + Return EgtMsg(6004) + Case MCH_TY.COMPO + Return EgtMsg(6005) + Case Else + Return String.Empty + End Select + End Function + +#End Region ' Messages + + ' Definizione comandi + Private m_cmdSetUpTool As ICommand + +#Region "CONSTRUCTORS" + + Sub New(ExitPar As String, MyPos As Position) + Me.ExitPar = ExitPar + m_MyPos = MyPos + End Sub + +#End Region ' Constructors + +#Region "COMMANDS" + +#Region "SetUpToolCommand" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property SetUpToolCommand As ICommand + Get + If m_cmdSetUpTool Is Nothing Then + m_cmdSetUpTool = New Command(AddressOf SetUpTool) + End If + Return m_cmdSetUpTool + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub SetUpTool(param As Object) + If m_IsOccupied Then + ' se quello selezionato nella lista non è un utensile esco + If Not TypeOf param Is ToolItem Then + m_IsOccupied = False + NotifyPropertyChanged(NameOf(IsOccupied)) + Return + End If + Dim SelTool As ToolItem = DirectCast(param, ToolItem) + ' verifico se devo cambiare la testa + EgtLuaSetGlobStringVar("STU.TUUID", SelTool.Uuid) + EgtLuaSetGlobStringVar("STU.TCPOS", m_MyPos.TcPos) + EgtLuaCallFunction("STU.GetValidHeadExitForPos") + ' Leggo variabili + Dim sHead As String = String.Empty + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + Dim nExit As Integer = 0 + EgtLuaGetGlobIntVar("STU.EXIT", nExit) + Dim nErr As Integer = 999 + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr <> 0 Then + Dim sToolName As String = String.Empty + EgtTdbGetToolFromUUID(SelTool.Uuid, sToolName) + EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & m_MyPos.TcPos) + m_IsOccupied = False + NotifyPropertyChanged(NameOf(IsOccupied)) + Return + End If + ' se la testa restituita non coincide con quella della posizione + If m_MyPos.Head <> sHead Then + ' aggiorno testa ed uscite + m_MyPos.Head = sHead + For ExitIndex = m_MyPos.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead) + m_MyPos.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, m_MyPos)) + Next + For ExitIndex = m_MyPos.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1 + m_MyPos.ExitToolAssociationList.RemoveAt(ExitIndex) + Next + End If + ' lo aggiungo alla posizione di attrezzaggio + Tool = SelTool + IsOccupied = True + ' e lo tolgo dalla lista + For Index = 0 To sh_ToolsList.Count - 1 + If (SelTool.Type And sh_ToolsList(Index).Type) > 0 Then + sh_ToolsList(Index).Items.Remove(SelTool) + Exit For + End If + Next + NotifyPropertyChanged(NameOf(ToolTipMsg)) + Else + ' lo rimetto nella lista utensili + For Index = 0 To sh_ToolsList.Count - 1 + If (Tool.Type And sh_ToolsList(Index).Type) > 0 Then + ' creo una copia della lista di utensili della famiglia + Dim TempList As New List(Of String) + Dim ToolIndex As Integer + For ToolIndex = 0 To sh_ToolsList(Index).Items.Count - 1 + TempList.Add(sh_ToolsList(Index).Items(ToolIndex).Name) + Next + ' aggiungo l'utensile da inserire + TempList.Add(Tool.Name) + ' riordino la lista + TempList.Sort() + ' ricavo l'indice dell'utensile inserito + ToolIndex = TempList.IndexOf(Tool.Name) + ' lo inserisco nel posto giusto + sh_ToolsList(Index).Items.Insert(ToolIndex, Tool) + ' espando la famiglia in cui l'ho messo + sh_ToolsList(Index).IsExpanded = True + Exit For + End If + Next + + ' abilito e disabilito tutte le uscite in base all'utensile selezionato + For GroupIndex = 0 To sh_PositionGroupList.Count - 1 + For PosIndex = 0 To sh_PositionGroupList(GroupIndex).PositionList.Count - 1 + sh_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(Tool.Uuid) + Next + Next + + ' seleziono utensile rimesso in lista + m_Tool.IsSelected = True + Tool.NotifyPropertyChanged(NameOf(ToolItem.IsSelected)) + ' e lo tolgo dalla posizione di attrezzaggio + Tool = Nothing + IsOccupied = False + + End If + End Sub + +#End Region ' SetUpToolCommand + +#End Region ' Commands + +End Class + +Public Class FamilyToolItem + Inherits InheritableTreeViewItem + + ' riferimento alla lista posizioni + Friend Shared m_PositionGroupList As ObservableCollection(Of PositionGroup) + + Public Overrides Property IsSelected As Boolean + Get + Return m_IsSelected + End Get + Set(value As Boolean) + If (value <> m_IsSelected) Then + m_IsSelected = value + If value Then + ' disabilito tutte le uscite tranne quelle occupate + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos() + Next + Next + End If + End If + End Set + End Property + + Public ReadOnly Property FamilyColor As SolidColorBrush + Get + If m_HaveToolsInCurrMachGroup Then + Return Brushes.Red + Else + Return Brushes.Transparent + End If + End Get + End Property + + Private m_HaveToolsInCurrMachGroup As Boolean + Friend ReadOnly Property HaveToolsInCurrMachGroup As Boolean + Get + Return m_HaveToolsInCurrMachGroup + End Get + End Property + + Private m_Type As MCH_TF + ''' + ''' Property that determines the tool type of the family + ''' + Public ReadOnly Property Type As MCH_TF + Get + Return m_Type + End Get + End Property + + Sub New(Name As String, Type As MCH_TF) + MyBase.New(Name) + Me.PictureString = "/Resources/TreeView/Folder.png" + m_Type = Type + ' Aggiungo il gestore d'evento di modifica lista degli item per poter mettere e togliere il pallino che indica se ci sono utensili da attrezzare + AddHandler Items.CollectionChanged, AddressOf ManageObservableCollection + End Sub + + Private Sub ManageObservableCollection(sender As Object, e As System.Collections.Specialized.NotifyCollectionChangedEventArgs) + m_HaveToolsInCurrMachGroup = False + For Index = 0 To Items.Count - 1 + Dim ToolItem As ToolItem = DirectCast(Items(Index), ToolItem) + If ToolItem.m_IsInCurrMachGroup Then + m_HaveToolsInCurrMachGroup = True + End If + Next + NotifyPropertyChanged(NameOf(FamilyColor)) + End Sub + +End Class + +Public Class ToolItem + Inherits InheritableTreeViewItem + + ' riferimento alla lista posizioni + Friend Shared m_PositionGroupList As ObservableCollection(Of PositionGroup) + + Public Overrides Property IsSelected As Boolean + Get + Return m_IsSelected + End Get + Set(value As Boolean) + If (value <> m_IsSelected) Then + m_IsSelected = value + If value Then + ' abilito e disabilito tutte le uscite in base all'utensile selezionato + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(Uuid) + Next + Next + End If + End If + End Set + End Property + + Public ReadOnly Property ToolColor As SolidColorBrush + Get + If m_IsInCurrMachGroup Then + Return Brushes.Red + Else + Return Brushes.Transparent + End If + End Get + End Property + + Friend m_IsInCurrMachGroup As Boolean + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Public Property IsInCurrMachGroup As Boolean + Get + Return m_IsInCurrMachGroup + End Get + Set(value As Boolean) + If value <> m_IsInCurrMachGroup Then + m_IsInCurrMachGroup = value + 'NotifyPropertyChanged("IsInCurrMachGroup") + End If + End Set + End Property + + Private m_Exit As String + ''' + ''' Property that read and write to the tool's database the Exit + ''' + Friend Property ExitPar As String + Get + Return m_Exit + End Get + Set(value As String) + If value <> m_Exit Then + m_Exit = value + End If + End Set + End Property + + Private m_Type As MCH_TY + ''' + ''' Property that determines the tool type of the family + ''' + Public ReadOnly Property Type As MCH_TY + Get + Return m_Type + End Get + End Property + + Private m_Head As String + ''' + ''' Property that read and write to the tool's database the Head + ''' + Friend Property Head As String + Get + Return m_Head + End Get + Set(value As String) + If value = String.Empty Or value <> m_Head Then + m_Head = value + End If + End Set + End Property + + Private m_TcPos As String + ''' + ''' Property that read and write to the tool's database the Tc Pos + ''' + Friend Property TcPos As String + Get + Return m_TcPos + End Get + Set(value As String) + If value = String.Empty Or value <> m_TcPos Then + m_TcPos = value + End If + End Set + End Property + + Private m_Uuid As String + ''' + ''' Property that read and write to the tool's database the Uuid + ''' + Friend ReadOnly Property Uuid As String + Get + Return m_Uuid + End Get + End Property + +#Region "Messages" + + Public ReadOnly Property ToolTipMsg As String + Get + Return (EgtMsg(6075) & ": " & m_Name & Environment.NewLine & + EgtMsg(6078) & ": " & m_TcPos & Environment.NewLine & + EgtMsg(6074) & ": " & m_Head & "." & m_Exit) + End Get + End Property + +#End Region ' Messages + + Sub New(Name As String, ExitPar As String, Type As Integer, Head As String, TcPos As String, Uuid As String, IsInCurrMachGroup As Boolean) + MyBase.New(Name) + m_Exit = ExitPar + m_Type = DirectCast(Type, MCH_TY) + m_Head = Head + m_TcPos = TcPos + m_Uuid = Uuid + m_IsInCurrMachGroup = IsInCurrMachGroup + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml b/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml new file mode 100644 index 00000000..3c5c108b --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml.vb b/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml.vb new file mode 100644 index 00000000..c63f0103 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SetUp/SetUpV.xaml.vb @@ -0,0 +1,24 @@ +Public Class SetUpV + + Private m_SetUpVM As SetUpVM + +#Region "EVENTS" + + Private Sub Me_DataContextChanged(sender As Object, e As DependencyPropertyChangedEventArgs) Handles Me.DataContextChanged + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_SetUpVM = DirectCast(e.NewValue, SetUpVM) + End Sub + + ' Evento di click di un Item dell'albero + Public Sub TreeViewItem_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs) + Dim TreeViewItem As TreeViewItem = DirectCast(e.Source, TreeViewItem) + If TypeOf TreeViewItem.DataContext Is ToolItem Then + Dim ToolItem As ToolItem = DirectCast(TreeViewItem.DataContext, ToolItem) + m_SetUpVM.ToolDoubleClick(ToolItem) + e.Handled = True + End If + End Sub + +#End Region ' EVENTS + +End Class diff --git a/EgtBEAMWALL.Optimizer/SetUp/SetUpVM.vb b/EgtBEAMWALL.Optimizer/SetUp/SetUpVM.vb new file mode 100644 index 00000000..71c78d0d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SetUp/SetUpVM.vb @@ -0,0 +1,810 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class SetUpVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private Const INVALIDPOS As String = "" + + Public Event SetUp_IsModified() + + Private m_Title As String + Public ReadOnly Property Title As String + Get + Return EgtMsg(6451) + End Get + End Property + + ' Lista degli utensili + Private m_ToolsList As New ObservableCollection(Of FamilyToolItem) + Public Property ToolsList As ObservableCollection(Of FamilyToolItem) + Get + Return m_ToolsList + End Get + Set(value As ObservableCollection(Of FamilyToolItem)) + m_ToolsList = value + End Set + End Property + + ' Lista dei gruppi di posizioni + Private m_PositionGroupList As New ObservableCollection(Of PositionGroup) + Public Property PositionGroupList As ObservableCollection(Of PositionGroup) + Get + Return m_PositionGroupList + End Get + Set(value As ObservableCollection(Of PositionGroup)) + m_PositionGroupList = value + End Set + End Property + + Private m_LastIndexRead As Integer = 0 + + Private m_IsEnabledApplyBtn As Boolean + Public ReadOnly Property IsEnabledApplyBtn As Boolean + Get + Return m_IsEnabledApplyBtn + End Get + End Property + + ' Immagine del porta utensili + Public ReadOnly Property SetUpImage As String + Get + ' Cerco png + Dim sImagePath As String = CurrentMachine.sMachSetupDir & "\SetupImage.png" + If File.Exists(sImagePath) Then Return sImagePath + ' Cerco jpeg + sImagePath = CurrentMachine.sMachSetupDir & "\SetupImage.jpg" + If File.Exists(sImagePath) Then Return sImagePath + ' Cerco bmp + sImagePath = CurrentMachine.sMachSetupDir & "\SetupImage.bmp" + If File.Exists(sImagePath) Then Return sImagePath + ' Non trovato alcunché + Return String.Empty + End Get + End Property + +#Region "Messages" + + Public ReadOnly Property TitleMsg As String + Get + Return EgtMsg(6451) + End Get + End Property + + Public ReadOnly Property ApplyMsg As String + Get + Return EgtMsg(6452) + End Get + End Property + Public ReadOnly Property ArchiveMsg As String + Get + Return EgtMsg(6453) + End Get + End Property + Public ReadOnly Property RetrievesMsg As String + Get + Return EgtMsg(6454) + End Get + End Property + Public ReadOnly Property AutomaticMsg As String + Get + Return EgtMsg(6455) + End Get + End Property + +#End Region + + ' Definizione comandi + Private m_cmdApply As ICommand + Private m_cmdArchive As ICommand + Private m_cmdRetrieves As ICommand + Private m_cmdAutomatic As ICommand + Private m_cmdToolDoubleClick As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' rendo accessibile la lista posizioni a famiglie ed utensili per poterle attivare e disattivare + ' (probabilmente da cambiare passandogli il riferimento alla creazione dell'utensile per non avere parametro shared) + FamilyToolItem.m_PositionGroupList = m_PositionGroupList + ToolItem.m_PositionGroupList = m_PositionGroupList + ' rendo accessibile le liste utensili e posizioni alle uscite + ExitToolAssociation.sh_ToolsList = m_ToolsList + ExitToolAssociation.sh_PositionGroupList = m_PositionGroupList + ' imposto il delegate che segnala una modifica al Db + ExitToolAssociation.m_delIsModifiedSetUp = AddressOf SetUp_IsModifiedManager + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + ''' + ''' Funzione che inizializza il set up calcolando le posizioni disponibili sulla macchina + ''' + Friend Function InitSetUp() As Boolean + ' Cancello tutto + m_ToolsList.Clear() + m_PositionGroupList.Clear() + ' genero l'attrezzaggio dalla configurazione Lua + Dim Index As Integer = 1 + While CreateStdPosFromPosIndex(Index) + Index += 1 + End While + m_LastIndexRead = Index + Return True + End Function + + ''' + ''' Funzione che carica il setup del gruppo di lavorazione corrente + ''' + Friend Function LoadCurrentSetUp() As Boolean + ' resetto lista utensili e posizioni + m_ToolsList.Clear() + ClearAllPos() + 'ricarico lista utensili + LoadMachineTools() + ' recupero il gruppo del setup + Dim nSetUpGroup As Integer = EgtGetCurrSetup() + ' leggo l'attrezzaggio del progetto + Dim sPosition As String = String.Empty + Dim IniIndex As Integer = 1 + ' recupero stringa di ogni posizione e sposto gli utensili nelle posizioni + While EgtGetInfo(nSetUpGroup, K_POS & IniIndex, sPosition) + If IniIndex < m_LastIndexRead Then + ReadPositionString(IniIndex, sPosition, True) + Else + EgtRemoveInfo(nSetUpGroup, K_POS & IniIndex) + End If + IniIndex += 1 + End While + ' Se esiste almeno una famiglia di utensili, la seleziono + If ToolsList.Count > 0 Then + ToolsList(0).IsSelected = True + ToolsList(0).NotifyPropertyChanged(NameOf(FamilyToolItem.IsSelected)) + End If + Return True + End Function + + ''' + ''' Funzione che carica il setup da un file. bOriginal indice se deve sostituire il valore originale + ''' + Public Sub LoadSetupFromFile(sFileName As String, bOriginal As Boolean) + ' Direttorio per attrezzaggi + Dim sFilePath As String = CurrentMachine.sMachDir & "\SetUp\" & sFileName & ".stu" + ' resetto lista utensili e posizioni + m_ToolsList.Clear() + ClearAllPos() + 'ricarico lista utensili + LoadMachineTools() + ' leggo l'attrezzaggio dal file scelto + Dim sPosition As String = String.Empty + Dim IniIndex As Integer = 1 + ' recupero stringa di ogni posizione + While EgtUILib.GetPrivateProfileString(S_GENERAL, K_POS & IniIndex, String.Empty, sPosition, sFilePath) > 0 + ReadPositionString(IniIndex, sPosition, bOriginal) + IniIndex += 1 + End While + ' recupero utensile correntemente selezionato + Dim SelTool As ToolItem = Nothing + Dim bFounded As Boolean = False + For Each Toolfamily In m_ToolsList + For Each Tool In Toolfamily.Items + If Tool.IsSelected Then + SelTool = DirectCast(Tool, ToolItem) + bFounded = True + Exit For + End If + Next + If bFounded Then Exit For + Next + ' verifico se disabilitare questa posizione in base all'utensile correntemente selezionato + If IsNothing(SelTool) Then + ' disabilito tutte le uscite tranne quelle occupate + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos() + Next + Next + Else + ' abilito e disabilito tutte le uscite in base all'utensile selezionato + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(SelTool.Uuid) + Next + Next + End If + ' Se esiste almeno una famiglia di utensili, la seleziono + If ToolsList.Count > 0 Then + ToolsList(0).IsSelected = True + ToolsList(0).NotifyPropertyChanged(NameOf(FamilyToolItem.IsSelected)) + End If + End Sub + + ''' + ''' Funzione che carica la lista di utensili ed evidenzia quelli usati nel gruppo di lavorazione corrente ma non attrezzati + ''' + Friend Sub LoadMachineTools() + ' Creo lista utensili utilizzati dal gruppo di lavorazione corrente + Dim UsedToolList As New List(Of String) + Dim Machining As Integer = EgtGetFirstOperation() + While Machining <> GDB_ID.NULL + If EgtGetOperationType(Machining) <> MCH_OY.DISP Then + EgtSetCurrMachining(Machining) + Dim Tuuid As String = String.Empty + EgtGetMachiningParam(MCH_MP.TUUID, Tuuid) + UsedToolList.Add(Tuuid) + End If + Machining = EgtGetNextOperation(Machining) + End While + ' Creo lista utensili per grafica + Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(CurrentMachine.sMachIniFile) + For Index = 0 To ActiveToolsFamilies.Count - 1 + Dim FamilyToolItem As New FamilyToolItem(ActiveToolsFamilies(Index).Name, ActiveToolsFamilies(Index).Id) + m_ToolsList.Add(FamilyToolItem) + Dim nType As Integer = 0 + Dim ToolName As String = String.Empty + Dim bFound As Boolean = EgtTdbGetFirstTool(ActiveToolsFamilies(Index).Id, ToolName, nType) + While bFound + EgtTdbSetCurrTool(ToolName) + Dim nValue As Integer = 0 + Dim sValue As String = String.Empty + EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue) + Dim ExitPar As String = nValue.ToString() + EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue) + Dim Head As String = sValue + EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue) + Dim TcPos As String = sValue + EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue) + Dim Uuid As String = sValue + Dim IsInCurrMachGroup As Boolean = If(UsedToolList.Contains(Uuid), True, False) + FamilyToolItem.Items.Add(New ToolItem(ToolName, ExitPar, nType, Head, TcPos, Uuid, IsInCurrMachGroup)) + bFound = EgtTdbGetNextTool(ActiveToolsFamilies(Index).Id, ToolName, nType) + End While + Next + End Sub + + ''' + ''' Funzione che dato l'indice di una posizione, la crea secondo il modello standard presente nello script Lua + ''' + Private Function CreateStdPosFromPosIndex(Index As Integer) As Boolean + Dim sTcPos As String = String.Empty + Dim sHead As String = String.Empty + Dim sGroup As String = String.Empty + Dim nErr As Integer = 999 + EgtLuaSetGlobIntVar("STU.INDEX", Index) + EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.TCPOS", sTcPos) + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + EgtLuaGetGlobStringVar("STU.GROUP", sGroup) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + ' se l'indice del gruppo è valido + Dim nGroup As Integer = If(Integer.TryParse(sGroup.Trim("G"c), nGroup), nGroup, 0) + If VerifyIndexValidity(nGroup) Then + m_PositionGroupList(nGroup - 1).PositionList.Add(New Position(sTcPos, sHead, EgtGetHeadExitCount(sHead))) + End If + Return (nErr = 0) + End Function + + ''' + ''' Funzione che mantiene le posizioni ma elimina tutti gli utensili attrezzati + ''' + Friend Sub ClearAllPos() + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + For ExitIndex = 0 To m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1 + Dim TempExit As ExitToolAssociation = m_PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex) + ' e lo tolgo dalla posizione di attrezzaggio + TempExit.SetTool(Nothing) + TempExit.IsOccupied = False + Next + Next + Next + End Sub + + ''' + ''' Funzione che verifica che l'indice del gruppo sia valido, esista, e nel caso non esistesse aggiunge i gruppi necessari + ''' + Private Function VerifyIndexValidity(nGroupIndex As Integer) As Boolean + ' verifico che l'indice del gruppo sia valido + If nGroupIndex >= 1 Then + ' verifico che l'indice del gruppo sia compreso nel range di quelli esistenti + If nGroupIndex <= m_PositionGroupList.Count Then + Return True + ' se l'indice è maggiore di quelli presenti nella lista dei gruppi + Else + ' aggiungo i gruppi che mancano fino all'indice del mio + For GroupIndex = m_PositionGroupList.Count To nGroupIndex - 1 + m_PositionGroupList.Add(New PositionGroup) + Next + Return True + End If + ' altrimenti + Else + ' mi assicuro che esista il primo gruppo + VerifyIndexValidity(1) + Return False + End If + End Function + + ''' + ''' Funzione che dati l'indice della posizione e la sua stringa di attrezzaggio, carica l'attrezzaggio descritto + ''' + Private Sub ReadPositionString(nIndex As Integer, sPosition As String, bOriginal As Boolean) + Dim sTcPos As String = String.Empty + Dim sHead As String = String.Empty + Dim sExitList As New List(Of String) + Dim sToolList As New List(Of String) + Dim sToolNameList As New List(Of String) + ' la spezzo sui ; + Dim sItems() As String = sPosition.Split(";".ToCharArray) + ' se c'è almeno un elemento sono sicuro che ci sia la T + If sItems.Count() >= 1 Then + Dim nGroup As Integer = 0 + sTcPos = sItems(0) + ' recupero il suo gruppo + If Not GetGroupFromTcPos(sTcPos, nGroup) Then + ' se non lo trovo lo metto nel primo + nGroup = 1 + End If + If Not VerifyIndexValidity(nGroup) Then + ' se mi viene passato un indice non valido, lo metto nel primo + nGroup = 1 + End If + ' se ci sono almeno due elementi sono sicuro che ci sia la H + If sItems.Count >= 2 Then + sHead = sItems(1) + ' se ci sono almeno tre elementi sono sicuro che ci sia almeno un'uscita attrezzata + If sItems.Count >= 3 Then + ' separo le uscite divise dalla , + Dim sExitToolAssList() As String = sItems(2).Split(",".ToCharArray) + sExitList.Clear() + sToolList.Clear() + sToolNameList.Clear() + ' creo le liste di uscite e utensili attrezzati ricavati + For AssIndex = 0 To sExitToolAssList.Count() - 1 + Dim sExitToolAssItem() As String = sExitToolAssList(AssIndex).Split("/".ToCharArray) + If sExitToolAssItem.Count > 1 Then + sExitList.Add(sExitToolAssItem(0)) + sToolList.Add(sExitToolAssItem(1)) + sToolNameList.Add(sExitToolAssItem(2)) + End If + Next + ' analizzo la lista di utensili attrezzati + For ToolIndex = 0 To sToolList.Count - 1 + If Not String.IsNullOrEmpty(sToolList(ToolIndex)) Then + Dim TempTool As ToolItem = Nothing + Dim TempFamilyIndex As Integer = -1 + Dim TempToolIndex As Integer = -1 + Dim bToolFound As Boolean = False + ' cerco l'utensile attrezzato nella lista utensili + For FamilyListIndex = 0 To m_ToolsList.Count - 1 + For ToolListIndex = 0 To m_ToolsList(FamilyListIndex).Items.Count - 1 + TempTool = DirectCast(m_ToolsList(FamilyListIndex).Items(ToolListIndex), ToolItem) + If TempTool.Uuid = sToolList(ToolIndex) Then + TempFamilyIndex = FamilyListIndex + TempToolIndex = ToolListIndex + bToolFound = True + Exit For + End If + Next + If bToolFound Then Exit For + Next + ' se lo trovo + If bToolFound Then + ' cerco la relativa uscita + Dim bFoundPos As Boolean = False + For PositionIndex = 0 To m_PositionGroupList(nGroup - 1).PositionList.Count - 1 + Dim TempPosition As Position = m_PositionGroupList(nGroup - 1).PositionList(PositionIndex) + If TempPosition.TcPos = sTcPos Then + bFoundPos = True + ' verifico se la testa è diversa + If TempPosition.Head <> sHead Then + ' altrimenti la sovrascrivo + TempPosition.Head = sHead + ' la metto anche come testa originale + If bOriginal Then TempPosition.OrigHead = sHead + ' e verifico il numero di uscite + For ExitIndex = TempPosition.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead) + TempPosition.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, TempPosition)) + Next + For ExitIndex = TempPosition.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1 + TempPosition.ExitToolAssociationList.RemoveAt(ExitIndex) + Next + End If + For ExitIndex = 0 To TempPosition.ExitToolAssociationList.Count - 1 + Dim CurrExitToolAss As ExitToolAssociation = TempPosition.ExitToolAssociationList(ExitIndex) + If CurrExitToolAss.ExitPar = sExitList(ToolIndex) Then + ' vi metto l'utensile e segno l'uscita come occupata + CurrExitToolAss.SetTool(TempTool) + CurrExitToolAss.IsOccupied = True + CurrExitToolAss.NotifyPropertyChanged(NameOf(ToolItem.ToolTipMsg)) + ' lo metto anche come utensile originale + If bOriginal Then CurrExitToolAss.OrigTool = TempTool + Exit For + End If + Next + Exit For + End If + Next + ' se posizione trovata, devo togliere l'utensile dalla lista utensili + If bFoundPos Then + m_ToolsList(TempFamilyIndex).Items.Remove(m_ToolsList(TempFamilyIndex).Items(TempToolIndex)) + End If + ' altrimenti, se non l'ho trovato + Else + Dim sSearchedTool As String = String.Empty + EgtTdbGetToolFromUUID(sToolList(ToolIndex), sSearchedTool) + If String.IsNullOrWhiteSpace(sSearchedTool) Then sSearchedTool = sToolNameList(ToolIndex) + If Not String.IsNullOrWhiteSpace(sSearchedTool) Then + ' Impossibile trovare l'utensile xxx nel DB utensili + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 3) & " " & sSearchedTool & " " & EgtMsg(MSG_SETUPERRORS + 4), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Error) + Else + ' Impossibile trovare l'utensile nel DB utensili + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 3) & " " & EgtMsg(MSG_SETUPERRORS + 4), EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Error) + End If + End If + End If + Next + End If + End If + End If + End Sub + + ''' + ''' Funzione che data una T restituisce il gruppo a cui appartiene + ''' + Private Function GetGroupFromTcPos(sTcPos As String, ByRef nGroup As Integer) As Boolean + Dim sGroup As String = String.Empty + Dim nErr As Integer = 999 + EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos) + EgtLuaCallFunction("STU.GetGroupFromTcPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.GROUP", sGroup) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + nGroup = If(Integer.TryParse(sGroup.Trim("G"c), nGroup), nGroup, 0) + Return True + End If + nGroup = 0 + Return False + End Function + + ''' + ''' Funzione che data una T ne restituisce la posizione + ''' + Private Function GetPositionFromTcPos(sTcPos As String, ByRef nPosIndex As Integer) As Boolean + Dim sPosition As String = String.Empty + Dim nErr As Integer = 999 + EgtLuaSetGlobStringVar("STU.TCPOS", sTcPos) + EgtLuaCallFunction("STU.GetPosFromTcPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.POS", sPosition) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + nPosIndex = If(Integer.TryParse(sPosition.Replace("Pos", ""), nPosIndex), nPosIndex, -1) + Return (nPosIndex >= 0) + End If + nPosIndex = -1 + Return False + End Function + + ''' + ''' Funzione che verifica se ci sono state modifiche all'attrezzaggio corrente + ''' + Friend Function IsAppliedSetUp() As Boolean + For GroupIndex = 0 To PositionGroupList.Count - 1 + For PositionIndex = 0 To PositionGroupList(GroupIndex).PositionList.Count - 1 + For ExitIndex = 0 To PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1 + Dim CurrExitToolAss As ExitToolAssociation = PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex) + If Not CurrExitToolAss.m_IsAppliedTool Or Not PositionGroupList(GroupIndex).PositionList(PositionIndex).m_IsAppliedHead Then + Return False + End If + Next + Next + Next + Return True + End Function + + Friend Function IsModifiedSetUp() As Boolean + For GroupIndex = 0 To PositionGroupList.Count - 1 + For PositionIndex = 0 To PositionGroupList(GroupIndex).PositionList.Count - 1 + For ExitIndex = 0 To PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1 + Dim CurrExitToolAss As ExitToolAssociation = PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex) + If CurrExitToolAss.m_IsModifiedTool Or PositionGroupList(GroupIndex).PositionList(PositionIndex).m_IsModifiedHead Then + Return True + End If + Next + Next + Next + Return False + End Function + + Friend Function ResetModifiedSetUp() As Boolean + For GroupIndex = 0 To PositionGroupList.Count - 1 + For PositionIndex = 0 To PositionGroupList(GroupIndex).PositionList.Count - 1 + For ExitIndex = 0 To PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList.Count - 1 + Dim CurrExitToolAss As ExitToolAssociation = PositionGroupList(GroupIndex).PositionList(PositionIndex).ExitToolAssociationList(ExitIndex) + CurrExitToolAss.m_IsModifiedTool = False + PositionGroupList(GroupIndex).PositionList(PositionIndex).m_IsModifiedHead = False + Next + Next + Next + Return False + End Function + + ''' + ''' Funzione che verifica se ci sono state modifiche all'attrezzaggio corrente e permette di attivare e disattivare il bottone applica + ''' + Private Sub SetUp_IsModifiedManager() + If IsModifiedSetUp() Then + RaiseEvent SetUp_IsModified() + End If + End Sub + + ''' + ''' Execute the TreeViewDoubleClick. This method is invoked by the TreeViewDoubleClickCommand. + ''' + Public Sub ToolDoubleClick(SelToolItem As ToolItem) + If TypeOf SelToolItem Is ToolItem Then + Dim SelTool As ToolItem = DirectCast(SelToolItem, ToolItem) + Dim ErrorList As New List(Of String) + AutoSetUpTool(SelTool, ErrorList) + ' verifico se ci sono errori + If ErrorList.Count > 0 Then + ' li raccolgo tutti nello stesso messaggio + Dim sError As String = EgtMsg(6476) & Environment.NewLine + For ErrorIndex = 0 To ErrorList.Count - 1 + sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine + Next + MessageBox.Show(sError, EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation) + End If + End If + End Sub + + Private Function AutoSetUpTool(SelTool As ToolItem, ByRef ErrorList As List(Of String)) As Boolean + ' cerco il TcPos dell'utensile selezionato nella lista di posizioni + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + Dim CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex) + If CurrPosition.TcPos = SelTool.TcPos Then + AutoSetUpToolFromPos(SelTool, CurrPosition, ErrorList) + End If + Next + Next + Return False + End Function + + Private Function AutoSetUpToolFromPos(SelTool As ToolItem, Position As Position, ByRef ErrorList As List(Of String)) As Boolean + Dim ExitToolAssociationList As ObservableCollection(Of ExitToolAssociation) = Position.ExitToolAssociationList + EgtLuaSetGlobStringVar("STU.TUUID", SelTool.Uuid) + EgtLuaSetGlobStringVar("STU.TCPOS", Position.TcPos) + EgtLuaCallFunction("STU.GetValidHeadExitForPos") + ' Leggo variabili + Dim sHead As String = String.Empty + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + Dim nExit As Integer = 0 + EgtLuaGetGlobIntVar("STU.EXIT", nExit) + Dim nErr As Integer = 999 + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr <> 0 Then + Dim sToolName As String = String.Empty + EgtTdbGetToolFromUUID(SelTool.Uuid, sToolName) + EgtOutLog("Error in setup! Tool:" & sToolName & " TcPos: " & Position.TcPos) + Return False + End If + ' verifico se la posizione è libera o c'è un utensile attrezzato + Dim PosIsOccupied As Boolean = False + For ExitIndex = 0 To ExitToolAssociationList.Count - 1 + If ExitToolAssociationList(ExitIndex).IsOccupied Then + PosIsOccupied = True + Exit For + End If + Next + ' se la posizione non è valida, restituisco errore + If sHead = INVALIDPOS Then + EgtOutLog("SetUp warning: try to set " & SelTool.Name & " on " & Position.TcPos) + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 5), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return False + ' altrimenti, se la posizione nell'attrezzaggio è vuota + ElseIf Not PosIsOccupied Then + ' verifico se la testa è la stessa + If Not Position.Head = sHead Then + ' altrimenti la sovrascrivo + Position.Head = sHead + ' e verifico il numero di uscite + For ExitIndex = Position.ExitToolAssociationList.Count + 1 To EgtGetHeadExitCount(sHead) + Position.ExitToolAssociationList.Add(New ExitToolAssociation(ExitIndex.ToString, Position)) + Next + For ExitIndex = Position.ExitToolAssociationList.Count - 1 To EgtGetHeadExitCount(sHead) Step -1 + Position.ExitToolAssociationList.RemoveAt(ExitIndex) + Next + End If + ' lo aggiungo alla posizione di attrezzaggio e lo tolgo dalla lista utensili + SetToolInPos(SelTool, Position, nExit) + ' altrimenti, se le teste coincidono + ElseIf sHead = Position.Head Then + ' se l'uscita restituita è libera + If Not ExitToolAssociationList(nExit - 1).IsOccupied Then + ' lo aggiungo alla posizione di attrezzaggio e lo tolgo dalla lista utensili + SetToolInPos(SelTool, Position, nExit) + ' altrimenti restituisco falso + Else + ErrorList.Add(SelTool.Name) + Return False + End If + ' altrimenti restituisco falso + Else + ErrorList.Add(SelTool.Name) + Return False + End If + Return True + End Function + + Private Function SetToolInPos(SelTool As ToolItem, Position As Position, nExit As Integer) As Boolean + Dim bOk As Boolean = False + ' lo aggiungo alla posizione di attrezzaggio + For ExitIndex = 0 To Position.ExitToolAssociationList.Count - 1 + If ExitIndex = nExit - 1 Then + Position.ExitToolAssociationList(ExitIndex).Tool = SelTool + Position.ExitToolAssociationList(ExitIndex).IsOccupied = True + Position.ExitToolAssociationList(ExitIndex).NotifyPropertyChanged(NameOf(ToolItem.ToolTipMsg)) + bOk = True + Exit For + End If + Next + If Not bOk Then Return False + bOk = False + ' e lo tolgo dalla lista utensili + For Index = 0 To m_ToolsList.Count - 1 + If (SelTool.Type And m_ToolsList(Index).Type) > 0 Then + m_ToolsList(Index).Items.Remove(SelTool) + bOk = True + Exit For + End If + Next + Return bOk + End Function + + ''' + ''' Funzione che salva il setup corrente + ''' + Public Function Save(sFilePath As String) As Boolean + ' verifica path + If Not Directory.Exists(Path.GetDirectoryName(sFilePath)) Then Return False + ' creo il file con il solo commento come prima linea + File.WriteAllLines(sFilePath, {"; Commento per evitare BOM con UTF-8"}, Text.Encoding.UTF8) + + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + Dim CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex) + Dim sPosition As String = String.Empty + sPosition = CurrPosition.TcPos + Dim sExitToolAssociation As String = String.Empty + For AssIndex = 0 To CurrPosition.ExitToolAssociationList.Count - 1 + sExitToolAssociation &= If(CurrPosition.ExitToolAssociationList(AssIndex).IsOccupied, + CurrPosition.ExitToolAssociationList(AssIndex).ExitPar & "/" & + CurrPosition.ExitToolAssociationList(AssIndex).Tool.Uuid & "/" & + CurrPosition.ExitToolAssociationList(AssIndex).Tool.Name & ",", String.Empty) + Next + sExitToolAssociation = sExitToolAssociation.Trim(","c) + If Not String.IsNullOrEmpty(sExitToolAssociation) Then + sPosition &= ";" & CurrPosition.Head & ";" & sExitToolAssociation + End If + Dim nPosition As Integer + If GetPositionFromTcPos(m_PositionGroupList(GroupIndex).PositionList(PositionIndex).TcPos, nPosition) Then + EgtUILib.WritePrivateProfileString(S_GENERAL, K_POS & nPosition, sPosition, sFilePath) + End If + Next + Next + Return True + End Function + + ''' + ''' Funzione che applica il setup corrente al gruppo di lavoro corrente + ''' + Public Sub Apply() + ' ricavo il gruppo in cui mettere l'attrezzaggio + Dim nSetUpGroup As Integer = EgtGetCurrSetup() + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PositionIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + Dim CurrPosition As Position = m_PositionGroupList(GroupIndex).PositionList(PositionIndex) + Dim sPosition As String = String.Empty + sPosition = CurrPosition.TcPos + CurrPosition.OrigHead = CurrPosition.Head + Dim sExitToolAssociation As String = String.Empty + For ExitIndex = 0 To CurrPosition.ExitToolAssociationList.Count - 1 + Dim CurrExitToolAss As ExitToolAssociation = CurrPosition.ExitToolAssociationList(ExitIndex) + sExitToolAssociation &= If(CurrExitToolAss.IsOccupied, + CurrExitToolAss.ExitPar & "/" & + CurrExitToolAss.Tool.Uuid & "/" & + CurrExitToolAss.Tool.Name & ",", String.Empty) + CurrExitToolAss.OrigTool = CurrExitToolAss.Tool + Next + sExitToolAssociation = sExitToolAssociation.Trim(","c) + If Not String.IsNullOrEmpty(sExitToolAssociation) Then + sPosition &= ";" & CurrPosition.Head & ";" & sExitToolAssociation + End If + Dim nPosition As Integer + If GetPositionFromTcPos(CurrPosition.TcPos, nPosition) Then + EgtSetInfo(nSetUpGroup, K_POS & nPosition, sPosition) + End If + Next + Next + m_IsEnabledApplyBtn = False + NotifyPropertyChanged(NameOf(IsEnabledApplyBtn)) + ' aggiorno le librerie sottostanti + EgtUpdateCurrSetup() + End Sub + + ''' + ''' Funzione che posiziona gli utensili nelle posizioni di setup predefinite + ''' + Public Sub Automatic() + ' verifico il tipo di elemento selezionato + Dim bIsToolItem As Boolean = False + ' recupero utensile correntemente selezionato + Dim SelTool As ToolItem = Nothing + Dim bFounded As Boolean = False + For Each Toolfamily In m_ToolsList + For Each Tool In Toolfamily.Items + If Tool.IsSelected Then + SelTool = DirectCast(Tool, ToolItem) + bIsToolItem = Not SelTool.IsInCurrMachGroup + bFounded = True + Exit For + End If + Next + If bFounded Then Exit For + Next + + Dim ErrorList As New List(Of String) + ' analizzo la lista degli utensili alla ricerca di quelli usati nel progetto corrente + For FamilyIndex = 0 To m_ToolsList.Count - 1 + ' verifico se nella famiglia c'è almeno un utensile usato nel progetto + If m_ToolsList(FamilyIndex).HaveToolsInCurrMachGroup Then + ' analizzo gli utensili all'interno della famiglia + For ToolIndex = m_ToolsList(FamilyIndex).Items.Count - 1 To 0 Step -1 + Dim CurrTool As ToolItem = DirectCast(m_ToolsList(FamilyIndex).Items(ToolIndex), ToolItem) + ' se l'utensile è utilizzato + If CurrTool.IsInCurrMachGroup Then + ' lo attrezzo al suo posto predefinito + AutoSetUpTool(CurrTool, ErrorList) + End If + Next + End If + Next + + ' verifico se ci sono errori + If ErrorList.Count > 0 Then + ' li raccolgo tutti nello stesso messaggio + Dim sError As String = EgtMsg(6476) & Environment.NewLine + For ErrorIndex = 0 To ErrorList.Count - 1 + sError &= "- " & ErrorList(ErrorIndex) & Environment.NewLine + Next + MessageBox.Show(sError, EgtMsg(MSG_SETUPERRORS + 2), MessageBoxButton.OK, MessageBoxImage.Exclamation) + End If + + ' abilito e disabilito tutte le uscite in base all'utensile selezionato + For GroupIndex = 0 To m_PositionGroupList.Count - 1 + For PosIndex = 0 To m_PositionGroupList(GroupIndex).PositionList.Count - 1 + If bIsToolItem Then + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetIsValidPosFromTool(SelTool.Uuid) + Else + m_PositionGroupList(GroupIndex).PositionList(PosIndex).SetNotValidPos() + End If + Next + Next + End Sub + +#End Region ' METHODS + +End Class diff --git a/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml b/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml new file mode 100644 index 00000000..4115e0df --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml.vb new file mode 100644 index 00000000..db179cf2 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowBeamPanel/OnlyProdShowBeamPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdShowBeamPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml new file mode 100644 index 00000000..d6a50f5f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb new file mode 100644 index 00000000..0375f3ea --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ShowBeamPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelVM.vb b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelVM.vb new file mode 100644 index 00000000..e83cdf6a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowBeamPanel/ShowBeamPanelVM.vb @@ -0,0 +1,193 @@ +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class ShowBeamPanelVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_bShowAll As Boolean = True + Friend Property bShowAll As Boolean + Get + Return m_bShowAll + End Get + Set(value As Boolean) + m_bShowAll = value + If m_bShowAll Then + m_ShowSolid_IsEnabled = False + m_ShowBuilding_IsEnabled = Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.BTLStructureM.nAsseBaseId <> GDB_ID.NULL + Else + m_ShowSolid_IsEnabled = True + m_ShowBuilding_IsEnabled = False + End If + UpdatePartBtnIsEnabled() + NotifyPropertyChanged(NameOf(ShowSolid_IsEnabled)) + NotifyPropertyChanged(NameOf(ShowBuilding_IsEnabled)) + NotifyPropertyChanged(NameOf(ShowAll_Visibility)) + End Set + End Property + + Private m_bShowSolid As Boolean + Public Property ShowSolid_IsChecked As Boolean + Get + Return m_bShowSolid + End Get + Set(value As Boolean) + m_bShowSolid = value + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then Map.refProjectVM.BTLStructureVM.ShowSolid( GDB_ID.NULL, m_bShowSolid) + End Set + End Property + Friend Sub SetShowSolid(bValue As Boolean) + If m_bShowSolid = bValue Then Return + m_bShowSolid = bValue + NotifyPropertyChanged(NameOf(ShowSolid_IsChecked)) + End Sub + + Private m_bShowBuilding As Boolean + Public Property ShowBuilding_IsChecked As Boolean + Get + Return m_bShowBuilding + End Get + Set(value As Boolean) + m_bShowBuilding = value + If Not IsNothing(Map.refProjectVM.BTLStructureVM) Then Map.refProjectVM.BTLStructureVM.ShowBuilding(m_bShowBuilding) + End Set + End Property + Friend Sub SetShowBuilding(bValue As Boolean) + m_bShowBuilding = bValue + NotifyPropertyChanged(NameOf(ShowBuilding_IsChecked)) + End Sub + + Private m_ShowAll_IsEnabled As Boolean = True + Public Property ShowAll_IsEnabled As Boolean + Get + Return m_ShowAll_IsEnabled + End Get + Set(value As Boolean) + m_ShowAll_IsEnabled = value + End Set + End Property + Friend Sub SetShowAll_IsEnabled(bValue As Boolean) + m_ShowAll_IsEnabled = bValue + NotifyPropertyChanged(NameOf(ShowAll_IsEnabled)) + End Sub + + Private m_ShowSolid_IsEnabled As Boolean + Public Property ShowSolid_IsEnabled As Boolean + Get + Return m_ShowSolid_IsEnabled + End Get + Set(value As Boolean) + m_ShowSolid_IsEnabled = value + End Set + End Property + Friend Sub SetShowSolid_IsEnabled(bValue As Boolean) + m_ShowSolid_IsEnabled = bValue + NotifyPropertyChanged(NameOf(ShowSolid_IsEnabled)) + End Sub + + Private m_ShowBuilding_IsEnabled As Boolean + Public Property ShowBuilding_IsEnabled As Boolean + Get + Return m_ShowBuilding_IsEnabled + End Get + Set(value As Boolean) + m_ShowBuilding_IsEnabled = value + End Set + End Property + + Public ReadOnly Property ShowAll_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + +#Region "ToolTip" + + Public ReadOnly Property ShowAll_ToolTip As String + Get + Return EgtMsg(61925) + End Get + End Property + + Public ReadOnly Property ShowSolid_ToolTip As String + Get + Return EgtMsg(61926) + End Get + End Property + + Public ReadOnly Property ShowBuilding_ToolTip As String + Get + Return EgtMsg(61927) + End Get + End Property + +#End Region + + ' Definizione comandi + Private m_cmdShowAll As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + 'Creo riferimento a questa classe in EgtBeamWALL + Map.SetRefShowBeamPanelVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub UpdatePartBtnIsEnabled() + Map.refCALCPanelVM.PartShowAllChanged() + Configuration.UpdateGraphics() + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "ShowAll" + + Public ReadOnly Property ShowAll_Command As ICommand + Get + If m_cmdShowAll Is Nothing Then + m_cmdShowAll = New Command(AddressOf ShowAllCmd) + End If + Return m_cmdShowAll + End Get + End Property + + Public Sub ShowAllCmd() + ShowAll(True) + End Sub + + Public Sub ShowAll(bDraw As Boolean) + If IsNothing(Map.refProjectVM.BTLStructureVM) Then Return + ' se necessario tolgo solido dal precedentemente selezionato + If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) AndAlso m_bShowSolid Then + Map.refShowBeamPanelVM.SetShowSolid(False) + Map.refProjectVM.BTLStructureVM.ShowSolid(GDB_ID.NULL, False, False) + End If + ' nascondo barra del pezzo + Map.refProjectVM.BTLStructureVM.SetSelectionType(BTLStructureVM.SelectionTypes.NULL) + Map.refProjectVM.NotifyPropertyChanged(NameOf(Map.refProdProjManagerVM.PartManager_Visibility)) + ' mostro in parte bassa dati BTL + If Not IsNothing(Map.refBottomPanelVM) Then Map.refBottomPanelVM.SetSelPartFeatureTab(BottomPanelVM.PartFeatureTab.STRUCTURE_) + ' mostro tutti i pezzi + Map.refProjectVM.BTLStructureVM.ShowAll(False) + ' deseleziono tutto + Map.refProjectVM.BTLStructureVM.SelBTLParts.Clear() + ' se attivata opzione, li assemblo + Map.refProjectVM.BTLStructureVM.ShowBuilding((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso ShowBuilding_IsChecked, False) + If bDraw Then EgtDraw() + End Sub + +#End Region ' ShowAll + +#End Region ' COMMANDS + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml b/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml new file mode 100644 index 00000000..1ad6701d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml.vb new file mode 100644 index 00000000..5f380de9 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowPanel/OnlyProdShowPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdShowPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml b/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml new file mode 100644 index 00000000..ba139101 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml.vb new file mode 100644 index 00000000..98406775 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ShowPanel/ShowPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ShowPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml b/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml new file mode 100644 index 00000000..0f523fa6 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml.vb new file mode 100644 index 00000000..10cd9476 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SpecialPanel/OnlyProdSpecialPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdSpecialPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml new file mode 100644 index 00000000..4d0d89a8 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml.vb new file mode 100644 index 00000000..8dada6e4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class SpecialPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelVM.vb b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelVM.vb new file mode 100644 index 00000000..90b6fdd0 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/SpecialPanel/SpecialPanelVM.vb @@ -0,0 +1,179 @@ +Imports System.IO +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class SpecialPanelVM + + Private m_ButtonList As New List(Of ButtonItem) + Public ReadOnly Property ButtonList As List(Of ButtonItem) + Get + Return m_ButtonList + End Get + End Property + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefSpecialPanelVM(Me) + ' se attivo, inizializzo i bottoni leggendoli da file ini + If Map.refMainWindowVM.MainWindowM.bSpecialPanel Then + Dim BtnIndex As Integer = 1 + Dim CurrBtn As ButtonItem = Nothing + While GetPrivateProfileButton(S_SPECIAL, K_BUTTON & BtnIndex, "", CurrBtn) + m_ButtonList.Add(CurrBtn) + BtnIndex += 1 + End While + End If + End Sub + +#Region "METHODS" + + Public Function SetSpecialPanelButtonsVisibility(IsMachMode As Boolean) As Boolean + Dim bSpecialPanel_Visible As Boolean = False + For Each BtnItem In m_ButtonList + ' verifico il valore di nDrawMachOrBoth del bottone e IsMachMode per rendere visibile o meno il bottone in ButtonList + Select Case BtnItem.nDrawMachOrBoth + Case 0 ' bottone nascosto + BtnItem.m_Btn_Visibility = Visibility.Collapsed + Case 1 ' bottone visibile solo in Draw + BtnItem.m_Btn_Visibility = If(Not IsMachMode, Visibility.Visible, Visibility.Collapsed) + Case 2 ' bottone visibile solo in Machining + BtnItem.m_Btn_Visibility = If(IsMachMode, Visibility.Visible, Visibility.Collapsed) + Case 3 ' bottone visibile sia in Draw che in Machining + BtnItem.m_Btn_Visibility = Visibility.Visible + End Select + ' se anche uno solo è visibile anche lo SpecialPanel dovrà esserlo + If BtnItem.Btn_Visibility = Visibility.Visible Then bSpecialPanel_Visible = True + BtnItem.NotifyPropertyChanged(NameOf(BtnItem.Btn_Visibility)) + Next + Return bSpecialPanel_Visible + End Function + + Friend Sub SpecialPanelIsEnabled(SpecialPanelBtn_IsEnabled As Boolean) + For Each BtnItem In m_ButtonList + BtnItem.m_Btn_IsEnabled = SpecialPanelBtn_IsEnabled + BtnItem.NotifyPropertyChanged(NameOf(BtnItem.Btn_IsEnabled)) + Next + End Sub + + Public Function GetPrivateProfileButton(sSection As String, sKey As String, sBaseDir As String, ByRef ReadButtonItem As ButtonItem) As Boolean + ReadButtonItem = Nothing + Dim sVal As String = String.Empty + GetMainPrivateProfileString(sSection, sKey, "", sVal) + If String.IsNullOrWhiteSpace(sVal) Then Return False + Dim sItems() As String = sVal.Split(","c) + If sItems.Count() >= 1 Then + Dim sLuaPath As String = sItems(0) + Dim sImagePath As String = If(sItems.Count() >= 2, sItems(1), "") + Dim sToolTip As String = If(sItems.Count() >= 3, sItems(2), "") + Dim sDrawMachOrBoth As String = If(sItems.Count() >= 4 AndAlso Not String.IsNullOrWhiteSpace(sItems(3)), sItems(3), "1") + If Not String.IsNullOrWhiteSpace(sBaseDir) And Not String.IsNullOrWhiteSpace(sLuaPath) Then + If sLuaPath.Contains(".lua") Then sLuaPath = sBaseDir & "\" & sLuaPath + If Not String.IsNullOrWhiteSpace(sImagePath) Then sImagePath = sBaseDir & "\" & sImagePath + End If + ReadButtonItem = New ButtonItem(sSection, sLuaPath, sImagePath, sToolTip, sDrawMachOrBoth) + Return True + End If + Return False + End Function + +#End Region ' Methods + +End Class + +Public Class ButtonItem + Inherits VMBase + + Friend Shared WithEvents m_ProjectVM As ProjectVM + Private Shared m_sCurrBarName As String + + Private m_sBarName As String + Private m_sImagePath As String + Public ReadOnly Property ImagePath As String + Get + Return m_sImagePath + End Get + End Property + Private m_sLuaCmdPath As String + Private m_sToolTip As String + Public ReadOnly Property ToolTip As String + Get + Return m_sToolTip + End Get + End Property + Private m_nDrawMachOrBoth As Integer + Public ReadOnly Property nDrawMachOrBoth As Integer + Get + Return m_nDrawMachOrBoth + End Get + End Property + Friend m_Btn_Visibility As Visibility + Public ReadOnly Property Btn_Visibility As Visibility + Get + Return m_Btn_Visibility + End Get + End Property + + Friend m_Btn_IsEnabled As Boolean = True + Public ReadOnly Property Btn_IsEnabled As Boolean + Get + Return m_Btn_IsEnabled + End Get + End Property + + ' Definizione comandi + Private m_cmdLuaExec As ICommand + + Sub New( sBarName As String, sLuaCmdPath As String, sImagePath As String, sToolTip As String, sDrawMachOrBoth As String) + m_sBarName = sBarName + If File.Exists(sImagePath) Then + ' per lasciare libere le immagini le copio (potrebbe fallire perchè bloccate da altro eseguibile) + Dim sNewPath As String = Path.Combine(Map.refMainWindowVM.MainWindowM.sResourcesRoot, sBarName & "_" & Path.GetFileName(sImagePath)) + Try + File.Copy( sImagePath, sNewPath, True) + Catch ex As Exception + End Try + m_sImagePath = sNewPath + Else + m_sImagePath = Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\" & sImagePath + End If + m_sLuaCmdPath = sLuaCmdPath + m_sToolTip = sToolTip + If Not Integer.TryParse(sDrawMachOrBoth, m_nDrawMachOrBoth) Then m_nDrawMachOrBoth = 0 + End Sub + +#Region "COMMANDS" + +#Region "LuaExecCommand" + + ''' + ''' Returns a command that do New. + ''' + Public ReadOnly Property LuaExecCommand As ICommand + Get + If m_cmdLuaExec Is Nothing Then + m_cmdLuaExec = New Command(AddressOf LuaExec) + End If + Return m_cmdLuaExec + End Get + End Property + + ''' + ''' Execute the New. This method is invoked by the NewCommand. + ''' + Public Sub LuaExec(ByVal param As Object) + If String.IsNullOrWhiteSpace(m_sLuaCmdPath) Then Return + If Not File.Exists(m_sLuaCmdPath) Then Return + If Not Path.GetExtension(m_sLuaCmdPath).ToLower = ".lua" Then Return + ' Abilito eventi se comando lua termina con Beam\Process.lua + m_sCurrBarName = m_sBarName + Dim bRaiseEvent As Boolean = ( m_sBarName = "Beam" OrElse m_sBarName = "Wall") + ' eseguo file Lua + EgtBEAMWALL.Optimizer.LuaExec.ExecScript(m_sLuaCmdPath, bRaiseEvent) + m_sCurrBarName = Nothing + End Sub + +#End Region ' LuaExecCommand + +#End Region ' Commands + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml new file mode 100644 index 00000000..1c67efa7 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml @@ -0,0 +1,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml.vb new file mode 100644 index 00000000..64883fe6 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdOptimizerStatisticsV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdOptimizerStatisticsV + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml new file mode 100644 index 00000000..783f327f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml.vb new file mode 100644 index 00000000..4769b408 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdPDFEditorV.xaml.vb @@ -0,0 +1,12 @@ +Public Class OnlyProdPDFEditorV + + Sub New() + + ' La chiamata è richiesta dalla finestra di progettazione. + InitializeComponent() + + ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). + DataContext = New PDFEditorVM() + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml new file mode 100644 index 00000000..aa4b0394 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml @@ -0,0 +1,200 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml.vb new file mode 100644 index 00000000..0448cdcd --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OnlyProdStatisticsV.xaml.vb @@ -0,0 +1,10 @@ +Public Class OnlyProdStatisticsV + + Private m_StatisticsVM As StatisticsVM + + Private Sub PrintBtn_Click(sender As Object, e As RoutedEventArgs) Handles CopyToClipboardBtn.Click + m_StatisticsVM = Me.DataContext() + ExportToExcelAndCsv(dgStatistics, m_StatisticsVM) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml b/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml new file mode 100644 index 00000000..6757f9c0 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml.vb new file mode 100644 index 00000000..702116dd --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/OptimizerStatisticsV.xaml.vb @@ -0,0 +1,16 @@ +Public Class OptimizerStatisticsV + + Private m_StatisticsVM As StatisticsVM + + Sub New() + ' This call is required by the designer. + InitializeComponent() + + End Sub + + Private Sub PrintBtn_Click(sender As Object, e As RoutedEventArgs) Handles CopyToClipboardBtn.Click + m_StatisticsVM = Me.DataContext() + CopyToClipboard(dgOptimizerStatistics, dgRawPartStatistics, m_StatisticsVM) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml new file mode 100644 index 00000000..02bcfe35 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml.vb new file mode 100644 index 00000000..1dded60a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorV.xaml.vb @@ -0,0 +1,12 @@ +Public Class PDFEditorV + + Sub New() + + ' La chiamata è richiesta dalla finestra di progettazione. + InitializeComponent() + + ' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent(). + DataContext = New PDFEditorVM() + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/PDFEditorVM.vb b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorVM.vb new file mode 100644 index 00000000..dcc8446a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/PDFEditorVM.vb @@ -0,0 +1,460 @@ +Imports System.Collections.ObjectModel +Imports EgtBEAMWALL.Core +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.Globalization +Imports System.IO + +Public Class PDFEditorVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + 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 + Return m_ExpanderList + End Get + End Property + + ' PDF visualizzato come preview nella sezione PDF Editor + Private m_WebAddress As String + Public ReadOnly Property WebAddress As String + Get + Return m_WebAddress + End Get + End Property + Friend Sub SetWebAddress(value As String) + m_WebAddress = value + NotifyPropertyChanged(NameOf(WebAddress)) + End Sub + + Private m_PdfViewer_Visibility As Visibility + Public ReadOnly Property PdfViewer_Visibility As Visibility + Get + Return m_PdfViewer_Visibility + End Get + End Property + Friend Sub SetPdfViewer_Visibility(value As Visibility) + m_PdfViewer_Visibility = value + NotifyPropertyChanged(NameOf(PdfViewer_Visibility)) + End Sub + + ' Definizione comandi + Private m_cmdCreatePDFPreviewVis As ICommand + Private m_cmdCreatePDFPreviewOtt As ICommand + Private m_cmdClosePreview As ICommand + +#End Region + +#Region "CONSTRUCTORS" + + Sub New() + m_ExpanderList.Add(New ExpanderPDF(ListTypes.MACHGROUPTOT)) ' MachGroup Totals + m_ExpanderList.Add(New ExpanderPDF(ListTypes.MACHGROUP)) ' MachGroup List + m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART_LIST)) ' Raw Part + m_ExpanderList.Add(New ExpanderPDF(ListTypes.RAWPART)) ' RawPart List + m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART_TOT)) ' Part Totals + m_ExpanderList.Add(New ExpanderPDF(ListTypes.PART)) ' Part List + SetWebAddress("") ' Pagina vuota + SetPdfViewer_Visibility(Visibility.Hidden) + Map.SetRefPDFEditorVM(Me) + End Sub + +#End Region ' Constructors + +#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 + + ''' + ''' Funzione per la visualizzazione della preview del PDF della sezione visualizzatore + ''' + Public Sub CreatePreviewVis() + SetPdfViewer_Visibility(Visibility.Visible) + Configuration.CreatePrintPDF(PDFPage.VIEW, True) + SetWebAddress(Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf") + 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 + + ''' + ''' Funzione per la visualizzazione della preview del PDF della sezione ottimizzatore + ''' + Public Sub CreatePreviewOtt() + SetPdfViewer_Visibility(Visibility.Visible) + Configuration.CreatePrintPDF(PDFPage.MACHING, True) + SetWebAddress(Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf") + End Sub + +#End Region ' CreatePreviewOt + +#Region "ClosePreview" + + Public ReadOnly Property ClosePreview_Command As ICommand + Get + If m_cmdClosePreview Is Nothing Then + m_cmdClosePreview = New Command(AddressOf ClosePreview) + End If + Return m_cmdClosePreview + End Get + End Property + + ''' + ''' Funzione per la chiusura della preview + ''' + Public Sub ClosePreview() + Try + File.Delete(Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf") + Catch ex As Exception + EgtOutLog("Errore! Cancellazione dei file pdf fallita") + End Try + + SetPdfViewer_Visibility(Visibility.Hidden) + SetWebAddress("") + End Sub + +#End Region ' CreatePreviewVis + +#End Region ' Commands + +End Class + +Public Class ExpanderPDF + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + 'Nome della categoria MachGroup Totals, MachGroup List, Raw Part e Raw Part List + Private m_sNameCategory As String + Public ReadOnly Property sNameCategory As String + Get + Return m_sNameCategory + End Get + End Property + + 'Lista degli elementi visualizzati nell'expander es Numero di grezzi o le colonne es colName + Private m_ExpanderElementList As New List(Of ExpanderPDF) + Public ReadOnly Property ExpanderElementList As List(Of ExpanderPDF) + Get + Return m_ExpanderElementList + End Get + End Property + +#End Region ' Fields & Properties + +#Region "CONTRUCTORS" + + Sub New() + End Sub + + Sub New(nListType As Integer) + Select Case nListType + Case ListTypes.MACHGROUPTOT ' MachGroup Totals + 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 ' MachGroup List + m_sNameCategory = EgtMsg(61730) ' Titolo Categoria: MachGroup List + m_ExpanderElementList.Add(New ExpanderTable(S_OPTIMIZERSTATISTICS)) ' Tabella MachGroupList + Case ListTypes.PART_LIST ' Raw 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 ' RawPart List + m_sNameCategory = EgtMsg(61732) ' Titolo Categoria: RawPart List + m_ExpanderElementList.Add(New ExpanderTable(S_RAWPARTSTATISTICS)) ' Tabella RawPartList + Case ListTypes.PART_TOT ' Part Totals + 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 ' Part List + m_sNameCategory = EgtMsg(61733) ' Titolo Categoria: Part List + m_ExpanderElementList.Add(New ExpanderTable(S_STATISTICS)) ' Tabella PartList + End Select + End Sub + +#End Region ' Constructors + +End Class + +Public Class ExpanderElement + Inherits ExpanderPDF + +#Region "FIELDS & PROPERTIES" + + 'Nome dei parametri visualizzati nella sezione del PDF Machgroup Totals es Numero di grezzi + Private m_sNameParameter As String + Public ReadOnly Property sNameParameter As String + Get + Return m_sNameParameter + End Get + End Property + + 'Check Box dei parametri visualizzati nella sezione del PDF Machgroup Totals + Private m_bParameter_IsChecked As Boolean + Public Property bParameter_IsChecked As Boolean + Get + Return m_bParameter_IsChecked + End Get + Set(value As Boolean) + m_bParameter_IsChecked = value + NotifyPropertyChanged(NameOf(bParameter_IsChecked)) + WriteMainPrivateProfileString(S_PDFEDITOR, m_sNameParameter, If(m_bParameter_IsChecked, 1, 0)) + End Set + End Property + +#End Region 'Fields & Properties + +#Region "CONTRUCTORS" + + Sub New(NameParameter As String) + m_sNameParameter = NameParameter + m_bParameter_IsChecked = GetMainPrivateProfileInt(S_PDFEDITOR, m_sNameParameter, 0) <> 0 + End Sub + +#End Region 'Constructors + +End Class + +Public Class ExpanderTable + Inherits ExpanderPDF + +#Region "FIELDS & PROPERTIES" + +#Region "RAWPARTCOLUMNS" + + 'Lista Colonne Tabella MachGroup List, RawPart List, PartList + Private m_RawPartColumns As New ObservableCollection(Of EgtDataGridColumn) + Public ReadOnly Property RawPartColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_RawPartColumns + End Get + End Property + + 'Elemento delle Liste MachGroup List, RawPart List, PartList selezionato es colName + Private m_SelColumns As EgtDataGridColumn + Public Property SelColumns As EgtDataGridColumn + Get + Return m_SelColumns + End Get + Set(value As EgtDataGridColumn) + m_SelColumns = value + End Set + End Property + +#End Region ' RawPartColumns + +#Region "SECTION & IMAGE" + + ' Visualizza Sezione ed Immagine solo se fa parte di DG_Statistics_PART + Private m_vRawPartVisibility As Visibility + Public ReadOnly Property vRawPartVisibility As Visibility + Get + Return m_vRawPartVisibility + End Get + End Property + + ' Check Box per la visualizzazione nel PDF della sezione + Private m_bSection_IsChecked As Boolean + Public Property bSection_IsChecked As Boolean + Get + Return m_bSection_IsChecked + End Get + Set(value As Boolean) + m_bSection_IsChecked = value + NotifyPropertyChanged(NameOf(bSection_IsChecked)) + WriteMainPrivateProfileString(S_PDFEDITOR, S_SECTION, If(m_bSection_IsChecked, 1, 0)) + End Set + End Property + + ' Check Box per la visualizzazione nel PDF dell' immagine + Private m_bImage_IsChecked As Boolean + Public Property bImage_IsChecked As Boolean + Get + Return m_bImage_IsChecked + End Get + Set(value As Boolean) + m_bImage_IsChecked = value + NotifyPropertyChanged(NameOf(bImage_IsChecked)) + WriteMainPrivateProfileString(S_PDFEDITOR, S_IMAGE, If(m_bImage_IsChecked, 1, 0)) + End Set + End Property + +#End Region ' Section & Image + +#End Region ' FIELDS & PROPERTIES + +#Region "MESSAGES" + + Public ReadOnly Property Section_Msg As String + Get + Return EgtMsg(61735).ToUpper() + End Get + End Property + + Public ReadOnly Property Image_Msg As String + Get + Return EgtMsg(61736).ToUpper() + End Get + End Property + +#End Region ' Messages + + ' Definizione comandi + Private m_cmdMoveUpOrder As ICommand + Private m_cmdMoveDownOrder As ICommand + +#Region "CONTRUCTORS" + + Sub New(TypeTable As String) + GetPrivateProfileColumns(TypeTable, m_RawPartColumns) + m_vRawPartVisibility = If(TypeTable = S_STATISTICS_PART, Visibility.Visible, Visibility.Collapsed) + m_bSection_IsChecked = GetMainPrivateProfileInt(S_PDFEDITOR, S_SECTION, 0) <> 0 + m_bImage_IsChecked = GetMainPrivateProfileInt(S_PDFEDITOR, S_IMAGE, 0) <> 0 + End Sub + +#End Region ' Constructors + +#Region "COMMANDS" + +#Region "MoveUpOrder" + + Public ReadOnly Property MoveUpOrder_Command As ICommand + Get + If m_cmdMoveUpOrder Is Nothing Then + m_cmdMoveUpOrder = New Command(AddressOf MoveUpOrder) + End If + Return m_cmdMoveUpOrder + End Get + End Property + + ''' + ''' Funzione per spostare in alto la colonna + ''' + Public Sub MoveUpOrder() + If IsNothing(m_RawPartColumns) Then Return + Dim nIndex As Integer = m_RawPartColumns.IndexOf(m_SelColumns) + If nIndex < 0 Then Return + If nIndex > 0 Then m_RawPartColumns.Move(nIndex, nIndex - 1) + End Sub + +#End Region ' MoveUpOrder + +#Region "MoveDownOrder" + + Public ReadOnly Property MoveDownOrder_Command As ICommand + Get + If m_cmdMoveDownOrder Is Nothing Then + m_cmdMoveDownOrder = New Command(AddressOf MoveDownOrder) + End If + Return m_cmdMoveDownOrder + End Get + End Property + + ''' + ''' Funzione per spostare in basso la colonna + ''' + Public Sub MoveDownOrder() + If IsNothing(m_RawPartColumns) Then Return + Dim nIndex As Integer = m_RawPartColumns.IndexOf(m_SelColumns) + If nIndex < 0 Then Return + If nIndex < m_RawPartColumns.Count - 1 Then m_RawPartColumns.Move(nIndex, nIndex + 1) + End Sub + +#End Region ' MoveDownOrder + +#End Region ' Commands + +End Class + +Class ColumnNameConverter + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert + Dim ColName As String = "" + If TypeOf value Is String Then + ColName = CStr(value) + Select Case value + 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 + Return Statistic_Messages.NAM_Msg + Case COL_NAME + 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_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 COL_INPROD + Return Statistic_Messages.INPROD_Msg + Case Else + Return Nothing + End Select + Else + Return Nothing + End If + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack + Throw New NotImplementedException() + End Function +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/Statistics/PDFHelper.vb b/EgtBEAMWALL.Optimizer/Statistics/PDFHelper.vb new file mode 100644 index 00000000..afb2b00f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/PDFHelper.vb @@ -0,0 +1,1030 @@ +Imports MigraDoc.DocumentObjectModel +Imports MigraDoc.DocumentObjectModel.Shapes.Charts +Imports MigraDoc.DocumentObjectModel.Tables +Imports EgtBEAMWALL.Core +Imports EgtBEAMWALL.Core.ConstGen +Imports EgtUILib +Imports System.Collections.ObjectModel +Imports MigraDoc.DocumentObjectModel.Shapes +Imports System.IO + +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() + Dim Project As ProjectFileVM + + If ActivePage = Pages.VIEW OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Map.refInstrumentPanelVM.bVisOtt_Selected = False) Then + Project = ProjectManagerVM.CurrProj + document.Info.Title = Project.sProjId & " - " & Project.BTLFileName_Msg & " - Statistics" + ElseIf ActivePage = Pages.MACHINING OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Map.refInstrumentPanelVM.bVisOtt_Selected) Then + If ActivePage = Pages.CONFIG Then + Project = ProjectManagerVM.CurrProj + document.Info.Title = Project.sProjId & " - " & Project.BTLFileName_Msg & " - Statistics" + ElseIf ActivePage = Pages.ONLYPRODPAGE Then + Project = ProjectManagerVM.CurrProd + document.Info.Title = Project.sProdId & " - " & Project.ListName_Msg & " - Statistics" + End If + 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) + + If ActivePage = Pages.VIEW OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Map.refInstrumentPanelVM.bVisOtt_Selected = False) Then + DefinePartTotals(document, section, bPreview) + DefineItemList(document, ListTypes.PART, bPreview) + ElseIf ActivePage = Pages.MACHINING OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Map.refInstrumentPanelVM.bVisOtt_Selected) 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) + Dim countItemList As Integer + 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 table As New Table() + table.Borders.Width = 0.75 + ' ciclo sulle colonne per creare la tabella e riempirne i campi + ' -2 -> creo colonne + ' -1 -> riempio colonne della riga degli header + ' >=0 -> riempio le colonne con i valori dei pezzi + Dim Itemlist As IEnumerable(Of Object) = Nothing + ' 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 + If Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE Then Map.refStatisticsVM.LoadRawPart() + Itemlist = Map.refStatisticsVM.RawPartList + End Select + End If + countItemList = If(bPreview, Itemlist.Count, Itemlist.Count - 1) + + For PartIndex = -2 To countItemList + Dim BTLPartVM As BTLPartVM = Nothing + Dim MachGroupVM As MyMachGroupVM = Nothing + Dim RawPart As SParam = 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 + If bPreview Then + ' recupero elemento della riga + Select Case nListType + Case ListTypes.PART + BTLPartVM = Nothing + Case ListTypes.MACHGROUP + MachGroupVM = Nothing + Case ListTypes.RAWPART + RawPart = Nothing + End Select + Else + ' recupero elemento della riga + Select Case nListType + Case ListTypes.PART + BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList(PartIndex) + Case ListTypes.MACHGROUP + MachGroupVM = Map.refProjectVM.MachGroupPanelVM.MachGroupVMList(PartIndex) + Case ListTypes.RAWPART + RawPart = Map.refStatisticsVM.RawPartList(PartIndex) + End Select + End If + End If + Dim Columnlist As ObservableCollection(Of EgtDataGridColumn) = Nothing + Select Case nListType + Case ListTypes.PART + Columnlist = sMachGroupList.RawPartColumns + Case ListTypes.MACHGROUP + Columnlist = sMachGroupList.RawPartColumns + Case ListTypes.RAWPART + Columnlist = sMachGroupList.RawPartColumns + End Select + For ColumnIndex = 0 To Columnlist.Count - 1 + Select Case Columnlist(ColumnIndex).Name + Case COL_PDN + If sPDN.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.PDN_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 1, BTLPartVM.nPDN)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_ID + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Map.refStatisticsVM.ID_Msg) + ElseIf nListType = ListTypes.MACHGROUP Then + row.Cells(ColumnIndex).AddParagraph(MachGroupVM.Id) + End If + Case COL_W + If sW.bIsChecked Then + If PartIndex = -2 Then + Select Case nListType + Case ListTypes.PART + table.AddColumn(Unit.FromCentimeter(1)) + Case ListTypes.MACHGROUP, ListTypes.RAWPART + table.AddColumn(Unit.FromCentimeter(2)) + End Select + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.W_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, 200, 120)) + Else + Select Case nListType + Case ListTypes.PART + row.Cells(ColumnIndex).AddParagraph(BTLPartVM.sW) + Case ListTypes.MACHGROUP + row.Cells(ColumnIndex).AddParagraph(MachGroupVM.dW) + Case ListTypes.RAWPART + row.Cells(ColumnIndex).AddParagraph(RawPart.sW) + End Select + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_H + If sH.bIsChecked Then + If PartIndex = -2 Then + Select Case nListType + Case ListTypes.PART + table.AddColumn(Unit.FromCentimeter(1)) + Case ListTypes.MACHGROUP, ListTypes.RAWPART + table.AddColumn(Unit.FromCentimeter(2)) + End Select + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.H_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, 360, 160)) + Else + Select Case nListType + Case ListTypes.PART + row.Cells(ColumnIndex).AddParagraph(BTLPartVM.sH) + Case ListTypes.MACHGROUP + row.Cells(ColumnIndex).AddParagraph(MachGroupVM.dH) + Case ListTypes.RAWPART + row.Cells(ColumnIndex).AddParagraph(RawPart.sH) + End Select + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_L + If sL.bIsChecked Then + If PartIndex = -2 Then + Select Case nListType + Case ListTypes.PART + table.AddColumn(Unit.FromCentimeter(1.6)) + Case ListTypes.MACHGROUP, ListTypes.RAWPART + table.AddColumn(Unit.FromCentimeter(2)) + End Select + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.L_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, 6672.6, 15000)) + Else + Select Case nListType + Case ListTypes.PART + row.Cells(ColumnIndex).AddParagraph(BTLPartVM.sL) + Case ListTypes.MACHGROUP + row.Cells(ColumnIndex).AddParagraph(MachGroupVM.dL) + Case ListTypes.RAWPART + row.Cells(ColumnIndex).AddParagraph(RawPart.sL) + End Select + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_DESC + If sDesc.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(4)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.NAM_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, "Arc.in salita smussato", 1)) + Else + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, BTLPartVM.sNAM, MachGroupVM.nName)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_NAME + If sName.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(4)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.NAM_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, "Arc.in salita smussato", 1)) + Else + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, BTLPartVM.sNAM, MachGroupVM.nName)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_MATERIAL + If sMaterial.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.MAT_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph("GL24h") + Else + Select Case nListType + Case ListTypes.PART + row.Cells(ColumnIndex).AddParagraph(BTLPartVM.sMATERIAL) + Case ListTypes.MACHGROUP + row.Cells(ColumnIndex).AddParagraph(MachGroupVM.sMATERIAL) + Case ListTypes.RAWPART + row.Cells(ColumnIndex).AddParagraph(RawPart.sMaterial) + End Select + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_CNT + If sCNT.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.6)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.CNT_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 1, BTLPartVM.sCNT)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_ADDED + If sAdded.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.ADDED_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 0, BTLPartVM.sADDED)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_INPROD + If sINProd.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.INPROD_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 0, BTLPartVM.nINPROD)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_DONE + If sDone.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.DONE_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 0, BTLPartVM.nDONE)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_USAGE + If sUsage.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.Used_Msg) + ElseIf nListType = ListTypes.MACHGROUP Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 99.719, MachGroupVM.sUsage)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_WASTE + If sWaste.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.Waste_Msg) + ElseIf nListType = ListTypes.MACHGROUP Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 0.5, MachGroupVM.sWaste)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_UNITVOLUME + If sUVolume.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(If(nListType = ListTypes.PART, Unit.FromCentimeter(1.5), Unit.FromCentimeter(2))) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.UNIT_VOLUME_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(0.48) + Else + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, BTLPartVM.sUnitVolume, MachGroupVM.dUnitVolume)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_TOTVOLUME + If sTVolume.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.TOT_VOLUME_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 0.48, BTLPartVM.sTotVolume)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_UNITTIME + If sUTime.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2.2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.UNIT_TIME_Msg) + ElseIf bPreview Then + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, "00:00:00", "00:13:07")) + Else + row.Cells(ColumnIndex).AddParagraph(If(nListType = ListTypes.PART, BTLPartVM.sUnitTime, MachGroupVM.sUnitTime)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_TOTTIME + If sTTime.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.TOT_TIME_Msg) + ElseIf nListType = ListTypes.PART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, "00:00:00", BTLPartVM.sTotTime)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_QTY + If sQty.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.QTY_Msg) + ElseIf nListType = ListTypes.RAWPART Then + row.Cells(ColumnIndex).AddParagraph(If(bPreview, 11, RawPart.nQuantity)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + End Select + Next + Next + ' aggiungo tabella all'ultima sezione + document.LastSection.Add(table) + End Sub + + 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() + ' cambio orientamento a verticale + Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone() + pgSetup.Orientation = Orientation.Landscape + section.PageSetup = pgSetup + Dim PartVMList As IEnumerable(Of Object) + Dim countPartVMList As Integer + If IsNothing(RawPart) Then + PartVMList = New List(Of Object) + CreateRawPartImage(section, sMachGroupList, 44143, 1, bPreview) + countPartVMList = PartVMList.Count + Else + PartVMList = RawPart.PartVMList + CreateRawPartImage(section, sMachGroupList, RawPart.Id, RawPart.Name, bPreview) + countPartVMList = PartVMList.Count - 1 + End If + + ' aggiungo tabella dei pezzi + Dim table As Table = New Table() + table.Borders.Width = 0.75 + For PartIndex = -2 To countPartVMList + 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) = sMachGroupList.RawPartColumns + For ColumnIndex = 0 To Columnlist.Count - 1 + Select Case Columnlist(ColumnIndex).Name + Case COL_PDN + If sPDN.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(1.5)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.PDN_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), 55, PartVM.nPDN)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_W + If sW.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.W_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), 120, PartVM.sW)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_H + If sH.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.H_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), 160, PartVM.sH)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_L + If sL.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.L_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), 185.9, PartVM.sL)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_DESC + If sDesc.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(4)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.NAM_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), "Correntini", PartVM.sNAM)) + End If + ElseIf PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(0)) + End If + Case COL_NAME + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(4)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.NAM_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(PartVM.sNAM) + End If + Case COL_MATERIAL + If sMaterial.bIsChecked Then + If PartIndex = -2 Then + table.AddColumn(Unit.FromCentimeter(2)) + ElseIf PartIndex = -1 Then + row.Cells(ColumnIndex).AddParagraph(Statistic_Messages.MAT_Msg) + Else + row.Cells(ColumnIndex).AddParagraph(If(IsNothing(RawPart), "GL24h", 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, bPreview As Boolean) + ' creo immagine + Dim sImagePath As String + If File.Exists(Map.refMainWindowVM.MainWindowM.sTempDir & "\Image" & RawPartId & ".png") Then + sImagePath = Map.refMainWindowVM.MainWindowM.sTempDir & "\Image" & RawPartId & ".png" + Else + sImagePath = Map.refMainWindowVM.MainWindowM.sTempDir & "\ImageNotFound.png" + End If + If bPreview Then + EgtSetCurrMachGroup(RawPartId) + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.FRONT, VT.TOP), False) + EgtZoom(ZM.ALL, False) + EgtGetImage(SM.HIDDENLINE, New Color3d(255, 255, 255), New Color3d(255, 255, 255), 3000, 1000, sImagePath) + End If + ' 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(245) + Image.Height = Unit.FromMillimeter(40) + Image.LockAspectRatio = True + Image.RelativeVertical = RelativeVertical.Line + Image.Top = ShapePosition.Top + Image.Left = ShapePosition.Left + Image.WrapFormat.Style = WrapStyle.Through + Image.RelativeHorizontal = RelativeHorizontal.Margin + End Sub + + ''' + ''' Defines the styles used in the document. + ''' + 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 + + ''' + ''' Defines the cover page. + ''' + 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 + + ''' + ''' Defines table of contents. + ''' + 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 diff --git a/EgtBEAMWALL.Optimizer/Statistics/StatisticsUtility.vb b/EgtBEAMWALL.Optimizer/Statistics/StatisticsUtility.vb new file mode 100644 index 00000000..97590a32 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/StatisticsUtility.vb @@ -0,0 +1,70 @@ +Public Module StatisticsUtility + + Public Sub CopyToClipboard(dgOptimizerStatistics As DataGrid, dgRawPartStatistics As DataGrid, StatisticsVM As StatisticsVM) + If Map.refStatisticsVM.bRawPart_IsChecked Then + ExportToExcelAndCsv(dgRawPartStatistics, StatisticsVM) + Else + ExportToExcelAndCsv(dgOptimizerStatistics, StatisticsVM) + End If + End Sub + + Public Sub ExportToExcelAndCsv(dgDataGrid As DataGrid, StatisticsVM As StatisticsVM) + ' imposto gli header + For Each DataGridColumn In dgDataGrid.Columns + If IsNothing(DataGridColumn) OrElse IsNothing(DataGridColumn.HeaderTemplate) Then Continue For + ' recupero il contenuto del HeaderTemplate + Dim DataGridColumnHeaderFE As FrameworkElement = DataGridColumn.HeaderTemplate.LoadContent() + ' recupero la stringa di binding + Dim DataGridColumnHeaderBindingText = DataGridColumnHeaderFE.GetBindingExpression(TextBlock.TextProperty).ParentBinding.Path.Path() + ' applico la stessa proprieta' del binding + Select Case DataGridColumnHeaderBindingText + Case "DataContext.PDN_Msg" + DataGridColumn.Header = StatisticsVM.PDN_Msg + Case "DataContext.ID_Msg" + DataGridColumn.Header = StatisticsVM.ID_Msg + Case "DataContext.W_Msg" + DataGridColumn.Header = StatisticsVM.W_Msg + Case "DataContext.H_Msg" + DataGridColumn.Header = StatisticsVM.H_Msg + Case "DataContext.L_Msg" + DataGridColumn.Header = StatisticsVM.L_Msg + Case "DataContext.NAM_Msg" + DataGridColumn.Header = StatisticsVM.NAM_Msg + Case "DataContext.MAT_Msg" + DataGridColumn.Header = StatisticsVM.MAT_Msg + Case "DataContext.CNT_Msg" + DataGridColumn.Header = StatisticsVM.CNT_Msg + Case "DataContext.ADDED_Msg" + DataGridColumn.Header = StatisticsVM.ADDED_Msg + Case "DataContext.INPROD_Msg" + DataGridColumn.Header = StatisticsVM.INPROD_Msg + Case "DataContext.DONE_Msg" + DataGridColumn.Header = StatisticsVM.DONE_Msg + Case "DataContext.Used_Msg" + DataGridColumn.Header = StatisticsVM.Used_Msg + Case "DataContext.Waste_Msg" + DataGridColumn.Header = StatisticsVM.Waste_Msg + Case "DataContext.UNIT_VOLUME_Msg" + DataGridColumn.Header = StatisticsVM.UNIT_VOLUME_Msg + Case "DataContext.TOT_VOLUME_Msg" + DataGridColumn.Header = StatisticsVM.TOT_VOLUME_Msg + Case "DataContext.UNIT_TIME_Msg" + DataGridColumn.Header = StatisticsVM.UNIT_TIME_Msg + Case "DataContext.TOT_TIME_Msg" + DataGridColumn.Header = StatisticsVM.TOT_TIME_Msg + Case "DataContext.QTY_Msg" + DataGridColumn.Header = StatisticsVM.QTY_Msg + End Select + Next + dgDataGrid.SelectAllCells() + dgDataGrid.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader + Try + ApplicationCommands.Copy.Execute(Nothing, dgDataGrid) + Catch ex As Exception + Map.refMyStatusBarVM.SetOutputMessage("Copy to clipboard impossible", 3, EgtWPFLib5.MSG_TYPE.INFO) + End Try + Map.refMyStatusBarVM.SetOutputMessage("Copied to clipboard", 3, EgtWPFLib5.MSG_TYPE.INFO) + dgDataGrid.UnselectAllCells() + End Sub + +End Module \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml b/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml new file mode 100644 index 00000000..4faedf1c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml.vb b/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml.vb new file mode 100644 index 00000000..16e31206 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/StatisticsV.xaml.vb @@ -0,0 +1,16 @@ +Public Class StatisticsV + + Private m_StatisticsVM As StatisticsVM + + Sub New() + ' This call is required by the designer. + InitializeComponent() + + End Sub + + Private Sub PrintBtn_Click(sender As Object, e As RoutedEventArgs) Handles CopyToClipboardBtn.Click + m_StatisticsVM = Me.DataContext() + ExportToExcelAndCsv(dgStatistics, m_StatisticsVM) + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/Statistics/StatisticsVM.vb b/EgtBEAMWALL.Optimizer/Statistics/StatisticsVM.vb new file mode 100644 index 00000000..d85683e4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/Statistics/StatisticsVM.vb @@ -0,0 +1,416 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 +Imports MigraDoc.DocumentObjectModel +Imports MigraDoc.Rendering + +Public Class StatisticsVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Friend Event m_CloseWindow(bDialogResult As Boolean) + + Public Enum StatisticsTab As Integer + OPTIMIZER = 0 + RAWPART = 1 + End Enum + + Private m_SelStatisticsTab As StatisticsTab + Public Property SelStatisticsTab As Integer + Get + Return m_SelStatisticsTab + End Get + Set(value As Integer) + m_SelStatisticsTab = value + End Set + End Property + + Private m_bRawPart_IsChecked As Boolean + Public Property bRawPart_IsChecked As Boolean + Get + Return m_bRawPart_IsChecked + End Get + Set(value As Boolean) + m_bRawPart_IsChecked = value + If value Then + m_SelStatisticsTab = StatisticsTab.RAWPART + Else + m_SelStatisticsTab = StatisticsTab.OPTIMIZER + End If + NotifyPropertyChanged(NameOf(SelStatisticsTab)) + End Set + End Property + + Private m_StatisticsColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property StatisticsColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_StatisticsColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_StatisticsColumns = value + End Set + End Property + + Private m_OptimizerStatisticsColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property OptimizerStatisticsColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_OptimizerStatisticsColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_OptimizerStatisticsColumns = value + End Set + End Property + + Private m_RawPartStatisticsColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property RawPartStatisticsColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_RawPartStatisticsColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_RawPartStatisticsColumns = value + End Set + End Property + + Private m_RawPartList As New ObservableCollection(Of SParam) + Public ReadOnly Property RawPartList As ObservableCollection(Of SParam) + Get + Return m_RawPartList + End Get + End Property + + ' Definizione comandi + Private m_cmdPrintPDF As ICommand + Private m_cmdOk As ICommand + +#Region "Messages" + + Public ReadOnly Property PDN_Msg As String + Get + Return Statistic_Messages.PDN_Msg + End Get + End Property + + Public ReadOnly Property ID_Msg As String + Get + Return Statistic_Messages.ID_Msg + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return Statistic_Messages.DO_Msg + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return Statistic_Messages.W_Msg + End Get + End Property + + Public ReadOnly Property H_Msg As String + Get + Return Statistic_Messages.H_Msg + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return Statistic_Messages.L_Msg + End Get + End Property + + Public ReadOnly Property NAM_Msg As String + Get + Return Statistic_Messages.NAM_Msg + End Get + End Property + + Public ReadOnly Property MAT_Msg As String + Get + Return Statistic_Messages.MAT_Msg + End Get + End Property + + Public ReadOnly Property CNT_Msg As String + Get + Return Statistic_Messages.CNT_Msg + End Get + End Property + + Public ReadOnly Property ADDED_Msg As String + Get + Return Statistic_Messages.ADDED_Msg + End Get + End Property + + Public ReadOnly Property INPROD_Msg As String + Get + Return Statistic_Messages.INPROD_Msg + End Get + End Property + + Public ReadOnly Property DONE_Msg As String + Get + Return Statistic_Messages.DONE_Msg + End Get + End Property + + Public ReadOnly Property GRP_Msg As String + Get + Return Statistic_Messages.GRP_Msg + End Get + End Property + + Public ReadOnly Property UNIT_VOLUME_Msg As String + Get + Return Statistic_Messages.UNIT_VOLUME_Msg + End Get + End Property + + Public ReadOnly Property TOT_VOLUME_Msg As String + Get + Return Statistic_Messages.TOT_VOLUME_Msg + End Get + End Property + + Public ReadOnly Property UNIT_TIME_Msg As String + Get + Return Statistic_Messages.UNIT_TIME_Msg + End Get + End Property + + Public ReadOnly Property TOT_TIME_Msg As String + Get + Return Statistic_Messages.TOT_TIME_Msg + End Get + End Property + + Public ReadOnly Property BTLTotParts_Msg As String + Get + Return Statistic_Messages.BTLTotParts_Msg + End Get + End Property + + Public ReadOnly Property BTLTotVolume_Msg As String + Get + Return Statistic_Messages.BTLTotVolume_Msg + End Get + End Property + + Public ReadOnly Property BTLTotEstimatedTime_Msg As String + Get + Return Statistic_Messages.BTLTotEstimatedTime_Msg + End Get + End Property + + Public ReadOnly Property BTLTotTime_Msg As String + Get + Return Statistic_Messages.BTLTotTime_Msg + End Get + End Property + + Public ReadOnly Property BTLRemainingTime_Msg As String + Get + Return Statistic_Messages.BTLRemainingTime_Msg + End Get + End Property + + Public ReadOnly Property TotMachGroups_Msg As String + Get + Return Statistic_Messages.TotMachGroups_Msg + End Get + End Property + + Public ReadOnly Property TotCNTParts_Msg As String + Get + Return Statistic_Messages.TotCNTParts_Msg + End Get + End Property + + Public ReadOnly Property TotADDEDParts_Msg As String + Get + Return Statistic_Messages.TotADDEDParts_Msg + End Get + End Property + + Public ReadOnly Property TotINPRODParts_Msg As String + Get + Return Statistic_Messages.TotINPRODParts_Msg + End Get + End Property + + Public ReadOnly Property TotDONEParts_Msg As String + Get + Return Statistic_Messages.TotDONEParts_Msg + End Get + End Property + + Public ReadOnly Property Used_Msg As String + Get + Return Statistic_Messages.Used_Msg + End Get + End Property + + Public ReadOnly Property Waste_Msg As String + Get + Return Statistic_Messages.Waste_Msg + End Get + End Property + + Public ReadOnly Property QTY_Msg As String + Get + Return Statistic_Messages.QTY_Msg + End Get + End Property + + Public ReadOnly Property CopyToClipboard_Msg As String + Get + Return EgtMsg(61841) + End Get + End Property + + Public ReadOnly Property PrintPDF_Msg As String + Get + Return EgtMsg(61727) + End Get + End Property + +#End Region ' Messages + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Aggiungo riferimento a Map + Map.SetRefStatisticsVM(Me) + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_STATISTICS, StatisticsColumns) + GetPrivateProfileColumns(S_OPTIMIZERSTATISTICS, OptimizerStatisticsColumns) + GetPrivateProfileColumns(S_RAWPARTSTATISTICS, RawPartStatisticsColumns) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub LoadRawPart() + m_RawPartList.Clear() + Select Case ProjectManagerVM.CurrProd.nType + Case BWType.BEAM + For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim RawPart As SParam = m_RawPartList.FirstOrDefault(Function(x) x.SectXMat.dW = MachGroup.dW AndAlso x.SectXMat.dH = MachGroup.dH AndAlso x.dL = MachGroup.dL AndAlso x.SectXMat.sMaterial.Any(Function(y) MachGroup.Section.sMaterial.Any(Function(z) z = y))) + If Not IsNothing(RawPart) Then + RawPart.nQuantity += 1 + Else + m_RawPartList.Add(New SParam(MachGroup.Section, MachGroup.dL, 1, True)) + End If + Next + Case BWType.WALL + For Each MachGroup As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList + Dim RawPart As SParam = m_RawPartList.FirstOrDefault(Function(x) x.dW = MachGroup.dW AndAlso x.SectXMat.dH = MachGroup.dH AndAlso x.dL = MachGroup.dL AndAlso x.SectXMat.sMaterial.Any(Function(y) MachGroup.Section.sMaterial.Any(Function(z) z = y))) + If Not IsNothing(RawPart) Then + RawPart.nQuantity += 1 + Else + m_RawPartList.Add(New SParam(MachGroup.Section, MachGroup.dW, MachGroup.dL, 1, True)) + End If + Next + End Select + End Sub + + Public Sub CreatePrintPDF(ActivePage As Integer, bPreview As Boolean) + LoadingWndHelper.OpenLoadingWnd(ActiveIds.CREATINGPDF, 1, "Creating PDF", "", 100) + Try + ' creo documento MigraDoc + Dim document As Document = PDFHelper.CreateStatReport(ActivePage, bPreview) + Dim documentPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\MigraDoc.mdddl" + MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, documentPath) + Dim renderer As New PdfDocumentRenderer(True) With { + .Document = document + } + renderer.RenderDocument() + ' salvo il documento + Dim sFileName As String = "" + + If (ActivePage = Pages.VIEW AndAlso Not bPreview) OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Not Map.refInstrumentPanelVM.bVisOtt_Selected AndAlso Not bPreview) Then + sFileName = ProjectManagerVM.CurrProj.sProjDirPath & "\" & "Statistics.pdf" + ElseIf ActivePage = Pages.VIEW OrElse Pages.ONLYPRODPAGE AndAlso bPreview Then + sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf" ' Se la pagina e' 0 e' bPreview e' True creo PDF Visualization + ElseIf (ActivePage = Pages.MACHINING AndAlso Not bPreview) OrElse (ActivePage = Pages.ONLYPRODPAGE AndAlso Map.refInstrumentPanelVM.bVisOtt_Selected AndAlso Not bPreview) Then + sFileName = ProjectManagerVM.CurrProd.sProdDirPath & "\" & ProjectManagerVM.CurrProd.sProdId & " - " & "Statistics.pdf" + ElseIf ActivePage = Pages.MACHINING OrElse Pages.ONLYPRODPAGE AndAlso bPreview Then ' Se la pagina e' 1 e' bPreview e' True creo PDF Optimizer + sFileName = Map.refMainWindowVM.MainWindowM.sTempDir & "\Statistics.pdf" + If Not bOnlyProd Then PrevSelect() + End If + + ' avvio il visualizzatore + renderer.PdfDocument.Save(sFileName) + ' cancello file MigraDoc + File.Delete(documentPath) + + If bPreview Then + Else + Process.Start(sFileName) + End If + Catch ex As Exception + EgtOutLog("Error genereting pdf: " & ex.ToString()) + End Try + LoadingWndHelper.CloseLoadingWnd(ActiveIds.CREATINGPDF) + + End Sub + + Private Shared Sub PrevSelect() + ' ripristino selezione precedente + Dim nCurrMachGroupId As Integer = EgtGetCurrMachGroup() + If Not IsNothing(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup) AndAlso nCurrMachGroupId <> Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.Id Then + EgtSetCurrMachGroup(Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup.Id) + End If + Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.ISO_SW, VT.TOP), False) + EgtZoom(ZM.ALL, True) + End Sub + +#End Region ' PrintPDF + +#Region "COMMANDS" + +#Region "Ok" + + Public ReadOnly Property Ok_Command As ICommand + Get + If m_cmdOk Is Nothing Then + m_cmdOk = New Command(AddressOf Ok) + End If + Return m_cmdOk + End Get + End Property + + Public Sub Ok() + RaiseEvent m_CloseWindow(True) + End Sub + +#End Region ' Ok + +#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() + Configuration.CreatePrintPDF(Map.refMainMenuVM.SelPage, False) + End Sub + +#End Region ' PrintPDF + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml new file mode 100644 index 00000000..803c8dde --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml.vb new file mode 100644 index 00000000..e3f5b133 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/OnlyProdStatisticsTimePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdStatisticsTimePanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml new file mode 100644 index 00000000..fff7b34a --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml.vb new file mode 100644 index 00000000..07535ebb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class StatisticsTimePanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb new file mode 100644 index 00000000..63246e81 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsTimePanel/StatisticsTimePanelVM.vb @@ -0,0 +1,82 @@ +Imports EgtBEAMWALL.Core +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class StatisticsTimePanelVM + Inherits VMBase + +#Region "FIELDS & PROPERTIES" + + Private m_ViewPage_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property ViewPage_Visibility As Visibility + Get + If Map.refMainMenuVM.SelPage = Pages.VIEW Then + Return Visibility.Visible + Else + Return m_ViewPage_Visibility + End If + End Get + End Property + Friend Sub SetViewPage_Visibility(value As Visibility) + m_ViewPage_Visibility = value + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + End Sub + + Private m_MachiningPage_Visibility As Visibility = Visibility.Collapsed + Public ReadOnly Property MachiningPage_Visibility As Visibility + Get + If Map.refMainMenuVM.SelPage = Pages.MACHINING Then + Return Visibility.Visible + Else + Return m_MachiningPage_Visibility + End If + End Get + End Property + Friend Sub SetMachiningPage_Visibility(value As Visibility) + m_MachiningPage_Visibility = value + NotifyPropertyChanged(NameOf(MachiningPage_Visibility)) + End Sub + +#Region "ToolTip" + + Public ReadOnly Property TotalTime_ToolTip As String + Get + Return EgtMsg(61978) + End Get + End Property + + Public ReadOnly Property DoneTime_ToolTip As String + Get + Return EgtMsg(61979) + End Get + End Property + + Public ReadOnly Property RemainingTime_ToolTip As String + Get + Return EgtMsg(61980) + End Get + End Property + +#End Region ' ToolTip + +#End Region ' Fields & Properties + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefStatisticsTimePanelVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Sub SetStatisticsTimePanel_Visibility() + NotifyPropertyChanged(NameOf(ViewPage_Visibility)) + NotifyPropertyChanged(NameOf(MachiningPage_Visibility)) + End Sub + +#End Region ' METHODS + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml b/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml new file mode 100644 index 00000000..f54e5d26 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml @@ -0,0 +1,20 @@ + + + + + diff --git a/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml.vb b/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml.vb new file mode 100644 index 00000000..97564222 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsWnd/OptimizerStatisticsWndV.xaml.vb @@ -0,0 +1,20 @@ +Public Class OptimizerStatisticsWndV + + Private WithEvents m_StatisticsVM As StatisticsVM + + Sub New(Owner As Window, StatisticsVM As StatisticsVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + Me.DataContext = StatisticsVM + Me.Tag = Map.refProjectVM + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_StatisticsVM = StatisticsVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_StatisticsVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml b/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml new file mode 100644 index 00000000..f2e6864d --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml @@ -0,0 +1,22 @@ + + + + + + diff --git a/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml.vb b/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml.vb new file mode 100644 index 00000000..cf214b49 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatisticsWnd/StatisticsWndV.xaml.vb @@ -0,0 +1,20 @@ +Public Class StatisticsWndV + + Private WithEvents m_StatisticsVM As StatisticsVM + + Sub New(Owner As Window, StatisticsVM As StatisticsVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + ' Add any initialization after the InitializeComponent() call. + Me.DataContext = StatisticsVM + Me.Tag = Map.refProjectVM.BTLStructureVM + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_StatisticsVM = StatisticsVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_StatisticsVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatusBar/MyStatusBarVM.vb b/EgtBEAMWALL.Optimizer/StatusBar/MyStatusBarVM.vb new file mode 100644 index 00000000..7970c6d4 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatusBar/MyStatusBarVM.vb @@ -0,0 +1,116 @@ +Imports System.Runtime.InteropServices +Imports System.Threading +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MyStatusBarVM + Inherits EgtWPFLib5.StatusBarVM + + ' Funzioni di callback per output in interfaccia da LUA + Private m_ProcEventsCallback As New ProcessEventsCallback(AddressOf ProcessEvents) + Private m_OutTextCallback As New OutTextCallback(AddressOf OutText) + + Private m_bStopProgress As Boolean + Friend ReadOnly Property bStopProgress As Boolean + Get + Return m_bStopProgress + End Get + End Property + + Public ReadOnly Property CurrMachine As String + Get + Return If(Not IsNothing(Map.refMachinePanelVM.SelectedMachine), Map.refMachinePanelVM.SelectedMachine.Name, "") + End Get + End Property + + ' Definizione comandi + Private m_cmdStopProgress As ICommand + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefMyStatusBarVM(Me) + ' Installo funzione gestione eventi per lua + EgtSetProcessEvents(m_ProcEventsCallback) + ' Installo funzione output testo su status per lua + EgtSetOutText(m_OutTextCallback) + End Sub + + Friend Sub ResetStopProgress() + m_bStopProgress = False + End Sub + + Public Function OutText(ByRef psText As IntPtr) As Boolean + ' Assegno stringa + OutputMessage = (Marshal.PtrToStringUni(psText)) + ' Costringo ad aggiornare + UpdateUI() + Return True + End Function + + Private Function ProcessEvents(ByVal nProg As Integer, ByVal nPause As Integer) As Integer + ' se nesting in corso + If Map.refOptimizePanelVM.m_bNestingRunning Then + ' gestisco nel nesting + Return Map.refOptimizePanelVM.ProcessEvents(nProg, nPause) + End If + ' Se previsto, imposto progress + If nProg > 0 Then SetLoadingProgress(Math.Min(nProg, 100)) + ' Costringo ad aggiornare + UpdateUI() + ' Eventuale attesa + Thread.Sleep(nPause) + ' Ritorno eventuale stop + If m_bStopProgress Then + m_bStopProgress = False + Return 1 + Else + Return 0 + End If + End Function + + Friend Sub StartLoading(sMessage As String, bIsStop As Boolean) + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True) + Map.refMyStatusBarVM.SetStopProgress_IsActive(bIsStop) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(bIsStop) + Map.refMyStatusBarVM.SetOutputMessage(sMessage) + End Sub + + Friend Sub EndLoading(sMessage As String, Optional nMessageTime As Integer = 3) + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False) + Map.refMyStatusBarVM.SetStopProgress_IsActive(False) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False) + Map.refMyStatusBarVM.SetOutputMessage(sMessage, nMessageTime) + End Sub + + Friend Sub RefreshMachName() + NotifyPropertyChanged(NameOf(CurrMachine)) + End Sub + +#Region "COMMANDS" + +#Region "StopProgress" + + ''' + ''' Returns a command that do Exec. + ''' + Public ReadOnly Property StopProgress_Command As ICommand + Get + If m_cmdStopProgress Is Nothing Then + m_cmdStopProgress = New Command(AddressOf StopProgress) + End If + Return m_cmdStopProgress + End Get + End Property + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Sub StopProgress() + m_bStopProgress = True + End Sub + +#End Region ' StopProgress + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Optimizer/StatusBar/StatusBarV.xaml b/EgtBEAMWALL.Optimizer/StatusBar/StatusBarV.xaml new file mode 100644 index 00000000..2dd2c626 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/StatusBar/StatusBarV.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ViewPanel/OnlyProdViewPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ViewPanel/OnlyProdViewPanelV.xaml.vb new file mode 100644 index 00000000..366de359 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ViewPanel/OnlyProdViewPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdViewPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml b/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml new file mode 100644 index 00000000..cab9c958 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml.vb b/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml.vb new file mode 100644 index 00000000..d9dd0b2c --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ViewPanel/ViewPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class ViewPanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml b/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml new file mode 100644 index 00000000..d763edb8 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml @@ -0,0 +1,428 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml.vb b/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml.vb new file mode 100644 index 00000000..a80de7fb --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/OnlyProdWarehouseWndV.xaml.vb @@ -0,0 +1,19 @@ +Public Class OnlyProdWarehouseWndV + + Private WithEvents m_WarehouseWndVM As WarehouseWndVM + + Sub New(Owner As Window, WarehouseWndVM As WarehouseWndVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + Me.DataContext = WarehouseWndVM + Me.Tag = Map.refProjectVM.BTLStructureVM + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_WarehouseWndVM = WarehouseWndVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_WarehouseWndVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseHelper.vb b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseHelper.vb new file mode 100644 index 00000000..d015a618 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseHelper.vb @@ -0,0 +1,418 @@ +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Module WarehouseHelper + + Public Enum WarehouseTypes As Integer + BASIC = 1 + MEDIUM = 2 + ADVANCED = 3 + End Enum + + Public Enum RawPartDefs As Integer + NULL = 0 + EXPLICIT = 1 + FROMWAREHOUSE = 2 + End Enum + + ' funzione che restituisce il tipo di warehouse + Public Function GetWarehouseType() As WarehouseType + Return GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, 2) + End Function + + ' funzione che restituisce la path dell'ini del warehouse + Public Function GetWarehouseIniPath() As String + Dim sWarehouseIniPath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir + Select Case GetWarehouseType() + Case WarehouseType.BASIC + Return sWarehouseIniPath & "\" & WH_BASIC_INI_FILE_NAME + Case WarehouseType.MEDIUM + Return sWarehouseIniPath & "\" & WH_MEDIUM_INI_FILE_NAME + End Select + Return "" + End Function + + ' funzione che restituisce l'offset + Public Function GetOffset(Type As BWType) As Double + If Type = BWType.BEAM Then + Dim dOffset As Double = GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_OFFSET, 0, GetWarehouseIniPath()) + Return Math.Max(dOffset, CurrentMachine.dMinOffset) + Else + Return GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_OFFSET, 0, GetWarehouseIniPath()) + End If + End Function + + ' funzione che restituisce l'offset dato spessore pareti + Public Function GetWallOffsetByWidth(dHeight As Double) As Double + Dim dOffset As Double = 0 + Dim nRangeIndex As Integer = 1 + Dim sRange As String = "" + While GenInterface.GetPrivateProfileString(WRH_WALL, WRH_RANGE & nRangeIndex, "", sRange, GetWarehouseIniPath()) >= 0 AndAlso Not String.IsNullOrWhiteSpace(sRange) + Dim sRanges() As String = sRange.Split(","c) + If sRanges.Count() >= 2 Then + Dim dMaxThickness As Double = 0 + StringToDoubleAdv(sRanges(1), dMaxThickness) + If dHeight <= dMaxThickness Then + If StringToDoubleAdv(sRanges(0), dOffset) Then Return dOffset + End If + End If + nRangeIndex += 1 + End While + Return 0 + End Function + + Public Function SetOffset(Type As BWType, Offset As Double) As Boolean + Return GenInterface.WritePrivateProfileString(If(Type = BWType.BEAM, WRH_BEAM, WRH_WALL), WRH_OFFSET, Offset, GetWarehouseIniPath()) + End Function + +#Region "Beam" + + ' funzione che restituisce l'offset iniziale + Public Function GetStartOffset() As Double + Return GenInterface.GetPrivateProfileDouble(WRH_BEAM, WRH_STARTOFFSET, 0, GetWarehouseIniPath()) + End Function + + Public Function SetStartOffset(StartOffset As Double) As Boolean + Return GenInterface.WritePrivateProfileString(WRH_BEAM, WRH_STARTOFFSET, StartOffset, GetWarehouseIniPath()) + End Function + +#End Region ' Beam + +#Region "Wall" + + ' funzione che restituisce l'offset + Public Function GetKerf() As Double + Return GenInterface.GetPrivateProfileDouble(WRH_WALL, WRH_KERF, 0, GetWarehouseIniPath()) + End Function + + Public Function SetKerf(Kerf As Double) As Boolean + Return GenInterface.WritePrivateProfileString(WRH_WALL, WRH_KERF, Kerf, GetWarehouseIniPath()) + End Function + +#End Region ' Wall + + ' funzione che restituisce le dimensioni correnti + Public Function GetCurrentDimensions(Type As BWType, ByRef dW As Double, ByRef dL As Double) As Boolean + If Type = BWType.BEAM Then + Dim nCurrentL As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_CURRENT & WRH_L, 1, GetWarehouseIniPath()) + If nCurrentL <= 0 Then Return False + dL = GenInterface.GetPrivateProfileInt(WRH_BEAM, WRH_L & nCurrentL, 0, GetWarehouseIniPath()) + Return True + Else + Dim nCurrentS As Integer = EgtUILib.GenInterface.GetPrivateProfileInt(WRH_WALL, WRH_CURRENT & WRH_S, nCurrentS, GetWarehouseIniPath()) + Dim sPanelDim As String = "" + Dim sPanelDims() As String + GenInterface.GetPrivateProfileString(WRH_WALL, WRH_S & nCurrentS, "", sPanelDim, GetWarehouseIniPath()) + If String.IsNullOrWhiteSpace(sPanelDim) Then Return False + sPanelDims = sPanelDim.Split(","c) + If Not sPanelDims.Count = 2 OrElse Not StringToDoubleAdv(sPanelDims(0), dW) OrElse Not StringToDoubleAdv(sPanelDims(1), dL) Then Return False + Return True + End If + End Function + + ' funzione che restituisce la quantita' generica di grezzi + Public Function GetQuantity(Type As BWType) As Integer + Dim nQuantity As Integer = 0 + Integer.TryParse(EgtUILib.GenInterface.GetPrivateProfileDouble(If(Type = BWType.BEAM, WRH_BEAM, WRH_WALL), WRH_QUANTITY, 0, GetWarehouseIniPath()), nQuantity) + Return nQuantity + End Function + + ' funzione che restituisce la quantita' di grezzi per sezione + Public Function GetDimensionsAndQuantityBySection(Type As BWType, ByRef dW As Double, dH As Double, ByRef dL As Double, Material As String, nQuantity As Integer) As Boolean + Dim nIndex As Integer = 1 + Dim sSection As String = "" + While GenInterface.GetPrivateProfileString(If(Type = BWType.BEAM, WRH_BEAM, WRH_WALL), If(Type = BWType.BEAM, WRH_L, WRH_S) & nIndex, "", sSection, GetWarehouseIniPath()) > 0 + If String.IsNullOrWhiteSpace(sSection) Then Return False + Dim sSectionValues() As String = sSection.Split(","c) + Select Case Type + Case BWType.BEAM + If dW = sSectionValues(0) AndAlso dH = sSectionValues(1) AndAlso Material = sSectionValues(2) Then + If Not StringToDoubleAdv(sSectionValues(3), dL) Then Return False + If Not Integer.TryParse(sSectionValues(4), nQuantity) Then Return False + Return True + End If + Case BWType.WALL + If dH = sSectionValues(0) AndAlso Material = sSectionValues(1) Then + If Not StringToDoubleAdv(sSectionValues(2), dW) Then Return False + If Not StringToDoubleAdv(sSectionValues(3), dL) Then Return False + If Not Integer.TryParse(sSectionValues(4), nQuantity) Then Return False + Return True + End If + End Select + nIndex += 1 + End While + Return False + End Function + + ' funzione che restituisce la quantita' di grezzi per sezione + Public Function GetDimensionsAndQuantityForList(Type As BWType, ByRef SectionList As List(Of SectionProgress)) As Boolean + Dim nIndex As Integer = 1 + Dim sSection As String = "" + While GenInterface.GetPrivateProfileString(If(Type = BWType.BEAM, WRH_BEAM, WRH_WALL), If(Type = BWType.BEAM, WRH_L, WRH_S) & nIndex, "", sSection, GetWarehouseIniPath()) > 0 + If String.IsNullOrWhiteSpace(sSection) Then Continue While + Dim sSectionValues() As String = sSection.Split(","c) + Dim dW As Double = 0 + Dim dL As Double = 0 + Dim nQty As Integer = 0 + Dim nActive As Integer = 0 + Dim sSectionData As String = "" + GetPrivateProfileString(If(Type = BWType.BEAM, S_BEAM_LIST, S_WALL_LIST), sSectionValues(0), "", sSectionData, GetWarehouseIniPath()) + Dim SectionData() As String = sSectionData.Split(","c) + Select Case Type + Case BWType.BEAM + Dim dSectionW As Double = 0 : StringToDoubleAdv( SectionData(0), dSectionW) + Dim dSectionH As Double = 0 : StringToDoubleAdv( SectionData(1), dSectionH) + For Each SectionProgress In SectionList + If Math.Abs( SectionProgress.Section.dW - dSectionW) < 0.1 AndAlso + Math.Abs( SectionProgress.Section.dH - dSectionH) < 0.1 AndAlso SectionProgress.Section.sMaterial.Contains(SectionData(2)) Then + If Not StringToDoubleAdv(sSectionValues(1), dL) Then Continue While + If Not Integer.TryParse(sSectionValues(2), nQty) Then Continue While + If sSectionValues.Count >= 4 AndAlso Integer.TryParse(sSectionValues(3), nActive) Then + If nActive > 0 Then SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dL, nQty, nActive > 0)) + Else + SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dL, nQty, True)) + nIndex += 1 + Continue While + End If + End If + Next + Case BWType.WALL + Dim dSectionH As Double = 0 : StringToDoubleAdv( SectionData(0), dSectionH) + For Each SectionProgress In SectionList + If Math.Abs( SectionProgress.Section.dH - dSectionH) < 0.1 AndAlso SectionProgress.Section.sMaterial.Contains(SectionData(1)) Then + If Not StringToDoubleAdv(sSectionValues(1), dW) Then Continue While + If Not StringToDoubleAdv(sSectionValues(2), dL) Then Continue While + If Not Integer.TryParse(sSectionValues(3), nQty) Then Continue While + If Not Integer.TryParse(sSectionValues(4), nActive) Then Continue While + If nActive > 0 Then SectionProgress.SParamList.Add(New SParam(SectionProgress.Section, dW, dL, nQty, nActive > 0)) + End If + Next + End Select + nIndex += 1 + End While + Return True + End Function + + Public Function GetSectionList() As List(Of SParam) + Dim Sectionlist As New List(Of SParam) + Dim nIndex As Integer = 1 + Dim CurrSParam As SParam = WarehouseWndVM.GetSParamFromWarehouse(nIndex) + While Not IsNothing(CurrSParam) + Sectionlist.Add(CurrSParam) + nIndex += 1 + CurrSParam = WarehouseWndVM.GetSParamFromWarehouse(nIndex) + End While + Return Sectionlist + End Function + + ' funzione che restituisce modalita' di definizione del grezzo + Public Function GetRawPartDef() As Integer + Return GetMainPrivateProfileInt(S_NEST, K_RAWPARTDEF, 2) + End Function + + ' funzione che restituisce la validità della sezione + Public Function IsSectionValid(SectXMat As SectionXMaterial) As Boolean + Return SectXMat.dH >= 0 Or + SectXMat.dL >= 0 Or + SectXMat.dW >= 0 + End Function + + Friend Function GetLastMaterial(SectXMat As SectionXMaterial) As SParam + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + Dim ParamIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, ParamIndex, String.Empty, sSxMValue, sWarehousePath) > 0 + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim sMaterial As String = sSectXMatValues(2) + StringToLenAdv(sSectXMatValues(0), dW) + StringToLenAdv(sSectXMatValues(1), dH) + If SectXMat.dW = dW AndAlso SectXMat.dH = dH AndAlso SectXMat.sMaterial(0) = sMaterial Then + If sSectXMatValues.Length <= 3 Then Return Nothing + Dim sValue As String = "" + If EgtUILib.GetPrivateProfileString(S_BEAM, "L" & sSectXMatValues(3), String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count < 2 Then Return Nothing + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + Dim dL As Double = 0 + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sParamValues(1), dL) + If sParamValues.Count >= 3 Then Integer.TryParse(sParamValues(2), nQty) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(3), nActive) + Return New SParam(New SectionXMaterial(dW, dH, dL, sSectXMatValues(2)), dL, nQty, nActive > 0) + End If + End If + ParamIndex += 1 + End While + Else + Dim ParamIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_WALL_LIST, ParamIndex, String.Empty, sSxMValue, sWarehousePath) > 0 + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dH As Double = 0 + Dim sMaterial As String = sSectXMatValues(1) + StringToLenAdv(sSectXMatValues(0), dH) + If SectXMat.dH = dH AndAlso SectXMat.sMaterial(0) = sMaterial Then + If sSectXMatValues.Length <= 2 Then Return Nothing + Dim sValue As String = "" + If EgtUILib.GetPrivateProfileString(S_WALL, "S" & sSectXMatValues(2), String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count < 3 Then Return Nothing + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + Dim dW As Double = 0 + Dim dL As Double = 0 + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sParamValues(1), dW) + StringToLenAdv(sParamValues(2), dL) + If sParamValues.Count >= 3 Then Integer.TryParse(sParamValues(3), nQty) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(4), nActive) + Return New SParam(New SectionXMaterial(dW, dH, dL, sSectXMatValues(1)), dW, dL, nQty, nActive > 0) + End If + End If + ParamIndex += 1 + End While + End If + + Return Nothing + End Function + + Friend Sub SetLastMaterial(SectXMat As SectionXMaterial, SParam As SParam) + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' cerco sezione + Dim SectIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, SectIndex, String.Empty, sSxMValue, sWarehousePath) > 0 + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim sMaterial As String = sSectXMatValues(2) + StringToLenAdv(sSectXMatValues(0), dW) + StringToLenAdv(sSectXMatValues(1), dH) + If SectXMat.dW = dW AndAlso SectXMat.dH = dH AndAlso SectXMat.sMaterial(0) = sMaterial Then + ' recupero indice di SParam + Dim SParamIndex As Integer = 1 + Dim sValue As String = "" + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & SParamIndex, String.Empty, sValue, sWarehousePath) + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count < 2 Then Return + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + Dim dL As Double = 0 + Dim nSectIndex As Integer = sParamValues(0) + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sParamValues(1), dL) + If sParamValues.Count >= 3 Then Integer.TryParse(sParamValues(2), nQty) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(3), nActive) + Dim bActive As Boolean = nActive = 1 + If dL = SParam.dL AndAlso nQty = SParam.nQuantity AndAlso bActive = SParam.bActive Then + ' scrivo indice ultimo materiale + EgtUILib.WritePrivateProfileString(S_BEAM_LIST, SectIndex, LenToString(dW, 3) & "," & + LenToString(dH, 3) & "," & + sMaterial & "," & + SParamIndex, sWarehousePath) + End If + SParamIndex += 1 + End While + End If + SectIndex += 1 + End While + Else + ' cerco sezione + Dim SectIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_WALL_LIST, SectIndex, String.Empty, sSxMValue, sWarehousePath) > 0 + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dH As Double = 0 + Dim sMaterial As String = sSectXMatValues(1) + StringToLenAdv(sSectXMatValues(0), dH) + If SectXMat.dH = dH AndAlso SectXMat.sMaterial(0) = sMaterial Then + ' recupero indice di SParam + Dim SParamIndex As Integer = 1 + Dim sValue As String = "" + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & SParamIndex, String.Empty, sValue, sWarehousePath) + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count < 3 Then Return + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + Dim dW As Double = 0 + Dim dL As Double = 0 + Dim nSectIndex As Integer = sParamValues(0) + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sParamValues(1), dW) + StringToLenAdv(sParamValues(2), dL) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(3), nQty) + If sParamValues.Count >= 5 Then Integer.TryParse(sParamValues(4), nActive) + Dim bActive As Boolean = nActive = 1 + If dW = SParam.dW AndAlso dL = SParam.dL AndAlso nQty = SParam.nQuantity AndAlso bActive = SParam.bActive Then + ' scrivo indice ultimo materiale + EgtUILib.WritePrivateProfileString(S_WALL_LIST, SectIndex, + LenToString(dH, 3) & "," & + sMaterial & "," & + SParamIndex, sWarehousePath) + End If + SParamIndex += 1 + End While + End If + SectIndex += 1 + End While + End If + End Sub + + Friend Function GetSectIndexFromSection(Type As BWType, Section As SectionXMaterial) As Integer + Dim nIndex As Integer = 1 + Dim sSectionData As String = "" + While GetPrivateProfileString(If(Type = BWType.BEAM, S_BEAM_LIST, S_WALL_LIST), nIndex, "", sSectionData, GetWarehouseIniPath()) > 0 + If String.IsNullOrWhiteSpace(sSectionData) Then Continue While + Dim sSectionValues() As String = sSectionData.Split(","c) + Select Case Type + Case BWType.BEAM + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim sMaterial As String = sSectionValues(2) + StringToLenAdv(sSectionValues(0), dW) + StringToLenAdv(sSectionValues(1), dH) + If Section.dW = dW AndAlso Section.dH = dH AndAlso Section.sMaterial(0) = sMaterial Then + ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + Return nIndex + End If + Case BWType.WALL + Dim dH As Double = 0 + Dim sMaterial As String = sSectionValues(1) + StringToLenAdv(sSectionValues(0), dH) + If Section.dH = dH AndAlso Section.sMaterial(0) = sMaterial Then + ' se l'ho trovato esco dal while, il SectXMatIndex è l'indice che cercavamo + Return nIndex + End If + End Select + nIndex += 1 + End While + Return -1 + End Function + +End Module diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml new file mode 100644 index 00000000..e1f25942 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml @@ -0,0 +1,416 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml.vb b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml.vb new file mode 100644 index 00000000..f75ddbd5 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndV.xaml.vb @@ -0,0 +1,19 @@ +Public Class WarehouseWndV + + Private WithEvents m_WarehouseWndVM As WarehouseWndVM + + Sub New(Owner As Window, WarehouseWndVM As WarehouseWndVM) + MyBase.New(Owner) + ' This call is required by the designer. + InitializeComponent() + Me.DataContext = WarehouseWndVM + Me.Tag = Map.refProjectVM.BTLStructureVM + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_WarehouseWndVM = WarehouseWndVM + End Sub + + Private Sub CloseWindow(bDialogResult As Boolean) Handles m_WarehouseWndVM.m_CloseWindow + Me.DialogResult = bDialogResult + End Sub + +End Class diff --git a/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndVM.vb b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndVM.vb new file mode 100644 index 00000000..be039aaf --- /dev/null +++ b/EgtBEAMWALL.Optimizer/WarehouseWnd/WarehouseWndVM.vb @@ -0,0 +1,1586 @@ +Imports EgtWPFLib5 +Imports EgtUILib +Imports System.Collections.ObjectModel +Imports System.Windows.Forms +Imports EgtBEAMWALL.Core + +Public Class WarehouseWndVM + Inherits VMBase + +#Region "Messages" + + Public ReadOnly Property CurrentS_Msg As String + Get + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case MachineType.BEAM + Return EgtMsg(61752) + Case MachineType.WALL + Return EgtMsg(61751) + End Select + Return Nothing + End Get + End Property + + Public ReadOnly Property StartOffset_Msg As String + Get + Return EgtMsg(61753) + End Get + End Property + + Public ReadOnly Property Kerf_Msg As String + Get + Return EgtMsg(61754) + End Get + End Property + + Public ReadOnly Property Offset_Msg As String + Get + Return EgtMsg(61755) + End Get + End Property + + Public ReadOnly Property MinThickness_Msg As String + Get + Return EgtMsg(61775) + End Get + End Property + + Public ReadOnly Property MaxThickness_Msg As String + Get + Return EgtMsg(61776) + End Get + End Property + + Public ReadOnly Property SParams_Msg As String + Get + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case MachineType.BEAM + Return EgtMsg(61757) + Case MachineType.WALL + Return EgtMsg(61756) + End Select + Return Nothing + End Get + End Property + + Public ReadOnly Property NewParam_Msg As String + Get + Return EgtMsg(61758) + End Get + End Property + + Public ReadOnly Property SectionXMaterial_Msg As String + Get + Return EgtMsg(61771) + End Get + End Property + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61759) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61760) + End Get + End Property + + Public ReadOnly Property Quantity_Msg As String + Get + Return EgtMsg(61774) + End Get + End Property + + Public ReadOnly Property OkAddParam_Msg As String + Get + Return EgtMsg(61761) + End Get + End Property + + Public ReadOnly Property Save_Msg As String + Get + Return EgtMsg(61762) + End Get + End Property + + Public ReadOnly Property Cancel_Msg As String + Get + Return EgtMsg(61763) + End Get + End Property + + Public ReadOnly Property Error_Msg As String + Get + Return EgtMsg(61764) + End Get + End Property + + Public ReadOnly Property ValueExists_Msg As String + Get + Return EgtMsg(61765) + End Get + End Property + + Public ReadOnly Property IncorrectValue_Msg As String + Get + Return EgtMsg(61766) + End Get + End Property + + Public ReadOnly Property ValuesExist_Msg As String + Get + Return EgtMsg(61767) + End Get + End Property + + Public ReadOnly Property IncorrectValues_Msg As String + Get + Return EgtMsg(61768) + End Get + End Property + + Public ReadOnly Property Attention_Msg As String + Get + Return EgtMsg(61769) + End Get + End Property + + Public ReadOnly Property RemoveCurrent_Msg As String + Get + Return EgtMsg(61770) + End Get + End Property + +#End Region ' Messages + +#Region "FIELDS & PROPERTIES" + + ' Costanti per settare la larghezza delle finestra + Private Const BASIC_WNDWIDTH As Integer = 400 + Private Const MEDIUM_WNDWIDTH As Integer = 600 + + ' Contatore dei parametri L/S rimossi in finestra per successiva rimozione dal file INI + Friend m_RemovedParamsCount As Integer = 0 + ' Contatore dei parametri Offset e Spessore Min/Max in finestra per successiva rimozione dal file INI + Friend m_RemovedWhWallParamsCount As Integer = 0 + + Protected m_SParamColumns As New ObservableCollection(Of EgtDataGridColumn) + Public Property SParamColumns As ObservableCollection(Of EgtDataGridColumn) + Get + Return m_SParamColumns + End Get + Set(value As ObservableCollection(Of EgtDataGridColumn)) + m_SParamColumns = value + End Set + End Property + + Private m_WhType As WarehouseType + Public ReadOnly Property WhType As WarehouseType + Get + Return m_WhType + End Get + End Property + + Private m_dStartOffset As Double + Public Property dStartOffset As Double + Get + Return m_dStartOffset + End Get + Set(value As Double) + m_dStartOffset = value + NotifyPropertyChanged(NameOf(dStartOffset)) + End Set + End Property + + Private m_dKerf As Double + Public Property dKerf As Double + Get + Return m_dKerf + End Get + Set(value As Double) + m_dKerf = value + NotifyPropertyChanged(NameOf(dKerf)) + End Set + End Property + + Private m_dOffset As Double + Public Property dOffset As Double + Get + Return m_dOffset + End Get + Set(value As Double) + If value >= CurrentMachine.dMinOffset Then + m_dOffset = value + Else + m_dOffset = CurrentMachine.dMinOffset + End If + NotifyPropertyChanged(NameOf(dOffset)) + End Set + End Property + + Private m_WhWallParamList As New ObservableCollection(Of WhWallParam) + Public Property WhWallParamList As ObservableCollection(Of WhWallParam) + Get + Return m_WhWallParamList + End Get + Set(value As ObservableCollection(Of WhWallParam)) + m_WhWallParamList = value + NotifyPropertyChanged(NameOf(WhWallParamList)) + End Set + End Property + + Private m_nQuantity As Integer + Public Property nQuantity As Integer + Get + Return m_nQuantity + End Get + Set(value As Integer) + m_nQuantity = value + NotifyPropertyChanged(NameOf(nQuantity)) + End Set + End Property + + Private m_SelCurrentS As SParam + Public Property SelCurrentS As SParam + Get + Return m_SelCurrentS + End Get + Set(value As SParam) + m_SelCurrentS = value + End Set + End Property + + Private m_SParamList_View As CollectionView = Nothing + Private m_SParamList As New ObservableCollection(Of SParam) + Public Property SParamList As ObservableCollection(Of SParam) + Get + Return m_SParamList + End Get + Set(value As ObservableCollection(Of SParam)) + m_SParamList = value + End Set + End Property + + Private m_SectionXMaterialList_View As CollectionView = Nothing + Private m_SectionXMaterialList As New ObservableCollection(Of SectionXMaterial) + Public Property SectionXMaterialList As ObservableCollection(Of SectionXMaterial) + Get + Return m_SectionXMaterialList + End Get + Set(value As ObservableCollection(Of SectionXMaterial)) + m_SectionXMaterialList = value + End Set + End Property + + Private m_SelSParam As SParam + Public Property SelSParam As SParam + Get + Return m_SelSParam + End Get + Set(value As SParam) + m_SelSParam = value + End Set + End Property + + Private m_sNewW As String + Public Property sNewW As String + Get + Return m_sNewW + End Get + Set(value As String) + m_sNewW = value + NotifyPropertyChanged(NameOf(sNewW)) + End Set + End Property + + Private m_sNewL As String + Public Property sNewL As String + Get + Return m_sNewL + End Get + Set(value As String) + m_sNewL = value + NotifyPropertyChanged(NameOf(sNewL)) + End Set + End Property + + Private m_StartOffset_Visibility As Visibility = Visibility.Collapsed + Public Property StartOffset_Visibility As Visibility + Get + Return m_StartOffset_Visibility + End Get + Set(value As Visibility) + m_StartOffset_Visibility = value + NotifyPropertyChanged(NameOf(StartOffset_Visibility)) + End Set + End Property + + Private m_Kerf_Visibility As Visibility = Visibility.Collapsed + Public Property Kerf_Visibility As Visibility + Get + Return m_Kerf_Visibility + End Get + Set(value As Visibility) + m_Kerf_Visibility = value + NotifyPropertyChanged(NameOf(Kerf_Visibility)) + End Set + End Property + + Private m_Offset_Visibility As Visibility = Visibility.Collapsed + Public Property Offset_Visibility As Visibility + Get + Return m_Offset_Visibility + End Get + Set(value As Visibility) + m_Offset_Visibility = value + NotifyPropertyChanged(NameOf(Offset_Visibility)) + End Set + End Property + + Private m_Basic_Visibility As Visibility = Visibility.Collapsed + Public Property Basic_Visibility As Visibility + Get + Return m_Basic_Visibility + End Get + Set(value As Visibility) + m_Basic_Visibility = value + NotifyPropertyChanged(NameOf(Basic_Visibility)) + End Set + End Property + + Private m_Medium_Visibility As Visibility = Visibility.Collapsed + Public Property Medium_Visibility As Visibility + Get + Return m_Medium_Visibility + End Get + Set(value As Visibility) + m_Medium_Visibility = value + NotifyPropertyChanged(NameOf(Medium_Visibility)) + End Set + End Property + + Private m_MediumWall_Visibility As Visibility = Visibility.Collapsed + Public Property MediumWall_Visibility As Visibility + Get + Return m_MediumWall_Visibility + End Get + Set(value As Visibility) + m_MediumWall_Visibility = value + NotifyPropertyChanged(NameOf(MediumWall_Visibility)) + End Set + End Property + + Private m_AddRemoveBtns_Visibility As Visibility = Visibility.Collapsed + Public Property AddRemoveBtns_Visibility As Visibility + Get + Return m_AddRemoveBtns_Visibility + End Get + Set(value As Visibility) + m_AddRemoveBtns_Visibility = value + NotifyPropertyChanged(NameOf(AddRemoveBtns_Visibility)) + End Set + End Property + + Private m_NewWallParam_Visibility As Visibility = Visibility.Collapsed + Public Property NewWallParam_Visibility As Visibility + Get + Return m_NewWallParam_Visibility + End Get + Set(value As Visibility) + m_NewWallParam_Visibility = value + NotifyPropertyChanged(NameOf(NewWallParam_Visibility)) + End Set + End Property + + Private m_NewBeamParam_Visibility As Visibility = Visibility.Collapsed + Public Property NewBeamParam_Visibility As Visibility + Get + Return m_NewBeamParam_Visibility + End Get + Set(value As Visibility) + m_NewBeamParam_Visibility = value + NotifyPropertyChanged(NameOf(NewBeamParam_Visibility)) + End Set + End Property + + Private m_WarehouseWnd_Width As Integer + Public Property WarehouseWnd_Width As Integer + Get + Return m_WarehouseWnd_Width + End Get + Set(value As Integer) + m_WarehouseWnd_Width = value + NotifyPropertyChanged(NameOf(WarehouseWnd_Width)) + End Set + End Property + + Friend Event m_CloseWindow(bDialogResult As Boolean) + + ' Definizione comandi + Private m_cmdSave As ICommand + Private m_cmdCancel As ICommand + Private m_cmdAddParam As ICommand + Private m_cmdOkAddParam As ICommand + Private m_cmdCancelAddParam As ICommand + Private m_cmdRemoveParam As ICommand + Private m_cmdAddMediumParam As ICommand + Private m_cmdRemoveMediumParam As ICommand + Private m_cmdAddWhWallParam As ICommand + Private m_cmdRemoveWhWallParam As ICommand + +#End Region ' FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefWarehouseWndVM(Me) + + ' setto il tipo in base alla macchina selezionata come macchina corrente + Dim nMachType As MachineType = Map.refProjectVM.BTLStructureVM.nPROJTYPE + SectionXMaterial.SetType(nMachType) + + ' carico le colonne della datagrid + LoadColumns(nMachType) + + Dim sValue As String = String.Empty + Dim dValue As Double = 0 + Dim ParamIndex As Integer = 1 + m_WhType = GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, 2) + + Select Case WhType + Case WarehouseType.BASIC + + WarehouseWnd_Width = BASIC_WNDWIDTH + Basic_Visibility = Visibility.Visible + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + StartOffset_Visibility = Visibility.Visible + Offset_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_BEAM, K_STARTOFFSET, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dStartOffset) + EgtUILib.GetPrivateProfileString(S_BEAM, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dOffset) + EgtUILib.GetPrivateProfileString(S_BEAM, K_QUANTITY, String.Empty, sValue, sWarehousePath) + Integer.TryParse(sValue, nQuantity) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) + SParamList.Add(GetSParamFromWarehouse(ParamIndex)) + ParamIndex += 1 + End While + + EgtUILib.GetPrivateProfileString(S_BEAM, K_CURRENTL, String.Empty, sValue, sWarehousePath) + SelCurrentS = If(CInt(sValue) > 0 AndAlso CInt(sValue) <= SParamList.Count, SParamList(CInt(sValue) - 1), Nothing) + + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Kerf_Visibility = Visibility.Visible + Offset_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_WALL, K_KERF, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dKerf) + EgtUILib.GetPrivateProfileString(S_WALL, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dOffset) + EgtUILib.GetPrivateProfileString(S_WALL, K_QUANTITY, String.Empty, sValue, sWarehousePath) + Integer.TryParse(sValue, nQuantity) + + SParamList = New ObservableCollection(Of SParam) + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) + SParamList.Add(GetSParamFromWarehouse(ParamIndex)) + ParamIndex += 1 + End While + + EgtUILib.GetPrivateProfileString(S_WALL, K_CURRENTS, String.Empty, sValue, sWarehousePath) + SelCurrentS = If(CInt(sValue) > 0 AndAlso CInt(sValue) <= SParamList.Count, SParamList(CInt(sValue) - 1), Nothing) + + End If + AddRemoveBtns_Visibility = Visibility.Visible + + Case WarehouseType.MEDIUM + + WarehouseWnd_Width = MEDIUM_WNDWIDTH + Medium_Visibility = Visibility.Visible + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + StartOffset_Visibility = Visibility.Visible + Offset_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_BEAM, K_STARTOFFSET, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dStartOffset) + EgtUILib.GetPrivateProfileString(S_BEAM, K_OFFSET, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dOffset) + + SParamList = New ObservableCollection(Of SParam) + SectionXMaterialList = New ObservableCollection(Of SectionXMaterial)(GetSectionXMaterialsFromWarehouse()) + While EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) + Dim SParam = GetSParamFromWarehouse(ParamIndex) + If Not IsNothing(SParam) Then + SParamList.Add(SParam) + End If + ParamIndex += 1 + End While + + ' per ogni SParam seleziono il SectionXMaterial corrispondente dalla lista della Warehouse + For Each SParam In SParamList + Dim i As Integer = 0 + For Each SectXMat In SectionXMaterialList + If SectXMat.sSectionXMaterial = SParam.SectXMat.sSectionXMaterial Then + SParam.nSelSectionXMaterial = i + End If + i += 1 + Next + Next + + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + Kerf_Visibility = Visibility.Visible + Offset_Visibility = Visibility.Collapsed + MediumWall_Visibility = Visibility.Visible + + EgtUILib.GetPrivateProfileString(S_WALL, K_KERF, String.Empty, sValue, sWarehousePath) + StringToLenAdv(sValue, dKerf) + + ' carico la lista degli Spessori Min/Max e Offset compresi tra di essi + While EgtUILib.GetPrivateProfileString(S_WALL, K_RANGE & ParamIndex, String.Empty, sValue, sWarehousePath) + WhWallParamList.Add(GetRangeParamFromWarehouse(ParamIndex)) + ParamIndex += 1 + End While + + SParamList = New ObservableCollection(Of SParam) + SectionXMaterialList = New ObservableCollection(Of SectionXMaterial)(GetSectionXMaterialsFromWarehouse()) + ParamIndex = 1 + While EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) + Dim SParamItem As SParam = GetSParamFromWarehouse(ParamIndex) + If Not IsNothing(SParamItem) Then + SParamList.Add(SParamItem) + End If + ParamIndex += 1 + End While + + ' per ogni SParam seleziono il SectionXMaterial corrispondente dalla lista della Warehouse + For Each SParam In SParamList + Dim i As Integer = 0 + For Each SectXMat In SectionXMaterialList + If SectXMat.sSectionXMaterial = SParam.SectXMat.sSectionXMaterial Then + SParam.nSelSectionXMaterial = i + End If + i += 1 + Next + Next + + End If + + Case WarehouseType.ADVANCED + + ' CASO NON ANCORA PRESENTE + + End Select + ' riduco lista SecXMat a solo quelli presenti nel progetto corrente + m_SectionXMaterialList_View = CollectionViewSource.GetDefaultView(m_SectionXMaterialList) + m_SectionXMaterialList_View.Filter = AddressOf SectionXMaterialFilter + ' riduco lista SParam a solo quelli che utilizzano SecXMat presenti nel progetto corrente + m_SParamList_View = CollectionViewSource.GetDefaultView(m_SParamList) + m_SParamList_View.Filter = AddressOf SParamFilter + + End Sub + + Private Function SectionXMaterialFilter(SectionXMaterial As Object) As Boolean + Dim CurrSectionXMaterial As SectionXMaterial = DirectCast(SectionXMaterial, SectionXMaterial) + Return Map.refProjectVM.BTLStructureVM.SectionList.Contains(CurrSectionXMaterial) + End Function + + Private Function SParamFilter(SParam As Object) As Boolean + Dim CurrSParam As SParam = DirectCast(SParam, SParam) + Return IsNothing(CurrSParam.SectXMat) OrElse Map.refProjectVM.BTLStructureVM.SectionList.Contains(CurrSParam.SectXMat) + End Function + +#End Region ' CONSTRUCTOR + +#Region "COMMANDS" + +#Region "Save" + + Public ReadOnly Property Save_Command As ICommand + Get + If m_cmdSave Is Nothing Then + m_cmdSave = New Command(AddressOf Save) + End If + Return m_cmdSave + End Get + End Property + + Public Sub Save() + ' Scrivo i valori nell'INI + Dim ParamIndex = 1 + Select Case WhType + Case WarehouseType.BASIC + + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' Verifico che i valori siano tutti > 0 + If dStartOffset <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_BEAM, K_CURRENTL, SParamList.IndexOf(SelCurrentS) + 1, sWarehousePath) + WritePrivateProfileString(S_BEAM, K_STARTOFFSET, LenToString(dStartOffset, 3), sWarehousePath) + WritePrivateProfileString(S_BEAM, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + WritePrivateProfileString(S_BEAM, K_QUANTITY, nQuantity, sWarehousePath) + For Each SPItem In SParamList + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, SParamList(ParamIndex - 1).sValue, sWarehousePath) + ParamIndex += 1 + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_BEAM, K_L & Index, Nothing, sWarehousePath) + Next + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' Verifico che i valori siano tutti > 0 + If dKerf <= 0 OrElse dOffset <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_WALL, K_CURRENTS, SParamList.IndexOf(SelCurrentS) + 1, sWarehousePath) + WritePrivateProfileString(S_WALL, K_KERF, LenToString(dKerf, 3), sWarehousePath) + WritePrivateProfileString(S_WALL, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + WritePrivateProfileString(S_WALL, K_QUANTITY, nQuantity, sWarehousePath) + For Each SPItem In SParamList + WritePrivateProfileString(S_WALL, K_S & ParamIndex, SParamList(ParamIndex - 1).sValue, sWarehousePath) + ParamIndex += 1 + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_WALL, K_S & Index, Nothing, sWarehousePath) + Next + End If + Case WarehouseType.MEDIUM + + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' Verifico che i valori siano tutti > 0 + If dStartOffset < 0 OrElse dOffset < 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + For Each SPItem In SParamList + If IsNothing(SParamList(ParamIndex - 1).SectXMat) OrElse SParamList(ParamIndex - 1).dL <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ParamIndex += 1 + Next + ' Se i valori sono tutti >= 0 li scrivo nel file INI + WritePrivateProfileString(S_BEAM, K_STARTOFFSET, LenToString(dStartOffset, 3), sWarehousePath) + WritePrivateProfileString(S_BEAM, K_OFFSET, LenToString(dOffset, 3), sWarehousePath) + ParamIndex = 1 + For Each SPItem In SParamList + Dim sL As String = String.Empty + sL = LenToString(SParamList(ParamIndex - 1).dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Beam_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.BEAM, SParamList(ParamIndex - 1).SectXMat) + If SectXMatIndex > 0 Then + WritePrivateProfileString(S_BEAM, K_L & ParamIndex, + SectXMatIndex & "," & sL & "," & SParamList(ParamIndex - 1).nQuantity & "," & If(SParamList(ParamIndex - 1).bActive, 1, 0), + sWarehousePath) + ParamIndex += 1 + Else + EgtOutLog("Error in material creation, section not found!") + End If + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_BEAM, K_L & Index, Nothing, sWarehousePath) + Next + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' Verifico che i valori siano tutti > 0 + If dKerf < 0 OrElse dOffset < 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + For Each SPItem In SParamList + If IsNothing(SParamList(ParamIndex - 1).SectXMat) OrElse SParamList(ParamIndex - 1).dW <= 0 OrElse SParamList(ParamIndex - 1).dL <= 0 Then + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + Return + End If + ParamIndex += 1 + Next + ' Se i valori sono tutti > 0 li scrivo nel file INI + WritePrivateProfileString(S_WALL, K_KERF, LenToString(dKerf, 3), sWarehousePath) + ParamIndex = 1 + For Each WhWallParamtem In WhWallParamList + Dim sOffset As String = String.Empty + Dim sMaxThickness As String = String.Empty + sOffset = LenToString(WhWallParamList(ParamIndex - 1).dOffset, 3) + sMaxThickness = LenToString(WhWallParamList(ParamIndex - 1).dMaxThickness, 3) + WritePrivateProfileString(S_WALL, K_RANGE & ParamIndex, sOffset & "," & sMaxThickness, sWarehousePath) + ParamIndex += 1 + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedWhWallParamsCount + WritePrivateProfileString(S_WALL, K_RANGE & Index, Nothing, sWarehousePath) + Next + ParamIndex = 1 + For Each SPItem In SParamList + Dim sW As String = String.Empty + Dim sL As String = String.Empty + sW = LenToString(SParamList(ParamIndex - 1).dW, 3) + sL = LenToString(SParamList(ParamIndex - 1).dL, 3) + ' ricavo l'indice del SecionXMaterial dalla Wall_List + Dim SectXMatIndex As Integer = GetSectIndexFromSection(MachineType.WALL, SParamList(ParamIndex - 1).SectXMat) + If SectXMatIndex > 0 Then + WritePrivateProfileString(S_WALL, K_S & ParamIndex, + SectXMatIndex & "," & sW & "," & sL & "," & SParamList(ParamIndex - 1).nQuantity & "," & If(SParamList(ParamIndex - 1).bActive, 1, 0), + sWarehousePath) + ParamIndex += 1 + Else + EgtOutLog("Error in material creation, section not found!") + End If + Next + ' Se ci sono parametri da rimuovere li rimuovo + For Index = ParamIndex To ParamIndex + m_RemovedParamsCount + WritePrivateProfileString(S_WALL, K_S & Index, Nothing, sWarehousePath) + Next + End If + + Case WarehouseType.ADVANCED + + ' CASO NON ANCORA PRESENTE + + End Select + + RaiseEvent m_CloseWindow(True) + End Sub + +#End Region ' Save + +#Region "Cancel" + + Public ReadOnly Property Cancel_Command As ICommand + Get + If m_cmdCancel Is Nothing Then + m_cmdCancel = New Command(AddressOf Cancel) + End If + Return m_cmdCancel + End Get + End Property + + Public Sub Cancel() + RaiseEvent m_CloseWindow(True) + End Sub + +#End Region ' Cancel + +#Region "AddParam" + + Public ReadOnly Property AddParam_Command As ICommand + Get + If m_cmdAddParam Is Nothing Then + m_cmdAddParam = New Command(AddressOf AddParam) + End If + Return m_cmdAddParam + End Get + End Property + + Public Sub AddParam() + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case MachineType.BEAM + NewBeamParam_Visibility = Visibility.Visible + Case MachineType.WALL + NewWallParam_Visibility = Visibility.Visible + End Select + End Sub + +#End Region ' AddParam + +#Region "OkAddParam" + + Public ReadOnly Property OkAddParam_Command As ICommand + Get + If m_cmdOkAddParam Is Nothing Then + m_cmdOkAddParam = New Command(AddressOf OkAddParam) + End If + Return m_cmdOkAddParam + End Get + End Property + + Public Sub OkAddParam() + Dim dWValue As Double = 0 + Dim dLValue As Double = 0 + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case MachineType.BEAM + If Not IsNothing(sNewL) Then StringToLenAdv(sNewL, dLValue, True) + If dLValue > 0 Then + ' controllo il valore immesso non sia già presente + Dim bExist As Boolean = False + For Each SPItem In SParamList + If SPItem.dL = dLValue Then + bExist = True + Exit For + End If + Next + If bExist Then + MessageBox.Show(ValueExists_Msg, Error_Msg) + Else + SParamList.Add(New SParam(dLValue)) + sNewL = Nothing + NewBeamParam_Visibility = Visibility.Collapsed + End If + Else + MessageBox.Show(IncorrectValue_Msg, Error_Msg) + End If + Case MachineType.WALL + If Not IsNothing(sNewW) Then StringToLenAdv(sNewW, dWValue, True) + If Not IsNothing(sNewL) Then StringToLenAdv(sNewL, dLValue, True) + If dWValue > 0 AndAlso dLValue > 0 Then + ' controllo che la coppia di valori immessa non sia già presente + Dim bExist As Boolean = False + For Each SPItem In SParamList + If SPItem.dW = dWValue And SPItem.dL = dLValue Then + bExist = True + Exit For + End If + Next + If bExist Then + MessageBox.Show(ValuesExist_Msg, Error_Msg) + Else + SParamList.Add(New SParam(dWValue, dLValue)) + sNewW = Nothing + sNewL = Nothing + NewWallParam_Visibility = Visibility.Collapsed + End If + Else + MessageBox.Show(IncorrectValues_Msg, Error_Msg) + End If + End Select + End Sub + +#End Region ' OkAddParam + +#Region "CancelAddParam" + + Public ReadOnly Property CancelAddParam_Command As ICommand + Get + If m_cmdCancelAddParam Is Nothing Then + m_cmdCancelAddParam = New Command(AddressOf CancelAddParam) + End If + Return m_cmdCancelAddParam + End Get + End Property + + Public Sub CancelAddParam() + sNewW = Nothing + sNewL = Nothing + NewBeamParam_Visibility = Visibility.Collapsed + NewWallParam_Visibility = Visibility.Collapsed + End Sub + +#End Region ' CancelAddParam + +#Region "RemoveParam" + + Public ReadOnly Property RemoveParam_Command As ICommand + Get + If m_cmdRemoveParam Is Nothing Then + m_cmdRemoveParam = New Command(AddressOf RemoveParam) + End If + Return m_cmdRemoveParam + End Get + End Property + + Public Sub RemoveParam() + If Not IsNothing(SelSParam) Then + If SelSParam.Equals(SelCurrentS) Then + If MessageBox.Show(Application.Current.MainWindow, RemoveCurrent_Msg, Attention_Msg, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then + SParamList.Remove(SelSParam) + m_RemovedParamsCount += 1 + If SParamList.Count > 0 Then + SelCurrentS = SParamList(0) + NotifyPropertyChanged(NameOf(SelCurrentS)) + End If + End If + Return + End If + SParamList.Remove(SelSParam) + m_RemovedParamsCount += 1 + End If + End Sub + +#End Region ' RemoveParam + +#Region "AddMediumParam" + + Public ReadOnly Property AddMediumParam_Command As ICommand + Get + If m_cmdAddMediumParam Is Nothing Then + m_cmdAddMediumParam = New Command(AddressOf AddMediumParam) + End If + Return m_cmdAddMediumParam + End Get + End Property + + Public Sub AddMediumParam() + Dim nQuantity As Integer = GetMainPrivateProfileInt(S_WAREHOUSE, K_DEFAULTQUANTITY, 1) + Dim NewSParam As SParam = Nothing + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + NewSParam = New SParam(Nothing, 0, nQuantity, True) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + NewSParam = New SParam(Nothing, 0, 0, nQuantity, True) + End If + ' setto il valore selezionato della CmBx al primo elemento della lista e assegno NewSParam alla lista degli SParam + If Not IsNothing(NewSParam) Then + NewSParam.nSelSectionXMaterial = -1 + SParamList.Add(NewSParam) + m_SelSParam = NewSParam + NotifyPropertyChanged(NameOf(SelSParam)) + End If + End Sub + +#End Region ' AddMediumParam + +#Region "RemoveMediumParam" + + Public ReadOnly Property RemoveMediumParam_Command As ICommand + Get + If m_cmdRemoveMediumParam Is Nothing Then + m_cmdRemoveMediumParam = New Command(AddressOf RemoveMediumParam) + End If + Return m_cmdRemoveMediumParam + End Get + End Property + + Public Sub RemoveMediumParam() + SParamList.Remove(SelSParam) + m_RemovedParamsCount += 1 + End Sub + +#End Region ' RemoveMediumParam + +#Region "AddWhWallParam" + + Public ReadOnly Property AddWhWallParam_Command As ICommand + Get + If m_cmdAddWhWallParam Is Nothing Then + m_cmdAddWhWallParam = New Command(AddressOf AddWhWallParam) + End If + Return m_cmdAddWhWallParam + End Get + End Property + + Public Sub AddWhWallParam() + If WhWallParamList.Count > 0 Then + If WhWallParamList.Last().dMaxThickness > WhWallParamList.Last().dMinThickness Then + WhWallParamList.Add(New WhWallParam(0, CurrentMachine.dMaxRawH)) + Else + System.Windows.MessageBox.Show(EgtMsg(61777), "", MessageBoxButton.OK, MessageBoxImage.Warning) + End If + Else + WhWallParamList.Add(New WhWallParam(0, CurrentMachine.dMaxRawH)) + End If + End Sub + +#End Region ' AddWhWallParam + +#Region "RemoveWhWallParam" + + Public ReadOnly Property RemoveWhWallParam_Command As ICommand + Get + If m_cmdRemoveWhWallParam Is Nothing Then + m_cmdRemoveWhWallParam = New Command(AddressOf RemoveWhWallParam) + End If + Return m_cmdRemoveWhWallParam + End Get + End Property + + Public Sub RemoveWhWallParam() + If WhWallParamList.Count > 0 Then + WhWallParamList.Remove(WhWallParamList.Last()) + m_RemovedWhWallParamsCount += 1 + End If + End Sub + +#End Region ' RemoveWhWallParam + +#End Region ' COMMANDS + +#Region "METHODS" + + Protected Sub LoadColumns(ProjectType As BWType) + If ProjectType = BWType.BEAM Then + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_SPARAMLIST_BEAM, SParamColumns) + ElseIf ProjectType = BWType.WALL Then + ' carico le colonne della datagrid + GetPrivateProfileColumns(S_SPARAMLIST_WALL, SParamColumns) + End If + ' aggiorno la visibilità delle colonne + For Each col In SParamColumns + col.ColumnVisibility = If(col.Visible, Visibility.Visible, Visibility.Collapsed) + Next + End Sub + + Public Shared Sub CheckExistingSectionXMaterial() + Dim NewSectXMatList As New List(Of SectionXMaterialToBeAdded) + ' Ricavo la lista dei SectionXMaterial presenti in Warehouse + Dim WhSectXMatList As List(Of SectionXMaterial) = GetSectionXMaterialsFromWarehouse() + For Each SectionListItem In Map.refProjectVM.BTLStructureVM.SectionList + Dim Index As Integer = 0 + Dim bEqual As Boolean = False + ' Confronto l'Item di SectionList con ciascuno di quelli presenti nella Warehouse + For Each SectXMatListItem In WhSectXMatList + If SectionListItem = WhSectXMatList(Index) Then + ' Se l'Item di SectionList equivale ad uno presente nella Warehouse setto bEqual a True ed esco dal For + bEqual = True + Exit For + End If + Index += 1 + Next + ' Se l'Item di SectionList non equivale a nessuno di quelli della Warehouse lo aggiungo alla lista + If Not bEqual And IsSectionValid(SectionListItem) Then + NewSectXMatList.Add(New SectionXMaterialToBeAdded(SectionListItem)) + End If + Next + ' Se nel BTL importato ci sono SectionXMaterial non presenti nell'INI della Warehouse mostro il dialog per la gestione di questi + If NewSectXMatList.Count > 0 Then + Dim AddSectionXMaterialWnd As New AddSectionXMaterialWndV(Application.Current.MainWindow, New AddSectionXMaterialWndVM(NewSectXMatList)) + AddSectionXMaterialWnd.ShowDialog() + End If + End Sub + + Public Shared Sub UpdateSectionXMaterial() + ' aggiungo tutte le sezioni al magazzino (verifica se esiste gia' viene fatta all'interno della funzione) + For Each SectionItem In Map.refProjectVM.BTLStructureVM.SectionList + If SectionItem.dH <> -1 Then + AddSectionXMaterialInWarehouse(SectionItem) + End If + Next + End Sub + + Public Shared Function GetSectionXMaterialsFromWarehouse() As List(Of SectionXMaterial) + Dim SectXMatList As New List(Of SectionXMaterial) + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' ricavo SectionXMaterial tramite Beam_List + Dim sSectXMatIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, sSectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + StringToLenAdv(sSectXMatValues(0), dW) + StringToLenAdv(sSectXMatValues(1), dH) + If Not SectXMatList.Any(Function(x) x.dW = dW AndAlso x.dH = dH AndAlso x.sMaterial(0) = sSectXMatValues(2)) Then + SectXMatList.Add(New SectionXMaterial(dW, dH, 0, sSectXMatValues(2))) + End If + sSectXMatIndex += 1 + End While + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' ricavo SectionXMaterial tramite Wall_List + Dim sSectXMatIndex As Integer = 1 + Dim sSxMValue As String = "" + While EgtUILib.GetPrivateProfileString(S_WALL_LIST, sSectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dH As Double = 0 + StringToLenAdv(sSectXMatValues(0), dH) + If Not SectXMatList.Any(Function(x) x.dH = dH AndAlso x.sMaterial(0) = sSectXMatValues(1)) Then + SectXMatList.Add(New SectionXMaterial(0, dH, 0, sSectXMatValues(1))) + End If + sSectXMatIndex += 1 + End While + End If + Return SectXMatList + End Function + + Public Shared Function AddSectionXMaterialInWarehouse(SectionXMaterial As SectionXMaterial) As Boolean + Dim SectXMatList As New List(Of SectionXMaterial) + Dim sSectXMatIndex As Integer = 1 + Dim sSxMValue As String = "" + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' ricavo SectionXMaterial tramite Beam_List + While EgtUILib.GetPrivateProfileString(S_BEAM_LIST, sSectXMatIndex, String.Empty, sSxMValue, sWarehousePath) > 0 + ' verifico se uguale + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + StringToLenAdv(sSectXMatValues(0), dW) + StringToLenAdv(sSectXMatValues(1), dH) + Dim ReadSection As New SectionXMaterial(dW, dH, 0, sSectXMatValues(2)) + If ReadSection = SectionXMaterial Then Return False + sSectXMatIndex += 1 + End While + WritePrivateProfileString(S_BEAM_LIST, sSectXMatIndex, LenToString(SectionXMaterial.dW, 3) & "," & + LenToString(SectionXMaterial.dH, 3) & "," & + SectionXMaterial.sMaterial(0), sWarehousePath) + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + ' ricavo SectionXMaterial tramite Wall_List + While EgtUILib.GetPrivateProfileString(S_WALL_LIST, sSectXMatIndex, String.Empty, sSxMValue, sWarehousePath) + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dH As Double = 0 + StringToLenAdv(sSectXMatValues(0), dH) + Dim ReadSection As New SectionXMaterial(0, dH, 0, sSectXMatValues(1)) + If ReadSection = SectionXMaterial Then Return False + sSectXMatIndex += 1 + End While + WritePrivateProfileString(S_WALL_LIST, sSectXMatIndex, LenToString(SectionXMaterial.dH, 3) & "," & + SectionXMaterial.sMaterial(0), sWarehousePath) + End If + Return True + End Function + + Public Shared Function GetSParamFromWarehouse(ParamIndex As Integer) As SParam + Dim nDefault As Integer = 2 + Dim sValue As String = String.Empty + Dim sSxMValue As String = String.Empty + Dim dValue As Double = 0 + Dim WhType As Integer = GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) + Select Case WhType + Case WarehouseType.BASIC + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_BASIC_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + If EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + StringToLenAdv(sValue, dValue) + Return New SParam(dValue) + End If + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + If EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 2 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dW As Double = 0 + Dim dL As Double = 0 + StringToLenAdv(sParamValues(0), dW) + StringToLenAdv(sParamValues(1), dL) + Return New SParam(dW, dL) + End If + End If + End If + Case WarehouseType.MEDIUM + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + If EgtUILib.GetPrivateProfileString(S_BEAM, "L" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 2 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' ricavo SectionXMaterial tramite Beam_List + If EgtUILib.GetPrivateProfileString(S_BEAM_LIST, sParamValues(0), String.Empty, sSxMValue, sWarehousePath) Then + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dW As Double = 0 + Dim dH As Double = 0 + Dim dL As Double = 0 + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sSectXMatValues(0), dW) + StringToLenAdv(sSectXMatValues(1), dH) + StringToLenAdv(sParamValues(1), dL) + If sParamValues.Count >= 3 Then Integer.TryParse(sParamValues(2), nQty) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(3), nActive) + Return New SParam(New SectionXMaterial(dW, dH, dL, sSectXMatValues(2)), dL, nQty, nActive > 0) + End If + End If + End If + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + If EgtUILib.GetPrivateProfileString(S_WALL, "S" & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 3 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' ricavo SectionXMaterial tramite Wall_List + If EgtUILib.GetPrivateProfileString(S_WALL_LIST, sParamValues(0), String.Empty, sSxMValue, sWarehousePath) Then + Dim sSectXMatValues() As String = sSxMValue.Split(","c) + ' creo parametro + Dim dH As Double = 0 + Dim dW As Double = 0 + Dim dL As Double = 0 + Dim nQty As Integer = 0 + Dim nActive As Integer = 1 + StringToLenAdv(sSectXMatValues(0), dH) + StringToLenAdv(sParamValues(1), dW) + StringToLenAdv(sParamValues(2), dL) + If sParamValues.Count >= 4 Then Integer.TryParse(sParamValues(3), nQty) + If sParamValues.Count >= 5 Then Integer.TryParse(sParamValues(4), nActive) + Return New SParam(New SectionXMaterial(dW, dH, dL, sSectXMatValues(1)), dW, dL, nQty, nActive > 0) + End If + End If + End If + End If + Case WarehouseType.ADVANCED + ' CASO NON ANCORA PRESENTE + End Select + Return Nothing + End Function + + Public Shared Function GetRangeParamFromWarehouse(ParamIndex As Integer) As WhWallParam + Dim nDefault As Integer = 2 + Dim sValue As String = String.Empty + Dim sSxMValue As String = String.Empty + Dim dValue As Double = 0 + Dim WhType As Integer = GetMainPrivateProfileInt(S_WAREHOUSE, EgtBEAMWALL.Core.ConstIni.K_TYPE, nDefault) + Select Case WhType + Case WarehouseType.BASIC + ' NON DISPONIBILE + Case WarehouseType.MEDIUM + Dim sWarehousePath As String = Map.refMainWindowVM.MainWindowM.sWarehouseDir & "\" & WH_MEDIUM_INI_FILE_NAME + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then + ' NON DISPONIBILE + ElseIf Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then + If EgtUILib.GetPrivateProfileString(S_WALL, K_RANGE & ParamIndex, String.Empty, sValue, sWarehousePath) Then + Dim sParamValues() As String = sValue.Split(","c) + ' verifico numero minimo di parametri + If sParamValues.Count >= 2 Then + ' cancello spazi + For Index = 0 To sParamValues.Count - 1 + sParamValues(Index) = sParamValues(Index).Trim() + Next + ' creo parametro + Dim dOffset As Double = 0 + Dim dMaxThickness As Double = 0 + StringToLenAdv(sParamValues(0), dOffset) + StringToLenAdv(sParamValues(1), dMaxThickness) + Return New WhWallParam(dOffset, dMaxThickness) + End If + End If + End If + Case WarehouseType.ADVANCED + ' CASO NON ANCORA PRESENTE + End Select + Return Nothing + End Function + +#End Region ' METHODS + +End Class + +Public Class SParam + Inherits VMBase + Implements IComparable + + Public ReadOnly Property W_Msg As String + Get + Return EgtMsg(61759) + End Get + End Property + + Public ReadOnly Property L_Msg As String + Get + Return EgtMsg(61760) + End Get + End Property + + Public ReadOnly Property Quantity_Msg As String + Get + Return EgtMsg(61774) + End Get + End Property + + Private m_bActive As Boolean + Public Property bActive As Boolean + Get + Return m_bActive + End Get + Set(value As Boolean) + m_bActive = value + End Set + End Property + + Private m_SectXMat As SectionXMaterial + Public Property SectXMat As SectionXMaterial + Get + Return m_SectXMat + End Get + Set(value As SectionXMaterial) + m_SectXMat = value + End Set + End Property + + Private m_dW As Double + Public Property dW As Double + Get + Return m_dW + End Get + Set(value As Double) + m_dW = value + End Set + End Property + + Private m_dL As Double + Public Property dL As Double + Get + Return m_dL + End Get + Set(value As Double) + m_dL = value + End Set + End Property + + Private m_nQuantity As Integer + Public Property nQuantity As Integer + Get + Return m_nQuantity + End Get + Set(value As Integer) + m_nQuantity = value + End Set + End Property + + Private m_nSelSectionXMaterial As Integer + Public Property nSelSectionXMaterial As Integer + Get + Return m_nSelSectionXMaterial + End Get + Set(value As Integer) + m_nSelSectionXMaterial = value + ' aggiorno SectXMat del SParam + If value < 0 Then + SectXMat = Nothing + Else + SectXMat = Map.refWarehouseWndVM.SectionXMaterialList(m_nSelSectionXMaterial) + End If + End Set + End Property + + Public ReadOnly Property sValue As String + Get + Select Case WarehouseHelper.GetWarehouseType() + Case WarehouseType.BASIC + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then Return LenToString(dL, 3) + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then Return LenToString(dW, 3) & "," & LenToString(dL, 3) + Case WarehouseType.MEDIUM + Dim sAlias As String = String.Empty + For Each sMatItem In SectXMat.sMaterial + sAlias &= sMatItem & ";" + Next + sAlias = sAlias.TrimEnd(";") + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.BEAM Then Return LenToString(SectXMat.dW, 3) & "," & LenToString(SectXMat.dH, 3) & "," & sAlias + If Map.refProjectVM.BTLStructureVM.nPROJTYPE = MachineType.WALL Then Return LenToString(SectXMat.dH, 3) & "," & sAlias + End Select + Return Nothing + End Get + End Property + + ' proprietà per il sorting del SectionXMaterial in base alla prima dimensione della sezione + Public ReadOnly Property dFirstDimension As Double + Get + If SectionXMaterial.nType = MachineType.BEAM AndAlso Not IsNothing(SectXMat) Then + Return SectXMat.dW + ElseIf SectionXMaterial.nType = MachineType.WALL AndAlso Not IsNothing(SectXMat) Then + Return SectXMat.dH + Else + Return 0 + End If + End Get + End Property + + ' proprietà per il sorting del SectionXMaterial in base alla seconda dimensione della sezione + Public ReadOnly Property dSecondDimension As Double + Get + If SectionXMaterial.nType = MachineType.BEAM AndAlso Not IsNothing(SectXMat) Then + Return SectXMat.dH + Else + Return 0 + End If + End Get + End Property + + ' proprieta' per finestra di aggiunta nuovo grezzo + Public ReadOnly Property sDimension As String + Get + If SectionXMaterial.nType = MachineType.BEAM Then + Return LenToString(dL, 3) + ElseIf SectionXMaterial.nType = MachineType.WALL Then + Return LenToString(dW, 3) & " x " & LenToString(dL, 3) + Else + Return 0 + End If + End Get + End Property + + Private m_Quantity_Visibility As Visibility = Visibility.Hidden + Public Property Quantity_Visibility As Visibility + Get + Return m_Quantity_Visibility + End Get + Set(value As Visibility) + m_Quantity_Visibility = value + End Set + End Property + + Private m_MediumW_Visibility As Visibility = Visibility.Hidden + Public Property MediumW_Visibility As Visibility + Get + Return m_MediumW_Visibility + End Get + Set(value As Visibility) + m_MediumW_Visibility = value + End Set + End Property + +#Region "For Statistics" + + Public ReadOnly Property sW As Double + Get + Select Case Map.refProjectVM.BTLStructureVM.nPROJTYPE + Case BWType.BEAM + Return SectXMat.dW + Case BWType.WALL + Return dW + Case Else + Return dW + End Select + End Get + End Property + + Public ReadOnly Property sH As Double + Get + Return SectXMat.dH + End Get + End Property + + Public ReadOnly Property sL As Double + Get + Return dL + End Get + End Property + + Public ReadOnly Property sMaterial As String + Get + Return If(IsNothing(SectXMat), "", SectXMat.sMaterial(0)) + End Get + End Property + +#End Region ' For Statistics + + Sub New(W As Double, L As Double) + m_dW = W + m_dL = L + End Sub + + Sub New(L As Double) + m_dL = L + End Sub + + Sub New(SxM As SectionXMaterial, W As Double, L As Double, Qty As Integer, Active As Boolean) + m_SectXMat = SxM + m_dW = W + m_dL = L + m_nQuantity = Qty + m_bActive = Active + MediumW_Visibility = Visibility.Visible + Quantity_Visibility = Visibility.Visible + End Sub + + Sub New(SxM As SectionXMaterial, L As Double, Qty As Integer, Active As Boolean) + m_SectXMat = SxM + m_dL = L + m_nQuantity = Qty + m_bActive = Active + Quantity_Visibility = Visibility.Visible + End Sub + + ' definizione di CompareTo per il Sort degli SParam (Materiale -> 1^ dimensione -> 2^ dimensione) + Public Function CompareTo(obj As Object) As Integer Implements IComparable.CompareTo + Dim SParamItem As SParam = DirectCast(obj, SParam) + If sMaterial.CompareTo(SParamItem.sMaterial) <> 0 Then + Return sMaterial.CompareTo(SParamItem.sMaterial) + Else + If dFirstDimension.CompareTo(SParamItem.dFirstDimension) <> 0 Then + Return dFirstDimension.CompareTo(SParamItem.dFirstDimension) + Else + Return dSecondDimension.CompareTo(SParamItem.dSecondDimension) + End If + End If + End Function + + ' proprietà usata come SortMemberPath della colonna SectionXMaterial + Public ReadOnly Property SectionXMaterialDisplayOrder As SParam + Get + Return Me + End Get + End Property + +End Class + +Public Class WhWallParam + Inherits VMBase + + Public ReadOnly Property dMinThickness As Double + Get + If Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) > 0 Then + Return Map.refWarehouseWndVM.WhWallParamList(Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) - 1).dMaxThickness + Else + Return CurrentMachine.dMinRawH + End If + End Get + End Property + + Private m_dOffset As Double + Public Property dOffset As Double + Get + Return m_dOffset + End Get + Set(value As Double) + m_dOffset = value + End Set + End Property + + Private m_dMaxThickness As Double + Public Property dMaxThickness As Double + Get + Return m_dMaxThickness + End Get + Set(value As Double) + If Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) = Map.refWarehouseWndVM.WhWallParamList.Count - 1 Then + m_dMaxThickness = CurrentMachine.dMaxRawH + NotifyPropertyChanged(NameOf(dMaxThickness)) + ElseIf value >= Map.refWarehouseWndVM.WhWallParamList(Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me)).dMinThickness And + ((Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) < Map.refWarehouseWndVM.WhWallParamList.Count - 1 AndAlso + value <= Map.refWarehouseWndVM.WhWallParamList(Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) + 1).dMaxThickness) Or + Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) = Map.refWarehouseWndVM.WhWallParamList.Count - 1) Then + m_dMaxThickness = value + If Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) < Map.refWarehouseWndVM.WhWallParamList.Count - 1 Then + Map.refWarehouseWndVM.WhWallParamList(Map.refWarehouseWndVM.WhWallParamList.IndexOf(Me) + 1).NotifyPropertyChanged(NameOf(dMinThickness)) + End If + Else + NotifyPropertyChanged(NameOf(dMaxThickness)) + End If + End Set + End Property + + Sub New(Offset As Double, MaxThickness As Double) + m_dOffset = Offset + m_dMaxThickness = MaxThickness + End Sub + +End Class + +Public Enum WarehouseType + BASIC = 1 + MEDIUM = 2 + ADVANCED = 3 +End Enum diff --git a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb index 14d73afc..544364c8 100644 --- a/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -855,6 +855,8 @@ Public Class OnlyProdManagerVM DbControllers.m_ProjController.DeleteProj(nProjId, False) End If If bOk Then + ' salvo il progetto + bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) ' inizializzo nuovo progetto PROD NewProdFromProj() End If diff --git a/EgtBEAMWALL.sln b/EgtBEAMWALL.sln index ae1080f8..977e60c3 100644 --- a/EgtBEAMWALL.sln +++ b/EgtBEAMWALL.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EgtBEAMWALL.DataLayer", "Eg EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.Core", "EgtBEAMWALL.Core\EgtBEAMWALL.Core.vbproj", "{F22835A1-83D8-4334-91BB-BAAEB9CF59B1}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.Optimizer", "EgtBEAMWALL.Optimizer\EgtBEAMWALL.Optimizer.vbproj", "{4BD87FB8-9D12-46E3-ABCB-6576415BCE9A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -42,6 +44,10 @@ Global {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x86.Build.0 = Release|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.RemoteDebug|x86.ActiveCfg = Release|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.RemoteDebug|x86.Build.0 = Release|Any CPU + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A}.Debug|x86.ActiveCfg = Debug|x86 + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A}.Debug|x86.Build.0 = Debug|x86 + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A}.Release|x86.ActiveCfg = Release|x86 + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A}.RemoteDebug|x86.ActiveCfg = Debug|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj new file mode 100644 index 00000000..a6a47463 --- /dev/null +++ b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj @@ -0,0 +1,1329 @@ + + + + + Debug + AnyCPU + {4BD87FB8-9D12-46E3-ABCB-6576415BCE9A} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + EgtBEAMWALL.Optimizer + EgtBEAMWALL.Optimizer + v4.7.2 + Custom + true + true + + + + + AnyCPU + true + full + true + true + true + bin\Debug\ + EgtBEAMWALL.Optimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + AnyCPU + pdbonly + false + false + true + false + true + bin\Release\ + EgtBEAMWALL.Optimizer.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + + ..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll + + + ..\packages\DotNetZip.1.16.0\lib\net40\DotNetZip.dll + + + ..\EgtBEAMWALL.Core\bin\Debug\EgtBEAMWALL.Core.dll + + + ..\EgtBEAMWALL.DataLayer\bin\Debug\EgtBEAMWALL.DataLayer.dll + + + ..\ExtLibs\EgtUILib.dll + + + ..\ExtLibs\EgtWPFLib5.dll + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll + + + ..\packages\Google.Protobuf.3.21.9\lib\net45\Google.Protobuf.dll + + + ..\packages\K4os.Compression.LZ4.1.3.5\lib\net462\K4os.Compression.LZ4.dll + + + ..\packages\K4os.Compression.LZ4.Streams.1.3.5\lib\net462\K4os.Compression.LZ4.Streams.dll + + + ..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + + ..\packages\PDFsharp-MigraDoc-wpf.1.50.5147\lib\net30\MigraDoc.DocumentObjectModel-wpf.dll + + + ..\packages\PDFsharp-MigraDoc-wpf.1.50.5147\lib\net30\MigraDoc.Rendering-wpf.dll + + + ..\packages\PDFsharp-MigraDoc-wpf.1.50.5147\lib\net30\MigraDoc.RtfRendering-wpf.dll + + + ..\packages\MySql.Data.8.0.21\lib\net452\MySql.Data.dll + + + ..\packages\MySql.Data.EntityFramework.8.0.21\lib\net452\MySql.Data.EntityFramework.dll + + + ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\NLog.5.0.1\lib\net46\NLog.dll + + + ..\packages\PDFsharp-MigraDoc-wpf.1.50.5147\lib\net30\PdfSharp-wpf.dll + + + ..\packages\PDFsharp-MigraDoc-wpf.1.50.5147\lib\net30\PdfSharp.Charting-wpf.dll + + + ..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll + + + ..\packages\RestSharp.111.2.0\lib\net471\RestSharp.dll + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + + + + + + + ..\packages\System.IO.Pipelines.6.0.0\lib\net461\System.IO.Pipelines.dll + + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.8.0.3\lib\net462\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + + 4.0 + + + ..\packages\MySql.Data.8.0.21\lib\net452\Ubiety.Dns.Core.dll + + + ..\..\..\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.22000.0\Windows.winmd + + + + + + + + ..\packages\MySql.Data.8.0.21\lib\net452\Zstandard.Net.dll + + + + + MSBuild:Compile + Designer + + + AboutBoxV.xaml + + + + + NewAddFeatureWndV.xaml + + + AddPartWndV.xaml + + + + OnlyProdAddPartWndV.xaml + + + AddRawPartWndV.xaml + + + + OnlyProdAddRawPartWndV.xaml + + + AddSectionXMaterialWndV.xaml + + + + Application.xaml + Code + + + NestingRunningWndV.xaml + + + + OnlyProdNestingRunningWndV.xaml + + + + + + OnlyProdProjectV.xaml + + + + OnlyProdOptimizePanelV.xaml + + + OptimizePanelV.xaml + + + + OnlyProdPartInRawPartManagerV.xaml + + + PartInRawPartManagerV.xaml + + + + PartInRawPartManagerWndV.xaml + + + OnlyProdPartManagerV.xaml + + + PartManagerV.xaml + + + + PartParametersWndV.xaml + + + + PdfViewer.xaml + + + + ProdManagerV.xaml + + + + ProdProjManagerV.xaml + + + + + + + OnlyProdProjectTypeWndV.xaml + + + ProjectTypeWndV.xaml + + + + ProjectV.xaml + + + + ProjManagerV.xaml + + + + OnlyProdRawPartManagerV.xaml + + + RawPartManagerV.xaml + + + + RawPartManagerWndV.xaml + + + + SceneHostV.xaml + + + + SetUpV.xaml + + + + OnlyProdShowBeamPanelV.xaml + + + ShowBeamPanelV.xaml + + + + OnlyProdShowPanelV.xaml + + + ShowPanelV.xaml + + + OnlyProdSpecialPanelV.xaml + + + SpecialPanelV.xaml + + + + OnlyProdStatisticsTimePanelV.xaml + + + StatisticsTimePanelV.xaml + + + + OptimizerStatisticsWndV.xaml + + + StatisticsWndV.xaml + + + OnlyProdOptimizerStatisticsV.xaml + + + OnlyProdPDFEditorV.xaml + + + OnlyProdStatisticsV.xaml + + + OptimizerStatisticsV.xaml + + + PDFEditorV.xaml + + + + + + StatisticsV.xaml + + + + + StatusBarV.xaml + + + + + ProdWndV.xaml + + + ProjWndV.xaml + + + + + + TopPanelV.xaml + + + + OnlyProdUpdateBTLWndV.xaml + + + OnlyProdUpdateOrAppendWndV.xaml + + + UpdateBTLWndV.xaml + + + + UpdateOrAppendWndV.xaml + + + + + + + Dictionary.xaml + + + + + + + + + + + + OnlyProdViewPanelV.xaml + + + ViewPanelV.xaml + + + OnlyProdWarehouseWndV.xaml + + + + WarehouseWndV.xaml + + + + + + + + + + + + + + + + + + + + + + + + + BlockedWndV.xaml + + + + BottomPanelV.xaml + + + + BTLDataWndV.xaml + + + + BTLPartManagerV.xaml + + + + OnlyProdBTLPartManagerV.xaml + + + + + + + CalcPanelV.xaml + + + + OnlyProdCalcPanelV.xaml + + + ChangeMaterialWndV.xaml + + + + ChangeParameterWndV.xaml + + + + ConfigurationPageV.xaml + + + + OnlyProdCheckVersionV.xaml + + + OnlyProdConfigurationPageV.xaml + + + + + + + FeatureListManagerV.xaml + + + + OnlyProdFeatureListManagerV.xaml + + + FeatureManagerV.xaml + + + + OnlyProdFeatureManagerV.xaml + + + FreeContourInputV.xaml + + + + OnlyProdFreeContourInputV.xaml + + + FreeContourManagerV.xaml + + + + OnlyProdFreeContourManagerV.xaml + + + InputPwdWndV.xaml + + + + OnlyProdInputPwdWndV.xaml + + + InstrumentPanelV.xaml + + + + OnlyProdInstrumentPanelV.xaml + + + BTLDataV.xaml + + + BTLPartListV.xaml + + + + + FeatureInPartInRawPartListV.xaml + + + + FeatureListV.xaml + + + + OnlyProdBTLPartListV.xaml + + + OnlyProdFeatureInPartInRawPartListV.xaml + + + OnlyProdFeatureListV.xaml + + + OnlyProdPartInRawPartListV.xaml + + + OnlyProdPParameterListV.xaml + + + OnlyProdQParameterListProdV.xaml + + + OnlyProdQParameterListV.xaml + + + OnlyProdRawPartListV.xaml + + + PartInRawPartListV.xaml + + + + PartParametersV.xaml + + + + PParameterListV.xaml + + + + + QParameterListV.xaml + + + + QParamListV.xaml + + + RawPartListV.xaml + + + + LeftPanelV.xaml + + + + OnlyProdLeftPanelV.xaml + + + + + + + MacroFeatureWndV.xaml + + + + NewMacroFeatureWnd.xaml + + + MainMenuV.xaml + + + + OnlyProdMainMenuV.xaml + + + + MainWindowV.xaml + + + + OnlyProdMainWindowV.xaml + + + MovePartInRawPartWndV.xaml + + + + OnlyProdMovePartInRawPartWndV.xaml + + + MultiCopyRawPartWndV.xaml + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/NuGetUpgradeLog.html b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/NuGetUpgradeLog.html new file mode 100644 index 00000000..81e69f1d --- /dev/null +++ b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/NuGetUpgradeLog.html @@ -0,0 +1,187 @@ + + + + + NuGetMigrationLog +

+ NuGet Migration Report - EgtBEAMWALL.Optimizer

Overview

Migration to PackageReference was completed successfully. Please build and run your solution to verify that all packages are available.
+ If you run into any problems, have feedback, questions, or concerns, please + file an issue on the NuGet GitHub repository.
+ Changed files and this report have been backed up here: + C:\EgtDev\EgtBEAMWALL\MigrationBackup\8310256a\EgtBEAMWALL.Optimizer

Packages processed

Top-level dependencies:

Package IdVersion
BouncyCastle + v1.8.5
DotNetZip + v1.16.0
EntityFramework + v6.4.4
Google.Protobuf + v3.21.9
K4os.Compression.LZ4.Streams + v1.3.5
MySql.Data.EntityFramework + v8.0.21
Newtonsoft.Json + v13.0.1
NLog + v5.0.1
PDFsharp-MigraDoc-wpf + v1.50.5147
Portable.BouncyCastle + v1.9.0
RestSharp + v111.2.0
System.IO.Pipelines + v6.0.0
System.Runtime.InteropServices.WindowsRuntime + v4.3.0
System.Runtime.WindowsRuntime.UI.Xaml + v4.6.0

Transitive dependencies:

Package IdVersion
K4os.Compression.LZ4 + v1.3.5
K4os.Hash.xxHash + v1.0.8
Microsoft.Bcl.AsyncInterfaces + v8.0.0
MySql.Data + v8.0.21
SSH.NET + v2016.1.0
System.Buffers + v4.5.1
System.Memory + v4.5.5
System.Numerics.Vectors + v4.5.0
System.Runtime.CompilerServices.Unsafe + v6.0.0
System.Runtime.WindowsRuntime + v4.6.0
System.Text.Encodings.Web + v8.0.0
System.Text.Json + v8.0.3
System.Threading.Tasks.Extensions + v4.5.4
System.ValueTuple + v4.5.0

Package compatibility issues

Description
+ No issues were found. +
\ No newline at end of file diff --git a/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/packages.config b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/packages.config new file mode 100644 index 00000000..6c36e184 --- /dev/null +++ b/MigrationBackup/8310256a/EgtBEAMWALL.Optimizer/packages.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file