Imports EgtWPFLib5 Imports EgtUILib Imports System.Windows.Threading Public Class SceneUserControlVM Inherits VMBase #Region "FIELDS & PROPERTIES" Public m_Color_Timer As New DispatcherTimer Public m_WaitAfterRender As Integer = 0 Private m_Title As String Public Property Title As String Get Return m_Title End Get Set(value As String) m_Title = value End Set End Property Private m_ParamList As New List(Of GenericParam) Public Property ParamList As List(Of GenericParam) Get Return m_ParamList End Get Set(value As List(Of GenericParam)) m_ParamList = value End Set End Property #Region "Messages" Public ReadOnly Property Conferma_Msg As String Get Return EgtMsg(110003) ' Conferma End Get End Property Public ReadOnly Property Preview_Msg As String Get Return EgtMsg(110017) ' Preview End Get End Property Public ReadOnly Property Annulla_Msg As String Get Return EgtMsg(110004) ' Annulla End Get End Property #End Region ' Messages ' Definizione Comandi Private m_ConfermaCmd As ICommand Private m_PreviewCmd As ICommand Private m_AnnullaCmd As ICommand #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New() End Sub #End Region ' Constructor #Region "METHODS" Public Overridable Sub LoadParamList() End Sub Public Sub AddGenericParam(Control As GenericParam) If TypeOf Control Is _CheckBoxParam Then AddHandler DirectCast(Control, _CheckBoxParam).CheckChanged, AddressOf OnCheckboxCheckedChanged End If If TypeOf Control Is _ComboBoxParam Then AddHandler DirectCast(Control, _ComboBoxParam).SelectionChanged, AddressOf OnComboboxSelectionChanged End If If TypeOf Control Is _TextBoxParam Then AddHandler DirectCast(Control, _TextBoxParam).TextChanged, AddressOf OnTextboxTextChanged End If ParamList.Add(Control) End Sub Public Sub ColorTimer_Tick() If m_WaitAfterRender > 1 Then DirectCast(ParamList(0), _TextBlockParam).Foreground_TxBl = Brushes.Black m_Color_Timer.Stop() ElseIf m_WaitAfterRender > 0 Then m_WaitAfterRender += 1 End If End Sub ''' ''' Funzione che permette di cambiare colore al foreground della textblock ''' Public Sub ChangeTextColor() DirectCast(ParamList(0), _TextBlockParam).Foreground_TxBl = Brushes.Blue m_Color_Timer.Interval = New TimeSpan(0, 0, 0, 2, 0) AddHandler m_Color_Timer.Tick, AddressOf ColorTimer_Tick m_WaitAfterRender = 1 m_Color_Timer.Start() End Sub #End Region ' Methods #Region "EVENTS" ' Event handler for checkbox CheckedChanged Public Overridable Sub OnCheckboxCheckedChanged(sender As Object, CheckState As Boolean) End Sub Public Overridable Sub OnComboboxSelectionChanged(sender As Object, Selection As ParamCmBx) End Sub Public Overridable Sub OnTextboxTextChanged(sender As Object, Text As String) End Sub #End Region ' Events #Region "COMMANDS" #Region "ConfermCmd" Public ReadOnly Property ConfermaCmd As ICommand Get If m_ConfermaCmd Is Nothing Then m_ConfermaCmd = New Command(AddressOf Conferma) End If Return m_ConfermaCmd End Get End Property Public Overridable Sub Conferma() End Sub #End Region ' ConfermaCmd #Region "PreviewCmd" Public ReadOnly Property PreviewCmd As ICommand Get If m_PreviewCmd Is Nothing Then m_PreviewCmd = New Command(AddressOf ShowPreview) End If Return m_PreviewCmd End Get End Property Public Overridable Sub ShowPreview() End Sub #End Region ' PreviewCmd #Region "AnnullaCmd" Public ReadOnly Property AnnullaCmd As ICommand Get If m_AnnullaCmd Is Nothing Then m_AnnullaCmd = New Command(AddressOf Annulla) End If Return m_AnnullaCmd End Get End Property Public Overridable Sub Annulla() End Sub #End Region ' AnnullaCmd #End Region ' Commands End Class Public Class GenericParam Inherits VMBase #Region "FIELDS & PROPERTIES" Private m_Name As String = String.Empty Public Property Name As String Get Return m_Name End Get Set(value As String) m_Name = value NotifyPropertyChanged(NameOf(Name)) End Set End Property Private m_nVisibility As Visibility = Visibility.Visible Public Property nVisibility As Visibility Get Return m_nVisibility End Get Set(value As Visibility) m_nVisibility = value NotifyPropertyChanged(NameOf(nVisibility)) End Set End Property Private m_IsEnabled As Boolean = True Public Property IsEnabled As Boolean Get Return m_IsEnabled End Get Set(value As Boolean) m_IsEnabled = value NotifyPropertyChanged(NameOf(IsEnabled)) End Set End Property Private m_TypeValue As ParamType Public Property TypeValue As Integer Get Return m_TypeValue End Get Set(value As Integer) m_TypeValue = value NotifyPropertyChanged(NameOf(TypeValue)) End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String, Optional Visibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) m_Name = sName m_TypeValue = ParamType.STR m_nVisibility = Visibility m_IsEnabled = bIsEnabled End Sub Sub New(sName As String, TypeValue As Integer, Optional Visibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) m_Name = sName m_TypeValue = TypeValue m_nVisibility = Visibility m_IsEnabled = bIsEnabled End Sub #End Region ' Constructor End Class Public Class _TextBoxParam Inherits GenericParam #Region "FIELDS & PROPERTIES" Public Event TextChanged(sender As Object, text As String) Private m_sValue As String = String.Empty Public Property sValue As String Get Return m_sValue End Get Set(value As String) m_sValue = value RaiseEvent TextChanged(Me, m_sValue) NotifyPropertyChanged(NameOf(sValue)) End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String, sValue As String, TypeValue As Integer, Optional nVisibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) MyBase.New(sName, TypeValue, nVisibility, bIsEnabled) m_sValue = sValue End Sub #End Region ' Constructor #Region "METHODS" Public Function GetValue() If String.IsNullOrEmpty(sValue) Then Return 0 If Not IsNumeric(sValue) Then Return 0 Dim dValue As Double = CDbl(sValue) Return dValue End Function #End Region End Class Public Class _TextBlockParam Inherits GenericParam #Region "FIELDS & PROPERTIES" Private m_MsgValue As String = String.Empty Public Property MsgValue As String Get Return m_MsgValue End Get Set(value As String) m_MsgValue = value NotifyPropertyChanged(NameOf(MsgValue)) End Set End Property Private m_Foreground_TxBl As Brush = Brushes.Black Public Property Foreground_TxBl As Brush Get Return m_Foreground_TxBl End Get Set(value As Brush) m_Foreground_TxBl = value NotifyPropertyChanged(NameOf(Foreground_TxBl)) End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String, sValue As String, TypeValue As Integer, Optional nVisibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) MyBase.New(sName, TypeValue, nVisibility, bIsEnabled) m_MsgValue = sValue End Sub #End Region ' Constructor End Class Public Class _ComboBoxParam Inherits GenericParam #Region "FIELDS & PROPERTIES" Public Event SelectionChanged(sender As Object, selection As ParamCmBx) Private m_ParamCmBxList As New List(Of ParamCmBx) Public Property ParamCmBxList As List(Of ParamCmBx) Get Return m_ParamCmBxList End Get Set(value As List(Of ParamCmBx)) m_ParamCmBxList = value NotifyPropertyChanged(NameOf(ParamCmBxList)) End Set End Property Private m_SelParamCmBx As ParamCmBx Public Property SelParamCmBx As ParamCmBx Get Return m_SelParamCmBx End Get Set(value As ParamCmBx) m_SelParamCmBx = value RaiseEvent SelectionChanged(Me, m_SelParamCmBx) NotifyPropertyChanged(NameOf(SelParamCmBx)) IndexSelParamCmBx = ParamCmBxList.FindIndex(Function(x As ParamCmBx) x.Name = m_SelParamCmBx.Name) End Set End Property Private m_IndexSelParamCmBx As Integer = 0 Public Property IndexSelParamCmBx As Integer Get Return m_IndexSelParamCmBx End Get Set(value As Integer) m_IndexSelParamCmBx = value NotifyPropertyChanged(NameOf(IndexSelParamCmBx)) End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String, _ParamCmBxList As List(Of ParamCmBx), IndexSelected As Integer, Optional nVisibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) MyBase.New(sName, nVisibility, bIsEnabled) m_ParamCmBxList = _ParamCmBxList m_SelParamCmBx = m_ParamCmBxList(IndexSelected) End Sub #End Region ' Constructor End Class Public Class ParamCmBx #Region "FIELDS & PROPERTIES" Private m_Name As String = String.Empty Public Property Name As String Get Return m_Name End Get Set(value As String) m_Name = value End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String) m_Name = sName End Sub #End Region ' Constructor End Class Public Class _CheckBoxParam Inherits GenericParam #Region "FIELDS & PROPERTIES" Public Event CheckChanged(sender As Object, checked As Boolean) Private m_MsgValue As String = String.Empty Public Property MsgValue As String Get Return m_MsgValue End Get Set(value As String) m_MsgValue = value NotifyPropertyChanged(NameOf(value)) End Set End Property Private m_IsChecked As Boolean = False Public Property IsChecked As Boolean Get Return m_IsChecked End Get Set(value As Boolean) m_IsChecked = value RaiseEvent CheckChanged(Me, m_IsChecked) NotifyPropertyChanged(NameOf(value)) End Set End Property #End Region ' Fields & Properties #Region "CONSTRUCTOR" Sub New(sName As String, sValue As String, Optional nVisibility As Visibility = Visibility.Visible, Optional bIsEnabled As Boolean = True) MyBase.New(sName, ParamType.BOOL, nVisibility, bIsEnabled) m_MsgValue = sValue End Sub #End Region ' Constructor End Class