Imports EgtUILib

Module CamPolishing

   Private m_MainWindow As MainWindow = DirectCast(Application.Current.MainWindow, MainWindow)

   Friend Function AddPolishings( sKitName As String, nContourId As Integer) As Boolean
      EgtLuaCreateGlobTable( "POLI")
      Dim nErr As Integer = 999
      Dim bOk As Boolean = EgtLuaExecFile( m_MainWindow.GetCamAutoDir() & "\Polishing.lua")
      bOk = bOk AndAlso EgtLuaGetGlobIntVar( "POLI.ERR", nErr) AndAlso nErr = 0
      EgtLuaSetGlobStringVar( "POLI.KITNAME", sKitName)
      EgtLuaSetGlobIntVar( "POLI.CNTID", nContourId)
      bOk = bOk AndAlso EgtLuaCallFunction( "POLI.Add")
      EgtLuaGetGlobIntVar( "POLI.ERR", nErr)
      EgtLuaResetGlobVar( "POLI")
      If nErr <> 0 Then
         bOk = False
         EgtOutLog("Error in Polishing.Add : " & nErr.ToString())
      End If
      Return bOk
   End Function

   Friend Function RemovePolishings() As Boolean
      EgtLuaCreateGlobTable( "POLI")
      Dim nErr As Integer = 999
      Dim bOk As Boolean = EgtLuaExecFile( m_MainWindow.GetCamAutoDir() & "\Polishing.lua")
      bOk = bOk AndAlso EgtLuaGetGlobIntVar( "POLI.ERR", nErr) AndAlso nErr = 0
      bOk = bOk AndAlso EgtLuaCallFunction( "POLI.Remove")
      EgtLuaGetGlobIntVar( "POLI.ERR", nErr)
      EgtLuaResetGlobVar( "POLI")
      If nErr <> 0 Then
         bOk = False
         EgtOutLog("Error in Polishing.Remove : " & nErr.ToString())
      End If
      Return bOk
   End Function

End Module
