Imports System.IO Imports EgtUILib Imports EgtWPFLib5 Public Class MachOptionVM Private m_sSafeZ As String Public Property SafeZ As String Get Return m_sSafeZ End Get Set(value As String) Dim dSafeZ As Double = 0 If StringToLen(value, dSafeZ) Then EgtMdbSetGeneralParam(MCH_GP.SAFEZ, dSafeZ) EgtMdbSave() m_sSafeZ = value End If End Set End Property Private m_sSafeAggrBottZ As String Public Property SafeAggrBottZ As String Get Return m_sSafeAggrBottZ End Get Set(value As String) Dim dSafeAggrBottZ As Double = 0 If StringToLen(value, dSafeAggrBottZ) Then EgtMdbSetGeneralParam(MCH_GP.SAFEAGGRBOTTZ, dSafeAggrBottZ) EgtMdbSave() m_sSafeAggrBottZ = value End If End Set End Property Private m_sHolesTolerance As String Public Property HolesTolerance As String Get Return m_sHolesTolerance End Get Set(value As String) Dim dHolesTolerance As Double = 0 If StringToLen(value, dHolesTolerance) Then EgtMdbSetGeneralParam(MCH_GP.HOLEDIAMTOLER, dHolesTolerance) EgtMdbSave() m_sHolesTolerance = value End If 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 Private m_sExtSawArcMinRad As String Public Property ExtSawArcMinRad As String Get Return m_sExtSawArcMinRad End Get Set(value As String) Dim dExtSawArcMinRad As Double = 0 If StringToLen(value, dExtSawArcMinRad) Then EgtMdbSetGeneralParam(MCH_GP.EXTSAWARCMINRAD, dExtSawArcMinRad) EgtMdbSave() m_sExtSawArcMinRad = value End If End Set End Property Private m_sIntSawArcMaxSideAng As String Public Property IntSawArcMaxSideAng As String Get Return m_sIntSawArcMaxSideAng End Get Set(value As String) Dim dIntSawArcMaxSideAng As Double = 0 If StringToLen(value, dIntSawArcMaxSideAng) Then EgtMdbSetGeneralParam(MCH_GP.INTSAWARCMAXSIDEANG, dIntSawArcMaxSideAng) EgtMdbSave() m_sIntSawArcMaxSideAng = value End If End Set End Property Private m_sApproxLinTol As String Public Property ApproxLinTol As String Get Return m_sApproxLinTol End Get Set(value As String) Dim dApproxLinTol As Double = 0 If StringToLen(value, dApproxLinTol) Then EgtMdbSetGeneralParam(MCH_GP.APPROXLINTOL, dApproxLinTol) EgtMdbSave() m_sApproxLinTol = value End If 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, 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 SafeAggrBottZMsg As String Get Return EgtMsg(MSG_MACHININGOPTIONPAGE + 8) End Get End Property Public ReadOnly Property HolesToleranceMsg As String Get Return EgtMsg(MSG_MACHININGOPTIONPAGE + 9) End Get End Property Public ReadOnly Property SplitArcsMsg As String Get Return EgtMsg(MSG_MACHININGOPTIONPAGE + 2) End Get End Property Public ReadOnly Property ExtSawArcMinRadMsg As String Get Return EgtMsg(6411) ' Minimo raggio arco esterno con lama End Get End Property Public ReadOnly Property IntSawArcMaxSideAngMsg As String Get Return EgtMsg(6412) ' Massima inclinazione arco interno con lama End Get End Property Public ReadOnly Property ApproxLinTolMsg As String Get Return EgtMsg(6410) ' Tolleranza di approssimazione End Get End Property Public ReadOnly Property DefaultSetUpMsg As String Get Return EgtMsg(MSG_MACHININGOPTIONPAGE + 7) 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_sSafeZ = LenToString(dVal, 2) ' Leggo distanza di sicurezza per rinvii da sotto dVal = 0 EgtMdbGetGeneralParam(MCH_GP.SAFEAGGRBOTTZ, dVal) m_sSafeAggrBottZ = LenToString(dVal, 2) ' Leggo tolleranza tra diametro punta e diametro foro dVal = 0 EgtMdbGetGeneralParam(MCH_GP.HOLEDIAMTOLER, dVal) m_sHolesTolerance = LenToString(dVal, 2) ' Leggo tipo di spezzatura archi Dim nVal As Integer = 0 EgtMdbGetGeneralParam(MCH_GP.SPLITARCS, nVal) m_SelectedSplitArcs = DirectCast(nVal, MCH_SA) ' Leggo minimo raggio arco esterno lavorabile con lama dVal = 0 EgtMdbGetGeneralParam(MCH_GP.EXTSAWARCMINRAD, dVal) m_sExtSawArcMinRad = LenToString(dVal, 4) ' Leggo massima inclinazione lama per lavorare archi interni dVal = 0 EgtMdbGetGeneralParam(MCH_GP.INTSAWARCMAXSIDEANG, dVal) m_sIntSawArcMaxSideAng = LenToString(dVal, 4) ' Leggo tolleranza lineare di approssimazione dVal = 0 EgtMdbGetGeneralParam(MCH_GP.APPROXLINTOL, dVal) m_sApproxLinTol = LenToString(dVal, 4) ' Riempio lista attrezzaggi salvati m_ArchivedSetUpList.Add(String.Empty) If Directory.Exists(IniFile.m_sCurrMachSetUpDirPath) Then 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 End If ' Leggo attrezzaggio predefinito If EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", MachOptionModule.m_sSelectedDefaultSetUp, IniFile.m_sCurrMachIniFilePath) <= 0 Then SelectedDefaultSetUp = Nothing Else If Not m_ArchivedSetUpList.Contains(MachOptionModule.m_sSelectedDefaultSetUp) Then SelectedDefaultSetUp = Nothing End If End If End Sub #Region "Visibility" Public ReadOnly Property StoneVisibility As Visibility Get Dim sGenMat As String = "" EgtUILib.GetPrivateProfileString(S_MCH_GENERAL, K_MATERIAL, MCH_MAT_WOOD, sGenMat, IniFile.m_sCurrMachIniFilePath) Return If( sGenMat = MCH_MAT_STONE, Visibility.Visible, Visibility.Collapsed) End Get End Property #End Region #Region "COMMANDS" #Region "CloseMachOptionsCommand" ''' ''' Returns a command that remove the current selected machining. ''' 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 ''' ''' Manage the MachiningDb closing. This method is invoked by the CloseMachiningDbCommand. ''' Public Sub CloseMachOptions() ' Chiusura finestra For Each Window In Application.Current.Windows If TypeOf Window Is MachOptionV Then Dim MachOptionsWindow As MachOptionV = DirectCast(Window, MachOptionV) MachOptionsWindow.Close() End If Next End Sub #End Region ' CloseMachOptionsCommand #End Region ' COMMANDS End Class 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