Files
OmagCUT/AlarmsPageUC.xaml.vb
T
Dario Sassi e2daebcb5a OmagCUT 1.6k10 :
- aggiornamenti e migliorie varie.
2015-12-07 08:05:49 +00:00

115 lines
4.3 KiB
VB.net

Imports System.Windows.Threading
Imports System.IO
Imports EgtUILib
Public Class AlarmsPageUC
' Riferimento alla MainWindow
Private m_MainWindow As MainWindow = Application.Current.MainWindow
Friend m_CN As CN_generico
' Properties
Private m_bFirst As Boolean = True
'Lista che contiene le lame disponibili (per Combobox pagina Alarms)
Friend SawList As New List(Of String)
Private Sub AlarmsPage_Initialized(sender As Object, e As EventArgs)
'Assegno liste a combobox
CurrSawCmBx.ItemsSource = SawList
'Imposto i messaggi letti dal file dei messaggi
CurrSawTxBl.Text = "Lama corrente"
AuxiliaryToolTxBl.Text = "Secondo utensile"
SafeZTxBl.Text = "Distanza di sicurezza"
End Sub
Private Sub AlarmsPage_Loaded(sender As Object, e As RoutedEventArgs)
If Not m_MainWindow.m_bNCLink = 0 Then
ErrorLstBx.ItemsSource = m_CN.sz_NC_error_messages
End If
' Aggiorno lista delle lame per pagina macchina in cui scegliere quella corrente
SawList.Clear()
Dim ToolName As String = String.Empty
Dim nType As Integer = MCH_TY.NONE
If EgtTdbGetFirstTool(MCH_TF.SAWBLADE, ToolName, nType) Then
SawList.Add(ToolName)
While EgtTdbGetNextTool(MCH_TF.SAWBLADE, ToolName, nType)
SawList.Add(ToolName)
End While
End If
' Leggo lama corrente da file ini
GetPrivateProfileString(S_MACH, K_CURRSAW, "", ToolName, m_MainWindow.GetIniFile())
CurrSawCmBx.SelectedItem = ToolName
' Leggo distanza di sicurezza
Dim dSafeZ As Double = 0
EgtMdbGetSafeZ(dSafeZ)
SafeZTxBx.Text = dSafeZ
End Sub
Friend Sub NcError()
If m_CN.sz_NC_error_messages.Count > 0 Then
m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background = Brushes.Red
NCErrorMessages.Text = m_CN.sz_NC_error_messages(0)
Else
NCErrorMessages.Text = ""
Dim BackColor As SolidColorBrush = m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background
If Colors.Red.Equals(BackColor.Color) Then
m_MainWindow.m_MachineStatusUC.MachineStatusGrid.Background = Brushes.DarkGray
End If
End If
End Sub
Friend Sub PlcError(ErrorMsg As String)
' m_MainWindow.m_MachineStatusUC.Background = Brushes.Red
' Dim sFilePath As String = m_MainWindow.GetMachinesRootDir() & "/PLCMessages/" & EgtMsg(MSG_MACHINEPAGEUC + 1)
' Try
' Dim sErrorText As String = File.ReadLines(sFilePath).Skip(m_CN.sz_PLC_error_messages).Take(1).First()
' sErrorText = sErrorText.Substring(sErrorText.IndexOf("$"))
' If sErrorText(0) = " " Then
' sErrorText = sErrorText.Substring(1)
' End If
' PLCErrorMessages.Text = sErrorText
' Catch ex As Exception
' MsgBox("Errore lettura errori PLC")
' End Try
End Sub
Private Sub CurrSawCmBx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles CurrSawCmBx.SelectionChanged
WritePrivateProfileString(S_MACH, K_CURRSAW, CurrSawCmBx.SelectedItem, m_MainWindow.GetIniFile())
m_MainWindow.m_CurrentProjectPageUC.ToolTxBx.Text = CurrSawCmBx.SelectedItem
End Sub
Private Sub SafeZTxBx_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs) Handles SafeZTxBx.PreviewMouseDown
' Lancio calcolatrice
Dim NumericKeyboardWD As New NumericKeyboardWD
NumericKeyboardWD.Owner = m_MainWindow
NumericKeyboardWD.NumericKeyboardWDTitle.Text = SafeZTxBl.Text
NumericKeyboardWD.NumericKeyboardWDTextBox.Text = SafeZTxBx.Text
' Text box per valore di ritorno
NumericKeyboardWD.m_CurrentTxBx = SafeZTxBx
' Imposto Dimensioni e posizione della calcolatrice
NumericKeyboardWD.Top = m_MainWindow.Top + (m_MainWindow.Height / 12)
NumericKeyboardWD.Left = m_MainWindow.Left + (m_MainWindow.Width / 15 * 3)
NumericKeyboardWD.Height = m_MainWindow.Height / 12 * 5
NumericKeyboardWD.Width = m_MainWindow.Width / 15 * 5
' Visualizzo calcolatrice
Dim bRes As Boolean = NumericKeyboardWD.ShowDialog()
' Se nuovo valore
If bRes Then
EgtMdbSetSafeZ(NumericKeyboardWD.m_DoubleResult)
EgtMdbSave()
End If
End Sub
End Class