Files
omagoffice/MachOptionWindow/MachOptionWindowVM.vb
T
Dario Sassi 52a3cc910e OmagOffice 2.1e4 :
- gestione ventose con rotazione a step come in OmagCUT
- gestione angoli di lato e talloni da colori di DXF come in OmagCUT
- gestione flag tastatura su tagli con angoli di fianco come in OmagCUT
- impostata a Hidden regione di Kerf per Vacuum come in OmagCUT.
2019-06-04 18:26:00 +00:00

569 lines
16 KiB
VB.net

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
#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
#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
#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
If Not String.IsNullOrWhiteSpace(m_NewMatName) Then
' Verifico che il nome non sia già utilizzato
Dim bNameExist As Boolean = False
For Each Material In CurrentMachine.Materials
If Material.sName = m_NewMatName Then
bNameExist = True
Exit For
End If
Next
If Not bNameExist Then
CurrentMachine.AddMaterial(New Material(m_NewMatName, CurrentMachine.Materials))
End If
End If
' Nascondo textbox per il nome
NewMatName_Visibility = Visibility.Collapsed
m_NewMatName = String.Empty
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
#End Region ' Material
' Definizione comandi
Private m_cmdNewMat As ICommand
Private m_cmdRemoveMat 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
Return EgtMsg(MSG_ALARMSPAGEUC + 29)
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 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
#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
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
#End Region
#Region "COMMANDS"
#Region "NewMatCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
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
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
Public Sub NewMat(ByVal param As Object)
NewMatName_Visibility = Visibility.Visible
End Sub
#End Region ' NewMatCommand
#Region "RemoveMatCommand"
''' <summary>
''' Returns a command that do Exec.
''' </summary>
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
''' <summary>
''' Execute the Exec. This method is invoked by the ExecCommand.
''' </summary>
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
#End Region ' COMMANDS
End Class