diff --git a/EgtBEAMWALL.Core/Utility/MyMachine.vb b/EgtBEAMWALL.Core/Utility/MyMachine.vb index e2cd79ee..ce8712a8 100644 --- a/EgtBEAMWALL.Core/Utility/MyMachine.vb +++ b/EgtBEAMWALL.Core/Utility/MyMachine.vb @@ -1,4 +1,5 @@ -Imports System.IO +Imports System.Collections.ObjectModel +Imports System.IO Imports EgtWPFLib5 Public Class MyMachine @@ -45,4 +46,4 @@ Public Class MyMachine Return True End Function -End Class \ No newline at end of file +End Class diff --git a/EgtBEAMWALL.Optimizer/BTLDataWnd/BTLDataWndVM.vb b/EgtBEAMWALL.Optimizer/BTLDataWnd/BTLDataWndVM.vb index 7a001dbc..acb3069b 100644 --- a/EgtBEAMWALL.Optimizer/BTLDataWnd/BTLDataWndVM.vb +++ b/EgtBEAMWALL.Optimizer/BTLDataWnd/BTLDataWndVM.vb @@ -172,7 +172,7 @@ Public Class BTLDataWndVM Sub New(nProjId As Integer) ' leggo cartella dei setup delle strategie - Dim AISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim AISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(ProjectManagerVM.CurrProd.nType) Dim AISetupPaths As String() = Directory.GetFiles(AISetupDirPath) For Each AiSetup In AISetupPaths m_StrategySetupList.Add(Path.GetFileNameWithoutExtension(AiSetup)) diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb index fa6d16ad..68b88b1b 100644 --- a/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/ConfigurationPageVM.vb @@ -639,91 +639,6 @@ Public Class ConfigurationPageVM #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 @@ -736,24 +651,7 @@ Public Class ConfigurationPageVM WriteMainPrivateProfileString(S_NEST, K_PARTTIME, DoubleToString(m_PartTime, 5)) WriteMainPrivateProfileString(S_PRINTER, K_ENABLE, If(m_bPrintLabel_IsChecked, 1, 0)) 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 + Map.refMachinePanelVM.VerifyConfigPageModification() End Select End Sub @@ -1216,198 +1114,198 @@ Public Class ConfigurationPageVM End Class -Public Class MachParam - Inherits VMBase +'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 +' ' 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 +' ' 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 +' ' 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 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 +' ' 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 +' 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 +' 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 +' ' 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 +' 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 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 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 +' ' 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 +' 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 ReadOnly Property IsModified() As Boolean +' Get +' Return m_IsModifiedValue +' End Get +' End Property - Public Sub IsModifiedReset() - m_IsModifiedValue = False - End Sub +' Public Sub IsModifiedReset() +' m_IsModifiedValue = False +' End Sub -End Class +'End Class -Public Class MachTable - Inherits VMBase +'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 +' ' 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 +' 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 +' Sub New(Name As String, ParamList As ObservableCollection(Of MachParam)) +' sName = Name +' MachParamList = ParamList +' End Sub -End Class +'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 \ No newline at end of file +'' Tipo parametro nel file di configurazione Macchina +'Public Enum MachParamType As Integer +' DOUBLE_ = 1 +' STRING_ = 2 +' COMBO = 3 +' LENGTH = 4 +' CHECKBOX = 5 +'End Enum \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml index 002b3926..9fc8f221 100644 --- a/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdConfigurationPageV.xaml @@ -17,16 +17,6 @@ - - - - - - - - @@ -52,7 +42,7 @@ - + diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml new file mode 100644 index 00000000..f8809a62 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..e543003f --- /dev/null +++ b/EgtBEAMWALL.Optimizer/ConfigurationPage/OnlyProdMachine_ConfigurationPageV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdMachine_ConfigurationPageV + +End Class \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj b/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj index c7026d5b..dc931c5d 100644 --- a/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj +++ b/EgtBEAMWALL.Optimizer/EgtBEAMWALL.Optimizer.vbproj @@ -137,6 +137,9 @@ Application.xaml Code + + OnlyProdMachine_ConfigurationPageV.xaml + ForcedStrategyBTLV.xaml @@ -145,12 +148,15 @@ ForcedStrategyPanelV.xaml + + OnlyProdMachinePanelV.xaml + OnlyProdNestingRunningWndV.xaml - + OnlyProdProjectV.xaml @@ -538,6 +544,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -618,6 +628,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/EgtBEAMWALL.Optimizer/ForcedStrategyBTL/ForcedStrategyBTLVM.vb b/EgtBEAMWALL.Optimizer/ForcedStrategyBTL/ForcedStrategyBTLVM.vb index 98754208..631c247b 100644 --- a/EgtBEAMWALL.Optimizer/ForcedStrategyBTL/ForcedStrategyBTLVM.vb +++ b/EgtBEAMWALL.Optimizer/ForcedStrategyBTL/ForcedStrategyBTLVM.vb @@ -84,7 +84,7 @@ Public Class ForcedStrategyBTLVM m_StrategyList.Clear() Dim sTopologyName As String = "Feature" ' carico default - Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath() + Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath(ProjectManagerVM.CurrProd.nType) Dim sAvailableStrategiesFilePath As String = sStrategiesDirPath & "\" & AVAILABLESTRATEGYLIST_FILE & ".json" If File.Exists(sAvailableStrategiesFilePath) Then Dim sReadedFile As String = File.ReadAllText(sAvailableStrategiesFilePath) @@ -111,7 +111,7 @@ Public Class ForcedStrategyBTLVM EgtGetInfo(nBTLInfoLayerId, "AISETUP", sStrategySetupName) If Not String.IsNullOrWhiteSpace(sStrategySetupName) Then ' carico custom - Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(ProjectManagerVM.CurrProd.nType) Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sStrategySetupName & ".json" If File.Exists(sStrategyConfigurationFilePath) Then Dim sReadedFile As String = File.ReadAllText(sStrategyConfigurationFilePath) diff --git a/EgtBEAMWALL.Optimizer/ForcedStrategyPanel/ForcedStrategyPanelVM.vb b/EgtBEAMWALL.Optimizer/ForcedStrategyPanel/ForcedStrategyPanelVM.vb index abdfe854..df234960 100644 --- a/EgtBEAMWALL.Optimizer/ForcedStrategyPanel/ForcedStrategyPanelVM.vb +++ b/EgtBEAMWALL.Optimizer/ForcedStrategyPanel/ForcedStrategyPanelVM.vb @@ -84,7 +84,7 @@ Public Class ForcedStrategyPanelVM m_StrategyList.Clear() Dim sTopologyName As String = "Feature" ' carico default - Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath() + Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath(ProjectManagerVM.CurrProd.nType) Dim sAvailableStrategiesFilePath As String = sStrategiesDirPath & "\" & AVAILABLESTRATEGYLIST_FILE & ".json" If File.Exists(sAvailableStrategiesFilePath) Then Dim sReadedFile As String = File.ReadAllText(sAvailableStrategiesFilePath) @@ -111,7 +111,7 @@ Public Class ForcedStrategyPanelVM EgtGetInfo(nBTLInfoLayerId, "AISETUP", sStrategySetupName) If Not String.IsNullOrWhiteSpace(sStrategySetupName) Then ' carico custom - Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(ProjectManagerVM.CurrProd.nType) Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sStrategySetupName & ".json" If File.Exists(sStrategyConfigurationFilePath) Then Dim sReadedFile As String = File.ReadAllText(sStrategyConfigurationFilePath) diff --git a/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb index 71727b62..f6bb2b78 100644 --- a/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb +++ b/EgtBEAMWALL.Optimizer/ItemParamList/BTLPartListVM.vb @@ -267,3 +267,20 @@ Public Class BooleanToVisibilityConverter End Function End Class + +Class FractionHeightConverter + 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 Double Then Return "" + If TypeOf parameter IsNot Double Then Return "" + Dim dListBoxHeight As Double = CDbl(value) + Dim dWrapPanelHeight As Double = CDbl(parameter) + Return Math.Floor((dListBoxHeight - 40) * dWrapPanelHeight) + 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/OnlyProdBTLPartListV.xaml b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml index 1d6c91d8..367bcf5e 100644 --- a/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml +++ b/EgtBEAMWALL.Optimizer/ItemParamList/OnlyProdBTLPartListV.xaml @@ -1,12 +1,15 @@  + + 0.6 - + diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb index 5cc14f36..34ae4801 100644 --- a/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb +++ b/EgtBEAMWALL.Optimizer/MachinePanel/MachinePanelVM.vb @@ -1,4 +1,5 @@ -Imports System.IO +Imports System.Collections.ObjectModel +Imports System.IO Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 @@ -60,6 +61,12 @@ Public Class MachinePanelVM End Set End Property + Public ReadOnly Property ConfigMachTableList As ObservableCollection(Of MachTable) + Get + Return CurrentMachine.MachTableList + End Get + End Property + Private m_MachPanel_IsEnabled As Boolean = True Public Property MachPanel_IsEnabled As Boolean Get @@ -329,42 +336,118 @@ Public Class MachinePanelVM SetUpWindow.ShowDialog() End Sub + ' 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 + ' 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 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" ''' @@ -394,3 +477,199 @@ Public Class MachinePanelVM #End Region ' COMMANDS 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 \ No newline at end of file diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml b/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml new file mode 100644 index 00000000..4ac1ed55 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml.vb b/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml.vb new file mode 100644 index 00000000..b38f49c9 --- /dev/null +++ b/EgtBEAMWALL.Optimizer/MachinePanel/OnlyProdMachinePanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class OnlyProdMachinePanelV + +End Class diff --git a/EgtBEAMWALL.Optimizer/MainWindow/MainWindowM.vb b/EgtBEAMWALL.Optimizer/MainWindow/MainWindowM.vb index e61eb2c1..33c592cd 100644 --- a/EgtBEAMWALL.Optimizer/MainWindow/MainWindowM.vb +++ b/EgtBEAMWALL.Optimizer/MainWindow/MainWindowM.vb @@ -512,15 +512,13 @@ Public Class MainWindowM ''' Fuzione che recupera la cartella dove salvare il file json CustomerConfig ''' ''' - Friend Function GetAISetupDirPath() As String - ' Recupero tipo progetto - Dim nProdType As BWType = GetProdType() + Friend Function GetAISetupDirPath(StrategyType As BWType) As String ' Percorso SetUpDir Dim sAISetUpDir As String = String.Empty - If nProdType = BWType.BEAM Then - sAISetUpDir = sMachinesRoot & "\" & sMachineName & "\" & BEAM_DIR & "\" & AISETUP_DIR - Else - sAISetUpDir = sMachinesRoot & "\" & sMachineName & "\" & WALL_DIR & "\" & AISETUP_DIR + If StrategyType = BWType.BEAM Then + sAISetUpDir = sMachinesRoot & "\" & CurrentMachine.sMachineName & "\" & BEAM_DIR & "\" & AISETUP_DIR + ElseIf StrategyType = BWType.WALL Then + sAISetUpDir = sMachinesRoot & "\" & CurrentMachine.sMachineName & "\" & WALL_DIR & "\" & AISETUP_DIR End If ' Controllo se la cartella AISetup è presente If Not Directory.Exists(sAISetUpDir) Then @@ -534,12 +532,10 @@ Public Class MainWindowM ''' Funzione che recupera il percorso della cartella Strategies ''' ''' - Friend Function GetStrategiesDirPath() As String - ' Recupero tipo progetto - Dim nProdType As BWType = GetProdType() - If nProdType = BWType.BEAM Then + Friend Function GetStrategiesDirPath(StrategyType As BWType) As String + If StrategyType = BWType.BEAM Then Return sBeamRoot & "\" & STRATEGIES_DIR - ElseIf nProdType = BWType.WALL Then + ElseIf StrategyType = BWType.WALL Then Return sWallRoot & "\" & STRATEGIES_DIR End If Return String.Empty diff --git a/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerV.vb b/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerV.xaml.vb similarity index 100% rename from EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerV.vb rename to EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerV.xaml.vb diff --git a/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb b/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb index 2c7159fa..6e972285 100644 --- a/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb +++ b/EgtBEAMWALL.Optimizer/OnlyProdManager/OnlyProdManagerVM.vb @@ -173,6 +173,7 @@ Public Class OnlyProdManagerVM Private m_cmdExportProject As ICommand Private m_cmdImportProject As ICommand Private m_cmdAddProj As ICommand + Private m_cmdAddBTL As ICommand Private m_cmdGoToSupervisor As ICommand Private m_cmdShowPopUpStartBtnCmd As ICommand Private m_cmdShowPopUpSaveBtnCmd As ICommand @@ -279,31 +280,31 @@ Public Class OnlyProdManagerVM 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 + Private Function InitNewProj(ByRef nProjId As Integer, ByRef sProjectDir As String, nType As BWType, Machine As String) 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 + ' salvo dati 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 + .Machine = Machine}) + '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 @@ -408,6 +409,319 @@ Public Class OnlyProdManagerVM End If End Sub + Private Function CreateNewProd() As Boolean + ' creo proj + Dim nProjId As Integer = 0 + Dim sBTLFileName As String = "" + Dim nType As BWType = BWType.NULL + Dim sMachine As String = "" + If Not CreateNewProj(Nothing, nProjId, sBTLFileName, nType, sMachine) Then + EgtOutLog("Errore! Creazione nuovo prod fallita!") + Return False + End If + ' inizializzo nuovo progetto PROD + Dim nProdId As Integer = 0 + Dim sProdDir As String = "" + If Not InitNewProd(nProjId, nProdId, sProdDir) Then + EgtOutLog("Errore! Impossibile creare nuovo progetto!") + Return False + End If + ' setto il PType del Prod + DbControllers.m_ProdController.UpdatePType(nProdId, nType) + ' setto la Macchina associata al Prod + DbControllers.m_ProdController.UpdateMachine(nProdId, sMachine) + ' copio file importato + Dim sImportFilePath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\" & sBTLFileName + Dim sProdPath As String = sProdDir & "\" & sBTLFileName + If File.Exists(sImportFilePath) Then + Try + File.Copy(sImportFilePath, sProdPath) + Catch ex As Exception + EgtOutLog("Errore! Impossibile copiare il file importato nella cartella del progetto!") + End Try + Try + File.Delete(sImportFilePath) + Catch ex As Exception + EgtOutLog("Errore! Impossibile cancellare il file importato dalla cartella Temp!") + End Try + End If + ' salvo il progetto + Dim sProdFileName As String = sProdDir & "\" & nProdId.ToString("0000") & ".nge" + EgtSaveFile(sProdFileName, NGE.CMPTEXT) + ' resetto stato new del proj + DbControllers.m_ProjController.ResetNew(nProjId) + ' imposto currprod + SetCurrProd(nProdId) + '' imposto TempCurrProd + 'TempCurrProd = CurrProd + '' setto flag nuovo progetto in prod + 'CurrProd.bIsNew = True + '' elimino da DB + ''DbControllers.m_ProdController.DeleteProd(nProdId, True) + '' riapro progetto prod + 'OpenProject(TempCurrProd) + ' 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 + Return True + End Function + + Private Function CreateNewProj(ProdFileVM As ProdFileVM, Optional ByRef nProjId As Integer = 0, Optional ByRef sBTLFileName As String = "", Optional ByRef nType As BWType = BWType.NULL, Optional ByRef sMachine As String = "") As Boolean + 'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + ' apro finestra scelta file + Dim sImportFilePath As String = "" + 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 + sImportFilePath = BTLDlg.FileName + Else + Return False + End If + Dim sProjDir As String = "" + ' verifico se non e' tra i BTL gia' importati + sBTLFileName = Path.GetFileName(sImportFilePath) + Dim nAlreadyImported As Integer = DbControllers.m_ProjController.AlreadyImported(Path.GetFileNameWithoutExtension(sImportFilePath)) + 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 False + End Select + End If + End If + Dim Machine As Machine = Nothing + If IsNothing(ProdFileVM) Then + ' 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 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 False + End If + End If + sMachine = Machine.Name + 'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' creo progetto per file BTL + If Not CreateFirstBTLProj(sImportFilePath, nType, sMachine, nProjId, sProjDir) Then Return False + Else + ' creo progetto per file BTL + If Not AddNewBTLProj(sImportFilePath, ProdFileVM, nProjId, sProjDir) Then Return False + End If + ' carico filtri di ricerca + Map.refProjectVM.BTLStructureVM.LoadFilters() + ' gestisco log di importazione + ManageImportLog(nProjId, sProjDir) + 'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + Return True + End Function + + Private Function CreateFirstBTLProj(sImportFilePath As String, nType As BWType, sMachine As String, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean + 'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False + 'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' copio file BTL + Dim sBtlCopyPath As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\" & Path.GetFileName(sImportFilePath) + Dim bOk = False + Try + File.Copy(sImportFilePath, sBtlCopyPath, True) + bOk = True + Catch ex As Exception + EgtOutLog("Errore! Impossibile copiare il file BTL!") + Return False + End Try + ' inizializzo nuovo progetto + If InitNewProj(nProjId, sProjDir, nType, sMachine) Then + ' imposto ProjId di caricamento + ProjectManagerVM.nLoadingProjId = nProjId + Else + EgtOutLog("Errore! Impossibile creare indice nuovo progetto!") + ' elimino file Btl copiato + Try + File.Delete(sBtlCopyPath) + Catch ex As Exception + EgtOutLog("Errore! Eliminazione file BTL copiato fallita!") + End Try + Return False + End If + ' importo file + If Not Map.refSceneHostVM.MainController.ImportProject(sBtlCopyPath, False) Then + EgtOutLog("Errore! Inserimento nel progetto del file BTL fallito!") + ' elimino file Btl copiato + Try + File.Delete(sBtlCopyPath) + Catch ex As Exception + EgtOutLog("Errore! Eliminazione file BTL copiato fallita!") + End Try + 'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' elimino da Db + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nProjId, False) + Return False + End If + 'Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk Then '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 + ' aggiorno Db + Dim ExportDate As DateTime + Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sImportFilePath) + 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, sMachine) + 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.SetOnlyProdOptimizePanel_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) + 'If bOk Then + ''' salvo il progetto + ''Dim sProjFileName As String = sProdDir & "\" & nProjId.ToString("0000") & ".nge" + ''EgtSaveFile(sProjFileName, NGE.CMPTEXT) + 'End If + '' carico filtri di ricerca + 'Map.refProjectVM.BTLStructureVM.LoadFilters() + '' gestisco log di importazione + 'ManageImportLog(nProjId, sProjDir) + 'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + Return True + End Function + + Private Function AddNewBTLProj(sImportFilePath As String, ProdFileVM As ProdFileVM, ByRef nProjId As Integer, ByRef sProjDir As String) As Boolean + 'If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return False + 'LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' copio file BTL + Dim sBtlCopyPath As String = ProdFileVM.sProdDirPath & "\" & Path.GetFileName(sImportFilePath) + Dim bOk = False + Try + File.Copy(sImportFilePath, sBtlCopyPath, True) + bOk = True + Catch ex As Exception + EgtOutLog("Errore! Impossibile copiare il file BTL!") + Return False + End Try + ' inizializzo nuovo progetto + If Not InitNewProj(nProjId, sProjDir, ProdFileVM.nType, ProdFileVM.sMachine) Then + EgtOutLog("Errore! Impossibile creare indice nuovo progetto!") + ' elimino file Btl copiato + Try + File.Delete(sBtlCopyPath) + Catch ex As Exception + EgtOutLog("Errore! Eliminazione file BTL copiato fallita!") + End Try + Return False + End If + ' importo file + If Not Map.refSceneHostVM.MainController.InsertProject(sBtlCopyPath, False) Then + EgtOutLog("Errore! Inserimento nel progetto del file BTL fallito!") + ' elimino file Btl copiato + Try + File.Delete(sBtlCopyPath) + Catch ex As Exception + EgtOutLog("Errore! Eliminazione file BTL copiato fallita!") + End Try + 'Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' elimino da Db + ' CheckMe impostata come cancellazione FISICA dal DB... + DbControllers.m_ProjController.DeleteProj(nProjId, False) + Return False + End If + Dim sProjFileName As String = sProjDir & "\" & nProjId.ToString("0000") & ".nge" + Dim bFirstPart As Boolean = EgtGetFirstPart() <> GDB_ID.NULL + If bOk Then '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 + ' aggiorno Db + Dim ExportDate As DateTime + Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sImportFilePath) + 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, ProdFileVM.nType, ProdFileVM.sMachine) + SetCurrProj(nProjId) + ' se progetto pareti e vista ruotata + If ProdFileVM.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.SetOnlyProdOptimizePanel_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) + 'If bOk Then + ' ' salvo il progetto + ' bOk = EgtSaveFile(sProjFileName, NGE.CMPTEXT) + 'End If + '' carico filtri di ricerca + 'Map.refProjectVM.BTLStructureVM.LoadFilters() + '' gestisco log di importazione + 'ManageImportLog(nProjId, sProjDir) + 'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + Return True + End Function + 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) @@ -511,7 +825,7 @@ Public Class OnlyProdManagerVM ' inizializzo nuovo progetto PROJ Dim nProjId As Integer = 0 Dim sProjDir As String = "" - InitNewProj(nProjId, sProjDir, nType, Machine) + InitNewProj(nProjId, sProjDir, nType, Machine.Name) SetCurrProj(nProjId) ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel Map.refCALCPanelVM.LoadMachineList() @@ -694,13 +1008,13 @@ Public Class OnlyProdManagerVM 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 + ' aggiorno pezzi su 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 @@ -750,6 +1064,12 @@ Public Class OnlyProdManagerVM ''' Execute the ImportBTL. This method is invoked by the ImportBTLCommand. ''' Public Sub ImportBTL(Optional sFile As String = "", Optional bWithDlg As Boolean = True) + If Not CreateNewProd() Then + Dim sErrMsg As String = "Errore! Creazione del progetto fallita!" + MessageBox.Show(sErrMsg) + EgtOutLog(sErrMsg) + End If + Return If ProdFileVM.VerifyProjectModification(CurrProd) = MessageBoxResult.Cancel Then Return Dim sDir As String = String.Empty GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) @@ -784,21 +1104,6 @@ Public Class OnlyProdManagerVM 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 @@ -820,12 +1125,12 @@ Public Class OnlyProdManagerVM 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() + InitNewProj(nProjId, sProjDir, nType, Machine.Name) + '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 @@ -838,9 +1143,9 @@ Public Class OnlyProdManagerVM 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 + '' 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) @@ -882,11 +1187,11 @@ Public Class OnlyProdManagerVM Map.refProjectVM.SetOnlyProdOptimizePanel_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 + ' Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly ' mostro tutti i pezzi Map.refShowBeamPanelVM.ShowAll(True) Else - Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly + ' Map.refShowBeamPanelVM.ShowBuilding_IsChecked = bAssembly ' elimino da Db ' CheckMe impostata come cancellazione FISICA dal DB... DbControllers.m_ProjController.DeleteProj(nProjId, False) @@ -1624,7 +1929,7 @@ Public Class OnlyProdManagerVM ' inizializzo nuovo proj Dim nNewProjId As Integer = 0 Dim sNewProjDir As String = "" - InitNewProj(nNewProjId, sNewProjDir, nType, Machine) + InitNewProj(nNewProjId, sNewProjDir, nType, Machine.Name) NewProjIdList.Add(nNewProjId) ' imposto ProjId di caricamento ProjectManagerVM.nLoadingProjId = nImportProjId @@ -1807,6 +2112,10 @@ Public Class OnlyProdManagerVM ''' Execute the Save. This method is invoked by the SaveCommand. ''' Public Sub AddProj() + If Not CreateNewProj(CurrProd, 0) Then + MessageBox.Show("Errore! Aggiunta file fallita!") + End If + Return ' verifico se progetto modificato, e chiedo se salvare If IsNothing(CurrProd) Then Return Dim bNewProject As Boolean = False @@ -1880,6 +2189,175 @@ Public Class OnlyProdManagerVM #End Region ' AddProj +#Region "AddBTL" + + ''' + ''' Returns a command that do Save. + ''' + Public ReadOnly Property AddBTL_Command As ICommand + Get + If m_cmdAddBTL Is Nothing Then + m_cmdAddBTL = New Command(AddressOf AddBTL) + End If + Return m_cmdAddBTL + End Get + End Property + + ''' + ''' Execute the Save. This method is invoked by the SaveCommand. + ''' + Public Sub AddBTL() + '' verifico ci sia un progetto aperto + If IsNothing(CurrProd) Then Return + ' apro finestra scelta file + Dim sDir As String = String.Empty + GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir) + Dim sFile As String = "" + 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 + Dim nNewProjId 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 + 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 + End If + + + + + ''LoadingWndHelper.OpenLoadingWnd(ActiveIds.IMPORTBTL, 3, EgtMsg(63008), EgtMsg(63009), 50) ' BTL file importing ' Reading BTL file + ' inizializzo nuovo progetto + InitNewProj(nNewProjId, sProjDir, CurrProd.nType, CurrProd.sMachine) + ''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 = CurrProd.sProdDirPath & "\" & 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 + ' aggiungo file BTL + 'Dim nPartCount As Integer = EgtGetPartCount() + If bOk Then + bOk = Map.refSceneHostVM.MainController.InsertProject(sBtlCopyPath, False) + End If + Dim sProjFileName As String = sProjDir & "\" & nNewProjId.ToString("0000") & ".nge" + ' Dim nNewPartCount As Integer = EgtGetPartCount() + If bOk Then ' AndAlso nNewPartCount > nPartCount 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(nNewProjId, sBTLFileName, sBTLFileName, Map.refProjectVM.BTLStructureVM.sLISTNAME, ExportDate, nType, Map.refMachinePanelVM.SelectedMachine.Name) + SetCurrProj(nNewProjId) + ' 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.SetOnlyProdOptimizePanel_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(nNewProjId, 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(nNewProjId, sProjDir) + '' aggiorno titolo + 'Map.refMainWindowVM.UpdateTitle() + 'LoadingWndHelper.CloseLoadingWnd(ActiveIds.IMPORTBTL) + + + + + + + '' 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, nNewProjId) + 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 ' AddBTL + #Region "ShowPopUpStartBtnCommand" Public ReadOnly Property ShowPopUpStartBtnCommand As ICommand diff --git a/EgtBEAMWALL.Optimizer/ProjectTypeWnd/ProjectTypeWndVM.vb b/EgtBEAMWALL.Optimizer/ProjectTypeWnd/ProjectTypeWndVM.vb index d164e1a4..120326d2 100644 --- a/EgtBEAMWALL.Optimizer/ProjectTypeWnd/ProjectTypeWndVM.vb +++ b/EgtBEAMWALL.Optimizer/ProjectTypeWnd/ProjectTypeWndVM.vb @@ -10,21 +10,19 @@ Public Class ProjectTypeWndVM Friend Event m_CloseWindow(bDialogResult As Boolean) - ' recupero la lista delle Macchine da MachinePanel - Private m_MachineList As ObservableCollection(Of Machine) = Map.refMachinePanelVM.MachineList + Private m_MachineList As ObservableCollection(Of Machine) Public ReadOnly Property MachineList As ObservableCollection(Of Machine) Get Return m_MachineList End Get End Property - ' La Macchina selezionata di default sarà quella correntemente selezionata in MachinePanel - Private m_SelMachine As Machine = MachineList.FirstOrDefault(Function(x) x.Name = Map.refMachinePanelVM.SelectedMachine.Name) - Public Property SelMachine As Machine + Private m_SelMachine As MyMachine + Public Property SelMachine As MyMachine Get Return m_SelMachine End Get - Set(value As Machine) + Set(value As MyMachine) If value IsNot m_SelMachine Then m_SelMachine = value Dim nMachType As MachineType = DirectCast(SelMachine, MyMachine).nType @@ -33,9 +31,7 @@ Public Class ProjectTypeWndVM End Set End Property - ' Se la Macchina selezionata è di tipo BOTH verrà mostrata anche la selezione del Tipo - Private m_IsBoth_Visibility As Visibility = If(Not IsNothing(ProjectManagerVM.CurrProj) AndAlso - DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH OrElse Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(ProjectManagerVM.CurrProd), Visibility.Visible, Visibility.Collapsed) + Private m_IsBoth_Visibility As Visibility = Visibility.Collapsed Public Property IsBoth_Visibility As Visibility Get Return m_IsBoth_Visibility @@ -56,8 +52,7 @@ Public Class ProjectTypeWndVM End Property ' Se la Macchina selezionata è di tipo BOTH verrà selezionato di default il Tipo del progetto corrente - Private m_nSelType As BWType = If(Not IsNothing(ProjectManagerVM.CurrProj) AndAlso Not IsNothing(Map.refOnlyProdManagerVM) AndAlso Not IsNothing(Map.refOnlyProdManagerVM.CurrProj) AndAlso - DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, ProjectManagerVM.CurrProj.nType, Nothing) + Private m_nSelType As BWType = BWType.BEAM Public Property nSelType As BWType Get Return m_nSelType @@ -90,6 +85,22 @@ Public Class ProjectTypeWndVM #End Region ' MESSAGES + Sub New() + ' recupero la lista delle Macchine da MachinePanel + m_MachineList = Map.refMachinePanelVM.MachineList + ' La Macchina selezionata di default sarà quella correntemente selezionata in MachinePanel + m_SelMachine = MachineList.FirstOrDefault(Function(x) x.Name = Map.refMachinePanelVM.SelectedMachine.Name) + ' Se la Macchina selezionata è di tipo BOTH verrà selezionato di default il Tipo del progetto corrente + Select Case SelMachine.nType + Case MachineType.BEAM, MachineType.BOTH + m_nSelType = BWType.BEAM + Case MachineType.WALL + m_nSelType = BWType.WALL + End Select + ' Se la Macchina selezionata è di tipo BOTH verrà mostrata anche la selezione del Tipo + m_IsBoth_Visibility = If(DirectCast(SelMachine, MyMachine).nType = MachineType.BOTH, Visibility.Visible, Visibility.Collapsed) + End Sub + #Region "COMMANDS" #Region "Ok" diff --git a/EgtBEAMWALL.Optimizer/SaveAsStrategyWnd/SaveAsStrategyVM.vb b/EgtBEAMWALL.Optimizer/SaveAsStrategyWnd/SaveAsStrategyVM.vb index 6813c7eb..3144e733 100644 --- a/EgtBEAMWALL.Optimizer/SaveAsStrategyWnd/SaveAsStrategyVM.vb +++ b/EgtBEAMWALL.Optimizer/SaveAsStrategyWnd/SaveAsStrategyVM.vb @@ -163,7 +163,7 @@ Public Class SaveAsStrategyVM ''' Funzione che salva il file json CustomerConfig ''' Public Sub SaveAs() - Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(ProjectManagerVM.CurrProd.nType) Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sFileNameCustomConfig & ".json" Dim Strategy As New StrategySetup(sFileNameCustomConfig) Map.refStrategyManagerVM.SelStrategySetup = Strategy diff --git a/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb index 92d36e46..9b630b2e 100644 --- a/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb +++ b/EgtBEAMWALL.Optimizer/SceneHost/MySceneHostVM.vb @@ -692,8 +692,7 @@ Public Class MySceneHostVM 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)) + ' aggiungo informazioni su pezzi Dim nPartId As Integer = EgtGetFirstPart() While nPartId <> GDB_ID.NULL ' scrivo in ogni pezzo ProjId @@ -717,10 +716,12 @@ Public Class MySceneHostVM ' 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) + ''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) + ' leggo struttura BTL per liste + Map.refProjectVM.BTLStructureVM = New BTLStructureVM(BTLStructureM.CreateBTLStructure(0)) Else Dim sMsg As String = EgtMsg(10006) & " '" & sFile & "'" 'Error importing file MessageBox.Show(Application.Current.MainWindow, sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error diff --git a/EgtBEAMWALL.Optimizer/SceneShowBulding/SceneShowBuldingV.xaml.vb b/EgtBEAMWALL.Optimizer/SceneShowBulding/SceneShowBuldingV.xaml.vb index 40785fd1..efa7e669 100644 --- a/EgtBEAMWALL.Optimizer/SceneShowBulding/SceneShowBuldingV.xaml.vb +++ b/EgtBEAMWALL.Optimizer/SceneShowBulding/SceneShowBuldingV.xaml.vb @@ -32,8 +32,8 @@ Public Class SceneShowBuldingV 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() + '' Seleziono la macchina impostata nel file ini + 'Map.refMachinePanelVM.LoadCurrentMachine() Return End If End Sub diff --git a/EgtBEAMWALL.Optimizer/StrategyManager/StrategyManagerV.xaml b/EgtBEAMWALL.Optimizer/StrategyManager/StrategyManagerV.xaml index 1c203f02..4d94889a 100644 --- a/EgtBEAMWALL.Optimizer/StrategyManager/StrategyManagerV.xaml +++ b/EgtBEAMWALL.Optimizer/StrategyManager/StrategyManagerV.xaml @@ -12,6 +12,11 @@ + 0 Then - SelStrategySetup = m_StrategySetupList(0) - End If + ' imposto Type a primo della lista per default + Select Case CurrentMachine.nType + Case MachineType.BEAM + m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.BEAM) + Case MachineType.WALL + m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.WALL) + Case MachineType.BOTH + m_SelStrategyType = m_StrategyTypeList.FirstOrDefault(Function(x) x.Id = BWType.BEAM) + End Select + NotifyPropertyChanged(NameOf(StrategyType_Visibility)) ' Assegno riferimento funzione per aggiornare elemento selezionato dall'albero Topology.refUpdateSelTreeItem = AddressOf UpdateSelTreeItem End Sub @@ -173,6 +197,18 @@ Public Class StrategyManagerVM End If End Sub + Friend Sub Update() + ' leggo cartella dei setup delle strategie + Dim AISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(SelStrategyType.Id) + Dim AISetupPaths As String() = Directory.GetFiles(AISetupDirPath) + For Each AiSetup In AISetupPaths + m_StrategySetupList.Add(New StrategySetup(Path.GetFileNameWithoutExtension(AiSetup))) + Next + If m_StrategySetupList.Count > 0 Then + SelStrategySetup = m_StrategySetupList(0) + End If + End Sub + #End Region ' Methods #Region "COMMANDS" @@ -468,7 +504,7 @@ Public Class StrategySetup Friend Sub Read() ' carico default - Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath() + Dim sStrategiesDirPath As String = Map.refMainWindowVM.MainWindowM.GetStrategiesDirPath(Map.refStrategyManagerVM.SelStrategyType.Id) Dim sAvailableStrategiesFilePath As String = sStrategiesDirPath & "\" & AVAILABLESTRATEGYLIST_FILE & ".json" If File.Exists(sAvailableStrategiesFilePath) Then Dim sReadedFile As String = File.ReadAllText(sAvailableStrategiesFilePath) @@ -478,7 +514,7 @@ Public Class StrategySetup End If ' carico custom - Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(Map.refStrategyManagerVM.SelStrategyType.Id) Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sName & ".json" If File.Exists(sStrategyConfigurationFilePath) Then Dim sReadedFile As String = File.ReadAllText(sStrategyConfigurationFilePath) @@ -513,7 +549,7 @@ Public Class StrategySetup JsonFromStrategyManager.Add(StrategyFeature.Serialize()) Next Dim JsonFromStrategy As String = JsonConvert.SerializeObject(JsonFromStrategyManager, Formatting.Indented) - Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath() + Dim sAISetupDirPath As String = Map.refMainWindowVM.MainWindowM.GetAISetupDirPath(Map.refStrategyManagerVM.SelStrategyType.Id) Dim sStrategyConfigurationFilePath As String = sAISetupDirPath & "\" & sName & ".json" File.WriteAllText(sStrategyConfigurationFilePath, JsonFromStrategy) End Sub diff --git a/EgtBEAMWALL.Optimizer/Utility/CurrentMachine.vb b/EgtBEAMWALL.Optimizer/Utility/CurrentMachine.vb index 2962d1ac..2571615e 100644 --- a/EgtBEAMWALL.Optimizer/Utility/CurrentMachine.vb +++ b/EgtBEAMWALL.Optimizer/Utility/CurrentMachine.vb @@ -199,6 +199,9 @@ Public Module CurrentMachine ' crea l'elenco dei parametri della macchina corrente CreateMachParams() + '' aggiorna strategie per macchina corrente + 'Map.refStrategyManagerVM.Update() + ' leggo parametri macchina da BeamData If nType = MachineType.BEAM OrElse nType = MachineType.BOTH Then ' Assegno i dati