Files
EgtCAM5/MachOptionsWindow/MachOptionsViewModel.vb
T
Emmanuele Sassi dffe9de64e EgtCAM5 :
- Migliorie SetUp.
- Migliorie simulazione.
2017-01-27 18:33:56 +00:00

180 lines
6.2 KiB
VB.net

Imports System.IO
Imports EgtUILib
Namespace EgtCAM5
Public Class MachOptionsViewModel
Private m_dSafeZ As String
Public Property SafeZ As String
Get
Return m_dSafeZ
End Get
Set(value As String)
Dim dSafeZ As Double = 0
StringToLen(value, dSafeZ)
EgtMdbSetGeneralParam(MCH_GP.SAFEZ, dSafeZ)
EgtMdbSave()
m_dSafeZ = value
End Set
End Property
Private m_SplitArcsList As New List(Of MCH_SA)({MCH_SA.NEVER, MCH_SA.GEN_PLANE, MCH_SA.NO_XY_PLANE, MCH_SA.ALWAYS})
Public ReadOnly Property SplitArcsList As List(Of MCH_SA)
Get
Return m_SplitArcsList
End Get
End Property
Private m_SelectedSplitArcs As MCH_SA
Public Property SelectedSplitArcs As MCH_SA
Get
Return m_SelectedSplitArcs
End Get
Set(value As MCH_SA)
EgtMdbSetGeneralParam(MCH_GP.SPLITARCS, value)
EgtMdbSave()
m_SelectedSplitArcs = value
End Set
End Property
Public Property IsActiveDefaultSetUp As Boolean
Get
Return MachOptionModule.m_bIsActiveDefaultSetUp
End Get
Set(value As Boolean)
MachOptionModule.m_bIsActiveDefaultSetUp = value
EgtUILib.WritePrivateProfileString(S_SETUP, K_ACTIVEDEFAULT, If(value, 1, 0).ToString, IniFile.m_sCurrMachIniFilePath)
End Set
End Property
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
Public Property SelectedDefaultSetUp As String
Get
Return MachOptionModule.m_sSelectedDefaultSetUp
End Get
Set(value As String)
MachOptionModule.m_sSelectedDefaultSetUp = value
EgtUILib.WritePrivateProfileString(S_SETUP, K_DEFAULT, If(Not IsNothing(value), value & ".stu", String.Empty), IniFile.m_sCurrMachIniFilePath)
End Set
End Property
#Region "Messages"
Public ReadOnly Property SafeZMsg As String
Get
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 1)
End Get
End Property
Public ReadOnly Property SplitArcsMsg As String
Get
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 2)
End Get
End Property
Public ReadOnly Property ActivateDefaultSetUpMsg As String
Get
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 7)
End Get
End Property
Public ReadOnly Property DefaultSetUpMsg As String
Get
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 8)
End Get
End Property
#End Region
' Definizione comandi
Private m_cmdCloseMachOptions As ICommand
Sub New()
' Leggo distanza di sicurezza
Dim dVal As Double = 0
EgtMdbGetGeneralParam(MCH_GP.SAFEZ, dVal)
m_dSafeZ = LenToString(dVal, 2)
' Leggo tipo di spezzatura archi
Dim nVal As Integer = 0
EgtMdbGetGeneralParam(MCH_GP.SPLITARCS, nVal)
m_SelectedSplitArcs = DirectCast(nVal, MCH_SA)
' Riempio lista attrezzaggi salvati
Dim SetUpFileNames() As String = Directory.GetFiles(IniFile.m_sCurrMachSetUpDirPath)
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
' Leggo se attivo attrezzaggio predefinito
m_bIsActiveDefaultSetUp = EgtUILib.GetPrivateProfileInt(S_SETUP, K_ACTIVEDEFAULT, 0, IniFile.m_sCurrMachIniFilePath) <> 0
' Leggo attrezzaggio predefinito
If EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", m_sSelectedDefaultSetUp, IniFile.m_sCurrMachIniFilePath) <= 0 Then
m_sSelectedDefaultSetUp = Nothing
End If
End Sub
#Region "COMMANDS"
#Region "CloseMachOptionsCommand"
''' <summary>
''' Returns a command that remove the current selected machining.
''' </summary>
Public ReadOnly Property CloseMachOptionsCommand() As ICommand
Get
If m_cmdCloseMachOptions Is Nothing Then
m_cmdCloseMachOptions = New RelayCommand(AddressOf CloseMachOptions)
End If
Return m_cmdCloseMachOptions
End Get
End Property
''' <summary>
''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand.
''' </summary>
Public Sub CloseMachOptions()
' Chiusura finestra
For Each Window In Application.Current.Windows
If TypeOf Window Is MachOptionsView Then
Dim MachOptionsWindow As MachOptionsView = DirectCast(Window, MachOptionsView)
MachOptionsWindow.Close()
End If
Next
End Sub
#End Region ' CloseMachOptionsCommand
#End Region ' COMMANDS
End Class
End Namespace
Public Class SplitArcTypeConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
Select Case CInt(value)
Case MCH_SA.NEVER
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 3)
Case MCH_SA.GEN_PLANE
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 4)
Case MCH_SA.NO_XY_PLANE
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 5)
Case Else
Return EgtMsg(MSG_MACHININGOPTIONPAGE + 6)
End Select
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException
End Function
End Class