Files
EgtCAM5/Special/GunStockWindow/GunStockWndViewModel.vb
T
Emmanuele Sassi 4f0e718501 EgtCAM5 :
- Aggiunta finestra speciale per GunStock.
2016-10-27 14:39:48 +00:00

114 lines
3.5 KiB
VB.net

Imports System.ComponentModel
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Public Class GunStockWndViewModel
Implements INotifyPropertyChanged
Private m_FileName As String
Public Property FileName As String
Get
Return m_FileName
End Get
Set(value As String)
m_FileName = value
End Set
End Property
Private m_ParamList As New ObservableCollection(Of GunStockParamListItem)
Public Property ParamList As ObservableCollection(Of GunStockParamListItem)
Get
Return m_ParamList
End Get
Set(value As ObservableCollection(Of GunStockParamListItem))
m_ParamList = value
' verifico se la nuova lista è valida per attivare/disattivare OkBtn di conseguenza
IsValidParamList()
End Set
End Property
Private m_IsEnabledOkBtn As Boolean
Public ReadOnly Property IsEnabledOkBtn As Boolean
Get
Return m_IsEnabledOkBtn
End Get
End Property
#Region "Messages"
Public ReadOnly Property FileNameMsg As String
Get
Return EgtMsg(MSG_GUNSTOCK + 1)
End Get
End Property
Public ReadOnly Property OkMsg As String
Get
Return EgtMsg(MSG_GUNSTOCK + 2)
End Get
End Property
Public ReadOnly Property CancelMsg As String
Get
Return EgtMsg(MSG_GUNSTOCK + 3)
End Get
End Property
#End Region
Friend Sub AddParam(sName As String, dValue As Double, dMin As Double, dMax As Double)
m_ParamList.Add(New GunStockParamListItem(sName, dValue, dMin, dMax, AddressOf IsValidParamList))
End Sub
Friend Function GetParam(sName As String, ByRef dValue As Double) As Boolean
For Index As Integer = 0 To m_ParamList.Count - 1
If m_ParamList(Index).Name = sName Then
StringToDouble(m_ParamList(Index).Value, dValue)
Return True
End If
Next
Return False
End Function
Private Sub IsValidParamList()
Dim bOk As Boolean = True
For Index As Integer = 0 To m_ParamList.Count - 1
If Not String.IsNullOrEmpty(m_ParamList(Index).ErrorMsg) Then
bOk = False
Exit For
End If
Next
If bOk Then
m_IsEnabledOkBtn = True
Else
m_IsEnabledOkBtn = False
End If
NotifyPropertyChanged("IsEnabledOkBtn")
End Sub
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class
''' <summary>
''' Class that represent a Converter that convert the complete file path in the file name and vice versa.
''' </summary>
'Public Class FileNameConverter
' Implements IValueConverter
' Dim TempPath As String
' Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
' TempPath = CStr(value)
' Return Path.GetFileNameWithoutExtension(TempPath)
' End Function
' Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
' Return Path.GetDirectoryName(TempPath) & "\" & CStr(value) & Path.GetExtension(TempPath)
' End Function
'End Class