Imports System.IO
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5

Public Class ProjectFileVM
   Inherits VMBase

   Protected Shared m_sProjsDir As String
   Protected Shared m_sProdsDir As String

   Protected m_ProjectFileM As ProjectFileM

   Public Overridable ReadOnly Property nProjId As Integer
      Get
         Return m_ProjectFileM.nProjId
      End Get
   End Property
   Public Overridable ReadOnly Property sProjId As String
      Get
         Return m_ProjectFileM.nProjId.ToString("0000")
      End Get
   End Property

   Public Overridable ReadOnly Property nProdId As Integer
      Get
         Return m_ProjectFileM.nProdId
      End Get
   End Property
   Public Overridable ReadOnly Property sProdId As String
      Get
         Return m_ProjectFileM.nProdId.ToString("0000")
      End Get
   End Property

   Public Overridable ReadOnly Property sProjDirPath As String
      Get
         If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty
         Return m_sProjsDir & "\" & nProjId.ToString("0000")
      End Get
   End Property
   Public Overridable ReadOnly Property sProjPath As String
      Get
         Dim sPath As String = String.Empty
         If IsNothing(m_ProjectFileM.nProjId) OrElse m_ProjectFileM.nProjId = 0 Then Return String.Empty
         sPath = m_sProjsDir & "\" & nProjId.ToString("0000") & "\" & nProjId.ToString("0000") & ".nge"
         Return sPath
      End Get
   End Property

   Public Overridable ReadOnly Property sProdDirPath As String
      Get
         Dim sPath As String = String.Empty
         If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty
         Return m_sProdsDir & "\" & nProdId.ToString("0000")
      End Get
   End Property
   Public Overridable ReadOnly Property sProdPath As String
      Get
         Dim sPath As String = String.Empty
         If IsNothing(m_ProjectFileM.nProdId) OrElse m_ProjectFileM.nProdId = 0 Then Return String.Empty
         Return m_sProdsDir & "\" & nProdId.ToString("0000") & "\" & nProdId.ToString("0000") & ".nge"
      End Get
   End Property

   Public Overridable Property bIsNew As Boolean
      Get
         Return m_ProjectFileM.bIsNew
      End Get
      Set(value As Boolean)
         m_ProjectFileM.bIsNew = value
      End Set
   End Property

   Public Overridable Property bIsLocked As Boolean
      Get
         Return m_ProjectFileM.bIsLocked
      End Get
      Set(value As Boolean)
         m_ProjectFileM.bIsLocked = value
      End Set
   End Property

   Public ReadOnly Property dtCreateDate As DateTime
      Get
         Return m_ProjectFileM.dtCreateDate
      End Get
   End Property

   ' variabile che indica se ricaricare il progetto
   Protected m_bReloadProject As Boolean = True
   Public ReadOnly Property bReloadProject As Boolean
      Get
         Return m_bReloadProject
      End Get
   End Property

   Protected m_nModificationIndex As Integer = Integer.MaxValue - 1000
   Public ReadOnly Property nModificationIndex As Integer
      Get
         Return m_nModificationIndex
      End Get
   End Property
   Public Sub SetModificationIndex(value As String)
      m_nModificationIndex = value
   End Sub

   Public ReadOnly Property nType As BWType
      Get
         Return m_ProjectFileM.nType
      End Get
   End Property

   Public ReadOnly Property sMachine As String
      Get
         Return m_ProjectFileM.sMachine
      End Get
   End Property

   Public ReadOnly Property bIsActive As Boolean
      Get
         Return m_ProjectFileM.bIsActive
      End Get
   End Property

   Public ReadOnly Property bIsArchived As Boolean
      Get
         Return m_ProjectFileM.bIsArchived
      End Get
   End Property

#Region "Messages"

   Public ReadOnly Property Id_Msg As String
      Get
         Return EgtMsg(61815)
      End Get
   End Property
   Public ReadOnly Property BTLFileName_Msg As String
      Get
         Return EgtMsg(61819)
      End Get
   End Property
   Public ReadOnly Property ListName_Msg As String
      Get
         Return EgtMsg(61820)
      End Get
   End Property
   Public ReadOnly Property ExportDate_Msg As String
      Get
         Return EgtMsg(61821)
      End Get
   End Property
   Public ReadOnly Property CreateDate_Msg As String
      Get
         Return EgtMsg(61822)
      End Get
   End Property
   Public ReadOnly Property Name_Msg As String
      Get
         Return EgtMsg(61808)
      End Get
   End Property

#End Region    ' Messages

#Region "CONSTRUCTORS"

#End Region    ' CONSTRUCTORS

   Public Sub SetReloadProject(bValue As Boolean)
      m_bReloadProject = bValue
   End Sub

   Public Shared Sub Init(sProjsDir As String, sProdsDir As String)
      m_sProjsDir = sProjsDir
      m_sProdsDir = sProdsDir
   End Sub

   Public Sub SetMachine(sMachine)
      m_ProjectFileM.sMachine = sMachine
   End Sub

End Class