Files
2025-03-27 16:20:24 +01:00

298 lines
9.2 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Public Class MachiningOpListBoxItem
Inherits OperationListBoxItem
Friend Event m_ModifyNameGetFocus()
Private m_Status As Boolean
Public Property Status As Boolean
Get
Return m_Status
End Get
Set(value As Boolean)
If value <> m_Status Then
If m_Type = MCH_OY.NONE Or m_Type = MCH_OY.DISP Then
m_Status = True
Else
m_Status = value
' Recupero l'indice dell'operazione a cui abbiamo appena modificato lo Status e l'indice della Disposizione che la contiene
Dim DispIndex As Integer = 0
Dim OpIndex As Integer = 0
For Each OpItem In Map.refOperationsListExpanderVM.OperationList
If EgtGetOperationType(OpItem.Id) = MCH_OY.DISP Then DispIndex = OpIndex
If OpItem.Id = Id Then
Exit For
End If
OpIndex += 1
Next
' Notifico StatusAll per calcolare lo stato della CheckBox della Disposizione
Map.refOperationsListExpanderVM.OperationList(DispIndex).NotifyPropertyChanged(NameOf(DispositionOpListBoxItem.StatusAll))
EgtSetOperationMode(Id, m_Status)
EgtDraw()
End If
NotifyPropertyChanged(NameOf(Status))
End If
End Set
End Property
Private m_Image As String
Public Property Image As String
Get
Return m_Image
End Get
Set(value As String)
m_Image = value
End Set
End Property
Private m_Info As String
Public Property Info As String
Get
Return m_Info
End Get
Set(value As String)
m_Info = value
End Set
End Property
Private m_Tool As String
Public Property Tool As String
Get
Return m_Tool
End Get
Set(value As String)
m_Tool = value
End Set
End Property
Private m_LibMach As String
Public ReadOnly Property LibMach As String
Get
Return m_LibMach
End Get
End Property
Private m_ModifiedName As String
Public Property ModifiedName As String
Get
Return m_ModifiedName
End Get
Set(value As String)
m_ModifiedName = value
End Set
End Property
Private m_ModifyNameOk As Boolean = False
Private m_IsActive_ModifyName As Boolean
Public Property IsActive_ModifyName As Boolean
Get
Return m_IsActive_ModifyName
End Get
Set(value As Boolean)
m_IsActive_ModifyName = value
' se attivo modifica nome
If m_IsActive_ModifyName Then
' imposto il nome originale
m_ModifiedName = Name
' do il focus al nome
RaiseEvent m_ModifyNameGetFocus()
' se esco da modifica
End If
NotifyPropertyChanged("ModifiedName")
NotifyPropertyChanged("Name")
NotifyPropertyChanged("Name_Visibility")
NotifyPropertyChanged("ModifyName_Visibility")
End Set
End Property
Public ReadOnly Property Name_Visibility As Visibility
Get
Return If(Not m_IsActive_ModifyName, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property ModifyName_Visibility As Visibility
Get
Return If(m_IsActive_ModifyName, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property SelectedName As String
Get
Return Name
End Get
End Property
Private m_bOnOff As Boolean = True
Public Property OnOff As Boolean
Get
Return m_bOnOff
End Get
Set(value As Boolean)
If m_bOnOff <> value Then
m_bOnOff = value
Dim bOldEnMod As Boolean = EgtGetEnableModified()
EgtDisableModified()
' se abilitato, eseguo operazione
Dim status As Integer = GDB_ST.OFF
If value Then
status = GDB_ST.ON_
End If
ModifyStatusLamp()
EgtSetStatus(Id, status)
If bOldEnMod Then EgtEnableModified()
EgtDraw()
End If
NotifyPropertyChanged(NameOf(OnOff))
End Set
End Property
' Definizione comandi
Private m_cmdModifyNameEnter As ICommand
Private m_cmdModifyNameEsc As ICommand
Sub New(nId As Integer, bStatus As Boolean, sName As String, nType As Integer, sTool As String, sMach As String)
m_Id = nId
Me.Status = bStatus
Me.Name = sName
m_Type = nType
Me.Image = ConvertTypeToImage(Type)
If Type = MCH_OY.DISP Then
Me.Info = String.Empty
Me.Tool = String.Empty
Me.m_LibMach = String.Empty
Else
Me.Info = "(" & If(Not String.IsNullOrEmpty(sTool), sTool, String.Empty) & ", " &
If(Not String.IsNullOrEmpty(sMach), sMach, String.Empty) & ")"
Me.Tool = If(Not String.IsNullOrEmpty(sTool), "(" & sTool & ")", String.Empty)
Me.m_LibMach = sMach
End If
End Sub
Private Function ConvertTypeToImage(Type As Integer) As String
Select Case Type
Case MCH_OY.DISP
Return ""
Case MCH_OY.DRILLING
Return ""
Case MCH_OY.SAWING
Return ""
Case MCH_OY.MILLING
Return ""
Case MCH_OY.POCKETING
Return ""
Case MCH_OY.MORTISING
Return ""
Case MCH_OY.SAWROUGHING
Return ""
Case MCH_OY.SAWFINISHING
Return ""
Case MCH_OY.GENMACHINING
Return ""
Case MCH_OY.CHISELING
Return ""
Case MCH_OY.FIVEAXISMILLING
Return ""
Case Else
Return String.Empty
End Select
End Function
Private Sub ModifyStatusLamp()
' Recupero l'indice dell'operazione a cui abbiamo appena modificato lo Status e l'indice della Disposizione che la contiene
Dim DispIndex As Integer = 0
Dim OpIndex As Integer = 0
For Each OpItem In Map.refOperationsListExpanderVM.OperationList
If EgtGetOperationType(OpItem.Id) = MCH_OY.DISP Then DispIndex = OpIndex
If OpItem.Id = Id Then
Exit For
End If
OpIndex += 1
Next
' Notifico StatusAll per calcolare lo stato della CheckBox della Disposizione
Map.refOperationsListExpanderVM.OperationList(DispIndex).NotifyPropertyChanged(NameOf(DispositionOpListBoxItem.OnOffAll))
End Sub
#Region "COMMANDS"
#Region "ModifyNameEnterCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property ModifyNameEnterCommand As ICommand
Get
If m_cmdModifyNameEnter Is Nothing Then
m_cmdModifyNameEnter = New RelayCommand(AddressOf ModifyNameEnter)
End If
Return m_cmdModifyNameEnter
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub ModifyNameEnter()
m_ModifyNameOk = True
' verifico che il nome non inizi con disp
If m_ModifiedName.StartsWith("disp", StringComparison.InvariantCultureIgnoreCase) Then
m_CloseModifyLostFocus = False
MessageBox.Show(EgtMsg(MSG_OPERATION + 21), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Warning)
Return
End If
' Imposto il nuovo nome
If String.Compare(m_ModifiedName, Name, True) <> 0 Then
If Not EgtSetOperationName(Id, m_ModifiedName) Then
m_Spy = False
m_CloseModifyLostFocus = False
MessageBox.Show(EgtMsg(MSG_OPERATION + 22), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Warning)
m_IsActive_ModifyName = True
NotifyPropertyChanged("ModifyName_Visibility")
m_Spy = True
Return
End If
' aggiorno il nome con quello modificato
Name = m_ModifiedName
End If
' aggiorno titolo
Map.refProjectVM.EmitTitle()
' termino il rinomina
m_CloseModifyLostFocus = True
IsActive_ModifyName = False
End Sub
Friend Shared m_CloseModifyLostFocus As Boolean = True
Friend Shared m_Spy As Boolean = False
#End Region ' ModifyNameEnterCommand
#Region "ModifyNameEscCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property ModifyNameEscCommand As ICommand
Get
If m_cmdModifyNameEsc Is Nothing Then
m_cmdModifyNameEsc = New RelayCommand(AddressOf ModifyNameEsc)
End If
Return m_cmdModifyNameEsc
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub ModifyNameEsc()
m_ModifyNameOk = False
IsActive_ModifyName = False
End Sub
#End Region ' ModifyNameEscCommand
#End Region ' Commands
End Class