Imports System.Windows.Threading Imports EgtBEAMWALL.Core Imports EgtWPFLib5 Imports EgtUILib Imports System.Collections.ObjectModel Public Class ProjectVM Inherits VMBase #Region "FIELDS & PROPERTIES" Private m_Calc_Timer As New DispatcherTimer ' Selezione Tab Prod / Proj Private m_SelProdProj As ProdProj Public Property SelProdProj As Integer Get Return m_SelProdProj End Get Set(value As Integer) m_SelProdProj = value NotifyPropertyChanged(NameOf(SelProdProj)) End Set End Property Private Property m_GridDims As New ObservableCollection(Of GridDimension) Public Property GridDims As ObservableCollection(Of GridDimension) Get Return m_GridDims End Get Set m_GridDims = Value NotifyPropertyChanged(NameOf(GridDims)) End Set End Property Private m_BTLStructureVM As BTLStructureVM Public Property BTLStructureVM As BTLStructureVM Get Return m_BTLStructureVM End Get Set(value As BTLStructureVM) m_BTLStructureVM = value NotifyPropertyChanged(NameOf(BTLStructureVM)) End Set End Property Private m_MachGroupPanelVM As MyMachGroupPanelVM Public Property MachGroupPanelVM As MyMachGroupPanelVM Get Return m_MachGroupPanelVM End Get Set(value As MyMachGroupPanelVM) m_MachGroupPanelVM = value NotifyPropertyChanged(NameOf(MachGroupPanelVM)) End Set End Property Private m_bCalcRunning As Boolean = False Public ReadOnly Property bCalcRunning As Boolean Get Return m_bCalcRunning End Get End Property Private m_bLockUX As Boolean = False Private m_LeftPanel_Visibility As Boolean = True Public Property LeftPanel_Visibility As Visibility Get Return If(m_LeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_LeftPanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetLeftPanel_Visibility(IsVisible As Boolean) m_LeftPanel_Visibility = IsVisible End Sub Private m_TopPanel_Visibility As Boolean = False Public Property TopPanel_Visibility As Visibility Get Return If(m_TopPanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_TopPanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetTopPanel_Visibility(IsVisible As Boolean) m_TopPanel_Visibility = IsVisible End Sub Private m_BottomPanel_Visibility As Boolean = True Public Property BottomPanel_Visibility As Visibility Get Return If(m_BottomPanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_BottomPanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetBottomPanel_Visibility(IsVisible As Boolean) m_BottomPanel_Visibility = IsVisible End Sub Private m_PartManager_Visibility As Boolean = True Public ReadOnly Property PartManager_Visibility As Visibility Get Return If((Map.refMainMenuVM.SelPage = Pages.VIEW OrElse Map.refMainMenuVM.SelPage = Pages.ONLYPRODPAGE) AndAlso Not IsNothing(Map.refProjectVM.BTLStructureVM) AndAlso Map.refProjectVM.BTLStructureVM.SelectionType = BTLStructureVM.SelectionTypes.SELECT_ AndAlso Not Map.refFreeContourManagerVM.bIsActive, Visibility.Visible, Visibility.Collapsed) End Get End Property Private m_FeatureManager_Visibility As Boolean = True Public Property FeatureManager_Visibility As Visibility Get Return If(m_FeatureManager_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_FeatureManager_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetFeatureManager_Visibility(IsVisible As Boolean) m_FeatureManager_Visibility = IsVisible End Sub Private m_ShowBeamPanel_Visibility As Boolean = True Public Property ShowBeamPanel_Visibility As Visibility Get Return If(m_ShowBeamPanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_ShowBeamPanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetShowBeamPanel_Visibility(IsVisible As Boolean) m_ShowBeamPanel_Visibility = IsVisible End Sub Private m_ProjManager_Visibility As Boolean = True Public Property ProjManager_Visibility As Visibility Get Return If(m_ProjManager_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_ProjManager_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetProjManager_Visibility(IsVisible As Boolean) m_ProjManager_Visibility = IsVisible If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.NotifyPropertyChanged(NameOf(Map.refProjManagerVM.GoToProd_Visibility)) End Sub Private m_ProdManager_Visibility As Boolean = True Public Property ProdManager_Visibility As Visibility Get Return If(m_ProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_ProdManager_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetProdManager_Visibility(IsVisible As Boolean) m_ProdManager_Visibility = IsVisible If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.NotifyPropertyChanged(NameOf(Map.refProdManagerVM.GoToProj_Visibility)) End Sub Private m_OptimizePanel_Visibility As Boolean = True Public Property OptimizePanel_Visibility As Visibility Get Return If(m_OptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_OptimizePanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetOptimizePanel_Visibility(IsVisible As Boolean) m_OptimizePanel_Visibility = IsVisible NotifyPropertyChanged(NameOf(OptimizePanel_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) End Sub Friend Sub NotifyCalcPanel_Visibility() Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility)) Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility)) End Sub Private m_FreeContourManager_Visibility As Boolean = False Public Property FreeContourManager_Visibility As Visibility Get Return If(m_FreeContourManager_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_FreeContourManager_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetFreeContourManager_Visibility(IsVisible As Boolean) m_FreeContourManager_Visibility = IsVisible NotifyPropertyChanged("FreeContourManager_Visibility") End Sub ' OnlyProdProject Private m_OnlyProdManager_Visibility As Boolean = True Public Property OnlyProdManager_Visibility As Visibility Get Return If(m_OnlyProdManager_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_OnlyProdManager_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetOnlyProdManager_Visibility(IsVisible As Boolean) m_OnlyProdManager_Visibility = IsVisible End Sub Private m_OnlyProdLeftPanel_Visibility As Boolean = True Public Property OnlyProdLeftPanel_Visibility As Visibility Get Return If(m_OnlyProdLeftPanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_OnlyProdLeftPanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetOnlyProdLeftPanel_Visibility(IsVisible As Boolean) m_OnlyProdLeftPanel_Visibility = IsVisible End Sub Private m_OnlyProdOptimizePanel_Visibility As Boolean = True Public Property OnlyProdOptimizePanel_Visibility As Visibility Get Return If(m_OnlyProdOptimizePanel_Visibility, Visibility.Visible, Visibility.Collapsed) End Get Set(value As Visibility) m_OnlyProdOptimizePanel_Visibility = (value = Visibility.Visible) End Set End Property Friend Sub SetOnlyProdOptimizePanel_Visibility(IsVisible As Boolean) m_OnlyProdOptimizePanel_Visibility = IsVisible NotifyPropertyChanged(NameOf(OnlyProdOptimizePanel_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.CalcRotFlip_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.Optimize_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.OriginType_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.ViewPage_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.MachiningPage_Visibility)) Map.refOptimizePanelVM.NotifyPropertyChanged(NameOf(Map.refOptimizePanelVM.NestingOption_Visibility)) End Sub Private m_CopyFeature_IsEnabled As Boolean = False Public Property CopyFeature_IsEnabled As Boolean Get Return m_CopyFeature_IsEnabled End Get Set(value As Boolean) m_CopyFeature_IsEnabled = value NotifyPropertyChanged(NameOf(CopyFeature_IsEnabled)) End Set End Property Private m_MacroFeature_IsEnabled As Boolean = False Public Property MacroFeature_IsEnabled As Boolean Get Return m_MacroFeature_IsEnabled End Get Set(value As Boolean) m_MacroFeature_IsEnabled = value NotifyPropertyChanged(NameOf(MacroFeature_IsEnabled)) End Set End Property Enum GridSelTypes As Integer PART = 1 MACHGROUP = 2 End Enum Private m_LastSelGridType As GridSelTypes Public ReadOnly Property LastSelGridType As GridSelTypes Get Return m_LastSelGridType End Get End Property Friend Sub SetLastSelGridType(value As GridSelTypes) m_LastSelGridType = value End Sub ' Definizione Comandi Private m_cmdCopyFeature As ICommand Private m_cmdMacroFeature As ICommand Private m_cmdAddFeature As ICommand Private m_cmdRemoveFeature As ICommand Private m_cmdProduceAllRawPart As ICommand Private m_cmdProduceRawPart As ICommand Private m_cmdCopyRawPart As ICommand Private m_cmdRemoveRawPart As ICommand Private m_cmdRemoveAllRawPart As ICommand Private m_cmdRemovePart As ICommand Private m_cmdMoveUpPart As ICommand Private m_cmdMoveDownPart As ICommand Private m_cmdReOrderPart As ICommand Private m_cmdMovePartInRawPart As ICommand #End Region ' Fields & Properties #Region "Messages" Public ReadOnly Property ProduceRawPart_ToolTip As String Get Return EgtMsg(61912) End Get End Property Public ReadOnly Property ResetCALCRawPart_ToolTip As String Get Return EgtMsg(61924) End Get End Property Public ReadOnly Property ProduceAllRawPart_ToolTip As String Get Return EgtMsg(61913) End Get End Property Public ReadOnly Property CopyRawPart_ToolTip As String Get Return EgtMsg(61914) End Get End Property Public ReadOnly Property RemoveRawPart_ToolTip As String Get Return EgtMsg(61915) End Get End Property Public ReadOnly Property RemoveAllRawPart_ToolTip As String Get Return EgtMsg(61976) End Get End Property Public ReadOnly Property ReOrderPart_ToolTip As String Get Return EgtMsg(61916) End Get End Property Public ReadOnly Property MoveUpPart_ToolTip As String Get Return EgtMsg(61917) End Get End Property Public ReadOnly Property MoveDownPart_ToolTip As String Get Return EgtMsg(61918) End Get End Property Public ReadOnly Property RemovePart_ToolTip As String Get Return EgtMsg(61919) End Get End Property Public ReadOnly Property MovePartInRawPart_ToolTip As String Get Return EgtMsg(61944) End Get End Property Public ReadOnly Property CopyFeature_ToolTip As String Get Return EgtMsg(61908) End Get End Property Public ReadOnly Property MacroFeature_ToolTip As String Get Return EgtMsg(61909) End Get End Property Public ReadOnly Property AddFeature_ToolTip As String Get Return EgtMsg(61910) End Get End Property Public ReadOnly Property RemoveFeature_ToolTip As String Get Return EgtMsg(61911) End Get End Property #End Region ' Messages #Region "CONSTRUCTOR" Sub New() ' Creo riferimento a questa classe in Map Map.SetRefProjectVM(Me) ' imposto timer per aggiornamenti Calc m_Calc_Timer.Interval = TimeSpan.FromMilliseconds(500) AddHandler m_Calc_Timer.Tick, AddressOf Calc_Timer_Tick ' imposto dimensioni colonne/righe della Grid Dim ProjectGridDim As String = If(Map.refMainWindowVM.MainWindowM.bOnlyProd, ConstDims.PROJECT_ONLYPROD, ConstDims.PROJECT_VIEW) DimensionsIniFile.ReadGridDimensions(ProjectGridDim, GridDims) End Sub #End Region ' Constructor #Region "METHODS" Friend Sub SetCalcRunning(value As Boolean) If value Then m_Calc_Timer.Start() m_bCalcRunning = value End Sub Friend Sub ManageIsEnabled(bIsEnabled As Boolean) Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled) Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled) Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) If Not IsNothing(Map.refProjManagerVM) Then Map.refProjManagerVM.SetProjManagerIsEnabled(bIsEnabled) If Not IsNothing(Map.refProdManagerVM) Then Map.refProdManagerVM.SetProdManagerIsEnabled(bIsEnabled) If Not IsNothing(Map.refTopPanelVM) Then Map.refTopPanelVM.SetTopPanelIsEnabled(bIsEnabled) Map.refOptimizePanelVM.SetOptimizePanelIsEnabled(bIsEnabled) Map.refFeatureManagerVM.SetFeatureManagerIsEnabled(bIsEnabled) End Sub Private Sub Calc_Timer_Tick() If m_bCalcRunning <> m_bLockUX Then ' se calcolo iniziato If m_bCalcRunning Then ManageIsEnabled(False) ' aggiungere gestione colonne editabili delle tabelle If Not IsNothing(Map.refPartListVM.colPart_Do) Then Map.refPartListVM.colPart_Do.IsReadOnly = True End If If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then Map.refFeatureListVM.colFeature_Do.IsReadOnly = True End If If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then Map.refPParameterListVM.colPParam_Value.IsReadOnly = True End If If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then Map.refQParameterListVM.colQParam_Value.IsReadOnly = True End If If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then Map.refQParameterListVM.colQParam_Custom.IsReadOnly = True End If If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then Map.refRawPartListVM.colRawPart_StartCut.IsReadOnly = True End If If Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then Map.refRawPartListVM.colRawPart_W.IsReadOnly = True End If If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then Map.refRawPartListVM.colRawPart_L.IsReadOnly = True End If If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then Map.refRawPartListVM.colRawPart_PosZ.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then Map.refPartInRawPartListVM.colPartInRawPart_Offset.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then Map.refPartInRawPartListVM.colPartInRawPart_Rot.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then Map.refPartInRawPartListVM.colPartInRawPart_Flip.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then Map.refPartInRawPartListVM.colPartInRawPart_PosX.IsReadOnly = True End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then Map.refPartInRawPartListVM.colPartInRawPart_PosY.IsReadOnly = True End If If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.IsReadOnly = True End If m_bLockUX = True ' se calcolo finito Else ManageIsEnabled(True) ' aggiungere gestione colonne editabili delle tabelle If Not IsNothing(Map.refPartListVM.colPart_Do) Then Map.refPartListVM.colPart_Do.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refFeatureListVM.colFeature_Do) Then Map.refFeatureListVM.colFeature_Do.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPParameterListVM.colPParam_Value) Then Map.refPParameterListVM.colPParam_Value.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refQParameterListVM.colQParam_Value) Then Map.refQParameterListVM.colQParam_Value.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refQParameterListVM.colQParam_Custom) Then Map.refQParameterListVM.colQParam_Custom.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refRawPartListVM.colRawPart_StartCut) Then Map.refRawPartListVM.colRawPart_StartCut.ResetToOrigIsReadOnly() End If If m_BTLStructureVM.nPROJTYPE <> BWType.BEAM AndAlso Not IsNothing(Map.refRawPartListVM.colRawPart_W) Then Map.refRawPartListVM.colRawPart_W.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refRawPartListVM.colRawPart_L) Then Map.refRawPartListVM.colRawPart_L.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refRawPartListVM.colRawPart_PosZ) Then Map.refRawPartListVM.colRawPart_PosZ.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Offset) Then Map.refPartInRawPartListVM.colPartInRawPart_Offset.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Rot) Then Map.refPartInRawPartListVM.colPartInRawPart_Rot.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_Flip) Then Map.refPartInRawPartListVM.colPartInRawPart_Flip.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosX) Then Map.refPartInRawPartListVM.colPartInRawPart_PosX.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refPartInRawPartListVM.colPartInRawPart_PosY) Then Map.refPartInRawPartListVM.colPartInRawPart_PosY.ResetToOrigIsReadOnly() End If If Not IsNothing(Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do) Then Map.refFeatureInPartInRawPartListVM.colFeatureInPartInRawPart_Do.ResetToOrigIsReadOnly() End If ' fermo il timer If Not m_bCalcRunning Then m_Calc_Timer.Stop() m_bLockUX = False End If End If End If End Sub Friend Sub ManageQParamsRowVisibility(bVisible As Boolean) If bVisible Then DimensionsIniFile.ReadGridDimensions(ConstDims.TOPPANEL_OPTIMIZER, GridDims) Else GridDimension.SetSoftwareMod(True) Dim FeatureRow = m_GridDims(4) Dim QParRow = m_GridDims(5) m_GridDims(4).GridLen = New GridLength(1, GridUnitType.Star) m_GridDims(4).NotifyPropertyChanged(NameOf(FeatureRow.GridLen)) m_GridDims(5).GridLen = New GridLength(0) m_GridDims(5).NotifyPropertyChanged(NameOf(QParRow.GridLen)) GridDimension.SetSoftwareMod(False) End If End Sub Friend Sub NotifyAllPanelVisibility() NotifyPropertyChanged("LeftPanel_Visibility") NotifyPropertyChanged("TopPanel_Visibility") NotifyPropertyChanged("BottomPanel_Visibility") NotifyPropertyChanged("PartManager_Visibility") NotifyPropertyChanged("FeatureManager_Visibility") NotifyPropertyChanged("ShowBeamPanel_Visibility") NotifyPropertyChanged("ProjManager_Visibility") NotifyPropertyChanged("ProdManager_Visibility") NotifyPropertyChanged("FullCompleteManager_Visibility") NotifyCalcPanel_Visibility() End Sub #End Region ' Methods #Region "COMMAND" #Region "CopyFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property CopyFeature_Command As ICommand Get If m_cmdCopyFeature Is Nothing Then m_cmdCopyFeature = New Command(AddressOf CopyFeature) End If Return m_cmdCopyFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub CopyFeature() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim SelPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.SelBTLPart If IsNothing(SelPart) Then Return Dim SelFeature As BTLFeatureVM = SelPart.SelBTLFeatureVM If IsNothing(SelFeature) Then Return ' creo copia Dim NewFeature = SelFeature.Copy() If Not IsNothing(NewFeature) Then SelPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeature) EgtDuploSetModified(SelPart.nPartId) End If SelPart.ResetCalcPart() End Sub #End Region ' CopyFeature #Region "MacroFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MacroFeature_Command As ICommand Get If m_cmdMacroFeature Is Nothing Then m_cmdMacroFeature = New Command(AddressOf MacroFeature) End If Return m_cmdMacroFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MacroFeature() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return ' apro finestra di creazione macro Dim MacroFeatureWndVM As New MacroFeatureWndVM() Dim MacroFeatureWnd As New MacroFeatureWndV(Application.Current.MainWindow, MacroFeatureWndVM) If MacroFeatureWnd.ShowDialog() Then End If End Sub #End Region ' MacroFeature #Region "AddFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property AddFeature_Command As ICommand Get If m_cmdAddFeature Is Nothing Then m_cmdAddFeature = New Command(AddressOf AddFeature) End If Return m_cmdAddFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub AddFeature(ByVal param As Object) If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return ' apro finestra di definizione nuova feature Dim AddFeatureWndVM As New AddFeatureWndVM() Dim AddFeatureWnd As New AddFeatureWndV(Application.Current.MainWindow, AddFeatureWndVM) If AddFeatureWnd.ShowDialog() Then Dim NewFeat As BTLFeatureM Dim nNewFeatureId As Integer = 0 Dim bMacroFlag As Boolean = False ' verifico se una Macro è selezionata If AddFeatureWndVM.MacroList.Count > 0 AndAlso AddFeatureWndVM.nSelMacro >= 0 Then ' Creo nuova feature sulla base della Macro selezionata ' Creo table e setto variabili EgtLuaCreateGlobTable("MACRO") EgtLuaSetGlobNumVar("MACRO.L", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlL) EgtLuaSetGlobNumVar("MACRO.W", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlW) EgtLuaSetGlobNumVar("MACRO.H", Map.refProjectVM.BTLStructureVM.SelBTLPart.dBtlH) EgtLuaSetGlobIntVar("MACRO.PROCID", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId()) Dim bOk = EgtLuaExecFile(AddFeatureWndVM.m_MacroFilePathList(AddFeatureWndVM.nSelMacro)) ' Leggo variabili EgtLuaGetGlobIntVar("MACRO.FEATUREID", nNewFeatureId) ' Reset lua EgtLuaResetGlobVar("MACRO") If Not bOk Then MessageBox.Show(EgtMsg(61869), EgtMsg(30007)) Return End If bMacroFlag = True Else ' Creo nuova feature (Macro non selezionata) NewFeat = BTLFeatureM.CreateBTLFeature(AddFeatureWndVM.nSelPRC.nPRC, AddFeatureWndVM.nSelPRC.nGRP, AddFeatureWndVM.nSelPRC.nSIDE) NewFeat.SetDefaultValues() Dim vPar() As Double = Nothing Dim sPar As String = String.Empty Dim vParQ() As String = Nothing NewFeat.CalcParamArray(vPar, sPar, vParQ) ' aggiorno la feature con nuovo valore EgtBeamSetPart(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) nNewFeatureId = EgtBeamAddProcess(NewFeat.nSelGRP, NewFeat.nPRC, NewFeat.nSelSIDE, "", Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.NewProcId(), New Frame3d(), vPar, sPar, vParQ, GDB_ID.NULL, GDB_ID.NULL) bMacroFlag = False End If ' se è stata creata If nNewFeatureId <> GDB_ID.NULL Then EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) ' la aggiungo a struttura BTL corrente NewFeat = BTLFeatureM.CreateBTLFeature(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM, nNewFeatureId) If Not bMacroFlag Then NewFeat.SetDefaultValues() Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLPartM.AddBTLFeature(NewFeat) Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.FirstOrDefault(Function(x) x.BTLFeatureM Is NewFeat) Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() End If End If End Sub #End Region ' AddFeature #Region "RemoveFeature" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemoveFeature_Command As ICommand Get If m_cmdRemoveFeature Is Nothing Then m_cmdRemoveFeature = New Command(AddressOf RemoveFeature) End If Return m_cmdRemoveFeature End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemoveFeature() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Return If IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) Then Return If EgtBeamEraseProcess(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM.nFeatureId) Then EgtDuploSetModified(Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId) ' rimuovo dalla lista feature Dim Index As Integer = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.IndexOf(Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM) If Index = 0 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 0 Then Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(0) Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing End If ElseIf Index = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 1 Then If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count > 1 Then Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.Count - 2) Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Nothing End If Else Map.refProjectVM.BTLStructureVM.SelBTLPart.SelBTLFeatureVM = Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList(Index - 1) End If Map.refProjectVM.BTLStructureVM.SelBTLPart.BTLFeatureVMList.RemoveAt(Index) EgtDraw() Map.refProjectVM.BTLStructureVM.SelBTLPart.ResetCalcPart() End If End Sub #End Region ' RemoveFeature #Region "ProduceRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property ProduceRawPart_Command As ICommand Get If m_cmdProduceRawPart Is Nothing Then m_cmdProduceRawPart = New Command(AddressOf ProduceRawPart) End If Return m_cmdProduceRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub ProduceRawPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim ErrorMsg As String = "" ' se attiva opzione e non ancora calcolato If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.SelectedMachGroup.nGlobalState = CalcStates.NOTCALCULATED Then Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCE) Map.refCALCPanelVM.Verify() Return End If If Not Produce(Map.refMachGroupPanelVM.SelectedMachGroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then MessageBox.Show(ErrorMsg) End If End Sub Private Function Produce(MachGroup As MyMachGroupVM, ByRef ErrorMsg As String) As Boolean If IsNothing(MachGroup) Then Return False ' se barra gia' assegnata a supervisore, esco If MachGroup.nProduction_State >= ItemState.Assigned Then Return False If MachGroup.nGlobalState = CalcStates.OK Or MachGroup.nGlobalState = CalcStates.INFO Then ' se ci sono modifiche, salvo il pogetto If EgtGetModified() Then Map.refOnlyProdManagerVM.Save() End If ' mando al supervisore DbControllers.m_MachGroupController.UpdateOrder(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_MachGroupController.GetMinIndex(Map.refOnlyProdManagerVM.CurrProd.nProdId) + 1) DbControllers.m_MachGroupController.UpdateSupervisor(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, DbControllers.m_SupervisorId) MachGroup.SentToSupervisor() For Each Part As PartVM In MachGroup.PartVMList DbControllers.m_PartController.UpdateStatus(Map.refOnlyProdManagerVM.CurrProd.nProdId, MachGroup.Id, Part.nPartId, ItemState.Assigned) Part.nProduction_State = ItemState.Assigned Part.NotifyPropertyChanged(NameOf(Part.Background)) ' disabilito impostazione modificato Dim DisableMgr As New DisableModifiedMgr ' blocco modifica del pezzo EgtDuploSetLocked(Part.nPartId) ' ripristino precedente impostazione modificato DisableMgr.ReEnable() Next Return True Else ErrorMsg = String.Format("Impossible sending {0} to supervisor because not machinable!", MachGroup.Name) 'MessageBox.Show(String.Format("Impossible sending {0} to supervisor because it is not machinable!", MachGroup.Name)) Return False End If End Function #End Region ' ProduceRawPart #Region "ProduceAllRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property ProduceAllRawPart_Command As ICommand Get If m_cmdProduceAllRawPart Is Nothing Then m_cmdProduceAllRawPart = New Command(AddressOf ProduceAllRawPart) End If Return m_cmdProduceAllRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub ProduceAllRawPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return ' se attiva opzione e non ancora calcolato If GetMainPrivateProfileInt(S_GENERAL, K_FASTPRODUCE, 0) = 1 And Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x As MyMachGroupVM) x.nProduction_State = ItemState.ND AndAlso x.nGlobalState = CalcStates.NOTCALCULATED) Then Map.refCALCPanelVM.SetFromProduce(CALCPanelVM.ProduceType.PRODUCEALL) Map.refCALCPanelVM.VerifyAll() Return End If If Map.refMachGroupPanelVM.MachGroupVMList.Count > 0 Then Dim MachgroupErrorList As New List(Of MachGroupVM) For Each Machgroup In Map.refMachGroupPanelVM.MachGroupVMList Dim ErrorMsg As String = "" If Not Produce(Machgroup, ErrorMsg) AndAlso Not String.IsNullOrWhiteSpace(ErrorMsg) Then MachgroupErrorList.Add(Machgroup) End If Next If MachgroupErrorList.Count > 0 Then Dim sMachGroups As String = "" For Each MachGroup In MachgroupErrorList sMachGroups &= " " & MachGroup.Name & "," Next sMachGroups = sMachGroups.Trim({" "c, ","c}) MessageBox.Show(String.Format("Impossible sending {0} to supervisor because not machinable!", sMachGroups)) End If End If End Sub #End Region ' ProduceAllRawPart #Region "CopyRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property CopyRawPart_Command As ICommand Get If m_cmdCopyRawPart Is Nothing Then m_cmdCopyRawPart = New Command(AddressOf CopyRawPart) End If Return m_cmdCopyRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub CopyRawPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim nQty As Integer = 1 ' se premuto shift If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then Dim MultiCopyRawPartWndVM As New MultiCopyRawPartWndVM() Dim MultiCopyRawPartWnd As New MultiCopyRawPartWndV(Application.Current.MainWindow, MultiCopyRawPartWndVM) If Not MultiCopyRawPartWnd.ShowDialog() Then Return nQty = MultiCopyRawPartWndVM.nQuantity End If Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' creo copia Dim NewMachGroup As MyMachGroupVM = SelMachGroup.Copy(nQty) If Not IsNothing(NewMachGroup) Then ' lo seleziono Map.refProjectVM.MachGroupPanelVM.SelectedMachGroup = NewMachGroup End If End Sub #End Region ' CopyRawPart #Region "RemoveRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemoveRawPart_Command As ICommand Get If m_cmdRemoveRawPart Is Nothing Then m_cmdRemoveRawPart = New Command(AddressOf RemoveRawPartCmd) End If Return m_cmdRemoveRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemoveRawPartCmd() RemoveRawPart() End Sub Public Sub RemoveRawPart(Optional bAll As Boolean = False) If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return ' se tutti If bAll Then ' cancello tutti For Index = Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 To 0 Step -1 Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(Index) ' se barra gia' assegnata a supervisore, esco If CurrMachGroup.nProduction_State >= ItemState.Assigned Then Continue For CurrMachGroup.DeleteMachGroup(True) Next Else Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' se barra gia' assegnata a supervisore, esco If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return SelMachGroup.DeleteMachGroup() End If EgtDraw() ' se nessun grezzo, rimetto tutti i pezzi invisibili If Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Count = 0 Then Map.refProjectVM.BTLStructureVM.HideAll(True) End If End Sub #End Region ' RemoveRawPart #Region "RemoveAllRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemoveAllRawPart_Command As ICommand Get If m_cmdRemoveAllRawPart Is Nothing Then m_cmdRemoveAllRawPart = New Command(AddressOf RemoveAllRawPart) End If Return m_cmdRemoveAllRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemoveAllRawPart() RemoveRawPart(True) End Sub #End Region ' RemoveRawPart #Region "RemovePart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemovePart_Command As ICommand Get If m_cmdRemovePart Is Nothing Then m_cmdRemovePart = New Command(AddressOf RemovePart) End If Return m_cmdRemovePart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemovePart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' se barra gia' assegnata a supervisore, esco If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return Dim SelPart As PartVM = SelMachGroup.SelPart If IsNothing(SelPart) Then Return SelPart.DeletePart() SelMachGroup.UpdateUsage() SelMachGroup.ResetCalcMachGroup() End Sub #End Region ' RemovePart #Region "MoveUpPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MoveUpPart_Command As ICommand Get If m_cmdMoveUpPart Is Nothing Then m_cmdMoveUpPart = New Command(AddressOf MoveUpPart) End If Return m_cmdMoveUpPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MoveUpPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' se barra gia' assegnata a supervisore, esco If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return Dim SelPart As PartVM = SelMachGroup.SelPart If IsNothing(SelPart) Then Return If SelMachGroup.nType = MachineType.BEAM Then SelMachGroup.MoveBeam(SelPart, MoveDirections.UP) EgtDraw() ' riseleziono trave SelMachGroup.SelPart = SelPart End If SelMachGroup.ResetCalcMachGroup() End Sub #End Region ' MoveUpPart #Region "MoveDownPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MoveDownPart_Command As ICommand Get If m_cmdMoveDownPart Is Nothing Then m_cmdMoveDownPart = New Command(AddressOf MoveDownPart) End If Return m_cmdMoveDownPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MoveDownPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' se barra gia' assegnata a supervisore, esco If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return Dim SelPart As PartVM = SelMachGroup.SelPart If IsNothing(SelPart) Then Return If SelMachGroup.nType = MachineType.BEAM Then SelMachGroup.MoveBeam(SelPart, MoveDirections.DOWN) EgtDraw() ' riseleziono trave SelMachGroup.SelPart = SelPart End If SelMachGroup.ResetCalcMachGroup() End Sub #End Region ' MoveDownPart #Region "ReOrderPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property ReOrderPart_Command As ICommand Get If m_cmdReOrderPart Is Nothing Then m_cmdReOrderPart = New Command(AddressOf ReOrderPart) End If Return m_cmdReOrderPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub ReOrderPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup If IsNothing(SelMachGroup) Then Return ' se barra gia' assegnata a supervisore, esco If SelMachGroup.nProduction_State >= ItemState.Assigned Then Return Dim SelPart As PartVM = SelMachGroup.SelPart If IsNothing(SelPart) Then Return If SelMachGroup.nType = MachineType.BEAM Then SelMachGroup.ReorderBeam() EgtDraw() ' riseleziono trave If Not IsNothing(SelPart) Then SelMachGroup.SelPart = SelPart End If End If SelMachGroup.ResetCalcMachGroup() End Sub #End Region ' ReOrderPart #Region "MovePartInRawPart" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property MovePartInRawPart_Command As ICommand Get If m_cmdMovePartInRawPart Is Nothing Then m_cmdMovePartInRawPart = New Command(AddressOf MovePartInRawPart) End If Return m_cmdMovePartInRawPart End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub MovePartInRawPart() If IsNothing(Map.refOnlyProdManagerVM.CurrProd) Then Return Dim MovePartInRawPartWndVM As New MovePartInRawPartWndVM() Dim MovePartInRawPartWnd As New MovePartInRawPartWndV(Application.Current.MainWindow, MovePartInRawPartWndVM) If Not MovePartInRawPartWnd.ShowDialog() Then Return End Sub #End Region ' MovePartInRawPart #End Region ' Command End Class