Files
EgtCAM5/Base/ViewModelBase.vb
Renzo Lanza 257a4490c4 EgtCAM5 2.1g1 :
- Possibilità di selezione multipla delle Operations in Lavora Travi (con CTRL o SHIFT)
- Il bottone Delete ora funziona anche sulle selezioni multiple
- I bottoni MoveUp/MoveDown ora funzionano anche per le selezioni multiple e si disabilitano se sono selezionate Operations non consecutive, appartenenti a diverse fasi di lavorazione o quando il movimento comporterebbe il passaggio ad un'altra fase di lavorazione
- Sistemati gli Expander Operations/OperationParameters/Simulation/Expander in modo che ce ne sia aperto al massimo solo 1 (L'apertura di un Expander porta alla chiusura di un altro precedentemente aperto)
2019-07-03 11:18:05 +00:00

93 lines
3.0 KiB
VB.net

Imports System.ComponentModel
Public Class ViewModelBase
Implements INotifyPropertyChanged
#Region "Constructor"
Protected Sub New()
End Sub
#End Region ' Constructor
#Region "DisplayName"
''' <summary>
''' Returns the user-friendly name of this object.
''' Child classes can set this property to a new value,
''' or override it to determine the value on-demand.
''' </summary>
Private m_sDisplayName As String
Public Overridable Property sDisplayName() As String
Get
Return m_sDisplayName
End Get
Protected Set(ByVal value As String)
m_sDisplayName = value
End Set
End Property
#End Region ' DisplayName
#Region "Debugging Aides"
''' <summary>
''' Warns the developer if this object does not have
''' a public property with the specified name. This
''' method does not exist in a Release build.
''' </summary>
<Conditional("DEBUG"), DebuggerStepThrough()> _
Public Sub VerifyPropertyName(ByVal sPropertyName As String)
' Verify that the property name matches a real,
' public, instance property on this object.
If TypeDescriptor.GetProperties(Me)(sPropertyName) Is Nothing Then
Dim msg As String = "Invalid property name: " & sPropertyName
If Me.ThrowOnInvalidPropertyName Then
Throw New Exception(msg)
Else
Debug.Fail(msg)
End If
End If
End Sub
''' <summary>
''' Returns whether an exception is thrown, or if a Debug.Fail() is used
''' when an invalid property name is passed to the VerifyPropertyName method.
''' The default value is false, but subclasses used by unit tests might
''' override this property's getter to return true.
''' </summary>
Private privateThrowOnInvalidPropertyName As Boolean
Protected Overridable Property ThrowOnInvalidPropertyName() As Boolean
Get
Return privateThrowOnInvalidPropertyName
End Get
Set(ByVal value As Boolean)
privateThrowOnInvalidPropertyName = value
End Set
End Property
#End Region ' Debugging Aides
#Region "INotifyPropertyChanged Members"
''' <summary>
''' Raised when a property on this object has a new value.
''' </summary>
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
''' <summary>
''' Raises this object's PropertyChanged event.
''' </summary>
''' <param name="spropertyName">The property that has a new value.</param>
Friend Overridable Sub OnPropertyChanged(ByVal sPropertyName As String)
Me.VerifyPropertyName(sPropertyName)
If Me.PropertyChangedEvent IsNot Nothing Then
RaiseEvent PropertyChanged(Me, New System.ComponentModel.PropertyChangedEventArgs(sPropertyName))
End If
End Sub
#End Region ' INotifyPropertyChanged Members
End Class