Files
EgtCAM5/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderVM.vb
T
Renzo Lanza fe58578e65 EgtCAM5 :
- eliminati tutti gli Application.Msn.Register/NotifyColleagues e la classe Messenger. Ora tutto ciò che eseguivano è in funzioni/sub Friend chiamate tramite i riferimenti in Map.
2020-10-28 14:09:17 +00:00

841 lines
27 KiB
VB.net

Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtCAM5.IniFile
Public Class ManageLayerExpanderVM
Inherits ViewModelBase
#Region "FIELDS & PROPERTIES"
' Expander Header Properties
Private m_HeaderName As String
Public Property HeaderName As String
Get
Return m_HeaderName
End Get
Set(value As String)
m_HeaderName = value
OnPropertyChanged("HeaderName")
End Set
End Property
Private m_HeaderColor As SolidColorBrush
Public Property HeaderColor As SolidColorBrush
Get
Return m_HeaderColor
End Get
Set(value As SolidColorBrush)
m_HeaderColor = value
OnPropertyChanged("HeaderColor")
End Set
End Property
' Definizione comandi
Private m_cmdNewPart As ICommand
Private m_cmdNewLayer As ICommand
Private m_cmdLayerColor As ICommand
Private m_cmdTreeViewDoubleClick As ICommand
Private m_cmdTreeViewMouseUp As ICommand
Private m_cmdTreeViewMouseRightButton As ICommand
Private m_cmdSelect As ICommand
Private m_cmdDeselect As ICommand
Private m_cmdName As ICommand
Private m_cmdInfo As ICommand
Private m_cmdRelocate As ICommand
Private m_cmdCopy As ICommand
Private m_cmdDelete As ICommand
Private m_cmdSave As ICommand
' Lista dei layer
Private m_LayerList As New ObservableCollection(Of LayerTreeViewItem)
Public Property LayerList As ObservableCollection(Of LayerTreeViewItem)
Get
Return m_LayerList
End Get
Set(value As ObservableCollection(Of LayerTreeViewItem))
m_LayerList = value
End Set
End Property
Private m_IsRightClickedTreeItem As Boolean
Public ReadOnly Property IsRightClickedTreeItem As Integer
Get
Return m_RightClickedTreeItemId
End Get
End Property
Private m_RightClickedTreeItemId As Integer
Public ReadOnly Property RightClickedTreeItemId As Integer
Get
Return m_RightClickedTreeItemId
End Get
End Property
#Region "Messages"
Public ReadOnly Property NewPartMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 2)
End Get
End Property
Public ReadOnly Property NewLayerMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 3)
End Get
End Property
Public ReadOnly Property ColorMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 4)
End Get
End Property
Public ReadOnly Property SelectMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 6)
End Get
End Property
Public ReadOnly Property DeselectMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 7)
End Get
End Property
Public ReadOnly Property NameMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 8)
End Get
End Property
Public ReadOnly Property InfoMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 9)
End Get
End Property
Public ReadOnly Property RelocateMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 10)
End Get
End Property
Public ReadOnly Property CopyMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 11)
End Get
End Property
Public ReadOnly Property DeleteMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 12)
End Get
End Property
Public ReadOnly Property SaveMsg As String
Get
Return EgtMsg(MSG_DRAWOPTION + 13)
End Get
End Property
#End Region
#End Region
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in EgtCAM5Map
Map.SetRefManageLayerExpanderVM(Me)
'Imposto tempo di evidenziazione delle entità clickate
ObjTreeTimer.Interval = TimeSpan.FromMilliseconds(1000)
End Sub
#End Region ' Constructor
#Region "COMMANDS"
#Region "NewPartCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewPartCommand As ICommand
Get
If m_cmdNewPart Is Nothing Then
m_cmdNewPart = New RelayCommand(AddressOf NewPart)
End If
Return m_cmdNewPart
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewPart(ByVal param As Object)
Map.refProjectVM.ExecuteCommand(Controller.CMD.NEWPART)
' Seleziono nell'albero il layer del pezzo appena creato
SelectIdInObjTree(EgtGetCurrLayer(), False)
End Sub
#End Region ' NewPartCommand
#Region "NewLayerCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NewLayerCommand As ICommand
Get
If m_cmdNewLayer Is Nothing Then
m_cmdNewLayer = New RelayCommand(AddressOf NewLayer)
End If
Return m_cmdNewLayer
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub NewLayer(ByVal param As Object)
Map.refProjectVM.ExecuteCommand(Controller.CMD.NEWLAYER)
' Seleziono nell'albero il layer appena creato
SelectIdInObjTree(EgtGetCurrLayer(), False)
End Sub
#End Region ' NewLayerCommand
#Region "LayerColorCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property LayerColorCommand As ICommand
Get
If m_cmdLayerColor Is Nothing Then
m_cmdLayerColor = New RelayCommand(AddressOf LayerColor)
End If
Return m_cmdLayerColor
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub LayerColor(ByVal param As Object)
Map.refProjectVM.ExecuteCommand(Controller.CMD.LAYERCOLOR)
Map.refManageLayerExpanderVM.LoadObjTree()
End Sub
#End Region ' LayerColorCommand
#Region "TreeViewDoubleClickCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property TreeViewDoubleClickCommand As ICommand
Get
If m_cmdTreeViewDoubleClick Is Nothing Then
m_cmdTreeViewDoubleClick = New RelayCommand(AddressOf TreeViewDoubleClick)
End If
Return m_cmdTreeViewDoubleClick
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub TreeViewDoubleClick(ByVal param As Object)
If m_nObjTreeOldId <> GDB_ID.NULL Then
Map.refProjectVM.SetLastInteger(m_nObjTreeOldId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.SETCURRPARTLAYER)
End If
End Sub
#End Region ' TreeViewDoubleClickCommand
#Region "TreeViewMouseRightButtonCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property TreeViewMouseRightButtonCommand As ICommand
Get
If m_cmdTreeViewMouseRightButton Is Nothing Then
m_cmdTreeViewMouseRightButton = New RelayCommand(AddressOf TreeViewMouseRightButton)
End If
Return m_cmdTreeViewMouseRightButton
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub TreeViewMouseRightButton(ByVal param As Object)
If m_nObjTreeOldId <> GDB_ID.NULL Then
Map.refProjectVM.SetLastInteger(m_nObjTreeOldId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.SETCURRPARTLAYER)
End If
End Sub
#End Region ' TreeViewMouseRightButtonCommand
#Region "TreeViewMouseUpCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property TreeViewMouseUpCommand As ICommand
Get
If m_cmdTreeViewMouseUp Is Nothing Then
m_cmdTreeViewMouseUp = New RelayCommand(AddressOf TreeViewMouseUp)
End If
Return m_cmdTreeViewMouseUp
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub TreeViewMouseUp(ByVal param As Object)
' determino Id di eventuale item sotto il mouse
Dim nId As Integer = GDB_ID.NULL
If m_IsRightClickedTreeItem Then
nId = m_RightClickedTreeItemId
Else
nId = m_nObjTreeOldId
End If
' se Id coincide con il corrente
If nId <> GDB_ID.NULL Then 'And nId = m_nObjTreeOldId Then
' evidenzio
EgtSetMark(nId)
EgtDraw()
' lancio timer per successiva de-evidenziazione
ObjTreeTimer.Stop()
ObjTreeTimer.Start()
End If
End Sub
#End Region ' TreeViewMouseUpCommand
#Region "SelectCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property SelectCommand As ICommand
Get
If m_cmdSelect Is Nothing Then
m_cmdSelect = New RelayCommand(AddressOf SelectCmd)
End If
Return m_cmdSelect
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub SelectCmd(ByVal param As Object)
Dim bSelGroup As Boolean = ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
If Not bSelGroup Then
Map.refProjectVM.ExecuteCommand(Controller.CMD.SELECTPARTLAYEROBJ)
Else
Map.refProjectVM.ExecuteCommand(Controller.CMD.SELECTGROUP)
End If
End Sub
#End Region ' SelectCommand
#Region "DeselectCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property DeselectCommand As ICommand
Get
If m_cmdDeselect Is Nothing Then
m_cmdDeselect = New RelayCommand(AddressOf Deselect)
End If
Return m_cmdDeselect
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Deselect(ByVal param As Object)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.DESELECTPARTLAYEROBJ)
End Sub
#End Region ' DeselectCommand
#Region "NameCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property NameCommand As ICommand
Get
If m_cmdName Is Nothing Then
m_cmdName = New RelayCommand(AddressOf Name)
End If
Return m_cmdName
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Name(ByVal param As Object)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.SETNAME)
End Sub
#End Region ' NameCommand
#Region "InfoCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property InfoCommand As ICommand
Get
If m_cmdInfo Is Nothing Then
m_cmdInfo = New RelayCommand(AddressOf Info)
End If
Return m_cmdInfo
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Info(ByVal param As Object)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.SETINFO)
End Sub
#End Region ' InfoCommand
#Region "RelocateCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property RelocateCommand As ICommand
Get
If m_cmdRelocate Is Nothing Then
m_cmdRelocate = New RelayCommand(AddressOf Relocate)
End If
Return m_cmdRelocate
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Relocate(ByVal param As Object)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.RELOCATEPARTLAYEROBJ)
End Sub
#End Region ' RelocateCommand
#Region "CopyCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property CopyCommand As ICommand
Get
If m_cmdCopy Is Nothing Then
m_cmdCopy = New RelayCommand(AddressOf Copy)
End If
Return m_cmdCopy
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Copy(ByVal param As Object)
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.COPYPARTLAYEROBJ)
End Sub
#End Region ' CopyCommand
#Region "DeleteCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property DeleteCommand As ICommand
Get
If m_cmdDelete Is Nothing Then
m_cmdDelete = New RelayCommand(AddressOf Delete)
End If
Return m_cmdDelete
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Delete(ByVal param As Object)
' Se è un pezzo con lavorazioni, devo chiedere conferma della cancellazione
If EgtIsPart(RightClickedTreeItemId) And EgtExistsInfo(RightClickedTreeItemId, GDB_SI_LIST) Then
' Pezzo in lavorazione, vuoi cancellarlo lo stesso ? - Erase Confirm
If MessageBox.Show(EgtMsg(MSG_DRAWOPTION + 17), EgtMsg(MSG_DRAWOPTION + 16), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.No Then
Return
End If
End If
' Recupero Id vicino per prossimo selezionato in albero
Dim nNewId As Integer = EgtGetNext(RightClickedTreeItemId)
If nNewId = GDB_ID.NULL Then nNewId = EgtGetPrev(RightClickedTreeItemId)
If nNewId = GDB_ID.NULL Then nNewId = EgtGetParent(RightClickedTreeItemId)
' eseguo cancellazione
Map.refProjectVM.SetLastInteger(RightClickedTreeItemId)
Map.refProjectVM.ExecuteCommand(Controller.CMD.DELETE)
' Seleziono prossimo
SelectIdInObjTree(nNewId, False)
End Sub
#End Region ' DeleteCommand
#Region "SaveCommand"
''' <summary>
''' Returns a command that do Point.
''' </summary>
Public ReadOnly Property SaveCommand As ICommand
Get
If m_cmdSave Is Nothing Then
m_cmdSave = New RelayCommand(AddressOf Save)
End If
Return m_cmdSave
End Get
End Property
''' <summary>
''' Execute the Point. This method is invoked by the PointCommand.
''' </summary>
Public Sub Save(ByVal param As Object)
Dim sDir As String = String.Empty
GetPrivateProfileString(S_GENERAL, K_LASTNGEOBJDIR, "", sDir)
Dim nType As NGE = DirectCast(GetPrivateProfileInt(S_GEOMDB, K_SAVETYPE, NGE.CMPTEXT), NGE)
Map.refProjectVM.SaveObject(New SaveObjectParam(m_RightClickedTreeItemId, sDir, nType))
End Sub
#End Region ' SaveCommand
#End Region ' Commands
#Region "METHODS"
Private WithEvents ObjTreeTimer As New System.Windows.Threading.DispatcherTimer
Private m_nObjTreeOldId As Integer = GDB_ID.NULL
Private m_nObjTreeMenuId As Integer = GDB_ID.NULL
Private m_bEnableUpdateObjInObjTree As Boolean = True
Friend Sub SelectIdInObjTreeNoMark(nId As Integer)
SelectIdInObjTree(nId, False)
End Sub
Friend Sub SelectIdInObjTree(nId As Integer)
SelectIdInObjTree(nId, True)
End Sub
Friend Sub UpdateObjTreeOldId(ObjTreeOldId As Integer)
Me.m_nObjTreeOldId = ObjTreeOldId
End Sub
Friend Sub UpdateHeaderName(HeaderName As String)
Me.HeaderName = HeaderName
End Sub
Friend Sub UpdateHeaderColor(HeaderColor As Color3d)
Me.HeaderColor = New SolidColorBrush(Color.FromArgb(CByte(HeaderColor.A * 255 / 100), CByte(HeaderColor.R), CByte(HeaderColor.G), CByte(HeaderColor.B)))
End Sub
Friend Sub RightClickedLayerTreeItem(Id As Integer)
EgtResetMark(m_RightClickedTreeItemId)
m_RightClickedTreeItemId = Id
End Sub
Friend Sub IsRightClickedLayerTreeItem(Value As Boolean)
m_IsRightClickedTreeItem = Value
End Sub
Private Sub ObjTreeTickEvent(source As Object, e As EventArgs) Handles ObjTreeTimer.Tick
Dim nId As Integer = GDB_ID.NULL
If m_IsRightClickedTreeItem Then
nId = m_RightClickedTreeItemId
Else
nId = m_nObjTreeOldId
End If
If nId <> GDB_ID.NULL Then
EgtResetMark(nId)
EgtDraw()
End If
ObjTreeTimer.Stop()
End Sub
Friend Sub LoadObjTree()
LayerTreeViewItem.m_SendCmd = False
Dim nOldId As Integer = ClearObjTree()
AddGroupInObjTree(GDB_ID.ROOT, GDB_LV.USER, GDB_MD.STD, 0, LayerList)
If nOldId <> GDB_ID.NULL Then
m_bEnableUpdateObjInObjTree = False
If Not SelectIdInObjTree(nOldId, True) Then
Map.refInfoExpanderVM.SetInfoBox(String.Empty)
End If
m_bEnableUpdateObjInObjTree = True
Else
Map.refInfoExpanderVM.SetInfoBox(String.Empty)
End If
LayerTreeViewItem.m_SendCmd = True
End Sub
Friend Function ClearObjTree() As Integer
Dim nOldId As Integer = RevertOldIdInObjTree()
LayerList.Clear()
Return nOldId
End Function
Private Sub AddGroupInObjTree(nGroupId As Integer, nLevel As Integer, nMode As Integer, nDepth As Integer, ByRef PrevNodColl As ObservableCollection(Of LayerTreeViewItem))
Dim CurrNodColl As ObservableCollection(Of LayerTreeViewItem)
If nGroupId = GDB_ID.ROOT Then
CurrNodColl = PrevNodColl
Else
' livello
Dim nObjLev As Integer = GDB_LV.USER
EgtGetLevel(nGroupId, nObjLev)
If nObjLev = GDB_LV.TEMP Then
nLevel = GDB_LV.TEMP
ElseIf nLevel = GDB_LV.USER Then
nLevel = nObjLev
End If
' modo
Dim nObjMode As Integer = GDB_MD.STD
EgtGetMode(nGroupId, nObjMode)
If nObjMode = GDB_MD.HIDDEN Then
nMode = GDB_MD.HIDDEN
ElseIf nObjMode = GDB_MD.STD Then
nMode = nObjMode
End If
' tipo
Dim nGroupType As Integer = 0 ' 0=gruppo generico, 1=pezzo, 2=layer
If nLevel = GDB_LV.USER Then
nGroupType = nDepth
End If
' nome
Dim sName As String = String.Empty
Dim sText As String = String.Empty
If EgtGetName(nGroupId, sName) Then
If nGroupType = 1 Then
sText = sName + " (Part " + nGroupId.ToString + ")"
ElseIf nGroupType = 2 Then
sText = sName + " (Layer " + nGroupId.ToString + ")"
Else
sText = sName + " (Group " + nGroupId.ToString + ")"
End If
Else
If nGroupType = 1 Then
sText = "Part " + nGroupId.ToString
ElseIf nGroupType = 2 Then
sText = "Layer " + nGroupId.ToString
Else
sText = "Group " + nGroupId.ToString
End If
End If
' per visualizzare oggetti di livello diverso da utente o di modo diverso da standard, si deve avere il permesso
If (nLevel <> GDB_LV.USER Or nMode <> GDB_MD.STD) And m_nUserLevel < 5 Then
Return
End If
' inserisco il nodo nell'albero
Dim CurrColor As Color3d
EgtGetCalcColor(nGroupId, CurrColor)
Dim sImage As String = TypeToImageInObjTree(GDB_TY.GROUP, nGroupType)
Dim CurrNod As LayerTreeViewItem = New LayerTreeViewItem(nGroupId, sText, sImage, CurrColor)
Try
PrevNodColl.Add(CurrNod)
Catch
End Try
CurrNodColl = CurrNod.Items
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nGroupId, nStat)
CurrNod.OnOff = (nStat <> GDB_ST.OFF)
CurrNod.SetHidden(nMode <> GDB_MD.STD)
End If
Dim nObjs As Integer = EgtGetGroupObjs(nGroupId)
If (nObjs > 20000) Then
Dim sText As String = "Too many entities (" + nObjs.ToString() + ")"
CurrNodColl.Add(New LayerTreeViewItem(GDB_ID.NULL, sText))
Return
End If
Dim nId As Integer = EgtGetFirstInGroup(nGroupId)
While nId <> GDB_ID.NULL
'recupero il tipo di nodo
Dim nType As Integer = EgtGetType(nId)
'se gruppo
If nType = GDB_TY.GROUP Then
AddGroupInObjTree(nId, nLevel, nMode, nDepth + 1, CurrNodColl)
'se oggetto geometrico
ElseIf nType >= GDB_TY.GEO_VECTOR Then
Dim sTitle As String = String.Empty
EgtGetTitle(nId, sTitle)
Dim sName As String = String.Empty
Dim sText As String = String.Empty
If EgtGetName(nId, sName) Then
sText = sName + " (" + sTitle + " " + nId.ToString + ")"
Else
sText = sTitle + " " + nId.ToString
End If
Dim CurrColor As New Color3d(0, 0, 0, 0)
EgtGetColor(nId, CurrColor)
Dim sImage As String = TypeToImageInObjTree(nType, nDepth)
Dim CurrNod As LayerTreeViewItem = New LayerTreeViewItem(nId, sText, sImage, CurrColor)
CurrNodColl.Add(CurrNod)
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nId, nStat)
CurrNod.OnOff = (nStat <> GDB_ST.OFF)
Dim nObjMode As Integer = GDB_MD.STD
EgtGetMode(nId, nObjMode)
CurrNod.SetHidden(nObjMode <> GDB_MD.STD)
End If
'passo al successivo
nId = EgtGetNext(nId)
End While
End Sub
Private Function TypeToImageInObjTree(ByVal nType As Integer, ByVal nSubType As Integer) As String
Select Case nType
Case GDB_TY.GROUP
If nSubType = 1 Then
Return "/Resources/TreeView/Folder.png"
ElseIf nSubType = 2 Then
Return "/Resources/TreeView/Folder.png"
Else
Return "/Resources/TreeView/Group.ico"
End If
Case GDB_TY.GEO_VECTOR
Return "/Resources/TreeView/Vector.ico"
Case GDB_TY.GEO_POINT
Return "/Resources/TreeView/Point.ico"
Case GDB_TY.GEO_FRAME
Return "/Resources/TreeView/Frame.ico"
Case GDB_TY.CRV_LINE
Return "/Resources/TreeView/Line.ico"
Case GDB_TY.CRV_ARC
Return "/Resources/TreeView/Arc.ico"
Case GDB_TY.CRV_BEZ
Return "/Resources/TreeView/CBezier.ico"
Case GDB_TY.CRV_COMPO
Return "/Resources/TreeView/CCompo.ico"
Case GDB_TY.SRF_MESH
Return "/Resources/TreeView/STriMesh.ico"
Case GDB_TY.SRF_FRGN
Return "/Resources/TreeView/SFlatRegion.ico"
Case GDB_TY.SRF_BEZ
Return "/Resources/TreeView/SBezier.ico"
Case GDB_TY.VOL_ZMAP
Return "/Resources/TreeView/VolZmap.ico"
Case GDB_TY.EXT_TEXT
Return "/Resources/TreeView/Text.ico"
Case GDB_TY.EXT_DIMENSION
Return "/Resources/TreeView/Dimension.ico"
End Select
Return ""
End Function
Friend Sub UpdateObjTree()
' per aggiornare l'albero senza ricostruirlo da capo
' se c'è una entità corrente, ne aggiorno i dati
If m_nObjTreeOldId <> GDB_ID.NULL Then
Map.refInfoExpanderVM.UpdateObjDataInObjTree(m_nObjTreeOldId)
End If
End Sub
Friend Sub UpdateObjInObjTree(nId As Integer)
If m_bEnableUpdateObjInObjTree Then
' ripristino eventuale vecchio oggetto selezionato
RevertOldIdInObjTree()
' stampa dei dati del nuovo oggetto
Map.refInfoExpanderVM.UpdateObjDataInObjTree(nId)
' evidenzio l'oggetto
EgtSetMark(nId)
m_nObjTreeOldId = nId
' imposto il ridisegno della scena
EgtDraw()
' lancio timer per successiva de-evidenziazione
ObjTreeTimer.Stop()
ObjTreeTimer.Start()
Else
' stampa dei dati del nuovo oggetto
Map.refInfoExpanderVM.UpdateObjDataInObjTree(nId)
End If
End Sub
Friend Sub UpdateObjInObjTreeNoMark(nId As Integer)
If m_bEnableUpdateObjInObjTree Then
' ripristino eventuale vecchio oggetto selezionato
RevertOldIdInObjTree()
' stampa dei dati del nuovo oggetto
Map.refInfoExpanderVM.UpdateObjDataInObjTree(nId)
' salvo id corrente
m_nObjTreeOldId = nId
Else
' stampa dei dati del nuovo oggetto
Map.refInfoExpanderVM.UpdateObjDataInObjTree(nId)
End If
End Sub
Private Function RevertOldIdInObjTree() As Integer
' salvo il vecchio Id
Dim nOldId As Integer = m_nObjTreeOldId
' se non nullo...
If EgtExistsObj(m_nObjTreeOldId) Then
' smarco l'oggetto
EgtResetMark(m_nObjTreeOldId)
' annullo oggetto da ripristinare
m_nObjTreeOldId = GDB_ID.NULL
End If
Return nOldId
End Function
Private Function SelectIdInObjTree(nId As Integer, bMark As Boolean) As Boolean
Dim tNode As LayerTreeViewItem = SearchIdInLayerList(LayerList, nId, True)
If Not IsNothing(tNode) Then
If Not bMark Then LayerTreeViewItem.m_MarkOnSel = False
tNode.IsSelected = True
tNode.NotifyPropertyChanged("IsSelected")
If Not bMark Then LayerTreeViewItem.m_MarkOnSel = True
tNode.IsExpanded = True
m_nObjTreeOldId = nId
Return True
Else
m_nObjTreeOldId = GDB_ID.NULL
Return False
End If
End Function
Private Function SearchIdInLayerList(Tree As ObservableCollection(Of LayerTreeViewItem), nId As Integer, bExpand As Boolean) As LayerTreeViewItem
For Each Item In Tree
If Item.Id = nId Then
If bExpand Then Item.IsExpanded = True
Return Item
ElseIf Item.Items.Count() > 0 Then
Dim Item2 As LayerTreeViewItem = SearchIdInLayerList(Item.Items, nId, bExpand)
If Not IsNothing(Item2) Then
If bExpand Then Item.IsExpanded = True
Return Item2
End If
End If
Next
Return Nothing
End Function
#End Region ' Methods
End Class