Imports System.IO Imports EgtUILib Imports EgtWPFLib5 Public Class EstimationsExpanderVM Inherits EstimationsVM #Region "FIELDS & PROPERTIES" 'GRAPHICAL PROPERTIES Private m_Estimation_IsExpanded As Boolean Public Property Estimation_IsExpanded As Boolean Get Return m_Estimation_IsExpanded End Get Set(value As Boolean) If value <> m_Estimation_IsExpanded Then Map.refMachiningOptionPanelVM.Set_IsExpanded(MachiningOptionPanelVM.MachiningOptionPanelExpander.ESTIMATIONS, value) End If End Set End Property Private m_Estimation_IsEnabled As Boolean = False Public Property Estimation_IsEnabled As Boolean Get Return m_Estimation_IsEnabled And Not Map.refSimulationExpanderVM.bSimExecuting End Get Set(value As Boolean) m_Estimation_IsEnabled = value NotifyPropertyChanged(NameOf(Estimation_IsEnabled)) End Set End Property #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New() SetRefEstimationsExpanderVM(Me) End Sub #End Region ' CONSTRUCTOR #Region "COMMANDS" #Region "Details" Public Overrides 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) EgtMessageBoxV.Show(Application.Current.MainWindow, 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 ' COMMANDS #Region "METHODS" Friend Function InitEstimations() As Boolean EgtDeselectAll() Map.refInstrumentPanelVM.GetDistIsChecked = False ' Disabilito la selezione dei Percorsi di Lavorazione Map.refProjectVM.SceneSelType = SceneSelTypeOpt.NULL ' Abilito la selezione di tutti i tipi di geometria Map.refProjectVM.SceneSelMode = SceneSelModeOpt.PARTCURVESANDSURFACES CalcEstimation() NotifyPropertyChanged(NameOf(Time)) NotifyPropertyChanged(NameOf(CutLen)) m_Estimation_IsExpanded = True Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = False Map.refOperationsListExpanderVM.EstimationExpander_Get_IsExpanded(True) NotifyPropertyChanged(NameOf(Estimation_IsExpanded)) Map.refMachiningOptionPanelVM.OnPropertyChanged(NameOf(Map.refMachiningOptionPanelVM.GenerateIsEnabled)) ' disattivo database utensili, lavorazioni e setup se vado in stima Map.refMachinePanelVM.ToolMachSetUpIsEnabled(False, False, False) ' disattivo MTable e SpecialPanel se vado in stima Map.refDoorPanelVM.MTableIsEnabled(False) Map.refSpecialPanelVM.SpecialPanelIsEnabled(False) Return True End Function Friend Function ExitEstimations() As Boolean m_Estimation_IsExpanded = False Map.refOperationParametersExpanderVM.OperParamsViewIsEnabled = True Map.refOperationsListExpanderVM.EstimationExpander_Get_IsExpanded(False) NotifyPropertyChanged(NameOf(Estimation_IsExpanded)) Map.refMachiningOptionPanelVM.OnPropertyChanged(NameOf(Map.refMachiningOptionPanelVM.GenerateIsEnabled)) ' attivo database utensili, lavorazioni e setup se esco dalla stima Map.refMachinePanelVM.ToolMachSetUpIsEnabled(True, True, True) ' attivo MTable e SpecialPanel se esco dalla stima Map.refDoorPanelVM.MTableIsEnabled(True) Map.refSpecialPanelVM.SpecialPanelIsEnabled(True) Return True End Function Public Overrides 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 If EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then ' Abbandono bOk = False Else ' Lancio salvataggio Map.refProjectVM.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) EgtMessageBoxV.Show(Application.Current.MainWindow, 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 Map.refSimulationExpanderVM.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) EgtMessageBoxV.Show(Application.Current.MainWindow, sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation) Else 'MessageBox.Show(EgtMsg(MSG_SIMULATION + 17), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error) EgtMessageBoxV.Show(Application.Current.MainWindow, 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 ' METHODS End Class