Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports EgtWPFLib

' nuova libreria EgtWPFLib5 ver 2.4g1
Public Class WaterjetDbWindowVM_OmagCUT
   Inherits EgtWPFLib5.WaterjetDbWindowVM

   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 As EgtWPFLib5.WjMaterial In MaterialList
            If Not IsNothing(Material.SubMaterialList) Then
               For Each SubMaterial As EgtWPFLib5.WjSubMaterial In Material.SubMaterialList
                  If Not IsNothing(SubMaterial.ParamList) Then
                     For Each QParam As EgtWPFLib5.WjParam 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

   Sub New(sMachDir As String)
      MyBase.New(sMachDir)
   End Sub

End Class
