diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index 2beebc5..f1519a7 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -67,7 +67,7 @@ true - pdbonly + None x86 MinimumRecommendedRules.ruleset @@ -86,7 +86,10 @@ - + + False + ..\..\EgtProg\EgtCAM5\System.Windows.Interactivity.dll + diff --git a/EgtCAM5Resources.xaml b/EgtCAM5Resources.xaml index 2473816..fe51379 100644 --- a/EgtCAM5Resources.xaml +++ b/EgtCAM5Resources.xaml @@ -182,13 +182,13 @@ diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb index 5c90cc6..ea02ca0 100644 --- a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb +++ b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/LayerTreeView.vb @@ -85,7 +85,7 @@ Public Class LayerTreeViewItem MyBase.New(Name) Me.m_Id = Id Me.PictureString = Image - Me.LayerColor = New SolidColorBrush(Color.FromArgb(CurrColor.A, CurrColor.R, CurrColor.G, CurrColor.B)) + Me.LayerColor = New SolidColorBrush(Color.FromArgb(CByte(CurrColor.A), CByte(CurrColor.R), CByte(CurrColor.G), CByte(CurrColor.B))) End Sub Sub New(Id As Integer, Name As String) diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml index 9509667..e336a02 100644 --- a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml +++ b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderView.xaml @@ -24,6 +24,9 @@ + + + diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderViewModel.vb b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderViewModel.vb index 0348031..f20f559 100644 --- a/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/DrawOptionPanel/ManageLayerExpander/ManageLayerExpanderViewModel.vb @@ -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" + + ''' + ''' Returns a command that do Point. + ''' + 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 + + ''' + ''' Execute the Point. This method is invoked by the PointCommand. + ''' + 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 + + ''' + ''' Returns always true. + ''' + 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 diff --git a/Utility.vb b/Utility.vb index 3e13b20..1001041 100644 --- a/Utility.vb +++ b/Utility.vb @@ -108,10 +108,10 @@ Public Module Utility End Sub Friend Sub WindowToWinPos(Window As Window, WinPos As WinPos) - WinPos.nTop = Window.Top - WinPos.nLeft = Window.Left - WinPos.nHeight = Window.Height - WinPos.nWidth = Window.Width + WinPos.nTop = CInt(Window.Top) + WinPos.nLeft = CInt(Window.Left) + WinPos.nHeight = CInt(Window.Height) + WinPos.nWidth = CInt(Window.Width) WinPos.nFlag = If(Window.WindowState = WindowState.Maximized, 1, 0) End Sub