Files
OmagCUT/MachiningDbPageUC.xaml.vb
T
Emmanuele Sassi 8bd01b8058 OmagCUT :
- Introduzione materiali e spessori nelle lavorazioni.
- Scelta delle lavorazioni che tiene conto di materiali e spessori impostati in Db lavorazioni.
- Bottoni macchina singoli a stati invece che doppi on/off.
- Miglioramenti vari durante prove in macchina.
2016-02-08 09:17:35 +00:00

721 lines
32 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports OmagCUT.TreeViewItem
Imports EgtUILib
Imports EgtWPFLib
Public Class MachiningDbPageUC
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
' Lista degli utensili
Dim MachiningsList As New ObservableCollection(Of CathegoryItem)
' Lista dei materiali
Private m_MaterialsList As New ObservableCollection(Of MachiningMaterial)
' Proprietà
Private m_bFirst As Boolean = True
Private m_sMachiningName As String = String.Empty
'Array che contengono le variabili per Combobox
Dim WorkSide() As String
Dim HeadSide() As String
Dim LeadInType() As String
Dim ExtLinkType() As String
Dim LeadOutType() As String
Dim CurveUse() As String
Dim StepType() As String
Dim SawTool As New List(Of String)
Dim DrillTool As New List(Of String)
'Variabile che conserva la lavorazione precedentemente selezionata, usata nel caso si selezioni annulla quando si cambia lavorazione selezionata
Private m_OldItem As Object
Private Sub MachiningDbPage_Initialized(sender As Object, e As EventArgs)
' Assegno la lista degli utensili come sorgente del treeview
MachiningTreeView.ItemsSource = MachiningsList
' Assegno la lista dei materiali come sorgente della listbox
MaterialsList.ItemsSource = m_MaterialsList
' Imposto testo delle combobox da file dei messaggi
WorkSide = {EgtMsg(MSG_COMBOBOXPARAM + 21), EgtMsg(MSG_COMBOBOXPARAM + 22), EgtMsg(MSG_COMBOBOXPARAM + 23)}
HeadSide = {EgtMsg(MSG_COMBOBOXPARAM + 22), EgtMsg(MSG_COMBOBOXPARAM + 23)}
LeadInType = {EgtMsg(MSG_COMBOBOXPARAM + 24), EgtMsg(MSG_COMBOBOXPARAM + 25), EgtMsg(MSG_COMBOBOXPARAM + 26), EgtMsg(MSG_COMBOBOXPARAM + 27), EgtMsg(MSG_COMBOBOXPARAM + 28)}
ExtLinkType = {EgtMsg(MSG_COMBOBOXPARAM + 24), EgtMsg(MSG_COMBOBOXPARAM + 29), EgtMsg(MSG_COMBOBOXPARAM + 30), EgtMsg(MSG_COMBOBOXPARAM + 31)}
LeadOutType = {EgtMsg(MSG_COMBOBOXPARAM + 32), EgtMsg(MSG_COMBOBOXPARAM + 33), EgtMsg(MSG_COMBOBOXPARAM + 34)}
CurveUse = {EgtMsg(MSG_COMBOBOXPARAM + 35), EgtMsg(MSG_COMBOBOXPARAM + 36), EgtMsg(MSG_COMBOBOXPARAM + 37)}
StepType = {EgtMsg(MSG_COMBOBOXPARAM + 38), EgtMsg(MSG_COMBOBOXPARAM + 39), EgtMsg(MSG_COMBOBOXPARAM + 40)}
'Assegno array a combobox
WorkSideCmBx.ItemsSource = WorkSide
HeadSideCmBx.ItemsSource = HeadSide
LeadInTypeCmBx.ItemsSource = LeadInType
ExtLinkTypeCmBx.ItemsSource = ExtLinkType
LeadOutTypeCmBx.ItemsSource = LeadOutType
CurveUseCmBx.ItemsSource = CurveUse
StepTypeCmBx.ItemsSource = StepType
'Imposto i messaggi letti dal file dei messaggi
NewBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 16)
SaveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 17)
RemoveBtn.Content = EgtMsg(MSG_MACHINEPAGEUC + 18)
NameTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 1)
DepthTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 2)
SideAngleTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 3)
InvertTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 4)
StepTypeTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 5)
WorkSideTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 6)
HeadSideTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 7)
StartPosTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 8)
LeadInTypeTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 9)
ExtLinkTypeTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 10)
LeadOutTypeTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 11)
CurveUseTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 12)
ApproxTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 13)
SawStepGpBx.Header = EgtMsg(MSG_MACHININGSDBPAGEUC + 14)
SawStepTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 15)
DrillStepTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 16)
ArcIntTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 17)
ArcExtTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 18)
LowLenGpBx.Header = EgtMsg(MSG_MACHININGSDBPAGEUC + 19)
StartsLowLenTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 20)
EndsLowLenTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 21)
ThrouAddLenTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 22)
ReturnPosTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 23)
ToolTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 24)
MinThicknessTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 25)
MaxThicknessTxBl.Text = EgtMsg(MSG_MACHININGSDBPAGEUC + 26)
' Associo TextBox e Label
Dim TempLabel1 As New Label
TempLabel1.Content = SideAngleTxBl.Text
SideAngleTxBx.Tag = TempLabel1
Dim TempLabel2 As New Label
TempLabel2.Content = ApproxTxBl.Text
ApproxTxBx.Tag = TempLabel2
End Sub
Private Sub MachiningDbPage_Loaded(sender As Object, e As RoutedEventArgs)
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
InitializeToolLists()
If m_bFirst Then
' Inizializzo le famiglie di utensili nell'albero
InitializeToolLists()
InitializeMachiningFamily(K_SAWING, MCH_MY.SAWING, EgtMsg(MSG_MACHININGSDBPAGEUC + 31))
InitializeMachiningFamily(K_DRILLING, MCH_MY.DRILLING, EgtMsg(MSG_MACHININGSDBPAGEUC + 32))
'InitializeMachiningFamily(K_MILLING, MCH_MY.MILLING, EgtMsg(MSG_MACHININGSDBPAGEUC + 33))
m_bFirst = False
End If
InitializeFirstSelectedItem()
End Sub
'Funzione che permette di inizializzare le liste di utensili
Private Sub InitializeToolLists()
SawTool.Clear()
Dim sToolName As String = String.Empty
Dim nType As Integer = MCH_TY.NONE
If EgtTdbGetFirstTool(MCH_TF.SAWBLADE, sToolName, nType) Then
SawTool.Add(sToolName)
While EgtTdbGetNextTool(MCH_TF.SAWBLADE, sToolName, nType)
SawTool.Add(sToolName)
End While
End If
DrillTool.Clear()
If EgtTdbGetFirstTool(MCH_TF.DRILLBIT, sToolName, nType) Then
DrillTool.Add(sToolName)
While EgtTdbGetNextTool(MCH_TF.DRILLBIT, sToolName, nType)
DrillTool.Add(sToolName)
End While
End If
End Sub
'Funzione che permette l'inizializzazione di albero e parametri all'apertura della pagina ToolsDb
Private Sub InitializeFirstSelectedItem()
If MachiningsList.Count > 0 Then
For Each MachiningFamily In MachiningsList
If MachiningFamily.Items.Count > 0 Then
MachiningFamily.IsExpanded = True
MachiningFamily.Items(0).IsSelected = True
EgtMdbSetCurrMachining(MachiningFamily.Items(0).Name)
m_OldItem = MachiningFamily.Items(0)
GetMachiningParams()
ViewMachiningParams()
Exit Sub
End If
Next
MachiningsList.Item(0).IsSelected = True
HideMachiningParams()
End If
End Sub
'Private Sub MoveParam()
' SpeedBrd.SetValue(Grid.RowProperty, 1)
' FeedBrd.SetValue(Grid.RowProperty, 2)
' CoolantTxBl.SetValue(Grid.RowProperty, 4)
' CoolantCmBx.SetValue(Grid.RowProperty, 4)
' CorrTxBl.SetValue(Grid.RowProperty, 4)
' CorrTxBx.SetValue(Grid.RowProperty, 4)
' OffsetBrd.SetValue(Grid.RowProperty, 5)
' AbsorptionBrd.SetValue(Grid.RowProperty, 6)
' MaxMatTxBl.SetValue(Grid.RowProperty, 7)
' MaxMatTxBx.SetValue(Grid.RowProperty, 7)
'End Sub
Private Sub NewBtn_Click(sender As Object, e As RoutedEventArgs) Handles NewBtn.Click
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
If TypeOf MachiningTreeView.SelectedItem Is CathegoryItem Then
Dim SelectedCathegory As CathegoryItem = MachiningTreeView.SelectedItem
Dim NewName As String = SelectedCathegory.Name
EgtMdbGetMachiningNewName(NewName)
If EgtMdbAddMachining(NewName, SelectedCathegory.nFType) Then
For Each MachiningFamily In MachiningsList
If MachiningFamily.nFType = SelectedCathegory.nFType Then
Dim NewMachiningItem As New CustomItem(NewName, SelectedCathegory.nFType)
MachiningFamily.Items.Add(NewMachiningItem)
NewMachiningItem.IsSelected = True
MachiningFamily.IsExpanded = True
m_OldItem = MachiningTreeView.SelectedItem
End If
Next
GetMachiningParams()
ViewMachiningParams()
End If
ElseIf TypeOf MachiningTreeView.SelectedItem Is CustomItem Then
Dim SelectedCathegory As CustomItem = MachiningTreeView.SelectedItem
Dim NewName As String = SelectedCathegory.Name
EgtMdbGetMachiningNewName(NewName)
If EgtMdbCopyMachining(SelectedCathegory.Name, NewName) Then
Dim CurrType As Integer
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, CurrType)
For Each MachiningFamily In MachiningsList
If MachiningFamily.nFType = CurrType Then
Dim NewMachiningItem As New CustomItem(NewName, CurrType)
MachiningFamily.Items.Add(NewMachiningItem)
NewMachiningItem.IsSelected = True
GetMachiningParams()
m_OldItem = MachiningTreeView.SelectedItem
End If
Next
End If
End If
End Sub
Private Sub SaveBtn_Click(sender As Object, e As RoutedEventArgs) Handles SaveBtn.Click
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
SetMachiningParams()
EgtMdbSaveCurrMachining()
Dim CurrTool As CustomItem = TryCast(m_OldItem, CustomItem)
If CurrTool IsNot Nothing Then
CurrTool.Name = NameTxBx.Text
End If
End Sub
Private Sub RemoveBtn_Click(sender As Object, e As RoutedEventArgs) Handles RemoveBtn.Click
If TypeOf MachiningTreeView.SelectedItem Is CustomItem Then
Dim SelectedItem As CustomItem = MachiningTreeView.SelectedItem
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
EgtMdbRemoveMachining(SelectedItem.Name)
For Each MachiningFamily In MachiningsList
If (MachiningFamily.nFType And SelectedItem.nType) <> 0 Then
MachiningFamily.Items.Remove(SelectedItem)
If MachiningFamily.Items.Count = 0 Then
MachiningFamily.IsSelected = True
HideMachiningParams()
Else
MachiningFamily.Items(0).IsSelected = True
EgtMdbSetCurrMachining(MachiningFamily.Items(0).Name)
m_OldItem = MachiningFamily.Items(0)
GetMachiningParams()
ViewMachiningParams()
End If
End If
Next
End If
End Sub
Private Sub InitializeMachiningFamily(sFIniConst As String, nFType As Integer, sFName As String)
If GetPrivateProfileInt(S_MACHININGS, sFIniConst, 0, m_MainWindow.GetMachIniFile()) = 1 Then
Dim MachiningCathegory As New CathegoryItem(sFName, nFType)
Dim MachiningName As String = String.Empty
If EgtMdbGetFirstMachining(nFType, MachiningName) Then
MachiningCathegory.Items.Add(New CustomItem(MachiningName, nFType))
While EgtMdbGetNextMachining(nFType, MachiningName)
MachiningCathegory.Items.Add(New CustomItem(MachiningName, nFType))
End While
End If
MachiningsList.Add(MachiningCathegory)
End If
End Sub
Private Sub OkBtn_Click(sender As Object, e As RoutedEventArgs) Handles OkBtn.Click
' Se necessario, chiedo se salvare ll lavorazione corrente
If Not SaveCurrMachining() Then
Exit Sub
End If
' Salvo il DB utensili
EgtMdbSave()
' Esco dalla pagina
m_MainWindow.m_MachinePageUC.MachinePageGrid.Children.Remove(m_MainWindow.m_MachinePageUC.m_MachiningDbPageUC)
m_MainWindow.m_MachinePageUC.MachinePageGrid.Children.Add(m_MainWindow.m_MachinePageUC.m_AlarmsPageUC)
m_MainWindow.m_MachinePageUC.m_ActiveMachinePage = MachinePageUC.MachinePages.Alarms
m_MainWindow.m_MachinePageUC.MachiningDBBtn.IsChecked = False
m_MainWindow.m_MachinePageUC.AlarmsBtn.IsChecked = True
End Sub
Private Sub GetMachiningParams()
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
Dim ToolString As String = String.Empty
Dim ToolInt As Integer = 0
Dim ToolDouble As Double = 0
Dim ToolBool As Boolean = False
EgtMdbGetCurrMachiningParam(MCH_MP.NAME, m_sMachiningName)
NameTxBx.Text = m_sMachiningName
EgtMdbGetCurrMachiningParam(MCH_MP.DEPTH_STR, ToolString)
DepthTxBx.Text = ExprToUIExpr(ToolString)
'Parametri Taglio
EgtMdbGetCurrMachiningParam(MCH_MP.SIDEANGLE, ToolDouble)
SideAngleTxBx.Text = DoubleToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.INVERT, ToolBool)
InvertChBx.IsChecked = ToolBool
EgtMdbGetCurrMachiningParam(MCH_MP.STEPTYPE, ToolInt)
StepTypeCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.WORKSIDE, ToolInt)
WorkSideCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.HEADSIDE, ToolInt)
HeadSideCmBx.SelectedIndex = ToolInt - 1
EgtMdbGetCurrMachiningParam(MCH_MP.LEADINTYPE, ToolInt)
LeadInTypeCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.EXTLINKTYPE, ToolInt)
ExtLinkTypeCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.LEADOUTTYPE, ToolInt)
LeadOutTypeCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.CURVEUSE, ToolInt)
CurveUseCmBx.SelectedIndex = ToolInt
EgtMdbGetCurrMachiningParam(MCH_MP.APPROX, ToolDouble)
ApproxTxBx.Text = LenToString(ToolDouble, 3)
'Parametri Foratura
EgtMdbGetCurrMachiningParam(MCH_MP.STARTPOS, ToolDouble)
StartPosTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.STARTSLOWLEN, ToolDouble)
StartsLowLenTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.ENDSLOWLEN, ToolDouble)
EndsLowLenTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.THROUADDLEN, ToolDouble)
ThrouAddLenTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.STEP_, ToolDouble)
StepTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.RETURNPOS, ToolDouble)
ReturnPosTxBx.Text = LenToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.STEPEXTARC, ToolDouble)
ArcExtTxBx.Text = DoubleToString(ToolDouble, 3)
EgtMdbGetCurrMachiningParam(MCH_MP.STEPINTARC, ToolDouble)
ArcIntTxBx.Text = DoubleToString(ToolDouble, 3)
'Parametri utensile
Dim nMachiningType As Integer
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachiningType)
Select Case nMachiningType
Case MCH_MY.SAWING 'Taglio
ToolCmBx.ItemsSource = SawTool
Case MCH_MY.DRILLING 'Foratura
ToolCmBx.ItemsSource = DrillTool
End Select
EgtMdbGetCurrMachiningParam(MCH_MP.TOOL, ToolString)
Dim bToolExist As Boolean = False
For Each CurrTool In ToolCmBx.ItemsSource
If CurrTool = ToolString Then
bToolExist = True
Exit For
End If
Next
If bToolExist Then
ToolCmBx.SelectedItem = ToolString
'Else
' SawTool.Add("")
' ToolCmBx.SelectedItem = ""
End If
' Pulisco lista materiali
m_MaterialsList.Clear()
' Creo lista materiali
For Each Material In m_MainWindow.m_CurrentMachine.Materials
m_MaterialsList.Add(New MachiningMaterial(Material.nId, Material.sName))
Next
EgtMdbGetCurrMachiningParam(MCH_MP.SYSNOTES, ToolString)
If ToolString <> String.Empty Then
Dim sItems() = ToolString.Split(";".ToCharArray)
Dim Index As Integer = 0
For Each Material In m_MaterialsList
Dim Param() As String = sItems(Index).Split(",".ToCharArray)
If Not String.IsNullOrEmpty(Param(0)) AndAlso CInt(Param(0)) = Material.nId Then
Material.dMinThickness = Param(1)
Material.dMaxThickness = Param(2)
Material.bIsActive = True
Index += 1
Else
Material.bIsActive = False
End If
Next
End If
If MaterialsList.Items.Count > 0 Then
MaterialsList.SelectedItem = m_MaterialsList(0)
End If
End Sub
Friend Sub SetMachiningParams()
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
Dim dTemp As Double
Dim bTemp As Boolean
EgtMdbSetCurrMachiningParam(MCH_MP.NAME, NameTxBx.Text)
EgtMdbSetCurrMachiningParam(MCH_MP.DEPTH_STR, UIExprToExpr(DepthTxBx.Text))
'Parametri Taglio
StringToDouble(SideAngleTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.SIDEANGLE, dTemp)
bTemp = InvertChBx.IsChecked
EgtMdbSetCurrMachiningParam(MCH_MP.INVERT, bTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STEPTYPE, StepTypeCmBx.SelectedIndex)
EgtMdbSetCurrMachiningParam(MCH_MP.WORKSIDE, WorkSideCmBx.SelectedIndex)
EgtMdbSetCurrMachiningParam(MCH_MP.HEADSIDE, HeadSideCmBx.SelectedIndex + 1)
EgtMdbSetCurrMachiningParam(MCH_MP.LEADINTYPE, LeadInTypeCmBx.SelectedIndex)
EgtMdbSetCurrMachiningParam(MCH_MP.EXTLINKTYPE, ExtLinkTypeCmBx.SelectedIndex)
EgtMdbSetCurrMachiningParam(MCH_MP.LEADOUTTYPE, LeadOutTypeCmBx.SelectedIndex)
EgtMdbSetCurrMachiningParam(MCH_MP.CURVEUSE, CurveUseCmBx.SelectedIndex)
StringToLen(ApproxTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.APPROX, dTemp)
StringToDouble(ArcExtTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STEPEXTARC, dTemp)
StringToDouble(ArcIntTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STEPINTARC, dTemp)
'Parametri Foratura
StringToLen(StartPosTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STARTPOS, dTemp)
StringToLen(StartsLowLenTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STARTSLOWLEN, dTemp)
StringToLen(EndsLowLenTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.ENDSLOWLEN, dTemp)
StringToLen(ThrouAddLenTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.THROUADDLEN, dTemp)
StringToLen(StepTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.STEP_, dTemp)
StringToLen(ReturnPosTxBx.Text, dTemp)
EgtMdbSetCurrMachiningParam(MCH_MP.RETURNPOS, dTemp)
'Parametri utensile
If Not IsNothing(ToolCmBx.SelectedItem) Then
EgtMdbSetCurrMachiningParam(MCH_MP.TOOL, ToolCmBx.SelectedItem.ToString)
Else
EgtMdbSetCurrMachiningParam(MCH_MP.TOOL, String.Empty)
End If
' Scrivo stringa materiali da lista
Dim sMaterialString As String = String.Empty
For Each Material In m_MaterialsList
If Material.bIsActive Then
sMaterialString += Material.nId.ToString & "," & DoubleToString(Material.dMinThickness, 0) & "," & DoubleToString(Material.dMaxThickness, 0) & ";"
End If
Next
EgtMdbSetCurrMachiningParam(MCH_MP.SYSNOTES, sMaterialString)
End Sub
Private Sub ViewMachiningParams()
Dim nMachiningType As Integer
EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachiningType)
NameTxBl.Visibility = Windows.Visibility.Visible
NameTxBx.Visibility = Windows.Visibility.Visible
DepthTxBl.Visibility = Windows.Visibility.Visible
DepthTxBx.Visibility = Windows.Visibility.Visible
Select Case nMachiningType
Case MCH_MY.SAWING 'Parametri Taglio
SideAngleTxBl.Visibility = Windows.Visibility.Visible
SideAngleTxBx.Visibility = Windows.Visibility.Visible
InvertTxBl.Visibility = Windows.Visibility.Visible
InvertChBx.Visibility = Windows.Visibility.Visible
StepTypeTxBl.Visibility = Windows.Visibility.Visible
StepTypeCmBx.Visibility = Windows.Visibility.Visible
SideBrd.Visibility = Windows.Visibility.Visible
TypeBrd.Visibility = Windows.Visibility.Visible
CurveBrd.Visibility = Windows.Visibility.Visible
If MachParamGrd.Children.Contains(StartPosTxBl) Then
MachParamGrd.Children.Remove(StartPosTxBl)
MachParamGrd.Children.Remove(StartPosTxBx)
TypeGrd.Children.Add(StartPosTxBl)
TypeGrd.Children.Add(StartPosTxBx)
StartPosTxBl.SetValue(Grid.ColumnProperty, 0)
StartPosTxBl.SetValue(Grid.RowProperty, 0)
StartPosTxBx.SetValue(Grid.ColumnProperty, 1)
StartPosTxBx.SetValue(Grid.RowProperty, 0)
StartPosTxBl.SetValue(Grid.RowSpanProperty, 1)
StartPosTxBx.SetValue(Grid.RowSpanProperty, 1)
End If
StartPosTxBl.Visibility = Windows.Visibility.Visible
StartPosTxBx.Visibility = Windows.Visibility.Visible
LowLenGpBx.Visibility = Windows.Visibility.Hidden
ThrouAddLenTxBl.Visibility = Windows.Visibility.Hidden
ThrouAddLenTxBx.Visibility = Windows.Visibility.Hidden
If DrillStepGrd.Children.Contains(StepTxBx) Then
DrillStepGrd.Children.Remove(StepTxBx)
SawStepGrd.Children.Add(StepTxBx)
StepTxBx.SetValue(Grid.ColumnProperty, 1)
StepTxBx.SetValue(Grid.RowProperty, 0)
End If
DrillStepBrd.Visibility = Windows.Visibility.Hidden
SawStepGpBx.Visibility = Windows.Visibility.Visible
ReturnPosTxBl.Visibility = Windows.Visibility.Hidden
ReturnPosTxBx.Visibility = Windows.Visibility.Hidden
Case MCH_MY.DRILLING 'Parametri Foratura
SideAngleTxBl.Visibility = Windows.Visibility.Hidden
SideAngleTxBx.Visibility = Windows.Visibility.Hidden
InvertTxBl.Visibility = Windows.Visibility.Hidden
InvertChBx.Visibility = Windows.Visibility.Hidden
StepTypeTxBl.Visibility = Windows.Visibility.Hidden
StepTypeCmBx.Visibility = Windows.Visibility.Hidden
SideBrd.Visibility = Windows.Visibility.Hidden
TypeBrd.Visibility = Windows.Visibility.Hidden
CurveBrd.Visibility = Windows.Visibility.Hidden
If TypeGrd.Children.Contains(StartPosTxBl) Then
TypeGrd.Children.Remove(StartPosTxBl)
TypeGrd.Children.Remove(StartPosTxBx)
MachParamGrd.Children.Add(StartPosTxBl)
MachParamGrd.Children.Add(StartPosTxBx)
StartPosTxBl.SetValue(Grid.ColumnProperty, 0)
StartPosTxBl.SetValue(Grid.RowProperty, 6)
StartPosTxBx.SetValue(Grid.ColumnProperty, 1)
StartPosTxBx.SetValue(Grid.RowProperty, 6)
StartPosTxBl.SetValue(Grid.RowSpanProperty, 3)
StartPosTxBx.SetValue(Grid.RowSpanProperty, 3)
End If
StartPosTxBl.Visibility = Windows.Visibility.Visible
StartPosTxBx.Visibility = Windows.Visibility.Visible
LowLenGpBx.Visibility = Windows.Visibility.Visible
ThrouAddLenTxBl.Visibility = Windows.Visibility.Visible
ThrouAddLenTxBx.Visibility = Windows.Visibility.Visible
If SawStepGrd.Children.Contains(StepTxBx) Then
SawStepGrd.Children.Remove(StepTxBx)
DrillStepGrd.Children.Add(StepTxBx)
StepTxBx.SetValue(Grid.ColumnProperty, 1)
StepTxBx.SetValue(Grid.RowProperty, 2)
End If
SawStepGpBx.Visibility = Windows.Visibility.Hidden
DrillStepBrd.Visibility = Windows.Visibility.Visible
ReturnPosTxBl.Visibility = Windows.Visibility.Visible
ReturnPosTxBx.Visibility = Windows.Visibility.Visible
End Select
'Parametri utensile
ToolTxBl.Visibility = Windows.Visibility.Visible
ToolCmBx.Visibility = Windows.Visibility.Visible
End Sub
Private Sub HideMachiningParams()
'Dim nMachiningType As Integer
'EgtMdbGetCurrMachiningParam(MCH_MP.TYPE, nMachiningType)
NameTxBl.Visibility = Windows.Visibility.Hidden
NameTxBx.Visibility = Windows.Visibility.Hidden
DepthTxBl.Visibility = Windows.Visibility.Hidden
DepthTxBx.Visibility = Windows.Visibility.Hidden
'Parametri Taglio
SideAngleTxBl.Visibility = Windows.Visibility.Hidden
SideAngleTxBx.Visibility = Windows.Visibility.Hidden
InvertTxBl.Visibility = Windows.Visibility.Hidden
InvertChBx.Visibility = Windows.Visibility.Hidden
StepTypeTxBl.Visibility = Windows.Visibility.Hidden
StepTypeCmBx.Visibility = Windows.Visibility.Hidden
SideBrd.Visibility = Windows.Visibility.Hidden
TypeBrd.Visibility = Windows.Visibility.Hidden
CurveBrd.Visibility = Windows.Visibility.Hidden
SawStepGpBx.Visibility = Windows.Visibility.Hidden
'Parametri Foratura
StartPosTxBl.Visibility = Windows.Visibility.Hidden
StartPosTxBx.Visibility = Windows.Visibility.Hidden
LowLenGpBx.Visibility = Windows.Visibility.Hidden
ThrouAddLenTxBl.Visibility = Windows.Visibility.Hidden
ThrouAddLenTxBx.Visibility = Windows.Visibility.Hidden
ReturnPosTxBl.Visibility = Windows.Visibility.Hidden
ReturnPosTxBx.Visibility = Windows.Visibility.Hidden
DrillStepBrd.Visibility = Windows.Visibility.Hidden
'Parametri utensile
ToolTxBl.Visibility = Windows.Visibility.Hidden
ToolCmBx.Visibility = Windows.Visibility.Hidden
End Sub
Private Sub MachiningTreeView_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs) Handles MachiningTreeView.PreviewMouseUp
' Se necessario, chiedo se salvare l'utensile corrente
If Not SaveCurrMachining() Then
Dim PreviousMachining As CustomItem = m_OldItem
PreviousMachining.IsSelected = True
Exit Sub
End If
' Aggiorno
If TypeOf MachiningTreeView.SelectedItem Is CathegoryItem Then
Dim SelectedCathegory As CathegoryItem = MachiningTreeView.SelectedItem
SelectedCathegory.IsExpanded = Not SelectedCathegory.IsExpanded
HideMachiningParams()
ElseIf TypeOf MachiningTreeView.SelectedItem Is CustomItem Then
Dim SelectedMachining As CustomItem = MachiningTreeView.SelectedItem
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
EgtMdbSetCurrMachining(SelectedMachining.Name)
GetMachiningParams()
ViewMachiningParams()
End If
m_OldItem = MachiningTreeView.SelectedItem
End Sub
Friend Function SaveCurrMachining() As Boolean
SetMachiningParams()
If EgtMdbIsCurrMachiningModified() Then
Dim SaveCurrMachiningWnd As New EgtMsgBox(m_MainWindow, "", EgtMsg(MSG_EGTMSGBOX + 3), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
Select Case SaveCurrMachiningWnd.DialogResult
Case 0 ' Annulla
Return False
Case 1 ' Si
EgtMdbSaveCurrMachining()
Dim CurrMachining As CustomItem = TryCast(m_OldItem, CustomItem)
If CurrMachining IsNot Nothing Then
CurrMachining.Name = NameTxBx.Text
End If
Case 2 ' No
EgtMdbSetCurrMachining(m_sMachiningName)
GetMachiningParams()
End Select
End If
Return True
End Function
Private Sub NameTxBx_EgtClosed(sender As Object, e As EventArgs) Handles NameTxBx.EgtClosed
' Se cambiato nome
If NameTxBx.Text <> m_sMachiningName Then
' Imposto contesto macchina
EgtSetCurrentContext(m_MainWindow.m_CurrentProjectPageUC.CurrentProjectScene.GetCtx())
' Se nome nuovo,lo assegno
Dim TempName As String = NameTxBx.Text
EgtMdbGetMachiningNewName(TempName)
If TempName = NameTxBx.Text Then
NameTxBx.Text = NameTxBx.Text
Else
' Nome già utilizzato
Dim InfoBox As New EgtMsgBox(m_MainWindow, "", EgtMsg(91104), EgtMsgBox.Buttons.OK, EgtMsgBox.Icons.ESCLAMATION)
NameTxBx.Text = m_sMachiningName
End If
Else
NameTxBx.Text = m_sMachiningName
End If
End Sub
Private Sub DepthTxBx_EgtClosed(sender As Object, e As EventArgs) Handles DepthTxBx.EgtClosed
' Non devo fare alcunchè
End Sub
Private Sub MaterialsList_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles MaterialsList.SelectionChanged
Dim Selectedmaterial As MachiningMaterial = MaterialsList.SelectedItem
If Not IsNothing(Selectedmaterial) Then
If Selectedmaterial.bIsActive Then
MinThicknessTxBx.Text = DoubleToString(Selectedmaterial.dMinThickness, 0)
MaxThicknessTxBx.Text = DoubleToString(Selectedmaterial.dMaxThickness, 0)
Else
MinThicknessTxBx.Text = 0
MaxThicknessTxBx.Text = 0
End If
End If
End Sub
Private Sub MinThicknessTxBx_EgtClosed(sender As Object, e As EventArgs) Handles MinThicknessTxBx.EgtClosed
Dim SelectedMaterial As MachiningMaterial = MaterialsList.SelectedItem
If MinThicknessTxBx.Text = 0 And MaxThicknessTxBx.Text = 0 Then
SelectedMaterial.bIsActive = False
Else
SelectedMaterial.dMinThickness = MinThicknessTxBx.Text
SelectedMaterial.bIsActive = True
End If
End Sub
Private Sub MaxThicknessTxBx_EgtClosed(sender As Object, e As EventArgs) Handles MaxThicknessTxBx.EgtClosed
Dim SelectedMaterial As MachiningMaterial = MaterialsList.SelectedItem
If MinThicknessTxBx.Text = 0 And MaxThicknessTxBx.Text = 0 Then
SelectedMaterial.bIsActive = False
Else
SelectedMaterial.dMaxThickness = MaxThicknessTxBx.Text
SelectedMaterial.bIsActive = True
End If
End Sub
End Class
Class MachiningMaterial
Implements INotifyPropertyChanged
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Private m_nId As Integer
Private m_sName As String
Private m_dMinThickness As Double
Private m_dMaxThickness As Double
Private m_bIsActive As Boolean
Public ReadOnly Property nId As Integer
Get
Return m_nId
End Get
End Property
Public ReadOnly Property Name As String
Get
Return m_sName
End Get
End Property
Public Property dMinThickness As Double
Get
Return m_dMinThickness
End Get
Set(value As Double)
m_dMinThickness = value
End Set
End Property
Public Property dMaxThickness As Double
Get
Return m_dMaxThickness
End Get
Set(value As Double)
m_dMaxThickness = value
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
Sub New(nId As String, sName As String)
m_nId = nId
m_sName = sName
m_dMinThickness = 0
m_dMaxThickness = 0
m_bIsActive = False
End Sub
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub NotifyPropertyChanged(propName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
End Sub
End Class