20b978c19c
- modifiche per Gunstock.
156 lines
4.5 KiB
VB.net
156 lines
4.5 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
|
|
|
|
Public Class GunStockWndViewModel
|
|
Implements INotifyPropertyChanged
|
|
|
|
Private m_bNewFile As Boolean
|
|
Friend Property bNewFile As Boolean
|
|
Get
|
|
Return m_bNewFile
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_bNewFile = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OrigFileName As String
|
|
Public WriteOnly Property OrigFileName As String
|
|
Set(value As String)
|
|
m_OrigFileName = value
|
|
FileName = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_FileName As String
|
|
Public Property FileName As String
|
|
Get
|
|
Return m_FileName
|
|
End Get
|
|
Set(value As String)
|
|
m_FileName = value
|
|
' verifico se il nome del file è valido per attivare/disattivare OkBtn di conseguenza
|
|
IsValidParamList()
|
|
End Set
|
|
End Property
|
|
|
|
Private m_OrigDescription As String
|
|
Public WriteOnly Property OrigDescription As String
|
|
Set(value As String)
|
|
m_OrigDescription = value
|
|
Description = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Description As String
|
|
Public Property Description As String
|
|
Get
|
|
Return m_Description
|
|
End Get
|
|
Set(value As String)
|
|
m_Description = 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 TitleMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_GUNSTOCK + 5)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property FileNameMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_GUNSTOCK + 6)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property DescriptionMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_GUNSTOCK + 7)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OkMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_GUNSTOCK + 8)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property CancelMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_GUNSTOCK + 9)
|
|
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 = Not String.IsNullOrWhiteSpace(FileName)
|
|
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
|
|
|
|
Friend Function IsModifiedParamList() As Boolean
|
|
If m_OrigFileName <> m_FileName Then Return True
|
|
If m_OrigDescription <> m_Description Then Return True
|
|
For Index As Integer = 0 To m_ParamList.Count - 1
|
|
Dim dVal As Double
|
|
StringToDouble(m_ParamList(Index).Value, dVal)
|
|
If Math.Abs(dVal - m_ParamList(Index).dOrigVal) > EPS_SMALL Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class |