Imports System.ComponentModel Imports EgtUILib Public Class MachineAxis Implements INotifyPropertyChanged Private m_IsReadOnlyAxesValue As Boolean Public Property IsReadOnlyAxesValue As Boolean Get Return m_IsReadOnlyAxesValue End Get Set(value As Boolean) If value <> m_IsReadOnlyAxesValue Then m_IsReadOnlyAxesValue = value NotifyPropertyChanged(NameOf(IsReadOnlyAxesValue)) NotifyPropertyChanged(NameOf(IsEnabledAxesValue)) End If End Set End Property Public ReadOnly Property IsEnabledAxesValue As Boolean Get Return Not m_IsReadOnlyAxesValue End Get End Property ' Definizione comandi Private m_cmdManualAxisModify As ICommand Private m_Name As String Public Property Name As String Get Return m_Name End Get Set(value As String) m_Name = value UpdateInvert() UpdateOffset() End Set End Property Private m_Token As String Public Property Token As String Get Return m_Token End Get Set(value As String) If value <> m_Token Then m_Token = value NotifyPropertyChanged(NameOf(Token)) End If End Set End Property Private m_bLinear As Boolean = True Public WriteOnly Property Linear As Boolean Set(value As Boolean) m_bLinear = value End Set End Property Private m_bInvert As Boolean = False Private Function UpdateInvert() As Boolean Return EgtGetAxisInvert(m_Name, m_bInvert) End Function Private m_dOffset As Double = 0 Private Function UpdateOffset() As Boolean Return EgtGetAxisOffset(m_Name, m_dOffset) End Function Private m_Value As String Public Property Value As String Get Return m_Value End Get Set(value As String) m_Value = value ManualAxisModify(Nothing) End Set End Property Friend Sub SetValue(value As String) m_Value = value NotifyPropertyChanged(NameOf(value)) End Sub Sub New() IsReadOnlyAxesValue = True End Sub #Region "COMMANDS" #Region "ManualAxisModifyCommand" ''' ''' Returns a command that create a new tool. ''' Public ReadOnly Property ManualAxisModifyCommand As ICommand Get If m_cmdManualAxisModify Is Nothing Then m_cmdManualAxisModify = New Command(AddressOf ManualAxisModify) End If Return m_cmdManualAxisModify End Get End Property ''' ''' Creata the new tool. This method is invoked by the NewCommand. ''' Public Sub ManualAxisModify(ByVal param As Object) Dim dVal As Double If m_bLinear Then StringToLen(m_Value, dVal) Else StringToDouble(m_Value, dVal) End If dVal -= m_dOffset If m_bInvert Then dVal = -dVal EgtSetAxisPos(m_Name, dVal) EgtGetAxisPos(m_Name, dVal) If m_bInvert Then dVal = -dVal dVal += m_dOffset If m_bLinear Then SetValue(LenToString(dVal, -3)) Else SetValue(DoubleToString(dVal, -3)) End If EgtDraw() End Sub #End Region ' ManualAxisModifyCommand #End Region Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Public Sub NotifyPropertyChanged(propName As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName)) End Sub End Class