diff --git a/Application.xaml.vb b/Application.xaml.vb index e13c6b6..579098c 100644 --- a/Application.xaml.vb +++ b/Application.xaml.vb @@ -64,6 +64,7 @@ Class Application Friend Const ISOVIEWSE As String = "IsoViewSE" Friend Const ISOVIEWNE As String = "IsoViewNE" Friend Const ISOVIEWNW As String = "IsoViewNW" + Friend Const VIEWTOCPLANE As String = "ViewToCPlane" Friend Const SETSTATUSANALYZE As String = "SetStatusAnalyze" Friend Const RESETSTATUSANALYZE As String = "ResetStatusAnalyze" Friend Const SETSTATUSGETDISTANCE As String = "SetStatusGetDistance" @@ -150,6 +151,11 @@ Class Application Friend Const RIGHTCLICKEDLAYERTREEITEM As String = "RightClickedLayerTreeItem" Friend Const SAVEOBJECT As String = "SaveObject" Friend Const REMOVEMARKFROMLASTOPERATION As String = "RemoveMarkFromLastOperation" + Friend Const SELECTEDOPERATION As String = "SelectedOperation" + + ' MachiningOptionPanel + ' MachiningTreeViewExpander + Friend Const MACHININGTREEVIEWEXPANDERISENABLED As String = "MachiningTreeViewExpanderIsEnabled" ' StatusBar messages Friend Const STATUSGRIDCOMMAND As String = "StatusGridCommand" diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index 5fc63cf..802207d 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -148,10 +148,10 @@ - + DrawOptionPanelView.xaml - + InfoExpanderView.xaml @@ -160,15 +160,13 @@ InputExpanderView.xaml - - MachiningTreeExpanderView.xaml - ManageLayerExpanderView.xaml + OperationExpanderView.xaml @@ -239,7 +237,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -251,14 +249,14 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/ProjectPage/GridViewPanel/GridViewPanelView.xaml b/ProjectPage/GridViewPanel/GridViewPanelView.xaml index fe8ff64..3b36ce9 100644 --- a/ProjectPage/GridViewPanel/GridViewPanelView.xaml +++ b/ProjectPage/GridViewPanel/GridViewPanelView.xaml @@ -49,6 +49,9 @@ + diff --git a/ProjectPage/GridViewPanel/GridViewPanelViewModel.vb b/ProjectPage/GridViewPanel/GridViewPanelViewModel.vb index b21694e..e58d0c2 100644 --- a/ProjectPage/GridViewPanel/GridViewPanelViewModel.vb +++ b/ProjectPage/GridViewPanel/GridViewPanelViewModel.vb @@ -160,6 +160,11 @@ Namespace EgtCAM5 Return EgtMsg(MSG_GRIDVIEWPANEL + 15) End Get End Property + Public ReadOnly Property ViewToCPlaneToolTip As String + Get + Return EgtMsg(MSG_GRIDVIEWPANEL + 32) + End Get + End Property 'Proprietà ToolTip Public ReadOnly Property CurveDirToolTip As String Get @@ -273,6 +278,7 @@ Namespace EgtCAM5 Private m_cmdIsoViewSE As ICommand Private m_cmdIsoViewNE As ICommand Private m_cmdIsoViewNW As ICommand + Private m_cmdViewToCPlane As ICommand Private m_cmdCurveDir As ICommand Private m_cmdAnalyze As ICommand Private m_cmdGetDist As ICommand @@ -740,95 +746,35 @@ Namespace EgtCAM5 #End Region ' IsoViewNWCommand - '#Region "CurveDirCommand" +#Region "ViewToCPlaneCommand" - ' ''' - ' ''' Returns a command that do CurveDir. - ' ''' - ' Public ReadOnly Property CurveDirCommand As ICommand - ' Get - ' If m_cmdCurveDir Is Nothing Then - ' m_cmdCurveDir = New RelayCommand(AddressOf CurveDir, AddressOf CanCurveDir) - ' End If - ' Return m_cmdCurveDir - ' End Get - ' End Property + ''' + ''' Returns a command that do GetDist. + ''' + Public ReadOnly Property ViewToCPlaneCommand As ICommand + Get + If m_cmdViewToCPlane Is Nothing Then + m_cmdViewToCPlane = New RelayCommand(AddressOf ViewToCPlane, AddressOf CanViewToCPlane) + End If + Return m_cmdViewToCPlane + End Get + End Property - ' ''' - ' ''' Execute the CurveDir. This method is invoked by the CurveDirCommand. - ' ''' - ' Public Sub CurveDir(ByVal param As Object) - ' Application.Msn.NotifyColleagues(Application.CURVEDIR) - ' End Sub + ''' + ''' Execute the GetDist. This method is invoked by the GetDistCommand. + ''' + Public Sub ViewToCPlane(ByVal param As Object) + Application.Msn.NotifyColleagues(Application.VIEWTOCPLANE) + End Sub - ' ''' - ' ''' Returns always true. - ' ''' - ' Private Function CanCurveDir(ByVal param As Object) As Boolean - ' Return True - ' End Function + ''' + ''' Returns always true. + ''' + Private Function CanViewToCPlane(ByVal param As Object) As Boolean + Return True + End Function - '#End Region ' CurveDirCommand - - '#Region "AnalyzeCommand" - - ' ''' - ' ''' Returns a command that do Analyze. - ' ''' - ' Public ReadOnly Property AnalyzeCommand As ICommand - ' Get - ' If m_cmdAnalyze Is Nothing Then - ' m_cmdAnalyze = New RelayCommand(AddressOf Analyze, AddressOf CanAnalyze) - ' End If - ' Return m_cmdAnalyze - ' End Get - ' End Property - - ' ''' - ' ''' Execute the Analyze. This method is invoked by the AnalyzeCommand. - ' ''' - ' Public Sub Analyze(ByVal param As Object) - ' Application.Msn.NotifyColleagues(Application.ANALYZE) - ' End Sub - - ' ''' - ' ''' Returns always true. - ' ''' - ' Private Function CanAnalyze(ByVal param As Object) As Boolean - ' Return True - ' End Function - - '#End Region ' AnalyzeCommand - - '#Region "GetDistCommand" - - ' ''' - ' ''' Returns a command that do GetDist. - ' ''' - ' Public ReadOnly Property GetDistCommand As ICommand - ' Get - ' If m_cmdGetDist Is Nothing Then - ' m_cmdGetDist = New RelayCommand(AddressOf GetDist, AddressOf CanGetDist) - ' End If - ' Return m_cmdGetDist - ' End Get - ' End Property - - ' ''' - ' ''' Execute the GetDist. This method is invoked by the GetDistCommand. - ' ''' - ' Public Sub GetDist(ByVal param As Object) - ' Application.Msn.NotifyColleagues(Application.GETDIST) - ' End Sub - - ' ''' - ' ''' Returns always true. - ' ''' - ' Private Function CanGetDist(ByVal param As Object) As Boolean - ' Return True - ' End Function - - '#End Region ' GetDistCommand +#End Region ' ViewToCPlaneCommand #Region "CPlaneTopCommand" diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelView.xaml b/ProjectPage/OptionPanel/DrawOptionPanelView.xaml similarity index 100% rename from ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelView.xaml rename to ProjectPage/OptionPanel/DrawOptionPanelView.xaml diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelView.xaml.vb b/ProjectPage/OptionPanel/DrawOptionPanelView.xaml.vb similarity index 100% rename from ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelView.xaml.vb rename to ProjectPage/OptionPanel/DrawOptionPanelView.xaml.vb diff --git a/ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelViewModel.vb b/ProjectPage/OptionPanel/DrawOptionPanelViewModel.vb similarity index 100% rename from ProjectPage/OptionPanel/DrawOptionPanel/DrawOptionPanelViewModel.vb rename to ProjectPage/OptionPanel/DrawOptionPanelViewModel.vb diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml index fac5732..ae6a7dd 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml @@ -1,10 +1,66 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" + xmlns:local="clr-namespace:EgtCAM5"> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml.vb deleted file mode 100644 index 492f63d..0000000 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderView.xaml.vb +++ /dev/null @@ -1,3 +0,0 @@ -Public Class MachiningTreeExpanderView - -End Class diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb index a39dc21..f36579c 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeExpanderViewModel.vb @@ -1,6 +1,184 @@ -Namespace EgtCAM5 +Imports System.Collections.ObjectModel +Imports EgtUILib + +Namespace EgtCAM5 Public Class MachiningTreeExpanderViewModel + Inherits ViewModelBase + +#Region "FIELDS & PROPERTIES" + + Private m_IsEnabled As Boolean + Public Property IsEnabled As Boolean + Get + Return m_IsEnabled + End Get + Set(value As Boolean) + If value <> m_IsEnabled Then + m_IsEnabled = value + OnPropertyChanged("IsEnabled") + End If + End Set + End Property + + ' Lista delle lavorazioni + Private m_MachiningsList As New ObservableCollection(Of FamilyMachiningTreeViewExpanderItem) + Public Property MachiningsList As ObservableCollection(Of FamilyMachiningTreeViewExpanderItem) + Get + Return m_MachiningsList + End Get + Set(value As ObservableCollection(Of FamilyMachiningTreeViewExpanderItem)) + m_MachiningsList = value + End Set + End Property + + ' Definizione comandi + Private m_cmdTreeViewDoubleClick As ICommand + +#End Region + +#Region "CONSTRUCTOR" + + Sub New() + ' Per caricare l'albero la prima volta che viene aperto + IsEnabled = False + LoadSelectedMachineMachinings() + Application.Msn.Register(Application.PROJECTPAGE_MACHININGMODE, Sub() + m_MachiningsList.Clear() + LoadSelectedMachineMachinings() + End Sub) + Application.Msn.Register(Application.MACHININGTREEVIEWEXPANDERISENABLED, Sub(bValue As Boolean) + IsEnabled = bValue + End Sub) + End Sub + +#End Region + +#Region "COMMANDS" + +#Region "TreeViewDoubleClickCommand" + + ''' + ''' Returns a command that do TreeViewDoubleClick. + ''' + Public ReadOnly Property TreeViewDoubleClickCommand As ICommand + Get + If m_cmdTreeViewDoubleClick Is Nothing Then + m_cmdTreeViewDoubleClick = New RelayCommand(AddressOf TreeViewDoubleClick, AddressOf CanTreeViewDoubleClick) + End If + Return m_cmdTreeViewDoubleClick + End Get + End Property + + ''' + ''' Execute the TreeViewDoubleClick. This method is invoked by the TreeViewDoubleClickCommand. + ''' + Public Sub TreeViewDoubleClick(ByVal param As Object) + If TypeOf param Is MachiningTreeViewExpanderItem Then + Dim Machining As MachiningTreeViewExpanderItem = DirectCast(param, MachiningTreeViewExpanderItem) + Dim x = EgtAddMachining(MachiningTypeToString(DirectCast(Machining.Type, MCH_MY)) & "_1", Machining.Name) + Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST) + Application.Msn.NotifyColleagues(Application.MACHININGTREEVIEWEXPANDERISENABLED, False) + End If + End Sub + + ''' + ''' Returns always true. + ''' + Private Function CanTreeViewDoubleClick(ByVal param As Object) As Boolean + Return True + End Function + + Private Function MachiningTypeToString(Type As MCH_MY) As String + Select Case Type + Case MCH_MY.DRILLING + Return EgtMsg(MSG_MACHININGSDBPAGE + 1) + Case MCH_MY.SAWING + Return EgtMsg(MSG_MACHININGSDBPAGE + 2) + Case MCH_MY.MILLING + Return EgtMsg(MSG_MACHININGSDBPAGE + 3) + Case MCH_MY.POCKETING + Return EgtMsg(MSG_MACHININGSDBPAGE + 4) + Case MCH_MY.MORTISING + Return EgtMsg(MSG_MACHININGSDBPAGE + 5) + Case MCH_MY.SAWROUGHING + Return EgtMsg(MSG_MACHININGSDBPAGE + 6) + Case MCH_MY.SAWFINISHING + Return EgtMsg(MSG_MACHININGSDBPAGE + 7) + Case Else + Return String.Empty + End Select + End Function + +#End Region ' TreeViewDoubleClickCommand + +#End Region ' Commands + +#Region "METHODS" + + ''' + ''' Method that search the machines in the correct folder and add to the MachinesList those valid. + ''' + Private Sub LoadSelectedMachineMachinings() + Dim ActiveMachiningsTypes() As MachiningsType = ReadActiveMachiningsFamilies() + For Each MachiningsType In ActiveMachiningsTypes + Dim FamilyTreeView As New FamilyMachiningTreeViewExpanderItem(MachiningsType.TypeName, MachiningsType.TypeId) + MachiningsList.Add(FamilyTreeView) + Dim MachiningName As String = String.Empty + If EgtMdbGetFirstMachining(MachiningsType.TypeId, MachiningName) Then + FamilyTreeView.Items.Add(New MachiningTreeViewExpanderItem(MachiningName, MachiningsType.TypeId)) + While EgtMdbGetNextMachining(MachiningsType.TypeId, MachiningName) + FamilyTreeView.Items.Add(New MachiningTreeViewExpanderItem(MachiningName, MachiningsType.TypeId)) + End While + End If + Next + ' Se esiste almeno una famiglia di lavorazioni, la seleziono + If MachiningsList.Count > 0 Then + MachiningsList(0).IsSelected = True + MachiningsList(0).NotifyPropertyChanged("IsSelected") + End If + End Sub + + ''' + ''' Method that search the machines in the correct folder and add to the MachinesList those valid. + ''' + Private Function ReadActiveMachiningsFamilies() As MachiningsType() + Dim ActiveMachiningsFamiliesList As New List(Of MachiningsType) + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_DRILLING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.DRILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 1)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 2)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MILLING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MILLING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 3)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_POCKETING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.POCKETING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 4)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_MORTISING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.MORTISING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 5)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWROUGHING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWROUGHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 6)}) + End If + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWFINISHING, 0, m_sDbsCurrMachIniFilePath) <> 0 Then + ActiveMachiningsFamiliesList.Add(New MachiningsType With {.TypeId = MCH_MY.SAWFINISHING, .TypeName = EgtMsg(MSG_MACHININGSDBPAGE + 7)}) + End If + Return ActiveMachiningsFamiliesList.ToArray + End Function + + ''' + ''' Structure that represent a tool's family, containing family type and family name + ''' + Structure MachiningsType + + Friend TypeId As MCH_MY + Friend TypeName As String + + End Structure + +#End Region End Class diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeViewExpander.vb b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeViewExpander.vb new file mode 100644 index 0000000..129f9f0 --- /dev/null +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/MachiningsTreeViewExpander/MachiningTreeViewExpander.vb @@ -0,0 +1,102 @@ +Imports EgtUILib + +''' +''' Class that represent a Machining in the treeview. +''' It's an element in the treeview that represent the child of familymachiningtreeviewitem, but also the class that read and write in the machining's database +''' +Public Class MachiningTreeViewExpanderItem + Inherits ChildItem + +#Region "Machining Property" + + Private m_Type As MCH_MY + Public ReadOnly Property Type As Integer + Get + Return m_Type + End Get + End Property + + ''' + ''' Property that determines if the Machining is selected or not + ''' + Public Overrides Property IsSelected As Boolean + Get + Return m_isSelected + End Get + Set(value As Boolean) + If (value <> m_isSelected) Then + m_isSelected = value + ' If Machining is selected, set it as current and notify all machining's property + ' to refresh them values with those of the new selected machining + If value Then + EgtMdbSetCurrMachining(Me.Name) + Else + End If + + End If + + End Set + + End Property + + + +#End Region ' Machining Property + +#Region "Constructors" + + Sub New(Name As String, Type As MCH_MY) + MyBase.New(Name) + Me.m_Type = Type + End Sub + +#End Region ' Constructors + +End Class + + +''' +''' Class that represent a FamilyMachining in the treeview. +''' It's an element in the treeview that represent a folder, but also a machining family +''' +Public Class FamilyMachiningTreeViewExpanderItem + Inherits ParentItem + + Private m_MachiningType As MCH_MY + ''' + ''' Property that determines the machining type of the family + ''' + Public Property MachiningType As MCH_MY + Get + Return m_MachiningType + End Get + Set(value As MCH_MY) + m_MachiningType = value + End Set + End Property + + ''' + ''' Property that determines if the Machining is selected or not + ''' + Public Overrides Property IsSelected As Boolean + Get + Return m_isSelected + End Get + Set(value As Boolean) + If (value <> m_isSelected) Then + m_isSelected = value + End If + End Set + End Property + + ''' + ''' Constructor that receive the name of the FamilyMachiningTreeViewItem, the MachiningType, and set + ''' the picture(Folder.png) + ''' + Sub New(Name As String, MachiningType As MCH_MY) + MyBase.New(Name) + Me.MachiningType = MachiningType + Me.PictureString = "/Resources/TreeView/Folder.png" + End Sub + +End Class diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml index e813b4a..2d47ba8 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml @@ -11,8 +11,8 @@