c0e8838394
- aggiustamenti per lama manuale con TC+SAW - vari altri aggiustamenti per scelta utensili e lavorazioni.
875 lines
32 KiB
VB.net
875 lines
32 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.ComponentModel
|
|
Imports EgtUILib
|
|
|
|
Public Class ControlsMachineButtonUC
|
|
Implements INotifyPropertyChanged
|
|
|
|
' Costanti per nomi stati dei bottoni
|
|
Private Const BTN_STATE_NOTHING As String = "Nothing"
|
|
|
|
Private Enum MachineButtonType As Integer
|
|
NOSTATE = 0
|
|
TWOSTATE = 1
|
|
THREESTATE = 2
|
|
DOUBLECOMMAND = 3
|
|
PRESSEDCOMMAND = 4
|
|
End Enum
|
|
|
|
' Dichiarazione delle Page UserControl
|
|
Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
Private m_DirectCutPage As DirectCutPageUC
|
|
Friend m_CN As CN_generico
|
|
Private m_bFirst As Boolean = True
|
|
|
|
' visualizzo l'elenco degli elementi della pagina sono al primo avvio
|
|
Friend Shared m_OutLogTypeButton As Boolean = True
|
|
|
|
' Creazione converter da String a ImageSource
|
|
Dim ImageConverter As New ImageSourceConverter
|
|
|
|
Private m_ButtonList As New ObservableCollection(Of MachineButton)
|
|
Public ReadOnly Property ButtonList As ObservableCollection(Of MachineButton)
|
|
Get
|
|
Return m_ButtonList
|
|
End Get
|
|
End Property
|
|
|
|
Private Sub ControlsMachineButtonUC_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
|
|
Me.DataContext = Me
|
|
End Sub
|
|
|
|
Private Sub ControlsMachineButtonUC_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
|
|
If m_bFirst Then
|
|
m_DirectCutPage = m_MainWindow.m_DirectCutPageUC
|
|
m_bFirst = False
|
|
|
|
' Lettura configurazione bottoni da Ini di macchina
|
|
Dim m_nCount As Integer = 1
|
|
Dim bFoundBtn As Boolean = True
|
|
While bFoundBtn
|
|
Dim sNameBtn As String = K_BUTTON & (m_nCount).ToString()
|
|
Dim sMachineButtonType As String = String.Empty
|
|
Dim sTImageName As String = String.Empty
|
|
Dim sTLuaScriptName As String = String.Empty
|
|
Dim sFImageName As String = String.Empty
|
|
Dim sFLuaScriptName As String = String.Empty
|
|
Dim sStateFlag As String = String.Empty
|
|
bFoundBtn = GetPrivateProfileMachineButtons(S_CONTROLMACHBUTTONS, sNameBtn, sMachineButtonType, sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag, m_MainWindow.GetMachIniFile())
|
|
If bFoundBtn Then
|
|
m_nCount += 1
|
|
Dim ButtonToAdd As MachineButton = Nothing
|
|
Select Case sMachineButtonType
|
|
Case MachineButtonType.NOSTATE
|
|
ButtonToAdd = New NoStateButton(sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag)
|
|
Case MachineButtonType.TWOSTATE
|
|
ButtonToAdd = New TwoStateButton(sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag)
|
|
Case MachineButtonType.THREESTATE
|
|
ButtonToAdd = New ThreeStateButton(sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag)
|
|
Case MachineButtonType.DOUBLECOMMAND
|
|
ButtonToAdd = New DoubleCommandButton(sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag)
|
|
Case MachineButtonType.PRESSEDCOMMAND
|
|
ButtonToAdd = New PressedCommandButton(sTImageName, sTLuaScriptName, sFImageName, sFLuaScriptName, sStateFlag)
|
|
End Select
|
|
If Not IsNothing(ButtonToAdd) Then m_ButtonList.Add(ButtonToAdd)
|
|
End If
|
|
End While
|
|
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
GetTypeButton(MachineButton)
|
|
Next
|
|
m_OutLogTypeButton = False
|
|
|
|
NotifyPropertyChanged("ButtonList")
|
|
End If
|
|
End Sub
|
|
|
|
#Region "STATE CHANGED"
|
|
' ------------------------------------------------------------------------------
|
|
' i segeunti metodi notificano il cambiamento di stato di specifici bottoni
|
|
'-------------------------------------------------------------------------------
|
|
|
|
Friend Sub GetTypeButton(CurrMachineButton As MachineButton)
|
|
If Not m_OutLogTypeButton Then Return
|
|
Dim BtnType As Type = CurrMachineButton.GetType
|
|
If BtnType Is GetType(NoStateButton) Then
|
|
EgtOutLog(" ► " & BtnType.ToString.Replace("OmagCUT.", "(0) ") & " , " & CurrMachineButton.StateFlag)
|
|
ElseIf BtnType Is GetType(TwoStateButton) Then
|
|
EgtOutLog(" ► " & BtnType.ToString.Replace("OmagCUT.", "(1) ") & " , " & CurrMachineButton.StateFlag)
|
|
ElseIf BtnType Is GetType(ThreeStateButton) Then
|
|
EgtOutLog(" ► " & BtnType.ToString.Replace("OmagCUT.", "(2) ") & " , " & CurrMachineButton.StateFlag)
|
|
ElseIf BtnType Is GetType(DoubleCommandButton) Then
|
|
EgtOutLog(" ► " & BtnType.ToString.Replace("OmagCUT.", "(3) ") & " , " & CurrMachineButton.StateFlag)
|
|
ElseIf BtnType Is GetType(PressedCommandButton) Then
|
|
EgtOutLog(" ► " & BtnType.ToString.Replace("OmagCUT.", "(4) ") & " , " & CurrMachineButton.StateFlag)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub SpindleStateChanged(SpindleState As Boolean)
|
|
Dim SpindleButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_SPINDLE Then
|
|
SpindleButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(SpindleButton) Then
|
|
SpindleButton.SetIsChecked(SpindleState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub LaserStateChanged(LaserState As Boolean)
|
|
Dim LaserButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_LASER Then
|
|
LaserButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(LaserButton) Then
|
|
LaserButton.SetIsChecked(LaserState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub FeedHoldChanged(FeedHoldState As Boolean)
|
|
Dim FeedHoldButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_FEEDHOLD Then
|
|
FeedHoldButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(FeedHoldButton) Then
|
|
FeedHoldButton.SetIsChecked(FeedHoldState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub SpeedHoldChanged(SpeedHoldState As Boolean)
|
|
Dim SpeedHoldButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_SPEEDHOLD Then
|
|
SpeedHoldButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(SpeedHoldButton) Then
|
|
SpeedHoldButton.SetIsChecked(SpeedHoldState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub LaserTracStateChanged(LaserTracState As Boolean)
|
|
Dim LaserTracButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_LASERTRAC Then
|
|
LaserTracButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(LaserTracButton) Then
|
|
LaserTracButton.SetIsChecked(LaserTracState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub CoolantStateChanged(CoolantState As Boolean)
|
|
Dim CoolantButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_COOLANT Then
|
|
CoolantButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(CoolantButton) Then
|
|
CoolantButton.SetIsChecked(CoolantState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub InternalCoolantStateChanged(InternalCoolantState As Boolean)
|
|
Dim IntCoolantButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_INTERNALCOOLANT Then
|
|
IntCoolantButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(IntCoolantButton) Then
|
|
IntCoolantButton.SetIsChecked(InternalCoolantState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub ExternCoolantStateChanged(ExternCoolantState As Boolean)
|
|
Dim ExtCoolantButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_EXTERNCOOLANT Then
|
|
ExtCoolantButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(ExtCoolantButton) Then
|
|
ExtCoolantButton.SetIsChecked(ExternCoolantState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub CBAxesStateChanged(CBAxesState As Boolean)
|
|
Dim CAxesButton As TwoStateButton = Nothing
|
|
Dim BAxesButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_CAXES Then
|
|
CAxesButton = MachineButton
|
|
ElseIf MachineButton.StateFlag = K_BAXES Then
|
|
BAxesButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(CAxesButton) Then
|
|
CAxesButton.SetIsChecked(CBAxesState)
|
|
End If
|
|
If Not IsNothing(BAxesButton) Then
|
|
BAxesButton.SetIsChecked(Not CBAxesState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub AirBlowStateChanged(AirBlowState As Boolean)
|
|
Dim AirBlowButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_AIRBLOW Then
|
|
AirBlowButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(AirBlowButton) Then
|
|
AirBlowButton.SetIsChecked(AirBlowState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub HomeStateChanged(HomeState As Boolean)
|
|
Dim HomeButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_HOME Then
|
|
HomeButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(HomeButton) Then
|
|
HomeButton.SetIsChecked(HomeState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub TableUpChanged(TableUpState As Boolean)
|
|
Dim TableUpButton As PressedCommandButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_TABLEUP Then
|
|
TableUpButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(TableUpButton) Then
|
|
TableUpButton.SetIsPressed(TableUpState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub TableDownChanged(TableDownState As Boolean)
|
|
Dim TableDownButton As PressedCommandButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_TABLEDOWN Then
|
|
TableDownButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(TableDownButton) Then
|
|
TableDownButton.SetIsPressed(TableDownState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub HSMChanged(HsmState As Boolean)
|
|
Dim HsmButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_HSM Then
|
|
HsmButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(HsmButton) Then
|
|
HsmButton.SetIsChecked(HsmState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub DoorClosedChanged(DoorClosedState As Integer)
|
|
Dim DoorClosedButton As ThreeStateButton = Nothing
|
|
Dim DoorOpenedButton As ThreeStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_DOORCLOSED Then
|
|
DoorClosedButton = MachineButton
|
|
End If
|
|
If MachineButton.StateFlag = K_DOOROPENDED Then
|
|
DoorOpenedButton = MachineButton
|
|
End If
|
|
Next
|
|
' Chiusura porte (gesrtione comando Three/Two state
|
|
If Not IsNothing(DoorClosedButton) Then
|
|
Select Case DoorClosedState
|
|
Case 0
|
|
' porta aperta
|
|
DoorClosedButton.Background = Application.Current.FindResource("OmagCut_Red")
|
|
Case 1, 2
|
|
' porta in movimento/aperta
|
|
DoorClosedButton.Background = Application.Current.FindResource("OmagCut_LightGray")
|
|
End Select
|
|
End If
|
|
' Chiusura porte (gesrtione comando Three/Two state
|
|
If Not IsNothing(DoorOpenedButton) Then
|
|
Select Case DoorClosedState
|
|
Case 0
|
|
' porta aperta
|
|
DoorOpenedButton.Background = Application.Current.FindResource("OmagCut_LightGray")
|
|
Case 1
|
|
' porta in movimento
|
|
DoorOpenedButton.Background = Application.Current.FindResource("OmagCut_Yellow")
|
|
Case 2
|
|
' porta chiusa
|
|
DoorOpenedButton.Background = Application.Current.FindResource("OmagCut_Green")
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub LimitZChanged(LimitZState As Boolean)
|
|
Dim TwoLimitZButton As TwoStateButton = Nothing
|
|
Dim DoubleLimitZButton As DoubleCommandButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_LIMITZ Then
|
|
If TypeOf MachineButton Is DoubleCommandButton Then
|
|
DoubleLimitZButton = MachineButton
|
|
If Not IsNothing(DoubleLimitZButton) Then
|
|
DoubleLimitZButton.SetIsChecked(LimitZState)
|
|
End If
|
|
ElseIf TypeOf MachineButton Is TwoStateButton Then
|
|
TwoLimitZButton = MachineButton
|
|
If Not IsNothing(TwoLimitZButton) Then
|
|
TwoLimitZButton.SetIsChecked(LimitZState)
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Friend Sub FiveAxisStateChanged(FiveAxisState As Boolean)
|
|
Dim ThreeAxesButton As TwoStateButton = Nothing
|
|
Dim FiveAxesButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_THREEAXES Then
|
|
ThreeAxesButton = MachineButton
|
|
ElseIf MachineButton.StateFlag = K_FIVEAXES Then
|
|
FiveAxesButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(ThreeAxesButton) Then
|
|
ThreeAxesButton.SetIsChecked(Not FiveAxisState)
|
|
End If
|
|
If Not IsNothing(FiveAxesButton) Then
|
|
FiveAxesButton.SetIsChecked(FiveAxisState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub ParkingStateChanged(ParkingState As Boolean)
|
|
Dim ParkingButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_PARKING Then
|
|
ParkingButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(ParkingButton) Then
|
|
ParkingButton.SetIsChecked(ParkingState)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub ZoneStateChanged(ZoneState As Integer)
|
|
Dim bEnableZone1 As Boolean = False
|
|
If ZoneState = 1 Then
|
|
bEnableZone1 = True
|
|
ElseIf ZoneState = 2 Then
|
|
bEnableZone1 = False
|
|
End If
|
|
' attivo il comando associato
|
|
Dim EnableZoneButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = BTN_ENABLE_ZONE_1 Then
|
|
EnableZoneButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(EnableZoneButton) Then
|
|
EnableZoneButton.SetIsChecked(bEnableZone1)
|
|
End If
|
|
' disattivo l'altro per esclusione
|
|
EnableZoneButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = BTN_ENABLE_ZONE_2 Then
|
|
EnableZoneButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(EnableZoneButton) Then
|
|
EnableZoneButton.SetIsChecked(Not bEnableZone1)
|
|
End If
|
|
End Sub
|
|
|
|
Friend Sub PcStateChanged(EnablePC As Integer)
|
|
Dim bEnablePC1 As Boolean = False
|
|
If EnablePC = 1 Then
|
|
bEnablePC1 = True
|
|
ElseIf EnablePC = 2 Then
|
|
bEnablePC1 = False
|
|
End If
|
|
' attivo/disattivo il comando associato
|
|
Dim EnablePCButton As TwoStateButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = K_ENABLEPC & "_1" Then
|
|
EnablePCButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(EnablePCButton) Then
|
|
EnablePCButton.SetIsChecked(bEnablePC1)
|
|
End If
|
|
' disattivo/attivo l'altro per esclusione
|
|
EnablePCButton = Nothing
|
|
For Each MachineButton As MachineButton In m_ButtonList
|
|
If MachineButton.StateFlag = BTN_ENABLE_ZONE_2 Then
|
|
EnablePCButton = MachineButton
|
|
End If
|
|
Next
|
|
If Not IsNothing(EnablePCButton) Then
|
|
EnablePCButton.SetIsChecked(Not bEnablePC1)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' State Range
|
|
|
|
Public Function GetPrivateProfileMachineButtons(
|
|
ByVal lpAppName As String,
|
|
ByVal lpKeyName As String,
|
|
ByRef lpMachineButtonType As String,
|
|
ByRef lpTImageName As String,
|
|
ByRef lpTLuaScriptName As String,
|
|
ByRef lpFImageName As String,
|
|
ByRef lpFLuaScriptName As String,
|
|
ByRef lpStateFlag As String,
|
|
ByVal lpFileName As String) As Boolean
|
|
|
|
Dim sVal As String = String.Empty
|
|
GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName)
|
|
Dim sItems() As String = sVal.Split(",".ToCharArray)
|
|
If sItems.Count() >= 3 Then
|
|
lpMachineButtonType = sItems(0)
|
|
lpTImageName = sItems(1)
|
|
lpTLuaScriptName = sItems(2)
|
|
If sItems.Count() >= 4 Then
|
|
lpStateFlag = sItems(3)
|
|
If sItems.Count() >= 6 Then
|
|
lpFImageName = sItems(4)
|
|
lpFLuaScriptName = sItems(5)
|
|
End If
|
|
Else
|
|
lpStateFlag = BTN_STATE_NOTHING
|
|
End If
|
|
Return True
|
|
End If
|
|
Return False
|
|
End Function
|
|
|
|
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
#Region "EVENTS"
|
|
|
|
' qesti eventi evsnti sono generati direttamente dei bottoni di tipo "Pressed"
|
|
Private Sub PressedCommandButton_PreviewMouseUp(sender As Object, e As MouseButtonEventArgs)
|
|
Dim Button As Button = DirectCast(sender, Button)
|
|
If TypeOf Button.DataContext Is PressedCommandButton Then
|
|
Dim PressedButton As PressedCommandButton = DirectCast(Button.DataContext, PressedCommandButton)
|
|
PressedButton.OnMouseUp()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub PressedCommandButton_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
|
|
Dim Button As Button = DirectCast(sender, Button)
|
|
If TypeOf Button.DataContext Is PressedCommandButton Then
|
|
Dim PressedButton As PressedCommandButton = DirectCast(Button.DataContext, PressedCommandButton)
|
|
PressedButton.OnMouseDown()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
End Class
|
|
|
|
Public MustInherit Class MachineButton
|
|
Implements INotifyPropertyChanged
|
|
|
|
' Costanti per nomi stati dei bottoni
|
|
Friend Const BTN_STATE_SPINDLE As String = "Spindle"
|
|
Friend Const BTN_STATE_COOLANT As String = "Coolant"
|
|
Friend Const BTN_STATE_LASER As String = "Laser"
|
|
Friend Const BTN_STATE_LASERTRAC As String = "LaserTrac"
|
|
Friend Const BTN_STATE_THREEAXIS As String = "ThreeAxis"
|
|
Friend Const BTN_STATE_FIVEAXIS As String = "FiveAxis"
|
|
Friend Const BTN_STATE_NOTHING As String = "Nothing"
|
|
Friend Const BTN_ENABLE_ZONE_1 As String = "EnableZone1"
|
|
Friend Const BTN_ENABLE_ZONE_2 As String = "EnableZone2"
|
|
|
|
' Dichiarazione delle Page UserControl
|
|
Friend Shared m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)
|
|
|
|
Friend Shared m_DirectCutPage As DirectCutPageUC = m_MainWindow.m_DirectCutPageUC
|
|
Friend Shared m_CN As CN_generico = m_MainWindow.m_DirectCutPageUC.m_CN
|
|
|
|
Private m_TImageName As String
|
|
Public ReadOnly Property TImageName As String
|
|
Get
|
|
Return m_TImageName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_TLuaScriptName As String
|
|
Public ReadOnly Property TLuaScriptName As String
|
|
Get
|
|
Return m_TLuaScriptName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_FImageName As String
|
|
Public ReadOnly Property FImageName As String
|
|
Get
|
|
Return m_FImageName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_FLuaScriptName As String
|
|
Public ReadOnly Property FLuaScriptName As String
|
|
Get
|
|
Return m_FLuaScriptName
|
|
End Get
|
|
End Property
|
|
|
|
Private m_StateFlag As String
|
|
Public ReadOnly Property StateFlag As String
|
|
Get
|
|
Return m_StateFlag
|
|
End Get
|
|
End Property
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
m_TImageName = TImagePath
|
|
m_TLuaScriptName = TLuaScriptPath
|
|
m_FImageName = FImagePath
|
|
m_FLuaScriptName = FLuaScriptPath
|
|
m_StateFlag = StateFlag
|
|
End Sub
|
|
|
|
|
|
Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged
|
|
|
|
Public Sub NotifyPropertyChanged(propName As String)
|
|
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propName))
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class TwoStateButton
|
|
Inherits MachineButton
|
|
|
|
Private m_IsChecked As Boolean
|
|
Public Property IsChecked As Boolean
|
|
Get
|
|
Return m_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
' accendo il comando, anche se dovrei aspettare di leggere lo stato da PLC
|
|
m_IsChecked = value
|
|
Dim sLuaScriptFile As String = m_MainWindow.m_CurrentMachine.sMachDir & "\DirectCmd\"
|
|
If value Then
|
|
sLuaScriptFile &= TLuaScriptName
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
Else
|
|
sLuaScriptFile &= FLuaScriptName
|
|
ExecuteMDICommand(FLuaScriptName)
|
|
End If
|
|
|
|
Dim IsPressedShiftKey As Boolean = False
|
|
If (Keyboard.Modifiers And ModifierKeys.Shift) > 0 AndAlso m_MainWindow.GetDebug() > 4 Then IsPressedShiftKey = True
|
|
' procedo all'apertura del file CadCut1 appena generato (solo se generazione corretta)
|
|
If IsPressedShiftKey Then
|
|
Try
|
|
Process.Start("Notepad.exe", sLuaScriptFile)
|
|
Catch ex As Exception
|
|
EgtOutLog(ex.ToString)
|
|
End Try
|
|
End If
|
|
End Set
|
|
End Property
|
|
Friend Sub SetIsChecked(value As Boolean)
|
|
m_IsChecked = value
|
|
NotifyPropertyChanged("IsChecked")
|
|
NotifyPropertyChanged("ImageSource")
|
|
End Sub
|
|
|
|
Public ReadOnly Property ImageSource As String
|
|
Get
|
|
Dim sNewIcons As String
|
|
If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then
|
|
sNewIcons = ""
|
|
Else
|
|
sNewIcons = "NewIcons\"
|
|
End If
|
|
' Se variabile di stato "Nothing" o non collegato a CN, imposto immagine fissa
|
|
If StateFlag = BTN_STATE_NOTHING Or Not m_MainWindow.m_bNCLink Or IsNothing(FImageName) Or String.IsNullOrWhiteSpace(FImageName) Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
End If
|
|
If m_IsChecked Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
Else
|
|
' ritorno immagine dello stato false
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & FImageName
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
MyBase.New(TImagePath, TLuaScriptPath, FImagePath, FLuaScriptPath, StateFlag)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class NoStateButton
|
|
Inherits MachineButton
|
|
|
|
' definizione comandi
|
|
Private m_cmdExecute As ICommand
|
|
|
|
Public ReadOnly Property ImageSource As String
|
|
Get
|
|
Dim sNewIcons As String
|
|
If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then
|
|
sNewIcons = ""
|
|
Else
|
|
sNewIcons = "NewIcons\"
|
|
End If
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
End Get
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
MyBase.New(TImagePath, TLuaScriptPath, Nothing, Nothing, StateFlag)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Execute"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property ExecuteCommand() As ICommand
|
|
Get
|
|
If m_cmdExecute Is Nothing Then
|
|
m_cmdExecute = New Command(AddressOf Execute)
|
|
End If
|
|
Return m_cmdExecute
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Execute()
|
|
If m_MainWindow.m_CNCommunication.m_nNCType = 1 Or m_MainWindow.m_CNCommunication.m_nNCType = 2 Then
|
|
If StateFlag = K_MANUAL Then
|
|
m_CN.DGeneralFunctions_WriteCncMode(7) ' Modalità manuale
|
|
Else
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
End If
|
|
Else
|
|
' FANUC, SIEMENS
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' Execute
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class ThreeStateButton
|
|
Inherits MachineButton
|
|
|
|
' definizione comandi
|
|
Private m_cmdExecute As ICommand
|
|
|
|
Private m_Background As SolidColorBrush
|
|
Public Property Background As SolidColorBrush
|
|
Get
|
|
Return m_Background
|
|
End Get
|
|
Set(value As SolidColorBrush)
|
|
m_Background = value
|
|
NotifyPropertyChanged("Background")
|
|
End Set
|
|
End Property
|
|
Public ReadOnly Property ImageSource As String
|
|
Get
|
|
Dim sNewIcons As String
|
|
If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then
|
|
sNewIcons = ""
|
|
Else
|
|
sNewIcons = "NewIcons\"
|
|
End If
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
End Get
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
MyBase.New(TImagePath, TLuaScriptPath, FImagePath, FLuaScriptPath, StateFlag)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Execute"
|
|
|
|
' Returns a command that manage the MainWindow_Unloaded command
|
|
Public ReadOnly Property ExecuteCommand() As ICommand
|
|
Get
|
|
If m_cmdExecute Is Nothing Then
|
|
m_cmdExecute = New Command(AddressOf Execute)
|
|
End If
|
|
Return m_cmdExecute
|
|
End Get
|
|
End Property
|
|
|
|
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
|
|
Public Sub Execute()
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
ExecuteMDICommand(FLuaScriptName)
|
|
End Sub
|
|
|
|
#End Region ' Execute
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|
|
|
|
Public Class DoubleCommandButton
|
|
Inherits MachineButton
|
|
|
|
Private m_IsChecked As Boolean
|
|
Public Property IsChecked As Boolean
|
|
Get
|
|
Return m_IsChecked
|
|
End Get
|
|
Set(value As Boolean)
|
|
m_IsChecked = value
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
System.Threading.Thread.Sleep(100)
|
|
ExecuteMDICommand(FLuaScriptName)
|
|
End Set
|
|
End Property
|
|
Friend Sub SetIsChecked(value As Boolean)
|
|
m_IsChecked = value
|
|
NotifyPropertyChanged("IsChecked")
|
|
NotifyPropertyChanged("ImageSource")
|
|
End Sub
|
|
|
|
Public ReadOnly Property ImageSource As String
|
|
Get
|
|
Dim sNewIcons As String
|
|
If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then
|
|
sNewIcons = ""
|
|
Else
|
|
sNewIcons = "NewIcons\"
|
|
End If
|
|
' Se variabile di stato "Nothing" o non collegato a CN, imposto immagine fissa
|
|
If StateFlag = BTN_STATE_NOTHING Or Not m_MainWindow.m_bNCLink Or IsNothing(FImageName) Or String.IsNullOrWhiteSpace(FImageName) Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
End If
|
|
If m_IsChecked Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
Else
|
|
' ritorno immagine dello stato false
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & FImageName
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
MyBase.New(TImagePath, TLuaScriptPath, FImagePath, FLuaScriptPath, StateFlag)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|
|
|
|
Public Class PressedCommandButton
|
|
Inherits MachineButton
|
|
|
|
Private m_IsPressed As Boolean
|
|
Friend Sub SetIsPressed(value As Boolean)
|
|
m_IsPressed = value
|
|
NotifyPropertyChanged("ImageSource")
|
|
End Sub
|
|
|
|
Public ReadOnly Property ImageSource As String
|
|
Get
|
|
Dim sNewIcons As String
|
|
If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then
|
|
sNewIcons = ""
|
|
Else
|
|
sNewIcons = "NewIcons\"
|
|
End If
|
|
' Se variabile di stato "Nothing" o non collegato a CN, imposto immagine fissa
|
|
If StateFlag = BTN_STATE_NOTHING OrElse Not m_MainWindow.m_bNCLink OrElse IsNothing(FImageName) OrElse String.IsNullOrWhiteSpace(FImageName) Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
End If
|
|
If m_IsPressed Then
|
|
' ritorno immagine dello stato true
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & TImageName
|
|
Else
|
|
' ritorno immagine dello stato false
|
|
Return m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & sNewIcons & FImageName
|
|
End If
|
|
End Get
|
|
End Property
|
|
|
|
#Region "METHODS"
|
|
|
|
Sub New(TImagePath As String, TLuaScriptPath As String, FImagePath As String, FLuaScriptPath As String, StateFlag As String)
|
|
MyBase.New(TImagePath, TLuaScriptPath, FImagePath, FLuaScriptPath, StateFlag)
|
|
End Sub
|
|
|
|
Friend Sub OnMouseDown()
|
|
Try
|
|
ExecuteMDICommand(TLuaScriptName)
|
|
EgtOutLog("Comando MDI eseguito")
|
|
SetIsPressed(True)
|
|
EgtOutLog("Aggiornamento immagine bottone eseguito")
|
|
Catch ex As Exception
|
|
EgtOutLog("Eccezione riga 909 di ControlsMachineButtonUC.xaml.vb : " & ex.ToString)
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Friend Sub OnMouseUp()
|
|
Try
|
|
ExecuteMDICommand(FLuaScriptName)
|
|
EgtOutLog("Comando MDI eseguito")
|
|
SetIsPressed(False)
|
|
EgtOutLog("Aggiornamento immagine bottone eseguito")
|
|
Catch ex As Exception
|
|
EgtOutLog("Eccezione riga 925 di ControlsMachineButtonUC.xaml.vb : " & ex.ToString)
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|