244 lines
8.3 KiB
VB.net
244 lines
8.3 KiB
VB.net
Imports EgtUILib
|
|
|
|
Public Class MachiningOptionPanelVM
|
|
Inherits ViewModelBase
|
|
|
|
' GRAPHICAL ELEMENTS
|
|
Private m_OperationsListExpander As OperationsListExpanderV
|
|
Public ReadOnly Property OperationsListExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_OperationsListExpander) Then
|
|
m_OperationsListExpander = New OperationsListExpanderV With {
|
|
.DataContext = New OperationsListExpanderVM}
|
|
End If
|
|
Map.refOperationsListExpanderVM.LoadOperationList(GDB_ID.NULL)
|
|
Return m_OperationsListExpander
|
|
End Get
|
|
End Property
|
|
|
|
Private m_OperationParametersExpander As OperationParametersExpanderV
|
|
Public ReadOnly Property OperationParametersExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_OperationParametersExpander) Then
|
|
m_OperationParametersExpander = New OperationParametersExpanderV With {
|
|
.DataContext = New OperationParametersExpanderVM}
|
|
End If
|
|
Return m_OperationParametersExpander
|
|
End Get
|
|
End Property
|
|
|
|
Private m_MachiningsTreeExpander As MachiningTreeExpanderV
|
|
Public ReadOnly Property MachiningsTreeExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_MachiningsTreeExpander) Then
|
|
m_MachiningsTreeExpander = New MachiningTreeExpanderV
|
|
m_MachiningsTreeExpander.DataContext = New MachiningTreeExpanderVM
|
|
End If
|
|
Return m_MachiningsTreeExpander
|
|
End Get
|
|
End Property
|
|
|
|
Private m_SimulationExpander As SimulationExpanderV
|
|
Public ReadOnly Property SimulationExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_SimulationExpander) Then
|
|
m_SimulationExpander = New SimulationExpanderV
|
|
m_SimulationExpander.DataContext = New SimulationExpanderVM
|
|
End If
|
|
Map.refSimulationExpanderVM.Simulation_IsEnabled = True
|
|
Return m_SimulationExpander
|
|
End Get
|
|
End Property
|
|
|
|
Private m_EstimationsExpander As EstimationsExpanderV
|
|
Public ReadOnly Property EstimationsExpander As ContentControl
|
|
Get
|
|
If IsNothing(m_EstimationsExpander) Then
|
|
m_EstimationsExpander = New EstimationsExpanderV
|
|
m_EstimationsExpander.DataContext = New EstimationsExpanderVM
|
|
End If
|
|
Map.refEstimationsExpanderVM.Estimation_IsEnabled =
|
|
(EgtUILib.GetPrivateProfileInt(S_ESTIMATIONS, K_EST_ENABLE, 0, IniFile.m_sCurrMachIniFilePath) <> 0)
|
|
Return m_EstimationsExpander
|
|
End Get
|
|
End Property
|
|
|
|
'Expander aperto tra quelli presenti nel MachiningOptionPanel
|
|
Friend Enum MachiningOptionPanelExpander
|
|
NONE
|
|
OPERATIONLIST
|
|
OPERATIONPARAMETERS
|
|
NEWMACHININGS
|
|
SIMULATION
|
|
ESTIMATIONS
|
|
End Enum
|
|
|
|
Friend Sub Set_IsExpanded(exp As MachiningOptionPanelExpander, flag As Boolean)
|
|
If flag Then
|
|
OpenExpander = exp
|
|
Else
|
|
' se il flag passato è False vuol dire che nessun Expander è attualmente aperto
|
|
OpenExpander = MachiningOptionPanelExpander.NONE
|
|
End If
|
|
End Sub
|
|
|
|
Private m_OpenExpander As Integer = MachiningOptionPanelExpander.OPERATIONLIST
|
|
Public Property OpenExpander As Integer
|
|
Get
|
|
Return m_OpenExpander
|
|
End Get
|
|
Set(value As Integer)
|
|
Dim bOk As Boolean = False
|
|
' Esco dallo stato corrente
|
|
Select Case m_OpenExpander
|
|
Case MachiningOptionPanelExpander.OPERATIONLIST
|
|
bOk = Map.refOperationsListExpanderVM.ExitOperationsList()
|
|
Case MachiningOptionPanelExpander.OPERATIONPARAMETERS
|
|
bOk = Map.refOperationParametersExpanderVM.ExitOperationParameters()
|
|
Case MachiningOptionPanelExpander.NEWMACHININGS
|
|
bOk = Map.refOperationsListExpanderVM.ExitOperationsList()
|
|
bOk = Map.refMachiningTreeExpanderVM.ExitMachiningTreeExpander()
|
|
Case MachiningOptionPanelExpander.SIMULATION
|
|
bOk = Map.refSimulationExpanderVM.ExitSimulation()
|
|
Case MachiningOptionPanelExpander.ESTIMATIONS
|
|
bOk = Map.refEstimationsExpanderVM.ExitEstimations()
|
|
Case MachiningOptionPanelExpander.NONE
|
|
bOk = True
|
|
End Select
|
|
If bOk Then
|
|
' Entro nel nuovo stato
|
|
m_OpenExpander = value
|
|
Select Case m_OpenExpander
|
|
Case MachiningOptionPanelExpander.OPERATIONLIST
|
|
Map.refOperationsListExpanderVM.InitOperationsList()
|
|
Case MachiningOptionPanelExpander.OPERATIONPARAMETERS
|
|
Map.refOperationParametersExpanderVM.InitOperationParameters()
|
|
Case MachiningOptionPanelExpander.NEWMACHININGS
|
|
Map.refOperationsListExpanderVM.InitOperationsList()
|
|
Map.refMachiningTreeExpanderVM.InitMachiningTreeExpander()
|
|
Case MachiningOptionPanelExpander.SIMULATION
|
|
Map.refSimulationExpanderVM.InitSimulation()
|
|
Case MachiningOptionPanelExpander.ESTIMATIONS
|
|
Map.refEstimationsExpanderVM.InitEstimations()
|
|
End Select
|
|
OnPropertyChanged("OpenExpander")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property GenerateIsEnabled As Boolean
|
|
Get
|
|
Return Not Map.refSimulationExpanderVM.Simulation_IsExpanded
|
|
End Get
|
|
End Property
|
|
|
|
Private m_OperationsListRowIsExpanded As Boolean = True
|
|
Public ReadOnly Property OperationsListRowIsExpanded As Boolean
|
|
Get
|
|
Return m_OperationsListRowIsExpanded
|
|
End Get
|
|
End Property
|
|
Friend Sub SetOperationsListRowIsExpanded(value As Boolean)
|
|
m_OperationsListRowIsExpanded = value
|
|
OnPropertyChanged("OperationsListRowIsExpanded")
|
|
End Sub
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property GenerateMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 30) 'GENERA
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in Map
|
|
Map.SetRefMachiningOptionPanelVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Function InitMachiningOptionPanel() As Boolean
|
|
'EgtZoom(ZM.ALL)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ExitMachiningOptionPanel() As Boolean
|
|
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
' Definizione comandi
|
|
Private m_cmdGenerate As ICommand
|
|
|
|
#Region "GenerateCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property GenerateCommand As ICommand
|
|
Get
|
|
If m_cmdGenerate Is Nothing Then
|
|
m_cmdGenerate = New RelayCommand(AddressOf Generate)
|
|
End If
|
|
Return m_cmdGenerate
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub Generate(ByVal param As Object)
|
|
Map.refSimulationExpanderVM.Generate(param)
|
|
End Sub
|
|
|
|
#End Region ' GenerateCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
#Region "DEPENCY PROPERTY"
|
|
|
|
Public Shared ReadOnly IsExpandedProperty As DependencyProperty =
|
|
DependencyProperty.RegisterAttached(
|
|
"IsExpanded",
|
|
GetType(Boolean),
|
|
GetType(MachiningOptionPanelVM),
|
|
New PropertyMetadata(True, AddressOf OnIsExpandedChanged)
|
|
)
|
|
|
|
Public Shared Sub SetIsExpanded(element As DependencyObject, value As Boolean)
|
|
element.SetValue(IsExpandedProperty, value)
|
|
End Sub
|
|
|
|
Public Shared Function GetIsExpanded(element As DependencyObject) As Boolean
|
|
Return CType(element.GetValue(IsExpandedProperty), Boolean)
|
|
End Function
|
|
|
|
Private Shared Sub OnIsExpandedChanged(d As DependencyObject, e As DependencyPropertyChangedEventArgs)
|
|
Dim row As RowDefinition = TryCast(d, RowDefinition)
|
|
If IsNothing(row) Then Return
|
|
|
|
Dim isExpanded As Boolean = CBool(e.NewValue)
|
|
|
|
If Not isExpanded Then
|
|
row.ClearValue(RowDefinition.HeightProperty)
|
|
|
|
row.Height = New GridLength(1, GridUnitType.Auto)
|
|
Else
|
|
row.Height = New GridLength(350)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Depency Property
|
|
|
|
End Class |