diff --git a/MachiningsDbPage/MachiningsDbViewModel.vb b/MachiningsDbPage/MachiningsDbViewModel.vb index 9088b07..6bfb582 100644 --- a/MachiningsDbPage/MachiningsDbViewModel.vb +++ b/MachiningsDbPage/MachiningsDbViewModel.vb @@ -463,7 +463,7 @@ Namespace EgtCAM5 Dim NewName As String = MachiningFamily.Name EgtMdbGetMachiningNewName(NewName) If EgtMdbAddMachining(NewName, MachiningFamily.MachiningType) Then - NewMachiningItem = New MachiningTreeViewItem(NewName, DirectCast(MachiningFamily.Type, MCH_MY)) + NewMachiningItem = New MachiningTreeViewItem(NewName, MachiningFamily.MachiningType) MachiningFamily.Items.Add(NewMachiningItem) EgtMdbSaveCurrMachining() NewMachiningItem.NewMachining = True diff --git a/MainWindow/MainWindowViewModel.vb b/MainWindow/MainWindowViewModel.vb index e07267b..9ddfc93 100644 --- a/MainWindow/MainWindowViewModel.vb +++ b/MainWindow/MainWindowViewModel.vb @@ -107,6 +107,10 @@ Namespace EgtCAM5 ' Esce dal gruppo di lavorazione corrente per poter aprire le macchine del database EgtResetCurrMachGroup() End If + If TypeOf value Is MachiningsDbViewModel Then + ' Esce dal gruppo di lavorazione corrente per poter aprire le macchine del database + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + End If End If End Set End Property diff --git a/ToolsDbPage/ToolTreeView.vb b/ToolsDbPage/ToolTreeView.vb index f744847..2038b25 100644 --- a/ToolsDbPage/ToolTreeView.vb +++ b/ToolsDbPage/ToolTreeView.vb @@ -79,8 +79,8 @@ Public Class ToolTreeViewItem ' If Tool is selected, set it as current and notify all tool's property ' to refresh them values with those of the new selected tool If value Then - Dim x = EgtSetCurrentContext(IniFile.m_ProjectSceneContext) - Dim y = EgtTdbSetCurrTool(Me.Name) + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + EgtTdbSetCurrTool(Me.Name) NotifyPropertyChanged("Corr") NotifyPropertyChanged("ExitPar") NotifyPropertyChanged("Type") @@ -113,7 +113,7 @@ Public Class ToolTreeViewItem ' Otherwhise Tool is deselected, so it and the database will be saved to ' keep the modify effective Else - If EgtTdbIsCurrToolModified() And Me.IsValid Then + If (EgtTdbIsCurrToolModified() And Me.IsValid) Or Me.NewTool Then Select Case MsgBox(EgtMsg(MSG_TOOLSERRORS), MsgBoxStyle.YesNo, EgtMsg(MSG_TOOLSERRORS + 1)) Case MsgBoxResult.Yes @@ -351,6 +351,7 @@ Public Class ToolTreeViewItem Dim dLen As Double = 0 StringToLen(value, dLen) m_Len = dLen + NotifyPropertyChanged("MaxMat") UpdateSceneToolDraw(DrawUpdateSource.LEN) EgtTdbSetCurrToolParam(MCH_TP.LEN, dLen) End Set @@ -677,6 +678,7 @@ Public Class ToolTreeViewItem Dim bDrawNameExistError As Boolean = False Dim bDrawNameError As Boolean = False Dim bDrawingError As Boolean = False + Dim m_bFirst As Boolean = True Private Sub UpdateSceneToolDraw(UpdateSource As DrawUpdateSource) ' Azzero errori @@ -685,11 +687,14 @@ Public Class ToolTreeViewItem bDrawNameExistError = False bDrawingError = False - EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, m_MaxMat) - EgtTdbGetCurrToolParam(MCH_TP.THICK, m_Thick) - EgtTdbGetCurrToolParam(MCH_TP.DIAM, m_Diam) - EgtTdbGetCurrToolParam(MCH_TP.LEN, m_Len) - EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, m_TotLen) + If m_NewTool And m_bFirst Then + m_bFirst = False + EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, m_MaxMat) + EgtTdbGetCurrToolParam(MCH_TP.THICK, m_Thick) + EgtTdbGetCurrToolParam(MCH_TP.DIAM, m_Diam) + EgtTdbGetCurrToolParam(MCH_TP.LEN, m_Len) + EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, m_TotLen) + End If ' Verifico proprietà draw If m_Draw = String.Empty OrElse IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then @@ -947,51 +952,48 @@ Public Class ToolTreeViewItem End Function Private Function ValidateMaxMat() As String - If String.IsNullOrEmpty(m_Draw) Then - If m_MaxMat < EPS_SMALL Then - Return EgtMsg(MSG_TOOLSERRORS + 6) - End If - If m_MaxMat > m_Len + EPS_SMALL Then - Return EgtMsg(MSG_TOOLSERRORS + 7) - End If + If m_MaxMat < EPS_SMALL Then + Return EgtMsg(MSG_TOOLSERRORS + 6) + End If + If m_MaxMat > m_Len + EPS_SMALL Then + Return EgtMsg(MSG_TOOLSERRORS + 7) End If Return Nothing End Function Private Function ValidateThick() As String - If (m_Type = MCH_TY.SAW_FLAT Or m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.MORTISE_STD) And m_Draw = String.Empty And m_Thick < EPS_SMALL Then + If (m_Type = MCH_TY.SAW_FLAT Or m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.MORTISE_STD) And m_Thick < EPS_SMALL Then Return EgtMsg(MSG_TOOLSERRORS + 8) End If Return Nothing End Function Private Function ValidateDiam() As String - If m_Draw = String.Empty And m_Diam < EPS_SMALL Then + If m_Diam < EPS_SMALL Then Return EgtMsg(MSG_TOOLSERRORS + 9) End If Return Nothing End Function Private Function ValidateLen() As String - If m_Draw = String.Empty Then - If m_Len < EPS_SMALL Then - Return EgtMsg(MSG_TOOLSERRORS + 10) - End If - If m_Len > m_TotLen + EPS_SMALL Then - Return "La lunghezza non può essere maggiore della lunghezza totale" - End If + If m_Len < EPS_SMALL Then + Return EgtMsg(MSG_TOOLSERRORS + 10) + End If + If m_Len > m_TotLen + EPS_SMALL Then + Return "La lunghezza non può essere maggiore della lunghezza totale" + End If + If m_Len < m_MaxMat Then + Return "La lunghezza non può essere minore del massimo materiale" End If Return Nothing End Function Private Function ValidateTotLen() As String - If m_Draw = String.Empty Then - If m_TotLen < EPS_SMALL Then - Return "La lunghezza totale deve essere maggiore di zero" - End If - If m_TotLen < m_Len - EPS_SMALL Then - Return "La lunghezza totale non può essere minore della lunghezza" - End If + If m_TotLen < EPS_SMALL Then + Return "La lunghezza totale deve essere maggiore di zero" + End If + If m_TotLen < m_Len - EPS_SMALL Then + Return "La lunghezza totale non può essere minore della lunghezza" End If Return Nothing End Function diff --git a/ToolsDbPage/ToolsDbViewModel.vb b/ToolsDbPage/ToolsDbViewModel.vb index fd27cdc..8df5c3c 100644 --- a/ToolsDbPage/ToolsDbViewModel.vb +++ b/ToolsDbPage/ToolsDbViewModel.vb @@ -378,6 +378,7 @@ Namespace EgtCAM5 NewToolItem = New ToolTreeViewItem(NewName) ToolFamily.Items.Add(NewToolItem) EgtTdbSaveCurrTool() + NewToolItem.NewTool = True NewToolItem.IsSelected = True NewToolItem.NotifyPropertyChanged("IsSelected") Exit For @@ -427,6 +428,7 @@ Namespace EgtCAM5 Application.Msn.NotifyColleagues(Application.SAVETOOLDRAW) EgtTdbSaveCurrTool() EgtTdbSave() + DirectCast(param, ToolTreeViewItem).NewTool = False End Sub ''' @@ -434,9 +436,10 @@ Namespace EgtCAM5 ''' Private Function CanSave(ByVal param As Object) As Boolean ' Verifico che sia selezionato un utensile - If TypeOf param Is MachiningTreeViewItem Then + If TypeOf param Is ToolTreeViewItem Then + Dim Tool As ToolTreeViewItem = DirectCast(param, ToolTreeViewItem) ' Verifico che i parametri dell'utensile siano validi - Return DirectCast(param, MachiningTreeViewItem).IsValid And EgtTdbIsCurrToolModified() + Return (Tool.IsValid And EgtTdbIsCurrToolModified()) Or Tool.NewTool Else Return False End If