Imports System.Collections.ObjectModel Imports EgtWPFLib5 Imports EgtUILib Public Class ViewLayerManagerVM Inherits VMBase Private m_LayerList As ObservableCollection(Of ViewLayer) Public ReadOnly Property LayerList As ObservableCollection(Of ViewLayer) Get Return m_LayerList End Get End Property Private m_ViewLayerManager_IsEnabled As Boolean = True Public ReadOnly Property ViewLayerManager_IsEnabled As Boolean Get Return m_ViewLayerManager_IsEnabled End Get End Property Friend Sub SetViewLayerManagerIsEnabled(value As Boolean) m_ViewLayerManager_IsEnabled = value NotifyPropertyChanged(NameOf(ViewLayerManager_IsEnabled)) End Sub Private m_ViewLayerManager_Visibility As Visibility = Visibility.Visible Public ReadOnly Property ViewLayerManager_Visibility As Visibility Get Return m_ViewLayerManager_Visibility End Get End Property Friend Sub SetViewLayerManagerVisibility(value As Boolean) m_ViewLayerManager_Visibility = If(value, Visibility.Visible, Visibility.Collapsed) NotifyPropertyChanged(NameOf(ViewLayerManager_Visibility)) End Sub Sub New() ' Creo riferimento a questa classe in EgtCAM5Map Map.SetRefViewLayerManagerVM(Me) m_LayerList = New ObservableCollection(Of ViewLayer)({New ViewLayer(ViewLayer.ViewLayerType.PRINT_SOLID, "Print", True), New ViewLayer(ViewLayer.ViewLayerType.REFERENCE, "Origin Point", True), New ViewLayer(ViewLayer.ViewLayerType.START_MACHINING, "Layer Start", True), New ViewLayer(ViewLayer.ViewLayerType.RIBS, "Ribs", True), New ViewLayer(ViewLayer.ViewLayerType.SHELL_NUMBER, "Reduce Shell Number", True), New ViewLayer(ViewLayer.ViewLayerType.AUX_SOLIDS, "Filled Solids", True), New ViewLayer(ViewLayer.ViewLayerType.SOLID_SLICE, "Solid Slice", True), New ViewLayer(ViewLayer.ViewLayerType.SLICE_TOOLPATH, "Slice Toolpath", True), New ViewLayer(ViewLayer.ViewLayerType.OTHERS, "Others", True)}) UpdateForced() End Sub Friend Sub ResetSolid() Dim ViewLayerSolid As ViewLayer = m_LayerList.FirstOrDefault(Function(x) x.Type = ViewLayer.ViewLayerType.SOLID_SLICE) If Not IsNothing(ViewLayerSolid) Then ViewLayerSolid.bIsVisible = False If Map.refTopPanelVM.SelPage = Pages.MODIFY Then WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SOLIDSLICE, "0") ElseIf Map.refTopPanelVM.SelPage = Pages.SLICE Then WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SOLIDSLICE, "0") ElseIf Map.refTopPanelVM.SelPage = Pages.NULL Then WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SOLIDSLICE, "0") WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SOLIDSLICE, "0") End If End If End Sub Friend Sub UpdateIsVisibleFromIni() For Each Layer In LayerList Layer.UpdateIsVisibleFromIni() Next EgtDraw() End Sub Friend Sub UpdateForced() For Each Layer In LayerList Layer.UpdateForced() Next EgtDraw() End Sub End Class Public Class ViewLayer Inherits VMBase Enum VisibilityType As Integer OFF = 0 ON_ = 1 FORCED = 2 End Enum Public Enum ViewLayerType As Integer PRINT_SOLID = 1 REFERENCE = 2 START_MACHINING = 3 RIBS = 4 SHELL_NUMBER = 5 AUX_SOLIDS = 6 OTHERS = 7 SOLID_SLICE = 8 SLICE_TOOLPATH = 9 End Enum Private m_Type As ViewLayerType Public ReadOnly Property Type As ViewLayerType Get Return m_Type End Get End Property Private m_sName As String Public ReadOnly Property sName As String Get Return m_sName End Get End Property Private m_IsVisible As VisibilityType Public Property bIsVisible As Boolean? Get Select Case m_IsVisible Case VisibilityType.OFF Return False Case VisibilityType.ON_ Return True Case VisibilityType.FORCED Return Nothing End Select End Get Set(value As Boolean?) If m_IsVisible = VisibilityType.FORCED Then NotifyPropertyChanged(NameOf(bIsVisible)) Return End If m_IsVisible = If(value, VisibilityType.ON_, VisibilityType.OFF) UpdateVisibility(m_IsVisible) WriteIsVisibleToIni() EgtDraw() End Set End Property Friend Sub SetIsVisible(value As Boolean?) bIsVisible = value NotifyPropertyChanged(NameOf(bIsVisible)) End Sub Sub New(Type As ViewLayerType, sName As String, bIsVisible As Boolean) m_Type = Type m_sName = sName m_IsVisible = bIsVisible End Sub Friend Sub UpdateVisibility(bIsVisible As Boolean) ' Disabilito segnalazione modificato Dim DisableMgr As New DisableModifiedMgr ' se solidi If m_Type = ViewLayerType.SOLID_SLICE Then If Map.refSceneHostVM.MainController.GetStep() = 0 Then ' aggiorno parametro di calcolo solidi sui pezzi For Each CurrPart In Map.refTopPanelVM.PartList EgtSetInfo(CurrPart.nPartId, KEY_CALC_SOLIDS, bIsVisible) Next ' lancio calcolo solidi If bIsVisible Then ' mostro barre di caricamento Map.refSliceManagerVM.SetCalcSolid(True) Map.refSliceManagerVM.SetLoadingVisibility(True) ' disabilito ProjManager, TopPanel e uscita dal programma Map.refProjManagerVM.SetProjCmdIsEnabled(False) Map.refTopPanelVM.SetTopPanelIsEnabled(False) Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(False) Map.refTFSEditorVM.SetTFSEditorIsEnabled(False) Map.refSliderManagerVM.SetLayerIndexIsEnabled(False) Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(False) Map.refSliceManagerVM.SetButtonsIsEnabled(False) ExecSolid() ' rileggo i layer con i solidi For Each CurrPart In Map.refTopPanelVM.PartList CurrPart.RefreshPrintLayers() Next ' nascondo barre di caricamento Map.refSliceManagerVM.SetCalcSolid(False) Map.refSliceManagerVM.SetLoadingVisibility(False) ' riabilito ProjManager, TopPanel e uscita dal programma Map.refProjManagerVM.SetProjCmdIsEnabled(True) Map.refTopPanelVM.SetTopPanelIsEnabled(True) Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(True) Map.refTFSEditorVM.SetTFSEditorIsEnabled(True) Map.refSliderManagerVM.SetLayerIndexIsEnabled(True) Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(True) Map.refSliceManagerVM.SetButtonsIsEnabled(True) End If End If End If ' se uno tra solid e toolpath e' attivo, visualizzo gli slider Map.refSliderManagerVM.SetSliderVisibility(Map.refViewLayerManagerVM.LayerList.Any(Function(x) (x.Type = ViewLayerType.SOLID_SLICE OrElse x.Type = ViewLayerType.SLICE_TOOLPATH) AndAlso Not IsNothing(x.bIsVisible) AndAlso x.bIsVisible)) Dim Status As GDB_ST = If(bIsVisible, GDB_ST.ON_, GDB_ST.OFF) For Each CurrPart In Map.refTopPanelVM.PartList Select Case m_Type Case ViewLayerType.PRINT_SOLID EgtSetStatus(CurrPart.nPrintSolidLayerId, Status) Case ViewLayerType.REFERENCE EgtSetStatus(CurrPart.nReferenceId, Status) Case ViewLayerType.START_MACHINING EgtSetStatus(CurrPart.nMachStartLayerId, Status) Case ViewLayerType.RIBS EgtSetStatus(CurrPart.nRibsLayerId, Status) Case ViewLayerType.SHELL_NUMBER EgtSetStatus(CurrPart.nShellNumberLayerId, Status) Case ViewLayerType.AUX_SOLIDS EgtSetStatus(CurrPart.nAuxSolidsLayerId, Status) Case ViewLayerType.SOLID_SLICE For Each Layer In Map.refTopPanelVM.SelPart.LayerList 'EgtSetStatus(Layer.nLayerId, GDB_ST.ON_) For Each Entity In Layer.SolidLayerIdList EgtSetStatus(Entity, Status) Next Next Case ViewLayerType.SLICE_TOOLPATH For Each Layer In Map.refTopPanelVM.SelPart.LayerList 'EgtSetStatus(Layer.nLayerId, GDB_ST.ON_) For Each Entity In Layer.ToolPathLayerIdList EgtSetStatus(Entity, Status) Next Next Case ViewLayerType.OTHERS EgtSetStatus(CurrPart.nOthersLayerId, Status) End Select Next ' se sono in importazione, dis/attivo anche queste superfici If Map.refTopPanelVM.SelPage = Pages.IMPORT Then For Each CurrPart In Map.refManagePartPanelVM.ManagerPartList For Each Layer In CurrPart.LayerList If (Layer.Type = ManagePart_Layer.LayerType.PRINT_SOLID AndAlso m_Type = ViewLayerType.PRINT_SOLID) OrElse (Layer.Type = ManagePart_Layer.LayerType.MACH_START AndAlso m_Type = ViewLayerType.START_MACHINING) OrElse (Layer.Type = ManagePart_Layer.LayerType.RIBS AndAlso m_Type = ViewLayerType.RIBS) OrElse (Layer.Type = ManagePart_Layer.LayerType.SHELL_NUMBER AndAlso m_Type = ViewLayerType.SHELL_NUMBER) OrElse (Layer.Type = ManagePart_Layer.LayerType.AUX_SOLIDS AndAlso m_Type = ViewLayerType.AUX_SOLIDS) OrElse (Layer.Type = ManagePart_Layer.LayerType.OTHERS AndAlso m_Type = ViewLayerType.OTHERS) Then For Each Entity In Layer.EntityList EgtSetStatus(Entity.nId, Status) Next End If Next Next End If ' Ripristino stato segnalazione modifica DisableMgr.ReEnable() End Sub Friend Sub UpdateForced() If Not IsNothing(Map.refTopPanelVM.SelModifyMode) AndAlso ((m_Type = ViewLayerType.REFERENCE AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.REFERENCE) OrElse (m_Type = ViewLayerType.START_MACHINING AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.STARTMACH) OrElse (m_Type = ViewLayerType.RIBS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.RIBS) OrElse (m_Type = ViewLayerType.SHELL_NUMBER AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.SHELLNUMBER) OrElse (m_Type = ViewLayerType.AUX_SOLIDS AndAlso Map.refTopPanelVM.SelModifyMode.ModifyMode = ModifyModes.AUXSOLIDS)) AndAlso m_IsVisible = VisibilityType.OFF Then m_IsVisible = VisibilityType.FORCED UpdateVisibility(True) ElseIf m_IsVisible = VisibilityType.FORCED Then m_IsVisible = VisibilityType.OFF UpdateVisibility(False) End If NotifyPropertyChanged(NameOf(bIsVisible)) End Sub Friend Sub UpdateIsVisibleFromIni() If m_IsVisible = VisibilityType.FORCED Then Return Dim nStatus As Integer = 1 Select Case Map.refTopPanelVM.SelPage Case Pages.MODIFY, Pages.NULL Select Case m_Type Case ViewLayerType.PRINT_SOLID nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_PRINTSOLID, 1) Case ViewLayerType.REFERENCE nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_REFERENCE, 1) Case ViewLayerType.START_MACHINING nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_STARTMACHINING, 1) Case ViewLayerType.RIBS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_RIBS, 1) Case ViewLayerType.SHELL_NUMBER nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_SHELLNUMBER, 1) Case ViewLayerType.AUX_SOLIDS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_AUXSOLIDS, 1) Case ViewLayerType.SOLID_SLICE Dim bSolid As Boolean = False If Not IsNothing(Map.refTopPanelVM.SelPart) Then Dim nIsSolidActive As Integer = 0 EgtGetInfo(Map.refTopPanelVM.SelPart.nPartId, KEY_CALC_SOLIDS, nIsSolidActive) bSolid = nIsSolidActive <> 0 End If nStatus = If(bSolid, GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_SOLIDSLICE, 1), 0) Case ViewLayerType.SLICE_TOOLPATH nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_SLICETOOLPATH, 1) Case ViewLayerType.OTHERS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_MOD_OTHERS, 1) End Select Case Pages.SLICE Select Case m_Type Case ViewLayerType.PRINT_SOLID nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_PRINTSOLID, 1) Case ViewLayerType.REFERENCE nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_REFERENCE, 1) Case ViewLayerType.START_MACHINING nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_STARTMACHINING, 1) Case ViewLayerType.RIBS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_RIBS, 1) Case ViewLayerType.SHELL_NUMBER nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_SHELLNUMBER, 1) Case ViewLayerType.AUX_SOLIDS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_AUXSOLIDS, 1) Case ViewLayerType.SOLID_SLICE nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_SOLIDSLICE, 1) Case ViewLayerType.SLICE_TOOLPATH If Map.refSliceManagerVM.bCalculating AndAlso Map.refSliceManagerVM.bSlice Then nStatus = 1 Else nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_SLICETOOLPATH, 1) End If Case ViewLayerType.OTHERS nStatus = GetMainPrivateProfileInt(S_VIEWLAYER, K_SLC_OTHERS, 1) End Select End Select m_IsVisible = nStatus UpdateVisibility(m_IsVisible) NotifyPropertyChanged(NameOf(bIsVisible)) End Sub Friend Sub WriteIsVisibleToIni() Dim nStatus As Integer = If(m_IsVisible, 1, 0) Select Case Map.refTopPanelVM.SelPage Case Pages.IMPORT, Pages.MODIFY, Pages.MATERIALDB, Pages.MACHININGDB, Pages.CURRMACHINING, Pages.MODIFYPART Select Case m_Type Case ViewLayerType.PRINT_SOLID WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_PRINTSOLID, nStatus) Case ViewLayerType.REFERENCE WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_REFERENCE, nStatus) Case ViewLayerType.START_MACHINING WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_STARTMACHINING, nStatus) Case ViewLayerType.RIBS WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_RIBS, nStatus) Case ViewLayerType.SHELL_NUMBER WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SHELLNUMBER, nStatus) Case ViewLayerType.AUX_SOLIDS WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_AUXSOLIDS, nStatus) Case ViewLayerType.SOLID_SLICE WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SOLIDSLICE, nStatus) Case ViewLayerType.SLICE_TOOLPATH WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_SLICETOOLPATH, nStatus) Case ViewLayerType.OTHERS WriteMainPrivateProfileString(S_VIEWLAYER, K_MOD_OTHERS, nStatus) End Select Case Pages.SLICE Select Case m_Type Case ViewLayerType.PRINT_SOLID WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_PRINTSOLID, nStatus) Case ViewLayerType.REFERENCE WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_REFERENCE, nStatus) Case ViewLayerType.START_MACHINING WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_STARTMACHINING, nStatus) Case ViewLayerType.RIBS WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_RIBS, nStatus) Case ViewLayerType.SHELL_NUMBER WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SHELLNUMBER, nStatus) Case ViewLayerType.AUX_SOLIDS WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_AUXSOLIDS, nStatus) Case ViewLayerType.SOLID_SLICE WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SOLIDSLICE, nStatus) Case ViewLayerType.SLICE_TOOLPATH WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_SLICETOOLPATH, nStatus) Case ViewLayerType.OTHERS WriteMainPrivateProfileString(S_VIEWLAYER, K_SLC_OTHERS, nStatus) End Select End Select End Sub End Class