7a378e44f3
- Aggiunto cambio lingua in pagina opzioni. - Sistemati tutti i testi in italiano e inglese.
247 lines
8.5 KiB
VB.net
247 lines
8.5 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports EgtUILib
|
|
|
|
Public Class SplitPageUC
|
|
|
|
' Riferimento alla MainWindow
|
|
Private m_MainWindow As MainWindow = Application.Current.MainWindow
|
|
|
|
Private m_MachiningList As New ObservableCollection(Of NameIdLsBxItem)
|
|
Private m_CurrOperId As Integer = GDB_ID.NULL
|
|
Private m_bModified As Boolean = False
|
|
Private m_nNbrGrpId As Integer = GDB_ID.NULL
|
|
|
|
Private Sub SplitPageUC_Initialized(sender As Object, e As EventArgs)
|
|
' Collego lista di oggetti a ListBox
|
|
MachiningLsBx.ItemsSource = m_MachiningList
|
|
|
|
CutBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 1)
|
|
MoveBtn.Content = EgtMsg(MSG_SPLITPAGEUC + 2)
|
|
End Sub
|
|
|
|
Private Sub SplitPageUC_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
|
|
' Se non c'è ordine delle lavorazioni, ne faccio uno automatico
|
|
If Not m_MainWindow.m_CurrentProjectPageUC.GetOrderMachiningFlag() Then
|
|
Dim bOk As Boolean = SortAllMachinings()
|
|
End If
|
|
' Pulisco la lista
|
|
m_MachiningList.Clear()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Creo gruppo per numeri identificativi di lavorazione
|
|
m_nNbrGrpId = EgtCreateGroup(GDB_ID.ROOT)
|
|
EgtSetColor(m_nNbrGrpId, New Color3d(128, 0, 0))
|
|
EgtSetStatus(m_nNbrGrpId, GDB_ST.SEL)
|
|
' Inserisco le lavorazioni e le identifico
|
|
Dim nCount As Integer = 0
|
|
Dim nOperId As Integer = EgtGetFirstOperation()
|
|
While nOperId <> GDB_ID.NULL
|
|
Dim nOperType As Integer = EgtGetOperationType(nOperId)
|
|
Dim bActive As Boolean = EgtGetOperationMode(nOperId)
|
|
If nOperType = MCH_OY.SAWING And bActive Then
|
|
nCount += 1
|
|
m_MachiningList.Add(New NameIdLsBxItem("Taglio" & nCount.ToString(), nOperId))
|
|
NumberMachining(nOperId, nCount)
|
|
End If
|
|
nOperId = EgtGetNextOperation(nOperId)
|
|
End While
|
|
EgtDraw()
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Reset flag di modifica
|
|
m_bModified = False
|
|
End Sub
|
|
|
|
Private Sub MachiningLsBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles MachiningLsBx.SelectionChanged
|
|
Dim SelItem As NameIdLsBxItem = MachiningLsBx.SelectedItem
|
|
If IsNothing(SelItem) Then
|
|
Return
|
|
End If
|
|
Dim nOperId As Integer = SelItem.ID
|
|
If nOperId <> m_CurrOperId Then
|
|
MarkMachining(m_CurrOperId, False)
|
|
MarkMachining(nOperId, True)
|
|
m_CurrOperId = nOperId
|
|
EgtDraw()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub MoveUpBtn_Click(sender As Object, e As RoutedEventArgs) Handles MoveUpBtn.Click
|
|
MoveItem(-1)
|
|
End Sub
|
|
|
|
Private Sub MoveDownBtn_Click(sender As Object, e As RoutedEventArgs) Handles MoveDownBtn.Click
|
|
MoveItem(1)
|
|
End Sub
|
|
|
|
Public Sub MoveItem(direction As Integer)
|
|
' Checking selected item
|
|
If MachiningLsBx.SelectedItem Is Nothing OrElse MachiningLsBx.SelectedIndex < 0 OrElse MachiningLsBx.SelectedItems.Count > 1 Then
|
|
Return
|
|
End If
|
|
' No selected item - nothing to do
|
|
' Calculate new index using move direction
|
|
Dim newIndex As Integer = MachiningLsBx.SelectedIndex + direction
|
|
|
|
' Checking bounds of the range
|
|
If newIndex < 0 OrElse newIndex >= MachiningLsBx.Items.Count Then
|
|
Return
|
|
End If
|
|
' Index out of range - nothing to do
|
|
Dim selected As Object = MachiningLsBx.SelectedItem
|
|
|
|
' Removing removable element
|
|
m_MachiningList.Remove(selected)
|
|
' Insert it in new position
|
|
m_MachiningList.Insert(newIndex, selected)
|
|
' Restore selection
|
|
MachiningLsBx.SelectedItem = selected
|
|
|
|
' Imposto flag di modifica
|
|
m_bModified = True
|
|
End Sub
|
|
|
|
Private Sub SplitPageUC_Unloaded(sender As Object, e As EventArgs) Handles Me.Unloaded
|
|
' cancello evidenziazione
|
|
If m_CurrOperId <> GDB_ID.NULL Then
|
|
MarkMachining(m_CurrOperId, False)
|
|
m_CurrOperId = GDB_ID.NULL
|
|
EgtDraw()
|
|
End If
|
|
' cancello gruppo di numerazione
|
|
EgtDisableModified()
|
|
EgtErase(m_nNbrGrpId)
|
|
EgtEnableModified()
|
|
' se modificato salvo ordine delle lavorazioni
|
|
If m_bModified Then
|
|
' Al primo posto deve rimanere la prima disposizione
|
|
Dim nFirstOperId As Integer = EgtGetFirstOperation()
|
|
For i = m_MachiningList.Count() - 1 To 0 Step -1
|
|
Dim nMchId As Integer = m_MachiningList(i).ID
|
|
EgtRelocate(nMchId, nFirstOperId, GDB_POS.AFTER)
|
|
Next
|
|
' dichiaro ordine salvato
|
|
m_MainWindow.m_CurrentProjectPageUC.SetOrderMachiningFlag()
|
|
End If
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
Private Sub NumberMachining(nOperId As Integer, nNumber As Integer)
|
|
' Ingombro complessivo della lavorazione
|
|
Dim ptMin, ptMax As Point3d
|
|
' Lavorazione principale
|
|
BoxFromSingleMachining(nOperId, ptMin, ptMax)
|
|
' Eventuali lavorazioni inglobate
|
|
Dim sInfo As String = String.Empty
|
|
If EgtGetInfo(nOperId, "OthMIds", sInfo) Then
|
|
Dim sItems() As String = sInfo.Split(",".ToCharArray)
|
|
For Each sId In sItems
|
|
UpdateBoxFromSingleMachining(CInt(sId), ptMin, ptMax)
|
|
Next
|
|
End If
|
|
' Metto il numero nel centro
|
|
Dim ptCen As Point3d = ptMin + 0.5 * (ptMax - ptMin) + 1 * Vector3d.Z_AX()
|
|
Dim nNbrId As Integer = EgtCreateTextAdv(m_nNbrGrpId, ptCen, 0, nNumber.ToString(), "",
|
|
300, False, 75, 1, 0, INS_POS.MC)
|
|
' Aggiungo a lavorazione info con identificativo del numero
|
|
EgtSetInfo(nOperId, "NbrId", nNbrId)
|
|
End Sub
|
|
|
|
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, "PV"), "PvId", nPvId)
|
|
Return EgtGetBBoxGlob(nPvId, GDB_BB.STANDARD, ptMin, ptMax)
|
|
End Function
|
|
|
|
Private Function UpdateBoxFromSingleMachining(nOperId As Integer, ByRef ptMin As Point3d, ByRef ptMax As Point3d) As Boolean
|
|
' Aggiorno con ingombro della lavorazione
|
|
Dim ptMchMin, ptMchMax As Point3d
|
|
If BoxFromSingleMachining(nOperId, 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)
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
Private Sub MarkMachining(nOperId As Integer, bMark As Boolean)
|
|
' Evidenzio la lavorazione principale
|
|
MarkSingleMachining(nOperId, bMark)
|
|
' Evidenzio l'eventuale numero della lavorazione
|
|
MarkNumber(nOperId, bMark)
|
|
' Se ci sono lavorazioni inglobate, evidenzio anch'esse
|
|
Dim sInfo As String = String.Empty
|
|
If Not EgtGetInfo(nOperId, "OthMIds", sInfo) Then
|
|
Return
|
|
End If
|
|
Dim sItems() As String = sInfo.Split(",".ToCharArray)
|
|
For Each sId In sItems
|
|
MarkSingleMachining(CInt(sId), bMark)
|
|
Next
|
|
End Sub
|
|
|
|
Private Sub MarkSingleMachining(nOperId As Integer, bMark As Boolean)
|
|
Dim nPvId As Integer = GDB_ID.NULL
|
|
If EgtGetInfo(EgtGetFirstNameInGroup(nOperId, "PV"), "PvId", nPvId) Then
|
|
If bMark Then
|
|
EgtSetMark(nPvId)
|
|
Else
|
|
EgtResetMark(nPvId)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub MarkNumber(nOperId As Integer, bMark As Boolean)
|
|
Dim nNbrId As Integer = GDB_ID.NULL
|
|
If EgtGetInfo(nOperId, "NbrId", nNbrId) Then
|
|
If bMark Then
|
|
EgtSetMark(nNbrId)
|
|
Else
|
|
EgtResetMark(nNbrId)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class NameIdLsBxItem
|
|
|
|
Private m_iID As Integer
|
|
Private m_sName As String
|
|
|
|
Public Property ID() As Integer
|
|
Get
|
|
Return m_iID
|
|
End Get
|
|
Set(value As Integer)
|
|
m_iID = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property Name() As String
|
|
Get
|
|
Return m_sName
|
|
End Get
|
|
Set(value As String)
|
|
m_sName = value
|
|
End Set
|
|
End Property
|
|
|
|
'Sub New()
|
|
' Me.Name = String.Empty
|
|
' Me.ID = 0
|
|
'End Sub
|
|
|
|
Sub New(Name As String, ID As Integer)
|
|
Me.Name = Name
|
|
Me.ID = ID
|
|
End Sub
|
|
|
|
End Class |