From 7eb824074954c8cc41ba4716337b44e98b0f74ab Mon Sep 17 00:00:00 2001 From: Renzo Lanza Date: Mon, 14 Sep 2020 09:42:54 +0000 Subject: [PATCH] =?UTF-8?q?EgtCAM5=202.2i2=20:=20-=20MachGroupPanelVM,=20M?= =?UTF-8?q?achinePanelVM,=20StatusBarVM=20spostati=20in=20EgtWPFLib5.=20Or?= =?UTF-8?q?a=20qua=20sono=20presenti=20le=20versioni=20My=5F=20che=20eredi?= =?UTF-8?q?tano=20quelle=20della=20Libreria.=20-=20ComboBox=20della=20Macc?= =?UTF-8?q?hina=20corrente=20spostata=20in=20MachinePanel=20(accanto=20a?= =?UTF-8?q?=20Db=20Ut./Lav./SetUp).=20-=20modificato=20OptionPanel=20in=20?= =?UTF-8?q?modo=20da=20gestire=20i=20nuovi=20DrawOptionPanel=20e=20Machini?= =?UTF-8?q?ngOptionPanel=20in=20base=20alle=20modalit=C3=A0=20DISEGNA=20e?= =?UTF-8?q?=20LAVORA.=20-=20ogni=20Expander=20di=20MachiningOptionPanel=20?= =?UTF-8?q?ora=20ha=20il=20suo=20VM=20e=20il=20suo=20V.=20-=20nuova=20gest?= =?UTF-8?q?ione=20degli=20Expander=20di=20MachiningOptionPanel=20tramite?= =?UTF-8?q?=20funzioni=20Init=20e=20Exit.=20-=20barra=20TOPTRAY=20ora=20pu?= =?UTF-8?q?=C3=B2=20estendersi=20su=20una=20seconda=20riga=20in=20base=20a?= =?UTF-8?q?=20larghezza=20finestra.=20-=20eliminati=20molti=20Application.?= =?UTF-8?q?Msn.Register/NotifyColleagues.=20Ora=20le=20funzioni=20che=20ch?= =?UTF-8?q?iamavano=20sono=20chiamate=20tramite=20i=20riferimenti=20in=20M?= =?UTF-8?q?ap.=20-=20corretta=20selezione=20superfici=20quando=20si=20sceg?= =?UTF-8?q?lie=20Nuova=20Lav.=20in=20LAVORA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EgtCAM5.vbproj | 83 +- InstrumentPanel/InstrumentPanelVM.vb | 1 + ...hGroupPanelVM.vb => MyMachGroupPanelVM.vb} | 164 +-- MachinePanel/MachinePanelV.xaml | 16 +- MachinePanel/MachinePanelVM.vb | 283 ---- MachinePanel/MyMachinePanelVM.vb | 464 +++++++ MainWindow/MainWindowVM.vb | 2 +- My Project/AssemblyInfo.vb | 4 +- OptionPanel/DrawOptionPanelV.xaml | 16 + OptionPanel/DrawOptionPanelV.xaml.vb | 7 + OptionPanel/DrawOptionPanelVM.vb | 63 + .../EstimationsExpanderV.xaml | 44 + .../EstimationsExpanderV.xaml.vb | 3 + .../EstimationsExpanderVM.vb | 300 +++++ .../MachiningTreeExpanderVM.vb | 62 +- .../DispositionParameterExpanderVM.vb | 14 +- .../RawPartOption/RawPartOptionVM.vb | 4 +- .../OperationExpander/OperationExpanderVM.vb | 114 +- .../OperationListBoxItem.vb | 26 +- .../OperationParametersExpanderV.xaml | 24 + .../OperationParametersExpanderV.xaml.vb | 180 +++ .../OperationParametersExpanderVM.vb | 214 +++ .../OperationsListExpanderV.xaml | 157 +++ .../OperationsListExpanderV.xaml.vb | 180 +++ .../OperationsListExpanderVM.vb | 1161 +++++++++++++++++ .../SimulationExpanderV.xaml | 109 ++ ...ew.xaml.vb => SimulationExpanderV.xaml.vb} | 0 ...erViewModel.vb => SimulationExpanderVM.vb} | 407 ++---- .../SimulationExpanderView.xaml | 143 -- OptionPanel/MachiningOptionPanelV.xaml | 25 + OptionPanel/MachiningOptionPanelV.xaml.vb | 7 + OptionPanel/MachiningOptionPanelVM.vb | 198 +++ OptionPanel/OptionPanelV.xaml | 13 +- OptionPanel/OptionPanelVM.vb | 119 +- OptionsWindow/OptionWindowVM.vb | 2 +- Project/ProjectV.xaml | 160 +-- Project/ProjectV.xaml.vb | 8 +- Project/ProjectVM.vb | 30 +- Special-BeamWall/Beam.vb | 2 +- Special-BeamWall/Wall.vb | 2 +- StatusBar/MyStatusBarVM.vb | 602 +++++++++ StatusBar/StatusBarV.xaml | 20 +- TopCommandBar/TopCommandBarVM.vb | 7 +- Utility/Dictionary.xaml | 9 +- Utility/Map.vb | 122 +- Utility/SelData.vb | 4 +- 46 files changed, 4367 insertions(+), 1208 deletions(-) rename MachGroupPanel/{MachGroupPanelVM.vb => MyMachGroupPanelVM.vb} (74%) delete mode 100644 MachinePanel/MachinePanelVM.vb create mode 100644 MachinePanel/MyMachinePanelVM.vb create mode 100644 OptionPanel/DrawOptionPanelV.xaml create mode 100644 OptionPanel/DrawOptionPanelV.xaml.vb create mode 100644 OptionPanel/DrawOptionPanelVM.vb create mode 100644 OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderV.xaml create mode 100644 OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderV.xaml.vb create mode 100644 OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderVM.vb create mode 100644 OptionPanel/MachiningOptionPanel/OperationParametersExpander/OperationParametersExpanderV.xaml create mode 100644 OptionPanel/MachiningOptionPanel/OperationParametersExpander/OperationParametersExpanderV.xaml.vb create mode 100644 OptionPanel/MachiningOptionPanel/OperationParametersExpander/OperationParametersExpanderVM.vb create mode 100644 OptionPanel/MachiningOptionPanel/OperationsListExpander/OperationsListExpanderV.xaml create mode 100644 OptionPanel/MachiningOptionPanel/OperationsListExpander/OperationsListExpanderV.xaml.vb create mode 100644 OptionPanel/MachiningOptionPanel/OperationsListExpander/OperationsListExpanderVM.vb create mode 100644 OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderV.xaml rename OptionPanel/MachiningOptionPanel/SimulationExpander/{SimulationExpanderView.xaml.vb => SimulationExpanderV.xaml.vb} (100%) rename OptionPanel/MachiningOptionPanel/SimulationExpander/{SimulationExpanderViewModel.vb => SimulationExpanderVM.vb} (60%) delete mode 100644 OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml create mode 100644 OptionPanel/MachiningOptionPanelV.xaml create mode 100644 OptionPanel/MachiningOptionPanelV.xaml.vb create mode 100644 OptionPanel/MachiningOptionPanelVM.vb create mode 100644 StatusBar/MyStatusBarVM.vb diff --git a/EgtCAM5.vbproj b/EgtCAM5.vbproj index 10796fd..321c8ed 100644 --- a/EgtCAM5.vbproj +++ b/EgtCAM5.vbproj @@ -155,6 +155,11 @@ CurrSetUpV.xaml + + + EstimationsExpanderV.xaml + + StoneMillingParameterExpanderV.xaml @@ -194,6 +199,22 @@ StoneSawingParameterExpanderV.xaml + + DrawOptionPanelV.xaml + + + + MachiningOptionPanelV.xaml + + + + OperationParametersExpanderV.xaml + + + + OperationsListExpanderV.xaml + + MachineBox.xaml @@ -239,6 +260,10 @@ SpecialPanelV.xaml + + StatusBarV.xaml + + @@ -264,7 +289,7 @@ MachinePanelV.xaml - + DoorPanelV.xaml @@ -291,10 +316,6 @@ Code - - MachGroupPanelV.xaml - - MachiningTreeExpanderV.xaml @@ -355,14 +376,10 @@ - - OperationExpanderV.xaml + + SimulationExpanderV.xaml - - - SimulationExpanderView.xaml - - + ProjectV.xaml @@ -378,10 +395,6 @@ GunStockWndV.xaml - - StatusBarV.xaml - - @@ -413,6 +426,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -465,6 +482,22 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + XamlIntelliSenseFileGenerator + + + Designer + XamlIntelliSenseFileGenerator + MSBuild:Compile Designer @@ -529,6 +562,10 @@ Designer MSBuild:Compile + + Designer + XamlIntelliSenseFileGenerator + MSBuild:Compile Designer @@ -549,10 +586,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -605,11 +638,7 @@ MSBuild:Compile Designer - - Designer - MSBuild:Compile - - + Designer MSBuild:Compile @@ -625,10 +654,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile diff --git a/InstrumentPanel/InstrumentPanelVM.vb b/InstrumentPanel/InstrumentPanelVM.vb index 4b3e185..087801a 100644 --- a/InstrumentPanel/InstrumentPanelVM.vb +++ b/InstrumentPanel/InstrumentPanelVM.vb @@ -80,6 +80,7 @@ Public Class InstrumentPanelVM #Region "CONSTRUCTOR" Sub New() + Map.SetRefInstrumentPanelVM(Me) Application.Msn.Register(Application.MACHININGMODE_ISCHECKED, Sub() AnalyzeIsChecked = False AnalyzeIsEnabled = False diff --git a/MachGroupPanel/MachGroupPanelVM.vb b/MachGroupPanel/MyMachGroupPanelVM.vb similarity index 74% rename from MachGroupPanel/MachGroupPanelVM.vb rename to MachGroupPanel/MyMachGroupPanelVM.vb index dd96343..ec676f4 100644 --- a/MachGroupPanel/MachGroupPanelVM.vb +++ b/MachGroupPanel/MyMachGroupPanelVM.vb @@ -3,81 +3,34 @@ Imports System.IO Imports EgtUILib Imports EgtWPFLib5 -Public Class MachGroupPanelVM - Inherits ViewModelBase - -#Region "FIELDS & PROPERTIES" - - Private m_MachGroupList As New ObservableCollection(Of String) - Public Property MachGroupList As ObservableCollection(Of String) - Get - Return m_MachGroupList - End Get - Set(value As ObservableCollection(Of String)) - If value IsNot m_MachGroupList Then - m_MachGroupList = value - End If - End Set - End Property - - Private m_SelectedMachGroup As String - Public Property SelectedMachGroup As String - Get - Return m_SelectedMachGroup - End Get - Set(value As String) - m_SelectedMachGroup = value - OnPropertyChanged("SelectedMachGroup") - End Set - End Property - - Private m_IsEnabled As Boolean = True - Public Property MachGroupPanelIsEnabled As Boolean - Get - Return m_IsEnabled - End Get - Set(value As Boolean) - m_IsEnabled = value - OnPropertyChanged("MachGroupPanelIsEnabled") - End Set - End Property - - ' Definizione comandi - Private m_cmdSetCurrMachGroup As ICommand - Private m_cmdAddMachGroup As ICommand - Private m_cmdRemoveMachGroup As ICommand - -#End Region ' FIELDS & PROPERTIES +Public Class MyMachGroupPanelVM + Inherits EgtWPFLib5.MachGroupPanelVM #Region "CONSTRUCTOR" Sub New() - Application.Msn.Register(Application.INITIALIZEMACHGROUPS, Sub(bAllowEmpty As Boolean) - InitializeMachGroups(bAllowEmpty) - End Sub) - Application.Msn.Register(Application.MACHGROUPSISENABLED, Sub(MgpIsEnabled As Boolean) - Me.MachGroupPanelIsEnabled = MgpIsEnabled - End Sub) + MyBase.New() End Sub #End Region ' CONSTRUCTOR #Region "METHODS" - Private Sub InitializeMachGroups(bAllowEmpty As Boolean) + Public Overloads Sub InitMachGroupList(bAllowEmpty As Boolean) Dim nGroupId As Integer = GDB_ID.NULL Dim nErr As Integer = ManageDisposition(nGroupId, bAllowEmpty) If nErr = 0 Then - LoadMachGroups() + LoadMachGroupList() Dim MachGroupName As String = "" EgtGetMachGroupName(nGroupId, MachGroupName) - SelectedMachGroup = MachGroupList(MachGroupList.IndexOf(MachGroupName)) + SelectedMachGroup = MachGroupList.First(Function(x) x.Name = MachGroupName) If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True) End If Application.Msn.NotifyColleagues(Application.MACHGROUPSRESULT, nErr) ' Setto il Materiale in base alla Macchina associata al MachGroup selezionato LoadMaterialType() If nErr <> 0 Then EgtDraw() + Map.refMachGroupPanelVM.SetMachGroupState(True) End Sub Private Function ManageDisposition(ByRef nGroupId As Integer, bAllowEmpty As Boolean) As Integer @@ -137,7 +90,7 @@ Public Class MachGroupPanelVM End Select Return If(bOk, 0, 1) End If - ' altrimenti creo il primo gruppo + ' altrimenti creo il primo gruppo Else ' Vuoi creare un nuovo Gruppo di Lavoro con i pezzi selezionati ? - LAVORA If MessageBox.Show(EgtMsg(5552), EgtMsg(5002), MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then @@ -146,16 +99,16 @@ Public Class MachGroupPanelVM Return -2 End If End If - ' Se non ci sono pezzi selezionati + ' Se non ci sono pezzi selezionati Else ' se ci sono gruppi di lavorazione If bMachGroup Then nGroupId = EgtGetLastMachGroup() Return If(EgtSetCurrMachGroup(nGroupId), 0, 1) - ' se altrimenti ammessi gruppi di lavoro vuoti + ' se altrimenti ammessi gruppi di lavoro vuoti ElseIf bAllowEmpty Then Return If(AddNewMachGroup(nGroupId, vPart), 0, 1) - ' altrimenti esco + ' altrimenti esco Else Return -1 End If @@ -296,15 +249,17 @@ Public Class MachGroupPanelVM End While End Sub - Private Sub LoadMachGroups() + Public Overrides Sub LoadMachGroupList() ' Pulisco la lista MachGroupList.Clear() ' Carico i gruppi di lavorazione nella lista Dim nId = EgtGetFirstMachGroup() While nId <> GDB_ID.NULL Dim sName As String = String.Empty + Dim sMachine As String = String.Empty EgtGetMachGroupName(nId, sName) - MachGroupList.Add(sName) + EgtGetMachGroupMachineName(nId, sMachine) + MachGroupList.Add(New MachGroup(nId, sName, sMachine)) nId = EgtGetNextMachGroup(nId) End While End Sub @@ -344,51 +299,7 @@ Public Class MachGroupPanelVM #End Region -#Region "COMMANDS" - -#Region "SetCurrMachGroupCommand" - - ''' - ''' Returns a command that set the selected MachGroup as the Current one. - ''' - Public ReadOnly Property SetCurrMachGroupCommand As ICommand - Get - If m_cmdSetCurrMachGroup Is Nothing Then - m_cmdSetCurrMachGroup = New RelayCommand(AddressOf SetCurrMachGroup) - End If - Return m_cmdSetCurrMachGroup - End Get - End Property - - Public Sub SetCurrMachGroup(ByVal param As Object) - EgtSetCurrMachGroup(EgtGetMachGroupId(DirectCast(param, String))) - If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True) - EgtZoom(ZM.ALL) - Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, GDB_ID.NULL) - Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE) - Map.refSimulationExpanderVM.Estimation_IsEnabled = - (EgtUILib.GetPrivateProfileInt(S_ESTIMATIONS, K_EST_ENABLE, 0, IniFile.m_sCurrMachIniFilePath) <> 0) - ' Setto il Materiale in base alla Macchina associata al MachGroup corrente - LoadMaterialType() - End Sub - -#End Region ' SetCurrMachGroupCommand - -#Region "AddMachGroupCommand" - - ''' - ''' Returns a command that set the selected MachGroup as the Current one. - ''' - Public ReadOnly Property AddMachGroupCommand As ICommand - Get - If m_cmdAddMachGroup Is Nothing Then - m_cmdAddMachGroup = New RelayCommand(AddressOf AddMachGroup) - End If - Return m_cmdAddMachGroup - End Get - End Property - - Public Sub AddMachGroup() + Public Overrides Sub AddMachGroup() 'If AddNewMachGroup() Then ' Dim sMachName As String = String.Empty ' EgtGetMachGroupName(EgtGetCurrMachGroup(), sMachName) @@ -400,23 +311,7 @@ Public Class MachGroupPanelVM 'End If End Sub -#End Region ' AddMachGroupCommand - -#Region "RemoveMachGroupCommand" - - ''' - ''' Returns a command that set the selected MachGroup as the Current one. - ''' - Public ReadOnly Property RemoveMachGroupCommand As ICommand - Get - If m_cmdRemoveMachGroup Is Nothing Then - m_cmdRemoveMachGroup = New RelayCommand(AddressOf RemoveMachGroup) - End If - Return m_cmdRemoveMachGroup - End Get - End Property - - Public Sub RemoveMachGroup() + Public Overrides Sub RemoveMachGroup() ' Calcolo indice del gruppo da cancellare Dim nSelectedMachGroupIndex As Integer = MachGroupList.IndexOf(SelectedMachGroup) If nSelectedMachGroupIndex = 0 And MachGroupList.Count = 1 Then @@ -424,7 +319,7 @@ Public Class MachGroupPanelVM Select Case MessageBox.Show(EgtMsg(MSG_MACHGROUP + 2), "", MessageBoxButton.YesNo, MessageBoxImage.Question) Case MessageBoxResult.Yes ' cancello il gruppo corrente - EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex))) + EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex).Name)) ' aggiorno la lista dei gruppi MachGroupList.RemoveAt(nSelectedMachGroupIndex) ' ritorno alla modalità disegno @@ -443,15 +338,15 @@ Public Class MachGroupPanelVM nNewInd = nSelectedMachGroupIndex - 1 End If If nNewInd >= 0 Then - EgtSetCurrMachGroup(EgtGetMachGroupId(MachGroupList(nNewInd))) + EgtSetCurrMachGroup(EgtGetMachGroupId(MachGroupList(nNewInd).Id.ToString())) SelectedMachGroup = MachGroupList(nNewInd) If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True) EgtZoom(ZM.ALL) - Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, GDB_ID.NULL) + Map.refOperationsListExpanderVM.LoadOperationList(GDB_ID.NULL) Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE) End If ' cancello quello selezionato - EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex))) + EgtRemoveMachGroup(EgtGetMachGroupId(MachGroupList(nSelectedMachGroupIndex).Name)) ' aggiorno la lista dei gruppi MachGroupList.RemoveAt(nSelectedMachGroupIndex) Case MessageBoxResult.No @@ -461,8 +356,21 @@ Public Class MachGroupPanelVM End Sub -#End Region ' RemoveMachGroupCommand + Public Overrides Function OnPostSetCurrMachGroup() As Boolean + ' Se gli Expander sono Nothing vuol dire che siamo appena entrati in Machining Mode e quindi non eseguo il codice seguente + If Not IsNothing(Map.refOperationsListExpanderVM) Or Not IsNothing(Map.refEstimationsExpanderVM) Then + If IniFile.m_bShowOnlyTable Then EgtShowOnlyTable(True) -#End Region ' COMMANDS + Map.refOperationsListExpanderVM.LoadOperationList(GDB_ID.NULL) + Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE) + Application.Msn.NotifyColleagues(Application.UPDATEOPERATIONMACHININGLIST) + Map.refEstimationsExpanderVM.Estimation_IsEnabled = + (EgtUILib.GetPrivateProfileInt(S_ESTIMATIONS, K_EST_ENABLE, 0, IniFile.m_sCurrMachIniFilePath) <> 0) + ' Setto il Materiale in base alla Macchina associata al MachGroup corrente + LoadMaterialType() + End If + + Return True + End Function End Class \ No newline at end of file diff --git a/MachinePanel/MachinePanelV.xaml b/MachinePanel/MachinePanelV.xaml index 766467f..c23306e 100644 --- a/MachinePanel/MachinePanelV.xaml +++ b/MachinePanel/MachinePanelV.xaml @@ -3,7 +3,11 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - + + diff --git a/MachinePanel/MachinePanelVM.vb b/MachinePanel/MachinePanelVM.vb deleted file mode 100644 index 0e2092a..0000000 --- a/MachinePanel/MachinePanelVM.vb +++ /dev/null @@ -1,283 +0,0 @@ -Imports System.IO -Imports EgtUILib - -Public Class MachinePanelVM - Inherits VMBase - -#Region "FIELDS & PROPERTIES" - - ' Definizione comandi - Private m_cmdToolDb As ICommand - Private m_cmdMachDb As ICommand - Private m_cmdSetUpDb As ICommand - Private m_cmdMachOptions As ICommand - - Private m_ToolDb_IsEnabled As Boolean = True - Public ReadOnly Property ToolDb_IsEnabled As Boolean - Get - Return m_ToolDb_IsEnabled - End Get - End Property - - Private m_MachDb_IsEnabled As Boolean = True - Public ReadOnly Property MachDb_IsEnabled As Boolean - Get - Return m_MachDb_IsEnabled - End Get - End Property - - Private m_SetUpDb_IsEnabled As Boolean = True - Public ReadOnly Property SetUpDb_IsEnabled As Boolean - Get - Return m_SetUpDb_IsEnabled - End Get - End Property - -#Region "Messages" - - Public ReadOnly Property ToolDBMsg As String - Get - Return EgtMsg(MSG_MAINWINDOW + 6) - End Get - End Property - Public ReadOnly Property MachiningDbMsg As String - Get - Return EgtMsg(MSG_MAINWINDOW + 7) - End Get - End Property - Public ReadOnly Property SetUpDbMsg As String - Get - Return EgtMsg(MSG_MAINWINDOW + 9) - End Get - End Property - -#End Region ' Messages - -#Region "ToolTip" - - Public ReadOnly Property ToolDBToolTip As String - Get - Return EgtMsg(MSG_MAINWINDOW + 3) - End Get - End Property - Public ReadOnly Property MachiningDbToolTip As String - Get - Return EgtMsg(MSG_MAINWINDOW + 4) - End Get - End Property - Public ReadOnly Property SetUpDbToolTip As String - Get - Return EgtMsg(MSG_MAINWINDOW + 10) - End Get - End Property - Public ReadOnly Property MachOptionsToolTip As String - Get - Return EgtMsg(MSG_MAINWINDOW + 8) - End Get - End Property - -#End Region ' ToolTip - -#End Region 'FIELDS & PROPERTIES - -#Region "CONSTRUCTOR" - - Sub New() - ' Creo riferimento a questa classe in Map - Map.SetRefMachinePanelVM(Me) - End Sub - -#End Region ' Constructor - -#Region "METHODS" - - Friend Sub ToolMachSetUpIsEnabled(ToolDb_IsEnabled As Boolean, MachDb_IsEnabled As Boolean, SetUpDb_IsEnabled As Boolean) - m_ToolDb_IsEnabled = ToolDb_IsEnabled - m_MachDb_IsEnabled = MachDb_IsEnabled - m_SetUpDb_IsEnabled = SetUpDb_IsEnabled - NotifyPropertyChanged("ToolDb_IsEnabled") - NotifyPropertyChanged("MachDb_IsEnabled") - NotifyPropertyChanged("SetUpDb_IsEnabled") - End Sub -#End Region ' Methods - -#Region "COMMANDS" - -#Region "ToolDbCommand" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property ToolDbCommand As ICommand - Get - If m_cmdToolDb Is Nothing Then - m_cmdToolDb = New RelayCommand(AddressOf ToolDb) - End If - Return m_cmdToolDb - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Shared Sub ToolDb() - If Not EgtVerifyMachinesDir() Then Return - ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) - If Not EgtTdbReload() Then - EgtOutLog("Impossible reloading tool Db") - MessageBox.Show(EgtMsg(MSG_TOOLSERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) - Return - End If - 'Dim ToolDbWindow As New ToolsDbV - 'ToolDbWindow.Height = 640 - 'ToolDbWindow.Width = 1024 - 'ToolDbWindow.DataContext = New ToolsDbVM - 'ToolDbWindow.Owner = Application.Current.MainWindow - 'ToolDbWindow.ShowDialog() - - Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName - Dim ToolDbWindowVM As New MyToolDbWindowVM(sMachineDir, IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") - Dim ToolDbWindowV As New EgtWPFLib5.ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) - If ToolDbWindowVM.MatType <> 0 Then - ToolDbWindowV.Height = 674 - ToolDbWindowV.Width = 1024 - ToolDbWindowV.Owner = Application.Current.MainWindow - ToolDbWindowV.ShowDialog() - End If - - End Sub - -#End Region ' ToolDbCommand - -#Region "MachDbCommand" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property MachDbCommand As ICommand - Get - If m_cmdMachDb Is Nothing Then - m_cmdMachDb = New RelayCommand(AddressOf MachDb) - End If - Return m_cmdMachDb - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Shared Sub MachDb() - If Not EgtVerifyMachinesDir() Then Return - ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) - If Not EgtMdbReload() Then - EgtOutLog("Impossible reloading machining Db") - MessageBox.Show(EgtMsg(MSG_MACHININGSERRORS + 7), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) - Return - End If - Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") - Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) - If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then - MachDbWindowV.Height = 784 '674 - MachDbWindowV.Width = 1024 - MachDbWindowV.Owner = Application.Current.MainWindow - MachDbWindowV.ShowDialog() - End If - End Sub - -#End Region ' MachDbCommand - -#Region "SetUpDb" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property SetUpDb_Command As ICommand - Get - If m_cmdSetUpDb Is Nothing Then - m_cmdSetUpDb = New RelayCommand(AddressOf SetUpDb) - End If - Return m_cmdSetUpDb - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Shared Sub SetUpDb() - ' verifico che il file di configurazione attrezzaggio (lua) della macchina esista - If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then - EgtOutLog("SetUp error: SetUp configuration file doesn't exist ") - MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) - Return - End If - ' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato, - ' e testa e uscita dell'utensile attrezzato - EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) - ' verifico che le teste riportate in configurazione esistano - Dim Index As Integer = 1 - Dim nErr As Integer = 0 - While nErr = 0 - Dim sHead As String = String.Empty - nErr = 999 - EgtLuaSetGlobIntVar("STU.INDEX", Index) - EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") - ' Leggo variabili - EgtLuaGetGlobStringVar("STU.HEAD", sHead) - EgtLuaGetGlobIntVar("STU.ERR", nErr) - If nErr = 0 Then - If EgtGetHeadExitCount(sHead) = 0 Then - MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) - Return - End If - End If - Index += 1 - End While - ' Verifico esistenza direttorio per attrezzaggi - Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp" - If Not Directory.Exists(sDir) Then - Try - Directory.CreateDirectory(sDir) - Catch ex As Exception - EgtOutLog("Error in SetupDir creation " & ex.ToString()) - Return - End Try - End If - ' creo ed apro finestra SetUp - Dim SetUpDbWindow As New SetUpDbV(Application.Current.MainWindow, New SetUpDbVM) - SetUpDbWindow.ShowDialog() - Application.Msn.NotifyColleagues(Application.EMITTITLE) - End Sub - -#End Region ' SetUpDb - -#Region "MachOptionsCommand" - - ''' - ''' Returns a command that do Exec. - ''' - Public ReadOnly Property MachOptionsCommand As ICommand - Get - If m_cmdMachOptions Is Nothing Then - m_cmdMachOptions = New RelayCommand(AddressOf MachOptions) - End If - Return m_cmdMachOptions - End Get - End Property - - ''' - ''' Execute the Exec. This method is invoked by the ExecCommand. - ''' - Public Sub MachOptions(ByVal param As Object) - Dim MachOptionWindow As New MachOptionV - 'MachOptionWindow.Height = 614 - 'MachOptionWindow.Width = 256 - MachOptionWindow.DataContext = New MachOptionVM - MachOptionWindow.Owner = Application.Current.MainWindow - MachOptionWindow.ShowDialog() - End Sub - -#End Region ' MachOptionsCommand - -#End Region ' COMMANDS - -End Class \ No newline at end of file diff --git a/MachinePanel/MyMachinePanelVM.vb b/MachinePanel/MyMachinePanelVM.vb new file mode 100644 index 0000000..3e02e19 --- /dev/null +++ b/MachinePanel/MyMachinePanelVM.vb @@ -0,0 +1,464 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 + +Public Class MyMachinePanelVM + Inherits MachinePanelVM + +#Region "FIELDS & PROPERTIES" + + ' Definizione comandi + Private m_cmdToolDb As ICommand + Private m_cmdMachDb As ICommand + Private m_cmdSetUpDb As ICommand + Private m_cmdMachOptions As ICommand + + Private m_ToolDb_IsEnabled As Boolean = True + Public ReadOnly Property ToolDb_IsEnabled As Boolean + Get + Return m_ToolDb_IsEnabled + End Get + End Property + + Private m_MachDb_IsEnabled As Boolean = True + Public ReadOnly Property MachDb_IsEnabled As Boolean + Get + Return m_MachDb_IsEnabled + End Get + End Property + + Private m_SetUpDb_IsEnabled As Boolean = True + Public ReadOnly Property SetUpDb_IsEnabled As Boolean + Get + Return m_SetUpDb_IsEnabled + End Get + End Property + + ' Lista delle macchine disponibili nel programma + Private m_MachinesList As New ObservableCollection(Of Machine) + Public Property MachinesList As ObservableCollection(Of Machine) + Get + Return m_MachinesList + End Get + Set(value As ObservableCollection(Of Machine)) + m_MachinesList = value + End Set + End Property + + ' Macchina correntemente selezionata e quindi attiva + Private m_SelectedMachine As Machine + Public Overloads Property SelectedMachine As Machine + Get + Return m_SelectedMachine + End Get + Set(value As Machine) + If IsNothing(value) Then + m_SelectedMachine = Nothing + ElseIf value IsNot m_SelectedMachine Then + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + If EgtSetCurrMachine(value.Name) Then + m_SelectedMachine = value + IniFile.m_sMachineName = m_SelectedMachine.Name + IniFile.m_sCurrMachIniFilePath = m_SelectedMachine.MachineDirPath & "\" & m_SelectedMachine.Name & ".ini" + IniFile.m_sCurrMachToolsDirPath = m_SelectedMachine.MachineDirPath & "\Tools" + IniFile.m_sCurrMachSetUpDirPath = m_SelectedMachine.MachineDirPath & "\SetUp" + IniFile.m_sCurrMachScriptsDirPath = m_SelectedMachine.MachineDirPath & "\Scripts" + UpdateToolAndMachDbParamVisibility() + NotifyPropertyChanged("SelectedMachine") + End If + End If + End Set + End Property + + Private m_MachineListIsEnabled As Boolean + Public Property MachineListIsEnabled As Boolean + Get + Return m_MachineListIsEnabled + End Get + Set(value As Boolean) + m_MachineListIsEnabled = value + NotifyPropertyChanged("MachineListIsEnabled") + End Set + End Property + +#Region "Messages" + + Public ReadOnly Property ToolDBMsg As String + Get + Return EgtMsg(MSG_MAINWINDOW + 6) + End Get + End Property + Public ReadOnly Property MachiningDbMsg As String + Get + Return EgtMsg(MSG_MAINWINDOW + 7) + End Get + End Property + Public ReadOnly Property SetUpDbMsg As String + Get + Return EgtMsg(MSG_MAINWINDOW + 9) + End Get + End Property + +#End Region ' Messages + +#Region "ToolTip" + + Public ReadOnly Property ToolDBToolTip As String + Get + Return EgtMsg(MSG_MAINWINDOW + 3) + End Get + End Property + Public ReadOnly Property MachiningDbToolTip As String + Get + Return EgtMsg(MSG_MAINWINDOW + 4) + End Get + End Property + Public ReadOnly Property SetUpDbToolTip As String + Get + Return EgtMsg(MSG_MAINWINDOW + 10) + End Get + End Property + Public ReadOnly Property MachOptionsToolTip As String + Get + Return EgtMsg(MSG_MAINWINDOW + 8) + End Get + End Property + +#End Region ' ToolTip + +#End Region 'FIELDS & PROPERTIES + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefMachinePanelVM(Me) + + SearchMachines() + Application.Msn.Register(Application.LOADCURRENTMACHINE, Sub() + If m_MachinesList.Count = 0 Then Return + Dim CurrMach As String = String.Empty + GetPrivateProfileString(S_MACH, K_CURRMACH, String.Empty, CurrMach) + Dim bFound As Boolean = False + If Not String.IsNullOrEmpty(CurrMach) Then + For Each Mach In MachinesList + If Mach.Name = CurrMach Then + bFound = True + SelectedMachine = Mach + Exit For + End If + Next + End If + If Not bFound And MachinesList.Count > 0 Then + SelectedMachine = MachinesList(0) + End If + End Sub) + Application.Msn.Register(Application.SAVECURRENTMACHINE, Sub() + If IsNothing(m_SelectedMachine) Then Return + WritePrivateProfileString(S_MACH, K_CURRMACH, SelectedMachine.Name) + End Sub) + Application.Msn.Register(Application.UPDATECURRENTMACHINE, Sub() + EgtSetCurrentContext(IniFile.m_ProjectSceneContext) + Dim sMachName As String = String.Empty + If EgtGetCurrMachineName(sMachName) Then + For Each Mach In MachinesList + If Mach.Name = sMachName Then + SelectedMachine = Mach + Exit For + End If + Next + End If + End Sub) + Application.Msn.Register(Application.MAINWINDOW_CONTENTRENDERED, Sub() + 'If IniFile.m_bMmUnits Then + ' GridDimensionText = LenToString(IniFile.dSnapStepMm, 4) + 'Else + ' GridDimensionText = LenToString(IniFile.dSnapStepInch, 4) + 'End If + If IniFile.m_ProjectMode = ProjectModeOpt.ONLYDRAW Then + MachineListIsEnabled = False + End If + End Sub) + Application.Msn.Register(Application.MACHININGMODE_ISCHECKED, Sub() + 'OutputMessage = String.Empty + MachineListIsEnabled = False + End Sub) + Application.Msn.Register(Application.DRAWMODE_ISCHECKED, Sub() + 'OutputMessage = String.Empty + MachineListIsEnabled = True + End Sub) + End Sub + +#End Region ' Constructor + +#Region "METHODS" + + Friend Sub ToolMachSetUpIsEnabled(ToolDb_IsEnabled As Boolean, MachDb_IsEnabled As Boolean, SetUpDb_IsEnabled As Boolean) + m_ToolDb_IsEnabled = ToolDb_IsEnabled + m_MachDb_IsEnabled = MachDb_IsEnabled + m_SetUpDb_IsEnabled = SetUpDb_IsEnabled + NotifyPropertyChanged("ToolDb_IsEnabled") + NotifyPropertyChanged("MachDb_IsEnabled") + NotifyPropertyChanged("SetUpDb_IsEnabled") + End Sub +#End Region ' Methods + +#Region "COMMANDS" + +#Region "ToolDbCommand" + + Public Overloads Shared Sub ToolDb() + If Not EgtVerifyMachinesDir() Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtTdbReload() Then + EgtOutLog("Impossible reloading tool Db") + MessageBox.Show(EgtMsg(MSG_TOOLSERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + + Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName + Dim ToolDbWindowVM As New MyToolDbWindowVM(sMachineDir, IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") + Dim ToolDbWindowV As New EgtWPFLib5.ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + If ToolDbWindowVM.MatType <> 0 Then + ToolDbWindowV.Height = 674 + ToolDbWindowV.Width = 1024 + ToolDbWindowV.Owner = Application.Current.MainWindow + ToolDbWindowV.ShowDialog() + End If + End Sub + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Overrides Sub ToolDb(ByVal param As Object) + If Not EgtVerifyMachinesDir() Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtTdbReload() Then + EgtOutLog("Impossible reloading tool Db") + MessageBox.Show(EgtMsg(MSG_TOOLSERRORS + 30), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + 'Dim ToolDbWindow As New ToolsDbV + 'ToolDbWindow.Height = 640 + 'ToolDbWindow.Width = 1024 + 'ToolDbWindow.DataContext = New ToolsDbVM + 'ToolDbWindow.Owner = Application.Current.MainWindow + 'ToolDbWindow.ShowDialog() + + Dim sMachineDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName + Dim ToolDbWindowVM As New MyToolDbWindowVM(sMachineDir, IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") + Dim ToolDbWindowV As New EgtWPFLib5.ToolDbWindowV(Application.Current.MainWindow, ToolDbWindowVM) + If ToolDbWindowVM.MatType <> 0 Then + ToolDbWindowV.Height = 674 + ToolDbWindowV.Width = 1024 + ToolDbWindowV.Owner = Application.Current.MainWindow + ToolDbWindowV.ShowDialog() + End If + + End Sub + +#End Region ' ToolDbCommand + +#Region "MachDbCommand" + + Public Overloads Shared Sub MachDb() + If Not EgtVerifyMachinesDir() Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtMdbReload() Then + EgtOutLog("Impossible reloading machining Db") + MessageBox.Show(EgtMsg(MSG_MACHININGSERRORS + 7), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") + Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then + MachDbWindowV.Height = 784 '674 + MachDbWindowV.Width = 1024 + MachDbWindowV.Owner = Application.Current.MainWindow + MachDbWindowV.ShowDialog() + End If + End Sub + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Overrides Sub MachDb(ByVal param As Object) + If Not EgtVerifyMachinesDir() Then Return + ' ricarico il database per intercettare eventuali aggiornamenti fatti da altre istanze del programma (se la cartella Machines è condivisa) + If Not EgtMdbReload() Then + EgtOutLog("Impossible reloading machining Db") + MessageBox.Show(EgtMsg(MSG_MACHININGSERRORS + 7), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + Dim MachDbWindowVM As New EgtWPFLib5.MachiningDbWindowVM(IniFile.m_sCurrMachIniFilePath, IniFile.m_ProjectSceneContext, "Wood") + Dim MachDbWindowV As New EgtWPFLib5.MachiningDbWindowV(Application.Current.MainWindow, MachDbWindowVM) + If EgtWPFLib5.MachiningTreeViewItem.m_MatType <> 0 Then + MachDbWindowV.Height = 784 '674 + MachDbWindowV.Width = 1024 + MachDbWindowV.Owner = Application.Current.MainWindow + MachDbWindowV.ShowDialog() + End If + End Sub + +#End Region ' MachDbCommand + +#Region "SetUpCommand" + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Overrides Sub SetUp(ByVal param As Object) + ' verifico che il file di configurazione attrezzaggio (lua) della macchina esista + If Not File.Exists(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) Then + EgtOutLog("SetUp error: SetUp configuration file doesn't exist ") + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 7), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' carico Lua che contiene le funzioni per ottenere le posizioni valide dell'utensile selezionato, + ' e testa e uscita dell'utensile attrezzato + EgtLuaExecFile(IniFile.m_sCurrMachScriptsDirPath & "\" & SETUP_LUA) + ' verifico che le teste riportate in configurazione esistano + Dim Index As Integer = 1 + Dim nErr As Integer = 0 + While nErr = 0 + Dim sHead As String = String.Empty + nErr = 999 + EgtLuaSetGlobIntVar("STU.INDEX", Index) + EgtLuaCallFunction("STU.GetTcPosHeadGroupFromPos") + ' Leggo variabili + EgtLuaGetGlobStringVar("STU.HEAD", sHead) + EgtLuaGetGlobIntVar("STU.ERR", nErr) + If nErr = 0 Then + If EgtGetHeadExitCount(sHead) = 0 Then + MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 8), EgtMsg(MSG_SETUPERRORS + 1), MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + End If + Index += 1 + End While + ' Verifico esistenza direttorio per attrezzaggi + Dim sDir As String = IniFile.m_sMachinesRoot & "\" & IniFile.m_sMachineName & "\SetUp" + If Not Directory.Exists(sDir) Then + Try + Directory.CreateDirectory(sDir) + Catch ex As Exception + EgtOutLog("Error in SetupDir creation " & ex.ToString()) + Return + End Try + End If + ' creo ed apro finestra SetUp + Dim SetUpDbWindow As New SetUpDbV(Application.Current.MainWindow, New SetUpDbVM) + SetUpDbWindow.ShowDialog() + Application.Msn.NotifyColleagues(Application.EMITTITLE) + End Sub + +#End Region ' SetUpCommand + +#Region "MachOptionsCommand" + + ''' + ''' Execute the Exec. This method is invoked by the ExecCommand. + ''' + Public Overrides Sub MachOptions(ByVal param As Object) + Dim MachOptionWindow As New MachOptionV + 'MachOptionWindow.Height = 614 + 'MachOptionWindow.Width = 256 + MachOptionWindow.DataContext = New MachOptionVM + MachOptionWindow.Owner = Application.Current.MainWindow + MachOptionWindow.ShowDialog() + End Sub + +#End Region ' MachOptionsCommand + +#End Region ' COMMANDS + + ''' + ''' Method that search the machines in the correct folder and add to the MachinesList those valid. + ''' + Private Sub SearchMachines() + ' Svuoto la lista delle macchine + m_MachinesList.Clear() + ' Se direttorio base macchine non definito o non esiste, ritorno + If String.IsNullOrWhiteSpace(IniFile.m_sMachinesRoot) OrElse + Not Directory.Exists(IniFile.m_sMachinesRoot) OrElse Directory.GetDirectories(IniFile.m_sMachinesRoot).Count = 0 Then + IniFile.m_ProjectMode = ProjectModeOpt.ONLYDRAW + EgtOutLog(EgtMsg(MSG_STATUSBAR + 1)) + Return + End If + ' Cerco le macchine + Dim TempArray As String() = Directory.GetDirectories(IniFile.m_sMachinesRoot) + For i As Integer = 0 To TempArray.Count - 1 + AddMachine(TempArray(i)) + Next + If m_MachinesList.Count = 0 Then + IniFile.m_ProjectMode = ProjectModeOpt.ONLYDRAW + EgtOutLog(EgtMsg(MSG_STATUSBAR + 1)) + Return + End If + End Sub + + Private Function AddMachine(sPath As String) As Boolean + ' Verifico presenza file caratteristici + Dim sName As String = Path.GetFileName(sPath) + Dim MachineIniPath As String = sPath & "\" & sName & ".ini" + Dim MachineMldePath As String = sPath & "\" & sName & ".mlde" + If Not File.Exists(MachineIniPath) Or Not File.Exists(MachineMldePath) Then Return False + ' Aggiungo alla lista + m_MachinesList.Add(New Machine With {.Name = sName, .MachineDirPath = sPath}) + Return True + End Function + + Friend Function InsertMachine(sPath As String) As Boolean + ' Verifico presenza file caratteristici + Dim sName As String = Path.GetFileName(sPath) + Dim MachineIniPath As String = sPath & "\" & sName & ".ini" + Dim MachineMldePath As String = sPath & "\" & sName & ".mlde" + If Not File.Exists(MachineIniPath) Or Not File.Exists(MachineMldePath) Then Return False + ' Cerco la posizione di inserimento + Dim nPos As Integer = 0 + For nI As Integer = 0 To m_MachinesList.Count() - 1 + Dim nRes As Integer = String.Compare(sName, m_MachinesList(nI).Name, True) + If nRes = 0 Then + Return True + ElseIf nRes < 0 Then + Exit For + Else + nPos += 1 + End If + Next + ' Inserisco nella lista + m_MachinesList.Insert(nPos, New Machine With {.Name = sName, .MachineDirPath = sPath}) + Return True + End Function + + ''' + ''' Class that create the association Name/IniPath for the machine's + ''' + Class Machine + + Private m_sName As String + Public Property Name As String + Get + Return m_sName + End Get + Set(value As String) + m_sName = value + End Set + End Property + + Friend MachineDirPath As String + + End Class + + Private Sub UpdateToolAndMachDbParamVisibility() + If EgtUILib.GetPrivateProfileInt(S_MACHININGS, K_SAWINGONARCS, 0, IniFile.m_sCurrMachIniFilePath) <> 0 Then + Sawing(39) = Visibility.Visible ' StepExtArc + Sawing(40) = Visibility.Visible ' StepIntArc + Else + Sawing(39) = Visibility.Collapsed ' StepExtArc + Sawing(40) = Visibility.Collapsed ' StepIntArc + End If + End Sub + +End Class \ No newline at end of file diff --git a/MainWindow/MainWindowVM.vb b/MainWindow/MainWindowVM.vb index a6230a2..9fc540a 100644 --- a/MainWindow/MainWindowVM.vb +++ b/MainWindow/MainWindowVM.vb @@ -66,7 +66,7 @@ Public Class MainWindowVM If m_bfirst Then m_bfirst = False m_StatusBar = New StatusBarV - m_StatusBar.DataContext = New StatusBarVM + m_StatusBar.DataContext = New MyStatusBarVM End If Return m_StatusBar End Get diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index ad184ac..15c335e 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -70,6 +70,6 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/OptionPanel/DrawOptionPanelV.xaml b/OptionPanel/DrawOptionPanelV.xaml new file mode 100644 index 0000000..808bf97 --- /dev/null +++ b/OptionPanel/DrawOptionPanelV.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/OptionPanel/DrawOptionPanelV.xaml.vb b/OptionPanel/DrawOptionPanelV.xaml.vb new file mode 100644 index 0000000..da226b1 --- /dev/null +++ b/OptionPanel/DrawOptionPanelV.xaml.vb @@ -0,0 +1,7 @@ +Public Class DrawOptionPanelV + + Private Sub Me_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded + Dim x = ciao.MaxHeight + End Sub + +End Class diff --git a/OptionPanel/DrawOptionPanelVM.vb b/OptionPanel/DrawOptionPanelVM.vb new file mode 100644 index 0000000..56dbea7 --- /dev/null +++ b/OptionPanel/DrawOptionPanelVM.vb @@ -0,0 +1,63 @@ +Imports EgtUILib + +Public Class DrawOptionPanelVM + Inherits ViewModelBase + + ' GRAPHICAL ELEMENTS + Private m_ManageLayerExpander As ManageLayerExpanderV + Public ReadOnly Property ManageLayerExpander As ContentControl + Get + If IsNothing(m_ManageLayerExpander) Then + m_ManageLayerExpander = New ManageLayerExpanderV + m_ManageLayerExpander.DataContext = New ManageLayerExpanderVM + End If + Return m_ManageLayerExpander + End Get + End Property + + Private m_InfoExpander As InfoExpanderV + Public ReadOnly Property InfoExpander As ContentControl + Get + If IsNothing(m_InfoExpander) Then + m_InfoExpander = New InfoExpanderV + m_InfoExpander.DataContext = New InfoExpanderVM + End If + Return m_InfoExpander + End Get + End Property + + Private m_InputExpander As InputExpanderV + Public ReadOnly Property InputExpander As ContentControl + Get + If IsNothing(m_InputExpander) Then + m_InputExpander = New InputExpanderV + m_InputExpander.DataContext = New InputExpanderVM + End If + Return m_InputExpander + End Get + End Property + +#Region "CONSTRUCTOR" + + Sub New() + ' Creo riferimento a questa classe in Map + Map.SetRefDrawOptionPanelVM(Me) + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Function InitDrawOptionPanel() As Boolean + 'EgtZoom(ZM.ALL) + Return True + End Function + + Friend Function ExitDrawOptionPanel() As Boolean + + Return True + End Function + +#End Region ' METHODS + +End Class \ No newline at end of file diff --git a/OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderV.xaml b/OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderV.xaml new file mode 100644 index 0000000..79b2f56 --- /dev/null +++ b/OptionPanel/MachiningOptionPanel/EstimationsExpander/EstimationsExpanderV.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml.vb b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderV.xaml.vb similarity index 100% rename from OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml.vb rename to OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderV.xaml.vb diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderVM.vb similarity index 60% rename from OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb rename to OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderVM.vb index 6ccc21c..0dcaeb4 100644 --- a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb +++ b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderVM.vb @@ -5,8 +5,6 @@ Imports EgtUILib Public Class SimulationExpanderVM Inherits ViewModelBase - Friend Shared m_RefOperationExpanderVM As OperationExpanderVM - #Region "FIELDS & PROPERTIES" 'EGT PROPERTIES @@ -41,120 +39,37 @@ Public Class SimulationExpanderVM ' Flag di esecuzione in corso Private m_bSimExecuting As Boolean = False + Public ReadOnly Property bSimExecuting As Boolean + Get + Return m_bSimExecuting + End Get + End Property 'GRAPHICAL PROPERTIES - Private m_IsExpanded As Boolean - Public Property IsExpanded As Boolean + Private m_Simulation_IsExpanded As Boolean + Public Property Simulation_IsExpanded As Boolean Get - Return m_IsExpanded + Return m_Simulation_IsExpanded End Get Set(value As Boolean) - If value <> m_IsExpanded Then - If value Then - - If m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.OPERATIONLIST Then - m_RefOperationExpanderVM.ListIsExpanded = False - ElseIf m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.OPERATIONPARAMETERS Then - m_RefOperationExpanderVM.ParametersIsExpanded = False - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.SIMULATION - ElseIf m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.ESTIMATIONS Then - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.SIMULATION - Application.Msn.NotifyColleagues(Application.ESTIMATIONSEXPANDER_SET_ISEXPANDED, False) - End If - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.SIMULATION - - EgtDeselectAll() - Application.Msn.NotifyColleagues(Application.GETDISTANCE_ISCHECKED, False) - ' Disabilito la selezione dei Percorsi di Lavorazione - Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL) - ' Disabilito la selezione di tutti i tipi di geometria - Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.NULL) - Map.refTopCommandBarVM.SaveIsEnabled = False - SelData.ClearIdSub() - If IniFile.m_bShowOnlyTable Then - EgtShowOnlyTable(False) - EgtZoom(ZM.ALL, False) - End If - InitializeSimulation() - EgtDraw() - Estimation_IsExpanded = False - Else - If m_bSimExecuting Then Return - CloseSimulation() - If IniFile.m_bShowOnlyTable Then - EgtShowOnlyTable(True) - EgtZoom(ZM.ALL) - End If - Map.refTopCommandBarVM.SaveIsEnabled = True - End If - m_IsExpanded = value - Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_GET_ISEXPANDED, value) - OnPropertyChanged("IsExpanded") - OnPropertyChanged("GenerateIsEnabled") - ' disattivo database utensili, lavorazioni e setup se vado in simulazione - Map.refMachinePanelVM.ToolMachSetUpIsEnabled(Not value, Not value, Not value) + If value <> m_Simulation_IsExpanded Then + Map.refMachiningOptionPanelVM.Set_IsExpanded(MachiningOptionPanelVM.MachiningOptionPanelExpander.SIMULATION, value) End If End Set End Property - Private m_Estimation_IsExpanded As Boolean - Public Property Estimation_IsExpanded As Boolean + Private m_Simulation_IsEnabled As Boolean = False + Public Property Simulation_IsEnabled As Boolean Get - Return m_Estimation_IsExpanded + Return m_Simulation_IsEnabled End Get Set(value As Boolean) - If value <> m_Estimation_IsExpanded Then - If value Then - If m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.OPERATIONLIST Then - m_RefOperationExpanderVM.ListIsExpanded = False - ElseIf m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.OPERATIONPARAMETERS Then - m_RefOperationExpanderVM.ParametersIsExpanded = False - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.ESTIMATIONS - Application.Msn.NotifyColleagues(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, False) - ElseIf m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.SIMULATION Then - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.ESTIMATIONS - Application.Msn.NotifyColleagues(Application.ESTIMATIONSEXPANDER_SET_ISEXPANDED, False) - End If - m_RefOperationExpanderVM.m_CurrExpandedExpander = OperationExpanderVM.MachiningOptionPanelExpander.ESTIMATIONS - IsExpanded = False - EgtDeselectAll() - Application.Msn.NotifyColleagues(Application.GETDISTANCE_ISCHECKED, False) - ' Disabilito la selezione dei Percorsi di Lavorazione - Application.Msn.NotifyColleagues(Application.SETSCENESELTYPE, SceneSelTypeOpt.NULL) - ' Abilito la selezione di tutti i tipi di geometria - Application.Msn.NotifyColleagues(Application.SETSCENESELMODE, SceneSelModeOpt.PARTCURVESANDSURFACES) - CalcEstimation() - OnPropertyChanged("TotalTime") - OnPropertyChanged("TotalLength") - End If - m_Estimation_IsExpanded = value - Application.Msn.NotifyColleagues(Application.ESTIMATIONEXPANDER_GET_ISEXPANDED, value) - OnPropertyChanged("Estimation_IsExpanded") - OnPropertyChanged("GenerateIsEnabled") - ' disattivo database utensili, lavorazioni e setup se vado in stima - Map.refMachinePanelVM.ToolMachSetUpIsEnabled(Not value, Not value, Not value) - End If + m_Simulation_IsEnabled = value + OnPropertyChanged("Simulation_IsEnabled") End Set End Property - Private m_Estimation_IsEnabled As Boolean = False - Public Property Estimation_IsEnabled As Boolean - Get - Return m_Estimation_IsEnabled And Not m_bSimExecuting - End Get - Set(value As Boolean) - m_Estimation_IsEnabled = value - OnPropertyChanged("Estimation_IsEnabled") - End Set - End Property - - Public ReadOnly Property GenerateIsEnabled As Boolean - Get - Return Not m_IsExpanded - End Get - End Property - ' lista degli assi Private m_MachineAxisList As New ObservableCollection(Of MachineAxis) Public ReadOnly Property MachineAxisList As ObservableCollection(Of MachineAxis) @@ -308,35 +223,10 @@ Public Class SimulationExpanderVM End Set End Property - Public ReadOnly Property TotalTime As String - Get - Dim nTotalTime As Integer = 0 - EgtGetInfo(EgtGetCurrMachGroup(), "Ttot", nTotalTime) - Dim sTotalTime As New TimeSpan(0, 0, nTotalTime) - Return sTotalTime.ToString("hh\:mm\:ss") - End Get - End Property - - Public ReadOnly Property TotalLength As String - Get - Dim dTotalLength As Double = 0 - EgtGetInfo(EgtGetCurrMachGroup(), "Ltot", dTotalLength) - Dim sTotalLength As String = "" - If EgtUiUnitsAreMM() Then - sTotalLength = DoubleToString(dTotalLength / 1000, 1) & " m" - Else - sTotalLength = DoubleToString(dTotalLength / (ONEINCH * 12), 1) & " ft" - End If - Return sTotalLength - End Get - End Property - ' Definizione comandi Private m_cmdStep As ICommand Private m_cmdPlayPause As ICommand Private m_cmdStop As ICommand - Private m_cmdGenerate As ICommand - Private m_cmdDetails As ICommand #Region "Messages" @@ -346,35 +236,6 @@ Public Class SimulationExpanderVM End Get End Property - Public ReadOnly Property GenerateMsg As String - Get - Return EgtMsg(MSG_SIMULATION + 30) 'GENERA - End Get - End Property - - Public ReadOnly Property EstimationMsg As String - Get - Return EgtMsg(MSG_SIMULATION + 40) 'Stime - End Get - End Property - - Public ReadOnly Property TotalTimeMsg As String - Get - Return EgtMsg(MSG_SIMULATION + 41) 'Tempo totale - End Get - End Property - - Public ReadOnly Property TotalLengthMsg As String - Get - Return EgtMsg(MSG_SIMULATION + 42) 'Lunghezza totale - End Get - End Property - Public ReadOnly Property DetailsMsg As String - Get - Return EgtMsg(MSG_SIMULATION + 43) 'Dettagli - End Get - End Property - Public ReadOnly Property VMillMsg As String Get Return EgtMsg(MSG_SIMULATION + 16) 'Virtual Milling @@ -410,18 +271,12 @@ Public Class SimulationExpanderVM Sub New() SetRefSimulationExpanderVM(Me) Application.Msn.Register(Application.CLOSEAPPLICATION, Sub() - If IsExpanded Then + If Simulation_IsExpanded Then ResetSimulation() End If End Sub) - Application.Msn.Register(Application.SIMULATIONEXPANDER_SET_ISEXPANDED, Sub(bValue As Boolean) - IsExpanded = bValue - End Sub) - Application.Msn.Register(Application.ESTIMATIONSEXPANDER_SET_ISEXPANDED, Sub(bValue As Boolean) - Estimation_IsExpanded = bValue - End Sub) Application.Msn.Register(Application.SIMULATIONEXPANDER_UPDATE_CNCDATA, Sub() - If IsExpanded Then + If Simulation_IsExpanded Then ShowCncData() End If End Sub) @@ -568,51 +423,39 @@ Public Class SimulationExpanderVM #Region "GenerateCommand" - ''' - ''' Returns a command that create a new tool. - ''' - Public ReadOnly Property GenerateCommand As ICommand - Get - If m_cmdGenerate Is Nothing Then - m_cmdGenerate = New RelayCommand(AddressOf Generate) - End If - Return m_cmdGenerate - End Get - End Property - ''' ''' Creata the new tool. This method is invoked by the NewCommand. ''' Public Sub Generate(ByVal param As Object) ' Verifico se richiesta anche visualizzazione del CN - Dim bNcView As Boolean = ( (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) + Dim bNcView As Boolean = ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) ' Recupero la fase corrente Dim nPhase As Integer = EgtGetCurrPhase() ' Aggiorno le lavorazioni If Not UpdateAllMachinings() Then - EgtSetCurrPhase( If( nPhase = 0, 1, nPhase), True) + EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) Return End If ' Recupero nome file CN (dopo aver verificato salvataggio progetto) Dim sCncFile As String = "" Dim sInfo As String = "" - If Not GetCncFileName( True, sCncFile, sInfo) Then Return + If Not GetCncFileName(True, sCncFile, sInfo) Then Return ' Eseguo If Not EgtGenerate(sCncFile, sInfo) Then Dim nErr = EgtGetLastMachMgrErrorId() - If nErr = 1000 then - MessageBox.Show( EgtMsg( 5333), EgtMsg( 5320), MessageBoxButton.OK, MessageBoxImage.Information) + If nErr = 1000 Then + MessageBox.Show(EgtMsg(5333), EgtMsg(5320), MessageBoxButton.OK, MessageBoxImage.Information) ElseIf nErr <> 0 Then Dim sErr As String = EgtGetLastMachMgrErrorString() - MessageBox.Show( sErr, EgtMsg( 5305), MessageBoxButton.OK, MessageBoxImage.Exclamation) + MessageBox.Show(sErr, EgtMsg(5305), MessageBoxButton.OK, MessageBoxImage.Exclamation) Else - MessageBox.Show( EgtMsg( 5306), EgtMsg( 5305), MessageBoxButton.OK, MessageBoxImage.Error) + MessageBox.Show(EgtMsg(5306), EgtMsg(5305), MessageBoxButton.OK, MessageBoxImage.Error) End If bNcView = False Else - Application.Msn.NotifyColleagues( Application.NOTIFYSTATUSOUTPUT, EgtMsg( 5332) & " (" & sCncFile & ")") + Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, EgtMsg(5332) & " (" & sCncFile & ")") End If ' Torno alla fase originale (o alla prima se non definita) EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) @@ -620,56 +463,66 @@ Public Class SimulationExpanderVM ' Se richiesta anche la visualizzazione del CN corrente, procedo If bNcView Then ' Se esiste ne lancio l'editing - If File.Exists( sCncFile) Then - Process.Start( "Notepad.exe", sCncFile) - ' altrimenti lo segnalo + If File.Exists(sCncFile) Then + Process.Start("Notepad.exe", sCncFile) + ' altrimenti lo segnalo Else - Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "Edit failed, missing part program file" & " (" & sCncFile & ")") + Application.Msn.NotifyColleagues(Application.NOTIFYSTATUSOUTPUT, "Edit failed, missing part program file" & " (" & sCncFile & ")") End If End If End Sub #End Region ' GenerateCommand -#Region "Details" - - ''' - ''' Returns a command that create a new tool. - ''' - Public ReadOnly Property Details_Command As ICommand - Get - If m_cmdDetails Is Nothing Then - m_cmdDetails = New RelayCommand(AddressOf Details) - End If - Return m_cmdDetails - End Get - End Property - - ''' - ''' Creata the new tool. This method is invoked by the NewCommand. - ''' - Public Sub Details(ByVal param As Object) - ' Determino il nome del file contenente le stime - Dim sEstFile As String = "" - Dim sInfo As String = "" - GetEstimationFileName(False, sEstFile, sInfo) - ' Verifico che il file esista - If Not File.Exists(sEstFile) Then - ' File delle stime non trovato - MessageBox.Show(EgtMsg(MSG_SIMULATION + 18), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.OK, MessageBoxImage.Warning) - Return - End If - ' Visualizzazione - Dim EstimationsWnd As New EstimationsDetailsWndV(Application.Current.MainWindow, New EstimationsDetailsWndVM(sEstFile)) - EstimationsWnd.ShowDialog() - End Sub - -#End Region ' Details - #End Region #Region "METHODS" + Friend Function InitSimulation() As Boolean + EgtDeselectAll() + Map.refInstrumentPanelVM.GetDistIsChecked = False + ' Disabilito la selezione dei Percorsi di Lavorazione + Map.refProjectVM.SceneSelType = SceneSelTypeOpt.NULL + ' Disabilito la selezione di tutti i tipi di geometria + Map.refProjectVM.SceneSelMode = SceneSelModeOpt.NULL + Map.refTopCommandBarVM.SaveIsEnabled = False + SelData.ClearIdSub() + If IniFile.m_bShowOnlyTable Then + EgtShowOnlyTable(False) + EgtZoom(ZM.ALL, False) + End If + InitializeSimulation() + EgtDraw() + + m_Simulation_IsExpanded = True + Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = False + Map.refOperationsListExpanderVM.SimulationExpander_Get_IsExpanded(True) + OnPropertyChanged("Simulation_IsExpanded") + Map.refMachiningOptionPanelVM.OnPropertyChanged("GenerateIsEnabled") + ' disattivo database utensili, lavorazioni e setup se vado in simulazione + Map.refMachinePanelVM.ToolMachSetUpIsEnabled(False, False, False) + Return True + End Function + + Friend Function ExitSimulation() As Boolean + If m_bSimExecuting Then Return False + CloseSimulation() + If IniFile.m_bShowOnlyTable Then + EgtShowOnlyTable(True) + EgtZoom(ZM.ALL) + End If + Map.refTopCommandBarVM.SaveIsEnabled = True + + m_Simulation_IsExpanded = False + Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = True + Map.refOperationsListExpanderVM.SimulationExpander_Get_IsExpanded(False) + OnPropertyChanged("Simulation_IsExpanded") + Map.refMachiningOptionPanelVM.OnPropertyChanged("GenerateIsEnabled") + ' disattivo database utensili, lavorazioni e setup se vado in simulazione + Map.refMachinePanelVM.ToolMachSetUpIsEnabled(True, True, True) + Return True + End Function + Private Function UpdateAllMachinings() As Boolean ' Eseguo ricalcolo Dim bModified As Boolean = EgtGetModified() @@ -748,10 +601,11 @@ Public Class SimulationExpanderVM Private Sub ExecSim() m_bSimExecuting = True IniFile.m_bSimulExecuting = True - Application.Msn.NotifyColleagues(Application.SETDRAWISENABLED, False) - Application.Msn.NotifyColleagues(Application.OPERATIONVIEWEXPANDERISENABLED, False) - Application.Msn.NotifyColleagues(Application.MACHGROUPSISENABLED, False) - OnPropertyChanged("Estimation_IsEnabled") + Map.refTopCommandBarVM.DrawIsEnabled = False + Map.refOperationsListExpanderVM.OpersListViewIsEnabled = False + Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = False + Map.refMachGroupPanelVM.SetMachGroupState(False) ' Map.refMachGroupPanelVM.MachGroupPanelIsEnabled = False + Map.refEstimationsExpanderVM.OnPropertyChanged("Estimation_IsEnabled") If Not EgtSimStart(False) Then If EgtGetLastMachMgrErrorId() <> 0 Then Dim sErr As String = EgtGetLastMachMgrErrorString() @@ -837,10 +691,11 @@ Public Class SimulationExpanderVM End While m_bSimExecuting = False IniFile.m_bSimulExecuting = False - Application.Msn.NotifyColleagues(Application.SETDRAWISENABLED, True) - Application.Msn.NotifyColleagues(Application.OPERATIONVIEWEXPANDERISENABLED, True) - Application.Msn.NotifyColleagues(Application.MACHGROUPSISENABLED, True) - OnPropertyChanged("Estimation_IsEnabled") + Map.refTopCommandBarVM.DrawIsEnabled = True + Map.refOperationsListExpanderVM.OpersListViewIsEnabled = True + Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = True + Map.refMachGroupPanelVM.SetMachGroupState(True) ' Map.refMachGroupPanelVM.MachGroupPanelIsEnabled = True + Map.refEstimationsExpanderVM.OnPropertyChanged("Estimation_IsEnabled") End Sub Private Sub ShowCncData() @@ -940,7 +795,7 @@ Public Class SimulationExpanderVM End If End Sub - Private Function GetCncFileName( bAskSave As Boolean, ByRef sCncFile As String, ByRef sInfo As String) As Boolean + Private Function GetCncFileName(bAskSave As Boolean, ByRef sCncFile As String, ByRef sInfo As String) As Boolean ' Recupero e verifico la path del progetto corrente Dim sCurrFilePath As String = String.Empty EgtGetCurrFilePath(sCurrFilePath) @@ -962,9 +817,9 @@ Public Class SimulationExpanderVM End If sCncFile = "" sInfo = "EgtCAM5 - " & sCurrFilePath - If EgtGetInfo( EgtGetCurrMachGroup(), KEY_MCHGRP_NCNAME, sCncFile) AndAlso Not String.IsNullOrWhiteSpace( sCncFile) then - sCncFile = Path.GetDirectoryName (sCurrFilePath) & "\" & sCncFile - else + If EgtGetInfo(EgtGetCurrMachGroup(), KEY_MCHGRP_NCNAME, sCncFile) AndAlso Not String.IsNullOrWhiteSpace(sCncFile) Then + sCncFile = Path.GetDirectoryName(sCurrFilePath) & "\" & sCncFile + Else sCncFile = Path.ChangeExtension(sCurrFilePath, Nothing) If IniFile.m_bMachiningGroup Then Dim sMGrpName As String = String.Empty @@ -975,94 +830,10 @@ Public Class SimulationExpanderVM Else sCncFile &= ".cnc" End If - End if + End If Return True End Function - Private Function GetEstimationFileName(bAskSave As Boolean, ByRef sEstFile As String, ByRef sInfo As String) As Boolean - Dim bOk As Boolean = True - ' Recupero e verifico la path del progetto corrente - Dim sCurrFilePath As String = String.Empty - EgtGetCurrFilePath(sCurrFilePath) - If bAskSave Then - If String.IsNullOrEmpty(sCurrFilePath) OrElse EgtGetModified() Then - ' Il progetto deve essere salvato prima di poter essere generato. Vuoi farlo ? - If MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then - ' Abbandono - bOk = False - Else - ' Lancio salvataggio - Application.Msn.NotifyColleagues(Application.SAVEPROJECT) - ' Se non salvato, abbandono - If EgtGetModified() Then bOk = False - ' Aggiorno path - EgtGetCurrFilePath(sCurrFilePath) - End If - End If - Else - If String.IsNullOrEmpty(sCurrFilePath) Then - ' File delle stime non trovato - MessageBox.Show(EgtMsg(MSG_SIMULATION + 18), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.OK, MessageBoxImage.Warning) - bOk = False - End If - End If - ' Creo la path del file di stima e relativo info (con nome gruppo se gestiti) - If Not String.IsNullOrEmpty(sCurrFilePath) Then - sInfo = "EgtCAM5 - " & sCurrFilePath - If EgtGetInfo( EgtGetCurrMachGroup(), KEY_MCHGRP_NCNAME, sEstFile) AndAlso Not String.IsNullOrWhiteSpace( sEstFile) then - sEstFile = Path.ChangeExtension(Path.GetDirectoryName (sCurrFilePath) & "\" & sEstFile, ".html") - else - sEstFile = Path.ChangeExtension(sCurrFilePath, Nothing) - If IniFile.m_bMachiningGroup Then - Dim sMGrpName As String = String.Empty - If EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrpName) Then - sEstFile &= "_" & sMGrpName & ".html" - sInfo &= "-" & sMGrpName - End If - Else - sEstFile &= ".html" - End If - End If - End If - Return bOk - End Function - - Private Function CalcEstimation() As Boolean - ' Recupero la fase corrente - Dim nPhase As Integer = EgtGetCurrPhase() - ' Aggiorno le lavorazioni - If Not UpdateAllMachinings() Then - EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) - Return False - End If - ' Determino il nome del file contenente le stime - Dim sEstFile As String = "" - Dim sInfo As String = "" - Dim bOk As Boolean = GetEstimationFileName(True, sEstFile, sInfo) - ' Cancello tutte le stime - If File.Exists(sEstFile) Then File.Delete(sEstFile) - Dim bOldEnMod As Boolean = EgtGetEnableModified() - EgtDisableModified() - EgtRemoveInfo(EgtGetCurrMachGroup(), "Ttot") - EgtRemoveInfo(EgtGetCurrMachGroup(), "Ltot") - If bOldEnMod Then EgtEnableModified() - If Not bOk Then Return False - ' Calcolo della stima - If Not EgtEstimate(sEstFile, sInfo) Then - If EgtGetLastMachMgrErrorId() <> 0 Then - Dim sErr As String = EgtGetLastMachMgrErrorString() - sErr = sErr.Replace("Cnc", "Est") - MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation) - Else - MessageBox.Show(EgtMsg(MSG_SIMULATION + 17), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error) - End If - bOk = False - End If - ' Torno alla fase originale (o alla prima se non definita) - EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True) - Return bOk - End Function - #End Region End Class \ No newline at end of file diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml deleted file mode 100644 index b477e00..0000000 --- a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -