From e1897e68b0ffedaef99d9c4468a5a7ef0e391c27 Mon Sep 17 00:00:00 2001 From: NicolaP Date: Tue, 15 Feb 2022 18:11:26 +0100 Subject: [PATCH] Aggiunta configurazione TableUp/Down per AreaCut --- DirectCuts/ControlsMachineButtonUC.xaml.vb | 33 +++++++++++ DirectCuts/MachineButtonsUC.xaml.vb | 68 ++++++++++++++++++++++ NcComm/CNCommunication.vb | 5 ++ 3 files changed, 106 insertions(+) diff --git a/DirectCuts/ControlsMachineButtonUC.xaml.vb b/DirectCuts/ControlsMachineButtonUC.xaml.vb index 0f12aac..f2ad643 100644 --- a/DirectCuts/ControlsMachineButtonUC.xaml.vb +++ b/DirectCuts/ControlsMachineButtonUC.xaml.vb @@ -342,6 +342,37 @@ Public Class ControlsMachineButtonUC End If End Sub + Friend Sub ZoneStateChanged(ZoneState As Integer) + 'Dim sFlag As String = String.Empty + 'If ZoneState = 1 Then + ' sFlag = BTN_ENABLE_ZONE_1 + 'ElseIf ZoneState = 2 Then + ' sFlag = BTN_ENABLE_ZONE_2 + 'End If + 'Dim EnableZoneButton As TwoStateButton = Nothing + 'For Each MachineButton As MachineButton In m_ButtonList + ' If MachineButton.StateFlag = K_ENABLEZONE Then + ' EnableZoneButton = MachineButton + ' End If + 'Next + 'If Not IsNothing(EnableZoneButton) Then + ' EnableZoneButton.SetIsChecked(EnableZone) + 'End If + End Sub + + Friend Sub PcStateChanged(EnablePC As Boolean) + 'Dim EnablePCButton As TwoStateButton = Nothing + 'For Each MachineButton As MachineButton In m_ButtonList + ' If MachineButton.StateFlag = K_ENABLEPC Then + ' EnablePCButton = MachineButton + ' End If + 'Next + 'If Not IsNothing(EnablePCButton) Then + ' EnablePCButton.SetIsChecked(EnablePC) + 'End If + End Sub + + Public Function GetPrivateProfileMachineButtons( ByVal lpAppName As String, ByVal lpKeyName As String, @@ -414,6 +445,8 @@ Public MustInherit Class MachineButton 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) diff --git a/DirectCuts/MachineButtonsUC.xaml.vb b/DirectCuts/MachineButtonsUC.xaml.vb index e0edfc0..a543db5 100644 --- a/DirectCuts/MachineButtonsUC.xaml.vb +++ b/DirectCuts/MachineButtonsUC.xaml.vb @@ -735,6 +735,74 @@ Public Class MachineButtonsUC End If End Sub + Friend Sub TableUpChanged(TableUpState As Boolean) + Dim nIndex As Integer = Array.IndexOf(StateFlagArray, K_TABLEUP) + If nIndex = -1 Then Return + If TableUpState Then + GetToggleButton(nIndex + 1).IsChecked = True + Try + Dim s As String + If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & ImageArrayY(nIndex) + Else + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\NewIcons\" & ImageArrayY(nIndex) + End If + Dim sButtonImageSource As ImageSource = ImageConverter.ConvertFromString(s) + GetImage(nIndex + 1).Source = sButtonImageSource + Catch ex As Exception + EgtOutLog("Error loading image " & ImageArrayY(nIndex + 1)) + End Try + Else + GetToggleButton(nIndex + 1).IsChecked = False + Try + Dim s As String + If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & ImageArrayN(nIndex) + Else + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\NewIcons\" & ImageArrayN(nIndex) + End If + Dim sButtonImageSource As ImageSource = ImageConverter.ConvertFromString(s) + GetImage(nIndex + 1).Source = sButtonImageSource + Catch ex As Exception + EgtOutLog("Error loading image " & ImageArrayN(nIndex + 1)) + End Try + End If + End Sub + + Friend Sub TableDownChanged(TableDownState As Boolean) + Dim nIndex As Integer = Array.IndexOf(StateFlagArray, K_TABLEDOWN) + If nIndex = -1 Then Return + If TableDownState Then + GetToggleButton(nIndex + 1).IsChecked = True + Try + Dim s As String + If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & ImageArrayY(nIndex) + Else + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\NewIcons\" & ImageArrayY(nIndex) + End If + Dim sButtonImageSource As ImageSource = ImageConverter.ConvertFromString(s) + GetImage(nIndex + 1).Source = sButtonImageSource + Catch ex As Exception + EgtOutLog("Error loading image " & ImageArrayY(nIndex + 1)) + End Try + Else + GetToggleButton(nIndex + 1).IsChecked = False + Try + Dim s As String + If (m_MainWindow.m_OptionsPageUC.ThemesCmBx.SelectedIndex = 0) Then + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\" & ImageArrayN(nIndex) + Else + s = m_MainWindow.GetResourcesDir() & "\MachineButtonsImage\NewIcons\" & ImageArrayN(nIndex) + End If + Dim sButtonImageSource As ImageSource = ImageConverter.ConvertFromString(s) + GetImage(nIndex + 1).Source = sButtonImageSource + Catch ex As Exception + EgtOutLog("Error loading image " & ImageArrayN(nIndex + 1)) + End Try + End If + End Sub + '----------------- Queste funzioni determina lo stato del bottone direttamente dalla lettura delle variabili CN Friend Sub XYJogChanged(ByVal bXYAxes As Boolean) ' recupero le asscociazioni con i bottoni diff --git a/NcComm/CNCommunication.vb b/NcComm/CNCommunication.vb index 80272bd..5c1eb39 100644 --- a/NcComm/CNCommunication.vb +++ b/NcComm/CNCommunication.vb @@ -549,6 +549,7 @@ Public Class CNCommunication m_MainWindow.m_DirectCutPageUC.m_ControlsMachineButton.FiveAxisStateChanged(m_CN.Is_G24_active()) m_MainWindow.m_DirectCutPageUC.m_ControlsMachineButton.ParkingStateChanged(m_CN.bParkingState) 'm_MainWindow.m_DirectCutPageUC.m_ControlsMachineButton.ZoneStateChanged(m_CN.nEnableZone) + 'm_MainWindow.m_DirectCutPageUC.m_ControlsMachineButton.PcStateChanged(m_CN.nEnablePc) m_MainWindow.m_DirectCutPageUC.m_VacuumMachineButton.VacuumUpChanged(m_CN.bVacuumUp) m_MainWindow.m_DirectCutPageUC.m_VacuumMachineButton.VacuumDownChanged(m_CN.bVacuumDown) m_MainWindow.m_DirectCutPageUC.m_VacuumMachineButton.Vacuum2UpChanged(m_CN.bVacuum2Up) @@ -597,6 +598,8 @@ Public Class CNCommunication m_MainWindow.m_DirectCutPageUC.m_MachineButtons.ParkingStateChanged(m_CN.bParkingState) m_MainWindow.m_DirectCutPageUC.m_MachineButtons.EnableZoneStateChanged(m_CN.nEnableZone) m_MainWindow.m_DirectCutPageUC.m_MachineButtons.EnablePcStateChanged(m_CN.nEnablePc) + m_MainWindow.m_DirectCutPageUC.m_MachineButtons.TableUpChanged(m_CN.bTableUpState) + m_MainWindow.m_DirectCutPageUC.m_MachineButtons.TableDownChanged(m_CN.bTableDownState) ' Nuovi bottoni (uso joystick) per Area4 If m_IsNewConsole Then @@ -635,6 +638,8 @@ Public Class CNCommunication m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.ParkingStateChanged(m_CN.bParkingState) m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.EnableZoneStateChanged(m_CN.nEnableZone) m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.EnablePcStateChanged(m_CN.nEnablePc) + m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.TableUpChanged(m_CN.bTableUpState) + m_MainWindow.m_WorkInProgressPageUC.m_MachineButtons.TableDownChanged(m_CN.bTableDownState) End If End Sub