Imports System.Collections.ObjectModel Imports System.ComponentModel Imports System.IO Imports EgtUILib Imports EgtWPFLib5 ''' ''' Class that represent a FamilyMachining in the treeview. ''' It's an element in the treeview that represent a folder, but also a machining family ''' 'Public Class MyFamilyMachiningTreeViewItem ' Inherits FamilyMachiningTreeViewItem ' ' Actions ' Friend Shared m_delIsEnabledBtns As Action(Of Boolean, Boolean, Boolean) ' ''' ' ''' Property that determines if the Machining 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 ' m_delIsEnabledBtns(True, False, False) ' End If ' End If ' End Set ' End Property ' Private m_MachiningType As MCH_MY ' ''' ' ''' Property that determines the machining type of the family ' ''' ' Public Property MachiningType As MCH_MY ' Get ' Return m_MachiningType ' End Get ' Set(value As MCH_MY) ' m_MachiningType = value ' End Set ' End Property ' ' Proprietà che permette di nascondere tutti i parametri di lavorazione grazie al binding ed al converter ' Public ReadOnly Property Type As Integer ' Get ' Return MCH_MY.NONE ' End Get ' End Property ' ''' ' ''' Constructor that receive the name of the FamilyMachiningTreeViewItem, the MachiningType, and set ' ''' the picture(Folder.png) ' ''' ' Sub New(Name As String, MachiningType As MCH_MY) ' MyBase.New(Name) ' Me.MachiningType = MachiningType ' Me.PictureString = "/Resources/TreeView/Folder.png" ' End Sub 'End Class ''' ''' Class that represent a Machining in the treeview. ''' It's an element in the treeview that represent the child of familymachiningtreeviewitem, but also the class that read and write in the machining's database ''' Public Class MyMachiningTreeViewItem Inherits MachiningTreeViewItem #Region "Machining Property" 'ObservableCollection che contiene le variabili per il combobox LeadInType Private m_MaterialList As New ObservableCollection(Of MachiningMaterial) Public Property MaterialList As ObservableCollection(Of MachiningMaterial) Get Return m_MaterialList End Get Set(value As ObservableCollection(Of MachiningMaterial)) m_MaterialList = value End Set End Property Private m_SelMaterial As MachiningMaterial Public Property SelMaterial As MachiningMaterial Get Return m_SelMaterial End Get Set(value As MachiningMaterial) m_SelMaterial = value End Set End Property Private m_IsModifiedSystemNotes As Boolean = False Private m_SystemNotes As String ''' ''' Property that read and write to the Machining's database the User Notes ''' Public Property SystemNotes As String Get Return m_SystemNotes End Get Set(value As String) If value = String.Empty Or value <> m_SystemNotes Then m_SystemNotes = value Dim DbSystemNotes As String = String.Empty EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, DbSystemNotes) m_IsModifiedSystemNotes = If(value <> DbSystemNotes, True, False) m_delIsEnabledBtns(IsValid And Not IsModified, IsValid And (IsModified Or NewMachining), True) End If End Set End Property Private Sub SetSystemNotes() ' Scrivo stringa materiali da lista Dim sMaterialString As String = String.Empty For Each Material In m_MaterialList If Material.MinThickness > 0 Or Material.MaxThickness > 0 Then sMaterialString += Material.nId.ToString & "," & LenToString(Material.MinThickness, 0) & "," & LenToString(Material.MaxThickness, 0) & ";" End If Next SystemNotes = sMaterialString End Sub #End Region ' Machining Property #Region "Constructors" Sub New(Name As String, Type As MCH_MY, IsValisTool As Boolean, Parent As InheritableTreeViewItem) MyBase.New(Name, Type, IsValisTool, Parent) End Sub #End Region ' Constructors #Region "METHODS" Public Overrides Sub ReadMachiningParam() MyBase.ReadMachiningParam() EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, SystemNotes) ' Compilo lista materiali m_MaterialList.Clear() For Each Material In CurrentMachine.Materials m_MaterialList.Add(New MachiningMaterial(Material.nId, Material.sName, AddressOf SetSystemNotes)) Next If m_SystemNotes <> String.Empty Then Dim sItems() = m_SystemNotes.Split(";".ToCharArray) Dim Index As Integer = 0 For Each Material In m_MaterialList Dim Param() As String = sItems(Index).Split(",".ToCharArray) Dim nParId As Integer = 0 If StringToInt(Param(0), nParId) AndAlso nParId = Material.nId Then Dim dVal As Double = 0 StringToLen(Param(1), dVal) Material.SetMinThickness(dVal) StringToLen(Param(2), dVal) Material.SetMaxThickness(dVal) 'Material.bIsActive = True Index += 1 Else 'Material.bIsActive = False End If Next End If NotifyPropertyChanged("MaterialList") End Sub Public Overrides Sub WriteMachiningParam() MyBase.WriteMachiningParam() EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx()) EgtMdbSetCurrMachiningParam(MCH_MP.SYSNOTES, SystemNotes) End Sub #End Region ' Methods #Region "Validation" Public Overrides ReadOnly Property IsModified() As Boolean Get Return MyBase.IsModified OrElse m_IsModifiedSystemNotes End Get End Property Public Overrides Sub IsModifiedReset() MyBase.IsModifiedReset() m_IsModifiedSystemNotes = False End Sub #End Region ' Validation End Class Public Class MachiningMaterial Inherits Material Friend m_refSetSystemNotes As Action Private m_MinThickness As String Public Property MinThickness As String Get Return m_MinThickness End Get Set(value As String) m_MinThickness = value m_refSetSystemNotes() End Set End Property Friend Sub SetMinThickness(value As String) m_MinThickness = value End Sub Private m_MaxThickness As String Public Property MaxThickness As String Get Return m_MaxThickness End Get Set(value As String) m_MaxThickness = value m_refSetSystemNotes() End Set End Property Friend Sub SetMaxThickness(value As String) m_MaxThickness = value End Sub Sub New(nId As Integer, sName As String, refSetSystemNotes As Action) MyBase.New(nId, sName) m_MinThickness = 0 m_MaxThickness = 0 m_refSetSystemNotes = refSetSystemNotes End Sub End Class