463 lines
14 KiB
VB.net
463 lines
14 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
Imports MS.Internal
|
|
|
|
Public Class InputExpanderVM
|
|
Inherits ViewModelBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Variabile temporanea per salvare bShow
|
|
Private m_bTempShow As Boolean
|
|
|
|
Private m_tmpInfoList As New ObservableCollection(Of InfoItem)
|
|
''' <summary>
|
|
''' Lista temporanea delle info
|
|
''' </summary>
|
|
Private Property tmpInfoList As ObservableCollection(Of InfoItem)
|
|
Get
|
|
Return m_tmpInfoList
|
|
End Get
|
|
Set(value As ObservableCollection(Of InfoItem))
|
|
m_tmpInfoList = value
|
|
OnPropertyChanged("tmpInfoList")
|
|
End Set
|
|
End Property
|
|
|
|
' Expander fields
|
|
Private m_IsExpanded As Boolean
|
|
Public Property IsExpanded As Boolean
|
|
Get
|
|
Return m_IsExpanded
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_IsExpanded = value
|
|
OnPropertyChanged("IsExpanded")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsEnabled As Boolean
|
|
Public Property IsEnabled As Boolean
|
|
Get
|
|
Return m_IsEnabled
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_IsEnabled = value
|
|
OnPropertyChanged("IsEnabled")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_Title As String
|
|
Public Property Title As String
|
|
Get
|
|
Return m_Title
|
|
End Get
|
|
Set(value As String)
|
|
m_Title = value
|
|
OnPropertyChanged("Title")
|
|
End Set
|
|
End Property
|
|
|
|
' TextBlock fields
|
|
Private m_TextBlock As String
|
|
Public Property TextBlock As String
|
|
Get
|
|
Return m_TextBlock
|
|
End Get
|
|
Set(value As String)
|
|
m_TextBlock = value
|
|
OnPropertyChanged("TextBlock")
|
|
End Set
|
|
End Property
|
|
|
|
' TextBox fields
|
|
Private m_TextBox As String
|
|
Public Property TextBox As String
|
|
Get
|
|
Return m_TextBox
|
|
End Get
|
|
Set(value As String)
|
|
m_TextBox = value
|
|
Map.refProjectVM.NotifyInputText(value)
|
|
OnPropertyChanged("TextBox")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_TextVisibility As Visibility
|
|
Public Property TextVisibility As Visibility
|
|
Get
|
|
Return m_TextVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_TextVisibility Then
|
|
m_TextVisibility = value
|
|
OnPropertyChanged("TextVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_FocusTextBox As Boolean
|
|
Public Property FocusTextBox As Boolean
|
|
Get
|
|
Return m_FocusTextBox
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_FocusTextBox = value
|
|
OnPropertyChanged("FocusTextBox")
|
|
End Set
|
|
End Property
|
|
|
|
'CheckBox fields
|
|
Private m_CheckBoxText As String
|
|
Public Property CheckBoxText As String
|
|
Get
|
|
Return m_CheckBoxText
|
|
End Get
|
|
Set(value As String)
|
|
m_CheckBoxText = value
|
|
OnPropertyChanged("CheckBoxText")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsChecked As Boolean
|
|
Public Property IsChecked As Boolean
|
|
Get
|
|
Return m_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
If value <> m_IsChecked Then
|
|
Map.refProjectVM.SetLastBoolean(value)
|
|
m_IsChecked = value
|
|
OnPropertyChanged("IsChecked")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private m_CheckVisibility As Visibility
|
|
Public Property CheckVisibility As Visibility
|
|
Get
|
|
Return m_CheckVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_CheckVisibility Then
|
|
m_CheckVisibility = value
|
|
OnPropertyChanged("CheckVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' ComboBox fields
|
|
Private m_ComboItemsList As New ObservableCollection(Of String)
|
|
Public Property ComboItemsList As ObservableCollection(Of String)
|
|
Get
|
|
Return m_ComboItemsList
|
|
End Get
|
|
Set(value As ObservableCollection(Of String))
|
|
m_ComboItemsList = value
|
|
OnPropertyChanged("ComboItemsList")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ComboSelectedIndex As Integer
|
|
Public Property ComboSelectedIndex As Integer
|
|
Get
|
|
Return m_ComboSelectedIndex
|
|
End Get
|
|
Set(value As Integer)
|
|
If m_bTempShow Then Map.refProjectVM.SetLastInteger(value)
|
|
m_ComboSelectedIndex = value
|
|
Dim tmpComboSelectedIndex As Integer = ComboSelectedIndex
|
|
If m_ComboSelectedIndex >= 0 AndAlso tmpInfoList.Count > 0 Then
|
|
' se la info è presente la aggiungo alla textbox per modificarla
|
|
If m_TextBox IsNot String.Empty Then
|
|
If Not m_TextBox.EndsWith(vbCrLf) Then m_TextBox &= vbCrLf
|
|
m_TextBox &= (tmpInfoList(m_ComboSelectedIndex).sKey & "=" & m_tmpInfoList(m_ComboSelectedIndex).sValour).Trim()
|
|
ElseIf m_TextBox Is String.Empty Then
|
|
m_TextBox &= (tmpInfoList(m_ComboSelectedIndex).sKey & "=" & m_tmpInfoList(m_ComboSelectedIndex).sValour).Trim() & vbCrLf
|
|
End If
|
|
ComboVisibility = Visibility.Collapsed
|
|
ComboItemsList.Remove((tmpInfoList(m_ComboSelectedIndex).sKey & "=" & m_tmpInfoList(m_ComboSelectedIndex).sValour).Trim())
|
|
tmpInfoList.Remove(tmpInfoList(tmpComboSelectedIndex))
|
|
End If
|
|
m_ComboSelectedIndex = -1
|
|
If ComboItemsList.Count <= 0 Then ShowInfoItemVisibility = Visibility.Collapsed
|
|
OnPropertyChanged("ComboSelectedIndex")
|
|
OnPropertyChanged("ComboItemsList")
|
|
OnPropertyChanged("TextBox")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ComboVisibility As Visibility
|
|
Public Property ComboVisibility As Visibility
|
|
Get
|
|
Return m_ComboVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_ComboVisibility Then
|
|
m_ComboVisibility = value
|
|
OnPropertyChanged("ComboVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Buttons fields
|
|
Private m_ShowBtnVisibility As Visibility
|
|
Public Property ShowBtnVisibility As Visibility
|
|
Get
|
|
Return m_ShowBtnVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_ShowBtnVisibility = value
|
|
OnPropertyChanged("ShowBtnVisibility")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ShowInfoItemVisibility As Visibility
|
|
''' <summary>
|
|
''' Propietà visibilità bottone +
|
|
''' </summary>
|
|
Public Property ShowInfoItemVisibility As Visibility
|
|
Get
|
|
Return m_ShowInfoItemVisibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
If value <> m_ShowInfoItemVisibility Then
|
|
m_ShowInfoItemVisibility = value
|
|
OnPropertyChanged("ShowInfoItemVisibility")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
' Commands definition
|
|
Private m_cmdShow As ICommand
|
|
Private m_cmdDone As ICommand
|
|
Private m_cmdShowInfoItem As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property ShowMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWOPTION + 14)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property OkMsg As String
|
|
Get
|
|
Return EgtMsg(MSG_DRAWOPTION + 15)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#End Region ' Fields & Properties
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in EgtCAM5Map
|
|
Map.SetRefInputExpanderVM(Me)
|
|
ComboSelectedIndex = -1
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ShowCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property ShowCommand As ICommand
|
|
Get
|
|
If m_cmdShow Is Nothing Then
|
|
m_cmdShow = New RelayCommand(AddressOf Show, AddressOf CanShow)
|
|
End If
|
|
Return m_cmdShow
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub Show(ByVal param As Object)
|
|
Map.refProjectVM.Show(TextBox)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanShow(ByVal param As Object) As Boolean
|
|
Return If(m_ShowBtnVisibility = Visibility.Visible, True, False)
|
|
End Function
|
|
|
|
#End Region ' ShowCommand
|
|
|
|
#Region "DoneCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that do Point.
|
|
''' </summary>
|
|
Public ReadOnly Property DoneCommand As ICommand
|
|
Get
|
|
If m_cmdDone Is Nothing Then
|
|
m_cmdDone = New RelayCommand(AddressOf Done, AddressOf CanDone)
|
|
End If
|
|
Return m_cmdDone
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Execute the Point. This method is invoked by the PointCommand.
|
|
''' </summary>
|
|
Public Sub Done(ByVal param As Object)
|
|
Map.refProjectVM.Done(m_TextBox)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Returns always true.
|
|
''' </summary>
|
|
Private Function CanDone(ByVal param As Object) As Boolean
|
|
Return True
|
|
End Function
|
|
|
|
#End Region ' DoneCommand
|
|
|
|
#Region "ShowInfoItemCommand"
|
|
|
|
''' <summary>
|
|
''' Comando per la visualizzazione della combobox
|
|
''' </summary>
|
|
Public ReadOnly Property ShowInfoItemCommand As ICommand
|
|
Get
|
|
If m_cmdShowInfoItem Is Nothing Then
|
|
m_cmdShowInfoItem = New Command(AddressOf ShowInfoItem)
|
|
End If
|
|
Return m_cmdShowInfoItem
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Funzione per la visualizzazione della combobox
|
|
''' </summary>
|
|
''' <param name="param"></param>
|
|
Public Sub ShowInfoItem(ByVal param As Object)
|
|
' Se presente info inserita in textbox
|
|
If m_TextBox IsNot String.Empty Then
|
|
Dim sSplitItem As String() = m_TextBox.Split("="c)
|
|
Dim ItemCombo As InfoItem = tmpInfoList.FirstOrDefault(Function(x) x.sKey = sSplitItem(0))
|
|
If Not IsNothing(ItemCombo) Then
|
|
ComboItemsList.Remove((ItemCombo.sKey & "=" & ItemCombo.sValour).Trim())
|
|
tmpInfoList.Remove(ItemCombo)
|
|
End If
|
|
End If
|
|
ComboVisibility = Visibility.Visible
|
|
End Sub
|
|
|
|
#End Region ' ShowInfoItemCommand
|
|
|
|
#End Region
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub PrepareInputBox(PrepareInputBoxParam As PrepareInputBoxParam)
|
|
' Divido il titolo che può contenere comandi dopo il ';'
|
|
Dim vsSplitTitle As String() = PrepareInputBoxParam.sTitle.Split(";"c)
|
|
Title = vsSplitTitle(0)
|
|
If PrepareInputBoxParam.sLabel <> "" Then
|
|
TextBlock = PrepareInputBoxParam.sLabel
|
|
TextBox = ""
|
|
TextVisibility = Visibility.Visible
|
|
' Se presente il comando "Sic=1"
|
|
If vsSplitTitle.Count() > 1 AndAlso vsSplitTitle(1) = "Sic=1" Then
|
|
m_bTempShow = False
|
|
ComboInfo()
|
|
If ComboItemsList.Count > 0 Then ShowInfoItemVisibility = Visibility.Visible
|
|
End If
|
|
End If
|
|
If PrepareInputBoxParam.sCheckLabel <> "" Then
|
|
CheckBoxText = PrepareInputBoxParam.sCheckLabel
|
|
CheckVisibility = Visibility.Visible
|
|
End If
|
|
If PrepareInputBoxParam.bShowCombo Then
|
|
m_bTempShow = PrepareInputBoxParam.bShowCombo
|
|
ComboItemsList.Clear()
|
|
tmpInfoList.Clear()
|
|
ComboVisibility = Visibility.Visible
|
|
End If
|
|
If PrepareInputBoxParam.bShowBtn Then
|
|
ShowBtnVisibility = Visibility.Visible
|
|
End If
|
|
IsEnabled = True
|
|
IsExpanded = True
|
|
FocusTextBox = True
|
|
End Sub
|
|
|
|
Friend Sub ResetInputBox()
|
|
Title = EgtMsg(MSG_DRAWOPTION + 5)
|
|
TextVisibility = Visibility.Collapsed
|
|
CheckVisibility = Visibility.Collapsed
|
|
ComboVisibility = Visibility.Collapsed
|
|
ShowBtnVisibility = Visibility.Collapsed
|
|
ShowInfoItemVisibility = Visibility.Collapsed
|
|
IsExpanded = False
|
|
IsEnabled = False
|
|
End Sub
|
|
|
|
Friend Function SetInputBoxText(ByVal sVal As String) As Boolean
|
|
TextBox = sVal
|
|
FocusTextBox = True
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function ChangeInputBoxCheck() As Boolean
|
|
IsChecked = Not m_IsChecked
|
|
Return True
|
|
End Function
|
|
|
|
Friend Function SetInputBoxCheck(ByVal bCheck As Boolean) As Boolean
|
|
IsChecked = bCheck
|
|
Map.refProjectVM.SetLastBoolean(IsChecked)
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub AddInputBoxCombo(AddInputBoxComboParam As AddInputBoxComboParam)
|
|
AddInputBoxCombo(AddInputBoxComboParam.sText, AddInputBoxComboParam.bSelected)
|
|
End Sub
|
|
|
|
Private Function AddInputBoxCombo(ByVal sText As String, ByVal bSelected As Boolean) As Boolean
|
|
ComboItemsList.Add(sText)
|
|
|
|
If bSelected Then
|
|
ComboSelectedIndex = ComboItemsList.Count - 1
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Funzione che popola la lista ComboItemsList
|
|
''' </summary>
|
|
Private Sub ComboInfo()
|
|
tmpInfoList.Clear()
|
|
ComboItemsList.Clear()
|
|
|
|
Dim vsVal As String() = Nothing
|
|
EgtGetAllInfo(Map.refManageLayerExpanderVM.RightClickedTreeItemId, vsVal)
|
|
|
|
If Not m_bTempShow And Not IsNothing(vsVal) Then
|
|
Dim Ind As Integer = 0
|
|
For Each Item As String In vsVal
|
|
Dim sSplitItem As String() = Item.Split("="c)
|
|
tmpInfoList.Add(New InfoItem(Ind, sSplitItem(0), sSplitItem(1)))
|
|
Ind += 1
|
|
Next
|
|
|
|
For Each InfoItem As InfoItem In tmpInfoList
|
|
ComboItemsList.Add((InfoItem.sKey & "=" & InfoItem.sValour).Trim())
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|