990 lines
31 KiB
VB.net
990 lines
31 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
'Imports EgtWPFLib
|
|
|
|
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)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Thickness_Msg As String
|
|
Get
|
|
Return EgtMsg(31752)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q1_Msg As String
|
|
Get
|
|
Return EgtMsg(31753)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q2_Msg As String
|
|
Get
|
|
Return EgtMsg(31754)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q3_Msg As String
|
|
Get
|
|
Return EgtMsg(31755)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q4_Msg As String
|
|
Get
|
|
Return EgtMsg(31756)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Q5_Msg As String
|
|
Get
|
|
Return EgtMsg(31757)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property QExtra_Msg As String
|
|
Get
|
|
Return EgtMsg(31758)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property New_Msg As String
|
|
Get
|
|
Return EgtMsg(31701)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Modify_Msg As String
|
|
Get
|
|
Return EgtMsg(31704)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Delete_Msg As String
|
|
Get
|
|
Return EgtMsg(31703)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Save_Msg As String
|
|
Get
|
|
Return EgtMsg(31702)
|
|
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))
|
|
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))
|
|
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))
|
|
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)))
|
|
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 dQ1 As Double
|
|
Dim dQ2 As Double
|
|
Dim dQ3 As Double
|
|
Dim dQ4 As Double
|
|
Dim dQ5 As Double
|
|
Dim dQExtra As Double
|
|
StringToLen(ParamItem.Thickness, dThickness)
|
|
StringToLen(ParamItem.Q1, dQ1)
|
|
StringToLen(ParamItem.Q2, dQ2)
|
|
StringToLen(ParamItem.Q3, dQ3)
|
|
StringToLen(ParamItem.Q4, dQ4)
|
|
StringToLen(ParamItem.Q5, dQ5)
|
|
StringToLen(ParamItem.QExtra, dQExtra)
|
|
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) & If(ParamIndex < SubMaterial.ParamList.Count, "", Environment.NewLine), sFilePath)
|
|
ParamItem.IsModifiedReset()
|
|
ParamIndex += 1
|
|
Next
|
|
End If
|
|
Next
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
'Public Function CloseWaterjetDb_OmagCut(MainWindow As Window) As SaveWndBtnEnum
|
|
' If bIsModified Then
|
|
' Dim SaveWjDbWnd As New EgtMsgBox(MainWindow, "", EgtMsg(31759), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
' Select Case SaveWjDbWnd.m_nPressedBtn
|
|
' Case 1 ' Yes
|
|
' WriteWaterjetDb()
|
|
' bIsModified = False
|
|
' Return SaveWndBtnEnum.YES
|
|
' Case 2 ' No
|
|
' Return SaveWndBtnEnum.NO
|
|
' Case Else ' Cancel
|
|
' Return SaveWndBtnEnum.CANCEL
|
|
' 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
|
|
' Dim SaveWjDbWnd As New EgtMsgBox(MainWindow, "", EgtMsg(31759), EgtMsgBox.Buttons.YES_NO_CANCEL, EgtMsgBox.Icons.NULL)
|
|
' Select Case SaveWjDbWnd.m_nPressedBtn
|
|
' Case 1 ' Yes
|
|
' WriteWaterjetDb()
|
|
' bIsModified = False
|
|
' Return SaveWndBtnEnum.YES
|
|
' Case 2 ' No
|
|
' Return SaveWndBtnEnum.NO
|
|
' Case Else ' Cancel
|
|
' Return SaveWndBtnEnum.CANCEL
|
|
' End Select
|
|
' End If
|
|
' End If
|
|
' Return SaveWndBtnEnum.YES
|
|
'End Function
|
|
|
|
#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
|
|
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)
|
|
Else
|
|
m_IsModifiedThickness = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Thickness = value
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
Public ReadOnly Property dThickness As Double
|
|
Get
|
|
Dim dValue As Double = 0
|
|
StringToLen(Thickness, dValue)
|
|
Return dValue
|
|
End Get
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Q1, dOldValue)
|
|
m_IsModifiedQ1 = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Q1 = value
|
|
End Set
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Q2, dOldValue)
|
|
m_IsModifiedQ2 = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Q2 = value
|
|
End Set
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Q3, dOldValue)
|
|
m_IsModifiedQ3 = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Q3 = value
|
|
End Set
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Q4, dOldValue)
|
|
m_IsModifiedQ4 = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Q4 = value
|
|
End Set
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_Q5, dOldValue)
|
|
m_IsModifiedQ5 = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_Q5 = value
|
|
End Set
|
|
End Property
|
|
|
|
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)
|
|
Dim dValue As Double = 0
|
|
Dim dOldValue As Double = 0
|
|
StringToLen(value, dValue)
|
|
StringToLen(m_QExtra, dOldValue)
|
|
m_IsModifiedQExtra = Math.Abs(dValue - dOldValue) > 10 * EPS_ANG_SMALL
|
|
m_QExtra = value
|
|
End Set
|
|
End Property
|
|
|
|
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
|
|
|
|
Public ReadOnly Property IsModified() As Boolean
|
|
Get
|
|
Return m_IsModifiedThickness 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_IsModifiedQ1 = False
|
|
m_IsModifiedQ2 = False
|
|
m_IsModifiedQ3 = False
|
|
m_IsModifiedQ4 = False
|
|
m_IsModifiedQ5 = False
|
|
m_IsModifiedQExtra = False
|
|
End Sub
|
|
|
|
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
|