Imports System.ComponentModel 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 EgtSetOperationMode(Id, m_Status) EgtDraw() End If 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 ' 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 Else Return String.Empty End Select End Function #Region "COMMANDS" #Region "ModifyNameEnterCommand" ''' ''' Returns a command that do Point. ''' 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 ''' ''' Execute the Point. This method is invoked by the PointCommand. ''' 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_CloseModifyLostFocus = False MessageBox.Show(EgtMsg(MSG_OPERATION + 22), EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Warning) Return End If ' aggiorno il nome con quello modificato Name = m_ModifiedName End If ' aggiorno titolo Application.Msn.NotifyColleagues(Application.EMITTITLE) ' termino il rinomina m_CloseModifyLostFocus = True IsActive_ModifyName = False End Sub Friend Shared m_CloseModifyLostFocus As Boolean = True #End Region ' ModifyNameEnterCommand #Region "ModifyNameEscCommand" ''' ''' Returns a command that do Point. ''' 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 ''' ''' Execute the Point. This method is invoked by the PointCommand. ''' Public Sub ModifyNameEsc() m_ModifyNameOk = False IsActive_ModifyName = False End Sub #End Region ' ModifyNameEscCommand #End Region ' Commands End Class