1213 lines
41 KiB
VB.net
1213 lines
41 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports System.Text.RegularExpressions
|
|
Imports EgtUILib
|
|
|
|
Public Class WaterjetDbWindowVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Bottone premuto nella finestra di richiesta salvataggio
|
|
Public Enum SaveWndBtnEnum As Integer
|
|
CANCEL
|
|
YES
|
|
NO
|
|
End Enum
|
|
|
|
Private Property m_MachDir As String
|
|
Public ReadOnly Property MachDir As String
|
|
Get
|
|
Return m_MachDir
|
|
End Get
|
|
End Property
|
|
|
|
Private Property m_MaterialList As ObservableCollection(Of WjMaterial)
|
|
Public Property MaterialList As ObservableCollection(Of WjMaterial)
|
|
Get
|
|
Return m_MaterialList
|
|
End Get
|
|
Set(value As ObservableCollection(Of WjMaterial))
|
|
m_MaterialList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_SelMaterial As WjMaterial
|
|
Public Property SelMaterial As WjMaterial
|
|
Get
|
|
Return m_SelMaterial
|
|
End Get
|
|
Set(value As WjMaterial)
|
|
m_SelMaterial = value
|
|
' Seleziono il primo Sottomateriale della lista, se esiste
|
|
If Not IsNothing(m_SelMaterial) AndAlso Not IsNothing(m_SelMaterial.SubMaterialList) AndAlso m_SelMaterial.SubMaterialList.Count > 0 Then
|
|
m_SelMaterial.SelSubMaterial = m_SelMaterial.SubMaterialList(0)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_SubMaterialList As New ObservableCollection(Of WjSubMaterial)
|
|
Public Property SubMaterialList As ObservableCollection(Of WjSubMaterial)
|
|
Get
|
|
Return m_SubMaterialList
|
|
End Get
|
|
Set(value As ObservableCollection(Of WjSubMaterial))
|
|
m_SubMaterialList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_SelSubMaterial As WjSubMaterial
|
|
Public Property SelSubMaterial As WjSubMaterial
|
|
Get
|
|
Return m_SelSubMaterial
|
|
End Get
|
|
Set(value As WjSubMaterial)
|
|
m_SelSubMaterial = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_ParamList As ObservableCollection(Of WjParam)
|
|
Public Property ParamList As ObservableCollection(Of WjParam)
|
|
Get
|
|
Return m_ParamList
|
|
End Get
|
|
Set(value As ObservableCollection(Of WjParam))
|
|
m_ParamList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_sNewMaterial As String
|
|
Public Property sNewMaterial As String
|
|
Get
|
|
Return m_sNewMaterial
|
|
End Get
|
|
Set(value As String)
|
|
m_sNewMaterial = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_sNewSubMaterial As String
|
|
Public Property sNewSubMaterial As String
|
|
Get
|
|
Return m_sNewSubMaterial
|
|
End Get
|
|
Set(value As String)
|
|
m_sNewSubMaterial = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_NewMaterial_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property NewMaterial_Visibility As Visibility
|
|
Get
|
|
Return m_NewMaterial_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_NewMaterial_Visibility = value
|
|
NotifyPropertyChanged(NameOf(NewMaterial_Visibility))
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_NewSubMaterial_Visibility As Visibility = Visibility.Collapsed
|
|
Public Property NewSubMaterial_Visibility As Visibility
|
|
Get
|
|
Return m_NewSubMaterial_Visibility
|
|
End Get
|
|
Set(value As Visibility)
|
|
m_NewSubMaterial_Visibility = value
|
|
NotifyPropertyChanged(NameOf(NewSubMaterial_Visibility))
|
|
End Set
|
|
End Property
|
|
|
|
Public Const WATERJETDB_PATH = "\Machinings\WaterjetDb.data"
|
|
Public Const S_MATERIALS = "Materials"
|
|
|
|
Public Event m_CloseWindow(bDialogResult As Boolean)
|
|
|
|
' flag per differenziare Nuova e Modifica nella TextBox
|
|
Public bModify As Boolean = False
|
|
' flag per aggiunte, modifiche, eliminazioni
|
|
Public bIsModified As Boolean = False
|
|
|
|
' Definizione comandi
|
|
Private m_cmdNewMaterial As ICommand
|
|
Private m_cmdModifyMaterial As ICommand
|
|
Private m_cmdDeleteMaterial As ICommand
|
|
Private m_cmdNewSubMaterial As ICommand
|
|
Private m_cmdModifySubMaterial As ICommand
|
|
Private m_cmdDeleteSubMaterial As ICommand
|
|
Private m_cmdNewWjParam As ICommand
|
|
Private m_cmdDeleteWjParam As ICommand
|
|
Private m_cmdSave As ICommand
|
|
Private m_cmdDone As ICommand
|
|
Private m_cmdCancel As ICommand
|
|
Private m_cmdCloseWaterjetDb As ICommand
|
|
|
|
#End Region
|
|
|
|
#Region "MESSAGES"
|
|
|
|
Public ReadOnly Property Title_Msg As String
|
|
Get
|
|
Return EgtMsg(31751) ' Db Waterjet
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Thickness_Msg As String
|
|
Get
|
|
Return EgtMsg(31752) ' Spessore
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Flux_Msg As String
|
|
Get
|
|
Return "mg/min"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q1_Msg As String
|
|
Get
|
|
Return EgtMsg(31753) ' Q1
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q2_Msg As String
|
|
Get
|
|
Return EgtMsg(31754) ' Q2
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q3_Msg As String
|
|
Get
|
|
Return EgtMsg(31755) ' Q3
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q4_Msg As String
|
|
Get
|
|
Return EgtMsg(31756) ' Q4
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q5_Msg As String
|
|
Get
|
|
Return EgtMsg(31757) ' Q5
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property QExtra_Msg As String
|
|
Get
|
|
Return EgtMsg(31758) ' QExtra
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property AngComp_Msg As String
|
|
Get
|
|
Return "Ang"
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property New_Msg As String
|
|
Get
|
|
Return EgtMsg(31701) ' Nuovo
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Modify_Msg As String
|
|
Get
|
|
Return EgtMsg(31704) ' Modifica
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Delete_Msg As String
|
|
Get
|
|
Return EgtMsg(31703) ' Rimuovi
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Save_Msg As String
|
|
Get
|
|
Return EgtMsg(31702) ' Salva
|
|
End Get
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New(sMachDir As String)
|
|
' Creo riferimento a questa classe in LibMap
|
|
LibMap.SetRefWaterjetDbWindowVM(Me)
|
|
' Leggo valori da file INI e li carico nelle proprietà
|
|
m_MachDir = sMachDir
|
|
Dim sFilePath As String = MachDir & WATERJETDB_PATH
|
|
MaterialList = New ObservableCollection(Of WjMaterial)
|
|
MaterialList = LoadWjMaterials(sFilePath)
|
|
' Seleziono il primo Materiale della lista
|
|
If MaterialList.Count > 0 Then SelMaterial = MaterialList(0)
|
|
End Sub
|
|
|
|
#End Region ' Constructor
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "NewMaterialCommand"
|
|
|
|
Public ReadOnly Property NewMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdNewMaterial Is Nothing Then
|
|
m_cmdNewMaterial = New Command(AddressOf NewMaterial)
|
|
End If
|
|
Return m_cmdNewMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub NewMaterial(ByVal param As Object)
|
|
NewSubMaterial_Visibility = Visibility.Collapsed
|
|
NewMaterial_Visibility = Visibility.Visible
|
|
sNewMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewMaterial))
|
|
bModify = False
|
|
End Sub
|
|
|
|
#End Region ' NewMaterial
|
|
|
|
#Region "ModifyMaterialCommand"
|
|
|
|
Public ReadOnly Property ModifyMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdModifyMaterial Is Nothing Then
|
|
m_cmdModifyMaterial = New Command(AddressOf ModifyMaterial)
|
|
End If
|
|
Return m_cmdModifyMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ModifyMaterial(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial) Then
|
|
NewSubMaterial_Visibility = Visibility.Collapsed
|
|
NewMaterial_Visibility = Visibility.Visible
|
|
sNewMaterial = SelMaterial.Name
|
|
NotifyPropertyChanged(NameOf(sNewMaterial))
|
|
bModify = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ModifyMaterial
|
|
|
|
#Region "DeleteMaterialCommand"
|
|
|
|
Public ReadOnly Property DeleteMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdDeleteMaterial Is Nothing Then
|
|
m_cmdDeleteMaterial = New Command(AddressOf DeleteMaterial)
|
|
End If
|
|
Return m_cmdDeleteMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeleteMaterial(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial) Then
|
|
MaterialList.Remove(SelMaterial)
|
|
bIsModified = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' DeleteMaterial
|
|
|
|
#Region "NewSubMaterialCommand"
|
|
|
|
Public ReadOnly Property NewSubMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdNewSubMaterial Is Nothing Then
|
|
m_cmdNewSubMaterial = New Command(AddressOf NewSubMaterial)
|
|
End If
|
|
Return m_cmdNewSubMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub NewSubMaterial(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial) Then
|
|
NewMaterial_Visibility = Visibility.Collapsed
|
|
NewSubMaterial_Visibility = Visibility.Visible
|
|
sNewSubMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewSubMaterial))
|
|
bModify = False
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' NewSubMaterial
|
|
|
|
#Region "ModifyMaterialCommand"
|
|
|
|
Public ReadOnly Property ModifySubMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdModifySubMaterial Is Nothing Then
|
|
m_cmdModifySubMaterial = New Command(AddressOf ModifySubMaterial)
|
|
End If
|
|
Return m_cmdModifySubMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub ModifySubMaterial(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial.SelSubMaterial) Then
|
|
NewMaterial_Visibility = Visibility.Collapsed
|
|
NewSubMaterial_Visibility = Visibility.Visible
|
|
sNewSubMaterial = SelMaterial.SelSubMaterial.Name
|
|
NotifyPropertyChanged(NameOf(sNewSubMaterial))
|
|
bModify = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' ModifyMaterial
|
|
|
|
#Region "DeleteSubMaterialCommand"
|
|
|
|
Public ReadOnly Property DeleteSubMaterialCommand As ICommand
|
|
Get
|
|
If m_cmdDeleteSubMaterial Is Nothing Then
|
|
m_cmdDeleteSubMaterial = New Command(AddressOf DeleteSubMaterial)
|
|
End If
|
|
Return m_cmdDeleteSubMaterial
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeleteSubMaterial(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial.SelSubMaterial) Then
|
|
SelMaterial.SubMaterialList.Remove(SelMaterial.SelSubMaterial)
|
|
bIsModified = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' DeleteSubMaterial
|
|
|
|
#Region "NewWjParamCommand"
|
|
|
|
Public ReadOnly Property NewWjParamCommand As ICommand
|
|
Get
|
|
If m_cmdNewWjParam Is Nothing Then
|
|
m_cmdNewWjParam = New Command(AddressOf NewWjParam)
|
|
End If
|
|
Return m_cmdNewWjParam
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub NewWjParam(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial.SelSubMaterial) Then
|
|
Dim nId As Integer = 0
|
|
If IsNothing(SelMaterial.SelSubMaterial.ParamList) Then
|
|
nId = 1
|
|
SelMaterial.SelSubMaterial.ParamList = New ObservableCollection(Of WjParam)
|
|
Else
|
|
nId = SelMaterial.SelSubMaterial.ParamList.Count + 1
|
|
End If
|
|
SelMaterial.SelSubMaterial.ParamList.Add(New WjParam(nId, "0", "0", "0", "0", "0", "0", "0", "0", "0"))
|
|
SelMaterial.SelSubMaterial.NotifyPropertyChanged(NameOf(ParamList))
|
|
bIsModified = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' NewWjParam
|
|
|
|
#Region "DeleteWjParamCommand"
|
|
|
|
Public ReadOnly Property DeleteWjParamCommand As ICommand
|
|
Get
|
|
If m_cmdDeleteWjParam Is Nothing Then
|
|
m_cmdDeleteWjParam = New Command(AddressOf DeleteWjParam)
|
|
End If
|
|
Return m_cmdDeleteWjParam
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub DeleteWjParam(ByVal param As Object)
|
|
If Not IsNothing(SelMaterial.SelSubMaterial.SelWjParam) Then
|
|
SelMaterial.SelSubMaterial.ParamList.Remove(SelMaterial.SelSubMaterial.SelWjParam)
|
|
SelMaterial.SelSubMaterial.NotifyPropertyChanged(NameOf(ParamList))
|
|
bIsModified = True
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' DeleteWjParam
|
|
|
|
#Region "DoneCommand"
|
|
|
|
Public ReadOnly Property DoneCommand As ICommand
|
|
Get
|
|
If m_cmdDone Is Nothing Then
|
|
m_cmdDone = New Command(AddressOf Done)
|
|
End If
|
|
Return m_cmdDone
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Done(ByVal param As Object)
|
|
If NewMaterial_Visibility = Visibility.Visible Then
|
|
If bModify Then
|
|
Dim tempMat As WjMaterial = SelMaterial
|
|
tempMat.Name = sNewMaterial
|
|
Dim tempIndex As Integer = MaterialList.IndexOf(SelMaterial)
|
|
MaterialList.RemoveAt(tempIndex)
|
|
MaterialList.Insert(tempIndex, tempMat)
|
|
NotifyPropertyChanged(NameOf(MaterialList))
|
|
sNewMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewMaterial))
|
|
NewMaterial_Visibility = Visibility.Collapsed
|
|
bModify = False
|
|
Else
|
|
MaterialList.Add(New WjMaterial(sNewMaterial))
|
|
MaterialList.Last.SubMaterialList = New ObservableCollection(Of WjSubMaterial)
|
|
NotifyPropertyChanged(NameOf(MaterialList))
|
|
sNewMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewMaterial))
|
|
NewMaterial_Visibility = Visibility.Collapsed
|
|
End If
|
|
ElseIf NewSubMaterial_Visibility = Visibility.Visible Then
|
|
If bModify Then
|
|
Dim tempSubMat As WjSubMaterial = SelMaterial.SelSubMaterial
|
|
tempSubMat.Name = sNewSubMaterial
|
|
Dim tempIndex As Integer = SelMaterial.SubMaterialList.IndexOf(SelMaterial.SelSubMaterial)
|
|
SelMaterial.SubMaterialList.RemoveAt(tempIndex)
|
|
SelMaterial.SubMaterialList.Insert(tempIndex, tempSubMat)
|
|
NotifyPropertyChanged(NameOf(SubMaterialList))
|
|
sNewSubMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewSubMaterial))
|
|
NewSubMaterial_Visibility = Visibility.Collapsed
|
|
bModify = False
|
|
Else
|
|
SelMaterial.SubMaterialList.Add(New WjSubMaterial(sNewSubMaterial))
|
|
NotifyPropertyChanged(NameOf(SubMaterialList))
|
|
sNewSubMaterial = String.Empty
|
|
NotifyPropertyChanged(NameOf(sNewSubMaterial))
|
|
NewSubMaterial_Visibility = Visibility.Collapsed
|
|
End If
|
|
End If
|
|
bIsModified = True
|
|
End Sub
|
|
|
|
#End Region ' Done
|
|
|
|
#Region "SaveCommand"
|
|
|
|
Public ReadOnly Property SaveCommand As ICommand
|
|
Get
|
|
If m_cmdSave Is Nothing Then
|
|
m_cmdSave = New Command(AddressOf Save)
|
|
End If
|
|
Return m_cmdSave
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Save(ByVal param As Object)
|
|
WriteWaterjetDb()
|
|
bIsModified = False
|
|
End Sub
|
|
|
|
#End Region ' Save
|
|
|
|
#Region "CancelCommand"
|
|
|
|
Public ReadOnly Property CancelCommand As ICommand
|
|
Get
|
|
If m_cmdCancel Is Nothing Then
|
|
m_cmdCancel = New Command(AddressOf Cancel)
|
|
End If
|
|
Return m_cmdCancel
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Cancel(ByVal param As Object)
|
|
NewMaterial_Visibility = Visibility.Collapsed
|
|
NewSubMaterial_Visibility = Visibility.Collapsed
|
|
End Sub
|
|
|
|
#End Region ' Cancel
|
|
|
|
#Region "CloseWaterjetDbCommand"
|
|
|
|
Public ReadOnly Property CloseWaterjetDbCommand As ICommand
|
|
Get
|
|
If m_cmdCloseWaterjetDb Is Nothing Then
|
|
m_cmdCloseWaterjetDb = New Command(AddressOf CloseWaterjetDb)
|
|
End If
|
|
Return m_cmdCloseWaterjetDb
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub CloseWaterjetDb(ByVal param As Object)
|
|
If bIsModified Then
|
|
Select Case MsgBox(EgtMsg(31759), MsgBoxStyle.YesNoCancel, EgtMsg(31402))
|
|
'Select Case EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31759), EgtMsg(31402), MessageBoxButton.YesNoCancel) ' Salvare le modifiche? - SALVA
|
|
Case MsgBoxResult.Cancel
|
|
Return
|
|
Case MsgBoxResult.Yes
|
|
WriteWaterjetDb()
|
|
bIsModified = False
|
|
Case MsgBoxResult.No
|
|
RaiseEvent m_CloseWindow(True)
|
|
End Select
|
|
Else
|
|
Dim bExitFor As Boolean = False
|
|
For Each Material In MaterialList
|
|
If Not IsNothing(Material.SubMaterialList) Then
|
|
For Each SubMaterial In Material.SubMaterialList
|
|
If Not IsNothing(SubMaterial.ParamList) Then
|
|
For Each QParam In SubMaterial.ParamList
|
|
bExitFor = QParam.IsModified()
|
|
If bExitFor Then Exit For
|
|
Next
|
|
End If
|
|
If bExitFor Then Exit For
|
|
Next
|
|
End If
|
|
If bExitFor Then Exit For
|
|
Next
|
|
If bExitFor Then
|
|
Select Case MsgBox(EgtMsg(31759), MsgBoxStyle.YesNoCancel, EgtMsg(31402))
|
|
'Select Case EgtMessageBoxV.Show(Application.Current.MainWindow, EgtMsg(31759), EgtMsg(31402), MessageBoxButton.YesNoCancel) ' Salvare le modifiche? - SALVA
|
|
Case MsgBoxResult.Cancel
|
|
Return
|
|
Case MsgBoxResult.Yes
|
|
WriteWaterjetDb()
|
|
bIsModified = False
|
|
Case MsgBoxResult.No
|
|
RaiseEvent m_CloseWindow(True)
|
|
End Select
|
|
End If
|
|
End If
|
|
RaiseEvent m_CloseWindow(True)
|
|
End Sub
|
|
|
|
#End Region ' CloseWaterjetDb
|
|
|
|
#End Region ' Commands
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Shared Function LoadWjMaterials(sFilePath As String) As ObservableCollection(Of WjMaterial)
|
|
Dim MatList As New ObservableCollection(Of WjMaterial)
|
|
If File.Exists(sFilePath) Then
|
|
' recupero i Materiali
|
|
Dim sMaterial As String = String.Empty
|
|
Dim MatIndex As Integer = 1
|
|
While EgtUILib.GetPrivateProfileString(S_MATERIALS, MatIndex.ToString(), "", sMaterial, sFilePath) > 0
|
|
' recupero i Sottomateriali
|
|
Dim SubMatIndex As Integer = 1
|
|
Dim sSubMat As String = String.Empty
|
|
Dim SubMatList As New ObservableCollection(Of WjSubMaterial)
|
|
While EgtUILib.GetPrivateProfileString(sMaterial, SubMatIndex.ToString(), "", sSubMat, sFilePath) > 0
|
|
' recupero la lista dei Q
|
|
Dim QInd As Integer = 1
|
|
Dim sParam As String = String.Empty
|
|
Dim QParamList As New ObservableCollection(Of WjParam)
|
|
While EgtUILib.GetPrivateProfileString(sMaterial & "." & sSubMat, QInd.ToString(), "", sParam, sFilePath) > 0
|
|
Dim sParams() As String = sParam.Split(","c)
|
|
If sParams.Length() = 7 Then
|
|
QParamList.Add(New WjParam(QInd, sParams(0), sParams(1), sParams(2), sParams(3), sParams(4), sParams(5), sParams(6), "0", "250"))
|
|
ElseIf sParams.Length() = 8 Then
|
|
QParamList.Add(New WjParam(QInd, sParams(0), sParams(1), sParams(2), sParams(3), sParams(4), sParams(5), sParams(6), sParams(7), "250"))
|
|
ElseIf sParams.Length() > 8 Then
|
|
QParamList.Add(New WjParam(QInd, sParams(0), sParams(1), sParams(2), sParams(3), sParams(4), sParams(5), sParams(6), sParams(7), sParams(8)))
|
|
End If
|
|
QInd += 1
|
|
End While
|
|
SubMatList.Add(New WjSubMaterial(sSubMat, QParamList))
|
|
SubMatIndex += 1
|
|
End While
|
|
MatList.Add(New WjMaterial(sMaterial, SubMatList))
|
|
MatIndex += 1
|
|
End While
|
|
End If
|
|
Return MatList
|
|
End Function
|
|
|
|
Public Sub WriteWaterjetDb()
|
|
' cambio il nome del file INI attuale e ne riscrivo uno completamente nuovo
|
|
Dim sFilePath As String = MachDir & WATERJETDB_PATH
|
|
Dim sOldFilePath As String = MachDir & WATERJETDB_PATH & ".bak"
|
|
If File.Exists(sOldFilePath) Then File.Delete(sOldFilePath)
|
|
If File.Exists(sFilePath) Then FileSystem.Rename(sFilePath, sOldFilePath)
|
|
' scrivo la sezione dei Materiali
|
|
Dim MatIndex = 1
|
|
For Each Material In MaterialList
|
|
WritePrivateProfileString(S_MATERIALS, MatIndex.ToString, Material.Name &
|
|
If(MatIndex < MaterialList.Count, "", Environment.NewLine), sFilePath)
|
|
MatIndex += 1
|
|
If Not IsNothing(Material.SubMaterialList) AndAlso Material.SubMaterialList.Count > 0 Then
|
|
' scrivo la sezione dei Sottomateriali
|
|
Dim SubMatIndex As Integer = 1
|
|
For Each SubMaterial In Material.SubMaterialList
|
|
WritePrivateProfileString(Material.Name, SubMatIndex.ToString(), SubMaterial.Name &
|
|
If(SubMatIndex < Material.SubMaterialList.Count, "", Environment.NewLine), sFilePath)
|
|
SubMatIndex += 1
|
|
If Not IsNothing(SubMaterial.ParamList) AndAlso SubMaterial.ParamList.Count > 0 Then
|
|
' Scrivo la sezione dei Parametri dei Sottomateriali
|
|
Dim ParamIndex As Integer = 1
|
|
' riarrangio la lista dei Parametri per ordine crescente di Spessore
|
|
SubMaterial.ParamList = New ObservableCollection(Of WjParam)(SubMaterial.ParamList.OrderBy(Function(x) x.dThickness))
|
|
For Each ParamItem In SubMaterial.ParamList
|
|
Dim dThickness As Double
|
|
Dim dFlux As Double
|
|
Dim dQ1 As Double
|
|
Dim dQ2 As Double
|
|
Dim dQ3 As Double
|
|
Dim dQ4 As Double
|
|
Dim dQ5 As Double
|
|
Dim dQExtra As Double
|
|
Dim dAngComp As Double
|
|
Dim sValConverted As String = "0"
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Thickness, sValConverted)
|
|
StringToLen(sValConverted, dThickness)
|
|
StringToDouble(ParamItem.Flux, dFlux)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Q1, sValConverted)
|
|
StringToLen(sValConverted, dQ1)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Q2, sValConverted)
|
|
StringToLen(sValConverted, dQ2)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Q3, sValConverted)
|
|
StringToLen(sValConverted, dQ3)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Q4, sValConverted)
|
|
StringToLen(sValConverted, dQ4)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.Q5, sValConverted)
|
|
StringToLen(sValConverted, dQ5)
|
|
ParamItem.StringFractionToStringDecimal(ParamItem.QExtra, sValConverted)
|
|
StringToLen(sValConverted, dQExtra)
|
|
StringToDouble(ParamItem.dAngComp, dAngComp)
|
|
WritePrivateProfileString(Material.Name & "." & SubMaterial.Name, ParamIndex.ToString(),
|
|
DoubleToString(dThickness, 3) & "," &
|
|
DoubleToString(dQ1, 3) & "," &
|
|
DoubleToString(dQ2, 3) & "," &
|
|
DoubleToString(dQ3, 3) & "," &
|
|
DoubleToString(dQ4, 3) & "," &
|
|
DoubleToString(dQ5, 3) & "," &
|
|
DoubleToString(dQExtra, 3) & "," &
|
|
DoubleToString(dAngComp, 3) & "," &
|
|
DoubleToString(dFlux, 3) & If(ParamIndex < SubMaterial.ParamList.Count, "", Environment.NewLine), sFilePath)
|
|
ParamItem.IsModifiedReset()
|
|
ParamIndex += 1
|
|
Next
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' Methods
|
|
|
|
End Class
|
|
|
|
Public Class WjMaterial
|
|
Inherits VMBase
|
|
|
|
Private m_Name As String
|
|
Public Property Name As String
|
|
Get
|
|
Return m_Name
|
|
End Get
|
|
Set(value As String)
|
|
m_Name = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_SubMaterialList As ObservableCollection(Of WjSubMaterial)
|
|
Public Property SubMaterialList As ObservableCollection(Of WjSubMaterial)
|
|
Get
|
|
Return m_SubMaterialList
|
|
End Get
|
|
Set(value As ObservableCollection(Of WjSubMaterial))
|
|
m_SubMaterialList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_SelSubMaterial As WjSubMaterial
|
|
Public Property SelSubMaterial As WjSubMaterial
|
|
Get
|
|
Return m_SelSubMaterial
|
|
End Get
|
|
Set(value As WjSubMaterial)
|
|
m_SelSubMaterial = value
|
|
' Seleziono il primo WjParam della lista, se esiste
|
|
If Not IsNothing(m_SelSubMaterial) AndAlso Not IsNothing(m_SelSubMaterial.ParamList) AndAlso m_SelSubMaterial.ParamList.Count > 0 Then
|
|
m_SelSubMaterial.SelWjParam = m_SelSubMaterial.ParamList(0)
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(sName As String, SubMatList As ObservableCollection(Of WjSubMaterial))
|
|
m_Name = sName
|
|
m_SubMaterialList = SubMatList
|
|
End Sub
|
|
|
|
Sub New(sName As String)
|
|
m_Name = sName
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class WjSubMaterial
|
|
Inherits VMBase
|
|
|
|
Private m_Name As String
|
|
Public Property Name As String
|
|
Get
|
|
Return m_Name
|
|
End Get
|
|
Set(value As String)
|
|
m_Name = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_ParamList As ObservableCollection(Of WjParam)
|
|
Public Property ParamList As ObservableCollection(Of WjParam)
|
|
Get
|
|
Return m_ParamList
|
|
End Get
|
|
Set(value As ObservableCollection(Of WjParam))
|
|
m_ParamList = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property m_SelWjParam As WjParam
|
|
Public Property SelWjParam As WjParam
|
|
Get
|
|
Return m_SelWjParam
|
|
End Get
|
|
Set(value As WjParam)
|
|
m_SelWjParam = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New(sName As String, ParamList As ObservableCollection(Of WjParam))
|
|
m_Name = sName
|
|
m_ParamList = ParamList
|
|
End Sub
|
|
|
|
Sub New(sName As String)
|
|
m_Name = sName
|
|
End Sub
|
|
|
|
End Class
|
|
|
|
Public Class WjParam
|
|
|
|
Private m_Id As Integer
|
|
Public Property Id As Integer
|
|
Get
|
|
Return m_Id
|
|
End Get
|
|
Set(value As Integer)
|
|
m_Id = value
|
|
End Set
|
|
End Property
|
|
|
|
Private m_IsModifiedThickness As Boolean = False
|
|
Private m_Thickness As String
|
|
Public Property Thickness As String
|
|
Get
|
|
Return m_Thickness
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
' --- INIZIO --- conversione in fomra decimale
|
|
Dim sValue As String = value
|
|
StringFractionToStringDecimal(sValue, value)
|
|
Dim sOldValue As String = m_Thickness
|
|
StringFractionToStringDecimal(sOldValue, m_Thickness)
|
|
' --- FINE --- conversione in fomra decimale
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Thickness, dOldValue)
|
|
' se il valore inserito è già presente nella lista dei parametri del Sottomateriale corrente lo resetto al vecchio valore
|
|
If IsThicknessAlreadyPresent(dValue) Then
|
|
m_IsModifiedThickness = False
|
|
'm_Thickness = LenToString(dOldValue, 3)
|
|
m_Thickness = sOldValue
|
|
Else
|
|
m_IsModifiedThickness = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Thickness = sValue
|
|
End If
|
|
End Set
|
|
End Property
|
|
Public Sub SetThickness(sVal As String)
|
|
m_Thickness = sVal
|
|
End Sub
|
|
|
|
Public ReadOnly Property dThickness As Double
|
|
Get
|
|
Dim dValue As Double = 0
|
|
StringToLen(Thickness, dValue)
|
|
Return dValue
|
|
End Get
|
|
End Property
|
|
|
|
Private m_IsModifiedFlux As Boolean = False
|
|
Private m_Flux As String
|
|
Public Property Flux As String
|
|
Get
|
|
Return m_Flux
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Flux)
|
|
End Set
|
|
End Property
|
|
Public Sub SetFlux(Flux As String)
|
|
m_Flux = Flux
|
|
End Sub
|
|
|
|
Private m_IsModifiedQ1 As Boolean = False
|
|
Private m_Q1 As String
|
|
Public Property Q1 As String
|
|
Get
|
|
Return m_Q1
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Q1)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQ1(sVal As String)
|
|
m_Q1 = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedQ2 As Boolean = False
|
|
Private m_Q2 As String
|
|
Public Property Q2 As String
|
|
Get
|
|
Return m_Q2
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Q2)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQ2(sVal As String)
|
|
m_Q2 = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedQ3 As Boolean = False
|
|
Private m_Q3 As String
|
|
Public Property Q3 As String
|
|
Get
|
|
Return m_Q3
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Q3)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQ3(sVal As String)
|
|
m_Q3 = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedQ4 As Boolean = False
|
|
Private m_Q4 As String
|
|
Public Property Q4 As String
|
|
Get
|
|
Return m_Q4
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Q4)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQ4(sVal As String)
|
|
m_Q4 = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedQ5 As Boolean = False
|
|
Private m_Q5 As String
|
|
Public Property Q5 As String
|
|
Get
|
|
Return m_Q5
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_Q5)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQ5(sVal As String)
|
|
m_Q5 = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedQExtra As Boolean = False
|
|
Private m_QExtra As String
|
|
Public Property QExtra As String
|
|
Get
|
|
Return m_QExtra
|
|
End Get
|
|
Set(value As String)
|
|
ManageFraction(value, m_QExtra)
|
|
End Set
|
|
End Property
|
|
Public Sub SetQExtra(sVal As String)
|
|
m_QExtra = sVal
|
|
End Sub
|
|
|
|
Private m_IsModifiedAngComp As Boolean = False
|
|
Private m_dAngComp As String
|
|
Public Property dAngComp As String
|
|
Get
|
|
Return m_dAngComp
|
|
End Get
|
|
Set(value As String)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToDouble(value, dValue)
|
|
StringToDouble(m_dAngComp, dOldValue)
|
|
m_IsModifiedAngComp = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_dAngComp = value
|
|
End Set
|
|
End Property
|
|
Public Sub SetAngComp(sVal As String)
|
|
m_dAngComp = sVal
|
|
End Sub
|
|
|
|
Sub New(nId As Integer, dThickness As String, dQ1 As String, dQ2 As String, dQ3 As String, dQ4 As String, dQ5 As String, dQExtra As String)
|
|
m_Id = nId
|
|
m_Thickness = dThickness
|
|
m_Q1 = dQ1
|
|
m_Q2 = dQ2
|
|
m_Q3 = dQ3
|
|
m_Q4 = dQ4
|
|
m_Q5 = dQ5
|
|
m_QExtra = dQExtra
|
|
End Sub
|
|
|
|
Sub New(nId As Integer, dThickness As String, dQ1 As String, dQ2 As String, dQ3 As String, dQ4 As String, dQ5 As String, dQExtra As String, dAngComp As String, dFlux As String)
|
|
m_Id = nId
|
|
Dim dVal As Double
|
|
StringToDouble(dThickness, dVal)
|
|
m_Thickness = LenToString(dVal, 3)
|
|
StringToDouble(dQ1, dVal)
|
|
m_Q1 = LenToString(dVal, 3)
|
|
StringToDouble(dQ2, dVal)
|
|
m_Q2 = LenToString(dVal, 3)
|
|
StringToDouble(dQ3, dVal)
|
|
m_Q3 = LenToString(dVal, 3)
|
|
StringToDouble(dQ4, dVal)
|
|
m_Q4 = LenToString(dVal, 3)
|
|
StringToDouble(dQ5, dVal)
|
|
m_Q5 = LenToString(dVal, 3)
|
|
StringToDouble(dQExtra, dVal)
|
|
m_QExtra = LenToString(dVal, 3)
|
|
m_dAngComp = dAngComp
|
|
m_Flux = dFlux
|
|
End Sub
|
|
|
|
Public ReadOnly Property IsModified() As Boolean
|
|
Get
|
|
Return m_IsModifiedThickness OrElse
|
|
m_IsModifiedFlux OrElse
|
|
m_IsModifiedQ1 OrElse
|
|
m_IsModifiedQ2 OrElse
|
|
m_IsModifiedQ3 OrElse
|
|
m_IsModifiedQ4 OrElse
|
|
m_IsModifiedQ5 OrElse
|
|
m_IsModifiedQExtra
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub IsModifiedReset()
|
|
m_IsModifiedThickness = False
|
|
m_IsModifiedFlux = False
|
|
m_IsModifiedQ1 = False
|
|
m_IsModifiedQ2 = False
|
|
m_IsModifiedQ3 = False
|
|
m_IsModifiedQ4 = False
|
|
m_IsModifiedQ5 = False
|
|
m_IsModifiedQExtra = False
|
|
End Sub
|
|
|
|
' riceve la stringa sorgente (non EPSRESSIONE) e restituisce la nuova stringa in formato decimale (VALORE) (senza eseguire conversioni di unità)
|
|
Public Function OldStringFractionToStringDecimal(sVal As String, ByRef sValConverted As String) As Boolean
|
|
Dim dVal As Double = 0
|
|
' dato in ingresso: sVal = 2'3"23/32
|
|
Dim sFeet As String = String.Empty
|
|
Dim sFeetPattern As String = "(.*?)(?=')"
|
|
Dim dFeet As Double = 0
|
|
Dim bOkFeet As Boolean = True
|
|
Dim bFeetExists As Boolean = False
|
|
Dim sInch As String = String.Empty
|
|
Dim sInchPattern As String = "(?<=')(.*?)(?="")" ' se la stringa contiene l'apice singolo
|
|
Dim sInchPattern1 As String = "(.*?)(?="")" ' se la stringa NON contiene l'apice singolo
|
|
Dim sInchPattern2 As String = "(.*?)(?=\s+)" ' se la stringa NON contiene l'apice singolo
|
|
Dim dInch As Double = 0
|
|
Dim bOkInch As Boolean = True
|
|
Dim bInchExists As Boolean = False
|
|
Dim sFraction As String = String.Empty
|
|
Dim sFractionPattern As String = "(?<="")(.*)" ' se la stringa contiene l'apice doppio
|
|
Dim sFractionPattern1 As String = "(?<=')(.*)" ' se la stringa NON contiene l'apice doppio ma solo quello singolo
|
|
Dim sFractionPattern2 As String = "(?<=\s+)(.*)"
|
|
Dim dFraction As Double = 0
|
|
Dim bOkFraction As Boolean = True
|
|
Dim bFractionExists As Boolean = False
|
|
|
|
' recupero il valore di Feet (2')
|
|
Dim sMyMatch As String = Regex.Match(sVal, sFeetPattern).Groups(1).Value
|
|
If Not String.IsNullOrEmpty(sMyMatch) Or Not String.IsNullOrWhiteSpace(sMyMatch) Then
|
|
sFeet = sMyMatch.Trim
|
|
bOkFeet = StringToDouble(sFeet, dFeet)
|
|
bFeetExists = True
|
|
End If
|
|
|
|
' recupero il valore di Inch (3") dopo i Feet - oppure direttamente i pollici
|
|
If bFeetExists Then
|
|
sMyMatch = Regex.Match(sVal, sInchPattern).Groups(1).Value
|
|
Else
|
|
sMyMatch = Regex.Match(sVal, sInchPattern1).Groups(1).Value
|
|
End If
|
|
If Not String.IsNullOrEmpty(sMyMatch) Or Not String.IsNullOrWhiteSpace(sMyMatch) Then
|
|
sInch = sMyMatch.Trim
|
|
bOkInch = StringToDouble(sInch, dInch)
|
|
bInchExists = True
|
|
End If
|
|
|
|
' recupero il valore frazionario (23/32) dopo i pollici - oppure dopo i feet - oppure direttamente i valore inteso come pollici
|
|
If bInchExists Then
|
|
sMyMatch = Regex.Match(sVal, sFractionPattern).Groups(1).Value
|
|
ElseIf bFeetExists And Not bInchExists Then
|
|
sMyMatch = Regex.Match(sVal, sFractionPattern1).Groups(1).Value
|
|
ElseIf Not bFeetExists And Not bInchExists Then
|
|
sMyMatch = sVal
|
|
End If
|
|
If Not String.IsNullOrEmpty(sMyMatch) Or Not String.IsNullOrWhiteSpace(sMyMatch) Then
|
|
sFraction = sMyMatch
|
|
bOkFraction = StringToDouble(sFraction, dFraction)
|
|
End If
|
|
|
|
If Not bOkFeet Or Not bOkInch Or Not bOkFraction Then
|
|
bOkFeet = True
|
|
bOkInch = True
|
|
bOkFraction = True
|
|
|
|
' separo la stringa nello spazio
|
|
sMyMatch = Regex.Match(sVal, sInchPattern2).Groups(1).Value
|
|
If Not String.IsNullOrEmpty(sMyMatch) Or Not String.IsNullOrWhiteSpace(sMyMatch) Then
|
|
sInch = sMyMatch.Trim
|
|
bOkInch = StringToDouble(sInch, dInch)
|
|
bInchExists = True
|
|
End If
|
|
|
|
sMyMatch = Regex.Match(sVal, sFractionPattern2).Groups(1).Value
|
|
If Not String.IsNullOrEmpty(sMyMatch) Or Not String.IsNullOrWhiteSpace(sMyMatch) Then
|
|
sFraction = sMyMatch
|
|
bOkFraction = StringToDouble(sFraction, dFraction)
|
|
End If
|
|
End If
|
|
|
|
' calcolo il valore decimale dell'espressione
|
|
If bOkFeet And bOkInch And bOkFraction Then
|
|
dVal = dFeet * 12 + dInch + dFraction
|
|
sValConverted = DoubleToString(dVal, 4)
|
|
Return True
|
|
Else
|
|
Return False
|
|
End If
|
|
End Function
|
|
|
|
' riceve la stringa sorgente (ESPRESSIONE) e restituisce la nuova stringa in formato decimale (ESPRESSIONE) (senza eseguire conversioni di unità)
|
|
Public Function StringFractionToStringDecimal(sVal As String, ByRef sValConverted As String) As Boolean
|
|
sValConverted = sVal
|
|
' (-?) *(\d */? *\d*')? *(\d* */? *\d+-)? *(\d */? *\d* *""?)? *(\d */? *\d*)?
|
|
Dim sPattern As String = "(-?) *(\d */? *\d*')?( *(?(?=\d+ */ *\d+)\d+ */ *\d+|\d+)""?)*"
|
|
Dim MyMatchCollection As MatchCollection = Regex.Matches(sVal, sPattern)
|
|
|
|
For Each MyMatch As Match In MyMatchCollection
|
|
Dim bValueExists As Boolean = False
|
|
Dim bNegative As Boolean = False
|
|
Dim dFeet As Double = 0
|
|
Dim bFeet As Boolean = True
|
|
Dim dInch As Double = 0
|
|
Dim bInch As Boolean = True
|
|
Dim dFraction As Double = 0
|
|
Dim bFraction As Boolean = True
|
|
Dim sCurrValue As String = String.Empty
|
|
Dim sCurrValueConverted As String = String.Empty
|
|
Dim dCurrValueConverted As Double = 0
|
|
|
|
For GroupIndex As Integer = 0 To MyMatch.Groups.Count - 1
|
|
Dim MyGroup As Group = MyMatch.Groups(GroupIndex)
|
|
Dim sGroupVal As String = MyGroup.Value
|
|
' verifico che il gruppo non sia vuoto
|
|
If Not String.IsNullOrEmpty(sGroupVal) Or Not String.IsNullOrWhiteSpace(sGroupVal) Then
|
|
Select Case GroupIndex
|
|
Case 0
|
|
' se il valore è vuoto allora passo a prossimo Match
|
|
If String.IsNullOrEmpty(sGroupVal.Trim) Or String.IsNullOrWhiteSpace(sGroupVal.Trim) Then
|
|
Exit For
|
|
End If
|
|
' salvo il valore del membro dell'espressione che deve essere valutato
|
|
sCurrValue = sGroupVal
|
|
bValueExists = True
|
|
Case 1
|
|
' riconosco il segno "-" ad inizio stringa
|
|
bNegative = True
|
|
Case 2
|
|
' riconosco il valore di Feet " ' "
|
|
sGroupVal = sGroupVal.Replace("'"c, "")
|
|
bFeet = StringToDouble(sGroupVal, dFeet)
|
|
Case 3
|
|
For CaptureIndex As Integer = 0 To MyGroup.Captures.Count - 1
|
|
Dim MyCapture As Capture = MyGroup.Captures(CaptureIndex)
|
|
Dim sCapture As String = MyCapture.Value
|
|
Select Case CaptureIndex
|
|
Case 0
|
|
' riconosco il valore in pollici
|
|
sCapture = sCapture.Replace(""""c, "")
|
|
bInch = StringToDouble(sCapture, dInch)
|
|
Case 1
|
|
' riconosco il valore di frazione
|
|
bFraction = StringToDouble(sCapture, dFraction)
|
|
End Select
|
|
Next
|
|
End Select
|
|
End If
|
|
Next
|
|
|
|
If bValueExists And bFeet And bInch And bFraction Then
|
|
' ricavo il valore decimale
|
|
dCurrValueConverted = dFeet * 12 + dInch + dFraction
|
|
If bNegative Then dCurrValueConverted = -dCurrValueConverted
|
|
sCurrValueConverted = DoubleToString(dCurrValueConverted, 4)
|
|
' sostituisco il valore calcolato nell'espressione iniziale
|
|
Dim nStartIndex As Integer = sValConverted.IndexOf(sCurrValue)
|
|
sValConverted = sValConverted.Remove(nStartIndex, sCurrValue.Count).Insert(nStartIndex, sCurrValueConverted)
|
|
End If
|
|
' passo allavalutazione del prossimo membro dell'espressione
|
|
Next
|
|
Dim dValueConverted As Double = 0
|
|
If StringToDouble(sValConverted, dValueConverted) Then
|
|
sValConverted = DoubleToString(dValueConverted, 4)
|
|
Else
|
|
' Errore lettura stringa: sCurrVal non è convertibile
|
|
Return False
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Public Function ManageFraction(value As String, ByRef sParam As String) As Boolean
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
' --- INIZIO --- conversione in fomra decimale
|
|
Dim sValue As String = value
|
|
StringFractionToStringDecimal(sValue, value)
|
|
Dim sOldValue As String = sParam
|
|
StringFractionToStringDecimal(sOldValue, sParam)
|
|
' --- FINE --- conversione in fomra decimale
|
|
StringToLen(value, dValue)
|
|
StringToLen(sParam, dOldValue)
|
|
m_IsModifiedQExtra = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
sParam = sValue
|
|
Return True
|
|
End Function
|
|
|
|
End Class
|
|
|
|
Module WaterjetDbUtility
|
|
|
|
Public Function IsThicknessAlreadyPresent(value As Double) As Boolean
|
|
For Each WjParamItem In LibMap.refWaterjetDbWindowVM.SelMaterial.SelSubMaterial.ParamList
|
|
Dim dThickness As Double = 0
|
|
StringToLen(WjParamItem.Thickness, dThickness)
|
|
If Math.Abs(value - dThickness) <= 10 * EPS_ANG_SMALL Then
|
|
Return True
|
|
End If
|
|
Next
|
|
Return False
|
|
End Function
|
|
|
|
End Module
|