Imports System.Collections.ObjectModel Imports System.IO Imports EgtUILib Public Class MachOptionWindowVM Inherits VMBase #Region "FIELDS & PROPERTIES" #Region "Holes Param" Private m_ArchivedSetUpList As New List(Of String) Public Property ArchivedSetUpList As List(Of String) Get Return m_ArchivedSetUpList End Get Set(value As List(Of String)) m_ArchivedSetUpList = value End Set End Property ' Parametro che indica quale è l'attrezzaggio di default correntemente selezionato Friend m_sSelectedDefaultSetUp As String Public Property SelectedDefaultSetUp As String Get Return m_sSelectedDefaultSetUp End Get Set(value As String) m_sSelectedDefaultSetUp = value EgtUILib.WritePrivateProfileString(S_SETUP, K_DEFAULT, If(Not IsNothing(value), value, String.Empty), CurrentMachine.sMachIniFile) End Set End Property Public Property HolesOffset As String Get Return LenToString(CurrentMachine.dHolesOffset, 2) End Get Set(value As String) Dim dHolesOffset As Double = 0 If StringToLen(value, dHolesOffset) Then CurrentMachine.dHolesOffset = dHolesOffset End If End Set End Property Public Property HolesOverlap As String Get Return LenToString(CurrentMachine.dHolesOverlap, 2) End Get Set(value As String) Dim dHolesOverlap As Double = 0 If StringToLen(value, dHolesOverlap) Then CurrentMachine.dHolesOverlap = dHolesOverlap End If End Set End Property Public Property HolesTolerance As String Get Return LenToString(CurrentMachine.dHolesTolerance, 2) End Get Set(value As String) Dim dHolesTolerance As Double = 0 If StringToLen(value, dHolesTolerance) Then CurrentMachine.dHolesTolerance = dHolesTolerance End If End Set End Property Public Property OneHoleInCorner As Boolean Get Return CurrentMachine.bOneHoleInCorner End Get Set(value As Boolean) CurrentMachine.bOneHoleInCorner = value End Set End Property #End Region ' Holes Param #Region "Saw Param" Public Property CutExtraLen As String Get Return LenToString(CurrentMachine.dCutExtraLen, 2) End Get Set(value As String) Dim dCutExtraLen As Double = 0 If StringToLen(value, dCutExtraLen) Then CurrentMachine.dCutExtraLen = dCutExtraLen End If End Set End Property Public Property AngleCutExtraLen As String Get Return LenToString(CurrentMachine.dAngleCutExtraLen, 2) End Get Set(value As String) Dim dAngleCutExtraLen As Double = 0 If StringToLen(value, dAngleCutExtraLen) Then CurrentMachine.dAngleCutExtraLen = dAngleCutExtraLen End If End Set End Property Public Property ExtArcMinRad As String Get Return LenToString(CurrentMachine.dExtArcMinRad, 2) End Get Set(value As String) Dim dExtArcMinRad As Double = 0 If StringToLen(value, dExtArcMinRad) Then CurrentMachine.dExtArcMinRad = dExtArcMinRad End If End Set End Property Public Property IntArcMaxSideAng As String Get Return DoubleToString(CurrentMachine.dIntArcMaxSideAng, 2) End Get Set(value As String) Dim dIntArcMaxSideAng As Double = 0 If StringToDouble(value, dIntArcMaxSideAng) Then CurrentMachine.dIntArcMaxSideAng = dIntArcMaxSideAng End If End Set End Property Public ReadOnly Property PreCutExitVisibility As Visibility Get Return CurrentMachine.vPreCutExitVisibility End Get End Property Public Property PreCutExit As Boolean Get Return CurrentMachine.bPreCutExit End Get Set(value As Boolean) CurrentMachine.bPreCutExit = value End Set End Property Public ReadOnly Property SawParam_Visibility As Visibility Get ' in assenza dell'uscita H1 nascondo i parametri lama If EgtGetHeadId("H1") = GDB_ID.NULL Then Return Visibility.Hidden Else Return Visibility.Visible End If End Get End Property #End Region ' Saw Param #Region "Machine Param" Public Property SafeZ As String Get Return LenToString(CurrentMachine.dSafeZ, 2) End Get Set(value As String) Dim dSafeZ As Double = 0 If StringToLen(value, dSafeZ) Then CurrentMachine.dSafeZ = dSafeZ End If End Set End Property #End Region ' Machine Param #Region "Milling Param" Public Property CornerCuts As Boolean Get Return CurrentMachine.bCornerCuts End Get Set(value As Boolean) CurrentMachine.bCornerCuts = value End Set End Property Public Property InternalCuts As Boolean Get Return CurrentMachine.bInternalCuts End Get Set(value As Boolean) CurrentMachine.bInternalCuts = value End Set End Property Public Property ShortCut As String Get Return LenToString(CurrentMachine.dShortCut, 2) End Get Set(value As String) Dim dShortCut As Double = 0 If StringToLen(value, dShortCut) Then CurrentMachine.dShortCut = dShortCut End If End Set End Property Public ReadOnly Property MillingParam_Visibility As Visibility Get If bWaterJet Then Return Visibility.Hidden Else Return Visibility.Visible End If End Get End Property #End Region ' Milling Param #Region "Nesting Param" Public Property CompleteCuts As Boolean Get Return Not CurrentMachine.bReducedCut End Get Set(value As Boolean) If value Then ' Se pezzi in interferenza If Not EstCalc.VerifyPartsNesting(False) Then ' Ci sono interferenze, alcuni pezzi saranno parcheggiati. Vuoi continuare ? If MessageBox.Show(EgtMsg(91105), "", MessageBoxButton.OKCancel, MessageBoxImage.Question) = MessageBoxResult.OK Then EstCalc.StoreCollisionParts(False) CurrentMachine.bReducedCut = False EgtDraw() End If Else CurrentMachine.bReducedCut = False End If Else CurrentMachine.bReducedCut = True End If EstCalc.SetReducedCut(CurrentMachine.bReducedCut) End Set End Property Public Property Aligned As Boolean Get Return CurrentMachine.bAligned End Get Set(value As Boolean) CurrentMachine.bAligned = value End Set End Property Public Property Guillotine As Boolean Get Return CurrentMachine.bGuillotine End Get Set(value As Boolean) CurrentMachine.bGuillotine = value End Set End Property Public ReadOnly Property GuillotineVisibility As Visibility Get If CurrentMachine.bAutomatic Then Return Visibility.Visible Else Return Visibility.Collapsed End If End Get End Property Public Property Automatic As Boolean Get Return CurrentMachine.bAutomatic End Get Set(value As Boolean) CurrentMachine.bAutomatic = value NotifyPropertyChanged("GuillotineVisibility") End Set End Property #End Region ' Nesting Param Public Property AdditionalTable As String Get Return LenToString(CurrentMachine.dAdditionalTable, 2) End Get Set(value As String) Dim dAdditionalTable As Double = 0 If StringToLen(value, dAdditionalTable) Then CurrentMachine.dAdditionalTable = dAdditionalTable EgtDraw() End If End Set End Property Public ReadOnly Property SacProbeVisibility As Visibility Get Return If( CurrentMachine.nSacProbe >= 0, Visibility.Visible, Visibility.Hidden) End Get End Property Public Property SacProbe As Boolean Get Return EstCalc.GetSideAngCutProbeFlag() End Get Set(value As Boolean) CurrentMachine.nSacProbe = If( value, 1, 0) EstCalc.SetSideAngCutProbeFlag(value) End Set End Property Public ReadOnly Property WashingVisibility As Visibility Get Return Visibility.Visible End Get End Property Public Property Washing As Boolean Get Return EstCalc.GetWashingFlag() End Get Set(value As Boolean) CurrentMachine.nWashing = If( value, 1, 0) EstCalc.SetWashingFlag(value) End Set End Property #Region "Material" Public ReadOnly Property MaterialList As ObservableCollection(Of Material) Get Return CurrentMachine.Materials End Get End Property Private m_SelMaterial As Material Public Property SelMaterial As Material Get Return m_SelMaterial End Get Set(value As Material) m_SelMaterial = value End Set End Property Private m_NewMatName As String Public Property NewMatName As String Get Return m_NewMatName End Get Set(value As String) m_NewMatName = value ' Verifico che il nome non sia vuoto AddNewMaterial() NotifyPropertyChanged("EnableOkNewMat") End Set End Property Private Function AddNewMaterial() As Boolean If Not String.IsNullOrWhiteSpace(m_NewMatName) Then ' Verifico che il nome non sia già utilizzato Dim bNameExist As Boolean = False For Each Material In MaterialList If Material.sName = m_NewMatName Then bNameExist = True Exit For End If Next If Not bNameExist Then 'm_MaterialList.Add(m_NewMatName) m_EnableOkNewMat = True Return True End If End If ' ' Nascondo textbox per il nome ' NewMatName_Visibility = Visibility.Collapsed ' m_NewMatName = String.Empty m_EnableOkNewMat = False Return False End Function Private m_EnableOkNewMat As Boolean = False Public Property EnableOkNewMat As Boolean Get Return m_EnableOkNewMat End Get Set(value As Boolean) m_EnableOkNewMat = value End Set End Property Private m_NewMatName_Visibility As Visibility = Visibility.Collapsed Public Property NewMatName_Visibility As Visibility Get Return m_NewMatName_Visibility End Get Set(value As Visibility) m_NewMatName_Visibility = value NotifyPropertyChanged("NewMatName_Visibility") End Set End Property Public ReadOnly Property Materials_Visibility As Visibility Get Return If(CurrentMachine.bWaterJet, Visibility.Collapsed, Visibility.Visible) End Get End Property #End Region ' Material ' Definizione comandi Private m_cmdNewMat As ICommand Private m_cmdRemoveMat As ICommand Private m_cmdOk As ICommand Private m_cmdCanel As ICommand #Region "Messages" Public ReadOnly Property TitleMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 19) End Get End Property Public ReadOnly Property SetUpMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 43) End Get End Property Public ReadOnly Property HolesMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 17) End Get End Property Public ReadOnly Property HolesOffsetMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 9) End Get End Property Public ReadOnly Property HolesOverlapMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 10) End Get End Property Public ReadOnly Property HolesToleranceMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 11) End Get End Property Public ReadOnly Property OneHoleInCornerMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 26) End Get End Property Public ReadOnly Property MaterialsMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 13) End Get End Property Public ReadOnly Property SawParamMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 25) End Get End Property Public ReadOnly Property CutExtraLenMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 6) End Get End Property Public ReadOnly Property AngleCutExtraLenMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 7) End Get End Property Public ReadOnly Property ExtArcMinRadMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 18) End Get End Property Public ReadOnly Property IntArcMaxSideAngMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 24) End Get End Property Public ReadOnly Property MachineParamMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 19) End Get End Property Public ReadOnly Property SafeZMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 5) End Get End Property Public ReadOnly Property MillingParamMsg As String Get If bWaterJet Then Return EgtMsg(91058) Else Return EgtMsg(MSG_ALARMSPAGEUC + 29) End If End Get End Property Public ReadOnly Property CornerCutsMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 44) End Get End Property Public ReadOnly Property ShortMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 49) End Get End Property Public ReadOnly Property InternalCutsMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 30) End Get End Property Public ReadOnly Property NestingParamMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 31) End Get End Property Public ReadOnly Property CompleteCutsMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 8) End Get End Property Public ReadOnly Property AlignMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 32) End Get End Property Public ReadOnly Property GuillotineMsg As String Get Return EgtMsg(91066) End Get End Property Public ReadOnly Property AutomaticMsg As String Get Return EgtMsg(91059) End Get End Property Public ReadOnly Property AdditionalTableMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 36) End Get End Property Public ReadOnly Property SacProbeMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 50) End Get End Property Public ReadOnly Property WashingMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 41) End Get End Property Public ReadOnly Property NewMatMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 34) End Get End Property Public ReadOnly Property RemoveMatMsg As String Get Return EgtMsg(MSG_ALARMSPAGEUC + 35) End Get End Property Public ReadOnly Property PreCutExitMsg As String Get Return EgtMsg(91065) End Get End Property Public ReadOnly Property OkMsg As String Get Return EgtMsg(91651) ' Ok End Get End Property Public ReadOnly Property CancelMsg As String Get Return EgtMsg(91652) ' Cancel End Get End Property #End Region ' Messages #Region "ToolTip" 'Public ReadOnly Property ToolDBToolTip As String ' Get ' Return "Tool DB" ' End Get 'End Property 'Public ReadOnly Property MachiningDbToolTip As String ' Get ' Return "Machining DB" ' End Get 'End Property #End Region ' ToolTip #End Region 'FIELDS & PROPERTIES #Region "CONSTRUCTOR" Sub New() ' Riempio lista attrezzaggi salvati m_ArchivedSetUpList.Add(String.Empty) If Directory.Exists(CurrentMachine.sMachDir & "\SetUp") Then Dim SetUpFileNames() As String = Directory.GetFiles(CurrentMachine.sMachDir & "\SetUp") For FileIndex = 0 To SetUpFileNames.Count - 1 If Path.GetExtension(SetUpFileNames(FileIndex)).ToLower = ".stu" Then m_ArchivedSetUpList.Add(Path.GetFileNameWithoutExtension(SetUpFileNames(FileIndex))) End If Next End If ' Leggo attrezzaggio predefinito If EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", m_sSelectedDefaultSetUp, CurrentMachine.sMachIniFile) <= 0 Then SelectedDefaultSetUp = Nothing Else If Not m_ArchivedSetUpList.Contains(m_sSelectedDefaultSetUp) Then SelectedDefaultSetUp = Nothing End If End If NotifyPropertyChanged("PreCutExitVisibility") End Sub #End Region ' CONSTRUCTOR #Region "METHODS" #End Region #Region "COMMANDS" #Region "NewMatCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property NewMatCommand As ICommand Get If m_cmdNewMat Is Nothing Then m_cmdNewMat = New Command(AddressOf NewMat) End If Return m_cmdNewMat End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub NewMat(ByVal param As Object) NewMatName_Visibility = Visibility.Visible End Sub #End Region ' NewMatCommand #Region "RemoveMatCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property RemoveMatCommand As ICommand Get If m_cmdRemoveMat Is Nothing Then m_cmdRemoveMat = New Command(AddressOf RemoveMat) End If Return m_cmdRemoveMat End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub RemoveMat(ByVal param As Object) If Not IsNothing(SelMaterial) Then If MessageBox.Show(EgtMsg(MSG_ALARMSPAGEUC + 42), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then CurrentMachine.RemoveMaterial(SelMaterial) End If End If End Sub #End Region ' RemoveMatCommand #Region "OkCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property OkCommand As ICommand Get If m_cmdOk Is Nothing Then m_cmdOk = New Command(AddressOf OkMat) End If Return m_cmdOk End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub OkMat(ByVal param As Object) ' aggiungo il materiale alla lista Dim objNewMat As New Material(m_NewMatName, CurrentMachine.Materials) If Not IsNothing(objNewMat) Then CurrentMachine.Materials.Add(objNewMat) End If ' Nascondo textbox per il nome NewMatName_Visibility = Visibility.Collapsed m_NewMatName = String.Empty NotifyPropertyChanged("NewMatName") End Sub #End Region ' OkCommand #Region "CancelCommand" ''' ''' Returns a command that do Exec. ''' Public ReadOnly Property CamcelCommand As ICommand Get If m_cmdCanel Is Nothing Then m_cmdCanel = New Command(AddressOf CancelMat) End If Return m_cmdCanel End Get End Property ''' ''' Execute the Exec. This method is invoked by the ExecCommand. ''' Public Sub CancelMat(ByVal param As Object) ' Nascondo textbox per il nome NewMatName_Visibility = Visibility.Collapsed m_NewMatName = String.Empty NotifyPropertyChanged("NewMatName") End Sub #End Region ' CancelCommand #End Region ' COMMANDS End Class