Files
EgtWPFLib5/OptionPanel/MachineAxis.vb
T
Dario Sassi 00a338c202 Revert "Merge commit 'f1aae48a2b80f96ae94b59a69addd6cc6e48ee14'"
This reverts commit 1f49d0936e, reversing
changes made to 236eeac038.
2025-03-21 19:21:02 +01:00

142 lines
3.6 KiB
VB.net

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("IsReadOnlyAxesValue")
NotifyPropertyChanged("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("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("Value")
End Sub
Sub New()
IsReadOnlyAxesValue = True
End Sub
#Region "COMMANDS"
#Region "ManualAxisModifyCommand"
''' <summary>
''' Returns a command that create a new tool.
''' </summary>
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
''' <summary>
''' Creata the new tool. This method is invoked by the NewCommand.
''' </summary>
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