From b3b11abd6f1a194db611ea9c6ea1d5851faa134e Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Mon, 26 Sep 2016 11:27:05 +0000 Subject: [PATCH] =?UTF-8?q?EgtCAM5=20:=20-=20Aggiunta=20deselezione=20di?= =?UTF-8?q?=20tutto=20quando=20vado=20in=20simulazione.=20-=20Quando=20si?= =?UTF-8?q?=20=C3=A8=20definita=20una=20nuova=20lavorazione=20apre=20diret?= =?UTF-8?q?tamente=20i=20parametri=20di=20questa.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtCAM5.vbproj | 2 +- IniFile.vb | 3 + Internals/MruList.vb | 114 ++++++++++++++++++ .../OperationExpanderView.xaml | 5 +- .../OperationExpanderViewModel.vb | 9 ++ .../SimulationExpanderViewModel.vb | 1 + ProjectPage/ProjectViewModel.vb | 60 +++++---- TopCommandBar/TopCommandBarViewModel.vb | 13 +- 8 files changed, 177 insertions(+), 30 deletions(-) create mode 100644 Internals/MruList.vb diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index e5cca7a..c6b381d 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -129,6 +129,7 @@ + OptionsView.xaml @@ -395,7 +396,6 @@ - diff --git a/IniFile.vb b/IniFile.vb index 6371629..1b60e2a 100644 --- a/IniFile.vb +++ b/IniFile.vb @@ -46,6 +46,9 @@ Module IniFile Friend nExtSStep As Integer Friend MinLnColor As Color3d Friend MajLnColor As Color3d + ' TopCommandBar + Friend m_MruFiles As New MruList(S_MRUFILES, 8) + Friend m_MruScripts As New MruList(S_MRUSCRIPTS, 8) ' Current Machine Friend m_sMachineName As String Friend m_sCurrMachIniFilePath As String diff --git a/Internals/MruList.vb b/Internals/MruList.vb new file mode 100644 index 0000000..982e3a0 --- /dev/null +++ b/Internals/MruList.vb @@ -0,0 +1,114 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2015 +'---------------------------------------------------------------------------- +' File : MruList.vb Data : 27.02.15 Versione : 1.6b7 +' Contenuto : Classe MruList (gestione elenco file appena usati). +' +' +' +' Modifiche : 27.02.15 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +'-------------------------------------------------------------------------------------------------- +Imports System.Collections.ObjectModel + +Public Class MruList + + '--------------------------------------------------------------------------- + Private m_sSection As String + Private m_nMaxEntries As Integer + Friend m_FileNames As ObservableCollection(Of String) + + '--------------------------------------------------------------------------- + Public Sub New(sSection As String, nMaxEntries As Integer) + ' Inizializzo + m_sSection = sSection + m_nMaxEntries = nMaxEntries + m_FileNames = New ObservableCollection(Of String) + ' Carico lista da Ini. + LoadMruList() + End Sub + + '--------------------------------------------------------------------------- + Private Sub LoadMruList() + ' Pulisco la lista dei file + m_FileNames.Clear() + ' Carico la lista dei file salvati in INI + Dim sFileName As String = String.Empty + For i As Integer = 1 To m_nMaxEntries + Dim sKey As String = K_FILE + i.ToString() + If GetPrivateProfileString(m_sSection, sKey, "", sFileName) > 0 Then + m_FileNames.Add(sFileName) + End If + Next + End Sub + + '--------------------------------------------------------------------------- + Private Sub SaveMruList() + For i As Integer = 1 To m_nMaxEntries + Dim sKey As String = K_FILE + i.ToString() + If i <= m_FileNames.Count Then + WritePrivateProfileString(m_sSection, sKey, m_FileNames(i).ToString) + Else + WritePrivateProfileString(m_sSection, sKey, "") + End If + Next + End Sub + + '--------------------------------------------------------------------------- + Public Sub Add(ByVal sFileName As String) + ' Se già presente, rimuovo il file dalla lista + Dim i As Integer = FileNameIndex(sFileName) + If i > 0 Then + m_FileNames.Remove(i) + End If + ' Aggiungo il file in cima alla lista + If m_FileNames.Count > 0 Then + m_FileNames.Insert(0, sFileName) + Else + m_FileNames.Add(sFileName) + End If + ' Se la lista ha superato la massima dimensione, cancello l'ultimo record + If m_FileNames.Count > m_nMaxEntries Then + m_FileNames.RemoveAt(m_nMaxEntries + 1) + End If + ' Salvo la lista aggiornata + SaveMruList() + End Sub + + '--------------------------------------------------------------------------- + Private Function FileNameIndex(ByVal sFileName As String) As Integer + For i As Integer = 1 To m_FileNames.Count + If String.Compare(m_FileNames(i).ToString, sFileName, True) = 0 Then + Return i + End If + Next + Return 0 + End Function + + '--------------------------------------------------------------------------- + Public Sub Remove(ByVal sFileName As String) + Dim i As Integer = FileNameIndex(sFileName) + If i > 0 Then + ' Rimuovo il file + m_FileNames.RemoveAt(i) + ' Salvo lalista aggiornata + SaveMruList() + End If + End Sub + + '--------------------------------------------------------------------------- + Public Function GetFileName(ByVal nInd As Integer, ByRef sFileName As String) As Boolean + If nInd > 0 And nInd <= m_FileNames.Count() Then + sFileName = m_FileNames(nInd).ToString() + Return True + Else + sFileName = String.Empty + Return False + End If + + End Function + +End Class diff --git a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml index b428022..91fa2ad 100644 --- a/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml +++ b/ProjectPage/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderView.xaml @@ -73,8 +73,11 @@ - + + + m_IsExpanded Then If value Then + EgtDeselectAll() Application.Msn.NotifyColleagues(Application.GETDISTANCE_ISCHECKED, False) InitializeSimulation() Else diff --git a/ProjectPage/ProjectViewModel.vb b/ProjectPage/ProjectViewModel.vb index 017f6f6..9283c70 100644 --- a/ProjectPage/ProjectViewModel.vb +++ b/ProjectPage/ProjectViewModel.vb @@ -13,6 +13,13 @@ Namespace EgtCAM5 Private m_CloseProgram As Boolean = False + ' Variabili in cui salvo i filtri di selezione della modalità Draw e che poi ripristino all'uscita dalla modalità Machining + Private m_bSelZeroDim As Boolean + Private m_bSelCurve As Boolean + Private m_bSelSurf As Boolean + Private m_bSelVolume As Boolean + Private m_bSelExtra As Boolean + Private m_bLoaded As Boolean = False 'PROJECT PAGE'S SCENE FIELDS AND PROPERTIES @@ -33,6 +40,7 @@ Namespace EgtCAM5 End Property ' Scene controller Private WithEvents m_Controller As New Controller + ' Definizione comandi Private m_cmdLoaded As ICommand @@ -68,11 +76,13 @@ Namespace EgtCAM5 RegisterDrawOptionPanelCommands() ' Funzione che contiene la registrazione di tutti i comandi della StatusBar RegisterStatusBarCommands() - ' Setto variabile che mi dice se sono in modalità macchina per gestire il click sulla scena e disattivo la gestione del click da libreria + ' Cambio impostazioni griglia a seconda che sia in modalità Draw o Machining Application.Msn.Register(Application.MACHININGMODE_ISCHECKED, Sub() + m_ProjectScene.GetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra) Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bMachiningShowGrid, IniFile.m_bShowGridFrame)) End Sub) Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub() + m_ProjectScene.SetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra) Application.Msn.NotifyColleagues(Application.UPDATESTATUSGRID, New UpdateStatusGridParam(IniFile.m_bDrawShowGrid, IniFile.m_bShowGridFrame)) End Sub) Application.Msn.Register(Application.SETSCENESELMODE, Sub(SceneSelMode As SceneSelModeOpt) @@ -225,9 +235,8 @@ Namespace EgtCAM5 ' Apro progetto vuoto Application.Msn.NotifyColleagues(Application.NEWPROJECT) ' Imposto stato filtro selezione - Dim bZeroDim, bCurve, bSurf, bVolume, bExtra As Boolean - m_ProjectScene.GetObjFilterForSel(bZeroDim, bCurve, bSurf, bVolume, bExtra) - m_Controller.MouseSetObjFilterForSelect(bZeroDim, bCurve, bSurf, bVolume, bExtra) + m_ProjectScene.GetObjFilterForSel(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra) + m_Controller.MouseSetObjFilterForSelect(m_bSelZeroDim, m_bSelCurve, m_bSelSurf, m_bSelVolume, m_bSelExtra) End Sub Private Sub ProcessCommandLine() @@ -837,13 +846,13 @@ Namespace EgtCAM5 Private Sub OnOpenProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnOpenProject WritePrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile)) - 'If bOk Then - ' m_MruFiles.Add(sFile) - 'Else - ' m_MruFiles.Remove(sFile) - ' Dim sMsg As String = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file - ' MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error - 'End If + If bOk Then + IniFile.m_MruFiles.Add(sFile) + Else + IniFile.m_MruFiles.Remove(sFile) + Dim sMsg As String = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file + MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error + End If End Sub Private Sub OnSavingProject(ByVal sender As Object) Handles m_Controller.OnSavingProject @@ -851,13 +860,13 @@ Namespace EgtCAM5 Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnSavedProject WritePrivateProfileString(S_GENERAL, K_LASTNGEDIR, Path.GetDirectoryName(sFile)) - 'If bOk Then - ' m_MruFiles.Add(sFile) - 'Else - ' m_MruFiles.Remove(sFile) - ' Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file - ' MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButtons.OK, MessageBoxIcon.Error) ' Error - 'End If + If bOk Then + IniFile.m_MruFiles.Add(sFile) + Else + IniFile.m_MruFiles.Remove(sFile) + Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file + MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If End Sub Private Sub OnSavingObject(ByVal sender As Object) Handles m_Controller.OnSavingObject @@ -865,13 +874,13 @@ Namespace EgtCAM5 Private Sub OnSavedObject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean) Handles m_Controller.OnSavedObject WritePrivateProfileString(S_GENERAL, K_LASTNGEOBJDIR, Path.GetDirectoryName(sFile)) - 'If bOk Then - ' m_MruFiles.Add(sFile) - 'Else - ' m_MruFiles.Remove(sFile) - ' Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file - ' MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButtons.OK, MessageBoxIcon.Error) ' Error - 'End If + If bOk Then + IniFile.m_MruFiles.Add(sFile) + Else + IniFile.m_MruFiles.Remove(sFile) + Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file + MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error + End If End Sub Private Sub OnImportingProject(ByVal sender As Object, ByVal bOkType As Boolean) Handles m_Controller.OnImportingProject @@ -1052,6 +1061,7 @@ Namespace EgtCAM5 Select Case m_SceneSelMode Case SceneSelModeOpt.NULL m_ProjectScene.SetObjFilterForSel(False, False, False, False, False) + EgtSetObjFilterForSelect(True, True, True, True, True) Case SceneSelModeOpt.PARTCURVES m_ProjectScene.SetObjFilterForSel(False, True, False, False, False) Case SceneSelModeOpt.PARTSURFACES diff --git a/TopCommandBar/TopCommandBarViewModel.vb b/TopCommandBar/TopCommandBarViewModel.vb index 752dd74..617b853 100644 --- a/TopCommandBar/TopCommandBarViewModel.vb +++ b/TopCommandBar/TopCommandBarViewModel.vb @@ -1,4 +1,5 @@ -Imports EgtUILib +Imports System.Collections.ObjectModel +Imports EgtUILib Namespace EgtCAM5 @@ -7,6 +8,12 @@ Namespace EgtCAM5 #Region "FIELDS & PROPERTIES" + Private ReadOnly Property MruFiles As ObservableCollection(Of String) + Get + Return IniFile.m_MruFiles.m_FileNames + End Get + End Property + ' Definizione comandi Private m_cmdNew As ICommand Private m_cmdOpen As ICommand @@ -111,8 +118,8 @@ Namespace EgtCAM5 Else ' Deevidenzio l'ultima operazione evidenziata Application.Msn.NotifyColleagues(Application.REMOVEMARKFROMLASTOPERATION) - ' Abilito selezione di tutto - Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.ALL) + ' e deseleziono tutto + EgtDeselectAll() End If End If End Set