0be02be5f7
- modificato TFSEditor
434 lines
18 KiB
VB.net
434 lines
18 KiB
VB.net
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SliderManagerVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Enum ViewSliderType As Integer
|
|
NULL = 0
|
|
FROM_SELECTED = 1
|
|
ONLY_SELECTED = 2
|
|
UNTIL_SELECTED = 3
|
|
End Enum
|
|
|
|
Private m_nLayerIndex As Integer = 0
|
|
Public Property nLayerIndex As Integer
|
|
Get
|
|
Return m_nLayerIndex
|
|
End Get
|
|
Set(value As Integer)
|
|
If IsNothing(Map.refTopPanelVM.SelPart) Then Return
|
|
Select Case m_nSelViewSlider
|
|
Case ViewSliderType.ONLY_SELECTED
|
|
' se diverso da nullo nascondo precedente
|
|
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
|
|
' riporto vecchio strato a visualizzazione di tutti i solidi
|
|
If m_nLayerIndex > 0 Then dLayerAdvancement = 100
|
|
If m_nLayerIndex = 0 Then
|
|
For Each Layer In Map.refTopPanelVM.SelPart.LayerList
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.OFF)
|
|
Next
|
|
ElseIf m_nLayerIndex > 0 Then
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).nLayerId, GDB_ST.OFF)
|
|
End If
|
|
End If
|
|
m_nLayerIndex = value
|
|
' se diverso da nullo visualizzo corrente
|
|
If Not IsNothing(Map.refTopPanelVM.SelPart) AndAlso m_nLayerIndex > 0 Then EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).nLayerId, GDB_ST.ON_)
|
|
' porto barra nuovo strato a 100
|
|
If m_nLayerIndex > 0 Then SetLayerAdvancement(100)
|
|
Case ViewSliderType.UNTIL_SELECTED
|
|
Dim LayerIndex As Integer = If(m_nLayerIndex > 0, m_nLayerIndex, 1)
|
|
If value > m_nLayerIndex Then
|
|
For Index = LayerIndex + 1 To value
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(Index - 1).nLayerId, GDB_ST.ON_)
|
|
Next
|
|
ElseIf value < m_nLayerIndex Then
|
|
For Index = value + 1 To LayerIndex
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(Index - 1).nLayerId, GDB_ST.OFF)
|
|
Next
|
|
End If
|
|
m_nLayerIndex = value
|
|
Case ViewSliderType.FROM_SELECTED
|
|
Dim LayerIndex As Integer = If(m_nLayerIndex > 0, m_nLayerIndex, 1)
|
|
If value > m_nLayerIndex Then
|
|
For Index = LayerIndex To value
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(Index - 1).nLayerId, GDB_ST.OFF)
|
|
Next
|
|
ElseIf value < m_nLayerIndex Then
|
|
For Index = value To LayerIndex
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(Index - 1).nLayerId, GDB_ST.ON_)
|
|
Next
|
|
End If
|
|
m_nLayerIndex = value
|
|
End Select
|
|
NotifyPropertyChanged(NameOf(ghShowValue))
|
|
NotifyPropertyChanged(NameOf(ghValueIndex))
|
|
NotifyPropertyChanged(NameOf(ghValueHeight))
|
|
EgtDraw()
|
|
End Set
|
|
End Property
|
|
Private Sub SetLayerIndex(value As Integer)
|
|
Select Case m_nSelViewSlider
|
|
Case ViewSliderType.ONLY_SELECTED
|
|
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
|
|
' riporto vecchio strato a visualizzazione di tutti i solidi
|
|
If m_nLayerIndex > 0 AndAlso m_nLayerIndex < Map.refTopPanelVM.SelPart.LayerList.Count Then dLayerAdvancement = 100
|
|
For nLayerInd = 0 To Map.refTopPanelVM.SelPart.LayerList.Count - 1
|
|
If nLayerInd = value - 1 Then
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
End If
|
|
m_nLayerIndex = value
|
|
Case ViewSliderType.UNTIL_SELECTED
|
|
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
|
|
' riporto vecchio strato a visualizzazione di tutti i solidi
|
|
If m_nLayerIndex > 0 AndAlso m_nLayerIndex < Map.refTopPanelVM.SelPart.LayerList.Count Then dLayerAdvancement = 100
|
|
For nLayerInd = 0 To Map.refTopPanelVM.SelPart.LayerList.Count - 1
|
|
If nLayerInd <= value - 1 Then
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
End If
|
|
m_nLayerIndex = value
|
|
Case ViewSliderType.FROM_SELECTED
|
|
If Not IsNothing(Map.refTopPanelVM.SelPart) Then
|
|
' riporto vecchio strato a visualizzazione di tutti i solidi
|
|
If m_nLayerIndex > 0 AndAlso m_nLayerIndex < Map.refTopPanelVM.SelPart.LayerList.Count Then dLayerAdvancement = 100
|
|
For nLayerInd = 0 To Map.refTopPanelVM.SelPart.LayerList.Count - 1
|
|
If nLayerInd >= value - 1 Then
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Map.refTopPanelVM.SelPart.LayerList(nLayerInd).nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
End If
|
|
m_nLayerIndex = value
|
|
End Select
|
|
NotifyPropertyChanged(NameOf(nLayerIndex))
|
|
NotifyPropertyChanged(NameOf(ghShowValue))
|
|
NotifyPropertyChanged(NameOf(ghValueIndex))
|
|
NotifyPropertyChanged(NameOf(ghValueHeight))
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Public ReadOnly Property ghShowValue As String
|
|
Get
|
|
Dim dH As Double = 0
|
|
If Not IsNothing(Map.refTopPanelVM.CurrMachining) Then
|
|
If Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45 Then
|
|
Return m_nLayerIndex
|
|
Else
|
|
Return m_nLayerIndex & " (" & DoubleToString(m_nLayerIndex * Map.refTopPanelVM.CurrMachining.dCurrStrandH, 0) & "mm)"
|
|
End If
|
|
Else
|
|
Return m_nLayerIndex
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ghValueIndex As String
|
|
Get
|
|
Return m_nLayerIndex
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ghValueHeight As String
|
|
Get
|
|
If IsNothing(Map.refTopPanelVM.CurrMachining) OrElse
|
|
Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45 OrElse
|
|
Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45_Y Then
|
|
Return ""
|
|
Else
|
|
Return DoubleToString(m_nLayerIndex * Map.refTopPanelVM.CurrMachining.dCurrStrandH, 0)
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ghMaximumIndex As String
|
|
Get
|
|
Return m_nLayerIndex_Maximum
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ghMaximumHeight As String
|
|
Get
|
|
If IsNothing(Map.refTopPanelVM.CurrMachining) OrElse
|
|
Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45 OrElse
|
|
Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45_Y Then
|
|
Return ""
|
|
Else
|
|
Return DoubleToString(m_nLayerIndex_Maximum * Map.refTopPanelVM.CurrMachining.dCurrStrandH, 0)
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Height_Visibility As Visibility
|
|
Get
|
|
If IsNothing(Map.refTopPanelVM.CurrMachining) Then
|
|
Return Visibility.Collapsed
|
|
Else
|
|
Return If(Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45 OrElse
|
|
Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45_Y, Visibility.Collapsed, Visibility.Visible)
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property ghShowMaximum As String
|
|
Get
|
|
If Not IsNothing(Map.refTopPanelVM.CurrMachining) Then
|
|
If Map.refTopPanelVM.CurrMachining.dCurrSlicingType = Machining.MPAR_SLICINGTYPE.DEG45 Then
|
|
Return m_nLayerIndex_Maximum
|
|
Else
|
|
Return m_nLayerIndex_Maximum & " (" & DoubleToString(m_nLayerIndex_Maximum * Map.refTopPanelVM.CurrMachining.dCurrStrandH, 0) & "mm)"
|
|
End If
|
|
Else
|
|
Return m_nLayerIndex_Maximum
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
Private m_dLayerAdvancement As Double
|
|
Public Property dLayerAdvancement As Double
|
|
Get
|
|
Return m_dLayerAdvancement
|
|
End Get
|
|
Set(value As Double)
|
|
Select Case m_nSelViewSlider
|
|
Case ViewSliderType.ONLY_SELECTED
|
|
Dim nTotSolid As Integer = 0
|
|
For Each nLayerId In Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).SolidLayerIdList
|
|
nTotSolid += EgtGetGroupObjs(nLayerId)
|
|
Next
|
|
Dim nTotToolPath As Integer = 0
|
|
For Each nLayerId In Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).ToolPathLayerIdList
|
|
nTotToolPath += EgtGetGroupObjs(nLayerId)
|
|
Next
|
|
Dim nOldSolidAdvancement As Integer = Math.Ceiling(nTotSolid * m_dLayerAdvancement / 100)
|
|
Dim nNewSolidAdvancement As Integer = Math.Ceiling(nTotSolid * value / 100)
|
|
If nNewSolidAdvancement <> nOldSolidAdvancement Then
|
|
Dim nIndex As Integer = 0
|
|
For nSolidLayerIndex = 0 To Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).SolidLayerIdList.Count - 1
|
|
Dim nId As Integer = EgtGetFirstInGroup(Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).SolidLayerIdList(nSolidLayerIndex))
|
|
While nId <> GDB_ID.NULL
|
|
nIndex += 1
|
|
If nIndex <= nNewSolidAdvancement Then
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(nId, GDB_ST.OFF)
|
|
End If
|
|
nId = EgtGetNext(nId)
|
|
End While
|
|
Next
|
|
End If
|
|
Dim nOldToolPathAdvancement As Integer = Math.Ceiling(nTotToolPath * m_dLayerAdvancement / 100)
|
|
Dim nNewToolPathAdvancement As Integer = Math.Ceiling(nTotToolPath * value / 100)
|
|
If nNewToolPathAdvancement <> nOldToolPathAdvancement Then
|
|
Dim nIndex As Integer = 0
|
|
For nToolPathLayerIndex = 0 To Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).ToolPathLayerIdList.Count - 1
|
|
Dim nId As Integer = EgtGetFirstInGroup(Map.refTopPanelVM.SelPart.LayerList(m_nLayerIndex - 1).ToolPathLayerIdList(nToolPathLayerIndex))
|
|
While nId <> GDB_ID.NULL
|
|
nIndex += 1
|
|
If nIndex <= nNewToolPathAdvancement Then
|
|
EgtSetStatus(nId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(nId, GDB_ST.OFF)
|
|
End If
|
|
nId = EgtGetNext(nId)
|
|
End While
|
|
Next
|
|
End If
|
|
m_dLayerAdvancement = value
|
|
End Select
|
|
EgtDraw()
|
|
End Set
|
|
End Property
|
|
Friend Sub SetLayerAdvancement(value As Double)
|
|
m_dLayerAdvancement = value
|
|
NotifyPropertyChanged(NameOf(dLayerAdvancement))
|
|
End Sub
|
|
|
|
Private m_LayerIndex_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property LayerIndex_Visibility As Visibility
|
|
Get
|
|
Return m_LayerIndex_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_LayerIndex_Visibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_LayerAdvancement_Visibility As Visibility = Visibility.Hidden
|
|
Public Property LayerAdvancement_Visibility As Visibility
|
|
Get
|
|
Return m_LayerAdvancement_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_LayerAdvancement_Visibility = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_LayerIndex_IsEnabled As Boolean = True
|
|
Public ReadOnly Property LayerIndex_IsEnabled As Boolean
|
|
Get
|
|
Return m_LayerIndex_IsEnabled
|
|
End Get
|
|
End Property
|
|
Friend Sub SetLayerIndexIsEnabled(value As Boolean)
|
|
m_LayerIndex_IsEnabled = value
|
|
NotifyPropertyChanged(NameOf(LayerIndex_IsEnabled))
|
|
End Sub
|
|
|
|
Private m_LayerAdvancement_IsEnabled As Boolean = True
|
|
Public ReadOnly Property LayerAdvancement_IsEnabled As Boolean
|
|
Get
|
|
Return m_LayerAdvancement_IsEnabled
|
|
End Get
|
|
End Property
|
|
Friend Sub SetLayerAdvancementIsEnabled(value As Boolean)
|
|
m_LayerAdvancement_IsEnabled = value
|
|
NotifyPropertyChanged(NameOf(LayerAdvancement_IsEnabled))
|
|
End Sub
|
|
|
|
Private m_nLayerIndex_TickFrequency As Double
|
|
Public ReadOnly Property nLayerIndex_TickFrequency As Double
|
|
Get
|
|
Return If(m_nLayerIndex_Maximum > 0, m_nLayerIndex_Maximum / 100, m_nLayerIndex_Maximum)
|
|
End Get
|
|
End Property
|
|
|
|
Private m_nLayerIndex_Minimum As Double
|
|
Public Property nLayerIndex_Minimum As Double
|
|
Get
|
|
Return m_nLayerIndex_Minimum
|
|
End Get
|
|
Set(value As Double)
|
|
m_nLayerIndex_Minimum = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nLayerIndex_Maximum As Double
|
|
Public Property nLayerIndex_Maximum As Double
|
|
Get
|
|
Return m_nLayerIndex_Maximum
|
|
End Get
|
|
Set(value As Double)
|
|
m_nLayerIndex_Maximum = value
|
|
NotifyPropertyChanged(NameOf(nLayerIndex_TickFrequency))
|
|
End Set
|
|
End Property
|
|
|
|
Private m_nSelViewSlider As ViewSliderType
|
|
Public Property ghSelViewSlider As Integer
|
|
Get
|
|
Return m_nSelViewSlider - 1
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nSelViewSlider = value + 1
|
|
WriteMainPrivateProfileString(S_PRINTING3D, K_VIEWSLIDER, m_nSelViewSlider)
|
|
' ciclo tutti i layer per nasconderli/mostrarli
|
|
If IsNothing(Map.refTopPanelVM.SelPart) OrElse IsNothing(Map.refTopPanelVM.SelPart.LayerList) Then Return
|
|
Select Case m_nSelViewSlider
|
|
Case ViewSliderType.ONLY_SELECTED
|
|
For Each Layer In Map.refTopPanelVM.SelPart.LayerList
|
|
If Layer.nLayerIndex = m_nLayerIndex Then
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
Case ViewSliderType.UNTIL_SELECTED
|
|
For Each Layer In Map.refTopPanelVM.SelPart.LayerList
|
|
If Layer.nLayerIndex <= m_nLayerIndex Then
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
Case ViewSliderType.FROM_SELECTED
|
|
For Each Layer In Map.refTopPanelVM.SelPart.LayerList
|
|
If Layer.nLayerIndex >= m_nLayerIndex Then
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.ON_)
|
|
Else
|
|
EgtSetStatus(Layer.nLayerId, GDB_ST.OFF)
|
|
End If
|
|
Next
|
|
End Select
|
|
' mostro/nascondo slider orizzontale
|
|
m_LayerAdvancement_Visibility = If(m_nSelViewSlider = ViewSliderType.ONLY_SELECTED, Visibility.Visible, Visibility.Hidden)
|
|
NotifyPropertyChanged(NameOf(LayerAdvancement_Visibility))
|
|
EgtDraw()
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelViewSlider(value As ViewSliderType)
|
|
m_nSelViewSlider = value
|
|
NotifyPropertyChanged(NameOf(ghSelViewSlider))
|
|
End Sub
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefSliderManagerVM(Me)
|
|
' leggo valore default ViewSlider
|
|
Dim nViewSlider As Integer = GetMainPrivateProfileInt(S_PRINTING3D, K_VIEWSLIDER, 1)
|
|
SetSelViewSlider(nViewSlider)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub SetSliderVisibility(bValue As Boolean)
|
|
Dim Visibility As Visibility = If(bValue, Visibility.Visible, Visibility.Collapsed)
|
|
m_LayerIndex_Visibility = Visibility
|
|
NotifyPropertyChanged(NameOf(LayerIndex_Visibility))
|
|
If bValue AndAlso m_nSelViewSlider = ViewSliderType.ONLY_SELECTED Then
|
|
m_LayerAdvancement_Visibility = Visibility.Visible
|
|
ElseIf Not bValue Then
|
|
m_LayerAdvancement_Visibility = Visibility.Hidden
|
|
End If
|
|
NotifyPropertyChanged(NameOf(LayerAdvancement_Visibility))
|
|
End Sub
|
|
|
|
Friend Sub RefreshSlider(nMin As Integer, nMax As Integer)
|
|
m_nLayerIndex_Minimum = nMin
|
|
m_nLayerIndex_Maximum = nMax
|
|
NotifyPropertyChanged(NameOf(nLayerIndex_Minimum))
|
|
NotifyPropertyChanged(NameOf(nLayerIndex_Maximum))
|
|
NotifyPropertyChanged(NameOf(nLayerIndex_TickFrequency))
|
|
NotifyPropertyChanged(NameOf(ghMaximumHeight))
|
|
NotifyPropertyChanged(NameOf(ghMaximumIndex))
|
|
NotifyPropertyChanged(NameOf(Height_Visibility))
|
|
NotifyPropertyChanged(NameOf(ghShowMaximum))
|
|
SetLayerIndex(If(m_nLayerIndex < nMax, m_nLayerIndex, nMax))
|
|
End Sub
|
|
|
|
Friend Sub SetLayerIndexToMax()
|
|
SetLayerIndex(m_nLayerIndex_Maximum)
|
|
NotifyPropertyChanged(NameOf(nLayerIndex))
|
|
End Sub
|
|
|
|
Friend Sub SetLayerIndexToMin()
|
|
SetLayerIndex(m_nLayerIndex_Minimum)
|
|
NotifyPropertyChanged(NameOf(nLayerIndex))
|
|
End Sub
|
|
|
|
Friend Sub SetLayerIndexToZero()
|
|
SetLayerIndex(0)
|
|
NotifyPropertyChanged(NameOf(nLayerIndex))
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|