Files
OmagCUT/ChooseMachining.xaml.vb
T
Emmanuele Sassi 5d2299a0b2 OmagCUT :
- Migliorata gestione attrezzaggio e scelta lavorazioni.
2016-01-26 14:59:03 +00:00

287 lines
14 KiB
VB.net

Imports EgtUILib
Public Class ChooseMachining
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_CurrentMachine As CurrentMachine = m_MainWindow.m_CurrentMachine
' Liste che contengono gli elementi appartenenti alle ComboBox
Private m_SawingList As New List(Of String)
Private m_AuxiliaryMachiningTypeList As New List(Of String)
Private m_DrillingList As New List(Of String)
Private m_MillingList As New List(Of String)
' Numero righe della finestra, necessario per non ridimensionarla quando si cambia il tipo di utensile ausiliario
Private m_RowNumber As Integer = 6
Sub New(Owner As Window)
Me.Owner = Owner
InitializeComponent()
ShowDialog()
End Sub
Private Sub ChooseMachining_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
Me.Top = Owner.Top + Owner.Height / 2 - Me.Height / 2
Me.Left = Owner.Left + Owner.Width / 2 - Me.Width / 2
CurrSawingCmBx.ItemsSource = m_SawingList
AuxiliaryMachiningCmBx.ItemsSource = m_AuxiliaryMachiningTypeList
CurrDrillingCmBx.ItemsSource = m_DrillingList
CurrMillingCmBx.ItemsSource = m_MillingList
CurrSawingTxBl.Text = EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 1)
AuxiliaryMachiningTxBl.Text = EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 2)
CurrDrillingTxBl.Text = EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 3)
CurrMillingTxBl.Text = EgtMsg(MSG_CHOOSEMACHININGPAGEUC + 4)
End Sub
Private Sub ChooseMachining_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
InitializeMachiningLists()
End Sub
Private Sub InitializeMachiningLists()
'Creo lista lavorazioni di lama
CreateMachiningList(MCH_MY.SAWING, m_CurrentMachine.sCurrSaw, m_SawingList)
' Verifico la configurazione della macchina per creare i combobox
Select Case m_CurrentMachine.MountedToolConfig
Case CurrentMachine.MountedToolConfigs.SAW
ChooseMachiningGrid.Children.Remove(AuxiliaryMachiningTxBl)
ChooseMachiningGrid.Children.Remove(AuxiliaryMachiningCmBx)
Case CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL, CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER, CurrentMachine.MountedToolConfigs.TOOLCHANGER
'Creo lista lavorazioni froretto e fresa
If m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
CreateMachiningList(MCH_MY.DRILLING, m_CurrentMachine.sCurrDrill, m_DrillingList)
CreateMachiningList(MCH_MY.MILLING, m_CurrentMachine.sCurrMill, m_MillingList)
ElseIf m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER Or m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
CreateMachiningList(MCH_MY.DRILLING, m_DrillingList)
CreateMachiningList(MCH_MY.MILLING, m_MillingList)
End If
' Definizione di due righe della tabella con la giusta altezza
For Index = 0 To 1
Dim Row As New RowDefinition
Row.Height = New GridLength(0.5, GridUnitType.Star)
ChooseMachiningGrid.RowDefinitions.Add(Row)
Next
AuxiliaryMachiningTxBl.SetValue(Grid.RowProperty, 2)
AuxiliaryMachiningCmBx.SetValue(Grid.RowProperty, 3)
ButtonsGrid.SetValue(Grid.RowProperty, 5)
AuxiliaryMachiningTxBl.Visibility = Windows.Visibility.Visible
AuxiliaryMachiningCmBx.Visibility = Windows.Visibility.Visible
Me.Height = 341.2
m_RowNumber += 2
End Select
CurrSawingCmBx.SelectedItem = If(Not IsNothing(m_SawingList(0)), m_SawingList(0), Nothing)
If Not m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAW Then
m_AuxiliaryMachiningTypeList.Add("Nessuna")
If m_CurrentMachine.bDrilling Then
m_AuxiliaryMachiningTypeList.Add("Fresatura")
If m_CurrentMachine.bMilling Then
m_AuxiliaryMachiningTypeList.Add("Foratura")
If m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.MANUALTOOLCHANGER Or m_CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
m_AuxiliaryMachiningTypeList.Add("Entrambe")
End If
End If
Else
If m_CurrentMachine.bMilling Then
m_AuxiliaryMachiningTypeList.Add("Foratura")
End If
End If
If m_CurrentMachine.sCurrDrilling <> String.Empty Then
If m_CurrentMachine.sCurrMilling <> String.Empty Then
AuxiliaryMachiningCmBx.SelectedItem = "Entrambe"
Else
AuxiliaryMachiningCmBx.SelectedItem = "Foratura"
End If
Else
If m_CurrentMachine.sCurrMilling <> String.Empty Then
AuxiliaryMachiningCmBx.SelectedItem = "Fresatura"
Else
AuxiliaryMachiningCmBx.SelectedItem = "Nessuna"
End If
End If
End If
End Sub
Private Sub CreateMachiningList(MachiningType As Integer, CurrTool As String, MachiningList As List(Of String))
'Cerco tutte le lavorazioni che utilizzano l'utensile corrente e le aggiungo alla lista
Dim MachiningTool As String = String.Empty
Dim MachiningName As String = String.Empty
If EgtMdbGetFirstMachining(MachiningType, MachiningName) Then
EgtMdbSetCurrMachining(MachiningName)
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, MachiningTool)
If MachiningTool = CurrTool Then
MachiningList.Add(MachiningName)
End If
While EgtMdbGetNextMachining(MachiningType, MachiningName)
EgtMdbSetCurrMachining(MachiningName)
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, MachiningTool)
If MachiningTool = CurrTool Then
MachiningList.Add(MachiningName)
End If
End While
End If
End Sub
Private Sub CreateMachiningList(MachiningType As Integer, MachiningList As List(Of String))
'Cerco tutte le lavorazioni che utilizzano un utensile presente nel portautensile e le aggiungo alla lista
Dim MachiningTool As String = String.Empty
Dim MachiningName As String = String.Empty
Dim ToolFound As Boolean = False
If EgtMdbGetFirstMachining(MachiningType, MachiningName) Then
EgtMdbSetCurrMachining(MachiningName)
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, MachiningTool)
For Each ToolChangerPos In m_CurrentMachine.ToolChanger
If MachiningTool = ToolChangerPos.sTool Then
MachiningList.Add(MachiningName)
ToolFound = True
Exit For
End If
Next
If Not ToolFound Then
For Each ToolChangerPos In m_CurrentMachine.ManualToolChanger
If MachiningTool = ToolChangerPos.sTool Then
MachiningList.Add(MachiningName)
Exit For
End If
Next
End If
While EgtMdbGetNextMachining(MachiningType, MachiningName)
ToolFound = False
EgtMdbSetCurrMachining(MachiningName)
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, MachiningTool)
For Each ToolChangerPos In m_CurrentMachine.ToolChanger
If MachiningTool = ToolChangerPos.sTool Then
MachiningList.Add(MachiningName)
ToolFound = True
Exit For
End If
Next
If Not ToolFound Then
For Each ToolChangerPos In m_CurrentMachine.ManualToolChanger
If MachiningTool = ToolChangerPos.sTool Then
MachiningList.Add(MachiningName)
Exit For
End If
Next
End If
End While
End If
End Sub
Private Sub AuxiliaryMachiningCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles AuxiliaryMachiningCmBx.SelectionChanged
Select Case AuxiliaryMachiningCmBx.SelectedItem
Case "Nessuna"
If m_RowNumber > 8 Then
For Index = m_RowNumber - 1 To 8 Step -1
ChooseMachiningGrid.RowDefinitions.RemoveAt(Index)
Next
m_RowNumber = 8
End If
ButtonsGrid.SetValue(Grid.RowProperty, 5)
m_MainWindow.m_CurrentMachine.sCurrDrilling = String.Empty
m_MainWindow.m_CurrentMachine.sCurrMilling = String.Empty
CurrDrillingTxBl.Visibility = Windows.Visibility.Hidden
CurrDrillingCmBx.Visibility = Windows.Visibility.Hidden
CurrMillingTxBl.Visibility = Windows.Visibility.Hidden
CurrMillingCmBx.Visibility = Windows.Visibility.Hidden
Me.Height = 341.2
Case "Foratura"
' Definizione di due righe della tabella con la giusta altezza
If m_RowNumber < 10 Then
For Index = 1 To 10 - m_RowNumber
Dim Row As New RowDefinition
Row.Height = New GridLength(0.5, GridUnitType.Star)
ChooseMachiningGrid.RowDefinitions.Add(Row)
Next
m_RowNumber = 10
End If
CurrDrillingTxBl.SetValue(Grid.RowProperty, 4)
CurrDrillingCmBx.SetValue(Grid.RowProperty, 5)
ButtonsGrid.SetValue(Grid.RowProperty, 7)
If m_CurrentMachine.sCurrDrilling <> String.Empty Then
CurrDrillingCmBx.SelectedItem = m_CurrentMachine.sCurrDrilling
End If
m_MainWindow.m_CurrentMachine.sCurrMilling = String.Empty
CurrDrillingTxBl.Visibility = Windows.Visibility.Visible
CurrDrillingCmBx.Visibility = Windows.Visibility.Visible
CurrMillingTxBl.Visibility = Windows.Visibility.Hidden
CurrMillingCmBx.Visibility = Windows.Visibility.Hidden
Me.Height = 426.5
Case "Fresatura"
' Definizione di due righe della tabella con la giusta altezza
If m_RowNumber < 10 Then
For Index = 1 To 10 - m_RowNumber
Dim Row As New RowDefinition
Row.Height = New GridLength(0.5, GridUnitType.Star)
ChooseMachiningGrid.RowDefinitions.Add(Row)
Next
m_RowNumber = 10
End If
CurrMillingTxBl.SetValue(Grid.RowProperty, 4)
CurrMillingCmBx.SetValue(Grid.RowProperty, 5)
ButtonsGrid.SetValue(Grid.RowProperty, 7)
If m_CurrentMachine.sCurrMilling <> String.Empty Then
CurrMillingCmBx.SelectedItem = m_CurrentMachine.sCurrMilling
End If
m_MainWindow.m_CurrentMachine.sCurrDrilling = String.Empty
CurrDrillingTxBl.Visibility = Windows.Visibility.Hidden
CurrDrillingCmBx.Visibility = Windows.Visibility.Hidden
CurrMillingTxBl.Visibility = Windows.Visibility.Visible
CurrMillingCmBx.Visibility = Windows.Visibility.Visible
Me.Height = 426.5
Case "Entrambe"
' Definizione di quattro righe della tabella con la giusta altezza
If m_RowNumber < 12 Then
For Index = 1 To 12 - m_RowNumber
Dim Row As New RowDefinition
Row.Height = New GridLength(0.5, GridUnitType.Star)
ChooseMachiningGrid.RowDefinitions.Add(Row)
Next
m_RowNumber = 12
End If
If m_CurrentMachine.sCurrDrilling <> String.Empty Then
CurrDrillingCmBx.SelectedItem = m_CurrentMachine.sCurrDrilling
End If
If m_CurrentMachine.sCurrMilling <> String.Empty Then
CurrMillingCmBx.SelectedItem = m_CurrentMachine.sCurrMilling
End If
CurrDrillingTxBl.SetValue(Grid.RowProperty, 4)
CurrDrillingCmBx.SetValue(Grid.RowProperty, 5)
CurrMillingTxBl.SetValue(Grid.RowProperty, 6)
CurrMillingCmBx.SetValue(Grid.RowProperty, 7)
ButtonsGrid.SetValue(Grid.RowProperty, 9)
CurrDrillingTxBl.Visibility = Windows.Visibility.Visible
CurrDrillingCmBx.Visibility = Windows.Visibility.Visible
CurrMillingTxBl.Visibility = Windows.Visibility.Visible
CurrMillingCmBx.Visibility = Windows.Visibility.Visible
Me.Height = 511.8
End Select
End Sub
Private Sub CurrSawingCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrSawingCmBx.SelectionChanged
m_MainWindow.m_CurrentMachine.sCurrSawing = CurrSawingCmBx.SelectedItem
End Sub
Private Sub CurrDrillingCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrDrillingCmBx.SelectionChanged
m_MainWindow.m_CurrentMachine.sCurrDrilling = CurrDrillingCmBx.SelectedItem
End Sub
Private Sub CurrMillingCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrMillingCmBx.SelectionChanged
m_MainWindow.m_CurrentMachine.sCurrMilling = CurrMillingCmBx.SelectedItem
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
DialogResult = True
End Sub
Private Sub ExitBtn_Click(sender As Object, e As RoutedEventArgs) Handles ExitBtn.Click
DialogResult = False
End Sub
End Class