Imports System.Collections.ObjectModel Imports EgtUILib Imports EgtWPFLib5 Public Class SplitModeVM Inherits VMBase #Region "FIELDS & PROPERTIES" ' Stato Private m_nCurrPhase As Integer = 0 Private m_MachiningList As New List(Of SplitMach) Private m_bModified As Boolean = False Private m_nNbrGrpId As Integer = GDB_ID.NULL Private m_CurrFirstInd As Integer = -1 Private m_CurrLastInd As Integer = -1 Private m_SelectedItemsList As New ObservableCollection(Of NameIdLsBxItem) Private m_ItemList As New ObservableCollection(Of NameIdLsBxItem) Public ReadOnly Property ItemList As ObservableCollection(Of NameIdLsBxItem) Get Return m_ItemList End Get End Property Private m_SplitModeIsEnabled As Boolean Public Property SplitModeIsEnabled As Boolean Get Return m_SplitModeIsEnabled End Get Set(value As Boolean) m_SplitModeIsEnabled = value NotifyPropertyChanged("SplitModeIsEnabled") End Set End Property Private m_AllExtRedVisibility As Visibility Public Property AllExtRedVisibility As Visibility Get Return m_AllExtRedVisibility End Get Set(value As Visibility) m_AllExtRedVisibility = value NotifyPropertyChanged("AllExtRedVisibility") End Set End Property #Region "Messages" Public ReadOnly Property OnOffMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 1) End Get End Property Public ReadOnly Property AllOnMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 2) End Get End Property Public ReadOnly Property AllOffMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 3) End Get End Property Public ReadOnly Property CutMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 4) End Get End Property Public ReadOnly Property CutStartMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 5) End Get End Property Public ReadOnly Property CutEndMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 6) End Get End Property Public ReadOnly Property OutCenStartMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 7) End Get End Property Public ReadOnly Property AllOutStartMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 8) End Get End Property Public ReadOnly Property AllCenStartMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 9) End Get End Property Public ReadOnly Property OutCenEndMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 12) End Get End Property Public ReadOnly Property AllOutEndMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 13) End Get End Property Public ReadOnly Property AllCenEndMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 14) End Get End Property Public ReadOnly Property AllExtendMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 15) End Get End Property Public ReadOnly Property AllReduceMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 16) End Get End Property Public ReadOnly Property ModifStartMsg As String Get Return EgtMsg( 90373) ' Inizio Modif. End Get End Property Public ReadOnly Property ModifEndMsg As String Get Return EgtMsg( 90374) ' Fine Modif. End Get End Property Public ReadOnly Property PauseMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 31) End Get End Property Public ReadOnly Property InvertMsg As String Get Return EgtMsg(MSG_SPLITPAGEUC + 36) End Get End Property #End Region ' Messages ' Definizione comandi Private m_cmdMoveUp As ICommand Private m_cmdMoveDown As ICommand Private m_cmdOnOff As ICommand Private m_cmdAllOn As ICommand Private m_cmdAllOff As ICommand Private m_cmdCut As ICommand Private m_cmdCutStart As ICommand Private m_cmdCutEnd As ICommand Private m_cmdOutCenStart As ICommand Private m_cmdAllOutStart As ICommand Private m_cmdAllCenStart As ICommand Private m_cmdOutCenEnd As ICommand Private m_cmdAllOutEnd As ICommand Private m_cmdAllCenEnd As ICommand Private m_cmdAllExtend As ICommand Private m_cmdAllReduce As ICommand Private m_cmdModifStart As ICommand Private m_cmdModifEnd As ICommand Private m_cmdPause As ICommand Private m_cmdInvert As ICommand #End Region ' FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New() ' Creo riferimento a questa classe in OmagOFFICEMap OmagOFFICEMap.SetRefSplitModeVM(Me) End Sub #End Region ' CONSTRUCTOR #Region "METHODS" Friend Function InitSplitRaw() As Boolean ' Nascondo eventuali pezzi in parcheggio EstCalc.HideParkedParts() ' Nascondo eventuale contorno da foto EstPhoto.ShowContour(False) ' Deseleziono pezzi EgtDeselectAll() VeinMatching.OnDeselectAll() EgtZoom(ZM.ALL) ' Elimino eventuali pretagli su uscite CamAuto.RemoveAllExitPreCuts() ' Se non sono in sola visualizzazione, faccio ordine automatico delle lavorazioni If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then If CurrentMachine.WaterJettingActive Then ResetAllMachinings() If SortAllMachinings() Then EstCalc.SetOrderMachiningFlag() If CurrentMachine.WaterJettingActive Then Dim bModif As Boolean = TestAllMachiningsForStrict() If bModif Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING) 'Ridotte alcune lavorazioni per evitare interferenze End If End If ' Disabilito impostazione modificato EgtDisableModified() ' Creo gruppo per numeri identificativi di lavorazione (colore default grigio) m_nNbrGrpId = EgtCreateGroup(GDB_ID.ROOT) EgtSetColor(m_nNbrGrpId, COL_MCH_DIS_NUMBER) EgtSetStatus(m_nNbrGrpId, GDB_ST.SEL) EgtSetLevel(m_nNbrGrpId, GDB_LV.TEMP) ' Recupero l'indice della fase corrente m_nCurrPhase = EgtGetCurrPhase() ' Visualizzo solo anteprime di lavorazioni della fase ShowOnePhaseMachiningPreview(m_nCurrPhase) ' Preparo la lista delle lavorazioni CalculateSplitMachList(m_nCurrPhase, m_MachiningList) ' Aggiorno visualizzazione delle lavorazioni For nI As Integer = 0 To m_MachiningList.Count() - 1 ' sistemo colore ColorMachining(m_MachiningList(nI)) ' assegno numerazione NumberDirectionMachining(nI) Next ' Preparo la lista degli Item ShowMachiningList() ' Aggiorno visualizzazione EgtDraw() ' Abilito impostazione modificato EgtEnableModified() ' Nessun item corrente m_CurrFirstInd = -1 m_CurrLastInd = -1 ' Reset flag di modifica m_bModified = False ' Abilitazione bottoni EnableButtons() Return True End Function Friend Function ExitSplitRaw(Optional bTrueExit As Boolean = True) As Boolean ' Rimuovo evidenziazione e numeri RemoveMarkAndNumbers() ' Ripristino colori lavorazioni EgtDisableModified() For i As Integer = 0 To m_MachiningList.Count() - 1 ColorMachining(m_MachiningList(i), True) Next EgtEnableModified() ' Pulisco la lista che tiene conto delle lavorazioni selezionate m_SelectedItemsList.Clear() ' se modificato salvo ordine e stato delle lavorazioni If m_bModified Then ' Al primo posto deve rimanere la disposizione della fase Dim nFirstOperId As Integer = EgtGetPhaseDisposition(m_nCurrPhase) For i = m_ItemList.Count() - 1 To 0 Step -1 Dim nI As Integer = m_ItemList(i).Ind Dim nMchId As Integer = m_MachiningList(nI).m_nId EgtRelocate(nMchId, nFirstOperId, GDB_POS.AFTER) If m_MachiningList(nI).m_bEnabled Then EgtSetOperationMode(m_MachiningList(nI).m_nId, True) EgtRemoveInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_OFF) Else EgtSetOperationMode(m_MachiningList(nI).m_nId, False) EgtSetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_OFF, True) End If Next ' dichiaro ordine salvato EstCalc.SetOrderMachiningFlag() End If ' Affondamento ridotto Dim dReducedDepth As Double = GetMainPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1) ' Restringo o rialzo lavorazioni abilitate ma con interferenza Dim bModified As Boolean = False For Each Mach As SplitMach In m_MachiningList If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then bModified = True End If End If Next If bTrueExit Then ' ritorno a fase 1 EgtSetCurrPhase(1) ' Ripristino visualizzazione preview lavorazioni ShowAllPhasesMachiningPreview() End If If bModified Then ' Ridotte alcune lavorazioni per evitare interferenze OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING) End If Return True End Function Private Sub AddPauseText(ByRef sName As String) sName &= " " & EgtMsg(MSG_SPLITPAGEUC + 32) ' Pausa End Sub Private Sub AddTopText(ByRef sName As String) sName &= " Top" End Sub Private Sub RemovePauseText(ByRef sName As String) sName = sName.Replace(EgtMsg(MSG_SPLITPAGEUC + 32), "") sName = sName.TrimEnd() End Sub Friend Function GetDisabledCutsCount() As Integer ' Determino il numero di tagli disabilitati Dim nCount As Integer = 0 For nI As Integer = 0 To m_MachiningList.Count() - 1 If Not m_MachiningList(nI).m_bEnabled Then nCount += 1 End If Next Return nCount End Function Friend Function GetSplitCutsCount() As Integer ' Determino il numero di tagli passanti almeno da un lato Dim nCount As Integer = 0 For nI As Integer = 0 To m_MachiningList.Count() - 1 If m_MachiningList(nI).m_bEnabled And (m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then nCount += 1 End If Next Return nCount End Function Friend Sub GetSplitCuts(ByRef Cuts() As Integer) ' Determino l'elenco dei tagli passanti almeno da un lato Dim MyCuts As New List(Of Integer) For nI As Integer = 0 To m_MachiningList.Count() - 1 If m_MachiningList(nI).m_bEnabled And (m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) Then MyCuts.Add(m_MachiningList(nI).m_nId) End If Next Cuts = MyCuts.ToArray() End Sub Friend Sub GetEnabledCuts(ByRef Cuts() As Integer) ' Determino l'elenco dei tagli abilitati Dim MyCuts As New List(Of Integer) For nI As Integer = 0 To m_MachiningList.Count() - 1 If m_MachiningList(nI).m_bEnabled Then MyCuts.Add(m_MachiningList(nI).m_nId) End If Next Cuts = MyCuts.ToArray() End Sub Friend Sub ExecAuto() ' Con movimento manuale, non disponibile movimento automatico If OmagOFFICEMap.refMachiningTabVM.ByHand Then Return ' Elimino evidenziazione e numerazione RemoveMarkAndNumbers() ' Calcolo automatico Dim bFinished As Boolean = False Dim bOk As Boolean = SplitAuto.CalculateOnePhaseSplitAuto(bFinished) If Not bOk Then ' Calcolo automatico non riuscito OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90350), 3, MSG_TYPE.WARNING) End If m_bModified = True End Sub Friend Sub ChangeToModify() ' Elimino le fasi successive alla corrente While EgtGetPhaseCount() > m_nCurrPhase RemoveLastPhase() End While ' Aggiorno le lavorazioni (eliminato sort per lasciare ordine immutato) If CurrentMachine.WaterJettingActive Then ResetAllMachinings() EstCalc.SetOrderMachiningFlag() If CurrentMachine.WaterJettingActive Then Dim bModif As Boolean = TestAllMachiningsForStrict() If bModif Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING) 'Ridotte alcune lavorazioni per evitare interferenze End If ' Visualizzo solo anteprime di lavorazioni della fase ShowOnePhaseMachiningPreview(m_nCurrPhase) ' Nascondo gli eventuali percorsi di lavorazione HideAllMachinings() ' Preparo la lista delle lavorazioni e le disabilito CalculateSplitMachList(m_nCurrPhase, m_MachiningList) For nI As Integer = 0 To m_MachiningList.Count() - 1 m_MachiningList(nI).m_bEnabled = False Next ' Aggiorno visualizzazione delle lavorazioni EgtEmptyGroup(m_nNbrGrpId) For nI As Integer = 0 To m_MachiningList.Count() - 1 ' sistemo colore ColorMachining(m_MachiningList(nI)) ' assegno numerazione NumberDirectionMachining(nI) Next ' Preparo la lista degli Item ShowMachiningList() ' Aggiorno visualizzazione EgtDraw() ' Aggiono abilitazione bottoni EnableButtons() End Sub Private Sub ShowMachiningList() m_ItemList.Clear() For i As Integer = 1 To m_MachiningList.Count() Dim Mach As SplitMach = m_MachiningList(i - 1) If Mach.m_nType = MCH_OY.SAWING Then ' Taglio Dim sText As String = String.Empty If Math.Abs(Mach.m_dSideAng) < EPS_ANG_SMALL Then sText = EgtMsg(90791) & " " & i.ToString() If Mach.m_sLay = NAME_ONPATH Then AddTopText( sText) Else sText = EgtMsg(90791) & " " & i.ToString() & " " & DoubleToString(Mach.m_dSideAng, 2) & "°" End If If Mach.m_bPause Then AddPauseText(sText) m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled)) ElseIf Mach.m_nType = MCH_OY.DRILLING Then ' Foratura Dim sText As String = EgtMsg(90792) & " " & i.ToString() If Mach.m_bPause Then AddPauseText(sText) m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled)) ElseIf Mach.m_nType = MCH_OY.MILLING Then ' Fresatura Dim sText As String = EgtMsg(90793) & " " & i.ToString() If Mach.m_sLay = NAME_ONPATH Then AddTopText( sText) m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled)) ElseIf Mach.m_nType = MCH_OY.WATERJETTING Then ' Waterjet Dim sText As String = EgtMsg(90797) & " " & i.ToString() If Mach.m_bPause Then AddPauseText(sText) m_ItemList.Add(New NameIdLsBxItem(sText, i - 1, Mach.m_bEnabled)) End If Next End Sub Private Sub EnableButtons() ' Per bottone PREV OmagOFFICEMap.refMachiningTabVM.PrevIsEnabled = (m_nCurrPhase > 1) ' Per bottone NEXT ' Se abilitato manipolatore If OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.MAN_MANIP) Or OmagOFFICEMap.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.AUTO_MANIP) Then ' Se in modifica If Not OmagOFFICEMap.refMachiningTabVM.IsShow Then ' Se allontanamento perpendicolare If OmagOFFICEMap.refMachiningTabVM.ByHand Then ' Ci deve essere almeno 1 taglio disabilitato e 1 e 1 solo passante OmagOFFICEMap.refMachiningTabVM.NextIsEnabled = (GetDisabledCutsCount() > 0 And GetSplitCutsCount() = 1) ' Altrimenti Else ' Ci deve essere almeno 1 taglio disabilitato e almeno 1 passante oppure fase successiva alla prima OmagOFFICEMap.refMachiningTabVM.NextIsEnabled = (GetDisabledCutsCount() > 0 And (GetSplitCutsCount() > 0 Or m_nCurrPhase > 1)) Or CurrentMachine.bRawFinalMove End If ' altrimenti sto solo visualizzando Else OmagOFFICEMap.refMachiningTabVM.NextIsEnabled = (m_nCurrPhase < EgtGetPhaseCount()) End If Else OmagOFFICEMap.refMachiningTabVM.NextIsEnabled = False End If ' Per bottone MODIFY OmagOFFICEMap.refMachiningTabVM.ModifyIsEnabled = OmagOFFICEMap.refMachiningTabVM.IsShow ' Per bottone AUTO OmagOFFICEMap.refMachiningTabVM.AutoIsEnabled = Not OmagOFFICEMap.refMachiningTabVM.IsShow And ((GetDisabledCutsCount() > 0 Or m_nCurrPhase = 1) And Not OmagOFFICEMap.refMachiningTabVM.ByHand) ' Altri bottoni SplitModeIsEnabled = Not OmagOFFICEMap.refMachiningTabVM.IsShow End Sub Private Function ModifyOtherLeadIn(nI As Integer, nLiOthType As Integer) As Boolean ' Modifico l'attacco delle lavorazioni inglobate For Each nMchId As Integer In m_MachiningList(nI).m_vOthId EgtSetCurrMachining(nMchId) EgtSetMachiningParam(MCH_MP.LEADINTYPE, nLiOthType) Next Return True End Function Private Function ModifyOtherLeadOut(nI As Integer, nLoOthType As Integer) As Boolean ' Modifico l'uscita delle lavorazioni inglobate For Each nMchId As Integer In m_MachiningList(nI).m_vOthId EgtSetCurrMachining(nMchId) EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, nLoOthType) Next Return True End Function Private Sub NumberDirectionMachining(nI As Integer, Optional bNumber As Boolean = True) EgtDisableModified() ' Determino se seconda lavorazione Dim sName As String = String.Empty EgtGetName(m_MachiningList(nI).m_nId, sName) Dim b2ndLav As Boolean = sName.Contains("_") Or sName.Contains("Drip") ' Ingombro complessivo della lavorazione Dim ptMin, ptMax As Point3d If Not BoxFromMachining(nI, ptMin, ptMax) Then Return ' Metto il numero nel centro Dim dRadXY = Point3d.DistXY(ptMin, ptMax) Dim dHtxt As Double = 50 Dim dRat As Double = 0.75 If dRadXY < 200 Then dHtxt = 40 dRat = 0.6 ElseIf dRadXY < 25 Then dHtxt = 25 dRat = 0.5 End If Dim vtXY As Vector3d = ptMax - ptMin vtXY.Normalize() Dim ptCen As Point3d = Point3d.Media(ptMin, ptMax) + vtXY * If(Not b2ndLav, -0.8, 0.8) * dHtxt ptCen.z = ptMax.z + 1 If bNumber Then Dim nNbrId As Integer = EgtCreateTextAdv(m_nNbrGrpId, ptCen, 0, (nI + 1).ToString(), "", 300, False, dHtxt, dRat, 0, INS_POS.MC) m_MachiningList(nI).m_nNbrId = nNbrId ' Aggiungo a numero info con identificativo della lavorazione e viceversa EgtSetInfo(nNbrId, "MId", m_MachiningList(nI).m_nId) EgtSetInfo(m_MachiningList(nI).m_nId, "NbrId", nNbrId) End If ' Se taglio con lama, metto la direzione accanto al numero If m_MachiningList(nI).m_nType = MCH_OY.SAWING Then Dim ptStart As New Point3d(ptCen + m_MachiningList(nI).m_vtDir * dHtxt) Dim vtDir As New Vector3d(m_MachiningList(nI).m_vtDir) Dim bTwin As Boolean = (Not m_MachiningList(nI).m_bEnableInvert OrElse Math.Abs(m_MachiningList(nI).m_dSideAng) > 0.1) Dim nArrId As Integer = AddMachiningDirection(ptStart, vtDir, dHtxt, bTwin) m_MachiningList(nI).m_nArrId = nArrId ' Aggiungo a freccia info con identificativo della lavorazione e viceversa EgtSetInfo(nArrId, "MId", m_MachiningList(nI).m_nId) EgtSetInfo(m_MachiningList(nI).m_nId, "ArrId", nArrId) Else m_MachiningList(nI).m_nArrId = GDB_ID.NULL End If ' Assegno colore a numero e freccia ColorNumberArrow(nI) EgtEnableModified() End Sub Private Function BoxFromMachining(nI As Integer, ByRef ptMin As Point3d, ByRef ptMax As Point3d) As Boolean If nI < 0 Then Return False ' Lavorazione principale If Not BoxFromSingleMachining(m_MachiningList(nI).m_nId, ptMin, ptMax) Then Return False End If ' Eventuali lavorazioni inglobate For Each nId As Integer In m_MachiningList(nI).m_vOthId Dim ptMchMin, ptMchMax As Point3d If BoxFromSingleMachining(nId, ptMchMin, ptMchMax) Then ptMin.x = Math.Min(ptMin.x, ptMchMin.x) ptMin.y = Math.Min(ptMin.y, ptMchMin.y) ptMin.z = Math.Min(ptMin.z, ptMchMin.z) ptMax.x = Math.Max(ptMax.x, ptMchMax.x) ptMax.y = Math.Max(ptMax.y, ptMchMax.y) ptMax.z = Math.Max(ptMax.z, ptMchMax.z) End If Next Return True End Function Private Function BoxFromSingleMachining(nOperId As Integer, ByRef ptMin As Point3d, ByRef ptMax As Point3d) As Boolean ' Recupero il preview della lavorazione Dim nPvId As Integer = GDB_ID.NULL EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) Return EgtGetBBoxGlob(nPvId, GDB_BB.STANDARD, ptMin, ptMax) End Function Private Function AddMachiningDirection(ptStart As Point3d, vtDir As Vector3d, dLen As Double, bTwin As Boolean) As Integer Dim dArrX As Double = dLen * Math.Cos(30 * Math.PI / 180) Dim dArrY As Double = dLen * Math.Sin(30 * Math.PI / 180) Dim nTmpId As Integer = EgtCreateLine(m_nNbrGrpId, Point3d.ORIG() + dArrY * Vector3d.Y_AX(), Point3d.ORIG() + dArrX * Vector3d.X_AX()) Dim nCrvId As Integer = EgtCreateCurveCompo(m_nNbrGrpId, nTmpId, True) EgtAddCurveCompoLine(nCrvId, Point3d.ORIG() - dArrY * Vector3d.Y_AX()) If bTwin Then EgtAddCurveCompoLine(nCrvId, Point3d.ORIG() + 2 * dArrX * Vector3d.X_AX()) EgtCloseCurveCompo(nCrvId) End If Dim frLoc As New Frame3d(ptStart, vtDir, Vector3d.Z_AX() ^ vtDir, Vector3d.Z_AX()) EgtTransform(nCrvId, frLoc) Return nCrvId End Function Private Sub MarkMachining(nI As Integer, bMark As Boolean) If nI < 0 Then Return Dim nOperId As Integer = m_MachiningList(nI).m_nId ' Evidenzio la lavorazione principale MarkSingleMachining(nOperId, bMark) ' Evidenzio l'eventuale numero della lavorazione MarkNumberArrow(nI, bMark) ' Marco anche le lavorazioni inglobate For Each nId As Integer In m_MachiningList(nI).m_vOthId MarkSingleMachining(nId, bMark) Next End Sub Private Sub MarkSingleMachining(nOperId As Integer, bMark As Boolean) Dim nPvId As Integer = GDB_ID.NULL If EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId) Then If bMark Then EgtSetMark(nPvId) Else EgtResetMark(nPvId) End If End If End Sub Private Sub MarkNumberArrow(nI As Integer, bMark As Boolean) If nI < 0 Then Return Dim nNbrId As Integer = m_MachiningList(nI).m_nNbrId Dim nArrId As Integer = m_MachiningList(nI).m_nArrId If bMark Then EgtSetMark(nNbrId) EgtSetMark(nArrId) Else EgtResetMark(nNbrId) EgtResetMark(nArrId) End If End Sub Private Sub ColorNumberArrow(nI As Integer) If nI < 0 Then Return Dim nNbrId As Integer = m_MachiningList(nI).m_nNbrId Dim nArrId As Integer = m_MachiningList(nI).m_nArrId If m_MachiningList(nI).m_bEnabled Then If m_MachiningList(nI).m_nInterf = FMI_TYPE.NONE Then EgtSetColor(nNbrId, COL_MCH_FREE) EgtSetColor(nArrId, COL_MCH_FREE) Else EgtSetColor(nNbrId, COL_MCH_INTERF) EgtSetColor(nArrId, COL_MCH_INTERF) End If Else If m_MachiningList(nI).m_nInterf = FMI_TYPE.NONE Then EgtResetColor(nNbrId) EgtResetColor(nArrId) ElseIf Not m_MachiningList(nI).m_bEnabled Then EgtSetColor(nNbrId, COL_MCH_DIS_INTERF) EgtSetColor(nArrId, COL_MCH_DIS_INTERF) End If End If End Sub Private Sub RemoveMarkAndNumbers() EgtDisableModified() ' cancello evidenziazione If m_CurrFirstInd >= 0 Then For Index = m_CurrFirstInd To m_CurrLastInd MarkMachining(m_ItemList(Index).Ind, False) Next m_CurrFirstInd = -1 m_CurrLastInd = -1 End If ' cancello gruppo di numerazione e ripristino colori lavorazioni EgtErase(m_nNbrGrpId) For i As Integer = 0 To m_MachiningList.Count() - 1 ColorMachining(m_MachiningList(i), True) Next EgtEnableModified() End Sub Private Sub SwapStartEndData(nI As Integer) ' Swap angoli precedente e successivo Dim dAng As Double = m_MachiningList(nI).m_dPrevAng m_MachiningList(nI).m_dPrevAng = m_MachiningList(nI).m_dNextAng m_MachiningList(nI).m_dNextAng = dAng ' Swap lunghezze libere Dim dFreeLen As Double = m_MachiningList(nI).m_dStartFreeLen m_MachiningList(nI).m_dStartFreeLen = m_MachiningList(nI).m_dEndFreeLen m_MachiningList(nI).m_dEndFreeLen = dFreeLen ' Swap stato di allungamento Dim bAll As Boolean = m_MachiningList(nI).m_bStartAll m_MachiningList(nI).m_bStartAll = m_MachiningList(nI).m_bEndAll m_MachiningList(nI).m_bEndAll = bAll ' Swap possibilità di allungamento Dim bCanAll As Boolean = m_MachiningList(nI).m_bCanStartAll m_MachiningList(nI).m_bCanStartAll = m_MachiningList(nI).m_bCanEndAll m_MachiningList(nI).m_bCanEndAll = bCanAll ' Swap stato interferenza If (m_MachiningList(nI).m_nInterf And FMI_TYPE.LI) <> 0 And (m_MachiningList(nI).m_nInterf And FMI_TYPE.LO) = 0 Then m_MachiningList(nI).m_nInterf -= FMI_TYPE.LI m_MachiningList(nI).m_nInterf += FMI_TYPE.LO ElseIf (m_MachiningList(nI).m_nInterf And FMI_TYPE.LI) = 0 And (m_MachiningList(nI).m_nInterf And FMI_TYPE.LO) <> 0 Then m_MachiningList(nI).m_nInterf += FMI_TYPE.LI m_MachiningList(nI).m_nInterf -= FMI_TYPE.LO End If ' Swap Allungamento Utente Dim dOrigUsal As Double = 0 EgtGetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_SAL, dOrigUsal) Dim dOrigUeal As Double = 0 EgtGetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_EAL, dOrigUeal) EgtSetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_SAL, dOrigUeal) EgtSetInfo(m_MachiningList(nI).m_nId, INFO_MCH_USER_EAL, dOrigUsal) End Sub #End Region ' METHODS #Region "COMMANDS" #Region "MoveCommands" Public ReadOnly Property MoveUpCommand As ICommand Get If m_cmdMoveUp Is Nothing Then m_cmdMoveUp = New Command(AddressOf MoveUp) End If Return m_cmdMoveUp End Get End Property Public Sub MoveUp(ByVal param As Object) MoveItem(-1) End Sub Public ReadOnly Property MoveDownCommand As ICommand Get If m_cmdMoveDown Is Nothing Then m_cmdMoveDown = New Command(AddressOf MoveDown) End If Return m_cmdMoveDown End Get End Property Public Sub MoveDown(ByVal param As Object) MoveItem(+1) End Sub Public Sub MoveItem(direction As Integer) ' Checking selected item If m_CurrFirstInd = -1 Then Return End If ' Se la direzione è giù If direction = 1 And m_CurrLastInd < m_ItemList.Count - 1 Then ' sposto il successivo prima di tutti i selezionati m_ItemList.Move(m_CurrLastInd + 1, m_CurrFirstInd) MoveMachining(m_CurrLastInd + 1, m_CurrFirstInd) ' aggiorno gli indici degli elementi coinvolti nello spostamento (selezionati e non) For index = m_CurrLastInd + 1 To m_CurrFirstInd Step -1 m_ItemList(index).Ind = index Next m_CurrFirstInd += 1 m_CurrLastInd += 1 ElseIf direction = -1 And m_CurrFirstInd > 0 Then ' sposto il precedente dopo tutti i selezionati m_ItemList.Move(m_CurrFirstInd - 1, m_CurrLastInd) MoveMachining(m_CurrFirstInd - 1, m_CurrLastInd) ' aggiorno gli indici degli elementi coinvolti nello spostamento (selezionati e non) For index = m_CurrFirstInd - 1 To m_CurrLastInd m_ItemList(index).Ind = index Next m_CurrFirstInd -= 1 m_CurrLastInd -= 1 End If ' Imposto flag di modifica m_bModified = True End Sub Private Sub MoveMachining(oldIndex As Integer, newIndex As Integer) Dim item As SplitMach = m_MachiningList(oldIndex) m_MachiningList.RemoveAt(oldIndex) m_MachiningList.Insert(newIndex, item) End Sub #End Region ' MoveCommands #Region "OnOffCommand" Public ReadOnly Property OnOffCommand As ICommand Get If m_cmdOnOff Is Nothing Then m_cmdOnOff = New Command(AddressOf OnOff) End If Return m_cmdOnOff End Get End Property Public Sub OnOff(ByVal param As Object) If m_CurrFirstInd = -1 Then Return For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind If m_MachiningList(nI).m_bEnabled Then m_MachiningList(nI).m_bEnabled = False m_ItemList(Index).bIsActive = False Else m_MachiningList(nI).m_bEnabled = True m_ItemList(Index).bIsActive = True End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) Next EgtDraw() ' Imposto flag di modifica m_bModified = True ' Abilitazione bottone Next EnableButtons() End Sub #End Region ' OnOffCommand #Region "AllOnCommand" Public ReadOnly Property AllOnCommand As ICommand Get If m_cmdAllOn Is Nothing Then m_cmdAllOn = New Command(AddressOf AllOn) End If Return m_cmdAllOn End Get End Property Public Sub AllOn(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 If Not m_MachiningList(nI).m_bEnabled Then m_MachiningList(nI).m_bEnabled = True m_ItemList(nI).bIsActive = True ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) End If Next EgtDraw() ' Imposto flag di modifica m_bModified = True ' Abilitazione bottone Next EnableButtons() End Sub #End Region ' AllOnCommand #Region "AllOffCommand" Public ReadOnly Property AllOffCommand As ICommand Get If m_cmdAllOff Is Nothing Then m_cmdAllOff = New Command(AddressOf AllOff) End If Return m_cmdAllOff End Get End Property Public Sub AllOff(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 If m_MachiningList(nI).m_bEnabled Then m_MachiningList(nI).m_bEnabled = False m_ItemList(nI).bIsActive = False ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) End If Next EgtDraw() ' Imposto flag di modifica m_bModified = True ' Abilitazione bottone Next EnableButtons() End Sub #End Region ' AllOffCommand #Region "CutCommands" Public ReadOnly Property CutCommand As ICommand Get If m_cmdCut Is Nothing Then m_cmdCut = New Command(AddressOf Cut) End If Return m_cmdCut End Get End Property Public Sub Cut(ByVal param As Object) If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind ' Provo ad entrambi gli estremi Dim bModif As Boolean = AdjustBothCuts(nI) ' Provo all'inizio If Not bModif Then bModif = AdjustStartCut(nI) ' Provo alla fine If Not bModif Then bModif = AdjustEndCut(nI) ' Se modificato qualcosa If bModif Then bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If ' Aggiono abilitazione bottoni EnableButtons() End Sub Public ReadOnly Property CutStartCommand As ICommand Get If m_cmdCutStart Is Nothing Then m_cmdCutStart = New Command(AddressOf CutStart) End If Return m_cmdCutStart End Get End Property Public Sub CutStart(ByVal param As Object) If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind ' Eseguo If AdjustStartCut(nI) Then bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If ' Aggiono abilitazione bottoni EnableButtons() End Sub Public ReadOnly Property CutEndCommand As ICommand Get If m_cmdCutEnd Is Nothing Then m_cmdCutEnd = New Command(AddressOf CutEnd) End If Return m_cmdCutEnd End Get End Property Public Sub CutEnd(ByVal param As Object) If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind ' Eseguo If AdjustEndCut(nI) Then bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If ' Aggiono abilitazione bottoni EnableButtons() End Sub Private Function AdjustBothCuts(nI As Integer, Optional bAllForced As Boolean = False, Optional bAccForced As Boolean = False) As Boolean ' Verifico che entrambi gli estremi siano allungabili If Not (m_MachiningList(nI).m_bCanStartAll And m_MachiningList(nI).m_bCanEndAll) Then Return False ' Eseguo allungamento o riporto allo standard EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLiPrev As Integer EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) Dim nLoPrev As Integer EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) If (m_MachiningList(nI).m_bStartAll Or m_MachiningList(nI).m_bEndAll) And Not bAllForced Then ' accorcio If nLiPrev = MCH_SAW_LI.EXT_OUT Then EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT) Else EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) End If If nLoPrev = MCH_SAW_LO.EXT_OUT Then EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.OUT) Else EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) End If UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) m_MachiningList(nI).m_bStartAll = False m_MachiningList(nI).m_bEndAll = False ElseIf m_MachiningList(nI).m_bEnabled And Not bAccForced Then ' allungo If nLiPrev = MCH_SAW_LI.OUT Then EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT) Else EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT) End If If nLoPrev = MCH_SAW_LO.OUT Then EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT) Else EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT) End If UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) m_MachiningList(nI).m_bStartAll = True m_MachiningList(nI).m_bEndAll = True End If ColorMachining(m_MachiningList(nI)) Return True End Function Private Function AdjustStartCut(nI As Integer, Optional bAllForced As Boolean = False, Optional bAccForced As Boolean = False) As Boolean ' Verifico che l'estremo iniziale sia allungabile If Not m_MachiningList(nI).m_bCanStartAll Then Return False ' Eseguo allungamento o riporto allo standard EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLiPrev As Integer EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) If m_MachiningList(nI).m_bStartAll And Not bAllForced Then ' accorcio If nLiPrev = MCH_SAW_LI.EXT_OUT Then EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT) Else EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) End If UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) m_MachiningList(nI).m_bStartAll = False ElseIf m_MachiningList(nI).m_bEnabled And Not bAccForced Then ' allungo If nLiPrev = MCH_SAW_LI.OUT Then EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT) Else EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT) End If UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) m_MachiningList(nI).m_bStartAll = True End If ColorMachining(m_MachiningList(nI)) Return True End Function Private Function AdjustEndCut(nI As Integer, Optional bAllForced As Boolean = False, Optional bAccForced As Boolean = False) As Boolean ' Verifico che l'estremo finale sia allungabile If Not m_MachiningList(nI).m_bCanEndAll Then Return False ' Eseguo allungamento o riporto allo standard EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLoPrev As Integer EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) If m_MachiningList(nI).m_bEndAll And Not bAllForced Then ' accorcio If nLoPrev = MCH_SAW_LO.EXT_OUT Then EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.OUT) Else EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) End If m_MachiningList(nI).m_bEndAll = False ElseIf m_MachiningList(nI).m_bEnabled And Not bAccForced Then ' allungo If nLoPrev = MCH_SAW_LO.OUT Then EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT) Else EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT) End If m_MachiningList(nI).m_bEndAll = True End If UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ColorMachining(m_MachiningList(nI)) Return True End Function #End Region ' CutCommands #Region "OutCenStartCommand" Public ReadOnly Property OutCenStartCommand As ICommand Get If m_cmdOutCenStart Is Nothing Then m_cmdOutCenStart = New Command(AddressOf OutCenStart) End If Return m_cmdOutCenStart End Get End Property Public Sub OutCenStart(ByVal param As Object) If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind If m_MachiningList(nI).m_sLay = NAME_OUTLOOP Then EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLiPrev As Integer EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) If nLiPrev = MCH_SAW_LI.OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLiPrev = MCH_SAW_LI.EXT_OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT) ElseIf nLiPrev = MCH_SAW_LI.CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLiPrev = MCH_SAW_LI.EXT_CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If End Sub #End Region ' OutCenStartCommand #Region "AllOutStartCommand" Public ReadOnly Property AllOutStartCommand As ICommand Get If m_cmdAllOutStart Is Nothing Then m_cmdAllOutStart = New Command(AddressOf AllOutStart) End If Return m_cmdAllOutStart End Get End Property Public Sub AllOutStart(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLiPrev As Integer EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) If nLiPrev = MCH_SAW_LI.CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLiPrev = MCH_SAW_LI.EXT_CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.OUT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) Next EgtDraw() ' Imposto flag di modifica m_bModified = True End Sub #End Region ' AllOutStartCommand #Region "AllCenStartCommand" Public ReadOnly Property AllCenStartCommand As ICommand Get If m_cmdAllCenStart Is Nothing Then m_cmdAllCenStart = New Command(AddressOf AllCenStart) End If Return m_cmdAllCenStart End Get End Property Public Sub AllCenStart(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLiPrev As Integer EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev) If nLiPrev = MCH_SAW_LI.OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLiPrev = MCH_SAW_LI.EXT_OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadIn(nI, MCH_SAW_LI.CENT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) Next EgtDraw() ' Imposto flag di modifica m_bModified = True End Sub #End Region ' AllCenStartCommand #Region "OutCenEndCommand" Public ReadOnly Property OutCenEndCommand As ICommand Get If m_cmdOutCenEnd Is Nothing Then m_cmdOutCenEnd = New Command(AddressOf OutCenEnd) End If Return m_cmdOutCenEnd End Get End Property Public Sub OutCenEnd(ByVal param As Object) If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind If m_MachiningList(nI).m_sLay = NAME_OUTLOOP Then EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLoPrev As Integer EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) If nLoPrev = MCH_SAW_LO.OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.CENT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLoPrev = MCH_SAW_LO.EXT_OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.CENT) ElseIf nLoPrev = MCH_SAW_LO.CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.OUT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLoPrev = MCH_SAW_LO.EXT_CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.OUT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If End Sub #End Region ' OutCenEndCommand #Region "AllOutEndCommand" Public ReadOnly Property AllOutEndCommand As ICommand Get If m_cmdAllOutEnd Is Nothing Then m_cmdAllOutEnd = New Command(AddressOf AllOutEnd) End If Return m_cmdAllOutEnd End Get End Property Public Sub AllOutEnd(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLoPrev As Integer EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) If nLoPrev = MCH_SAW_LO.CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.OUT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLoPrev = MCH_SAW_LO.EXT_CENT Then ' allungo EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.OUT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) Next EgtDraw() ' Imposto flag di modifica m_bModified = True End Sub #End Region ' AllOutEndCommand #Region "AllCenEndCommand" Public ReadOnly Property AllCenEndCommand As ICommand Get If m_cmdAllCenEnd Is Nothing Then m_cmdAllCenEnd = New Command(AddressOf AllCenEnd) End If Return m_cmdAllCenEnd End Get End Property Public Sub AllCenEnd(ByVal param As Object) For nI As Integer = 0 To m_MachiningList.Count() - 1 EgtSetCurrMachining(m_MachiningList(nI).m_nId) Dim nLoPrev As Integer EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev) If nLoPrev = MCH_SAW_LO.OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.CENT) ' ri-verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ElseIf nLoPrev = MCH_SAW_LO.EXT_OUT Then ' accorcio EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ModifyOtherLeadOut(nI, MCH_SAW_LO.CENT) End If ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) Next EgtDraw() ' Imposto flag di modifica m_bModified = True End Sub #End Region ' AllCenEndCommand #Region "AllExtendCommand" Public ReadOnly Property AllExtendCommand As ICommand Get If m_cmdAllExtend Is Nothing Then m_cmdAllExtend = New Command(AddressOf AllExtend) End If Return m_cmdAllExtend End Get End Property Public Sub AllExtend(ByVal param As Object) Dim bModif As Boolean = False For nI As Integer = 0 To m_MachiningList.Count() - 1 ' Provo ad entrambi gli estremi Dim bOneModif As Boolean = AdjustBothCuts(nI, True, False) ' Provo all'inizio If Not bOneModif Then bOneModif = AdjustStartCut(nI, True, False) ' Provo alla fine If Not bOneModif Then bOneModif = AdjustEndCut(nI, True, False) ' Aggiorno flag globale If bOneModif Then bModif = True Next ' Se modificato qualcosa If bModif Then EgtDraw() m_bModified = True End If ' Abilitazione bottone Next EnableButtons() End Sub #End Region ' AllExtendCommand #Region "AllReduceCommand" Public ReadOnly Property AllReduceCommand As ICommand Get If m_cmdAllReduce Is Nothing Then m_cmdAllReduce = New Command(AddressOf AllReduce) End If Return m_cmdAllReduce End Get End Property Public Sub AllReduce(ByVal param As Object) Dim bModif As Boolean = False For nI As Integer = 0 To m_MachiningList.Count() - 1 ' Provo ad entrambi gli estremi Dim bOneModif As Boolean = AdjustBothCuts(nI, False, True) ' Provo all'inizio If Not bOneModif Then bOneModif = AdjustStartCut(nI, False, True) ' Provo alla fine If Not bOneModif Then bOneModif = AdjustEndCut(nI, False, True) ' Aggiorno flag globale If bOneModif Then bModif = True Next ' Se modificato qualcosa If bModif Then EgtDraw() m_bModified = True End If ' Abilitazione bottone Next EnableButtons() End Sub #End Region ' AllReduceCommand #Region "ModifStartCommand" Public ReadOnly Property ModifStartCommand As ICommand Get If m_cmdModifStart Is Nothing Then m_cmdModifStart = New Command(AddressOf ModifStart) End If Return m_cmdModifStart End Get End Property Public Sub ModifStart(ByVal param As Object) ' Recupero la lavorazione corrente If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind Dim nOperId As Integer = m_MachiningList(nI).m_nId Dim nMachiningType As Integer = EgtGetOperationType(nOperId) ' Se taglio con lama If nMachiningType = MCH_MY.SAWING Then Dim dOrigUsal As Double = 0 EgtGetInfo(nOperId, INFO_MCH_USER_SAL, dOrigUsal) ' Dialogo richiesta valore Dim ModifStartWindow As New ModifStartEndCutWindowV Dim ModifStartWindowVM As New ModifStartEndCutWindowVM ModifStartWindow.DataContext = ModifStartWindowVM ModifStartWindow.Owner = Application.Current.MainWindow ModifStartWindowVM.SetVal(dOrigUsal) If Not ModifStartWindow.ShowDialog() Then Return ' Modifica della lavorazione Dim dUsal As Double = ModifStartWindowVM.GetVal() EgtSetCurrMachining(nOperId) Dim dAddLen As Double = 0 EgtGetMachiningParam(MCH_MP.STARTADDLEN, dAddLen) If dAddLen - dOrigUsal < -10 * EPS_SMALL Then Return EgtSetMachiningParam(MCH_MP.STARTADDLEN, dAddLen + dUsal - dOrigUsal) EgtSetInfo(nOperId, INFO_MCH_USER_SAL, dUsal) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ' verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True ' se altrimenti getto d'acqua ElseIf nMachiningType = MCH_MY.WATERJETTING Then ' Recupero i valori attuali della lavorazione Dim dAddLen As Double = 0 Dim bLiHole As Boolean = True Dim nTangDist As Double = 0 Dim nPerpDist As Double = 0 Dim LeadInTypeId As Integer = 0 EgtSetCurrMachining(nOperId) EgtGetMachiningParam(MCH_MP.STARTADDLEN, dAddLen) EgtGetMachiningParam(MCH_MP.LIHOLE, bLiHole) EgtGetMachiningParam(MCH_MP.LITANG, nTangDist) EgtGetMachiningParam(MCH_MP.LIPERP, nPerpDist) EgtGetMachiningParam(MCH_MP.LEADINTYPE, LeadInTypeId) ' Dialogo richiesta valori Dim ModifStartWnd As New ModifStartEndWjWindowV Dim ModifStartWndVM As New ModifStartEndWjWindowVM ModifStartWnd.DataContext = ModifStartWndVM ModifStartWnd.Owner = Application.Current.MainWindow ModifStartWndVM.HoleVisibility = Visibility.Visible ModifStartWndVM.LeadInVisibility = Visibility.Visible ModifStartWndVM.LeadOutVisibility = Visibility.Hidden ModifStartWndVM.SetVal(dAddLen) ModifStartWndVM.SetHole(bLiHole) ModifStartWndVM.SetLeadInType(LeadInTypeId) ModifStartWndVM.SetLiTangDist(nTangDist) ModifStartWndVM.SetLiPerpDist(nPerpDist) If Not ModifStartWnd.ShowDialog() Then Return ' Modifica della lavorazione EgtSetCurrMachining(nOperId) EgtSetMachiningParam(MCH_MP.LIHOLE, ModifStartWndVM.GetHole()) EgtSetMachiningParam(MCH_MP.STARTADDLEN, ModifStartWndVM.GetVal()) EgtSetMachiningParam(MCH_MP.LEADINTYPE, ModifStartWndVM.GetLeadInType().Id) EgtSetMachiningParam(MCH_MP.LITANG, ModifStartWndVM.GetLiTangDist()) EgtSetMachiningParam(MCH_MP.LIPERP, ModifStartWndVM.GetLiPerpDist()) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ' verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If End Sub #End Region ' ModifStartCommand #Region "ModifEndCommand" Public ReadOnly Property ModifEndCommand As ICommand Get If m_cmdModifEnd Is Nothing Then m_cmdModifEnd = New Command(AddressOf ModifEnd) End If Return m_cmdModifEnd End Get End Property Public Sub ModifEnd(ByVal param As Object) ' Recupero la lavorazione corrente If m_CurrFirstInd = -1 Then Return Dim bGenModif As Boolean = False For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind Dim nOperId As Integer = m_MachiningList(nI).m_nId Dim nMachiningType As Integer = EgtGetOperationType(nOperId) ' Se taglio con lama If nMachiningType = MCH_MY.SAWING Then Dim dOrigUeal As Double = 0 EgtGetInfo(nOperId, INFO_MCH_USER_EAL, dOrigUeal) ' Dialogo richiesta valore Dim ModifStartWindow As New ModifStartEndCutWindowV Dim ModifStartWindowVM As New ModifStartEndCutWindowVM ModifStartWindow.DataContext = ModifStartWindowVM ModifStartWindow.Owner = Application.Current.MainWindow ModifStartWindowVM.SetVal(dOrigUeal) If Not ModifStartWindow.ShowDialog() Then Return ' Modifica della lavorazione Dim dUsal As Double = ModifStartWindowVM.GetVal() EgtSetCurrMachining(nOperId) Dim dAddLen As Double = 0 EgtGetMachiningParam(MCH_MP.ENDADDLEN, dAddLen) If dAddLen - dOrigUeal < -10 * EPS_SMALL Then Return EgtSetMachiningParam(MCH_MP.ENDADDLEN, dAddLen + dUsal - dOrigUeal) EgtSetInfo(nOperId, INFO_MCH_USER_EAL, dUsal) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ' verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True ' se altrimenti getto d'acqua ElseIf nMachiningType = MCH_MY.WATERJETTING Then ' Recupero i valori attuali della lavorazione Dim dAddLen As Double = 0 Dim nTangDist As Double = 0 Dim nPerpDist As Double = 0 Dim LeadOutTypeId As Integer = 0 EgtSetCurrMachining(nOperId) EgtGetMachiningParam(MCH_MP.ENDADDLEN, dAddLen) EgtGetMachiningParam(MCH_MP.LOTANG, nTangDist) EgtGetMachiningParam(MCH_MP.LOPERP, nPerpDist) EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, LeadOutTypeId) ' Dialogo richiesta valori Dim ModifStartWnd As New ModifStartEndWjWindowV() Dim ModifStartWndVM As New ModifStartEndWjWindowVM ModifStartWnd.DataContext = ModifStartWndVM ModifStartWnd.Owner = Application.Current.MainWindow ModifStartWndVM.HoleVisibility = Visibility.Hidden ModifStartWndVM.LeadInVisibility = Visibility.Hidden ModifStartWndVM.LeadOutVisibility = Visibility.Visible ModifStartWndVM.SetVal(dAddLen) ModifStartWndVM.SetLeadOutType(LeadOutTypeId) ModifStartWndVM.SetLoTangDist(nTangDist) ModifStartWndVM.SetLoPerpDist(nPerpDist) If Not ModifStartWnd.ShowDialog() Then Return ' Modifica della lavorazione EgtSetCurrMachining(nOperId) EgtSetMachiningParam(MCH_MP.ENDADDLEN, ModifStartWndVM.GetVal()) EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, ModifStartWndVM.GetLeadOutType().Id) EgtSetMachiningParam(MCH_MP.LOTANG, ModifStartWndVM.GetLoTangDist()) EgtSetMachiningParam(MCH_MP.LOPERP, ModifStartWndVM.GetLoPerpDist()) UpdateMachiningPreview(m_MachiningList(nI).m_nId, True) ' verifico interferenza EgtVerifyMachining(m_MachiningList(nI).m_nId, m_MachiningList(nI).m_nInterf) ColorMachining(m_MachiningList(nI)) ColorNumberArrow(nI) bGenModif = True End If Next ' Se modificato qualcosa If bGenModif Then EgtDraw() m_bModified = True End If End Sub #End Region ' ModifEndCommand #Region "PauseCommand" Public ReadOnly Property PauseCommand As ICommand Get If m_cmdPause Is Nothing Then m_cmdPause = New Command(AddressOf Pause) End If Return m_cmdPause End Get End Property Public Sub Pause(ByVal param As Object) If m_CurrFirstInd = -1 Then Return For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind Dim nOperId As Integer = m_MachiningList(nI).m_nId If GetPause(nOperId) Then ResetPause(nOperId) m_MachiningList(nI).m_bPause = False RemovePauseText(m_ItemList(Index).Name) Else SetPause(nOperId) m_MachiningList(nI).m_bPause = True AddPauseText(m_ItemList(Index).Name) End If Next End Sub #End Region ' PauseCommand #Region "InvertCommand" #End Region ' InvertComman Public ReadOnly Property InvertCommand As ICommand Get If m_cmdInvert Is Nothing Then m_cmdInvert = New Command(AddressOf Invert) End If Return m_cmdInvert End Get End Property Public Sub Invert(ByVal param As Object) If m_CurrFirstInd = -1 Then Return For Index = m_CurrFirstInd To m_CurrLastInd Dim nI As Integer = m_ItemList(Index).Ind ' Si possono invertire solo i tagli di lama If m_MachiningList(nI).m_nType <> MCH_OY.SAWING Then Continue For ' Non si possono invertire i tagli di lama inclinati If Math.Abs(m_MachiningList(nI).m_dSideAng) > 0.1 Then Continue For ' Se abilitata inversione automatica e quindi non invertito If m_MachiningList(nI).m_bEnableInvert Then ' Inverto e disabilito inversione automatica If CamAuto.InvertVerticalCut(m_MachiningList(nI).m_nId) Then m_MachiningList(nI).m_bInvert = True m_MachiningList(nI).m_vtDir = -m_MachiningList(nI).m_vtDir m_MachiningList(nI).m_bEnableInvert = False SwapStartEndData(nI) ResetEnableInvert(m_MachiningList(nI).m_nEntId) EgtErase(m_MachiningList(nI).m_nArrId) NumberDirectionMachining(nI, False) EgtDraw() End If ' se altrimenti disabilitata inversione automatica e invertito ElseIf m_MachiningList(nI).m_bInvert Then ' Tolgo inversione e lascio disabilitazione inv. autom. If CamAuto.InvertVerticalCut(m_MachiningList(nI).m_nId) Then m_MachiningList(nI).m_bInvert = False m_MachiningList(nI).m_vtDir = -m_MachiningList(nI).m_vtDir SwapStartEndData(nI) EgtErase(m_MachiningList(nI).m_nArrId) NumberDirectionMachining(nI, False) EgtDraw() End If ' altrimenti disabilitata inversione automatica e non invertito Else ' Abilito inversione automatica e lascio non invertito m_MachiningList(nI).m_bEnableInvert = True SetEnableInvert(m_MachiningList(nI).m_nEntId) EgtErase(m_MachiningList(nI).m_nArrId) NumberDirectionMachining(nI, False) EgtDraw() End If Next End Sub #End Region ' COMMANDS '----------------------------------------------------------------------------------------------- Public Class NameIdLsBxItem Inherits VMBase Private m_nInd As Integer Private m_sName As String Private m_bIsActive As Boolean Public Property Ind As Integer Get Return m_nInd End Get Set(value As Integer) m_nInd = value End Set End Property Public Property Name As String Get Return m_sName End Get Set(value As String) If value <> m_sName Then m_sName = value NotifyPropertyChanged("Name") End If End Set End Property Public Property bIsActive As Boolean Get Return m_bIsActive End Get Set(value As Boolean) If value <> m_bIsActive Then m_bIsActive = value NotifyPropertyChanged("bIsActive") End If End Set End Property Private m_IsSelected As Boolean Public Property IsSelected As Boolean Get Return m_IsSelected End Get Set(value As Boolean) If Not IsNothing(value) Then m_IsSelected = value If value Then OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.Add(Me) Else OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.Remove(Me) End If ' creo lista ordinata dei selezionati Dim ItemList As New List(Of NameIdLsBxItem) For Each Item In OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList ItemList.Add(Item) Next ItemList.Sort(Function(x, y) Comparer(Of Integer).Default.Compare(OmagOFFICEMap.refSplitModeVM.m_ItemList.IndexOf(x), OmagOFFICEMap.refSplitModeVM.m_ItemList.IndexOf(y))) If Not My.Computer.Keyboard.ShiftKeyDown And (My.Computer.Keyboard.CtrlKeyDown And value) Then ' verifico che siano contigui Dim bContigus As Boolean = False Dim LastSel As NameIdLsBxItem = OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList(OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.Count - 1) If OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.Count = 1 Then bContigus = True Else For Each Item In ItemList If Item.Ind = LastSel.Ind + 1 Or Item.Ind = LastSel.Ind - 1 Then bContigus = True End If Next End If ' se non contiguo, elimino dai selezionati il primo(che è l'ultimo ad essere stato selezionato) If Not bContigus Then ItemList.Remove(LastSel) OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.RemoveAt(OmagOFFICEMap.refSplitModeVM.m_SelectedItemsList.Count - 1) OmagOFFICEMap.refSplitModeVM.ItemList(LastSel.Ind).IsSelected = Not value 'm_IsSelected = Not value End If End If ' resetto marcatura lavorazioni If OmagOFFICEMap.refSplitModeVM.m_CurrFirstInd > -1 Then For Index = OmagOFFICEMap.refSplitModeVM.m_CurrFirstInd To OmagOFFICEMap.refSplitModeVM.m_CurrLastInd OmagOFFICEMap.refSplitModeVM.MarkMachining(OmagOFFICEMap.refSplitModeVM.m_ItemList(Index).Ind, False) Next End If ' resetto indici OmagOFFICEMap.refSplitModeVM.m_CurrFirstInd = -1 OmagOFFICEMap.refSplitModeVM.m_CurrLastInd = -1 ' marco lavorazioni selezionate For Each Item In ItemList OmagOFFICEMap.refSplitModeVM.MarkMachining(Item.Ind, True) Next If (ItemList.Count > 0) Then OmagOFFICEMap.refSplitModeVM.m_CurrFirstInd = OmagOFFICEMap.refSplitModeVM.m_ItemList.IndexOf(ItemList(0)) OmagOFFICEMap.refSplitModeVM.m_CurrLastInd = OmagOFFICEMap.refSplitModeVM.m_ItemList.IndexOf(ItemList(ItemList.Count - 1)) End If EgtDraw() NotifyPropertyChanged("IsSelected") End If End Set End Property Sub New(Name As String, Ind As Integer, bIsActive As Boolean) Me.m_sName = Name Me.m_nInd = Ind Me.m_bIsActive = bIsActive End Sub End Class End Class