Files
EgtCAM5/OptionPanel/MachiningOptionPanel/OperationExpander/OperationListBoxItem/MachiningOpListBoxItem.vb
T
Dario Sassi e52c2a4277 EgtCAM5 :
- ora rinomina lavorazione chiama la nuova funzione EgtSetOperationName.
2018-11-15 18:42:58 +00:00

228 lines
6.2 KiB
VB.net

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
Else
'se premuto enter
If m_ModifyNameOk Then
' Imposto il nuovo nome
If Not EgtSetOperationName(Id, m_ModifiedName) Then Return
' aggiorno il nome con quello modificato
Name = m_ModifiedName
Else
' resetto il nome modificato
m_ModifiedName = ""
End If
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"
''' <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
IsActive_ModifyName = False
End Sub
#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