Imports System.ComponentModel Imports System.IO Imports System.Collections.ObjectModel Imports System.Text.RegularExpressions Imports EgtUILib Public Class FamilyToolTreeViewItem Inherits InheritableTreeViewItem ' Actions Friend Shared m_delIsEnabledBtns As Action(Of Boolean, Boolean, Boolean) Public Shared m_delNotifyPropertyChanged As Action(Of String) Friend Shared m_delErrorOnTool As Action(Of Boolean) Dim x As Integer = MCH_TF.MILL 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 ' The function that I want to call When Parent item is selected in the tree If EgtSetCurrentContext(ToolDbWindowVM.m_ToolDbSceneContext) Then EgtNewFile() EgtSetView(VT.TOP, False) EgtZoom(ZM.ALL) EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) End If If value Then m_delNotifyPropertyChanged("ParamPageV") m_delErrorOnTool(False) m_delIsEnabledBtns(True, False, False) End If End If NotifyPropertyChanged("IsSelected") End If End Set End Property Private m_ToolType As MCH_TF ''' ''' Property that determines the tool type of the family ''' Public Property ToolType As MCH_TF Get Return m_ToolType End Get Set(value As MCH_TF) m_ToolType = value End Set End Property ' Proprietà che permette di nascondere tutti i parametri utensile grazie al binding ed al converter Public ReadOnly Property Type As Integer Get Return MCH_TY.NONE End Get End Property Sub New(Name As String, ToolFamily As MCH_TF) MyBase.New(Name) Me.PictureString = "/Resources/TreeView/Folder.png" Me.m_ToolType = ToolFamily End Sub End Class Public Class ToolTreeViewItem Inherits InheritableTreeViewItem ' Actions Friend Shared m_delRemoveTool As Action(Of ToolTreeViewItem) Friend Shared m_delErrorOnTool As Action(Of Boolean) Friend Shared m_delIsEnabledBtns As Action(Of Boolean, Boolean, Boolean) Friend Shared m_delGetSelectedTool As Func(Of ToolTreeViewItem) Public Shared m_delNotifyPropertyChanged As Action(Of String) ' Constants Public Const K_STEPPAR As String = "STEP" Public Const K_SIDESTEP As String = "SIDESTEP" #Region "Tool Property" ' Variabile che indica quando non lanciare l'update del disegno utensile ' (utile per evitare di rifare il disegno più volte quando vengono caricati i parametri alla selezione di un utensile) Private Shared m_SuspendToolDrawUpdate As Boolean = False Public Shared Property SuspendToolDrawUpdate As Boolean Get Return m_SuspendToolDrawUpdate End Get Set(value As Boolean) m_SuspendToolDrawUpdate = value End Set End Property ' Variabile che indica se l'utensile è appena stato creato Dim m_NewTool As Boolean = False Public Property NewTool As Boolean Get Return m_NewTool End Get Set(value As Boolean) m_NewTool = value End Set End Property ''' ''' Property that determines if the Tool is selected or not ''' 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 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbSetCurrTool(Me.Name) ReadToolParam() IsModifiedReset() NotifyPropertyChanged("Type") 'm_delNotifyPropertyChanged("ParamPageV") m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) Else WriteToolParam() If EgtTdbIsCurrToolModified() Or m_IsModifiedName Or Me.NewTool Then Select Case MsgBox(EgtMsg(MSG_TOOLDBERRORS), MsgBoxStyle.YesNo, EgtMsg(MSG_TOOLDBERRORS + 1)) Case MsgBoxResult.Yes m_NewTool = False m_Name = m_Name.Trim() WriteToolName() EgtTdbSaveCurrTool() Case MsgBoxResult.No If m_NewTool Then m_delRemoveTool(Me) ElseIf m_IsModifiedName Then Dim DbName As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName) NamePar = DbName End If End Select End If End If ' ricarico utensile per avere valore Active e ricaricarlo EgtTdbSetCurrTool(Me.Name) NotifyPropertyChanged("Active") NotifyPropertyChanged("IsSelected") End If End Set End Property Friend Sub ResetSelected() m_IsSelected = False NotifyPropertyChanged(NameOf(IsSelected)) End Sub Private m_IsModifiedCorr As Boolean = False Private m_Corr As String ''' ''' Property that read and write to the tool's database the Corrector ''' Public Property Corr As String Get Return m_Corr End Get Set(value As String) If value <> m_Corr Then m_Corr = value Dim DbCorr As Integer = 0 Dim nValue As Integer = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.CORR, DbCorr) Int32.TryParse(value, nValue) m_IsModifiedCorr = If(nValue <> DbCorr, True, False) If GetNonNumericTextBox(m_Corr) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("Corr") End If End Set End Property Friend m_ExitList As New ObservableCollection(Of Object) Public ReadOnly Property ExitList As ObservableCollection(Of Object) Get Return m_ExitList End Get End Property Private m_IsModifiedSelectedExit As Boolean = False Private m_SelectedExit As Integer = -1 ''' ''' Property that read and write to the tool's database the Exit ''' Public Property SelectedExit As Integer Get Return m_SelectedExit End Get Set(value As Integer) If value <> m_SelectedExit Then If Not IsNothing(ExitList) AndAlso ExitList.Count() > 0 Then m_SelectedExit = value If SelectedExit <> -1 Then Dim DbExit As Integer = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.EXIT_, DbExit) DbExit = IdNameStruct.IndFromId(DbExit, ExitList) m_IsModifiedSelectedExit = If(value <> DbExit, True, False) ' se modificato disattivo l'utensile If m_IsModifiedSelectedExit And Not m_SuspendToolDrawUpdate Then EgtTdbSetCurrToolParam(MCH_TP.ACTIVE, False) If Not GetValidationError("SelectedExit") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If NotifyPropertyChanged("SelectedExit") End If End If End If End Set End Property ' Per Note Utensile Private m_TypeM As MCH_TY Private m_Type As Integer ''' ''' Property that read and write to the tool's database the Type ''' Public Property Type As Integer Get Return m_Type End Get Set(value As Integer) If value <> m_Type Then m_Type = value End If End Set End Property 'ObservableCollection che contiene le variabili per il combobox WorkSide Private m_CoolantList As ObservableCollection(Of Object) Public ReadOnly Property CoolantList As ObservableCollection(Of Object) Get Return m_CoolantList End Get End Property Private m_IsModifiedSelCoolant As Boolean = False Private m_SelCoolant As Integer ''' ''' Property that read and write to the tool's database the Coolant ''' Public Property SelCoolant As Integer Get If IsNothing(CoolantList) Then Return Nothing Return m_SelCoolant End Get Set(value As Integer) If value <> m_SelCoolant Then If Not IsNothing(CoolantList) Then m_SelCoolant = value Dim DbCoolant As Integer = 0 EgtTdbGetCurrToolParam(MCH_TP.COOLANT, DbCoolant) DbCoolant = IdNameStruct.IndFromId(DbCoolant, CoolantList) m_IsModifiedSelCoolant = If(value <> DbCoolant, True, False) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) NotifyPropertyChanged("SelCoolant") End If End If End Set End Property Private m_IsModifiedCornRad As Boolean = False Private m_CornRad As String ''' ''' Property that read and write to the tool's database the Corner Radius ''' Public Property CornRad As String Get Return m_CornRad End Get Set(value As String) If value <> m_CornRad Then m_CornRad = value Dim DbCornRad As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.CORNRAD, DbCornRad) StringToLen(value, dValue) m_IsModifiedCornRad = Math.Abs(dValue - DbCornRad) > 10 * EPS_ANG_SMALL If Not GetValidationError("CornRad") Or GetNonNumericTextBox(m_CornRad) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If NotifyPropertyChanged("CornRad") End If End Set End Property Private m_IsModifiedDiam As Boolean = False Private m_Diam As String ''' ''' Property that read and write to the tool's database the Diameter ''' Public Property Diam As String Get Return m_Diam End Get Set(value As String) If value <> m_Diam Then m_Diam = value Dim DbDiam As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.DIAM, DbDiam) StringToLen(value, dValue) m_IsModifiedDiam = Math.Abs(dValue - DbDiam) > 10 * EPS_ANG_SMALL If Not GetValidationError("Diam") Or GetNonNumericTextBox(m_Diam) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If NotifyPropertyChanged("Diam") End If End Set End Property Private m_IsModifiedTotDiam As Boolean = False Private m_TotDiam As String ''' ''' Property that read and write to the tool's database the Total Diameter ''' Public Property TotDiam As String Get Return m_TotDiam End Get Set(value As String) If value <> m_TotDiam Then m_TotDiam = value Dim DbTotDiam As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, DbTotDiam) StringToLen(value, dValue) m_IsModifiedTotDiam = Math.Abs(dValue - DbTotDiam) > 5 * EPS_SMALL If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If If Not GetValidationError("Diam") Or Not GetValidationError("TotDiam") Or GetNonNumericTextBox(m_TotDiam) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("TotDiam") End If End Set End Property Private m_IsModifiedFeed As Boolean = False Private m_Feed As String ''' ''' Property that read and write to the tool's database the Feed ''' Public Property Feed As String Get Return m_Feed End Get Set(value As String) If value <> m_Feed Then m_Feed = value Dim DbFeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.FEED, DbFeed) StringToLen(value, dValue) m_IsModifiedFeed = Math.Abs(dValue - DbFeed) > 5 * EPS_SMALL If GetNonNumericTextBox(m_Feed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("Feed") End If End Set End Property Private m_IsModifiedEndFeed As Boolean = False Private m_EndFeed As String ''' ''' Property that read and write to the tool's database the End Feed ''' Public Property EndFeed As String Get Return m_EndFeed End Get Set(value As String) If value <> m_EndFeed Then m_EndFeed = value Dim DbEndFeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.ENDFEED, DbEndFeed) StringToLen(value, dValue) m_IsModifiedEndFeed = Math.Abs(dValue - DbEndFeed) > 5 * EPS_SMALL If GetNonNumericTextBox(m_EndFeed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("EndFeed") End If End Set End Property Private m_IsModifiedStartFeed As Boolean = False Private m_StartFeed As String ''' ''' Property that read and write to the tool's database the Start Feed ''' Public Property StartFeed As String Get Return m_StartFeed End Get Set(value As String) If value <> m_StartFeed Then m_StartFeed = value Dim DbStartFeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.STARTFEED, DbStartFeed) StringToLen(value, dValue) m_IsModifiedStartFeed = Math.Abs(dValue - DbStartFeed) > 5 * EPS_SMALL If GetNonNumericTextBox(m_StartFeed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("StartFeed") End If End Set End Property Private m_IsModifiedTipFeed As Boolean = False Private m_TipFeed As String ''' ''' Property that read and write to the tool's database the Tip Feed ''' Public Property TipFeed As String Get Return m_TipFeed End Get Set(value As String) If value <> m_TipFeed Then m_TipFeed = value Dim DbTipFeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.TIPFEED, DbTipFeed) StringToLen(value, dValue) m_IsModifiedTipFeed = Math.Abs(dValue - DbTipFeed) > 5 * EPS_SMALL If GetNonNumericTextBox(m_TipFeed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("TipFeed") ' Se fresa e 0 non può lavorare di testa If (Type And MCH_TF.MILL) <> 0 Then If dValue > EPS_SMALL Then Type = MCH_TY.MILL_STD Else Type = MCH_TY.MILL_NOTIP End If End If End If End Set End Property Private m_IsModifiedLen As Boolean = False Private m_Len As String ''' ''' Property that read and write to the tool's database the Len ''' Public Property Len As String Get Return m_Len End Get Set(value As String) If value <> m_Len Then m_Len = value Dim DbLen As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.LEN, DbLen) StringToLen(value, dValue) m_IsModifiedLen = Math.Abs(dValue - DbLen) > 5 * EPS_SMALL If Not GetValidationError("Len") Or Not GetValidationError("MaxMat") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("Len") ' Se lama If (Type And MCH_TF.SAWBLADE) <> 0 Then Dim CurrTotLen As Double = 0 If Not IsNothing(TotLen) Then StringToLen(TotLen, CurrTotLen) ' se len e totlen coincidono tipo piatto If (CurrTotLen - dValue) > 10 * EPS_SMALL Then Type = MCH_TY.SAW_STD Else Type = MCH_TY.SAW_FLAT End If End If End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If End If End Set End Property Private m_IsModifiedTotLen As Boolean = False Private m_TotLen As String ''' ''' Property that read and write to the tool's database the Total Len ''' Public Property TotLen As String Get Return m_TotLen End Get Set(value As String) If value <> m_TotLen Then m_TotLen = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim DbTotLen As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, DbTotLen) Dim dValue As Double = 0 StringToLen(value, dValue) m_IsModifiedTotLen = Math.Abs(dValue - DbTotLen) > 5 * EPS_SMALL If Not GetValidationError("TotLen") Or Not GetValidationError("Len") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("TotLen") ' Se lama e len e totlen coincidono tipo piatto If (Type And MCH_TF.SAWBLADE) <> 0 Then If Not IsNothing(Len) Then Dim CurrLen As Double = 0 StringToLen(Len, CurrLen) If (dValue - CurrLen) > 10 * EPS_SMALL Then Type = MCH_TY.SAW_STD Else Type = MCH_TY.SAW_FLAT End If End If End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If End If End Set End Property Private m_IsModifiedDist As Boolean = False Private m_Dist As String ''' ''' Property that read and write to the tool's database the Len ''' Public Property Dist As String Get Return m_Dist End Get Set(value As String) If value <> m_Dist Then m_Dist = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim DbDist As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.DIST, DbDist) Dim dValue As Double = 0 StringToLen(value, dValue) If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() If Not GetValidationError("Dist") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_IsModifiedLen = Math.Abs(dValue - DbDist) > 5 * EPS_SMALL m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("Dist") End If End Set End Property Private m_IsModifiedMaxMat As Boolean = False Private m_MaxMat As String ''' ''' Property that read and write to the tool's database the Max Material ''' Public Property MaxMat As String Get Return m_MaxMat End Get Set(value As String) If value <> m_MaxMat Then m_MaxMat = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim DbMaxMat As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, DbMaxMat) Dim dValue As Double = 0 StringToLen(value, dValue) If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() If Not GetValidationError("MaxMat") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_IsModifiedMaxMat = Math.Abs(dValue - DbMaxMat) > 5 * EPS_SMALL m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("MaxMat") End If End Set End Property Private m_IsModifiedLonOffset As Boolean = False Private m_LonOffset As String ''' ''' Property that read and write to the tool's database the Lon Offset ''' Public Property LonOffset As String Get Return m_LonOffset End Get Set(value As String) If value <> m_LonOffset Then m_LonOffset = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim DbLonOffset As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.LONOFFSET, DbLonOffset) Dim dValue As Double = 0 If Not StringToLen(value, dValue) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_IsModifiedLonOffset = Math.Abs(dValue - DbLonOffset) > 5 * EPS_SMALL m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("LonOffset") End If End Set End Property Private m_IsModifiedRadOffset As Boolean = False Private m_RadOffset As String ''' ''' Property that read and write to the tool's database the Rad Offset ''' Public Property RadOffset As String Get Return m_RadOffset End Get Set(value As String) If value <> m_RadOffset Then m_RadOffset = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim DbRadOffset As Double = 0 EgtTdbGetCurrToolParam(MCH_TP.RADOFFSET, DbRadOffset) Dim dValue As Double = 0 If Not StringToLen(value, dValue) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_IsModifiedRadOffset = Math.Abs(dValue - DbRadOffset) > 5 * EPS_SMALL m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("RadOffset") End If End Set End Property Private m_IsModifiedStepPar As Boolean = False Private m_StepPar As String ''' ''' Property that read and write to the tool's database the Step Par ''' Public Property StepPar As String Get Return m_StepPar End Get Set(value As String) If value <> m_StepPar Then m_StepPar = value Dim DbStepPar As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolValInNotes(MCH_TP.SYSNOTES, K_STEPPAR, DbStepPar) StringToLen(value, dValue) m_IsModifiedStepPar = Math.Abs(dValue - DbStepPar) > 5 * EPS_SMALL If GetNonNumericTextBox(m_StepPar) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("StepPar") End If End Set End Property Private m_IsModifiedSideStep As Boolean = False Private m_SideStep As String ''' ''' Property that read and write to the tool's database the Side Step ''' Public Property SideStep As String Get Return m_SideStep End Get Set(value As String) If value <> m_SideStep Then m_SideStep = value Dim DbSideStep As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolValInNotes(MCH_TP.SYSNOTES, K_SIDESTEP, DbSideStep) StringToLen(value, dValue) m_IsModifiedSideStep = Math.Abs(dValue - DbSideStep) > 5 * EPS_SMALL If GetNonNumericTextBox(m_SideStep) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("SideStep") End If End Set End Property Private m_IsModifiedSpeed As Boolean = False Private m_Speed As String ''' ''' Property that read and write to the tool's database the Speed ''' Public Property Speed As String Get Return m_Speed End Get Set(value As String) m_Speed = value If Not value.Contains("-"c) Then m_CW_IsChecked = True Else m_CCW_IsChecked = True End If ' richiamo funzione che indica il verso di rotazione 'GetModifySpeed(m_Speed) NotifyPropertyChanged(NameOf(CW_IsChecked)) NotifyPropertyChanged(NameOf(CCW_IsChecked)) End Set End Property ' RadioButton per la rotazione positiva Private m_CW_IsChecked As Boolean = False Public Property CW_IsChecked As Boolean Get Return m_CW_IsChecked End Get Set(value As Boolean) ' metto il radiobutton ccw non selezionato m_CCW_IsChecked = False m_CW_IsChecked = value ' controllo se speed contiene il segno '-' se si elimina il il segno '-' If m_CW_IsChecked Then If m_Speed.Contains("-"c) Then Dim m_SpeedTmp As String = m_Speed.Substring(1) m_Speed = m_SpeedTmp NotifyPropertyChanged(NameOf(Speed)) End If Else m_CCW_IsChecked = True End If ' richiamo funzione che indica il verso di rotazione GetModifySpeed(m_Speed) NotifyPropertyChanged(NameOf(CW_IsChecked)) NotifyPropertyChanged(NameOf(CCW_IsChecked)) End Set End Property ' RadioButton per la rotazione negativa Private m_CCW_IsChecked As Boolean = False Public Property CCW_IsChecked As Boolean Get Return m_CCW_IsChecked End Get Set(value As Boolean) ' metto il radiobutton cw non selezionato m_CW_IsChecked = False m_CCW_IsChecked = value ' controllo se speed non contiene il segno '-' se si aggiunge il il segno '-' If m_CCW_IsChecked Then If Not m_Speed.Contains("-"c) Then Dim m_SpeedTmp As String = "-" & m_Speed m_Speed = m_SpeedTmp NotifyPropertyChanged(NameOf(Speed)) End If Else m_CW_IsChecked = True End If ' richiamo funzione che indica il verso di rotazione GetModifySpeed(m_Speed) NotifyPropertyChanged(NameOf(CCW_IsChecked)) NotifyPropertyChanged(NameOf(CW_IsChecked)) End Set End Property ''' ''' Metodo che controlla se la rotazione è stata modificata ''' ''' rotazione Private Sub GetModifySpeed(value As String) Dim DbSpeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.SPEED, DbSpeed) StringToDouble(value, dValue) m_IsModifiedSpeed = Math.Abs(dValue - DbSpeed) > 10 * EPS_ANG_SMALL If Not GetValidationError("Speed") Or GetNonNumericTextBox(m_Speed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If End Sub Private m_IsModifiedSideAng As Boolean = False Private m_SideAng As String ''' ''' Property that read and write to the tool's database the Side Angle ''' Public Property SideAng As String Get Return m_SideAng End Get Set(value As String) If value <> m_SideAng Then m_SideAng = value Dim DbSideAng As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.SIDEANG, DbSideAng) StringToDouble(value, dValue) m_IsModifiedSideAng = Math.Abs(dValue - DbSideAng) > 10 * EPS_ANG_SMALL If GetNonNumericTextBox(m_SideAng) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If NotifyPropertyChanged("SideAng") End If End Set End Property Private m_IsModifiedMaxSpeed As Boolean = False Private m_MaxSpeed As String ''' ''' Property that read and write to the tool's database the Max Speed ''' Public Property MaxSpeed As String Get Return m_MaxSpeed End Get Set(value As String) If value <> m_MaxSpeed Then m_MaxSpeed = value Dim DbMaxSpeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.MAXSPEED, DbMaxSpeed) StringToLen(value, dValue) m_IsModifiedMaxSpeed = Math.Abs(dValue - DbMaxSpeed) > 10 * EPS_ANG_SMALL If Not GetValidationError("Speed") Or GetNonNumericTextBox(m_MaxSpeed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("MaxSpeed") End If End Set End Property Private m_IsModifiedThick As Boolean = False Private m_Thick As String ''' ''' Property that read and write to the tool's database the Thick ''' Public Property Thick As String Get Return m_Thick End Get Set(value As String) If value <> m_Thick Then m_Thick = value Dim DbThick As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.THICK, DbThick) StringToLen(value, dValue) m_IsModifiedThick = Math.Abs(dValue - DbThick) > 5 * EPS_SMALL If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If If Not GetValidationError("Thick") Or Not GetValidationError("CornRad") Or GetNonNumericTextBox(m_Thick) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("Thick") End If End Set End Property Private m_IsModifiedStemDiam As Boolean = False Private m_StemDiam As String ''' ''' Property that read and write to the tool's database the StemDiam ''' Public Property StemDiam As String Get Return m_StemDiam End Get Set(value As String) If value <> m_StemDiam Then m_StemDiam = value Dim DbStemDiam As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.STEMDIAM, DbStemDiam) StringToLen(value, dValue) m_IsModifiedStemDiam = Math.Abs(dValue - DbStemDiam) > 5 * EPS_SMALL If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If If Not GetValidationError("StemDiam") Or GetNonNumericTextBox(m_StemDiam) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("StemDiam") End If End Set End Property Private m_IsModifiedMaxAbsorption As Boolean = False Private m_MaxAbsorption As String ''' ''' Property that read and write to the tool's database the Max Absorption ''' Public Property MaxAbsorption As String Get Return m_MaxAbsorption End Get Set(value As String) If value <> m_MaxAbsorption Then m_MaxAbsorption = value Dim DbMaxAbsorption As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.MAXABSORPTION, DbMaxAbsorption) StringToLen(value, dValue) m_IsModifiedMaxAbsorption = Math.Abs(dValue - DbMaxAbsorption) > 5 * EPS_SMALL If GetNonNumericTextBox(m_MaxAbsorption) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("MaxAbsorption") End If End Set End Property Private m_IsModifiedMinFeed As Boolean = False Private m_MinFeed As String ''' ''' Property that read and write to the tool's database the Min Feed ''' Public Property MinFeed As String Get Return m_MinFeed End Get Set(value As String) If value <> m_MinFeed Then m_MinFeed = value Dim DbMinFeed As Double = 0 Dim dValue As Double = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.MINFEED, DbMinFeed) StringToLen(value, dValue) m_IsModifiedMinFeed = Math.Abs(dValue - DbMinFeed) > 5 * EPS_SMALL If GetNonNumericTextBox(m_MinFeed) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("MinFeed") End If End Set End Property Private m_IsModifiedDraw As Boolean = False Friend m_Draw As String ''' ''' Property that read and write to the tool's database the Draw ''' Public Property Draw As String Get Return m_Draw End Get Set(value As String) If value = String.Empty Or value <> m_Draw Then EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) m_Draw = value Dim DbDraw As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.DRAW, DbDraw) m_IsModifiedDraw = If(value <> DbDraw, True, False) NotifyPropertyChanged("Draw") End If End Set End Property Friend Shared m_OrigHeadList As New List(Of Object) Public ReadOnly Property OrigHeadList As List(Of Object) Get Return m_OrigHeadList End Get End Property Friend m_HeadList As New ObservableCollection(Of Object) Public ReadOnly Property HeadList As ObservableCollection(Of Object) Get Return m_HeadList End Get End Property Private m_IsModifiedSelectedHead As Boolean = False Private m_SelectedHead As Integer = -1 ''' ''' Property that read and write to the tool's database the Head ''' Public Property SelectedHead As Integer Get Return m_SelectedHead End Get Set(value As Integer) If value <> m_SelectedHead Then m_SelectedHead = value If m_SelectedHead <> -1 Then Dim DbHead As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.HEAD, DbHead) m_IsModifiedSelectedHead = ((value < 0 Or value >= m_HeadList.Count) OrElse m_HeadList(value).HName <> DbHead) ' se modificato disattivo l'utensile If m_IsModifiedSelectedHead And Not m_SuspendToolDrawUpdate Then EgtTdbSetCurrToolParam(MCH_TP.ACTIVE, False) If Not m_SuspendToolDrawUpdate Then UpdateSceneToolDraw() End If If Not GetValidationError("SelectedHead") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("SelectedHead") ' verifico se le uscite sono cambiate EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim nExitNum As Integer = EgtGetHeadExitCount(m_HeadList(m_SelectedHead).HName) ' ricalcolo la lista uscite Dim nErr As Integer = 0 Dim bIsValid As Boolean = False If nExitNum > m_ExitList.Count Then For ExitIndex = m_ExitList.Count To nExitNum - 1 EgtLuaSetGlobStringVar("STU.HEAD", m_HeadList(m_SelectedHead).HName) EgtLuaSetGlobIntVar("STU.EXIT", ExitIndex + 1) EgtLuaSetGlobIntVar("STU.TYPE", m_Type) If EgtLuaExistsFunction("STU.IsValidExit") AndAlso EgtLuaCallFunction("STU.IsValidExit") Then 'Leggo variabili EgtLuaGetGlobBoolVar("STU.ISVALID", bIsValid) If Not EgtLuaGetGlobIntVar("STU.ERR", nErr) Then nErr = 999 If nErr = 0 AndAlso bIsValid Then m_ExitList.Add(New IdNameStruct(ExitIndex + 1, (ExitIndex + 1).ToString)) End If Else m_ExitList.Add(New IdNameStruct(ExitIndex + 1, (ExitIndex + 1).ToString)) End If Next ElseIf nExitNum < m_ExitList.Count Then For Index = m_ExitList.Count - 1 To nExitNum Step -1 m_ExitList.RemoveAt(Index) Next End If ' verifico se l'uscita selezionata è nella lista If Not m_ExitList.Count > m_SelectedExit AndAlso m_ExitList.Count > 0 Then SelectedExit = 0 ' m_ExitList(0) End If ' ricalcolo la lista di posizioni valide nErr = 0 bIsValid = False Dim TcPosIndex As Integer = 0 For OrigTcPosIndex = 0 To m_OrigTcPosList.Count - 1 Dim CurrTcPos As String = m_OrigTcPosList(OrigTcPosIndex) bIsValid = False EgtLuaSetGlobStringVar("STU.TCPOS", CurrTcPos) EgtLuaSetGlobStringVar("STU.HEAD", m_HeadList(m_SelectedHead).HName) EgtLuaSetGlobIntVar("STU.TYPE", m_Type) If Not EgtLuaCallFunction("STU.IsValidTcPosFromHead") Then nErr = 999 ' Leggo variabili EgtLuaGetGlobBoolVar("STU.ISVALID", bIsValid) If Not EgtLuaGetGlobIntVar("STU.ERR", nErr) Then nErr = 999 If nErr = 0 AndAlso bIsValid Then If m_TcPosList.Count - 1 >= TcPosIndex AndAlso m_TcPosList(TcPosIndex).Name = CurrTcPos Then TcPosIndex += 1 Else m_TcPosList.Insert(TcPosIndex, New IdNameStruct(TcPosIndex, CurrTcPos)) TcPosIndex += 1 End If Else If m_TcPosList.Count - 1 >= TcPosIndex AndAlso m_TcPosList(TcPosIndex).Name = CurrTcPos Then m_TcPosList.RemoveAt(TcPosIndex) End If End If Next ' quando la lista di posizioni valide è ricaricata non va selezionato nessun TcPos di default SelectedTcPos = -1 NotifyPropertyChanged("ExitList") NotifyPropertyChanged("TcPosList") End If End If End Set End Property ' Variabile che indica se c'è un errore nel nome dell'utensile (ad esempio nome già utilizzato) Dim nErrorToolName As Integer = 0 Friend m_IsModifiedName As Boolean = False ''' ''' Property that read and write to the tool's database the Name ''' Public Property NamePar As String Get Return m_Name End Get Set(value As String) If value = String.Empty Or value <> m_Name Then nErrorToolName = 0 m_Name = value ' Verifico se il nome è diverso da quello nel database e imposto l'apposito flag Dim DbName As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.NAME, DbName) m_IsModifiedName = If(value <> DbName, True, False) ' Verifico che il nuovo nome sia valido Dim sTempName As String = value EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetToolNewName(sTempName) If m_IsModifiedName And Not value = sTempName Then nErrorToolName = 1 End If If Not GetValidationError("NamePar") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged("NamePar") End If End Set End Property Private m_IsModifiedUserNotes As Boolean = False Private m_UserNotes As String ''' ''' Property that read and write to the tool's database the User Notes ''' Public Property UserNotes As String Get Return m_UserNotes End Get Set(value As String) If value = String.Empty Or value <> m_UserNotes Then m_UserNotes = value Dim DbUserNotes As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, DbUserNotes) m_IsModifiedUserNotes = If(value <> DbUserNotes, True, False) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) ' Aggiorno il disegno If Not m_SuspendToolDrawUpdate AndAlso value.Equals(DbUserNotes) Then UpdateSceneToolDraw() NotifyPropertyChanged(NameOf(UserNotes)) End If End Set End Property Friend Shared m_OrigTcPosList As New List(Of String) Public ReadOnly Property OrigTcPosList As List(Of String) Get Return m_OrigTcPosList End Get End Property Friend m_TcPosList As New ObservableCollection(Of Object) Public ReadOnly Property TcPosList As ObservableCollection(Of Object) Get Return m_TcPosList End Get End Property Private m_IsModifiedSelectedTcPos As Boolean = False Private m_SelectedTcPos As Integer = -1 ''' ''' Property that read and write to the tool's database the Tc Pos ''' Public Property SelectedTcPos As Integer Get Return m_SelectedTcPos End Get Set(value As Integer) If value <> m_SelectedTcPos Then If Not IsNothing(TcPosList) Then m_SelectedTcPos = value Dim sDbTcPos As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sDbTcPos) ' DbTcPos = IdNameStruct.IndFromId(DbTcPos, TcPosList) m_IsModifiedSelectedTcPos = ((value < 0 Or value >= m_TcPosList.Count) OrElse m_TcPosList(value).Name <> sDbTcPos) ' se modificato disattivo l'utensile If m_IsModifiedSelectedTcPos And Not m_SuspendToolDrawUpdate Then EgtTdbSetCurrToolParam(MCH_TP.ACTIVE, False) NotifyPropertyChanged("Active") End If m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) NotifyPropertyChanged("SelectedTcPos") End If End If End Set End Property Private m_Uuid As String ''' ''' Property that read and write to the tool's database the Uuid ''' Public ReadOnly Property Uuid As String Get Return m_Uuid End Get End Property Public Property Active As Boolean Get EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' salvo utensile corrente precedente Dim PreviousCurrentTool As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.NAME, PreviousCurrentTool) Dim bChangeTool As Boolean = PreviousCurrentTool <> Me.Name If bChangeTool Then EgtTdbSetCurrTool(Me.Name) Dim bActive As Boolean = False EgtTdbGetCurrToolParam(MCH_TP.ACTIVE, bActive) ' ripristino utensile corrente If bChangeTool Then EgtTdbSetCurrTool(PreviousCurrentTool) Return bActive End Get Set(value As Boolean) EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' verifico se l'utensile selezionato è modificato Dim SelTool As ToolTreeViewItem = m_delGetSelectedTool() If Not IsNothing(SelTool) AndAlso SelTool.IsModified Then ' chiedo di salvare If MessageBox.Show(String.Format(EgtMsg(6144), SelTool.Name), EgtMsg(6143), MessageBoxButton.YesNo, MessageBoxImage.Question) <> MessageBoxResult.Yes Then Return Else SelTool.WriteToolParam() SelTool.m_Name = SelTool.m_Name.Trim() SelTool.WriteToolName() EgtTdbSaveCurrTool() SelTool.NewTool = False SelTool.IsModifiedReset() m_delIsEnabledBtns(SelTool.IsValid And Not SelTool.IsModified, SelTool.IsValid, True) End If End If ' salvo utensile corrente precedente Dim PreviousCurrentTool As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.NAME, PreviousCurrentTool) ' se attivato, verifico definizione TcPos e che non sia in conflitto con altri utensili If value Then ' verifico che la posizione sia definita EgtTdbSetCurrTool(Me.Name) Dim sTcPos As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sTcPos) If String.IsNullOrWhiteSpace(sTcPos) Then ' Posizione non definita! MessageBox.Show(EgtMsg(6146), EgtMsg(6126), MessageBoxButton.OK, MessageBoxImage.Exclamation) ' ripristino utensile corrente EgtTdbSetCurrTool(PreviousCurrentTool) Return End If ' verifico se c'è un utensile con la stessa posizione If Not VerifyAllPositions() Then ' Posizione già occupata! MessageBox.Show(EgtMsg(6145), EgtMsg(6126), MessageBoxButton.OK, MessageBoxImage.Exclamation) ' ripristino utensile corrente EgtTdbSetCurrTool(PreviousCurrentTool) Return End If End If ' lo scrivo nel Db EgtTdbSetCurrTool(Me.Name) EgtTdbSetCurrToolParam(MCH_TP.ACTIVE, value) EgtTdbSaveCurrTool() NotifyPropertyChanged("Active") ' ripristino utensile corrente EgtTdbSetCurrTool(PreviousCurrentTool) End Set End Property Private m_SystemNotes As String ''' ''' Property that read and write to the Tool's database the System Notes ''' Public Property SystemNotes As String Get Return m_SystemNotes End Get Set(value As String) m_SystemNotes = value NotifyPropertyChanged("SystemNotes") End Set End Property ''' ''' Property that read the System Notes visibility ''' Public ReadOnly Property SysNotes_Visibility As Visibility Get If ToolDbWindowVM.m_bVisibleSysNotes Then Return Visibility.Visible Else Return Visibility.Collapsed End If End Get End Property #End Region ' Tool Property #Region "NOTE PROPERTY" ''' ''' Lista delle Note Utente ''' Private m_NotesList As New ObservableCollection(Of NoteListBoxItem) Public Property NotesList As ObservableCollection(Of NoteListBoxItem) Get Return m_NotesList End Get Set(value As ObservableCollection(Of NoteListBoxItem)) m_NotesList = value NotifyPropertyChanged(NameOf(NotesList)) End Set End Property ''' ''' Rende visibile o non visibile la combobox ''' Private m_bComboAddVisibility As Visibility = Visibility.Collapsed Public ReadOnly Property ComboAddVisibility As Visibility Get Return m_bComboAddVisibility End Get End Property Friend Sub SetComboAddVisibility(value As Visibility) m_bComboAddVisibility = value NotifyPropertyChanged(NameOf(ComboAddVisibility)) End Sub ''' ''' Rende visibile o non visibile la groupbox note ''' Private m_bToolNoteVisibility As Visibility = Visibility.Collapsed Public ReadOnly Property ToolNoteVisibility As Visibility Get Return m_bToolNoteVisibility End Get End Property Friend Sub SetToolNoteVisibility(value As Visibility) m_bToolNoteVisibility = value NotifyPropertyChanged(NameOf(ToolNoteVisibility)) End Sub ''' ''' Lista visualizzata nella combobox ''' Private m_NotesListCombo As New ObservableCollection(Of NoteListBoxItem) Public Property NotesListCombo As ObservableCollection(Of NoteListBoxItem) Get Return m_NotesListCombo End Get Set(value As ObservableCollection(Of NoteListBoxItem)) m_NotesListCombo = value NotifyPropertyChanged(NameOf(NotesListCombo)) End Set End Property ''' ''' Valore selezionato dalla combobox ''' Private m_SelNoteItemCombo As NoteListBoxItem Public Property SelNoteItemCombo As NoteListBoxItem Get Return m_SelNoteItemCombo End Get Set(value As NoteListBoxItem) m_SelNoteItemCombo = value ' Recupero Tool selezionato Dim SelTool As ToolTreeViewItem = m_delGetSelectedTool() SetToolNoteVisibility(Visibility.Visible) If Not IsNothing(m_SelNoteItemCombo) Then ' Controllo per la visualizzazione di una textbox o checkbox If m_SelNoteItemCombo.Type.Equals("d") OrElse m_SelNoteItemCombo.Type.Equals("l") OrElse m_SelNoteItemCombo.Type.Equals("s") OrElse m_SelNoteItemCombo.Type.Equals("dr") OrElse m_SelNoteItemCombo.Type.Equals("lr") OrElse m_SelNoteItemCombo.Type.Equals("sr") Then m_SelNoteItemCombo.SelTypeValue = 0 ' Seleziona la TextBox ElseIf m_SelNoteItemCombo.Type.Equals("th") Then m_SelNoteItemCombo.SelTypeValue = 2 ' Seleziona la ComboBox Else m_SelNoteItemCombo.SelTypeValue = 1 ' Seleziona la CheckBox ' Trasformo il valore della checkbox da stringa a booleano m_SelNoteItemCombo.Value = If(m_SelNoteItemCombo.Value = "1", "True", "False") Boolean.Parse(m_SelNoteItemCombo.Value) End If ' Aggiunto alla lista Note il valore selezionato nella combobox For Index As Integer = 0 To m_NotesListCombo.Count - 1 ' Se il valore selezionato dalla combobox e' diverso da quello presente nella lista lo aggiungo If m_NotesList.Count <= 0 OrElse m_NotesList(Index).Description <> m_SelNoteItemCombo.Description Then m_NotesList.Add(m_SelNoteItemCombo) ' Aggiorno il disegno If Not m_SuspendToolDrawUpdate AndAlso m_SelNoteItemCombo.Type.Equals("dr") OrElse m_SelNoteItemCombo.Type.Equals("lr") OrElse m_SelNoteItemCombo.Type.Equals("sr") OrElse m_SelNoteItemCombo.Type.Equals("br") OrElse m_SelNoteItemCombo.Type.Equals("th") Then SelTool.UpdateSceneToolDraw() ' Nascondo la combobox SetComboAddVisibility(Visibility.Collapsed) ' Riabilito pulsante che mostra la combobox SetShowNoteListCombo_IsEnable(True) End If Exit For Next End If ' Rimuovo dalla lista presente nella combobox il valore selezionato m_NotesListCombo.Remove(m_SelNoteItemCombo) ' Rimuovo selezionato m_SelNoteItemCombo = Nothing ' Disabilito pulsante che mostra la combobox If m_NotesListCombo.Count <= 0 Then SetShowNoteListCombo_IsEnable(False) NotifyPropertyChanged(NameOf(NotesList)) NotifyPropertyChanged(NameOf(NotesListCombo)) NotifyPropertyChanged(NameOf(ComboAddVisibility)) NotifyPropertyChanged(NameOf(ToolNoteVisibility)) NotifyPropertyChanged(NameOf(ShowNoteListCombo_IsEnable)) End Set End Property ''' ''' Rende attivo o disattivo il pulsante per visualizzare la combobox ''' Private m_ShowNoteListCombo_IsEnable As Boolean = False Public ReadOnly Property ShowNoteListCombo_IsEnable As Boolean Get Return m_ShowNoteListCombo_IsEnable End Get End Property Friend Sub SetShowNoteListCombo_IsEnable(value As Boolean) m_ShowNoteListCombo_IsEnable = value NotifyPropertyChanged(NameOf(ShowNoteListCombo_IsEnable)) End Sub ''' ''' Gestione visibilita' per pulsante visualizzazione combobox ''' Private m_ShowNoteListCombo_Visibility As Visibility = Visibility.Collapsed Public ReadOnly Property ShowNoteListCombo_Visibility As Visibility Get Return m_ShowNoteListCombo_Visibility End Get End Property Friend Sub SetShowNoteListCombo_Visibility(value As Visibility) m_ShowNoteListCombo_Visibility = value NotifyPropertyChanged(NameOf(ShowNoteListCombo_Visibility)) End Sub ''' ''' Lista THolders ''' Private m_THolders As New ObservableCollection(Of String) Public Property THolders As ObservableCollection(Of String) Get Return m_THolders End Get Set(value As ObservableCollection(Of String)) m_THolders = value NotifyPropertyChanged(NameOf(THolders)) End Set End Property ' Comandi Private m_cmdShowNoteListCombo As ICommand #End Region ' Note Property #Region "Messages" 'Definizione dei messaggi della pagina Public ReadOnly Property CorrTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 51) End Get End Property Public ReadOnly Property ExitParTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 52) End Get End Property Public ReadOnly Property TypeTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 53) End Get End Property Public ReadOnly Property CoolantTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 54) End Get End Property Public ReadOnly Property CornRadTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 55) End Get End Property Public ReadOnly Property DiamTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 56) End Get End Property Public ReadOnly Property TotDiamTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 57) End Get End Property Public ReadOnly Property FeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 58) End Get End Property Public ReadOnly Property EndFeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 59) End Get End Property Public ReadOnly Property StartFeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 60) End Get End Property 'Public ReadOnly Property TipFeedTxBl As String ' Get ' Return EgtMsg(MSG_TOOLSDBPAGE + 61) ' End Get 'End Property Public ReadOnly Property LenTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 62) End Get End Property Public ReadOnly Property TotLenTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 63) End Get End Property Public ReadOnly Property DistTxBl As String Get Return EgtMsg(6079) End Get End Property Public ReadOnly Property MaxMatTxBl As String Get '' Determino il tipo di utensile 'Dim nType As Integer 'EgtTdbGetCurrToolParam(MCH_TP.TYPE, nType) If ToolDbWindowVM.m_MatType = MaterialType.BEAM And (Type And MCH_TF.MILL) <> 0 Then Return EgtMsg(31080) ' Tagliente Else Return EgtMsg(MSG_TOOLSDBPAGE + 64) ' Massimo materiale End If End Get End Property Public ReadOnly Property LonOffsetTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 65) End Get End Property Public ReadOnly Property RadOffsetTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 66) End Get End Property Public ReadOnly Property SpeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 67) End Get End Property Public ReadOnly Property SideAngTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 68) End Get End Property Public ReadOnly Property MaxSpeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 69) End Get End Property Public ReadOnly Property ThickTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 70) End Get End Property Public ReadOnly Property StemDiamTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 81) End Get End Property Public ReadOnly Property MaxAbsorptionTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 71) End Get End Property Public ReadOnly Property MinFeedTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 72) End Get End Property Public ReadOnly Property DrawTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 73) End Get End Property Public ReadOnly Property HeadTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 74) End Get End Property Public ReadOnly Property NameParTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 75) End Get End Property Public ReadOnly Property UserNotesTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 76) End Get End Property Public ReadOnly Property TcPosTxBl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 77) End Get End Property Public ReadOnly Property InvertTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 51) End Get End Property Public ReadOnly Property LeaveTabTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 52) End Get End Property Public ReadOnly Property WorkSideTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 54) End Get End Property Public ReadOnly Property HeadSideTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 55) End Get End Property Public ReadOnly Property LeadInTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 56) End Get End Property Public ReadOnly Property ExtLinkTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 57) End Get End Property Public ReadOnly Property LeadOutTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 58) End Get End Property Public ReadOnly Property CurveUseTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 59) End Get End Property Public ReadOnly Property StepTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 60) End Get End Property Public ReadOnly Property LeadLinkTypeTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90770) ' Collegamento Else Return EgtMsg(MSG_MACHININGDB + 62) ' Tipo approccio End If End Get End Property Public ReadOnly Property InvertToolDirTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 151) End Get End Property Public ReadOnly Property FaceUseTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 152) End Get End Property Public ReadOnly Property InitAngsTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 164) ' Angoli suggeriti End Get End Property Public ReadOnly Property BlockedAxisTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 165) ' Asse bloccato End Get End Property Public ReadOnly Property SolChoiceTypeTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 104) End Get End Property 'Public ReadOnly Property SpeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' Return EgtMsg(90725) ' Rotazione ' Else ' Return EgtMsg(MSG_MACHININGDB + 63) ' Speed ' End If ' End Get 'End Property 'Public ReadOnly Property FeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' Return EgtMsg(90729) ' Avanzamento ' Else ' Return EgtMsg(MSG_MACHININGDB + 64) ' Feed ' End If ' End Get 'End Property 'Public ReadOnly Property StartFeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' Return EgtMsg(90731) ' Ingresso ' Else ' Return EgtMsg(MSG_MACHININGDB + 65) ' Feed iniziale ' End If ' End Get 'End Property 'Public ReadOnly Property EndFeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' Return EgtMsg(90732) ' Uscita ' Else ' Return EgtMsg(MSG_MACHININGDB + 66) ' Feed finale ' End If ' End Get 'End Property 'Public ReadOnly Property BackFeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' Return EgtMsg(90866) ' Ultimo ritorno ' Else ' Return EgtMsg(MSG_MACHININGDB + 166) ' Feed ultimo all'indietro ' End If ' End Get 'End Property Public ReadOnly Property OffSrTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90737) ' Radiale Else Return EgtMsg(MSG_MACHININGDB + 68) ' Offset radiale End If End Get End Property Public ReadOnly Property OffSlTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90736) ' Longitudinale Else Return EgtMsg(MSG_MACHININGDB + 69) ' Offset longitudinale End If End Get End Property Public ReadOnly Property SideAngleTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE And m_Type = MCH_MY.SAWING Then Return EgtMsg(90763) ' Angolo di sbandamento Else Return EgtMsg(MSG_MACHININGDB + 71) ' Angolo di fianco End If End Get End Property Public ReadOnly Property ApproxTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 72) End Get End Property Public ReadOnly Property StartPosTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90768) ' Posizione inizio Else Return EgtMsg(MSG_MACHININGDB + 73) ' Dist. di sicurezza End If End Get End Property Public ReadOnly Property StartSlowLenTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE And m_Type = MCH_MY.DRILLING Then Return EgtMsg(90780) ' Iniziale Else Return EgtMsg(MSG_MACHININGDB + 74) ' Lungh. rallent. iniziale End If End Get End Property Public ReadOnly Property EndSlowLenTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE And m_Type = MCH_MY.DRILLING Then Return EgtMsg(90781) ' Finale Else Return EgtMsg(MSG_MACHININGDB + 75) ' Lungh. rallent. finale End If End Get End Property Public ReadOnly Property ThrouAddLenTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE And m_Type = MCH_MY.DRILLING Then Return EgtMsg(90782) ' Affondamento aggiuntivo Else Return EgtMsg(MSG_MACHININGDB + 76) ' Lungh. passante agg. End If End Get End Property Public ReadOnly Property StepParTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 77) ' Passo End Get End Property Public ReadOnly Property StepBackTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90865) ' Ritorno Else Return EgtMsg(MSG_MACHININGDB + 167) ' Passo all'indietro End If End Get End Property Public ReadOnly Property ReturnPosTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 78) End Get End Property Public ReadOnly Property TabLenTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 79) End Get End Property Public ReadOnly Property TabDistTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 80) End Get End Property Public ReadOnly Property TabHeightTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 81) End Get End Property Public ReadOnly Property TabAngleTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 82) End Get End Property Public ReadOnly Property StepExtArcTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90778) ' Esterno archi Else Return EgtMsg(MSG_MACHININGDB + 93) ' Passo su esterno arco End If End Get End Property Public ReadOnly Property StepIntArcTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90777) ' Interno archi Else Return EgtMsg(MSG_MACHININGDB + 94) ' Passo su interno arco End If End Get End Property Public ReadOnly Property SideStepTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 95) ' Passo di lato End Get End Property Public ReadOnly Property StepSideAngTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90862) ' Inclinato Else Return EgtMsg(MSG_MACHININGDB + 168) ' Passo inclinato End If End Get End Property Public ReadOnly Property StepSideAngBackTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90863) ' Incl. ritorno Else Return EgtMsg(MSG_MACHININGDB + 169) ' Passo all'indietro inclinato End If End Get End Property Public ReadOnly Property VertFeedTxBl As String Get If ToolDbWindowVM.m_MatType = MaterialType.STONE Then Return EgtMsg(90790) ' In verticale Else Return EgtMsg(MSG_MACHININGDB + 96) ' Feed verticale End If End Get End Property 'Public ReadOnly Property NameParTxBl As String ' Get ' Return EgtMsg(MSG_MACHININGDB + 97) ' End Get 'End Property Public ReadOnly Property ToolTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 98) End Get End Property Public ReadOnly Property DepthStrTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 99) End Get End Property 'Public ReadOnly Property UserNotesTxBl As String ' Get ' Return EgtMsg(MSG_MACHININGDB + 100) ' End Get 'End Property Public ReadOnly Property OverLapTxBl As String Get Return EgtMsg(MSG_MACHININGDB + 101) End Get End Property Public ReadOnly Property SubTypeTxBl As String Get If m_Type = MCH_MY.SAWFINISHING Then Return EgtMsg(90861) ' Spatolatura Else Return EgtMsg(MSG_MACHININGDB + 103) ' Sottotipo End If End Get End Property Public ReadOnly Property ForwardAngleTxBl As String Get Return EgtMsg(31370) End Get End Property Public ReadOnly Property ProbingTxBl As String Get Return EgtMsg(90879) ' Abilitazione End Get End Property Public ReadOnly Property ProbingMinDistTxBl As String Get Return EgtMsg(31372) End Get End Property Public ReadOnly Property ProbingMaxDistTxBl As String Get Return EgtMsg(31373) End Get End Property Public ReadOnly Property ExtCornTypeTxBl As String Get Return EgtMsg(31374) End Get End Property Public ReadOnly Property IntCornTypeTxBl As String Get Return EgtMsg(31375) End Get End Property Public ReadOnly Property CornSlowLenTxBl As String Get Return EgtMsg(31376) End Get End Property Public ReadOnly Property CornSlowPercTxBl As String Get Return EgtMsg(31377) End Get End Property Public ReadOnly Property LiHoleTxBl As String Get Return EgtMsg(31378) End Get End Property Public ReadOnly Property LiHoleRadTxBl As String Get Return EgtMsg(31379) End Get End Property Public ReadOnly Property LpTurnsTxBl As String Get Return EgtMsg(31380) End Get End Property Public ReadOnly Property HpTurnsTxBl As String Get Return EgtMsg(31381) End Get End Property Public ReadOnly Property ThicknessFeedTxBl As String Get Return EgtMsg(31070) ' Spessore End Get End Property 'Public ReadOnly Property TipFeedTxBl As String ' Get ' If ToolDbWindowVM.m_MatType = MaterialType.STONE Then ' If m_Type = MCH_MY.WATERJETTING Then ' Return EgtMsg(31201) ' Foratura ' Else ' Return EgtMsg(90730) ' Testa ' End If ' Else ' Return EgtMsg(MSG_MACHININGDB + 67) ' Feed di testa ' End If ' End Get 'End Property Public ReadOnly Property TipFeedTxBl As String Get If m_Type = MCH_TY.WATERJET Then Return EgtMsg(31079) Else Return EgtMsg(MSG_TOOLDB + 61) End If End Get End Property Public ReadOnly Property MaterialMsg As String Get Return EgtMsg(91451) ' Materiale End Get End Property Public ReadOnly Property MinThicknessMsg As String Get Return EgtMsg(91452) ' Spessore minimo End Get End Property Public ReadOnly Property MaxThicknessMsg As String Get Return EgtMsg(91453) ' Spessore massimo End Get End Property Public ReadOnly Property OscillationGpBxLbl As String Get Return EgtMsg(31382) ' Oscillazione End Get End Property Public ReadOnly Property OscHeightTxBl As String Get Return EgtMsg(31383) ' Ampiezza End Get End Property Public ReadOnly Property OscRampLenTxBl As String Get Return EgtMsg(31384) ' Lungh. rampa End Get End Property Public ReadOnly Property OscFlatLenTxBl As String Get Return EgtMsg(31385) ' Lungh. cresta End Get End Property Public ReadOnly Property AcrossTxBl As String Get Return EgtMsg(90861) ' Spatolatura End Get End Property Public ReadOnly Property GenericGpBxLbl As String Get Return EgtMsg(31386) ' Generici End Get End Property Public ReadOnly Property AdvancedGpBxLbl As String Get Return EgtMsg(31387) ' Avanzati End Get End Property Public ReadOnly Property StepGpBxLbl As String Get Return EgtMsg(MSG_MACHININGDB + 77) ' Passo End Get End Property Public ReadOnly Property FeedGpBxLbl As String Get Return EgtMsg(90728) ' Feed End Get End Property Public ReadOnly Property OffsetGpBxLbl As String Get Return EgtMsg(90735) ' Sovramateriale End Get End Property Public ReadOnly Property SlowLenGpBxLbl As String Get Return EgtMsg(90779) ' Lunghezza del rallentamento End Get End Property Public ReadOnly Property OverlapGpBxLbl As String Get Return EgtMsg(90227) ' Sovrapposizione End Get End Property Public ReadOnly Property AnglesGpBxLbl As String Get Return EgtMsg(90880) ' Angoli End Get End Property Public ReadOnly Property ProbingGpBxLbl As String Get Return EgtMsg(90868) ' Tastatura End Get End Property Public ReadOnly Property LeadInTypeGpBxLbl As String Get Return EgtMsg(MSG_MACHININGDB + 56) ' Attacco End Get End Property Public ReadOnly Property LeadOutTypeGpBxLbl As String Get Return EgtMsg(MSG_MACHININGDB + 58) ' Uscita End Get End Property Public ReadOnly Property CurveUseGpBxLbl As String Get Return EgtMsg(MSG_MACHININGDB + 59) ' Uso curve End Get End Property Public ReadOnly Property SpeedGpBxLbl As String Get Return EgtMsg(MSG_TOOLSDBPAGE + 67) ' Rotazione End Get End Property Public ReadOnly Property OvertableGpBxLbl As String Get Return EgtMsg(6080) ' Sovratavola End Get End Property 'Public ReadOnly Property TypeTxBl As String ' Get ' Return EgtMsg(31053) ' Tipo ' End Get 'End Property Public ReadOnly Property LeadTangTxBl As String Get Return EgtMsg(31283) ' Dist. tangente End Get End Property Public ReadOnly Property LeadPerpTxBl As String Get Return EgtMsg(31284) ' Dist. perp. End Get End Property Public ReadOnly Property LeadElevTxBl As String Get Return EgtMsg(31285) ' Elevazione End Get End Property Public ReadOnly Property LeadCompLenTxBl As String Get Return EgtMsg(31286) ' Lungh. correz. End Get End Property Public ReadOnly Property AddLenTxBl As String Get Return EgtMsg(31291) ' Lungh. addiz. End Get End Property Public ReadOnly Property EnableTxBl As String Get Return EgtMsg(31394) ' Abilitazione End Get End Property Public ReadOnly Property SystemNotesTxBl As String Get Return EgtMsg(31398) ' Note di sistema End Get End Property Public ReadOnly Property ToolNotesBxLbl As String Get Return EgtMsg(31705) ' Note Utensile End Get End Property Public ReadOnly Property CWBxLbl As String Get Return EgtMsg(31707) ' Clockwise End Get End Property Public ReadOnly Property CCWBxLbl As String Get Return EgtMsg(31708) ' Counter clockwise End Get End Property #End Region ' Messages ' Definizione comandi Private m_cmdOpenDrawFile As ICommand Private m_cmdAutoDraw As ICommand #Region "Constructors" Sub New(Name As String) MyBase.New(Name) End Sub #End Region ' Constructors #Region "METHODS" Friend Sub ReadToolParamList() Select Case m_Type Case MCH_TF.SAWBLADE m_CoolantList = New ObservableCollection(Of Object)( {New IdNameStruct(MCH_TC.NO, EgtMsg(MSG_COMBOBOXPARAM + 1)), New IdNameStruct(MCH_TC.OUTER, EgtMsg(MSG_COMBOBOXPARAM + 3))}) Case Else m_CoolantList = New ObservableCollection(Of Object)( {New IdNameStruct(MCH_TC.NO, EgtMsg(MSG_COMBOBOXPARAM + 1)), New IdNameStruct(MCH_TC.INNER, EgtMsg(MSG_COMBOBOXPARAM + 2)), New IdNameStruct(MCH_TC.OUTER, EgtMsg(MSG_COMBOBOXPARAM + 3)), New IdNameStruct(MCH_TC.BOTH, EgtMsg(MSG_COMBOBOXPARAM + 4))}) End Select NotifyPropertyChanged("CoolantList") End Sub Friend Sub ReadToolParam() EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' sospendo l'aggiornamento del disegno per evitare di rifarlo al cambio di ogni parametro inerente m_SuspendToolDrawUpdate = True Dim nValue As Integer = 0 Dim dValue As Double = 0 Dim sValue As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.TYPE, nValue) m_Type = nValue m_TypeM = DirectCast(nValue, MCH_TY) NotifyPropertyChanged("Type") m_delNotifyPropertyChanged("ParamPageV") NotifyPropertyChanged("TipFeedTxBl") ReadToolParamList() EgtTdbGetCurrToolParam(MCH_TP.CORR, nValue) m_Corr = nValue.ToString() NotifyPropertyChanged("Corr") m_IsModifiedCorr = False EgtTdbGetCurrToolParam(MCH_TP.COOLANT, nValue) SelCoolant = If(IsNothing(CoolantList), nValue, IdNameStruct.IndFromId(nValue, CoolantList)) NotifyPropertyChanged("Coolant") m_IsModifiedSelCoolant = False EgtTdbGetCurrToolParam(MCH_TP.CORNRAD, dValue) m_CornRad = LenToString(dValue, 4) NotifyPropertyChanged("CornRad") m_IsModifiedCornRad = False EgtTdbGetCurrToolParam(MCH_TP.DIAM, dValue) m_Diam = LenToString(dValue, 4) m_IsModifiedDiam = False EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, dValue) m_TotDiam = LenToString(dValue, 4) m_IsModifiedTotDiam = False ValidateProperty("TotDiam") ValidateProperty("Diam") EgtTdbGetCurrToolParam(MCH_TP.FEED, dValue) m_Feed = LenToString(dValue, 4) NotifyPropertyChanged("Feed") m_IsModifiedFeed = False EgtTdbGetCurrToolParam(MCH_TP.ENDFEED, dValue) m_EndFeed = LenToString(dValue, 4) NotifyPropertyChanged("EndFeed") m_IsModifiedEndFeed = False EgtTdbGetCurrToolParam(MCH_TP.STARTFEED, dValue) m_StartFeed = LenToString(dValue, 4) NotifyPropertyChanged("StartFeed") m_IsModifiedStartFeed = False EgtTdbGetCurrToolParam(MCH_TP.TIPFEED, dValue) m_TipFeed = LenToString(dValue, 4) NotifyPropertyChanged("TipFeed") m_IsModifiedTipFeed = False EgtTdbGetCurrToolParam(MCH_TP.LEN, dValue) m_Len = LenToString(dValue, 4) m_IsModifiedLen = False EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, dValue) m_TotLen = LenToString(dValue, 4) m_IsModifiedTotLen = False EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dValue) m_MaxMat = LenToString(dValue, 4) m_IsModifiedMaxMat = False ValidateProperty("TotLen") ValidateProperty("Len") ValidateProperty("MaxMat") EgtTdbGetCurrToolParam(MCH_TP.DIST, dValue) m_Dist = LenToString(dValue, 4) ValidateProperty("Dist") m_IsModifiedDist = False EgtTdbGetCurrToolParam(MCH_TP.STEMDIAM, dValue) m_StemDiam = LenToString(dValue, 4) ValidateProperty("StemDiam") m_IsModifiedStemDiam = False EgtTdbGetCurrToolParam(MCH_TP.LONOFFSET, dValue) m_LonOffset = LenToString(dValue, 4) NotifyPropertyChanged("LonOffset") m_IsModifiedLonOffset = False EgtTdbGetCurrToolParam(MCH_TP.RADOFFSET, dValue) m_RadOffset = LenToString(dValue, 4) NotifyPropertyChanged("RadOffset") m_IsModifiedRadOffset = False EgtTdbGetCurrToolValInNotes(MCH_TP.SYSNOTES, K_STEPPAR, dValue) m_StepPar = LenToString(dValue, 4) NotifyPropertyChanged("StepPar") m_IsModifiedStepPar = False EgtTdbGetCurrToolValInNotes(MCH_TP.SYSNOTES, K_SIDESTEP, dValue) m_SideStep = LenToString(dValue, 4) NotifyPropertyChanged("SideStep") m_IsModifiedSideStep = False EgtTdbGetCurrToolParam(MCH_TP.SPEED, dValue) m_Speed = DoubleToString(dValue, 4) m_IsModifiedSpeed = False ' Seleziono radiobutton corretto If Not m_Speed.Contains("-"c) Then m_CW_IsChecked = True Else m_CCW_IsChecked = True End If NotifyPropertyChanged(NameOf(CW_IsChecked)) NotifyPropertyChanged(NameOf(CCW_IsChecked)) EgtTdbGetCurrToolParam(MCH_TP.MAXSPEED, dValue) m_MaxSpeed = DoubleToString(dValue, 4) m_IsModifiedMaxSpeed = False ValidateProperty("Speed") NotifyPropertyChanged("MaxSpeed") EgtTdbGetCurrToolParam(MCH_TP.SIDEANG, dValue) m_SideAng = DoubleToString(dValue, 4) NotifyPropertyChanged("SideAng") m_IsModifiedSideAng = False EgtTdbGetCurrToolParam(MCH_TP.THICK, dValue) m_Thick = LenToString(dValue, 4) m_IsModifiedThick = False ValidateProperty("Thick") EgtTdbGetCurrToolParam(MCH_TP.MAXABSORPTION, dValue) m_MaxAbsorption = DoubleToString(dValue, 4) NotifyPropertyChanged("MaxAbsorption") m_IsModifiedMaxAbsorption = False EgtTdbGetCurrToolParam(MCH_TP.MINFEED, dValue) m_MinFeed = LenToString(dValue, 4) NotifyPropertyChanged("MinFeed") m_IsModifiedMinFeed = False EgtTdbGetCurrToolParam(MCH_TP.DRAW, sValue) m_Draw = sValue m_IsModifiedDraw = False ValidateProperty("Draw") EgtTdbGetCurrToolParam(MCH_TP.HEAD, sValue) m_HeadList = New ObservableCollection(Of Object)(OrigHeadList) NotifyPropertyChanged("HeadList") For HeadIndex = 0 To m_HeadList.Count - 1 If sValue = m_HeadList(HeadIndex).HName Then SelectedHead = HeadIndex Exit For End If Next ValidateProperty("SelectedHead") EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nValue) SelectedExit = If(IsNothing(ExitList), nValue, IdNameStruct.IndFromId(nValue, ExitList)) m_IsModifiedSelectedExit = False ValidateProperty("SelectedExit") EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, sValue) m_UserNotes = sValue NotifyPropertyChanged("UserNotes") EgtTdbGetCurrToolParam(MCH_TP.SYSNOTES, sValue) m_SystemNotes = sValue NotifyPropertyChanged("SystemNotes") m_IsModifiedUserNotes = False EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sValue) If TcPosList.Any(Function(n) n.Name = sValue) Then For TcPosIndex = 0 To m_TcPosList.Count - 1 If sValue = m_TcPosList(TcPosIndex).Name Then SelectedTcPos = TcPosIndex m_IsModifiedSelectedTcPos = False Exit For End If Next Else m_SelectedTcPos = -1 EgtTdbSetCurrToolParam(MCH_TP.TCPOS, String.Empty) End If NotifyPropertyChanged("SelectedTcPos") EgtTdbGetCurrToolParam(MCH_TP.UUID, sValue) m_Uuid = sValue ' Carico Note Utensile m_NotesList.Clear() m_NotesListCombo.Clear() m_THolders.Clear() GetNoteList() GetComboNoteList() ' Ora che tutti i parametri sono aggiornati, aggiorno il disegno m_SuspendToolDrawUpdate = False UpdateSceneToolDraw() End Sub Friend Sub ReadToolName() EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.NAME, NamePar) End Sub Friend Sub WriteToolParam() EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) Dim nValue As Integer = 0 Dim dValue As Double = 0 Dim sValue As String = String.Empty Int32.TryParse(Corr, nValue) EgtTdbSetCurrToolParam(MCH_TP.CORR, nValue) nValue = If(IsNothing(ExitList), m_SelectedExit, IdNameStruct.IdFromInd(m_SelectedExit, ExitList)) EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nValue) EgtTdbSetCurrToolParam(MCH_TP.TYPE, Type) nValue = If(IsNothing(CoolantList), m_SelCoolant, IdNameStruct.IdFromInd(m_SelCoolant, CoolantList)) EgtTdbSetCurrToolParam(MCH_TP.COOLANT, nValue) StringToLen(CornRad, dValue) EgtTdbSetCurrToolParam(MCH_TP.CORNRAD, dValue) StringToLen(Diam, dValue) EgtTdbSetCurrToolParam(MCH_TP.DIAM, dValue) StringToLen(TotDiam, dValue) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dValue) StringToLen(Feed, dValue) EgtTdbSetCurrToolParam(MCH_TP.FEED, dValue) StringToLen(EndFeed, dValue) EgtTdbSetCurrToolParam(MCH_TP.ENDFEED, dValue) StringToLen(StartFeed, dValue) EgtTdbSetCurrToolParam(MCH_TP.STARTFEED, dValue) StringToLen(TipFeed, dValue) EgtTdbSetCurrToolParam(MCH_TP.TIPFEED, dValue) StringToLen(Len, dValue) EgtTdbSetCurrToolParam(MCH_TP.LEN, dValue) StringToLen(TotLen, dValue) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dValue) StringToLen(Dist, dValue) EgtTdbSetCurrToolParam(MCH_TP.DIST, dValue) StringToLen(StemDiam, dValue) EgtTdbSetCurrToolParam(MCH_TP.STEMDIAM, dValue) StringToLen(MaxMat, dValue) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dValue) StringToLen(LonOffset, dValue) EgtTdbSetCurrToolParam(MCH_TP.LONOFFSET, dValue) StringToLen(RadOffset, dValue) EgtTdbSetCurrToolParam(MCH_TP.RADOFFSET, dValue) If ToolDbWindowVM.m_MatType = MaterialType.BEAM Then If (m_Type And MCH_TF.MILL) <> 0 Or (m_Type And MCH_TF.SAWBLADE) <> 0 Or (m_Type And MCH_TF.MORTISE) <> 0 Then StringToLen(StepPar, dValue) EgtTdbSetCurrToolValInNotes(MCH_TP.SYSNOTES, K_STEPPAR, dValue) End If If (m_Type And MCH_TF.MILL) <> 0 Then StringToLen(SideStep, dValue) EgtTdbSetCurrToolValInNotes(MCH_TP.SYSNOTES, K_SIDESTEP, dValue) End If End If StringToDouble(Speed, dValue) EgtTdbSetCurrToolParam(MCH_TP.SPEED, dValue) StringToDouble(SideAng, dValue) EgtTdbSetCurrToolParam(MCH_TP.SIDEANG, dValue) StringToDouble(MaxSpeed, dValue) EgtTdbSetCurrToolParam(MCH_TP.MAXSPEED, dValue) StringToLen(Thick, dValue) EgtTdbSetCurrToolParam(MCH_TP.THICK, dValue) StringToDouble(MaxAbsorption, dValue) EgtTdbSetCurrToolParam(MCH_TP.MAXABSORPTION, dValue) StringToLen(MinFeed, dValue) EgtTdbSetCurrToolParam(MCH_TP.MINFEED, dValue) EgtTdbSetCurrToolParam(MCH_TP.DRAW, Draw) EgtTdbSetCurrToolParam(MCH_TP.HEAD, HeadList(SelectedHead).HName) EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, UserNotes) 'If String.IsNullOrEmpty(SelectedTcPos) Then m_SelectedTcPos = String.Empty 'EgtTdbSetCurrToolParam(MCH_TP.TCPOS, m_SelectedTcPos) sValue = If(SelectedTcPos < 0 Or SelectedTcPos >= TcPosList.Count, String.Empty, m_TcPosList(m_SelectedTcPos).Name) EgtTdbSetCurrToolParam(MCH_TP.TCPOS, sValue) ' Scrivo le note utente If m_NotesList.Count > 0 Then WriteToolParamNote() SetComboAddVisibility(Visibility.Collapsed) NotifyPropertyChanged(NameOf(ComboAddVisibility)) End Sub Public Sub WriteToolName() EgtTdbSetCurrToolParam(MCH_TP.NAME, NamePar) End Sub ' funzione che verifica se c'è attivo un utensile sulla stessa posizione Private Function VerifyAllPositions() As Boolean EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' carico posizione, testa e uscita dell'utensile che si attiva EgtTdbSetCurrTool(Me.Name) Dim sCheckedTcPos As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.TCPOS, sCheckedTcPos) Dim sCheckedHead As String = String.Empty EgtTdbGetCurrToolParam(MCH_TP.HEAD, sCheckedHead) Dim nCheckedExit As Integer = 0 EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nCheckedExit) ' verifico su tutti gli utensili disponibili Dim ActiveToolsFamilies() As ToolsFamily = MachineUtility.ReadToolFamilies(ToolDbWindowVM.m_sMachineIniPath) For Each ToolsFamily In ActiveToolsFamilies Dim nType As Integer = 0 Dim ToolName As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) If EgtTdbGetFirstTool(ToolsFamily.Id, ToolName, nType) Then If ToolName <> Me.Name Then EgtTdbSetCurrTool(ToolName) If Not VerifyPosition(sCheckedTcPos, sCheckedHead, nCheckedExit) Then Return False End If While EgtTdbGetNextTool(ToolsFamily.Id, ToolName, nType) If ToolName <> Me.Name Then EgtTdbSetCurrTool(ToolName) If Not VerifyPosition(sCheckedTcPos, sCheckedHead, nCheckedExit) Then Return False End If End While End If Next Return True End Function Private Function VerifyPosition(sCheckedTcPos As String, sCheckedHead As String, nCheckedExit As Integer) As Boolean ' verifico se attivo Dim DbActive As Boolean = False EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) If Not EgtTdbGetCurrToolParam(MCH_TP.ACTIVE, DbActive) Then DbActive = False ' se non è attivo non lo considero e restituisco vero If Not DbActive Then Return True ' recupero posizione Dim DbTcPos As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.TCPOS, DbTcPos) ' se la posizione è uguale controllo la testa If sCheckedTcPos = DbTcPos Then Dim DbHead As String = String.Empty EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.HEAD, DbHead) ' se la testa è uguale, controllo l'uscita If sCheckedHead = DbHead Then Dim DbExit As Integer = 0 EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) EgtTdbGetCurrToolParam(MCH_TP.EXIT_, DbExit) ' se l'uscita è uguale la posizione è già occupata If nCheckedExit = DbExit Then Return False Else ' se la testa è diversa vuol dire che la posizione è già occupata Return False End If End If Return True End Function #Region "Methods Note" ''' ''' Recupero la lista delle Note dal file Note.ini ''' Public Sub GetNoteList() ' Recupero direttorio della macchina corrente Dim sMachDir As String = "" EgtGetCurrMachineDir(sMachDir) ' Recupero ToolHolder dal direttorio THolders m_THolders.Clear() Dim filePaths As String() = Directory.GetFiles(sMachDir & "\" & T_HOLDER) For Each File As String In filePaths m_THolders.Add(Path.GetFileName(File)) Next ' Divido UserNotes in due Array di String Chiave e Valore (anche non presente) EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, m_UserNotes) Dim tmpDsc As New List(Of String) Dim tmpVal As New List(Of String) Dim sSplitNotes() As String = m_UserNotes.TrimEnd(";"c).Split(New Char() {";"c}) For Index As Integer = 0 To sSplitNotes.Count - 1 Dim sKeyVal() As String = sSplitNotes(Index).Trim().Split(New Char() {"="c}) If sKeyVal.Count() >= 1 AndAlso Not String.IsNullOrWhiteSpace(sKeyVal(0)) Then ' Assegno chiave tmpDsc.Add(sKeyVal(0)) ' Assegno valore o indicazione sua mancanza If sKeyVal.Count() >= 2 Then tmpVal.Add(sKeyVal(1)) Else tmpVal.Add("") End If End If Next m_UserNotes = "" ' Recupero le info dal file Notes.ini Dim tmpType As String = m_TypeM.ToString() Dim IndexNote As Integer = 0 Dim sNoteDescription As String = "" While EgtUILib.GetPrivateProfileString(tmpType, IndexNote.ToString(), "", sNoteDescription, sMachDir & "\" & TOOL_NOTES) > 0 Dim sNotes() As String = sNoteDescription.Split(","c) For Index As Integer = 0 To sNotes.Count - 1 sNotes(Index) = sNotes(Index).Trim() Next For IndexNoteUser As Integer = 0 To tmpDsc.Count - 1 ' Aggiungo alla lista NoteList le note presenti nel file ini If tmpDsc(IndexNoteUser) = sNotes(1) Then If Not sNotes(0).Equals("th") Then m_NotesList.Add(New NoteListBoxItem(IndexNote, sNotes(0), sNotes(1), tmpVal(IndexNoteUser))) Else m_NotesList.Add(New NoteListBoxItem(IndexNote, sNotes(0), sNotes(1), m_THolders)) m_NotesList(m_NotesList.Count - 1).SelListValue = tmpVal(IndexNoteUser) End If Exit For End If Next IndexNote += 1 End While ' Assegno alla lista temporanea solo le descrizioni Dim tmpDscList As New ObservableCollection(Of String) For IndN As Integer = 0 To m_NotesList.Count - 1 tmpDscList.Add(m_NotesList(IndN).m_Description) Next For TmpInd As Integer = 0 To tmpDsc.Count - 1 ' Controllo se la lista contiene la stessa descrizione If tmpDscList.Contains(tmpDsc(TmpInd)) Then m_UserNotes &= "" ' Se si la text UserNote rimane vuota ElseIf Not String.IsNullOrEmpty(tmpVal(TmpInd)) Then m_UserNotes &= (tmpDsc(TmpInd) & "=" & tmpVal(TmpInd) & ";").Trim() ' Altrimenti assegno descrizione + valore a UserNote Else m_UserNotes &= (tmpDsc(TmpInd) & ";").Trim() ' Se la lista valori e' vuota assegno solo la descrizione End If Next For Each ItemNote As NoteListBoxItem In m_NotesList ' Controllo per la visualizzazione di una textbox o checkbox If ItemNote.Type.Equals("d") OrElse ItemNote.Type.Equals("l") OrElse ItemNote.Type.Equals("s") OrElse ItemNote.Type.Equals("dr") OrElse ItemNote.Type.Equals("lr") OrElse ItemNote.Type.Equals("sr") Then ItemNote.SelTypeValue = 0 ' Seleziona la TextBox ElseIf ItemNote.Type.Equals("th") Then ItemNote.SelTypeValue = 2 ' Seleziona la ComboBox Else ItemNote.SelTypeValue = 1 ' Seleziona la CheckBox ' Trasformo il valore della checkbox da stringa a booleano ItemNote.Value = If(ItemNote.Value = "1", "True", "False") Boolean.Parse(ItemNote.Value) End If Next SetToolNoteVisibility(If(m_NotesList.Count > 0, Visibility.Visible, Visibility.Collapsed)) NotifyPropertyChanged(NameOf(UserNotes)) NotifyPropertyChanged(NameOf(NotesList)) NotifyPropertyChanged(NameOf(THolders)) NotifyPropertyChanged(NameOf(ToolNoteVisibility)) End Sub ''' ''' Recupero la lista delle Note dal file Note.ini da mostrare nella combobox ''' Public Sub GetComboNoteList() ' Recupero direttorio della macchina corrente Dim sMachDir As String = "" EgtGetCurrMachineDir(sMachDir) ' Recupero le info dal file Notes.ini Dim tmpType As String = m_TypeM.ToString() Dim IndexNote As Integer = 0 Dim sNoteDescription As String = "" Dim tmpsNotes As New ObservableCollection(Of NoteListBoxItem) Dim tmpDsc As New ObservableCollection(Of String) While EgtUILib.GetPrivateProfileString(tmpType, IndexNote.ToString(), "", sNoteDescription, sMachDir & "\" & TOOL_NOTES) > 0 Dim sNotes() As String = Nothing sNotes = sNoteDescription.Split(","c) For Index As Integer = 0 To sNotes.Count - 1 sNotes(Index) = sNotes(Index).Trim() Next 'Assegno valori alla lista temporanea If sNotes.Count < 3 Then tmpsNotes.Add(New NoteListBoxItem(IndexNote, sNotes(0), sNotes(1), "")) ElseIf sNotes(0).Equals("th") Then tmpsNotes.Add(New NoteListBoxItem(IndexNote, sNotes(0), sNotes(1), m_THolders)) Else tmpsNotes.Add(New NoteListBoxItem(IndexNote, sNotes(0), sNotes(1), sNotes(2))) End If tmpDsc.Add(sNotes(1)) IndexNote += 1 End While ' Assegno alla lista temporanea solo le descrizioni Dim tmpDscList As New ObservableCollection(Of String) For IndN As Integer = 0 To m_NotesList.Count - 1 tmpDscList.Add(m_NotesList(IndN).m_Description) Next ' Assegno alla combobox valori non presenti nella NoteList For TmpInd As Integer = 0 To tmpDsc.Count - 1 If Not tmpDscList.Contains(tmpDsc(TmpInd)) Then m_NotesListCombo.Add(tmpsNotes(TmpInd)) End If Next SetShowNoteListCombo_Visibility(Visibility.Visible) SetShowNoteListCombo_IsEnable(If(m_NotesListCombo.Count <= 0, False, True)) NotifyPropertyChanged(NameOf(NotesList)) NotifyPropertyChanged(NameOf(NotesListCombo)) NotifyPropertyChanged(NameOf(SelNoteItemCombo)) NotifyPropertyChanged(NameOf(THolders)) NotifyPropertyChanged(NameOf(ShowNoteListCombo_Visibility)) NotifyPropertyChanged(NameOf(ShowNoteListCombo_IsEnable)) End Sub ''' ''' Scrivo in UserNotes attraverso EgtSetMachiningParam la nota modificata ''' Public Sub WriteToolParamNote() ' Nascondo la combobox SetComboAddVisibility(Visibility.Collapsed) ' Recupero le note con la gestione avanzata Dim sAdvNotes As String = "" For IndexNote As Integer = 0 To m_NotesList.Count - 1 ' Scrivo in MCH_TP.USERNOTES la nota modificata If m_NotesList(IndexNote).Type.Equals("th") Then sAdvNotes &= m_NotesList(IndexNote).Description & "=" & m_NotesList(IndexNote).SelListValue & ";" ElseIf m_NotesList(IndexNote).Type.Equals("b") OrElse m_NotesList(IndexNote).Type.Equals("br") Then sAdvNotes &= m_NotesList(IndexNote).Description & "=" & If(m_NotesList(IndexNote).Value.Equals("True"), "1", "0") & ";" Else sAdvNotes &= m_NotesList(IndexNote).Description & "=" & m_NotesList(IndexNote).Value & ";" End If Next ' Processo le note standard come lista di chiavi-valori Dim tmpDsc = New List(Of String) Dim tmpVal = New List(Of String) Dim sSplitNotes() As String = m_UserNotes.TrimEnd(";"c).Split(New Char() {";"c}) For Index As Integer = 0 To sSplitNotes.Count - 1 Dim sKeyVal() As String = sSplitNotes(Index).Trim().Split(New Char() {"="c}) If sKeyVal.Count() >= 1 AndAlso Not String.IsNullOrWhiteSpace(sKeyVal(0)) Then ' Assegno chiave tmpDsc.Add(sKeyVal(0)) ' Assegno valore o indicazione sua mancanza If sKeyVal.Count() >= 2 Then tmpVal.Add(sKeyVal(1)) Else tmpVal.Add("") End If End If Next ' Assegno le note standard le cui chiavi non siano un duplicato delle descrizioni di quelle avanzate Dim sStdNotes As String = "" For NewInd As Integer = 0 To tmpDsc.Count - 1 ' Verifico se la chiave è presente nelle descrizioni avanzate Dim bAdvDesc As Boolean = False For IndexNote As Integer = 0 To m_NotesList.Count - 1 If m_NotesList(IndexNote).Description.Equals(tmpDsc(NewInd)) Then bAdvDesc = True Exit For End If Next ' Se non presente posso aggiungere If Not bAdvDesc Then If Not String.IsNullOrEmpty(tmpVal(NewInd)) Then sStdNotes &= tmpDsc(NewInd) & "=" & tmpVal(NewInd) & ";" ' Assegno a sUserNotes descrizione + valore Else sStdNotes &= tmpDsc(NewInd) & ";" ' Se non e' presente il valore solo la descrizione End If End If Next m_UserNotes = sStdNotes ' Salvo le note Dim sUserNotes As String = sAdvNotes & sStdNotes EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) NotifyPropertyChanged(NameOf(UserNotes)) NotifyPropertyChanged(NameOf(ComboAddVisibility)) End Sub ''' ''' Rimuove nota dalla lista Note Utente ''' Public Sub RemoveNote(NoteItem As NoteListBoxItem) ' Recupero Tool selezionato 'Dim SelTool As ToolTreeViewItem = m_delGetSelectedTool() ' Rimuovo la nota selezionata dalla lista note utente m_NotesList.Remove(NoteItem) ' Se il pulsante rimuovi nota viene selezionato riaggiungo la nota rimossa alla combobox m_NotesListCombo.Add(NoteItem) ' Nascondo la combobox SetComboAddVisibility(Visibility.Collapsed) ' Riabilito pulsante che mostra la combobox SetShowNoteListCombo_IsEnable(True) SetShowNoteListCombo_Visibility(If(m_NotesListCombo.Count > 0, Visibility.Visible, Visibility.Hidden)) SetToolNoteVisibility(If(m_NotesList.Count > 0, Visibility.Visible, Visibility.Collapsed)) ' Aggiorno il disegno If Not m_SuspendToolDrawUpdate AndAlso NoteItem.Type.Equals("dr") OrElse NoteItem.Type.Equals("lr") OrElse NoteItem.Type.Equals("sr") OrElse NoteItem.Type.Equals("br") OrElse NoteItem.Type.Equals("th") Then UpdateSceneToolDraw() NotifyPropertyChanged(NameOf(NotesList)) NotifyPropertyChanged(NameOf(NotesListCombo)) NotifyPropertyChanged(NameOf(UserNotes)) NotifyPropertyChanged(NameOf(ComboAddVisibility)) NotifyPropertyChanged(NameOf(ToolNoteVisibility)) NotifyPropertyChanged(NameOf(ShowNoteListCombo_IsEnable)) End Sub ''' ''' Aggiorna il colore del pulsante Applica Lavorazioni quando la nota della lista NoteList viene modificata ''' ''' Public Sub IsModifiedNote(NoteItem As NoteListBoxItem) ' Recupero Tool selezionato Dim SelTool As ToolTreeViewItem = m_delGetSelectedTool() If NoteItem.IsModifiedValue Then ' Aggiorno il disegno If Not m_SuspendToolDrawUpdate AndAlso NoteItem.Type.Equals("dr") OrElse NoteItem.Type.Equals("lr") OrElse NoteItem.Type.Equals("sr") OrElse NoteItem.Type.Equals("br") OrElse NoteItem.Type.Equals("th") Then SelTool.UpdateSceneToolDraw() End If End Sub ''' ''' Seleziona il valore di TH dalle Note Utensile ''' ''' Public Sub SelNoteListValue(NoteItem As NoteListBoxItem) ' Recupero Tool selezionato Dim SelTool As ToolTreeViewItem = m_delGetSelectedTool() If Not IsNothing(NoteItem.SelListValue) Then ' Aggiorno il disegno If Not m_SuspendToolDrawUpdate AndAlso NoteItem.Type.Equals("th") Then SelTool.UpdateSceneToolDraw() End If End Sub #End Region ' Methods Note #End Region ' Methods #Region "ToolSceneUpdate" ' Variabili che segnalano errori nel disegno dell'utensile Dim m_nDrawingError As Integer = 0 Friend Sub UpdateSceneToolDraw() ' Azzero errori m_nDrawingError = 0 ' Se nome disegno vuoto, assegno quello dell'automatico If String.IsNullOrEmpty(m_Draw) Then m_Draw = m_Uuid & ".nge" ' Creo il disegno dell'utensile CreateToolDraw() EgtSetCurrentContext(ToolDbWindowVM.m_ToolDbSceneContext) If m_nDrawingError <> 0 Then If IsUUID(Path.GetFileNameWithoutExtension(m_Draw)) Then EgtNewFile() End If End If EgtSetView(VT.TOP, False) EgtZoom(ZM.ALL) NotifyPropertyChanged("Draw") ' Aggiorno interfaccia If Not GetValidationError("Draw") Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If End Sub Private Function CreateToolDraw() As Boolean ' Calcolo parametri per disegno Dim sHeadName As String = If(Not (IsNothing(HeadList) OrElse HeadList.Count = 0) And SelectedHead <> -1 AndAlso Not IsNothing(HeadList(SelectedHead)), HeadList(SelectedHead).HName, "") Dim nExit As Integer = 0 : If Not (IsNothing(ExitList) OrElse ExitList.Count = 0) And SelectedExit <> -1 AndAlso Not IsNothing(ExitList(SelectedExit)) AndAlso Not IsNothing(ExitList(SelectedExit).Name) Then StringToInt(ExitList(SelectedExit).Name, nExit) Dim nType As Integer = Type Dim dTotLen As Double = 0 : StringToLen(TotLen, dTotLen) Dim dLen As Double = 0 : StringToLen(Len, dLen) Dim dTotDiam As Double = 0 : StringToLen(TotDiam, dTotDiam) Dim dDiam As Double = 0 : StringToLen(Diam, dDiam) Dim dThick As Double = 0 : StringToLen(Thick, dThick) Dim dDist As Double = 0 : StringToLen(Dist, dDist) Dim dStemDiam As Double = 0 : StringToLen(StemDiam, dStemDiam) Dim dMaxMat As Double = 0 : StringToLen(MaxMat, dMaxMat) Dim dSideAng As Double = 0 : StringToDouble(SideAng, dSideAng) Dim dCornRad As Double = 0 : StringToLen(CornRad, dCornRad) Dim dSpeed As Double = 0 : StringToDouble(Speed, dSpeed) Dim sUserNotes As String = UserNotes For Each Note As NoteListBoxItem In NotesList If Note.Type.Equals("th") Then sUserNotes &= Note.Description & "=" & Note.SelListValue & ";" Else sUserNotes &= Note.Description & "=" & Note.Value & ";" End If Next Dim sDraw As String = Draw EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' Salvo parametri originali dell'utensile corrente Dim sHeadNameOri As String = "" : EgtTdbGetCurrToolParam(MCH_TP.HEAD, sHeadNameOri) Dim nExitOri As Integer = 0 : EgtTdbGetCurrToolParam(MCH_TP.EXIT_, nExitOri) Dim nTypeOri As Integer = 0 : EgtTdbGetCurrToolParam(MCH_TP.TYPE, nTypeOri) Dim dTotLenOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.TOTLEN, dTotLenOri) Dim dLenOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.LEN, dLenOri) Dim dTotDiamOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.TOTDIAM, dTotDiamOri) Dim dDiamOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.DIAM, dDiamOri) Dim dThickOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.THICK, dThickOri) Dim dDistOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.DIST, dDistOri) Dim dStemDiamOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.STEMDIAM, dStemDiamOri) Dim dMaxMatOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.MAXMAT, dMaxMatOri) Dim dSideAngOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.SIDEANG, dSideAngOri) Dim dCornRadOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.CORNRAD, dCornRadOri) Dim dSpeedOri As Double = 0 : EgtTdbGetCurrToolParam(MCH_TP.SPEED, dSpeedOri) Dim sUserNotesOri As String = "" : EgtTdbGetCurrToolParam(MCH_TP.USERNOTES, sUserNotesOri) Dim sDrawOri As String = "" : EgtTdbGetCurrToolParam(MCH_TP.DRAW, sDrawOri) ' Imposto parametri correnti all'utensile corrente EgtTdbSetCurrToolParam(MCH_TP.HEAD, sHeadName) EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nExit) EgtTdbSetCurrToolParam(MCH_TP.TYPE, nType) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dTotLen) EgtTdbSetCurrToolParam(MCH_TP.LEN, dLen) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dTotDiam) EgtTdbSetCurrToolParam(MCH_TP.DIAM, dDiam) EgtTdbSetCurrToolParam(MCH_TP.THICK, dThick) EgtTdbSetCurrToolParam(MCH_TP.DIST, dDist) EgtTdbSetCurrToolParam(MCH_TP.STEMDIAM, dStemDiam) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dMaxMat) EgtTdbSetCurrToolParam(MCH_TP.SIDEANG, dSideAng) EgtTdbSetCurrToolParam(MCH_TP.CORNRAD, dCornRad) EgtTdbSetCurrToolParam(MCH_TP.SPEED, dSpeed) EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, sUserNotes) EgtTdbSetCurrToolParam(MCH_TP.DRAW, sDraw) ' Creo il disegno m_nDrawingError = EgtTdbCurrToolDraw(ToolDbWindowVM.m_ProjectSceneContext, ToolDbWindowVM.m_ToolDbSceneContext) EgtSetCurrentContext(ToolDbWindowVM.m_ProjectSceneContext) ' Ripristino i valori originali dell'utensile corrente EgtTdbSetCurrToolParam(MCH_TP.HEAD, sHeadNameOri) EgtTdbSetCurrToolParam(MCH_TP.EXIT_, nExitOri) EgtTdbSetCurrToolParam(MCH_TP.TYPE, nTypeOri) EgtTdbSetCurrToolParam(MCH_TP.TOTLEN, dTotLenOri) EgtTdbSetCurrToolParam(MCH_TP.LEN, dLenOri) EgtTdbSetCurrToolParam(MCH_TP.TOTDIAM, dTotDiamOri) EgtTdbSetCurrToolParam(MCH_TP.DIAM, dDiamOri) EgtTdbSetCurrToolParam(MCH_TP.THICK, dThickOri) EgtTdbSetCurrToolParam(MCH_TP.DIST, dDistOri) EgtTdbSetCurrToolParam(MCH_TP.STEMDIAM, dStemDiamOri) EgtTdbSetCurrToolParam(MCH_TP.MAXMAT, dMaxMatOri) EgtTdbSetCurrToolParam(MCH_TP.SIDEANG, dSideAngOri) EgtTdbSetCurrToolParam(MCH_TP.CORNRAD, dCornRadOri) EgtTdbSetCurrToolParam(MCH_TP.SPEED, dSpeedOri) EgtTdbSetCurrToolParam(MCH_TP.USERNOTES, sUserNotesOri) EgtTdbSetCurrToolParam(MCH_TP.DRAW, sDrawOri) Return (m_nDrawingError = 0) End Function #End Region ' ToolSceneUpdate #Region "Validation" Private m_NameError As String Public ReadOnly Property NameErrorMsg As String Get Return m_NameError End Get End Property Private m_SpeedError As String Public ReadOnly Property SpeedErrorMsg As String Get Return m_SpeedError End Get End Property Private m_TotDiamError As String Public ReadOnly Property TotDiamErrorMsg As String Get Return m_TotDiamError End Get End Property Private m_DiamError As String Public ReadOnly Property DiamErrorMsg As String Get Return m_DiamError End Get End Property Private m_CornRadError As String Public ReadOnly Property CornRadErrorMsg As String Get Return m_CornRadError End Get End Property Private m_TotLenError As String Public ReadOnly Property TotLenErrorMsg As String Get Return m_TotLenError End Get End Property Private m_LenError As String Public ReadOnly Property LenErrorMsg As String Get Return m_LenError End Get End Property Private m_DistError As String Public ReadOnly Property DistErrorMsg As String Get Return m_DistError End Get End Property Private m_MaxMatError As String Public ReadOnly Property MaxMatErrorMsg As String Get Return m_MaxMatError End Get End Property Private m_ThickError As String Public ReadOnly Property ThickErrorMsg As String Get Return m_ThickError End Get End Property Private m_StemDiamError As String Public ReadOnly Property StemDiamMsg As String Get Return m_StemDiamError End Get End Property Private m_DrawError As String Public ReadOnly Property DrawErrorMsg As String Get Return m_DrawError End Get End Property Private m_SelectedHeadError As String Public ReadOnly Property SelectedHeadErrorMsg As String Get Return m_SelectedHeadError End Get End Property Private m_SelectedExitError As String Public ReadOnly Property SelectedExitErrorMsg As String Get Return m_SelectedExitError End Get End Property ' Funzione che verifica se una proprietà è valida e attiva/disattiva di conseguenza lista e bottoni Private Sub ValidateProperty(propertyName As String) If Not GetValidationError(propertyName) Then m_delErrorOnTool(True) m_delIsEnabledBtns(False, False, True) Else m_delErrorOnTool(Not IsValid) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid, True) End If NotifyPropertyChanged(propertyName) End Sub Private Function GetValidationError(propertyName As String) As Boolean Dim bOk As Boolean = True Select Case propertyName Case "NamePar" bOk = Me.ValidateName() Case "Speed" bOk = Me.ValidateSpeed() Case "TotDiam" bOk = Me.ValidateTotDiam() Case "CornRad" bOk = Me.ValidateCornRad() Case "Diam" bOk = Me.ValidateDiam() Case "TotLen" bOk = Me.ValidateTotLen() Case "Len" bOk = Me.ValidateLen() Case "MaxMat" bOk = Me.ValidateMaxMat() Case "Thick" bOk = Me.ValidateThick() Case "Dist" bOk = Me.ValidateDist() Case "StemDiam" bOk = Me.ValidateStemDiam() Case "Draw" bOk = Me.ValidateDraw() Case "SelectedHead" bOk = Me.ValidateSelectedHead() Case "SelectedExit" bOk = Me.ValidateSelectedExit() End Select Return bOk End Function ' Funzione che verifica se il valore immesso in una TextBox non è un numero Private Function GetNonNumericTextBox(parameterValue As String) As Boolean Return Not IsNumeric(parameterValue) End Function Private Function GetErrorString(propertyName As String) As String Select Case propertyName Case "NamePar" Return m_NameError Case "Speed" Return m_SpeedError Case "TotDiam" Return m_TotDiamError Case "CornRad" Return m_CornRadError Case "Diam" Return m_DiamError Case "TotLen" Return m_TotLenError Case "Len" Return m_LenError Case "Dist" Return m_DistError Case "MaxMat" Return m_MaxMatError Case "Thick" Return m_ThickError Case "Draw" Return m_DrawError Case "SelectedHead" Return m_SelectedHeadError Case "SelectedExit" Return m_SelectedExitError End Select Return String.Empty End Function ''' ''' Returns true if this object has no validation errors. ''' Public ReadOnly Property IsValid() As Boolean Get For Each [property] As String In ValidatedProperties If Not String.IsNullOrEmpty(GetErrorString([property])) Then Return False End If Next [property] Return True End Get End Property Public ReadOnly Property IsModified() As Boolean Get Return m_IsModifiedCorr OrElse m_IsModifiedSelectedExit OrElse m_IsModifiedCornRad OrElse m_IsModifiedDiam OrElse m_IsModifiedTotDiam OrElse m_IsModifiedFeed OrElse m_IsModifiedEndFeed OrElse m_IsModifiedStartFeed OrElse m_IsModifiedTipFeed OrElse m_IsModifiedLen OrElse m_IsModifiedTotLen OrElse m_IsModifiedMaxMat OrElse m_IsModifiedLonOffset OrElse m_IsModifiedRadOffset OrElse m_IsModifiedSpeed OrElse m_IsModifiedSideAng OrElse m_IsModifiedMaxSpeed OrElse m_IsModifiedThick OrElse m_IsModifiedMaxAbsorption OrElse m_IsModifiedMinFeed OrElse m_IsModifiedDraw OrElse m_IsModifiedSelectedHead OrElse m_IsModifiedName OrElse m_IsModifiedUserNotes OrElse m_IsModifiedSelectedTcPos OrElse m_IsModifiedSelCoolant OrElse m_IsModifiedStepPar OrElse m_IsModifiedSideStep OrElse m_IsModifiedStemDiam End Get End Property Public Sub IsModifiedReset() m_IsModifiedCorr = False m_IsModifiedSelectedExit = False m_IsModifiedCornRad = False m_IsModifiedDiam = False m_IsModifiedTotDiam = False m_IsModifiedFeed = False m_IsModifiedEndFeed = False m_IsModifiedStartFeed = False m_IsModifiedTipFeed = False m_IsModifiedLen = False m_IsModifiedTotLen = False m_IsModifiedMaxMat = False m_IsModifiedLonOffset = False m_IsModifiedRadOffset = False m_IsModifiedSpeed = False m_IsModifiedSideAng = False m_IsModifiedMaxSpeed = False m_IsModifiedThick = False m_IsModifiedMaxAbsorption = False m_IsModifiedMinFeed = False m_IsModifiedDraw = False m_IsModifiedSelectedHead = False m_IsModifiedName = False m_IsModifiedUserNotes = False m_IsModifiedSelectedTcPos = False m_IsModifiedStepPar = False m_IsModifiedSideStep = False m_IsModifiedStemDiam = False End Sub Private Shared ReadOnly ValidatedProperties() As String = {"Draw", "TotDiam", "CornRad", "Diam", "TotLen", "Len", "Dist", "MaxMat", "Thick", "StemDiam", "Speed", "NamePar", "SelectedHead", "SelectedExit"} Private Function ValidateName() As Boolean m_NameError = String.Empty Select Case nErrorToolName Case 1 m_NameError = EgtMsg(MSG_MACHININGDBERRORS + 3) Case 2 m_NameError = EgtMsg(MSG_MACHININGDBERRORS + 4) End Select NotifyPropertyChanged("NameErrorMsg") If String.IsNullOrEmpty(m_NameError) Then Return True Else Return False End If End Function Private Function ValidateSpeed() As Boolean m_SpeedError = String.Empty If Not IsNothing(m_Speed) And Not IsNothing(m_MaxSpeed) Then Dim dSpeed As Double = 0 StringToDouble(m_Speed, dSpeed) Dim dMaxSpeed As Double = 0 StringToDouble(m_MaxSpeed, dMaxSpeed) If Math.Abs(dSpeed) > dMaxSpeed + EPS_ZERO Then m_SpeedError = EgtMsg(MSG_TOOLDBERRORS + 11) End If End If NotifyPropertyChanged("SpeedErrorMsg") If String.IsNullOrEmpty(m_SpeedError) Then Return True Else Return False End If End Function Private Function ValidateTotDiam() As Boolean m_TotDiamError = String.Empty If Not IsNothing(m_TotDiam) Then Dim dTotDiam As Double = 0 StringToLen(m_TotDiam, dTotDiam) If dTotDiam < EPS_SMALL Then m_TotDiamError = EgtMsg(31120) ' Il Diametro Totale deve essere maggiore di 0 End If End If NotifyPropertyChanged("TotDiamErrorMsg") If String.IsNullOrEmpty(m_TotDiamError) Then Return True Else Return False End If End Function Private Function ValidateCornRad() As Boolean m_CornRadError = String.Empty If Not IsNothing(m_CornRad) And Not IsNothing(m_Thick) Then Dim dCornRad As Double = 0 StringToLen(m_CornRad, dCornRad) Dim dThick As Double = 0 StringToLen(m_Thick, dThick) If (m_Type = MCH_TY.SAW_FLAT Or m_Type = MCH_TY.SAW_STD) And dCornRad > 0.5 * dThick Then m_CornRadError = EgtMsg(31135) ' Raggio Corner ha un valore troppo grande End If End If NotifyPropertyChanged("CornRadErrorMsg") Return String.IsNullOrEmpty(m_CornRadError) End Function Private Function ValidateDiam() As Boolean m_DiamError = String.Empty If Not IsNothing(m_Diam) Then Dim dDiam As Double = 0 StringToLen(m_Diam, dDiam) If dDiam < -EPS_SMALL Then m_DiamError = EgtMsg(31109) ' Il Diametro deve essere maggiore di 0 End If If Not IsNothing(m_TotDiam) Then Dim dTotDiam As Double = 0 StringToLen(m_TotDiam, dTotDiam) If dDiam > dTotDiam + EPS_SMALL Then m_DiamError = EgtMsg(31118) ' Il Diametro deve essere minore del Diametro Totale End If End If End If NotifyPropertyChanged("DiamErrorMsg") If String.IsNullOrEmpty(m_DiamError) Then Return True Else Return False End If End Function Private Function ValidateTotLen() As Boolean m_TotLenError = String.Empty If Not IsNothing(m_TotLen) Then Dim dTotLen As Double = 0 StringToLen(m_TotLen, dTotLen) If dTotLen < EPS_SMALL Then m_TotLenError = EgtMsg(MSG_TOOLDBERRORS + 15) End If End If NotifyPropertyChanged("TotLenErrorMsg") If String.IsNullOrEmpty(m_TotLenError) Then Return True Else Return False End If End Function Private Function ValidateLen() As Boolean m_LenError = String.Empty If Not IsNothing(m_Len) Then Dim dLen As Double = 0 StringToLen(m_Len, dLen) If dLen < EPS_SMALL Then m_LenError = EgtMsg(MSG_TOOLDBERRORS + 10) End If If Not IsNothing(m_TotLen) Then Dim dTotLen As Double = 0 StringToLen(m_TotLen, dTotLen) If dLen > dTotLen + EPS_SMALL Then m_LenError = EgtMsg(MSG_TOOLDBERRORS + 13) End If End If End If NotifyPropertyChanged("LenErrorMsg") If String.IsNullOrEmpty(m_LenError) Then Return True Else Return False End If End Function Private Function ValidateDist() As Boolean m_DistError = String.Empty NotifyPropertyChanged("DistErrorMsg") Return String.IsNullOrEmpty(m_DistError) End Function Private Function ValidateMaxMat() As Boolean m_MaxMatError = String.Empty If Not IsNothing(m_MaxMat) Then Dim dMaxMat As Double = 0 StringToLen(m_MaxMat, dMaxMat) ' Non ammesso valore nullo o negativo If dMaxMat < EPS_SMALL Then If ToolDbWindowVM.m_MatType = MaterialType.BEAM And (Type And MCH_TF.MILL) <> 0 Then m_MaxMatError = EgtMsg(31142) ' Il Tagliente deve essere maggiore di 0 Else m_MaxMatError = EgtMsg(31106) ' Il Massimo Materiale deve essere maggiore di 0 End If End If ' Per getto d'acqua If Type = MCH_TF.WATERJET Then ' Non devo fare controlli m_MaxMatError = String.Empty ' Per lame ElseIf (Type And MCH_TF.SAWBLADE) <> 0 Then If Not IsNothing(m_Diam) Then Dim dDiam As Double = 0 StringToLen(m_Diam, dDiam) If dMaxMat > (0.4 * dDiam) + EPS_SMALL Then m_MaxMatError = String.Format(EgtMsg(31117), 0.4 * dDiam) ' Il Massimo Materiale deve essere minore di {0} End If End If ' Per tutti gli altri Else If Not IsNothing(m_Len) Then Dim dLen As Double = 0 StringToLen(m_Len, dLen) If dMaxMat > dLen + EPS_SMALL Then If ToolDbWindowVM.m_MatType = MaterialType.BEAM And (Type And MCH_TF.MILL) <> 0 Then m_MaxMatError = EgtMsg(31143) ' Il Tagliente deve essere minore di Len Else m_MaxMatError = EgtMsg(31107) ' Il Massimo Materiale deve essere minore di Len End If End If End If End If End If NotifyPropertyChanged("MaxMatErrorMsg") If String.IsNullOrEmpty(m_MaxMatError) Then Return True Else Return False End If End Function Private Function ValidateThick() As Boolean m_ThickError = String.Empty If Not IsNothing(m_Thick) Then Dim dThick As Double = 0 StringToLen(m_Thick, dThick) If (m_Type = MCH_TY.SAW_FLAT Or m_Type = MCH_TY.SAW_STD Or m_Type = MCH_TY.MORTISE_STD) And dThick < EPS_SMALL Then m_ThickError = EgtMsg(MSG_TOOLDBERRORS + 8) End If End If NotifyPropertyChanged("ThickErrorMsg") If String.IsNullOrEmpty(m_ThickError) Then Return True Else Return False End If End Function Private Function ValidateStemDiam() As Boolean m_StemDiamError = String.Empty NotifyPropertyChanged("StemDiamErrorMsg") Return String.IsNullOrEmpty(m_StemDiamError) End Function Private Function ValidateDraw() As Boolean m_DrawError = String.Empty If m_nDrawingError = 12 Then m_DrawError = EgtMsg(31121) ' Lunghezza troppo piccola con il portautensile ElseIf m_nDrawingError = 13 Then m_DrawError = EgtMsg(31131) ' Lo Spessore deve essere differente da 0 ElseIf m_nDrawingError = 14 Then m_DrawError = EgtMsg(31132) ' L'Angolo di Lato deve essere minore di 90° ElseIf m_nDrawingError = 15 Then m_DrawError = EgtMsg(31133) ' L'Angolo di Lato deve essere maggiore di -90° ElseIf m_nDrawingError = 16 Then m_DrawError = EgtMsg(31135) ' Raggio Corner ha un valore troppo grande ElseIf m_nDrawingError = 17 Then m_DrawError = EgtMsg(31136) ' Lo Spessore ha un valore troppo piccolo rispetto al Raggio Corner ElseIf m_nDrawingError = 18 Then m_DrawError = EgtMsg(31137) ' Il diametro risultante supera il Diametro Totale ElseIf m_nDrawingError = 19 Then m_DrawError = EgtMsg(31138) ' Il diametro risultante è minore di 0 ElseIf m_nDrawingError = 20 Then m_DrawError = EgtMsg(31139) ' Il diametro stelo risultante è minore o uguale a 0 ElseIf m_nDrawingError = 21 Then m_DrawError = EgtMsg(31140) ' Il Massimo Materiale deve essere più grande del Raggio Corner ElseIf m_nDrawingError = 22 Then m_DrawError = EgtMsg(31134) ' La Lunghezza Totale deve essere maggiore di Lunghezza + Spessore ElseIf m_nDrawingError = 23 Then m_DrawError = EgtMsg(31144) ' Con portautensile flottante TOOL_OVERHANG deve essere maggiore o uguale a Tagliente ElseIf m_nDrawingError = 997 Then m_DrawError = EgtMsg(31103) ' Il file non esiste o non è Nge ElseIf m_nDrawingError = 998 Then m_DrawError = EgtMsg(31104) ' Non esiste il ToolMaker per questo tipo di utensile ElseIf m_nDrawingError <> 0 Then m_DrawError = EgtMsg(31105) ' Impossibile creare l'utensile con questi parametri End If NotifyPropertyChanged("DrawErrorMsg") If String.IsNullOrEmpty(m_DrawError) Then Return True Else Return False End If End Function Private Function ValidateSelectedHead() As Boolean m_SelectedHeadError = String.Empty If IsNothing(m_SelectedHead) Then m_SelectedHeadError = EgtMsg(MSG_TOOLDBERRORS + 27) Else If Not IsNothing(m_HeadList) Then If (m_SelectedHead < 0 Or m_SelectedHead >= m_HeadList.Count) OrElse IsNothing(m_HeadList(m_SelectedHead)) Then m_SelectedHeadError = EgtMsg(MSG_TOOLDBERRORS + 27) End If End If End If NotifyPropertyChanged("SelectedHeadErrorMsg") If String.IsNullOrEmpty(m_SelectedHeadError) Then Return True Else Return False End If End Function Private Function ValidateSelectedExit() As Boolean m_SelectedExitError = String.Empty If IsNothing(m_SelectedExit) Then m_SelectedExitError = EgtMsg(MSG_TOOLDBERRORS + 28) Else If Not IsNothing(m_ExitList) Then If (m_SelectedExit < 0 Or m_SelectedExit >= m_ExitList.Count) OrElse IsNothing(m_ExitList(m_SelectedExit)) Then m_SelectedExitError = EgtMsg(MSG_TOOLDBERRORS + 28) End If End If End If NotifyPropertyChanged("SelectedExitErrorMsg") If String.IsNullOrEmpty(m_SelectedExitError) Then Return True Else Return False End If End Function #End Region ' Validation #Region "COMMANDS" #Region "OpenDrawFileCommand" ''' ''' Returns a command that create a new tool. ''' Public ReadOnly Property OpenDrawFileCommand As ICommand Get If m_cmdOpenDrawFile Is Nothing Then m_cmdOpenDrawFile = New Command(AddressOf OpenDrawFile) End If Return m_cmdOpenDrawFile End Get End Property '''' '''' Creata the new tool. This method is invoked by the NewCommand. '''' 'Public Sub OpenDrawFile(ByVal param As Object) ' Dim OpenFileDialog As New EgtWPFLib5.EgtOpenFileDialog With { ' .Title = "Open draw file", ' .Filter = "*.nge", ' .FileNameFilter = AddressOf FilterFileName, ' .Directory = ToolDbWindowVM.m_sToolDirPath, ' .FileName = m_Draw ' } ' If OpenFileDialog.EgtShowDialog <> True Then Return ' m_Draw = Path.GetFileName(OpenFileDialog.FileName) ' UpdateSceneToolDraw() 'End Sub ''' ''' Creata the new tool. This method is invoked by the NewCommand. ''' Public Sub OpenDrawFile(ByVal param As Object) Dim OpenFileDialog As New Microsoft.Win32.OpenFileDialog() OpenFileDialog.Title = "Open draw file" OpenFileDialog.DefaultExt = ".nge" OpenFileDialog.Filter = "File Nge (.nge)|*.nge" OpenFileDialog.InitialDirectory = ToolDbWindowVM.m_sToolDirPath OpenFileDialog.FileName = m_Draw If OpenFileDialog.ShowDialog <> True Then Return m_Draw = Path.GetFileName(OpenFileDialog.FileName) ' Se il file è preso da una cartella diversa da quella degli utensili viene copiato nella cartella degli utensili Dim sFilePath As String = Path.GetDirectoryName(OpenFileDialog.FileName) If sFilePath <> ToolDbWindowVM.m_sToolDirPath Then File.Copy(OpenFileDialog.FileName, Path.Combine(ToolDbWindowVM.m_sToolDirPath, m_Draw)) End If UpdateSceneToolDraw() End Sub Private Function FilterFileName(sPath As String) As Boolean Dim FileName As String = Path.GetFileNameWithoutExtension(sPath) Return Not IsUUID(FileName) End Function #End Region ' OpenDrawFileCommand #Region "AutoDrawCommand" ''' ''' Returns a command that create a new tool. ''' Public ReadOnly Property AutoDrawCommand As ICommand Get If m_cmdAutoDraw Is Nothing Then m_cmdAutoDraw = New Command(AddressOf AutoDraw) End If Return m_cmdAutoDraw End Get End Property ''' ''' Creata the new tool. This method is invoked by the NewCommand. ''' Public Sub AutoDraw(ByVal param As Object) m_Draw = m_Uuid & ".nge" UpdateSceneToolDraw() End Sub #End Region ' AutoDrawCommand #Region "UpdateNoteCommand" ''' ''' Comando per la visualizzazione della combobox ''' ''' Public ReadOnly Property ShowNoteListComboCommand As ICommand Get If m_cmdShowNoteListCombo Is Nothing Then m_cmdShowNoteListCombo = New Command(AddressOf ShowNoteListCombo) End If Return m_cmdShowNoteListCombo End Get End Property ''' ''' Funzione per la visualizzazione della combobox ''' ''' Public Sub ShowNoteListCombo(ByVal param As Object) ' Rendo visibile la combobox If m_NotesListCombo.Count > 0 Then SetComboAddVisibility(Visibility.Visible) ' Disabilito pulsante che mostra la combobox SetShowNoteListCombo_IsEnable(False) NotifyPropertyChanged(NameOf(NotesListCombo)) NotifyPropertyChanged(NameOf(ComboAddVisibility)) NotifyPropertyChanged(NameOf(ShowNoteListCombo_IsEnable)) End Sub #End Region ' UpdateNoteCommand #End Region ' Commands End Class Public Class HeadItem Private m_HName As String Public ReadOnly Property HName As String Get Return m_HName End Get End Property Private m_HText As String Public ReadOnly Property HText As String Get Return m_HText End Get End Property Sub New(sHName As String, sHText As String) m_HName = sHName m_HText = sHText End Sub End Class ''' ''' Class that represent a Converter that use tool type and param type, to set the visibility state of the param type. ''' Public Class ToolParamVisibilityConverter Implements IValueConverter Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert Select Case CInt(value) Case MCH_TY.NONE Return Visibility.Hidden Case MCH_TY.DRILL_STD Return TMDbParamVisibility.Drill_Std(CInt(parameter)) Case MCH_TY.DRILL_LONG Return TMDbParamVisibility.Drill_Long(CInt(parameter)) Case MCH_TY.SAW_STD Return TMDbParamVisibility.Saw_Std(CInt(parameter)) Case MCH_TY.SAW_FLAT Return TMDbParamVisibility.Saw_Flat(CInt(parameter)) Case MCH_TY.MILL_STD Return TMDbParamVisibility.Mill_Std(CInt(parameter)) Case MCH_TY.MILL_NOTIP Return TMDbParamVisibility.Mill_NoTip(CInt(parameter)) Case MCH_TY.MORTISE_STD Return TMDbParamVisibility.Mortise_Std(CInt(parameter)) Case MCH_TY.CHISEL_STD Return TMDbParamVisibility.Chisel_Std(CInt(parameter)) Case MCH_TY.COMPO Return TMDbParamVisibility.Compo(CInt(parameter)) Case MCH_TY.WATERJET Return TMDbParamVisibility.Waterjet(CInt(parameter)) Case Else Return Visibility.Hidden End Select End Function Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack Throw New NotImplementedException End Function End Class ''' ''' Class that represent a Converter that convert UUID to ***** in Draw param ''' Public Class ToolDrawUUIDConverter Implements IValueConverter Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert If Not IsNothing(value) Then If IsUUID(Path.GetFileNameWithoutExtension(value.ToString)) Then Return ToolDrawUUIDName Else Return value.ToString End If Else Return Nothing End If End Function Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack Return value.ToString End Function End Class