EgtCAM5 :
- sistemazioni per TreeView.
This commit is contained in:
+72
-41
@@ -37,6 +37,7 @@ Namespace EgtCAM5
|
||||
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
|
||||
|
||||
' Lista dei layer
|
||||
@@ -76,7 +77,7 @@ Namespace EgtCAM5
|
||||
Me.HeaderName = HeaderName
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.UPDATEHEADERCOLOR, Sub(HeaderColor As Color3d)
|
||||
Me.HeaderColor = New SolidColorBrush(Color.FromArgb(HeaderColor.A, HeaderColor.R, HeaderColor.G, HeaderColor.B))
|
||||
Me.HeaderColor = New SolidColorBrush(Color.FromArgb(CByte(HeaderColor.A), CByte(HeaderColor.R), CByte(HeaderColor.G), CByte(HeaderColor.B)))
|
||||
End Sub)
|
||||
Application.Msn.Register(Application.UPDATEOBJTREEOLDID, Sub(ObjTreeOldId As Integer)
|
||||
Me.m_nObjTreeOldId = ObjTreeOldId
|
||||
@@ -243,6 +244,64 @@ Namespace EgtCAM5
|
||||
|
||||
#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, AddressOf CanTreeViewMouseUp)
|
||||
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
|
||||
Dim TNode As LayerTreeViewItem = DirectCast(param, LayerTreeViewItem)
|
||||
nId = TNode.Id
|
||||
' se Id coincide con il corrente
|
||||
If nId <> GDB_ID.NULL And nId = m_nObjTreeOldId Then
|
||||
' evidenzio
|
||||
EgtSetMark(m_nObjTreeOldId)
|
||||
EgtDraw()
|
||||
' lancio timer per successiva de-evidenziazione
|
||||
ObjTreeTimer.Stop()
|
||||
ObjTreeTimer.Start()
|
||||
End If
|
||||
' se rilascio tasto destro
|
||||
'If e.Button = Windows.Forms.MouseButtons.Right Then
|
||||
' ' Id pezzo sotto il mouse
|
||||
' m_nObjTreeMenuId = nId
|
||||
' ' verifico stato visualizzazione per abilitare voci menù
|
||||
' Dim nStat As GDB_ST = GDB_ST.ON_
|
||||
' Dim bOn As Boolean = EgtGetCalcStatus(m_nObjTreeMenuId, nStat) And nStat <> GDB_ST.OFF
|
||||
' For Each Item As ToolStripItem In ContextMenuTreeView1.Items
|
||||
' If Item.Name = "cmdSetName" Or Item.Name = "cmdSetInfo" Then
|
||||
' Item.Enabled = True
|
||||
' Else
|
||||
' Item.Enabled = bOn
|
||||
' End If
|
||||
' Next
|
||||
' 'ContextMenuTreeView1.Show(TreeView1, e.Location)
|
||||
'End If
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Returns always true.
|
||||
''' </summary>
|
||||
Private Function CanTreeViewMouseUp(ByVal param As Object) As Boolean
|
||||
Return True
|
||||
End Function
|
||||
|
||||
#End Region ' TreeViewMouseUpCommand
|
||||
|
||||
#End Region ' Commands
|
||||
|
||||
#Region "METHODS"
|
||||
@@ -250,6 +309,7 @@ Namespace EgtCAM5
|
||||
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
|
||||
|
||||
Private Sub ObjTreeTickEvent(source As Object, e As EventArgs) Handles ObjTreeTimer.Tick
|
||||
If m_nObjTreeOldId <> GDB_ID.NULL Then
|
||||
@@ -263,8 +323,9 @@ Namespace EgtCAM5
|
||||
Dim nOldId As Integer = ClearObjTree()
|
||||
AddGroupInObjTree(GDB_ID.ROOT, GDB_LV.USER, 0, LayerList)
|
||||
If nOldId <> GDB_ID.NULL Then
|
||||
m_bEnableUpdateObjInObjTree = False
|
||||
SelectIdInObjTree(nOldId)
|
||||
Application.Msn.NotifyColleagues(Application.UPDATEOBJDATAINOBJTREE, m_nObjTreeOldId)
|
||||
m_bEnableUpdateObjInObjTree = True
|
||||
Else
|
||||
Application.Msn.NotifyColleagues(Application.SETINFOBOX, String.Empty)
|
||||
End If
|
||||
@@ -414,41 +475,8 @@ Namespace EgtCAM5
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Private Sub ObjTree_MouseUp(ByVal sender As Object, e As MouseEventArgs) Handles TreeView1.MouseUp
|
||||
' ' determino Id di eventuale item sotto il mouse
|
||||
' Dim nId As Integer = GDB_ID.NULL
|
||||
' Dim TNode As TreeNode = TreeView1.GetNodeAt(e.Location)
|
||||
' If TNode IsNot Nothing Then
|
||||
' Int32.TryParse(TNode.Name, nId)
|
||||
' End If
|
||||
' ' se Id coincide con il corrente
|
||||
' If nId <> GDB_ID.NULL And nId = m_nObjTreeOldId Then
|
||||
' ' evidenzio
|
||||
' EgtSetMark(m_nObjTreeOldId)
|
||||
' EgtDraw()
|
||||
' ' lancio timer per successiva de-evidenziazione
|
||||
' ObjTreeTimer.Stop()
|
||||
' ObjTreeTimer.Start()
|
||||
' End If
|
||||
' ' se rilascio tasto destro
|
||||
' If e.Button = Windows.Forms.MouseButtons.Right Then
|
||||
' ' Id pezzo sotto il mouse
|
||||
' m_nObjTreeMenuId = nId
|
||||
' ' verifico stato visualizzazione per abilitare voci menù
|
||||
' Dim nStat As GDB_ST = GDB_ST.ON_
|
||||
' Dim bOn As Boolean = EgtGetCalcStatus(m_nObjTreeMenuId, nStat) And nStat <> GDB_ST.OFF
|
||||
' For Each Item As ToolStripItem In ContextMenuTreeView1.Items
|
||||
' If Item.Name = "cmdSetName" Or Item.Name = "cmdSetInfo" Then
|
||||
' Item.Enabled = True
|
||||
' Else
|
||||
' Item.Enabled = bOn
|
||||
' End If
|
||||
' Next
|
||||
' ContextMenuTreeView1.Show(TreeView1, e.Location)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Private Sub UpdateObjInObjTree(ByVal nId As Integer)
|
||||
If Not m_bEnableUpdateObjInObjTree Then Return
|
||||
' ripristino eventuale vecchio oggetto selezionato
|
||||
RevertOldIdInObjTree()
|
||||
' stampa dei dati del nuovo oggetto
|
||||
@@ -477,7 +505,7 @@ Namespace EgtCAM5
|
||||
End Function
|
||||
|
||||
Private Function SelectIdInObjTree(ByVal nId As Integer) As Boolean
|
||||
Dim tNode As LayerTreeViewItem = SearchIdInLayerList(nId)
|
||||
Dim tNode As LayerTreeViewItem = SearchIdInLayerList(LayerList, nId)
|
||||
If Not IsNothing(tNode) Then
|
||||
tNode.IsSelected = True
|
||||
tNode.IsExpanded = True
|
||||
@@ -489,12 +517,15 @@ Namespace EgtCAM5
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function SearchIdInLayerList(nId As Integer) As LayerTreeViewItem
|
||||
For Each Item In LayerList
|
||||
Private Function SearchIdInLayerList(Tree As ObservableCollection(Of LayerTreeViewItem), nId As Integer) As LayerTreeViewItem
|
||||
For Each Item In Tree
|
||||
If Item.Id = nId Then
|
||||
Return Item
|
||||
Else
|
||||
Return SearchIdInLayerList(Item.Id)
|
||||
ElseIf Item.Items.Count() > 0 Then
|
||||
Dim Item2 As LayerTreeViewItem = SearchIdInLayerList(Item.Items, nId)
|
||||
If Not IsNothing(Item2) Then
|
||||
Return Item2
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Return Nothing
|
||||
|
||||
Reference in New Issue
Block a user